- Joined
- Oct 16, 2006
- Messages
- 48
Hi . can someone help me with my spell trigger. I believe it is relatively simple, I just don't know where does it go wrong.
Been trying it in a few different ways. doesn't seems to work.
This current way still doesn't work.
When casting, it tests to see if they're in same cliff level and if target is more than 250 range away.
If not , it will slide the caster towards the target unit's initial location for 1.5 seconds. If it hits the target, it will do damage and stun. If not, it will just remove effect.
It detects the hitting by continually check range of Target and caster while sliding, and if it's less than 200, it's consider hit. It does this by looping the check for 15 times via for loop. each loop doing a 0.1 second pause.
Now here's the problem, i did a debug message on each loop to show the looping variable. doesn't work. The debug message only showed 1.which means it never looped. Sometimes, it still hits the unit even after 1.5 seconds ( which shouldn't ) any idea?
Also, it doesn't seem to detect the hits properly sometimes.
I tried doing it without loop, using exitwhen to change the range, but then again, if target misses, the loop will not stop. So I use Exitwhen to do a OR comparison for the range and time( max 1.5 second) , still don't work. So I i'm utterly confused.
I hope someone can advised. thanks
Been trying it in a few different ways. doesn't seems to work.
This current way still doesn't work.
When casting, it tests to see if they're in same cliff level and if target is more than 250 range away.
If not , it will slide the caster towards the target unit's initial location for 1.5 seconds. If it hits the target, it will do damage and stun. If not, it will just remove effect.
It detects the hitting by continually check range of Target and caster while sliding, and if it's less than 200, it's consider hit. It does this by looping the check for 15 times via for loop. each loop doing a 0.1 second pause.
Now here's the problem, i did a debug message on each loop to show the looping variable. doesn't work. The debug message only showed 1.which means it never looped. Sometimes, it still hits the unit even after 1.5 seconds ( which shouldn't ) any idea?
Also, it doesn't seem to detect the hits properly sometimes.
I tried doing it without loop, using exitwhen to change the range, but then again, if target misses, the loop will not stop. So I use Exitwhen to do a OR comparison for the range and time( max 1.5 second) , still don't work. So I i'm utterly confused.
I hope someone can advised. thanks
JASS:
function Trig_Ramstrike_Actions takes nothing returns nothing
local effect wave
local unit target
local unit caster
local location x
local real angle
local integer wait
set caster = GetTriggerUnit()
set target = GetSpellTargetUnit()
set x = GetUnitLoc(target)
set wait = 0
set angle = AngleBetweenPoints(GetUnitLoc(caster), GetUnitLoc(target))
if ( Trig_Ramstrike_Func001C() ) then
if ( DistanceBetweenPoints(GetUnitLoc(caster), GetUnitLoc(target)) >= 250.00 ) then
call SetUnitAnimation( caster , "spell throw" )
call PolledWait(0.30)
call SetUnitPathing( GetTriggerUnit(), false )
call Knockback(GetTriggerUnit(), 400, AngleBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetUnitLoc(GetSpellTargetUnit())) * bj_DEGTORAD, 1.5)
call AddSpecialEffectTargetUnitBJ( "origin", caster, "Abilities\\Spells\\Orc\\Shockwave\\ShockwaveMissile.mdl" )
set wave = GetLastCreatedEffectBJ()
loop
exitwhen wait > 15
call ErrorMsg( GetOwningPlayer(GetTriggerUnit()), I2S(wait) )
if ( DistanceBetweenPoints(GetUnitLoc(target), GetUnitLoc(caster)) <= 200.00 ) then //checks if target unit is near caster. Or if he already run off
call DestroyEffectBJ(wave)
call PlaySoundAtPointBJ( gg_snd_MetalHeavySliceFlesh1, 100.00, GetUnitLoc(target), 0 )
call SetUnitPathing( caster, true )
call Knockback(target, 150, angle * bj_DEGTORAD, 1 )
call Knockback(caster, 75, (angle - 180 ) * bj_DEGTORAD, 1 )
call UnitDamageTargetBJ( caster , target, udg_RamstrikeDMG[GetUnitAbilityLevelSwapped('A00B', GetTriggerUnit())], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
set wait = 16
call Stun( caster , target , udg_RamstrikeSTUN[GetUnitAbilityLevelSwapped('A00B', caster)] )
call ErrorMsg( GetOwningPlayer(GetTriggerUnit()), I2S(wait) )
else
call AddSpecialEffectLocWithTimer(GetUnitLoc(caster), "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl" , 2 )
set wait = wait + 1
call ErrorMsg( GetOwningPlayer(GetTriggerUnit()), I2S(wait) )
endif
call TriggerSleepAction(0.10)
endloop
else
call ErrorMsg( GetOwningPlayer(GetTriggerUnit()), "Unit too close to ram" )
call CancelOrders(caster)
endif
else
call ErrorMsg( GetOwningPlayer(GetTriggerUnit()), "Cannot ram unit in different cliff level." )
call CancelOrders(caster)
endif
call DestroyEffectBJ( wave )