- Joined
- Sep 24, 2004
- Messages
- 49
I'm working a spell for my map called "Annihilate", it fires a beam of energy through the target point. It charges the beam for "Charge Duration". My current problem is, when I try to call the method "Create" from structure "SE" (call SE.Create(u, l)) it does not run.
Another question I have is "How I would cause a method inside a structure to be used with a periodic timer?"
Thank you.
Another question I have is "How I would cause a method inside a structure to be used with a periodic timer?"
JASS:
//=========================================================
//Spell - Annihilate
//Spell Id - 'A01F'
//Spell Effect - Charge for 0.5 Sec
// Fire a laser beam for 0.25 Sec
// Extends to edge of map
// Deals 20*Level + 1.5 Int Damage
// 128 AoE around beam
//=========================================================
scope Annihilate initializer Aint
//Globals
globals
private boolean type1 = true
private boolean type2 = false
endglobals
private function Ticker takes nothing returns nothing
if type1 == true then
set type1 = false
set type2 = true
elseif type2 == true then
set type1 = true
set type2 = false
endif
endfunction
//Spell
private function spellIdMatch takes nothing returns boolean
return (GetSpellAbilityId()=='A01F')
endfunction
private function SpellId takes nothing returns integer
return 'A01F'
endfunction
//Constants
private function Interval takes nothing returns real
return 0.04
endfunction
private function ChargeDuration takes nothing returns real
return 0.50
endfunction
private function BeamDuration takes nothing returns real
return 0.25
endfunction
private function BeamDamage takes integer int, integer lvl returns real
return int * 1.5 + lvl * 20
endfunction
//Effect Structure
private struct SpellEffect
integer int //Caster's Intelligence
integer lvl //Spell Level
real ang //Casting Angle
unit o //Owner
location l //Target Location
timer t //Casting Timer
integer i = 0 //Tics passed
xefx Ex //Effect
method End takes nothing returns nothing
call this.Ex.destroy()
call RemoveLocation(this.l)
set this.o = null
call PauseUnit(this.o, false)
call ReleaseTimer(this.t)
endmethod
method FireLaser takes nothing returns nothing
call DisplayTextToForce(GetPlayersAll(), "IMMAFIRINMAHLASER")
call this.End()
endmethod
method ChargePulse takes nothing returns boolean
set this.i = this.i + 1
set this.Ex.scale = 1.0 + this.i*0.1
if this.i >= ChargeDuration() / Interval() then
call PauseTimer(this.t)
call this.FireLaser()
return false
endif
return true
endmethod
method Charge takes nothing returns nothing
local real x = GetUnitX(this.o) + Cos(this.ang) * 25
local real y = GetUnitY(this.o) + Sin(this.ang) * 25
local boolean t1 = type1
local boolean t2 = type2
set this.Ex = xefx.create(x,y,this.ang)
set this.Ex.owner = GetOwningPlayer(this.o)
set this.Ex.scale = 1.0
set this.Ex.fxpath= "Abilities\\Spells\\Orc\\LightningBolt\\LightningBoltMissile.mdl"
call PauseUnit(this.o, true)
loop
exitwhen this.ChargePulse() == false
loop
exitwhen t1 != type1 and t2 != type2
endloop
set t1 = type1
set t2 = type2
endloop
endmethod
method Create takes unit o, location l returns nothing
local location loc = GetUnitLoc(o)
local real x1 = GetLocationX(loc)
local real x2 = GetLocationX(l)
local real y1 = GetLocationY(loc)
local real y2 = GetLocationY(l)
call DisplayTextToForce(GetPlayersAll(), "Chargin2")
set this.t=NewTimer()
set this.int = GetHeroInt(o, true)
set this.lvl = GetUnitAbilityLevel(o, SpellId())
set this.o = o
set this.l = l
set this.ang = Atan2(y2 - y1, x2 - x1)
call DisplayTextToForce(GetPlayersAll(), "Chargin3")
call this.Charge()
//call TimerStart(FTime, Period(), true, method ChargePulse())
call DisplayTextToForce(GetPlayersAll(), "Chargin4")
call TimerStart(this.t, Interval(), true, function Ticker)
//Clean Up
call DisplayTextToForce(GetPlayersAll(), "Chargin5")
call RemoveLocation(loc)
call RemoveLocation(l)
set o = null
endmethod
endstruct
//Effect
private function onSpellCast takes nothing returns nothing
local location l = GetSpellTargetLoc()
local unit u = GetTriggerUnit()
local SpellEffect SE
call DisplayTextToForce(GetPlayersAll(), "Chargin'")
call SE.Create(u, l)
//Clean Up
call RemoveLocation(l)
set u = null
endfunction
//Initializer
private function Aint takes nothing returns nothing
//Locals
local trigger t=CreateTrigger()
//Create Trigger
call TriggerAddCondition(t, Condition( function spellIdMatch) )
call TriggerAddAction(t, function onSpellCast)
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
//Void Leaks
set t=null
endfunction
endscope