• 🏆 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!

[Solved] Unit created with respawn system doesn't do anything

Status
Not open for further replies.
Level 12
Joined
Feb 5, 2018
Messages
521
  • Set VariableSet ReSpawn_Time = 25.00
  • Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
    • Loop - Actions
      • Set VariableSet Temp_Integer = (Temp_Integer + 1)
      • Unit - Set the custom value of (Picked unit) to Temp_Integer
      • Set VariableSet Creep_Point[Temp_Integer] = (Position of (Picked unit))

  • Add Creeps ReSpawn
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • Set VariableSet Temp_Integer = (Temp_Integer + 1)
      • Unit - Set the custom value of (Triggering unit) to Temp_Integer
      • Set VariableSet Creep_Point[Temp_Integer] = (Position of (Triggering unit))

  • Creep ReSpawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
      • (Custom value of (Triggering unit)) Greater than 0
    • Actions
      • Custom script: local integer i = GetUnitTypeId(GetTriggerUnit())
      • Custom script: local integer ii = GetUnitUserData(GetTriggerUnit())
      • Wait (ReSpawn_Time + ((Real((Level of (Triggering unit)))) x 2.00)) seconds
      • Custom script: call SetUnitUserData(CreateUnit(Player(25),i,GetLocationX(udg_Creep_Point[ii]),GetLocationY(udg_Creep_Point[ii]),270),ii)

So what happens when unit dies first time, it then creates a unit that shows no name above the health bar. The unit has red circle around when selected, meaning that it is hostile.

But the created unit, does not attack or flee. In fact the unit does absolutely nothing. Just stands still and it's stand animations run in cycles.

And after the unit is killed a second time, it is no longer added to respawn sequence for some unknown reasons.

I checked that the player number in reforged is actually 25.
 

Attachments

  • WC3ScrnShot_071920_224655_001.png
    WC3ScrnShot_071920_224655_001.png
    3.6 MB · Views: 50
How have you tested player number? Player number of GUI would be -1 if you use Player() in JASS. So maybe Player(24).
But better use Player(PLAYER_NEUTRAL_AGGRESSIVE) or just GetTriggerPlayer().

For the re-created unit you already set custom value after the wait. But the EnterWorld trigger will then also sets a new custom value and location. It's increasing in that case which you probably don't want, and it would mean location leak.
 
Level 12
Joined
Feb 5, 2018
Messages
521
But better use Player(PLAYER_NEUTRAL_AGGRESSIVE) or just GetTriggerPlayer().

Yea worked like a charm with GetTriggerPlayer().

For the re-created unit you already set custom value after the wait. But the EnterWorld trigger will then also sets a new custom value and location. It's increasing in that case which you probably don't want, and it would mean location leak.

I don't understand. The location is set on map ini and then only when the unit enters playable map area.
 
At least not for those re-created units. : )
Maybe, if there are many other cases where new units are created, then it might make sense to have one trigger to catch those very new units.
You can check in the EnterWorld trigger if unit has some custom value above 0 already, it would mean it's already registered by the respawn system.

Are you using a UnitIndexer? It would manipulate a unit's custom value already and might mix up some things.
 
Status
Not open for further replies.
Top