• 🏆 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] Change Unit Owner to Random Player

Status
Not open for further replies.
Level 2
Joined
May 17, 2018
Messages
16
Hey Guys,
I'm working on a Map where you have 10 players and each player has a hero,
after a certain amount of time the ownership of heroes is swapped at random but at all times every players should always control only 1 hero. This is exactly where the problems start since often enough 1 player controls multiple heroes and another player controls no hero at all, which is not intended.
I have tried to disable all functions that are irrelevant for ownership change.
I'm glad about any suggestions and forms of help

here the trigger text:

ChangeGoldmasterOwner
Events
Time - OtherPlayerGainsControllTimer expires
Conditions
Actions
Countdown Timer - Start GoldmasterControllReturnTimer as a One-shot timer that will expire in 120.00 seconds
Countdown Timer - Create a timer window for (Last started timer) with title Clear Mind
Set ReturnTimerHer = (Last created timer window)
For each (Integer A) from 1 to NumberofPlayersPlaying, do (Actions)
Loop - Actions
Wait 1.00 seconds
Unit - Add Plunder to Goldmasters[(Integer A)]
Destructible - Close PrisonWalls[((Integer A) - 1)]
Player Group - Remove (Player((Integer A))) from RandomplayerGroup
Set PlayerBeeingRemovedFromGroup = (Random player from RandomplayerGroup)
Countdown Timer - Start TimeLimitToHackTimer[(Integer A)] as a One-shot timer that will expire in 0.50 seconds
Hashtable - Save (Player number of PlayerBeeingRemovedFromGroup) as 1 of (Key (Last started timer)) in Timers_Hashtable
Set PlayerinControlIsInRegion[(Player number of PlayerBeeingRemovedFromGroup)] = (Integer A)
Unit - Change ownership of Goldmasters[(Integer A)] to PlayerBeeingRemovedFromGroup and Change color
Set Goldmasternumbers[(Player number of PlayerBeeingRemovedFromGroup)] = Goldmaster[(Integer A)]
Player Group - Remove PlayerBeeingRemovedFromGroup from RandomplayerGroup
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
PlayerinControlIsInRegion[(Integer A)] Greater than or equal to 0
(Goldmasternumbers[(Player number of (Player((Integer A))))] is empty) Equal to True
Then - Actions
Player Group - Add (Player((Integer A))) to RandomplayerGroup
Game - Display to (All players) the text: Debug2
Else - Actions
Animation - Change Goldmasters[(Integer A)]'s vertex coloring to (100.00%, 4.00%, 4.00%) with 0.00% transparency
Unit - Set mana of HQs[(Integer A)] to (10.00 x ManaOfHq[(Integer A)])
Game - Display to (All players) the text: Debug
Set OtherPlayersNowInControl = True
Wait 2.00 seconds
For each (Integer A) from 1 to NumberofPlayersPlaying, do (Actions)
Loop - Actions
Unit Group - Pick every unit in Goldmasternumbers[(Integer A)] and do (Actions)
Loop - Actions
Unit Group - Remove (Picked unit) from Goldmasternumbers[(Integer A)]
Game - Display to (All players) the text: Debug1
 

Attachments

  • Trigger1.jpg
    Trigger1.jpg
    164.5 KB · Views: 85
Last edited:
Level 12
Joined
Mar 24, 2011
Messages
1,082
You could take a look here A simple question about Variables (which is not even that far down the threads list...)

They are explaining how you could switch around Integer variables, but this is applicable for any variable.

You are looking at something of the sort of:
  • int_numPlayers = NumberOfPlayers //or 10 or maxslotplayers
  • int_HeroesRemaining = int_numPlayers
  • Add all heroes to unit_HeroList[int_numPlayers]
  • For loopDex 1 to int_numPlayers
    • Set int_randomHeroNumber = Pick a random number from 1 to int_HeroesRemaining
    • Give unit_HeroList[int_randomHeroNumber] to player(loopDex)
    • Set unit_HeroList[int_randomHeroNumber] = unit_HeroList[int_HeroesRemaining]
    • int_HeroesRemaining = int_HeroesRemaining - 1
Before any further questions read through the thread above ^

Regards
-Ned
 
Level 2
Joined
May 17, 2018
Messages
16
Thx for the answer, sorry if it looks like i didn't research properly beforehand but "A simple question about Variables" is not really a telling title. Anyways you are right that thread provides the answers i've been looking for. Just not sure how it works when theres empty slots in the lobby so if it still works if slot 2 and 3 are empty for example but i'll see
<3 xoxo,
Rock
 
Last edited:
Level 12
Joined
Mar 24, 2011
Messages
1,082
Thx for the answer, sorry if it looks like i didn't research properly beforehand but "A simple question about Variables" is not really a telling title. Anyways you are right that thread provides the answers i've been looking for. Just not sure how it works when theres empty slots in the lobby so if it still works if slot 2 and 3 are empty for example but i'll see
<3 xoxo,
Rock

There are functions to filter only occupied slots vs. empty slots and users vs. computers.

regards
-Ned
 
Last edited:
Level 2
Joined
May 17, 2018
Messages
16
Btw I don't know wether a moderator has to do it or wether i just can't find the right but this thread can be set to solved. I already opened a thread with my new problem ;). I'll try to make myself useful and help out with other threads if i can find something where my abilities allow me to help.
 
Status
Not open for further replies.
Top