Name | Type | is_array | initial_value |
//TESH.scrollpos=176
//TESH.alwaysfold=0
scope Windslash initializer init
//========================================================================================
//======================================SETUP============================================
//========================================================================================
globals
//The effect that's played with every attack
private constant string EFFECT_ON_HIT = "Objects\\Spawnmodels\\Orc\\Orcblood\\BattrollBlood.mdl"
//The ability code of the ability, "Wind Slash"
private constant integer ABILITY_CODE = 'A000'
//The ability code of the Crow Form ability (Should be the same unless you tampered with)
private constant integer CROW_FORM ='Arav'
//The effect attached to the weapon.
private constant string EFFECT_ON_WEAPON = "Abilities\\Spells\\Orc\\EtherealForm\\SpiritWalkerChange.mdl"
//The effect at the location of the unit being slammed (Final attack)
private constant string FINAL_EFFECT = "Abilities\\Spells\\Orc\\EarthQuake\\EarthQuakeTarget.mdl"
//Attack type for the damage
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
//Damage type for the damage
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
//Weapon type for the damage
private constant weapontype WEAPON_TYPE = WEAPON_TYPE_WHOKNOWS
//Animation to be played while the attack goes on.
private constant string ANIMATION_ATTACK = "attack"
//Attachment point for the EFFECT_ON_HIT
private constant string ATTACHMENT_POINT = "origin"
//Attachment point for the EFFECT_ON_WEAPON effect.
private constant string CASTER_ATTACH_POINT = "origin"
//The final effect to be played on each individual unit in the final AOE
private constant string FINAL_AOE_EFFECT = "Objects\\Spawnmodels\\Undead\\UndeadDissipate\\UndeadDissipate.mdl"
private constant string FINAL_ATTACHED = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"
private group tempgroup = CreateGroup()
endglobals
private function Units takes unit u, player casterOwner returns boolean
return (not IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE)) and IsUnitEnemy(u, casterOwner)
endfunction
private function NUMBER_OF_SLASHES takes integer lvl returns real
return 4 + (lvl * 2.)
endfunction
private function HEIGHT takes integer lvl returns real
return 200 + (lvl * 25.)
endfunction
private function DAMAGE_PER_STRIKE takes integer lvl returns real
return (lvl * 6.25)
endfunction
private function RATE_OF_FLYING takes integer lvl returns real
return 600 + (lvl * 0.)
endfunction
private function FINAL_SPEED takes integer lvl returns real
return 25 + (lvl * 0.)
endfunction
private function FINAL_AOE_DAMAGE takes integer lvl returns real
return lvl * 40.
endfunction
private function FINAL_AOE takes integer lvl returns real
return lvl * 60.
endfunction
//========================================================================================
//=====================================ENDSETUP=========================================
//========================================================================================
private struct slash
unit Caster
unit Target
integer Tempint = 1
effect AttachedEffect
effect FinalEffect
static integer structtype
endstruct
private function FinalUnits takes nothing returns boolean
local slash s = slash.structtype
local unit f = GetFilterUnit()
local real damage = FINAL_AOE_DAMAGE(GetUnitAbilityLevel(s.Caster, ABILITY_CODE))
if GetUnitTypeId(f) != GetUnitTypeId(s.Caster) and Units(f, GetOwningPlayer(s.Caster)) then
call SetUnitX(s.Caster, GetUnitX(f))
call SetUnitY(s.Caster, GetUnitY(f))
call SetUnitAnimation(s.Caster, ANIMATION_ATTACK)
call UnitDamageTarget(s.Caster, f, damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
call DestroyEffect(AddSpecialEffectTarget(FINAL_AOE_EFFECT, f, ATTACHMENT_POINT))
endif
set f = null
return false
endfunction
private function userFunc takes nothing returns boolean
local slash s = KT_GetData()
local integer ability_level = GetUnitAbilityLevel(s.Caster, ABILITY_CODE)
local real fly_height = HEIGHT(ability_level) + 12.5 * s.Tempint
local real rate = RATE_OF_FLYING(ability_level)
local real damage = DAMAGE_PER_STRIKE(ability_level)
local real num_slashes = NUMBER_OF_SLASHES(ability_level)
local real final_attack_speed = FINAL_SPEED(ability_level)
local real radius = FINAL_AOE(ability_level)
local real offsetx
local real offsety
local real coffsetx
local real coffsety
local real angle
local real casterX = GetUnitX(s.Caster)
local real casterY = GetUnitY(s.Caster)
local real targetX = GetUnitX(s.Target)
local real targetY = GetUnitY(s.Target)
if s.Tempint < num_slashes and GetWidgetLife(s.Target) > .405 then
set angle = Atan2(targetY - casterY, targetX - casterX)
call SetUnitFlyHeight(s.Target, fly_height, rate)
call SetUnitFlyHeight(s.Caster, fly_height, (rate * .75))
set offsetx = targetX + 20 * Cos(angle)
set offsety = targetY + 20 * Sin(angle)
call SetUnitFacing(s.Caster, angle * bj_RADTODEG)
call SetUnitAnimation(s.Caster, ANIMATION_ATTACK)
call UnitDamageTarget(s.Caster, s.Target, damage, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
call DestroyEffect(AddSpecialEffectTarget(EFFECT_ON_HIT, s.Target, ATTACHMENT_POINT))
call SetUnitX(s.Target, offsetx)
call SetUnitY(s.Target, offsety)
set s.Tempint = s.Tempint + 1
elseif s.Tempint >= num_slashes or GetWidgetLife(s.Target) < .405 then
call SetUnitFlyHeight(s.Target, 0, 1000)
call SetUnitFlyHeight(s.Caster, 0, (rate * .75))
set s.FinalEffect = AddSpecialEffectTarget(FINAL_ATTACHED, s.Caster, ATTACHMENT_POINT)
call DestroyEffect(AddSpecialEffectTarget(EFFECT_ON_HIT, s.Target, ATTACHMENT_POINT))
call DestroyEffect(AddSpecialEffect(FINAL_EFFECT, targetX, targetY))
set slash.structtype = s
call GroupEnumUnitsInRange(tempgroup, targetX, targetY, radius, Filter(function FinalUnits))
call SelectUnit(s.Caster, true)
call DestroyEffect(s.AttachedEffect)
call DestroyEffect(s.FinalEffect)
call PauseUnit(s.Caster, false)
call PauseUnit(s.Target, false)
call SetUnitPathing(s.Caster, true)
call SetUnitPathing(s.Target, true)
call s.destroy()
return true
endif
return false
endfunction
private function OnCast takes nothing returns boolean
local slash s
local real x
local real y
if GetSpellAbilityId() == ABILITY_CODE then
set s = slash.create()
set s.Caster = GetTriggerUnit()
set s.Target = GetSpellTargetUnit()
call ClearSelectionForPlayer(GetTriggerPlayer())
call PauseUnit(s.Caster, true)
call PauseUnit(s.Target, true)
call UnitAddAbility(s.Caster, CROW_FORM)
call UnitAddAbility(s.Target, CROW_FORM)
call UnitRemoveAbility(s.Caster, CROW_FORM)
call UnitRemoveAbility(s.Target, CROW_FORM)
set s.AttachedEffect = AddSpecialEffectTarget(EFFECT_ON_WEAPON, s.Caster, CASTER_ATTACH_POINT)
set x = GetUnitX(s.Target) + 50 * Cos(GetRandomReal(0, 360))
set y = GetUnitY(s.Target) + 50 * Sin(GetRandomReal(0, 360))
call SetUnitX(s.Caster, x)
call SetUnitY(s.Caster, y)
call SetUnitPathing(s.Caster, false)
call SetUnitPathing(s.Target, false)
call KT_Add(function userFunc, s, .25)
endif
return false
endfunction
//===========================================================================
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerAddCondition( t, Condition(function OnCast) )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~ KT ~~ Key Timers 2 ~~ By Jesus4Lyf ~~ Version 1.7.3 ~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// What is Key Timers?
// - Key Timers attaches structs to timers, or more to the point timed
// effects.
// - You can specify different periods.
// - Key Timers only uses one timer with one trigger per low period
// to keep things efficient, especially within the looping.
// - Key Timers alternatively uses one trigger per instance for all higher
// periods to allow accurate expirations in a stable and efficient fashion.
//
// =Pros=
// - Easy to use.
// - Fastest attachment loading system (storing in parallel arrays).
// - Fastest execution system for low periods (all functions on one trigger).
// - Allows multiple periods to be used.
// - No H2I. Backwards compatability through patch 1.23 and 1.24.
//
// =Cons=
// - The code passed into KT2 must call KT_GetData exactly once.
// - Periods must be a multiple of 0.00125 seconds. Not 0.007, for example.
//
// Functions:
// - KT_Add(userFunc, struct, period)
// - KT_GetData returns the struct
//
// - userFunc is to be a user function that takes nothing and returns boolean.
// It will be executed by the system every period until it returns true.
//
// - KT_GetData is to be used inside func, it will return the struct passed to
// to the Add function. It must be called exactly once within the func.
//
// Details:
// - KT2 treats low periods and high periods differently, optimizing each
// with appropriate speed and accuracy, although this effect is invisible
// to you, the mapper.
//
// - While func returns false the timer will continue to call it each period.
// Once func returns true the instance will be detached from system.
//
// Thanks:
// - Daxtreme: For encouraging me to return to Key Timers 2, rather than
// leave it to rot. His interest in the system restored it, and helped
// it to become what it is now. :)
//
// - Captain Griffen: For his work on Rapid Timers, demonstrating that it
// is possible to attach all functions to one trigger, and that it is
// indeed faster.
//
// - Cohadar: Told me to make Key Timers without a textmacro.
// Thanks to him for helping me with the original Key Timers system too.
// Also, I'd like to thank him for his work on Timer Ticker (TT) which
// demonstrated how to use triggers/conditions in this sort of system,
// which has been used in Key Timers 2.
//
// How to import:
// - Create a trigger named .
// - Convert it to custom text and replace the whole trigger text with this.
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
library KT
///////////////
// Constants //
////////////////////////////////////////////////////////////////////////////
// That bit that users may play with if they know what they're doing.
// Not touching these at all is recommended.
globals
// Period Threshold is the point at which Key Timers 2 will switch from
// using the single timer per period mechanism to using TAZO, which is
// better for higher periods due to the first tick being accurate.
private constant real PERIODTHRESHOLD=0.3 // MUST be below 10.24 seconds.
// Tazo's number of precached instances. You can go over this during
// your map at runtime, but it will probably do some small background
// processing. Precaching just speeds things up a bit.
private constant integer TAZO_PRECACHE=64
// Tazo uses the low period part of Key Timers 2 to construct triggers
// over time when precached ones run out. Here you can set the period used.
private constant real TAZO_CONSTRUCT_PERIOD=0.03125
endglobals
//////////////////////////
// Previous KT2 Globals //
////////////////////////////////////////////////////////////////////////////
// These needed to be moved here for TAZO to hook GetData.
globals
private timer array KeyTimer
private trigger array TimerTrigger
private integer array KeyTimerListPointer
private integer array KeyTimerListEndPointer
private triggercondition array TriggerCond
private boolexpr array Boolexpr
private integer array Data
private integer array Next
private integer array Prev
private integer TrigMax=0
private integer array NextMem
private integer NextMemMaxPlusOne=1
private integer array ToAddMem
private triggercondition array ToRemove
private boolexpr array ToDestroy
private boolean array IsAdd
private integer AddRemoveMax=0
// Locals
private integer t_id=-1
private integer t_mem
private integer t_lastmem
private integer a_id
private integer a_mem
// Code Chunks
private conditionfunc RemoveInstanceCond
endglobals
//////////////////
// Previous KT2 //
////////////////////////////////////////////////////////////////////////////
// The KT2 implementation
private function KeyTimerLoop takes nothing returns nothing
set t_id=R2I(TimerGetTimeout(GetExpiredTimer())*800)
set t_mem=KeyTimerListEndPointer[t_id]
call TriggerEvaluate(TimerTrigger[t_id])
set t_mem=0
loop
exitwhen t_mem==AddRemoveMax
set t_mem=t_mem+1
if IsAdd[t_mem] then
set TriggerCond[ToAddMem[t_mem]]=TriggerAddCondition(TimerTrigger[t_id],Boolexpr[ToAddMem[t_mem]])
else
call TriggerRemoveCondition(TimerTrigger[t_id],ToRemove[t_mem])
call DestroyBoolExpr(ToDestroy[t_mem])
endif
endloop
set AddRemoveMax=0
set t_id=-1
endfunction
private function RemoveInstance takes nothing returns boolean
// Will only fire if code returns true.
set AddRemoveMax=AddRemoveMax+1
set IsAdd[AddRemoveMax]=false
set ToRemove[AddRemoveMax]=TriggerCond[t_lastmem]
set ToDestroy[AddRemoveMax]=Boolexpr[t_lastmem]
if Next[t_lastmem]==0 then
set KeyTimerListEndPointer[t_id]=Prev[t_lastmem]
endif
set Prev[Next[t_lastmem]]=Prev[t_lastmem]
if Prev[t_lastmem]==0 then
set KeyTimerListPointer[t_id]=Next[t_lastmem]
if KeyTimerListPointer[t_id]<1 then
call PauseTimer(KeyTimer[t_id])
endif
else
set Next[Prev[t_lastmem]]=Next[t_lastmem]
endif
set NextMem[NextMemMaxPlusOne]=t_lastmem
set NextMemMaxPlusOne=NextMemMaxPlusOne+1
return false
endfunction
private function KTadd takes code func, integer data, real period returns nothing
set a_id=R2I(period*800)
if KeyTimer[a_id]==null then
set KeyTimer[a_id]=CreateTimer()
set TimerTrigger[a_id]=CreateTrigger()
endif
if NextMemMaxPlusOne==1 then
set TrigMax=TrigMax+1
set a_mem=TrigMax
else
set NextMemMaxPlusOne=NextMemMaxPlusOne-1
set a_mem=NextMem[NextMemMaxPlusOne]
endif
set Boolexpr[a_mem]=And(Condition(func),RemoveInstanceCond)
if t_id==a_id then
set AddRemoveMax=AddRemoveMax+1
set IsAdd[AddRemoveMax]=true
set ToAddMem[AddRemoveMax]=a_mem
else
if KeyTimerListPointer[a_id]<1 then
call TimerStart(KeyTimer[a_id],a_id/800.0,true,function KeyTimerLoop)
set KeyTimerListEndPointer[a_id]=a_mem
endif
set TriggerCond[a_mem]=TriggerAddCondition(TimerTrigger[a_id],Boolexpr[a_mem])
endif
set Data[a_mem]=data
set Prev[a_mem]=0
set Next[a_mem]=KeyTimerListPointer[a_id]
set Prev[KeyTimerListPointer[a_id]]=a_mem
set KeyTimerListPointer[a_id]=a_mem
endfunction
public function GetData takes nothing returns integer // Gets hooked by TAZO.
set t_lastmem=t_mem
set t_mem=Prev[t_mem]
return Data[t_lastmem]
endfunction
private function KTinit takes nothing returns nothing
set RemoveInstanceCond=Condition(function RemoveInstance)
endfunction
//////////
// TAZO //
////////////////////////////////////////////////////////////////////////////
// KT2 implementation for higher periods (low frequency).
globals
private constant integer TAZO_DATAMEM=8190 // Added for KT2 hook. Don't change.
endglobals
globals
private conditionfunc TAZO_LoadDataCond
private conditionfunc TAZO_RemoveInstanceCond
private timer array TAZO_TrigTimer
private integer array TAZO_Data
private boolexpr array TAZO_Boolexpr
private trigger array TAZO_AvailableTrig
private integer TAZO_Max=0
private integer TAZO_ConstructNext=0
private trigger array TAZO_ConstructTrig
private integer array TAZO_ConstructCount
endglobals
globals//locals
private integer TAZO_ConKey
endglobals
private function TAZO_Constructer takes nothing returns boolean
set TAZO_ConKey=GetData()
call TriggerExecute(TAZO_ConstructTrig[TAZO_ConKey])
set TAZO_ConstructCount[TAZO_ConKey]=TAZO_ConstructCount[TAZO_ConKey]-1
if TAZO_ConstructCount[TAZO_ConKey]==0 then
set TAZO_Max=TAZO_Max+1
set TAZO_AvailableTrig[TAZO_Max]=TAZO_ConstructTrig[TAZO_ConKey]
set TAZO_TrigTimer[TAZO_ConKey]=CreateTimer()
call TriggerRegisterTimerExpireEvent(TAZO_AvailableTrig[TAZO_Max],TAZO_TrigTimer[TAZO_ConKey])
return true
endif
return false
endfunction
globals//locals
private trigger TAZO_DeadTrig
private integer TAZO_DeadCount
endglobals
private function TAZO_Recycle takes nothing returns boolean
set TAZO_DeadTrig=GetTriggeringTrigger()
set TAZO_DeadCount=GetTriggerExecCount(TAZO_DeadTrig)
call TriggerClearConditions(TAZO_DeadTrig)
call DestroyBoolExpr(TAZO_Boolexpr[TAZO_DeadCount])
call PauseTimer(TAZO_TrigTimer[TAZO_DeadCount])
set TAZO_Max=TAZO_Max+1
set TAZO_AvailableTrig[TAZO_Max]=TAZO_DeadTrig
return false
endfunction
private function TAZO_LoadData takes nothing returns boolean
// KT2 Data Hook
set t_mem=TAZO_DATAMEM
set Data[TAZO_DATAMEM]=TAZO_Data[GetTriggerExecCount(GetTriggeringTrigger())]
// End KT2 Data Hook
return false
endfunction
private function InitTrigExecCount takes trigger t, integer d returns nothing
if d>128 then
call InitTrigExecCount.execute(t,d-128)
set d=128
endif
loop
exitwhen d==0
set d=d-1
call TriggerExecute(t)
endloop
endfunction
globals//locals
private integer TAZO_AddKey
private trigger TAZO_AddTrigger
endglobals
public function TAZOadd takes code func, integer data, real period returns nothing
if TAZO_Max==0 then
// Failsafe.
set TAZO_ConstructNext=TAZO_ConstructNext+1
set TAZO_AddTrigger=CreateTrigger()
set TAZO_AddKey=TAZO_ConstructNext
call InitTrigExecCount.execute(TAZO_AddTrigger,TAZO_AddKey)
set TAZO_TrigTimer[TAZO_AddKey]=CreateTimer()
call TriggerRegisterTimerExpireEvent(TAZO_AddTrigger,TAZO_TrigTimer[TAZO_AddKey])
else
set TAZO_AddTrigger=TAZO_AvailableTrig[TAZO_Max]
set TAZO_AddKey=GetTriggerExecCount(TAZO_AddTrigger)
set TAZO_Max=TAZO_Max-1
endif
set TAZO_Data[TAZO_AddKey]=data
set TAZO_Boolexpr[TAZO_AddKey]=And(Condition(func),TAZO_RemoveInstanceCond)
call TriggerAddCondition(TAZO_AddTrigger,TAZO_LoadDataCond)
call TriggerAddCondition(TAZO_AddTrigger,TAZO_Boolexpr[TAZO_AddKey])
call TimerStart(TAZO_TrigTimer[TAZO_AddKey],period,true,null)
if TAZO_Max<10 then
set TAZO_ConstructNext=TAZO_ConstructNext+1
set TAZO_ConstructTrig[TAZO_ConstructNext]=CreateTrigger()
set TAZO_ConstructCount[TAZO_ConstructNext]=TAZO_ConstructNext
call KTadd(function TAZO_Constructer,TAZO_ConstructNext,TAZO_CONSTRUCT_PERIOD)
endif
endfunction
private function TAZOinit takes nothing returns nothing
set TAZO_LoadDataCond=Condition(function TAZO_LoadData)
set TAZO_RemoveInstanceCond=Condition(function TAZO_Recycle)
// Allow for GetData
set Next[TAZO_DATAMEM]=TAZO_DATAMEM
set Prev[TAZO_DATAMEM]=TAZO_DATAMEM
// End allow for GetData
loop
exitwhen TAZO_Max==TAZO_PRECACHE
set TAZO_ConstructNext=TAZO_ConstructNext+1 // The index.
set TAZO_Max=TAZO_Max+1 // Will be the same in the initialiser as ConstructNext.
set TAZO_AvailableTrig[TAZO_Max]=CreateTrigger()
call InitTrigExecCount.execute(TAZO_AvailableTrig[TAZO_Max],TAZO_ConstructNext)
set TAZO_TrigTimer[TAZO_ConstructNext]=CreateTimer()
call TriggerRegisterTimerExpireEvent(TAZO_AvailableTrig[TAZO_Max],TAZO_TrigTimer[TAZO_ConstructNext])
endloop
endfunction
///////////////
// Interface //
////////////////////////////////////////////////////////////////////////////
// Stitches it all together neatly.
public function Add takes code func, integer data, real period returns nothing
if period<PERIODTHRESHOLD then
call KTadd(func,data,period)
else
call TAZOadd(func,data,period)
endif
endfunction
private module InitModule
private static method onInit takes nothing returns nothing
call KTinit()
call TAZOinit()
endmethod
endmodule
private struct InitStruct extends array
implement InitModule
endstruct
endlibrary
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// End of Key Timers 2
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~