PrisonLove
Hard Realist
- Reaction score
- 78
Hi, I have a trigger that creates a bomb omb and makes it walk in a targte direction. When the bomb either comes into contact with another unit, or when its fuse runs out, it will explode damaging the area. All of that works just dandy, but there is one problem that I find so annoying: The bomb's walk animation won't play. It takes one step and then the animation freezes and I don't know why. The user defined functions that don't appear in the trigger are in the map header and work properly. Can anyone see why the animation isn't playing properly?
Here is the code:
Here is the code:
JASS:
function LaunchBombOmbConditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A000039;
endfunction
function LaunchBombOmbGroupFilter takes nothing returns boolean
local unit target = GetFilterUnit()
local boolean flag = false
if (IsUnitEnemy(target, udg_tempPlayer) and GetUnitState(target, UNIT_STATE_LIFE) > 0) then
set flag = true
endif
set target = null
return flag
endfunction
function LaunchBombOmbCallback takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local unit bomb = LoadUnitHandle(udg_hash, id, 0)
local player p = LoadPlayerHandle(udg_hash, id, 1)
local real angle = LoadReal(udg_hash, id, 2)
local real fuseTime = LoadReal(udg_hash, id, 3)
local real slideDist = 10
local real x1 = GetUnitX(bomb)
local real y1 = GetUnitY(bomb)
local real x2 = PolarProjectX(x1, angle, slideDist)
local real y2 = PolarProjectY(y1, angle, slideDist)
local group g = CreateGroup()
local integer numInGroup = 0
set udg_tempPlayer = p
call GroupEnumUnitsInRange(g, x2, y2, 50, Filter(function LaunchBombOmbGroupFilter))
set numInGroup = CountUnitsInGroup(g)
if (numInGroup == 0 and fuseTime > 0) then
call SlideWithCollision(bomb, slideDist, angle, "")
set fuseTime = fuseTime - .03
call SaveReal(udg_hash, id, 3, fuseTime)
else
call DestroyEffect(AddSpecialEffect("war3mapImported\\NewGroundEX.mdx", x1, y1))
call UnitDamagePoint(bomb, 0, 50, x1, y1, 25, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call UnitDamagePoint(bomb, 0, 150, x1, y1, 15, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call UnitDamagePoint(bomb, 0, 200, x1, y1, 10, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call KillUnit(bomb)
call RemoveUnit(bomb)
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_hash, id)
endif
set udg_tempPlayer = null
set bomb = null
set p = null
set t = null
endfunction
function LaunchBombOmbActions takes nothing returns nothing
local unit koopa = GetTriggerUnit()
local player p = GetOwningPlayer(koopa)
local integer bombID = 039;o001039;
local real kx = GetUnitX(koopa)
local real ky = GetUnitY(koopa)
local real tx = GetSpellTargetX()
local real ty = GetSpellTargetY()
local real angle = GetAngle(kx, ky, tx, ty)
local real dx = PolarProjectX(kx, 50, angle)
local real dy = PolarProjectY(ky, 50, angle)
local unit bomb = CreateUnit(p, bombID, dx, dy, angle)
local timer t = CreateTimer()
local integer id = GetHandleId(t)
local real fuseTime = 3
call SaveUnitHandle(udg_hash, id, 0, bomb)
call SavePlayerHandle(udg_hash, id, 1, p)
call SaveReal(udg_hash, id, 2, angle)
call SaveReal(udg_hash, id, 3, fuseTime)
call SetUnitAnimation(bomb, "walk")
call TimerStart(t, .03, true, function LaunchBombOmbCallback)
set koopa = null
set bomb = null
set p = null
set t = null
endfunction
//===========================================================================
function InitTrig_LaunchBombOmb takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( t, Condition( function LaunchBombOmbConditions ) )
call TriggerAddAction( t, function LaunchBombOmbActions )
set t = null
endfunction