• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Respawning Units

Status
Not open for further replies.
Level 4
Joined
Jul 22, 2010
Messages
63
Im making a RPG map and I need to make every unit, to respawn after 10-15 secs after death, at the initial position it was setted, facing doesnt matter.
I tried this, but for some odd reasons, some units doesnt respawn..
  • Respawn
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
        • Loop - Actions
          • Set Integer = (Integer + 1)
          • Set Creep_Loc[Integer] = (Position of (Picked unit))
          • Set Creep_Face_Ang[Integer] = (Facing of (Picked unit))
          • Unit - Set the custom value of (Picked unit) to Integer
  • Respawn Copy
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • Wait (Random real number between 10.00 and 12.00) seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at Creep_Loc[(Custom value of (Triggering unit))] facing Creep_Face_Ang[(Custom value of (Triggering unit))] degrees
      • Unit - Set the custom value of (Last created unit) to (Custom value of (Triggering unit))
PS: I also need a way to add hero glow to my hero
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
problem if u waste the custom value for unit respawn then later u can have complication if u want add example a damage detection system or any system/mui spell where unit indexer is used like a standard thing.

u can use unit indexer then u can use custom values for anything included respawn/dds/spells
 
There's a less complex system for that. Try doing this:
  • INIT Store Creeps
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Set Loop = 0
      • Unit Group - Pick every unit in (Units owned by Neutral Hostile) and do (Actions)
        • Loop - Actions
          • Set Creep_Type[Loop] = (Unit-type of (Picked unit))
          • Set Creep_Position[Loop] = (Position of (Picked unit))
          • Unit - Set the custom value of (Picked unit) to Loop
          • Set Loop = (Loop + 1)
JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Revive_Creeps_Actions takes nothing returns nothing
    local integer CUSTOM
    local real time = 65.00 //To change the revive time, change this
    set CUSTOM = GetUnitUserData(GetDyingUnit())
    call TriggerSleepAction( time )
    call CreateNUnitsAtLoc( 1, udg_Creep_Type[CUSTOM], Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Creep_Position[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
This is from eubz' Hostile Swamps, i thought it might be useful.
Don't use waits, their not Multiple Unit Instanceable.
 
Status
Not open for further replies.
Top