• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

A simple question about a trigger

Status
Not open for further replies.
Level 15
Joined
Nov 26, 2005
Messages
1,151
Hi guys. I wanted to make a trigger that makes the following:
everytime a unit owned by player one of type 1,2 or 3 dies, after 5 seconds a new unit of the same type is spawned in the cneter of the Rect
Code:
function Trig_Respawn_units_Func003C takes nothing returns boolean
    if ( ( GetUnitTypeId(GetDyingUnit()) == 'n602' ) ) then
        return true
    endif
    if ( ( GetUnitTypeId(GetDyingUnit()) == 'u602' ) ) then
        return true
    endif
    if ( ( GetUnitTypeId(GetDyingUnit()) == 'u603' ) ) then
        return true
    endif
    return false
endfunction

function Trig_Respawn_units_Conditions takes nothing returns boolean
    if ( not Trig_Respawn_units_Func003C() ) then
        return false
    endif
    return true
endfunction

function Trig_Respawn_units_Actions takes nothing returns nothing
    local unit u
    set u = GetDyingUnit()
    call TriggerSleepAction( 5.00 )
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(u), Player(0), GetRectCenter(gg_rct_Unit_Respawn), bj_UNIT_FACING )
endfunction

//===========================================================================
function InitTrig_Respawn_units takes nothing returns nothing
    set gg_trg_Respawn_units = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Respawn_units, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Respawn_units, Condition( function Trig_Respawn_units_Conditions ) )
    call TriggerAddAction( gg_trg_Respawn_units, function Trig_Respawn_units_Actions )
endfunction

Tell me why this doesn't work? Rep for helpful answers, ofc.


Edit:
  • Respawn units
    • Events
      • Unit - A unit Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Dying unit)) Equal to Risen Archer
          • (Unit-type of (Dying unit)) Equal to Risen Fighter
          • (Unit-type of (Dying unit)) Equal to Brute
    • Actions
      • Custom script: local unit u
      • Custom script: set u = GetDyingUnit()
      • Wait 5.00 seconds
      • Custom script: call CreateNUnitsAtLoc( 1, GetUnitTypeId(u), Player(0), GetRectCenter(gg_rct_Unit_Respawn), bj_UNIT_FACING )
This doesn't seem to work, wither ? :(
 
Last edited:
Use this:
  • Death
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Wait 5.00 seconds
      • Set temp_point = (Center of Region 000 <gen>)
      • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at temp_point facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_temp_point)
Works for me.
 
Level 15
Joined
Nov 26, 2005
Messages
1,151
It does, but I have to make it MUI, u know? So if another unit dies before these 5 seconds have passe, both units will be properly recreated, each 5 seconds after it has died.

With your suggestion, only the second unit, who died will be respawned.
 
Level 10
Joined
May 20, 2008
Messages
433
The issue is not MUI, but the fact that the trigger cannot run more then once at the same time.
My suggestions:
1) Make a few of the suggested triggers, and when one activates, have another get activated. Highly ineffective when there are lots of units that can be revived
2) Have a global respawn timer (after X seconds all units in group respawn). Ruins the "respawn after 5 seconds".
Otherwise I'm out of idea that are less specific then (when [UNIT] dies, wait 5 seconds, respawn)
 
Level 15
Joined
Nov 26, 2005
Messages
1,151
Thank you Ghost, as you are right, in a normal map it works, but then exactly the same trigger, when pasted in my campaign doesn't do anything ? Any ideas why ?

Does this only work with pre-placed units on the map or with all units (spawned in-game) ? Cause it caused some issues with that, too

Any idea why it doesn't work in my campaign and it works for other maps ?
 
Thank you Ghost, as you are right, in a normal map it works, but then exactly the same trigger, when pasted in my campaign doesn't do anything ? Any ideas why ?

Does this only work with pre-placed units on the map or with all units (spawned in-game) ? Cause it caused some issues with that, too

Any idea why it doesn't work in my campaign and it works for other maps ?

Make sure you changed this line:
  • (Center of Region 000 <gen>)
To whatever region you are using. Otherwise, it should work.
 
Level 15
Joined
Nov 26, 2005
Messages
1,151
Ok, here's a screenshot of what I am using ... this is seriously wierd. It's not such a hard or complicated trigger, but it just doesn't work in a campiagn.

And don't say it's inactive, cause there is another trigger that activates it when the time comes... so I just don't know what to do o_O
 

Attachments

  • scrrrrr11.JPG
    scrrrrr11.JPG
    237.5 KB · Views: 60
Status
Not open for further replies.
Top