Files
2HUCardTDGame/aghanim_singleplayer/scripts/vscripts/traps/fire_trap_cycle_a.lua
2021-10-24 15:36:18 -04:00

57 lines
1.5 KiB
Lua
Executable File

--print( "fire_trap_cycle_a" )
---------------------------------------------------------------------------
-- Fire Trap Cycle
---------------------------------------------------------------------------
function OnTrigger( trigger )
thisEntity.fRefireTime = 1.5
EmitGlobalSound( "ui.ui_player_disconnected" )
EmitSoundOn( "AghanimsFortress.FireTrap", hTrigger )
thisEntity.hBreatheFireAbility = thisEntity:FindAbilityByName( "breathe_fire" )
if thisEntity.hBreatheFireAbility == nil then
print( "ERROR: thisEntity.hBreatheFireAbility not found" )
return
end
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
thisEntity:SetContextThink( "ActivateTrap", function() return FireTrapActivate() end, 0 )
end
---------------------------------------------------------------------------
function DisableTrap( trigger )
thisEntity.bDisabled = true
end
---------------------------------------------------------------------------
function FireTrapActivate()
if not IsServer() then
return
end
if thisEntity.bDisabled then
return -1
end
if GameRules:IsGamePaused() == true then
return 0.5
end
if GameRules:GetGameTime() >= thisEntity.fNextAttackTime then
thisEntity:SetAnimation( "bark_attack" );
thisEntity:CastAbilityOnPosition( thisEntity:GetTrapTarget(), thisEntity.hBreatheFireAbility, -1 )
thisEntity.fNextAttackTime = GameRules:GetGameTime() + thisEntity.fRefireTime
end
return 0.5
end
---------------------------------------------------------------------------