• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

BotL - Coding & Systems

Status
Not open for further replies.
Level 18
Joined
Sep 14, 2012
Messages
3,413
What the .... are you saying xD ?

Anyway I'll suggest this when creating spell :
JASS:
scope SpellName
//CONFIGURATION
    globals
        private constant integer SPELL_ID = 'XXXX'
        //Some more things that needs configuration
    endglobals

    //Some private constant function that could be cool like damage calculation or something
//END CONFIGURATION

    private struct SpellName extends array
        private static method cond takes nothing returns boolean
            //Do the stuff
            return false
        endmethod
        
        private static method onInit takes nothing returns nothing
            local trigger t = CreateTrigger()
            call TriggerRegisterAnyUnitEvent(t, ....)
            call TriggerAddCondition(t, Condition(function thistype.cond))
            set t = null
        endmethod
    endstruct
endscope
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
The initial damage won't cause the bug though... I see you really don't trust me, instinct tells you my suggestion causes bugs. I'm rage-quitting this shit.
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
Try this for DoT I just tested it and no problem :
JASS:
library DoT
    globals
        private constant real FPS = 0.0100
    endglobals
    
    struct DoT extends array
        private unit caster
        private unit target
        private real interval   
        private real during
        private real dmg
        private real temp
        private static integer count
        private thistype prev
        private thistype next
        private static timer period
        
        private static method iterate takes nothing returns nothing
            local thistype this = thistype(0)
            loop
                set this = this.next
                exitwhen this == 0
                set this.temp = this.temp + FPS
                if this.temp >= this.interval then
                    call UnitDamageTarget(this.caster, this.target, this.dmg, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null)
                    set this.temp = this.temp-this.interval
                endif
                set this.during = this.during - FPS
                if this.during <= 0 then
                    call this.destroy()
                endif
            endloop
        endmethod
        
        static method add takes unit cast, unit targ, real dur, real inter, real dm returns nothing
            local thistype this
            
            if thistype(0).prev == 0 then
                set count = count + 1
                set this = count
            else
                set this = thistype(0).prev
                set thistype(0).prev = thistype(0).prev.prev
            endif
            
            if thistype(0).next == 0 then
                call TimerStart(period, FPS, true, function thistype.iterate)
            else
                set thistype(0).next.prev = this
            endif
            
            set this.next = thistype(0).next
            set thistype(0).next = this
            set this.prev = thistype(0)
            
            set this.caster = cast
            set this.target = targ
            set this.interval = inter
            set this.during = dur
            set this.dmg = dm
            set this.temp = 0
        endmethod

        private method destroy takes nothing returns nothing
            if this.next != 0 then
                set this.next.prev = this.prev
            endif
            
            set this.prev.next = this.next
            set this.prev = thistype(0).prev
            set thistype(0).prev = this
        
            if thistype(0).next == 0 then
                call PauseTimer(period)
            endif

            set this.caster = null
            set this.target = null
        endmethod
        
        private static method onInit takes nothing returns nothing
            set count = 0
            set period = CreateTimer()
        endmethod
    endstruct
endlibrary
 
Status
Not open for further replies.
Top