- Joined
- May 1, 2008
- Messages
- 1,605
Moin moin =)
i have a little problem with my spell. I rewrote the trigger now 4 times but always I get another error. Now in this code I have 2 new problems.
1: The loop part runs only one time. For testing I displayed the "war.t" and it stops by 0.04. Why that =O
2: As you see, I set the TimedLife of an orc in "private function FelOrcDur". Normally the duration should be 20/30/40 seconds, but when I test it ingame and the orc spawns, the TimedLife is at all levels only about 2 seconds (It's so fast so I think it's 2 seconds, maybe it's just 1 or 3) Why that =O
=== Warcry ===
When the ability is used, an fel orc spawn instantly. Now every 2 seconds another fel orc is spawned, until the "FelOrcAmount" is reached.
It's not my first vJass spell at all, but it's the first time, that the loop only runs one time and stop then. Also I don't understand this with the TImedLife, for me it seems to be correct =O
Hope someone can help me with this.
Greetings - Thanks - Peace
Dr. Boom
i have a little problem with my spell. I rewrote the trigger now 4 times but always I get another error. Now in this code I have 2 new problems.
1: The loop part runs only one time. For testing I displayed the "war.t" and it stops by 0.04. Why that =O
2: As you see, I set the TimedLife of an orc in "private function FelOrcDur". Normally the duration should be 20/30/40 seconds, but when I test it ingame and the orc spawns, the TimedLife is at all levels only about 2 seconds (It's so fast so I think it's 2 seconds, maybe it's just 1 or 3) Why that =O
=== Warcry ===
When the ability is used, an fel orc spawn instantly. Now every 2 seconds another fel orc is spawned, until the "FelOrcAmount" is reached.
JASS:
library Warcry initializer Init requires TimerUtils
globals
private constant integer SPELL_ID = 'A004'
private constant string WAR_EFFECT = "Abilities\\Spells\\NightElf\\BattleRoar\\RoarCaster.mdl"
private constant real SPAWN_RELEASE = 2.
endglobals
globals // store the unit
private integer array FEL_ORC
endglobals
private function WarcrySetup takes nothing returns nothing
set FEL_ORC[1] = 'uni0'
set FEL_ORC[2] = 'uni1'
set FEL_ORC[3] = 'uni2'
endfunction
private function FelOrcDur takes nothing returns real
return (10. * GetUnitAbilityLevel(GetTriggerUnit(),SPELL_ID)) + 10.
endfunction
private function FelOrcAmount takes nothing returns integer
return (2 + GetUnitAbilityLevel(GetTriggerUnit(),SPELL_ID))
endfunction
// Configuration ends here \\
globals
private constant real LOOP_TIME = 0.04
private integer TEMP
endglobals
private struct Warcry
unit caster = null
real t = 0.
integer c = 0
private static method WarcryLoop takes nothing returns nothing
local timer t = GetExpiredTimer()
local Warcry war = GetTimerData(t)
local real x
local real y
local unit u
set war.t = war.t + LOOP_TIME
if war.c < FelOrcAmount then
if war.t >= SPAWN_RELEASE then
set war.t = 0
set x = GetUnitX(war.caster)
set y = GetUnitY(war.caster)
set u = CreateUnit(GetOwningPlayer(war.caster),FEL_ORC[GetUnitAbilityLevel(war.caster,SPELL_ID)],x,y,GetUnitFacing(war.caster))
call DestroyEffect(AddSpecialEffect(WAR_EFFECT,x,y))
call UnitApplyTimedLife(u,'BTFL',FelOrcDur)
set war.c = war.c + 1
endif
elseif war.c == FelOrcAmount then
call ReleaseTimer(t)
call war.destroy()
endif
set u = null
endmethod
static method WarcryCreate takes unit caster returns Warcry
local thistype war = thistype.allocate()
local timer t = NewTimer()
local real x
local real y
local unit u
set war.caster = caster
set x = GetUnitX(war.caster)
set y = GetUnitY(war.caster)
set u = CreateUnit(GetOwningPlayer(war.caster),FEL_ORC[GetUnitAbilityLevel(war.caster,SPELL_ID)],x,y,GetUnitFacing(war.caster))
call UnitApplyTimedLife(u,'BTFL',FelOrcDur)
call DestroyEffect(AddSpecialEffect(WAR_EFFECT,x,y))
set war.c = war.c + 1
set u = null
call SetTimerData(t,war)
call TimerStart(t,LOOP_TIME,true,function Warcry.WarcryLoop)
return war
endmethod
endstruct
private function WarcryCast takes nothing returns boolean
if GetSpellAbilityId() == SPELL_ID then
call Warcry.WarcryCreate(GetTriggerUnit())
endif
return false
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i == 15
call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
set i = i + 1
endloop
call TriggerAddCondition(t,Condition(function WarcryCast))
call Preload(WAR_EFFECT)
call WarcrySetup()
set t = null
endfunction
endlibrary
It's not my first vJass spell at all, but it's the first time, that the loop only runs one time and stop then. Also I don't understand this with the TImedLife, for me it seems to be correct =O
Hope someone can help me with this.
Greetings - Thanks - Peace
Dr. Boom