- Joined
- Oct 18, 2007
- Messages
- 930
Ok im working on a spell but the trigger wont even fire! So what is the problem??
Custom Interface System
My Spell
Any ideas?
Custom Interface System
JASS:
//! textmacro CostumInterface takes Loop,End,path,periodic
library CostumInterface$path$ initializer init
interface $path$Loop
boolean active=false
boolean paused=false
method $Loop$ takes nothing returns nothing
method $End$ takes nothing returns nothing
endinterface
globals
private $path$Loop array $path$_loopObject
private integer $path$_size=0
private trigger $path$_loop
constant real $path$_periodic=$periodic$
endglobals
function AddObjectTo$path$ takes $path$Loop loopObject returns integer
set $path$_loopObject[$path$_size]=loopObject
set $path$_loopObject[$path$_size].active=true
set $path$_size=$path$_size+1
if not IsTriggerEnabled($path$_loop) then
call EnableTrigger($path$_loop)
endif
return $path$_size
endfunction
private function Loop$path$ takes nothing returns nothing
local integer index=0
loop
exitwhen index==$path$_size
if $path$_loopObject[index].active and not $path$_loopObject[index].paused then
call $path$_loopObject[index].$Loop$.execute()
set index=index+1
elseif $path$_loopObject[index].paused then
set index=index+1
else
call $path$_loopObject[index].$End$()
set $path$_size=$path$_size-1
set $path$_loopObject[index]=$path$_loopObject[$path$_size]
endif
endloop
if $path$_size<=0 then
call DisableTrigger($path$_loop)
endif
endfunction
private function init takes nothing returns nothing
set $path$_loop=CreateTrigger()
call TriggerRegisterTimerEvent($path$_loop,$path$_periodic,true)
call TriggerAddAction($path$_loop,function Loop$path$)
call DisableTrigger($path$_loop)
endfunction
endlibrary
//! endtextmacro
//! runtextmacro CostumInterface("flame","endflame","Flame","0.25")
//! runtextmacro CostumInterface("burn","endburn","Burn","0.10")
My Spell
JASS:
scope FieryTrial initializer Init
globals
private constant integer AID = 'AHtc' // Ability Id
private constant integer DID = 'h000' // Dummy Id
private constant string CastEffect = "Abilities\\Spells\\Other\\Volcano\\VolcanoDeath.mdl"
private constant string EndCastEffect = "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl"
private constant string LoopEffect = "Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl"
private constant string FlameEffect = "Abilities\\Spells\\Other\\BreathOfFire\\BreathOfFireDamage.mdl"
private constant string BurnEffect = "Abilities\\Spells\\NightElf\\Immolation\\ImmolationDamage.mdl"
private constant string CastEffectAttach = ""
private constant string EndCastEffectAttach = ""
private constant string LoopEffectAttach = "origin"
private constant string FlameEffectAttach = "origin"
private constant string BurnEffectAttach = "origin"
private constant real FlameSizeX = 1.
private constant real FlameSizeY = 1.
private constant real FlameSizeZ = 1.
private constant real Damage = 15.
private constant real DamageIncrease = 10.
private constant real BurnAOE = 75.
private constant integer FlameLifeTime = 20 // Secconds is in *10 so 2 secconds is 20 because ( 2 * 10 = 20 )
private constant integer FlameLifeTimeIncrease = 5
private constant integer NumberOfFlames = 15
private constant integer NumberOfFlamesIncrease = 5
//= = = = = /!\ End of constants /!\ = = = = =
private group tmpG=CreateGroup()
private player tmpP
private boolexpr Cond
endglobals
private constant function GetDamage takes integer lvl returns real
return Damage + ( DamageIncrease * (lvl - 1 ) )
endfunction
private constant function GetFlameLife takes integer lvl returns integer
return FlameLifeTime + ( FlameLifeTimeIncrease * ( lvl - 1 ) )
endfunction
private constant function GetNumberOfFlames takes integer lvl returns integer
return NumberOfFlames + ( NumberOfFlamesIncrease * ( lvl - 1 ) )
endfunction
private function filter takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(),tmpP) and (GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)>0) and IsUnitType(GetFilterUnit(),UNIT_TYPE_GROUND) and (GetUnitTypeId(GetFilterUnit())!=DID)
endfunction
private struct Burn extends BurnLoop
unit c
unit d
player p
real x
real y
integer lvl
integer i=1
integer e
effect ex
method burn takes nothing returns nothing
local unit u=null
local real x
local real y
if .i<.e then
set tmpP=.p
call GroupEnumUnitsInRange(tmpG,.x,.y,BurnAOE,Cond)
loop
set u=FirstOfGroup(tmpG)
exitwhen u==null
call UnitDamageTarget(.c,u,GetDamage(.lvl),false,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
if BurnEffect != "" then
if BurnEffectAttach != "" then
set x=GetUnitX(u)
set y=GetUnitY(u)
call DestroyEffect(AddSpecialEffect(BurnEffect,x,y))
else
call DestroyEffect(AddSpecialEffectTarget(BurnEffect,u,BurnEffectAttach))
endif
endif
call GroupRemoveUnit(tmpG,u)
set u=null
endloop
else
set .active=false
endif
endmethod
method endburn takes nothing returns nothing
call DestroyEffect(.ex)
call RemoveUnit(.d)
set .c=null
set .p=null
set .ex=null
call .destroy()
endmethod
endstruct
private struct FieryTrial extends FlameLoop
unit c
player p
real x
real y
integer lvl
integer i=1
integer e
effect ex
method flame takes nothing returns nothing
local Burn b
set .x=GetUnitX(.c)
set .y=GetUnitY(.c)
if .i<.e then
set b=Burn.create()
set b.c=.c
set b.lvl=.lvl
set b.p=.p
set b.e=GetFlameLife(.lvl)
set b.x=.x
set b.y=.y
set b.d=CreateUnit(.p,DID,.x,.y,0)
call SetUnitPathing(b.d,false)
call SetUnitScale(b.d,FlameSizeX,FlameSizeY,FlameSizeZ)
if FlameEffect != "" then
set b.ex=AddSpecialEffectTarget(FlameEffect,b.d,FlameEffectAttach)
endif
call AddObjectToBurn(b)
set .i=.i+1
else
set .active=false
endif
endmethod
method endflame takes nothing returns nothing
if EndCastEffect != "" then
if EndCastEffectAttach != "" then
call DestroyEffect(AddSpecialEffectTarget(EndCastEffect,.c,EndCastEffectAttach))
else
call DestroyEffect(AddSpecialEffect(EndCastEffect,.x,.y))
endif
endif
if .ex != null then
call DestroyEffect(.ex)
set .ex=null
endif
set .c=null
set .p=null
call .destroy()
endmethod
endstruct
private function Conditions takes nothing returns boolean
// Here i added a debug msg to see if it did fire but it didnt!
return GetSpellAbilityId() == AID
endfunction
private function Actions takes nothing returns nothing
local unit u=GetTriggerUnit()
local real x=GetUnitX(u)
local real y=GetUnitY(u)
local FieryTrial f=FieryTrial.create()
if CastEffect != "" then
if CastEffectAttach != "" then
call DestroyEffect(AddSpecialEffectTarget(CastEffect,u,CastEffectAttach))
else
call DestroyEffect(AddSpecialEffect(CastEffect,x,y))
endif
endif
if LoopEffect != "" then
set f.ex=AddSpecialEffectTarget(LoopEffect,u,LoopEffectAttach)
endif
set f.lvl=GetUnitAbilityLevel(u,AID)
set f.e=GetNumberOfFlames(f.lvl)
set f.p=GetOwningPlayer(u)
set f.c=u
call AddObjectToFlame(f)
set u=null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t=CreateTrigger()
local integer index=1
local player p=null
loop
set p=Player(index)
call TriggerRegisterPlayerUnitEvent(t,p,EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
set index=index+1
set p=null
exitwhen index==bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddAction(t,function Actions)
call TriggerAddCondition(t,Condition(function Conditions))
set t=null
set Cond=Condition(function filter)
endfunction
endscope
Any ideas?