- Joined
- Jul 31, 2012
- Messages
- 2,217
actually, this is the need of the dummy.mdl , attach Fxs on it 
anyway Bon8
anyway Bon8
function ApplyDPS takes unit target, unit source, real amount, real timeout returns nothing
//Damage Type is SPELL, Attack Type is MAGIC
function AddTimedStatBonus takes unit hero, integer amount, integer statType, real timeout returns nothing
target
from source
by amount
damage every second for timeout
secondslibrary DoT
globals
private constant real FPS = 0.0312500
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 instanceCount
private thistype prev
private thistype next
private static timer period
private static method iterate takes nothing returns nothing
local thistype this = thistype(0)
local integer i
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 instanceCount = instanceCount + 1
set this = instanceCount
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 instanceCount = 0
set period = CreateTimer()
endmethod
endstruct
endlibrary
caster
deals dmg
to target
every interval
during during
library TimedStats
globals
private constant real FPS = 0.0312500
endglobals
//1 : Strength
//2 : Agility
//3 : Intelligence
struct TimedStats extends array
private unit targ
private real temp
private integer amount
private integer type
private thistype prev
private thistype next
private static timer period
private static integer count
private static HandleTable tab
private static method periodic 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 < 0 then
if this.type==1 then
call SetHeroStr(this.targ, GetHeroStr(this.targ, false)-this.amount, false)
elseif this.type==2 then
call SetHeroAgi(this.targ, GetHeroAgi(this.targ, false)-this.amount, false)
elseif this.type==3 then
call SetHeroInt(this.targ, GetHeroInt(this.targ, false)-this.amount, false)
debug else
debug call BJDebugMsg("You entered the wrong number for the stats thingy")
endif
call this.destroy()
endif
endloop
endmethod
static method AddTimedStatBonus takes unit targ, integer i, integer stats, real time returns nothing
local thistype this
if thistype(0).prev == 0 then
set this = thistype(0).prev
set thistype(0).prev = thistype(0).prev.prev
else
set count = count + 1
set this = count
endif
if thistype(0).next == 0 then
call TimerStart(period, FPS, true, function thistype.periodic)
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.targ = targ
set this.amount = i
set this.type = stats
set this.temp = time
if i==1 then
call SetHeroStr(targ, GetHeroStr(targ, false)+amount, false)
elseif i==2 then
call SetHeroAgi(targ, GetHeroAgi(targ, false)+amount, false)
elseif i==3 then
call SetHeroInt(targ, GetHeroInt(targ, false)+amount, false)
debug else
debug call BJDebugMsg("You're giving wrong number for the stats thingy")
endif
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.targ = null
endmethod
private static method onInit takes nothing returns nothing
set count = 0
set period = CreateTimer()
set tab = HandleTable.create()
endmethod
endstruct
endlibrary
call AddTimedStatBonus(unit, integer, integer, real)
no each addition is individualYou want this to refresh the timeout each time it happens ?
call TimedStats.AddTimedStatBonus(targ,amount,typeOfStats,timeout)
library DoT
globals
private constant real FPS = 0.100
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 instanceCount
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 instanceCount = instanceCount + 1
set this = instanceCount
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 instanceCount = 0
set period = CreateTimer()
endmethod
endstruct
endlibrary
I'm using an integer if I see wellOh and don't use a real for an iterator countdown