XeNiM666
I lurk for pizza
- Reaction score
- 138
I'm no JASS master but I made a small cast time system that I use it for every spell on my heroes only and some items. I was wondering how to get the instance of a struct without copy/pasting this on every spell I have, maybe similar to KT2's KT_GetData()...
Code:
I want to be able to do something like this but don't know how.
Any suggestions? Also, is it fast/efficient?
TIA
Code:
JASS:
scope CT initializer onInit
private struct Cast
unit caster
real time
real t = 0.00
integer order
unit bar
static method Update takes nothing returns boolean
local Cast c = KT_GetData()
set c.t = c.t + 0.01
call SetUnitAnimationByIndex( c.bar, R2I( ( c.t / c.time ) * 20 ) + 1 )
if c.t >= c.time or GetUnitCurrentOrder( c.caster ) != c.order then
// call function here
call c.destroy()
return true
endif
return false
endmethod
method onDestroy takes nothing returns nothing
call UnitApplyTimedLife( .bar, 039;BTLF039;, 0.25 )
call FadeUnit( .bar, 255.00, 0.00, 0.25 ) //custom function
call IssueImmediateOrder( .caster, "stop" )
set .caster = null
endmethod
endstruct
public function Apply takes unit caster, real time, string order returns Cast
local Cast c = Cast.create()
set c.caster = caster
set c.time = time
set c.order = OrderId( order )
set c.bar = CreateUnit( GetOwningPlayer( c.caster ), 039;h00P039;, GetUnitX( c.caster ), GetUnitY( c.caster ), 270.00 ) // Hatebreeder's w/e Bars-modeled unit
call SetUnitAnimationByIndex( c.bar, 0 )
call KT_Add( function Cast.Update, c, 0.01 )
return c
endfunction
endscope
I want to be able to do something like this but don't know how.
JASS:
struct Spell
unit caster
unit target
static method After
local Spell s = Cast.GetData()
call KillUnit( s.target )
call something( s.caster )
endmethod
endstruct
function Test1
local Spell s = Spell.create()
set s.caster = GetTriggerUnit()
set s.target = GetSpellTargetUnit()
call CT_Apply( s.caster, 2.00, "holybolt", function Spell.After )
endfunction
Any suggestions? Also, is it fast/efficient?
TIA