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

[Trigger] Random Unit Changing Ownership #2

Status
Not open for further replies.
Level 4
Joined
May 17, 2011
Messages
106
Yeah... so I tested the script in solo and worked fine. But when I tried it in multiplayer, it would only work for player 1 (red) and not for the others.

I've been looking over it multiple times and I just couldn't find the problem so I'm posting it again.

Here are my triggers:

  • init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TempPoint = (Center of Spawn <gen>)
      • Set TempForce = (All players controlled by a User player)
      • Player Group - Pick every player in TempForce and do (Actions)
        • Loop - Actions
          • Set TempPlayer = (Picked player)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TempPlayer slot status) Equal to Is playing
            • Then - Actions
              • Set SurvivorsNum = (SurvivorsNum + 1)
              • Set TempUnit = (Last created unit)
              • Set TempPlayerNumber = (Player number of (Owner of TempUnit))
              • Player Group - Add TempPlayer to PlayersPlaying
              • Unit - Create 1 Crazy Survivor for TempPlayer at TempPoint facing Default building facing degrees
              • Set Survivors[TempPlayerNumber] = TempUnit
              • Camera - Pan camera for TempPlayer to TempPoint over 0.00 seconds
            • Else - Actions
      • Custom script: call DestroyForce (udg_TempForce)
      • Custom script: call RemoveLocation (udg_TempPoint)
My init trigger is much bigger than this but I removed most informations on it just to show what's necessary. (I'm using multiple time the same variable in that trigger though... could that be a problem?)

  • RageMode
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Set PickedRandomPlayer = (Player number of (Random player from PlayersPlaying))
      • Set PickedRandomUnit = (Random unit from Zombies[PickedRandomPlayer])
      • Custom script: set udg_id = GetHandleId(udg_PickedRandomUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (0 is stored as a Integer of id in ragemodehashtable) Equal to False
        • Then - Actions
          • Hashtable - Save PickedRandomPlayer as 0 of id in ragemodehashtable
          • Unit - Change ownership of PickedRandomUnit to Player 12 (Brown) and Change color
        • Else - Actions
  • RageMode2
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacked unit) is alive) Equal to True
      • (Life of (Attacked unit)) Less than or equal to 50.00
      • (Attacked unit) Equal to PickedRandomUnit
    • Actions
      • Unit - Make PickedRandomUnit Invulnerable
      • Unit - Set life of PickedRandomUnit to 100.00%
      • Unit - Change ownership of PickedRandomUnit to (Player((Load 0 of id from ragemodehashtable))) and Change color
      • Unit - Make PickedRandomUnit Vulnerable
      • Hashtable - Clear all child hashtables of child id in ragemodehashtable
There it is.
 
  • Set TempUnit = (Last created unit)
    • Set TempPlayerNumber = (Player number of (Owner of TempUnit))
    • Player Group - Add TempPlayer to PlayersPlaying
    • Unit - Create 1 Crazy Survivor for TempPlayer at TempPoint facing Default building facing degrees
    • Set Survivors[TempPlayerNumber] = TempUnit
Just do:
  • Set TempPlayerNumber = (Player number of TempPlayer)
  • Player Group - Add TempPlayer to PlayersPlaying
  • Unit - Create 1 Crazy Survivor for TempPlayer at TempPoint facing Default building facing degrees
  • Set Survivors[TempPlayerNumber] = (Last created unit)
I am guessing that Zombies[PickedRandomPlayer] are not initialized. Use CreateGroup() before defining their components.
 
Level 4
Joined
May 17, 2011
Messages
106
I am guessing that Zombies[PickedRandomPlayer] are not initialized. Use CreateGroup() before defining their components.

And how do I do that with an array? and where? Cause I'm trying to do so and it won't work...
 
Level 4
Joined
May 17, 2011
Messages
106
maybe try create at map init with loop to all 12 player

I can't do that. I need to set my PickedRandomPlayer variable in this specific trigger because I need it to be resetted each time the trigger runs to pick a new player each time.

The only thing I could do is make another trigger that would have the same specific event and would set my variable but that would be pointless. I don't need two triggers for one job.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
I can't do that. I need to set my PickedRandomPlayer variable in this specific trigger because I need it to be resetted each time the trigger runs to pick a new player each time.

u dont got, it, if u create group then just u prepare for later usage so u can do like we said
  • Custom script: set udg_Zombies[1] = CreateGroup()
  • Custom script: set udg_Zombies[2] = CreateGroup()
  • Custom script: set udg_Zombies[3] = CreateGroup()
  • Custom script: set udg_Zombies[4] = CreateGroup()
  • ....................................................................
    • Custom script: set udg_Zombies[12] = CreateGroup()
 
Status
Not open for further replies.
Top