Custom trigger help please.

Status
Not open for further replies.
Level 65
Joined
Jun 2, 2008
Messages
11,370
I'm currently making a dota type map and I came across this custom written trigger on one of the template maps and I tried copying and pasting it to mine but for some reason every time I copy and paste custom written triggers like this one it doesn't work.
-------------------------------------


function Trig_Revive_Creeps_Actions takes nothing returns nothing
local integer CUSTOM
set CUSTOM = GetUnitUserData(GetDyingUnit())
call TriggerSleepAction( udg_Hostile_Revive_Time )
call CreateNUnitsAtLoc( 1, udg_Creep_Types[CUSTOM], Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Creep_Positions[CUSTOM], bj_UNIT_FACING )
call SetUnitUserData( GetLastCreatedUnit(), CUSTOM )
endfunction
//===========================================================================
function InitTrig_Revive_Creeps takes nothing returns nothing
set gg_trg_Revive_Creeps = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Revive_Creeps, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( gg_trg_Revive_Creeps, function Trig_Revive_Creeps_Actions )
endfunction


--------------------------------------
Anyway I can make this without it messing up on my map?
 
Level 16
Joined
Mar 25, 2016
Messages
1,327
What does not work?
Do you mean it does not compile?

Are the variables set to the right values (Creep_Types,Creep_Position)

What do you use the Custom value of the units for? Every creep has its own index and a location/type attached to this index and the revived unit has same type/location and index, right?
 
Level 65
Joined
Jun 2, 2008
Messages
11,370
Jungle creeps are placed where they need to be, this custom trigger makes it so when someone kills them they come back at that same spot, just when I place it in my map and save it, it gets corrupt and I have to delete it.

I would like the creeps to be revived so its not just a one time thing.
 
Level 16
Joined
Mar 25, 2016
Messages
1,327
Create a new trigger, add the event player owned unit dies (neutral hostile), convert it to custom text and paste these lines into the actions block:

local integer CUSTOM
set CUSTOM = GetUnitUserData(GetDyingUnit())
call TriggerSleepAction( udg_Hostile_Revive_Time )
call CreateNUnitsAtLoc( 1, udg_Creep_Types[CUSTOM], Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Creep_Positions[CUSTOM], bj_UNIT_FACING )
call SetUnitUserData( GetLastCreatedUnit(), CUSTOM )

This way you will not have problems with the trigger initialization function and naming stuff.

Dota means multiplayer I guess. You should avoid waits in multiplayer games (TriggerSleepAction = wait), because of desync.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
what do you mean without the wait? i just wanna do the easiest way here.
TriggerSleepAction, aka GUI wait, is roughly synchronized with real time and not game time. This means it continues to count at the same rate even if the game is paused, waiting for lagging players or running at a different game speed.

Use of trigger events or timers is recommended for respawn systems as they are based on game time so will be paused when the game is paused or waiting for lagging players and will slow down/speed up when running at different game speeds.
 
Status
Not open for further replies.
Top