Unit respawn point

LmmcDarkY

New Member
Reaction score
1
I want unit to respawn at random point in playable map area exepct one region x, so can someone tell me how to do it :)
 

sentrywiz

New Member
Reaction score
25
Well umm, you can either make a huge region that will cover your entire map and another small region which will be outside the huge region. You can also make that if a hero respawns by accident in the not-supposed-to-respawn region, you can move it back to the huge region. Like throwing a guy off a bus XD


Ok seriously, make two regions, one to cover where you want units to respawn and other where you don't want em to. If they interlace with one another, then you'd have to think of something other than regions for the trigger. If they don't then the trigger is easy.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
For this to be done easily in GUI, you will need a few Custom Scripts, but only for the loop that is required.

Here's a version which uses only locations, so it'll be slower than the next version.
Here you have to create a location even if you're not gonna use it, which is quite a waste :p

Trigger:
  • Respawn at Random not Region
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Custom script: loop
      • Set Spawn_Loc = (Random point in (Playable map area))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Block Region 1 <gen> contains Spawn_Loc) Not equal to True
        • Then - Actions
          • Unit - Create 1 Footman for Player 1 (Red) at Spawn_Loc facing Default building facing degrees
          • Custom script: return
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Spawn_Loc)
      • Custom script: endloop


Here comes the more complex version, which uses reals at first instead, so you only create a location if you're gonna use it, which seems and is more efficient ;)

Trigger:
  • Respawn at Random not Region
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Custom script: loop
      • Set Spawn_X = (Random real number between (Min X of (Playable map area)) and (Max X of (Playable map area)))
      • Set Spawn_Y = (Random real number between (Min Y of (Playable map area)) and (Max Y of (Playable map area)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • Spawn_X Greater than (Max X of Block Region 1 <gen>)
              • Spawn_X Less than (Min X of Block Region 1 <gen>)
          • Or - Any (Conditions) are true
            • Conditions
              • Spawn_Y Greater than (Max Y of Block Region 1 <gen>)
              • Spawn_Y Less than (Min Y of Block Region 1 <gen>)
        • Then - Actions
          • Set Spawn_Loc = (Point(Spawn_X, Spawn_Y))
          • Unit - Create 1 Footman for Player 1 (Red) at Spawn_Loc facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_Spawn_Loc)
          • Custom script: return
        • Else - Actions
      • Custom script: endloop
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top