Name | Type | is_array | initial_value |
//TESH.scrollpos=0
//TESH.alwaysfold=0
/*
NovaSystem 2.02 1.31 By Adiktuz & KitsuneTailsPrower
Credits to Adiktuz for the original Nova Ssytem, J4L for T32,
Bribe for Table, SpellEffectEvent and Magtheridon96 for RegisterPlayerUnitEvent
Nestharus for WorldBounds
--------------------------------------------------------------------------------------------
Description:
A simple system that can be used to create:
1)An instant Nova
2)A targeted Nova
3)A time-delayed Nova
4)A Channeled spell which creates novas around you
5)A spell which creates novas around a target area over time
6)A non-channeled spell which creates novas around you
7)And some others
--------------------------------------------------------------------------------------------
How to Import
Copy Nova and the required libraries into your map
--------------------------------------------------------------------------------------------
Editable Globals
TICK = the timer interval
--------------------------------------------------------------------------------------------
How to use:
For very simple, 1-time Nova use this function
NovaSystem.simpleCreate(unit caster,real x, real y, real faoe,
real height, damage, real scale, string path, attacktype at, damagetype dt )
For very simple, 1-time Nova with time delay use this function
NovaSystem.simpleCreateDelay(unit caster,real x, real y, real delay, real faoe,
real height, damage, real scale, string path, attacktype at, damagetype dt )
For very simple, 1-time Nova with time delay + target use this function
NovaSystem.simpleCreateDelayTarget(unit caster, unit target, real x, real y, real delay, real faoe,
real height, damage, real scale, string path, attacktype at, damagetype dt )
For normal use, you just need to call the function
NovaSystem.create(parameters)
see the details below for what the parameters mean
Here are the parameters for the .create method arranged in order with details
unit caster - the unit casting the spell
unit target - the target unit of the spell
- if this has a value, the nova will follow the target
real x - the center x of the nova AOE
real y - the center y of the nova AOE
real aoe - the max distance that novas can be created from the center
real faoe - the radius of EACH nova's explosion
real height - the height of the nova special effect
integer npil - lowerbound of nova created per interval
integer npih - higherbound of nova created per interval
*amount of nova created per interval is randomized from npil to npih*
real ni - interval between nova creations, set this to a number higher than TICK
real ntt - the duration of the spell
real damage - the damage amount of each nova
real scalex - the x scale of the nova special effect
boolean channel - determines wheteher if nova spell is channeled
boolean oncast - whether novas will start on cast
-if false -> first set of novas will be created after ni
boolean follow ->determines if the caster will remain as the center of the AOE
*set it to true only for non-channeled no-target novas*
string path - the path to the nova special effect
attacktype at - the damage's attacktype
damagetype dt - the damage's damagetype
boolean circular - whether the AOE is circular or square, TRUE = circular, FALSE = Square
for the simple nova methods, it is set to true by default
integer abil - rawcode of the ability (used for the onXX events)
Note: I did not add a target method to the simpleCreate method because there is no point in that.
--------------------------------------------------------------------------------------------
Registering onXX events:
NovaSystem.registerOnDamage(integer abil, code action)
-> runs when a unit is damaged
NovaSystem.registerOnHit(integer abil, code action)
-> runs when a unit is hit (before filter is done, meaning it will run for ALL units around the nova)
NovaSystem.registerOnNova(integer abil, code action)
-> runs when a nova is created
NovaSystem.registerOnFinish(integer abil, code action)
-> runs when an instance of the Nova struct has ended
You can use NovaSystem.data to get the instance of Nova that triggered the events
Nova struct members that you can use:
real x
real y
unit caster
real aoe
real faoe
integer npih
integer npil
real ni
real ntc
real ntt
real nxi
boolean channel = false
real damage
string path
player owner
real scalex
boolean follow
real height
attacktype at
damagetype dt
boolean circular
integer abil
Sample:
NovaSystem.data.damage will return the damage value stored in that instance
Check the sample triggers for working examples
--------------------------------------------------------------------------------------------
The system automatically cancels a channeled nova when the caster moves, casts a new spell etc...
To cancel a channeled nova using other events, just use:
call NovaSystem.ForceCancel(unit caster)
*/
library Nova requires T32, Table, RegisterPlayerUnitEvent, MapBounds
native UnitAlive takes unit id returns boolean
globals
//TimerInterval
private constant real TICK = .03
//Do not Edit
private group NOVA_GROUP = CreateGroup()
private Table NovaTable
private Table onDamageTable
private Table onNovaTable
private Table onFinishTable
private Table onHitTable
endglobals
module NSInit
static method onInit takes nothing returns nothing
set NovaTable = Table.create()
set onDamageTable = Table.create()
set onNovaTable = Table.create()
set onHitTable = Table.create()
set onFinishTable = Table.create()
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_CAST, function thistype.Cancel)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function thistype.Cancel)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, function thistype.Cancel)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, function thistype.Cancel)
endmethod
endmodule
struct NovaSystem
real x
real y
unit caster
unit target
real aoe
real faoe
integer npih
integer npil
real ni
real ntc
real ntt
real nxi
boolean channel = false
real damage
string path
player owner
real scalex
boolean follow
real height
attacktype at
damagetype dt
boolean circular
integer abil
static real xx
static real yy
static thistype data
static thistype datu
static unit filter
static unit damagetarget
static method registerOnDamage 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 registerOnNova takes integer abil, code action returns nothing
if not onNovaTable.handle.has(abil) then
set onNovaTable.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(onNovaTable.trigger[abil], Filter(action))
endmethod
static method registerOnHit takes integer abil, code action returns nothing
if not onHitTable.handle.has(abil) then
set onHitTable.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(onHitTable.trigger[abil], Filter(action))
endmethod
static method registerOnFinish 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
stub method OnHitFilter takes unit u returns boolean
return (not BlzIsUnitInvulnerable(u)) and IsUnitEnemy(u, this.owner) and GetWidgetLife(u) >= .405 and UnitAlive(u)
endmethod
//The group loop that is run when a nova is created
static method Looper takes nothing returns boolean
set filter = GetFilterUnit()
if onHitTable.handle.has(data.abil) then
call TriggerEvaluate(onHitTable.trigger[data.abil])
endif
if data.OnHitFilter(filter) then
call UnitDamageTarget(data.caster, filter, data.damage, false, false, data.at, data.dt, null)
if onDamageTable.handle.has(data.abil) then
set damagetarget=filter
call TriggerEvaluate(onDamageTable.trigger[data.abil])
endif
endif
return false
endmethod
//For canceling a channeled nova using other triggers
static method ForceCancel takes unit u returns nothing
set datu = NovaTable[GetHandleId(u)]
if datu != 0 then
set datu.ntt = 0.00
endif
endmethod
//For canceling a channeled nova using the systems default events
static method Cancel takes nothing returns nothing
set datu = NovaTable[GetHandleId(GetTriggerUnit())]
if datu != 0 then
set datu.ntt = 0.00
endif
endmethod
method CreateNova takes nothing returns nothing
local effect fx=(AddSpecialEffect(this.path, xx, yy))
call BlzSetSpecialEffectScale(fx,this.scalex)
call BlzSetSpecialEffectHeight(fx,this.height)
call DestroyEffect(fx)
if onNovaTable.handle.has(data.abil) then
call TriggerEvaluate(onNovaTable.trigger[data.abil])
endif
call GroupEnumUnitsInRange(NOVA_GROUP, xx, yy, this.faoe, Condition(function NovaSystem.Looper))
set fx=null
endmethod
//Ensures that the X and Y are within map bounds
method GetPoint takes nothing returns nothing
local real angle = 0.0
local real range = GetRandomReal(0.0,this.aoe)
if this.circular then
set angle = GetRandomReal(0.0, 6.2832)
set xx = GetBoundedX(this.x + Cos(angle)*range)
set yy = GetBoundedY(this.y + Sin(angle)*range)
else
set xx = GetBoundedX(GetRandomReal(this.x - this.aoe, this.x + this.aoe))
set yy = GetBoundedY(GetRandomReal(this.y - this.aoe, this.y + this.aoe))
endif
endmethod
private method periodic takes nothing returns nothing
local integer a = 1
local integer b = 0
set data = this
set data.ntc = data.ntc + TICK
if data.ntc >= data.nxi then
set data.nxi = data.nxi + data.ni
set b = GetRandomInt(data.npil, data.npih)
loop
exitwhen a > b
if data.follow then
set data.x = GetUnitX(data.caster)
set data.y = GetUnitY(data.caster)
elseif data.target != null then
set data.x = GetUnitX(data.target)
set data.y = GetUnitY(data.target)
endif
call data.GetPoint()
call data.CreateNova()
set a = a + 1
endloop
endif
if data.ntc >= data.ntt then
call data.stopPeriodic()
if onFinishTable.handle.has(data.abil) then
call TriggerEvaluate(onFinishTable.trigger[data.abil])
endif
if data.channel then
call NovaTable.remove(GetHandleId(data.caster))
endif
call data.destroy()
endif
endmethod
implement T32x
static method create takes unit caster, unit target, real x, real y, real aoe, real faoe, real height, integer npil,/*
*/integer npih, real ni, real ntt,real damage, real scale, boolean channel, boolean oncast,/*
*/boolean follow, string path, attacktype at, damagetype dt, boolean circular, integer abil returns thistype
local integer a = 1
local integer b = GetRandomInt(npil, npih)
set data = .allocate()
set data.caster = caster
set data.owner = GetOwningPlayer(caster)
set data.target = target
//Ensures that the initial x,y values are within map bounds
set data.x = GetBoundedX(x)
set data.y = GetBoundedY(y)
set data.follow = follow
set data.height = height
set data.aoe = aoe
set data.damage = damage
set data.channel = channel
set data.path = path
set data.npil = npil
set data.npih = npih
set data.ni = ni
set data.nxi= ni
set data.ntt = ntt
set data.scalex = scale
set data.faoe = faoe
set data.ntc = 0.00
set data.at = at
set data.dt = dt
set data.circular = circular
set data.abil = abil
if channel then
set NovaTable[GetHandleId(caster)] = data
endif
if oncast then
loop
exitwhen a > b
call data.GetPoint()
call data.CreateNova()
set a = a + 1
endloop
endif
call data.startPeriodic()
return data
endmethod
static method simpleCreate takes unit caster,unit target,real x, real y, real faoe, real height,/*
*/ real damage, real scale, string path, attacktype at, damagetype dt,integer abil returns thistype
return thistype.create(caster,null, x, y, 0.0, faoe, height, 1, 1, 0.0, 0.0,damage, scale, false, false, false, path, at, dt, TRUE,abil)
endmethod
static method simpleCreateDelay takes unit caster,real x, real y, real delay, real faoe, real height,/*
*/ real damage, real scale, string path, attacktype at, damagetype dt,integer abil returns thistype
return thistype.create(caster,null, x, y, 0.0, faoe, height, 1, 1, delay, delay,damage, scale, false, false, false, path, at, dt, TRUE,abil)
endmethod
static method simpleCreateDelayTarget takes unit caster, unit target,real x, real y, real delay, real faoe, real height,/*
*/ real damage, real scale, string path, attacktype at, damagetype dt,integer abil returns thistype
return thistype.create(caster,target, x, y, 0.0, faoe, height, 1, 1, delay, delay,damage, scale, false, false, false, path, at, dt, TRUE,abil)
endmethod
implement NSInit
endstruct
endlibrary
//TESH.scrollpos=0
//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=9
//TESH.alwaysfold=0
/**************************************************************
*
* RegisterPlayerUnitEvent
* v5.1.0.0
* By Magtheridon96
*
* I would like to give a special thanks to Bribe, azlier
* and BBQ for improving this library. For modularity, it only
* supports player unit events.
*
* Functions passed to RegisterPlayerUnitEvent must either
* return a boolean (false) or nothing. (Which is a Pro)
*
* Warning:
* --------
*
* - Don't use TriggerSleepAction inside registered code.
* - Don't destroy a trigger unless you really know what you're doing.
*
* API:
* ----
*
* - function RegisterPlayerUnitEvent takes playerunitevent whichEvent, code whichFunction returns nothing
* - Registers code that will execute when an event fires.
* - function RegisterPlayerUnitEventForPlayer takes playerunitevent whichEvent, code whichFunction, player whichPlayer returns nothing
* - Registers code that will execute when an event fires for a certain player.
* - function GetPlayerUnitEventTrigger takes playerunitevent whichEvent returns trigger
* - Returns the trigger corresponding to ALL functions of a playerunitevent.
*
**************************************************************/
library RegisterPlayerUnitEvent // Special Thanks to Bribe and azlier
globals
private trigger array t
endglobals
function RegisterPlayerUnitEvent takes playerunitevent p, code c returns nothing
local integer i = GetHandleId(p)
local integer k = 15
if t[i] == null then
set t[i] = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(t[i], Player(k), p, null)
exitwhen k == 0
set k = k - 1
endloop
endif
call TriggerAddCondition(t[i], Filter(c))
endfunction
function RegisterPlayerUnitEventForPlayer takes playerunitevent p, code c, player pl returns nothing
local integer i = 260 + 16 * GetHandleId(p) + GetPlayerId(pl)
if t[i] == null then
set t[i] = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(t[i], pl, p, null)
endif
call TriggerAddCondition(t[i], Filter(c))
endfunction
function GetPlayerUnitEventTrigger takes playerunitevent p returns trigger
return t[GetHandleId(p)]
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=21
//TESH.alwaysfold=0
library WorldBounds /* v2.0.0.0
************************************************************************************
*
* struct WorldBounds extends array
* readonly static integer maxX
* readonly static integer maxY
* readonly static integer minX
* readonly static integer minY
* readonly static integer centerX
* readonly static integer centerY
* readonly static rect world
* readonly static region worldRegion
*
************************************************************************************/
private module WorldBoundInit
private static method onInit takes nothing returns nothing
set world=GetWorldBounds()
set maxX=R2I(GetRectMaxX(world))
set maxY=R2I(GetRectMaxY(world))
set minX=R2I(GetRectMinX(world))
set minY=R2I(GetRectMinY(world))
set centerX=R2I((maxX+minX)/2)
set centerY=R2I((minY+maxY)/2)
set worldRegion=CreateRegion()
call RegionAddRect(worldRegion,world)
endmethod
endmodule
struct WorldBounds extends array
readonly static integer maxX
readonly static integer maxY
readonly static integer minX
readonly static integer minY
readonly static integer centerX
readonly static integer centerY
readonly static rect world
readonly static region worldRegion
implement WorldBoundInit
endstruct
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
/*
*=================================================================================*
* Map Bounds 1.1 *
* By Adiktuz *
* *
* *
* This is a short snippet that provides some useful functions utilizing *
* the WorldBounds library created by Nestharus *
* *
* *
* Credits: *
* Nestharus for the WorldBounds library *
* Magtheridon96 for suggestions *
* *
* Functions: *
* *
* -> mapIncludeX(real x) returns boolean *
* -> mapIncludeY(real y) returns boolean *
* -> GetBoundedX(real x) returns real *
* -> GetBoundedY(real y) returns real *
* *
* *
* The mapIncludeX/Y functions return if the given x/y value is inside the map *
* *
* The GetBoundedX/Y checks if the given value is within the map. If it's *
* within the map, it will return the value given and if Not *
* it will return the value of the border that it will exceed *
* *
*=================================================================================*
*/
library MapBounds requires WorldBounds
function mapIncludeX takes real x returns boolean
return x < WorldBounds.maxX and x > WorldBounds.minX
endfunction
function mapIncludeY takes real y returns boolean
return y < WorldBounds.maxY and y > WorldBounds.minY
endfunction
function GetBoundedX takes real x returns real
if x > WorldBounds.maxX then
return I2R(WorldBounds.maxX)
elseif x < WorldBounds.minX then
return I2R(WorldBounds.minX)
endif
return x
endfunction
function GetBoundedY takes real y returns real
if y > WorldBounds.maxY then
return I2R(WorldBounds.maxY)
elseif y < WorldBounds.minY then
return I2R(WorldBounds.minY)
endif
return y
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
//============================================================================
// SpellEffectEvent
// - Version 1.1.0.0
//
// API
// ---
// RegisterSpellEffectEvent(integer abil, code onCast)
//
// Requires
// --------
// RegisterPlayerUnitEvent: hiveworkshop.com/forums/showthread.php?t=203338
//
// Optional
// --------
// Table: hiveworkshop.com/forums/showthread.php?t=188084
//
library SpellEffectEvent requires RegisterPlayerUnitEvent, optional Table
//============================================================================
private module M
static if LIBRARY_Table then
static Table tb
else
static hashtable ht = InitHashtable()
endif
static method onCast takes nothing returns nothing
static if LIBRARY_Table then
call TriggerEvaluate(.tb.trigger[GetSpellAbilityId()])
else
call TriggerEvaluate(LoadTriggerHandle(.ht, 0, GetSpellAbilityId()))
endif
endmethod
private static method onInit takes nothing returns nothing
static if LIBRARY_Table then
set .tb = Table.create()
endif
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, function thistype.onCast)
endmethod
endmodule
//============================================================================
private struct S extends array
implement M
endstruct
//============================================================================
function RegisterSpellEffectEvent takes integer abil, code onCast returns nothing
static if LIBRARY_Table then
if not S.tb.handle.has(abil) then
set S.tb.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(S.tb.trigger[abil], Filter(onCast))
else
if not HaveSavedHandle(S.ht, 0, abil) then
call SaveTriggerHandle(S.ht, 0, abil, CreateTrigger())
endif
call TriggerAddCondition(LoadTriggerHandle(S.ht, 0, abil), Filter(onCast))
endif
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
function actions takes nothing returns nothing
call NovaSystem.create(GetTriggerUnit(),null, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 350.00, 100.00 , 0.00,3, 3*(1 + GetUnitAbilityLevel(GetTriggerUnit(), 'A000')), .3, 3.0 , 100*GetUnitAbilityLevel(GetTriggerUnit(), 'A000'),/*
*/1.00, true, true, false,"Abilities\\Weapons\\Bolt\\BoltImpact.mdl", ATTACK_TYPE_MAGIC, DAMAGE_TYPE_LIGHTNING, FALSE, 'A000')
endfunction
//===========================================================================
function InitTrig_ElectroNova takes nothing returns nothing
call RegisterSpellEffectEvent('A000',function actions)
endfunction
//TESH.scrollpos=9
//TESH.alwaysfold=0
scope FlameNova initializer init
globals
private constant integer FN_ID = 'A001'
private constant real DPS = 100.00
private constant string FN_PATH = "Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl"
endglobals
function OnFinish takes nothing returns nothing
local NovaSystem nova = NovaSystem.data
call NovaSystem.create(nova.caster,null, nova.x, nova.y, 25.00, 300.00 ,0.00, 1, 1, .03, .03 , nova.damage, 3.00, false, true, false,FN_PATH, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, TRUE, 0)
endfunction
function OnDamage takes nothing returns nothing
call BJDebugMsg("BOOM!")
call BJDebugMsg("Hit " + GetUnitName(NovaSystem.damagetarget))
endfunction
function FN_Act takes nothing returns nothing
call NovaSystem.create(GetTriggerUnit(),null, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 200.00, 100.00 ,0.00, 2, 2, .6, 3.0 , DPS*GetUnitAbilityLevel(GetTriggerUnit(), FN_ID),/*
*/.80, false, true, false, FN_PATH, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, FALSE, FN_ID)
endfunction
private function init takes nothing returns nothing
call RegisterSpellEffectEvent(FN_ID, function FN_Act)
call NovaSystem.registerOnDamage(FN_ID, function OnDamage)
call NovaSystem.registerOnFinish(FN_ID, function OnFinish)
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
function MN_action takes nothing returns nothing
call NovaSystem.create(GetTriggerUnit(),null, GetSpellTargetX(), GetSpellTargetY(), 0.00, 300.00 , 100.00, 1, 1, 3.0, 3.0 , 300 + 200*(GetUnitAbilityLevel(GetTriggerUnit(), 'A000') - 1),/*
*/1.00, false, false, false,"Abilities\\Spells\\NightElf\\Taunt\\TauntCaster.mdl", ATTACK_TYPE_MAGIC, DAMAGE_TYPE_DIVINE, TRUE, 'A002')
endfunction
//===========================================================================
function InitTrig_MagicNova takes nothing returns nothing
call RegisterSpellEffectEvent('A002',function MN_action)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Quake_Actions takes nothing returns nothing
call NovaSystem.create(GetTriggerUnit(),null, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()),/*
*/350.00, 110.00 , 0.00,1, 3*(1 + GetUnitAbilityLevel(GetTriggerUnit(), 'A003')), .6, 4.0 ,/*
*/90*GetUnitAbilityLevel(GetTriggerUnit(), 'A003'), .80, false, true, true,"Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", ATTACK_TYPE_SIEGE, DAMAGE_TYPE_FORCE, FALSE, 'A003')
endfunction
//===========================================================================
function InitTrig_Quake takes nothing returns nothing
call RegisterSpellEffectEvent('A003', function Quake_Actions)
endfunction
//TESH.scrollpos=7
//TESH.alwaysfold=0
scope BuffNova initializer init
globals
private constant integer BN_ID = 'A004'
private constant real DPS = 100.00
private constant string BN_PATH = "Abilities\\Spells\\NightElf\\BattleRoar\\RoarCaster.mdl"
endglobals
private function OnHit takes nothing returns nothing
if IsUnitType(NovaSystem.filter, UNIT_TYPE_HERO) then
call SetHeroAgi(NovaSystem.filter, GetHeroAgi(NovaSystem.filter, true) + 10,true)
call SetHeroInt(NovaSystem.filter, GetHeroInt(NovaSystem.filter, true) + 10,true)
call SetHeroStr(NovaSystem.filter, GetHeroStr(NovaSystem.filter, true) + 10,true)
endif
endfunction
function BN_Act takes nothing returns nothing
call NovaSystem.create(GetTriggerUnit(),null, GetSpellTargetX(), GetSpellTargetY(), 0.00, 200.00 ,0.00, 1,/*
*/1, .03, .03 , 0.00, .80, false, false, false, BN_PATH, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, TRUE, BN_ID)
endfunction
private function init takes nothing returns nothing
call RegisterSpellEffectEvent(BN_ID, function BN_Act)
call NovaSystem.registerOnHit(BN_ID, function OnHit)
endfunction
endscope