• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[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