• 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.

Respawns as wrong player in script

Status
Not open for further replies.
Level 9
Joined
Jun 13, 2010
Messages
365
Question updated!!

Player() starts with index 0.

Player(0) is Player 1 (red)
...
Player(11) is Player 12 (brown)

You can just use GetTriggerPlayer(), though.

Alright I got it working now.
Although I seem have another issue.
My Player 12 creeps seem to be respawning at the position of their death location, instead of their original map initialization points, from trigger:

  • Creep Respawn Point Saver
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Creep_Respawn_Timer = 70.00
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Entire map) owned by Player 12 (Brown)) and do (Actions)
        • Loop - Actions
          • Set Creep_Respawn_Integer = (Creep_Respawn_Integer + 1)
          • Unit - Set the custom value of (Picked unit) to Creep_Respawn_Integer
          • Set Creep_Respawn_Point[Creep_Respawn_Integer] = (Position of (Picked unit))
Additionally my MUI seems to be messed up, since my Player 12 creeps respawn at each others death location. So if I kill unit in start area and a boss inside a dungeon, they might swap death locations and spawn in the middle of the start of my RPG map.

Can you help with that? :)

Rest of trigger system follows:

  • Creep Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Custom value of (Triggering unit)) Greater than 0
      • ((Triggering unit) is Summoned) Not equal to True
      • (Owner of (Triggering unit)) Equal to Player 12 (Brown)
    • Actions
      • Custom script: local integer i = GetUnitTypeId(GetTriggerUnit())
      • Custom script: local integer ii = GetUnitUserData(GetTriggerUnit())
      • Wait Creep_Respawn_Timer game-time seconds
      • Custom script: call SetUnitUserData(CreateUnit(Player(11),i,GetLocationX(udg_Creep_Respawn_Point[ii]),GetLocationY(udg_Creep_Respawn_Point[ii]),270),ii)
      • Set Creep_Respawn_Point[Creep_Respawn_Integer] = (Position of (Triggering unit))
  • Creep Add to Respawn
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Owner of (Entering unit)) Equal to Player 12 (Brown)
      • ((Entering unit) is Summoned) Equal to False
    • Actions
      • Set Creep_Respawn_Integer = (Creep_Respawn_Integer + 1)
      • Unit - Set the custom value of (Entering unit) to Creep_Respawn_Integer
      • Set Creep_Respawn_Point[Creep_Respawn_Integer] = (Position of (Entering unit))
      • Unit - Make (Triggering unit) face (Random angle) over 0.00 seconds
 
Last edited:
Level 9
Joined
Jun 13, 2010
Messages
365
Player() starts with index 0.

Player(0) is Player 1 (red)
...
Player(11) is Player 12 (brown)

You can just use GetTriggerPlayer(), though.

Alright I got it working now.
Although I seem have another issue.
My Player 12 creeps seem to be respawning at the position of their death location, instead of their original map initialization points, from trigger:

  • Creep Respawn Point Saver
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Creep_Respawn_Timer = 70.00
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Entire map) owned by Player 12 (Brown)) and do (Actions)
        • Loop - Actions
          • Set Creep_Respawn_Integer = (Creep_Respawn_Integer + 1)
          • Unit - Set the custom value of (Picked unit) to Creep_Respawn_Integer
          • Set Creep_Respawn_Point[Creep_Respawn_Integer] = (Position of (Picked unit))
Additionally my MUI seems to be messed up, since my Player 12 creeps respawn at each others death location. So if I kill unit in start area and a boss inside a dungeon, they might swap death locations and spawn in the middle of the start of my RPG map.

Can you help with that? :)

Rest of trigger system follows:

  • Creep Respawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Custom value of (Triggering unit)) Greater than 0
      • ((Triggering unit) is Summoned) Not equal to True
      • (Owner of (Triggering unit)) Equal to Player 12 (Brown)
    • Actions
      • Custom script: local integer i = GetUnitTypeId(GetTriggerUnit())
      • Custom script: local integer ii = GetUnitUserData(GetTriggerUnit())
      • Wait Creep_Respawn_Timer game-time seconds
      • Custom script: call SetUnitUserData(CreateUnit(Player(11),i,GetLocationX(udg_Creep_Respawn_Point[ii]),GetLocationY(udg_Creep_Respawn_Point[ii]),270),ii)
      • Set Creep_Respawn_Point[Creep_Respawn_Integer] = (Position of (Triggering unit))
  • Creep Add to Respawn
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Owner of (Entering unit)) Equal to Player 12 (Brown)
      • ((Entering unit) is Summoned) Equal to False
    • Actions
      • Set Creep_Respawn_Integer = (Creep_Respawn_Integer + 1)
      • Unit - Set the custom value of (Entering unit) to Creep_Respawn_Integer
      • Set Creep_Respawn_Point[Creep_Respawn_Integer] = (Position of (Entering unit))
      • Unit - Make (Triggering unit) face (Random angle) over 0.00 seconds
 
Level 9
Joined
Jun 13, 2010
Messages
365
You set custom value when you create the unit, and also when it enters the map. So twice for a created unit.
The second one will override the first.

Bumping a thread is only allowed after 48h.

Sorry about that.

But would you advice me to remove the second one then, and keep the first initialized one?

And those two in the second trigger:
  • Custom script: local integer i = GetUnitTypeId(GetTriggerUnit())
  • Custom script: local integer ii = GetUnitUserData(GetTriggerUnit())
Don't they save the local point where the unit died and not the original map initialization point?
What I need it to do is make the creep respawn at that start point and not where it died.
What makes me wonder is this:
  • Custom script: call SetUnitUserData(CreateUnit(Player(11),i,GetLocationX(udg_Creep_Respawn_Point[ii]),GetLocationY(udg_Creep_Respawn_Point[ii]),270),ii)
I don't get why it loads location of the dead unit, if it already has my Start point saved to it.

Additionally, won't I leak points?
I mean, trigger 2 creates a new point at newly created unit. But the original and previous points were never removed.
Also the 3'd trigger creates a point equal to its custom value, even though trigger 2 already made a point.

I'm a bit confused you see. ;)

Edit:
- Although I believe the 3'd trigger is only for units new units to add to the respawn system.
 
would you advice me to remove the second one then, and keep the first initialized one?
Remove the SetUnitUserData() custom script in the Creep Respawn trigger. You only need to set the custom value once, and that is either on map init or when they enter a map. I advise you just use a Unit Indexer in our spells section so you do not have to worry about indexing/deindexing these values.

those two in the second trigger:
  • Custom script: local integer i = GetUnitTypeId(GetTriggerUnit())
  • Custom script: local integer ii = GetUnitUserData(GetTriggerUnit())
Don't they save the local point where the unit died and not the original map initialization point?
If by point, you mean location, then you aren't doing that. All you're doing is storing the id type and the custom value of the triggering unit into two integers.


won't I leak points?
I mean, trigger 2 creates a new point at newly created unit. But the original and previous points were never removed.
Also the 3'd trigger creates a point equal to its custom value, even though trigger 2 already made a point.
You only leak points if you no longer have access to the original reference (overwriting). From what I can see, that isn't the case. You always make a new reference without overwriting.
 
Status
Not open for further replies.
Top