Zanderist
New Member
- Reaction score
- 5
How can I cause a crater to form (terrain deformation wise) when the shell fired from a cannon tower strikes the ground?
scope Shells initializer Init
globals
// CONFIGURABLE
private constant integer UnitID = 039;AAAA039;
private constant integer DummyID = 039;BBBB039;
private constant player DummyPlayer = Player(11)
private constant real Radius = 200
private constant real Depth = 100
private constant integer Duration = 3
private constant integer Count = 3
private constant real SpaceWaves = 1
private constant real TimeWaves = 1
private constant real RadiusStartPct = 1
private constant boolean LimitNeg = true
// NONCONFIGURABLE
private group dummies = CreateGroup()
private trigger Damage = CreateTrigger()
endglobals
private function Ripple takes nothing returns boolean
if (GetUnitTypeId(GetEventDamageSource()) == UnitID) then
call TerrainDeformRipple(GetUnitX(GetFilterUnit()), GetUnitY(GetFilterUnit()), Radius, Depth, Duration, Count, SpaceWaves, TimeWaves, RadiusStartPct, LimitNeg))
call GroupRemoveUnit(dummies, GetFilterUnit())
call RemoveUnit(GetFilterUnit())
endif
return false
endfunction
private function Ordered takes nothing returns boolean
local unit dummy
if (GetUnitTypeId(GetFilterUnit()) == UnitID)) then
set dummy = CreateUnit(DummyPlayer, DummyID, GetOrderPointX(), GetOrderPointY(), 0)
call GroupAddUnit(dummies, dummy)
call TriggerRegisterUnitEvent(Damage, dummy, EVENT_UNIT_DAMAGED)
set dummy = null
endif
return false
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 11
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ISSUED_ORDER, True)
set i = i - 1
exitwhen i == -1
endloop
call TriggerAddCondition(t, Filter(function Ordered))
call TriggerAddCondition(Damage, Filter(function Ripple))
set t = null
endfunction
endscope