Name | Type | is_array | initial_value |
//TESH.scrollpos=47
//TESH.alwaysfold=0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~ Timer32 ~~ By Jesus4Lyf ~~ Version 1.06 ~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// What is Timer32?
// - Timer32 implements a fully optimised timer loop for a struct.
// - Instances can be added to the loop, which will call .periodic every
// PERIOD until .stopPeriodic() is called.
//
// =Pros=
// - Efficient.
// - Simple.
//
// =Cons=
// - Only allows one period.
// - The called method must be named ".periodic".
//
// Methods:
// - struct.startPeriodic()
// - struct.stopPeriodic()
//
// - private method periodic takes nothing returns nothing
//
// This must be defined in structs that implement Periodic Module.
// It will be executed by the module every PERIOD until .stopPeriodic() is called.
// Put "implement T32x" BELOW this method.
//
// Modules:
// - T32x
// Has no safety on .stopPeriodic or .startPeriodic (except debug messages
// to warn).
//
// - T32xs
// Has safety on .stopPeriodic and .startPeriodic so if they are called
// multiple times, or while otherwise are already stopped/started respectively,
// no error will occur, the call will be ignored.
//
// - T32
// The original, old version of the T32 module. This remains for backwards
// compatability, and is deprecated. The periodic method must return a boolean,
// false to continue running or true to stop.
//
// Details:
// - Uses one timer.
//
// - Do not, within a .periodic method, follow a .stopPeriodic call with a
// .startPeriodic call.
//
// How to import:
// - Create a trigger named T32.
// - Convert it to custom text and replace the whole trigger text with this.
//
// Thanks:
// - Infinitegde for finding a bug in the debug message that actually altered
// system operation (when in debug mode).
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
library T32 initializer OnInit
globals
public constant real PERIOD=0.03125
public constant integer FPS=R2I(1/PERIOD)
public integer Tick=0 // very useful.
//==============================================================================
private trigger Trig=CreateTrigger()
endglobals
//==============================================================================
// The standard T32 module, T32x.
//
module T32x
private thistype next
private thistype prev
private static method PeriodicLoop takes nothing returns boolean
local thistype this=thistype(0).next
loop
exitwhen this==0
call this.periodic()
set this=this.next
endloop
return false
endmethod
method startPeriodic takes nothing returns nothing
debug if this.prev!=0 or thistype(0).next==this then
debug call BJDebugMsg("T32 ERROR: Struct #"+I2S(this)+" had startPeriodic called while already running!")
debug endif
set thistype(0).next.prev=this
set this.next=thistype(0).next
set thistype(0).next=this
set this.prev=thistype(0)
endmethod
method stopPeriodic takes nothing returns nothing
debug if this.prev==0 and thistype(0).next!=this then
debug call BJDebugMsg("T32 ERROR: Struct #"+I2S(this)+" had stopPeriodic called while not running!")
debug endif
// This is some real magic.
set this.prev.next=this.next
set this.next.prev=this.prev
// This will even work for the starting element.
debug set this.prev=0
endmethod
private static method onInit takes nothing returns nothing
call TriggerAddCondition(Trig,Condition(function thistype.PeriodicLoop))
endmethod
endmodule
//==============================================================================
// The standard T32 module with added safety checks on .startPeriodic() and
// .stopPeriodic(), T32xs.
//
module T32xs
private thistype next
private thistype prev
private boolean runningPeriodic
private static method PeriodicLoop takes nothing returns boolean
local thistype this=thistype(0).next
loop
exitwhen this==0
call this.periodic()
set this=this.next
endloop
return false
endmethod
method startPeriodic takes nothing returns nothing
if not this.runningPeriodic then
set thistype(0).next.prev=this
set this.next=thistype(0).next
set thistype(0).next=this
set this.prev=thistype(0)
set this.runningPeriodic=true
endif
endmethod
method stopPeriodic takes nothing returns nothing
if this.runningPeriodic then
// This is some real magic.
set this.prev.next=this.next
set this.next.prev=this.prev
// This will even work for the starting element.
set this.runningPeriodic=false
endif
endmethod
private static method onInit takes nothing returns nothing
call TriggerAddCondition(Trig,Condition(function thistype.PeriodicLoop))
endmethod
endmodule
//==============================================================================
// The original T32 module, for backwards compatability only.
//
module T32 // deprecated.
private thistype next
private thistype prev
private static method PeriodicLoop takes nothing returns boolean
local thistype this=thistype(0).next
loop
exitwhen this==0
if this.periodic() then
// This is some real magic.
set this.prev.next=this.next
set this.next.prev=this.prev
// This will even work for the starting element.
debug set this.prev=0
endif
set this=this.next
endloop
return false
endmethod
method startPeriodic takes nothing returns nothing
debug if this.prev!=0 or thistype(0).next==this then
debug call BJDebugMsg("T32 ERROR: Struct #"+I2S(this)+" had startPeriodic called while already running!")
debug endif
set thistype(0).next.prev=this
set this.next=thistype(0).next
set thistype(0).next=this
set this.prev=thistype(0)
endmethod
private static method onInit takes nothing returns nothing
call TriggerAddCondition(Trig,Condition(function thistype.PeriodicLoop))
endmethod
endmodule
//==============================================================================
// System Core.
//
private function OnExpire takes nothing returns nothing
set Tick=Tick+1
call TriggerEvaluate(Trig)
endfunction
private function OnInit takes nothing returns nothing
call TimerStart(CreateTimer(),PERIOD,true,function OnExpire)
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Table /* made by Bribe, special thanks to Vexorian & Nestharus, version 3.1.0.1
One map, one hashtable. Welcome to NewTable 3.1
This library was originally called NewTable so it didn't conflict with
the API of Table by Vexorian. However, the damage is done and it's too
late to change the library name now. To help with damage control, I
have provided an extension library called TableBC, which bridges all
the functionality of Vexorian's Table except for 2-D string arrays &
the ".flush(integer)" method. I use ".flush()" to flush a child hash-
table, because I wanted the API in NewTable to reflect the API of real
hashtables (I thought this would be more intuitive).
API
------------
struct Table
| static method create takes nothing returns Table
| create a new Table
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush all stored values inside of it
|
| method remove takes integer key returns nothing
| remove the value at index "key"
|
| method operator []= takes integer key, $TYPE$ value returns nothing
| assign "value" to index "key"
|
| method operator [] takes integer key returns $TYPE$
| load the value at index "key"
|
| method has takes integer key returns boolean
| whether or not the key was assigned
|
----------------
struct TableArray
| static method operator [] takes integer array_size returns TableArray
| create a new array of Tables of size "array_size"
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush and destroy it
|
| method operator size takes nothing returns integer
| returns the size of the TableArray
|
| method operator [] takes integer key returns Table
| returns a Table accessible exclusively to index "key"
*/
globals
private integer less = 0 //Index generation for TableArrays (below 0).
private integer more = 8190 //Index generation for Tables.
//Configure it if you use more than 8190 "key" variables in your map (this will never happen though).
private hashtable ht = InitHashtable()
private key sizeK
private key listK
endglobals
private struct dex extends array
static method operator size takes nothing returns Table
return sizeK
endmethod
static method operator list takes nothing returns Table
return listK
endmethod
endstruct
private struct handles extends array
method has takes integer key returns boolean
return HaveSavedHandle(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSavedHandle(ht, this, key)
endmethod
endstruct
private struct agents extends array
method operator []= takes integer key, agent value returns nothing
call SaveAgentHandle(ht, this, key, value)
endmethod
endstruct
//! textmacro NEW_ARRAY_BASIC takes SUPER, FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$(ht, this, key, value)
endmethod
method has takes integer key returns boolean
return HaveSaved$SUPER$(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSaved$SUPER$(ht, this, key)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//! textmacro NEW_ARRAY takes FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$Handle(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$Handle(ht, this, key, value)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//Run these textmacros to include the entire hashtable API as wrappers.
//Don't be intimidated by the number of macros - Vexorian's map optimizer is
//supposed to kill functions which inline (all of these functions inline).
//! runtextmacro NEW_ARRAY_BASIC("Real", "Real", "real")
//! runtextmacro NEW_ARRAY_BASIC("Boolean", "Boolean", "boolean")
//! runtextmacro NEW_ARRAY_BASIC("String", "Str", "string")
//! runtextmacro NEW_ARRAY("Player", "player")
//! runtextmacro NEW_ARRAY("Widget", "widget")
//! runtextmacro NEW_ARRAY("Destructable", "destructable")
//! runtextmacro NEW_ARRAY("Item", "item")
//! runtextmacro NEW_ARRAY("Unit", "unit")
//! runtextmacro NEW_ARRAY("Ability", "ability")
//! runtextmacro NEW_ARRAY("Timer", "timer")
//! runtextmacro NEW_ARRAY("Trigger", "trigger")
//! runtextmacro NEW_ARRAY("TriggerCondition", "triggercondition")
//! runtextmacro NEW_ARRAY("TriggerAction", "triggeraction")
//! runtextmacro NEW_ARRAY("TriggerEvent", "event")
//! runtextmacro NEW_ARRAY("Force", "force")
//! runtextmacro NEW_ARRAY("Group", "group")
//! runtextmacro NEW_ARRAY("Location", "location")
//! runtextmacro NEW_ARRAY("Rect", "rect")
//! runtextmacro NEW_ARRAY("BooleanExpr", "boolexpr")
//! runtextmacro NEW_ARRAY("Sound", "sound")
//! runtextmacro NEW_ARRAY("Effect", "effect")
//! runtextmacro NEW_ARRAY("UnitPool", "unitpool")
//! runtextmacro NEW_ARRAY("ItemPool", "itempool")
//! runtextmacro NEW_ARRAY("Quest", "quest")
//! runtextmacro NEW_ARRAY("QuestItem", "questitem")
//! runtextmacro NEW_ARRAY("DefeatCondition", "defeatcondition")
//! runtextmacro NEW_ARRAY("TimerDialog", "timerdialog")
//! runtextmacro NEW_ARRAY("Leaderboard", "leaderboard")
//! runtextmacro NEW_ARRAY("Multiboard", "multiboard")
//! runtextmacro NEW_ARRAY("MultiboardItem", "multiboarditem")
//! runtextmacro NEW_ARRAY("Trackable", "trackable")
//! runtextmacro NEW_ARRAY("Dialog", "dialog")
//! runtextmacro NEW_ARRAY("Button", "button")
//! runtextmacro NEW_ARRAY("TextTag", "texttag")
//! runtextmacro NEW_ARRAY("Lightning", "lightning")
//! runtextmacro NEW_ARRAY("Image", "image")
//! runtextmacro NEW_ARRAY("Ubersplat", "ubersplat")
//! runtextmacro NEW_ARRAY("Region", "region")
//! runtextmacro NEW_ARRAY("FogState", "fogstate")
//! runtextmacro NEW_ARRAY("FogModifier", "fogmodifier")
//! runtextmacro NEW_ARRAY("Hashtable", "hashtable")
struct Table extends array
// Implement modules for intuitive syntax (tb.handle; tb.unit; etc.)
implement realm
implement booleanm
implement stringm
implement playerm
implement widgetm
implement destructablem
implement itemm
implement unitm
implement abilitym
implement timerm
implement triggerm
implement triggerconditionm
implement triggeractionm
implement eventm
implement forcem
implement groupm
implement locationm
implement rectm
implement boolexprm
implement soundm
implement effectm
implement unitpoolm
implement itempoolm
implement questm
implement questitemm
implement defeatconditionm
implement timerdialogm
implement leaderboardm
implement multiboardm
implement multiboarditemm
implement trackablem
implement dialogm
implement buttonm
implement texttagm
implement lightningm
implement imagem
implement ubersplatm
implement regionm
implement fogstatem
implement fogmodifierm
implement hashtablem
method operator handle takes nothing returns handles
return this
endmethod
method operator agent takes nothing returns agents
return this
endmethod
//set this = tb[GetSpellAbilityId()]
method operator [] takes integer key returns Table
return LoadInteger(ht, this, key)
endmethod
//set tb[389034] = 8192
method operator []= takes integer key, Table tb returns nothing
call SaveInteger(ht, this, key, tb)
endmethod
//set b = tb.has(2493223)
method has takes integer key returns boolean
return HaveSavedInteger(ht, this, key)
endmethod
//call tb.remove(294080)
method remove takes integer key returns nothing
call RemoveSavedInteger(ht, this, key)
endmethod
//Remove all data from a Table instance
method flush takes nothing returns nothing
call FlushChildHashtable(ht, this)
endmethod
//local Table tb = Table.create()
static method create takes nothing returns Table
local Table this = dex.list[0]
if this == 0 then
set this = more + 1
set more = this
else
set dex.list[0] = dex.list[this]
call dex.list.remove(this) //Clear hashed memory
endif
debug set dex.list[this] = -1
return this
endmethod
// Removes all data from a Table instance and recycles its index.
//
// call tb.destroy()
//
method destroy takes nothing returns nothing
debug if dex.list[this] != -1 then
debug call BJDebugMsg("Table Error: Tried to double-free instance: " + I2S(this))
debug return
debug endif
call this.flush()
set dex.list[this] = dex.list[0]
set dex.list[0] = this
endmethod
//! runtextmacro optional TABLE_BC_METHODS()
endstruct
//! runtextmacro optional TABLE_BC_STRUCTS()
struct TableArray extends array
//Returns a new TableArray to do your bidding. Simply use:
//
// local TableArray ta = TableArray[array_size]
//
static method operator [] takes integer array_size returns TableArray
local Table tb = dex.size[array_size] //Get the unique recycle list for this array size
local TableArray this = tb[0] //The last-destroyed TableArray that had this array size
debug if array_size <= 0 then
debug call BJDebugMsg("TypeError: Invalid specified TableArray size: " + I2S(array_size))
debug return 0
debug endif
if this == 0 then
set this = less - array_size
set less = this
else
set tb[0] = tb[this] //Set the last destroyed to the last-last destroyed
call tb.remove(this) //Clear hashed memory
endif
set dex.size[this] = array_size //This remembers the array size
return this
endmethod
//Returns the size of the TableArray
method operator size takes nothing returns integer
return dex.size[this]
endmethod
//This magic method enables two-dimensional[array][syntax] for Tables,
//similar to the two-dimensional utility provided by hashtables them-
//selves.
//
//ta[integer a].unit[integer b] = unit u
//ta[integer a][integer c] = integer d
//
//Inline-friendly when not running in debug mode
//
method operator [] takes integer key returns Table
static if DEBUG_MODE then
local integer i = this.size
if i == 0 then
call BJDebugMsg("IndexError: Tried to get key from invalid TableArray instance: " + I2S(this))
return 0
elseif key < 0 or key >= i then
call BJDebugMsg("IndexError: Tried to get key [" + I2S(key) + "] from outside TableArray bounds: " + I2S(i))
return 0
endif
endif
return this + key
endmethod
//Destroys a TableArray without flushing it; I assume you call .flush()
//if you want it flushed too. This is a public method so that you don't
//have to loop through all TableArray indices to flush them if you don't
//need to (ie. if you were flushing all child-keys as you used them).
//
method destroy takes nothing returns nothing
local Table tb = dex.size[this.size]
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to destroy an invalid TableArray: " + I2S(this))
debug return
debug endif
if tb == 0 then
//Create a Table to index recycled instances with their array size
set tb = Table.create()
set dex.size[this.size] = tb
endif
call dex.size.remove(this) //Clear the array size from hash memory
set tb[this] = tb[0]
set tb[0] = this
endmethod
private static Table tempTable
private static integer tempEnd
//Avoids hitting the op limit
private static method clean takes nothing returns nothing
local Table tb = .tempTable
local integer end = tb + 0x1000
if end < .tempEnd then
set .tempTable = end
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
else
set end = .tempEnd
endif
loop
call tb.flush()
set tb = tb + 1
exitwhen tb == end
endloop
endmethod
//Flushes the TableArray and also destroys it. Doesn't get any more
//similar to the FlushParentHashtable native than this.
//
method flush takes nothing returns nothing
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to flush an invalid TableArray instance: " + I2S(this))
debug return
debug endif
set .tempTable = this
set .tempEnd = this + this.size
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
call this.destroy()
endmethod
endstruct
endlibrary
//TESH.scrollpos=49
//TESH.alwaysfold=0
/*Stigma System by Adiktuz
Version 2.01
Requires:
T32 - http://www.thehelper.net/forums/showthread.php/132538-Timer32
Table - http://www.hiveworkshop.com/forums/jass-resources-412/snippet-new-table-188084/
Description:
Inflicts damage every interval to the target depending of the difference between its max life and
its current life.
If you play DotA, you can think of this spell as a DamageOverTime reaper's scythe
You can modify the amount of damage, total duration and damage interval with each call of the function
You can also have multiple spells that use this library and supports multi-level spells
System is MUI
Also, the effect of Stigma can stack up on individual units if a spell using the system is casted unpon them successively.
the stacking effect works for every spell using stigma
How to use
just call the function:
Stigma.create(unit target, unit caster, real interval, real totalduration, boolean usebuff, attacktype at,
damagetype dt, real percent, string buffeffect, string damageeffect, string apoint, integer abil)
unit target is the unit to be afflicted by stigma
unit caster is the unit who caused the stigma
real interval is the interval in seconds in which the damage occurs
real totalduration is the duration of the stigma in seconds
For best results use reals divisible by .03
attacktype at is the attack type of the spell
damagetype dt is the damage type of the spell
real percent if the multiplier of the difference between the units maxlife and its current life to be dealt as damage per interval
string buffeffect is the effect that attaches to the unit during the duration of stigma
string damageeffect is the effect played every damage interval
string apoint is the attachment point of the effects
integer abil is the rawcode of the spell
If you need simpler functions:
Without attacktype,damagetype and damageeffect settings:
Stigma.Simple(unit target, unit caster, real interval, real totalduration,
real percent, string buffeffect, integer abil)
Further without buffeffect
Stigma.Simpler(unit target, unit caster, real interval, real totalduration,
real percent, integer abil)
Registering onXX events:
Stigma.registerDamageEvent(integer abil, code action)
-> runs when a unit is damaged
Stigma.registerFinishEvent(integer abil, code action)
-> runs when an instance of the stigma linear has ended
You can use Stigma_L.data to get the instance of stigma that triggered the events
*/
library Stigma requires T32, Table
//Do not edit below this line unless you are sure of what you're doing
function StigmaDamage takes unit target, real percent returns real
return (GetUnitState(target, UNIT_STATE_MAX_LIFE) - GetWidgetLife(target))*percent
endfunction
private module init
static method onInit takes nothing returns nothing
set thistype.onDamageTable = Table.create()
set thistype.onFinishTable = Table.create()
endmethod
endmodule
struct Stigma
static Table onDamageTable
static Table onFinishTable
static thistype data
unit target
unit caster
real interval
real totalduration
real timeelapsed
real damagetime
attacktype at
damagetype dt
real percent
string damageeffect
effect be
string apoint
integer abil
static method registerDamageEvent takes integer abil, code action returns nothing
if not onDamageTable.handle.has(abil) then
set onDamageTable.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(onDamageTable.trigger[abil], Filter(action))
endmethod
static method registerFinishEvent takes integer abil, code action returns nothing
if not onFinishTable.handle.has(abil) then
set onFinishTable.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(onFinishTable.trigger[abil], Filter(action))
endmethod
method finish takes nothing returns nothing
set this.target = null
set this.caster = null
set this.at = null
set this.dt = null
call DestroyEffect(this.be)
set this.be = null
call this.deallocate()
endmethod
method periodic takes nothing returns nothing
set this.timeelapsed = this.timeelapsed + T32_PERIOD
set data = this
if this.timeelapsed >= this.damagetime then
set this.damagetime = this.damagetime + this.interval
call UnitDamageTarget(this.caster, this.target, StigmaDamage(this.target, this.percent), false, false, this.at, this.dt, WEAPON_TYPE_WHOKNOWS )
if onDamageTable.handle.has(this.abil) then
call TriggerEvaluate(onDamageTable.trigger[this.abil])
endif
call DestroyEffect(AddSpecialEffectTarget(this.damageeffect, this.target, this.apoint))
endif
if (this.timeelapsed >= this.totalduration) or (GetWidgetLife(this.target) <= .405) then
if onFinishTable.handle.has(this.abil) then
call TriggerEvaluate(onFinishTable.trigger[this.abil])
endif
call this.stopPeriodic()
call this.finish()
endif
endmethod
implement T32x
static method create takes unit target, unit caster, real interval, real totalduration, /*
*/attacktype at, damagetype dt, real percent, string buffeffect, string damageeffect, /*
*/string apoint, integer abil returns thistype
local thistype stigma = .allocate()
set stigma.caster = caster
set stigma.target = target
set stigma.interval = interval
set stigma.totalduration = totalduration
set stigma.damagetime = interval
set stigma.at = at
set stigma.dt = dt
set stigma.percent = percent
set stigma.timeelapsed = 0.00
set stigma.be = AddSpecialEffectTarget(buffeffect, target, apoint)
set stigma.apoint = apoint
set stigma.damageeffect = damageeffect
set stigma.abil = abil
call stigma.startPeriodic()
return stigma
endmethod
static method simple takes unit target, unit caster, real interval, real totalduration,/*
*/real percent, string buffeffect, integer abil returns thistype
return thistype.create(target,caster,interval,totalduration,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,percent,buffeffect,"","origin",abil)
endmethod
static method simpler takes unit target, unit caster, real interval, real totalduration,/*
*/real percent, integer abil returns thistype
return thistype.create(target,caster,interval,totalduration,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,percent,"","","origin",abil)
endmethod
implement init
endstruct
endlibrary
//TESH.scrollpos=94
//TESH.alwaysfold=0
/*Stigma System by Adiktuz
Version 2.01 Linear
Requires:
T32 - http://www.thehelper.net/forums/showthread.php/132538-Timer32
Table - http://www.hiveworkshop.com/forums/jass-resources-412/snippet-new-table-188084/
Description:
Inflicts damage every interval which increases by a set amount
You can modify the amount of damage, total duration and damage interval with each call of the function
You can also have multiple spells that use this library and supports multi-level spells
System is MUI
Also, the effect of Stigma can stack up on individual units if a spell using the system is casted unpon them successively.
the stacking effect works for every spell using stigma
How to use
just call the function:
Stigma_L.create(unit target, unit caster, real interval, real totalduration, boolean usebuff, attacktype at,
damagetype dt, real base, real increment string buffeffect, string damageeffect, string apoint, integer abil)
unit target is the unit to be afflicted by stigma
unit caster is the unit who caused the stigma
real interval is the interval in seconds in which the damage occurs
real totalduration is the duration of the stigma in seconds
For best results use reals divisible by .03
attacktype at is the attack type of the spell
damagetype dt is the damage type of the spell
real base is the base damage of the stigma (first damage is already base + increment)
real increment is the additional damage dealth by stigma per interval
string buffeffect is the effect that attaches to the unit during the duration of stigma
string damageeffect is the effect played every damage interval
string apoint is the attachment point of the effects
integer abil is the rawcode of the spell
If you need simpler functions:
Without attacktype,damagetype and damageeffect settings:
Stigma_L.simple(unit target, unit caster, real interval, real totalduration,
real base,real increment, string buffeffect, integer abil)
Further without buffeffect
Stigma_L.simpler(unit target, unit caster, real interval, real totalduration,
real base,real increment, integer abil)
Further without base
Stigma_L.simplest(unit target, unit caster, real interval, real totalduration,
real increment, integer abil)
Registering onXX events:
Stigma_L.registerDamageEvent(integer abil, code action)
-> runs when a unit is damaged
Stigma_L.registerFinishEvent(integer abil, code action)
-> runs when an instance of the stigma linear has ended
You can use Stigma_L.data to get the instance of stigma that triggered the events
*/
library StigmaLinear requires T32, Table
//Do not edit below this line unless you are sure of what you're doing
function StigmaLinearDamage takes real base, real increment returns real
return base + increment
endfunction
private module init
static method onInit takes nothing returns nothing
set thistype.onDamageTable = Table.create()
set thistype.onFinishTable = Table.create()
endmethod
endmodule
struct Stigma_L
static Table onDamageTable
static Table onFinishTable
static thistype data
unit target
unit caster
real interval
real totalduration
real timeelapsed = 0
real damagetime
attacktype at
damagetype dt
real base
real increment
string damageeffect
effect be
string apoint
integer abil
static method registerDamageEvent takes integer abil, code action returns nothing
if not onDamageTable.handle.has(abil) then
set onDamageTable.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(onDamageTable.trigger[abil], Filter(action))
endmethod
static method registerFinishEvent takes integer abil, code action returns nothing
if not onFinishTable.handle.has(abil) then
set onFinishTable.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(onFinishTable.trigger[abil], Filter(action))
endmethod
method finish takes nothing returns nothing
set this.target = null
set this.caster = null
set this.at = null
set this.dt = null
call DestroyEffect(this.be)
set this.be = null
call this.deallocate()
endmethod
method periodic takes nothing returns nothing
set this.timeelapsed = this.timeelapsed + T32_PERIOD
set data = this
if this.timeelapsed >= this.damagetime then
set this.damagetime = this.damagetime + this.interval
call UnitDamageTarget(this.caster, this.target, StigmaLinearDamage(this.base, this.increment), false, false, this.at, this.dt, WEAPON_TYPE_WHOKNOWS )
if onDamageTable.handle.has(this.abil) then
call TriggerEvaluate(onDamageTable.trigger[this.abil])
endif
set this.base = this.base + this.increment
call DestroyEffect(AddSpecialEffectTarget(this.damageeffect, this.target, this.apoint))
endif
if (this.timeelapsed >= this.totalduration) or (GetWidgetLife(this.target) <= .405) then
if onFinishTable.handle.has(this.abil) then
call TriggerEvaluate(onFinishTable.trigger[this.abil])
endif
call this.stopPeriodic()
call this.finish()
endif
endmethod
implement T32x
static method create takes unit target, unit caster, real interval, real totalduration, /*
*/attacktype at, damagetype dt, real base, real increment, string buffeffect, /*
*/string damageeffect, string apoint, integer abil returns thistype
local thistype stigma = .allocate()
set stigma.caster = caster
set stigma.target = target
set stigma.interval = interval
set stigma.totalduration = totalduration
set stigma.damagetime = interval
set stigma.at = at
set stigma.dt = dt
set stigma.base = base
set stigma.increment = increment
set stigma.be = AddSpecialEffectTarget(buffeffect, target, apoint)
set stigma.apoint = apoint
set stigma.damageeffect = damageeffect
set stigma.abil = abil
call stigma.startPeriodic()
return stigma
endmethod
static method simple takes unit target, unit caster, real interval, real totalduration,/*
*/real base,real increment, string buffeffect,integer abil returns thistype
return thistype.create(target,caster,interval,totalduration,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,base,increment,buffeffect,"","origin",abil)
endmethod
static method simpler takes unit target, unit caster, real interval, real totalduration,/*
*/real base,real increment, integer abil returns thistype
return thistype.create(target,caster,interval,totalduration,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,base,increment,"","","origin",abil)
endmethod
static method simplest takes unit target, unit caster, real interval, real totalduration,/*
*/real increment, integer abil returns thistype
return thistype.create(target,caster,interval,totalduration,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,increment,increment,"","","origin",abil)
endmethod
implement init
endstruct
endlibrary
//TESH.scrollpos=4
//TESH.alwaysfold=0
scope DamageTest initializer init
private function onDamage takes nothing returns nothing
call BJDebugMsg("Testings!!!")
endfunction
private function Damager takes nothing returns boolean
if GetSpellAbilityId() == 'A002' then
call Stigma_L.create( GetTriggerUnit(), GetTriggerUnit(), .99, 99.00, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_DIVINE, 10, 10, "Abilities\\Spells\\Other\\Doom\\DoomTarget.mdl" ,"Objects\\Spawnmodels\\Orc\\Orcblood\\BattrollBlood.mdl", "origin",'A002' )
endif
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Damager))
call Stigma_L.registerDamageEvent('A002', function onDamage)
endfunction
endscope