• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] How to Random a Player and Make Him Enemy?

Status
Not open for further replies.
  • Player Group - Pick every player in (All players) and do (Actions)
  • Loop - Actions
    • Set Integer = (Random integer number between 1 and 12)
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (Picked player) Not Equal to (Player(Integer))
      • Then - Actions
        • Player - Make (Picked player) treat (Player(Integer)) as an Enemy
      • Else - Actions
Integer is an Integer variable.
To get (Player(IntegerA)), when it asks you for the player, go to Conversion - Convert Player Index to Player.

This trigger picks a random player and makes them an enemy to every other player of the map.

Reference:
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/variables-5896/

If this is not the answer you seek, please, be more specific.
 
Level 6
Joined
Jan 9, 2009
Messages
236
More =D

:mwahaha: it works but now instead of just choosing an enemy it chooses more than 2 lol
sorry i wasnt specific enough
Pick out of 12 players then random 1 = enemy
create a hero for enemy and create a peasant for non enemies:gg:
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Okay well the GUI script he posted (in a test I set up) makes all the players treat a single random player as if he were an enemy, though that player does not share the same hostility towards you. If your code is doing something differently, then please post what you have done.
 
Level 6
Joined
Jan 9, 2009
Messages
236
  • Events
    • Map initialization
  • Conditions
  • Actions
    • Player Group - Pick every player in (All players) and do (Actions)
      • Loop - Actions
        • Set Integer = (Random integer number between 1 and 12)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Picked player) Not equal to (Player(Integer))
          • Then - Actions
            • Player - Make (Picked player) treat (Player(Integer)) as an Enemy
            • Unit - Create 1 Artillery Unit for (Player(Integer)) at (Center of Region 001 <gen>) facing Default building facing degrees
          • Else - Actions
            • Unit - Create 1 Refugees (Male) for (Picked player) at (Center of Region 002 <gen>) facing Default building facing degrees
awesome :D cheers berbanog! well now i only added a few thing like creating a unit so i don't thing it'll affect the creation of more than 2 enemies
 
Level 15
Joined
Nov 26, 2005
Messages
1,151
  • Players
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- -- --------
      • Player Group - Add Player 1 (Red) to All_Players
      • Player Group - Add Player 2 (Blue) to All_Players
      • Player Group - Add Player 3 (Teal) to All_Players
      • Player Group - Add Player 4 (Purple) to All_Players
      • Player Group - Add Player 5 (Yellow) to All_Players
      • Player Group - Add Player 6 (Orange) to All_Players
      • Player Group - Add Player 7 (Green) to All_Players
      • Player Group - Add Player 8 (Pink) to All_Players
      • Player Group - Add Player 9 (Gray) to All_Players
      • Player Group - Add Player 10 (Light Blue) to All_Players
      • Player Group - Add Player 11 (Dark Green) to All_Players
      • Player Group - Add Player 12 (Brown) to All_Players
      • -------- -- --------
      • Set Player_Int = (Random integer number between 1 and 12)
      • -------- -- --------
      • Player Group - Remove (Player(Player_Int)) from All_Players
      • -------- -- --------
      • Player Group - Make (Player group((Player(Player_Int)))) treat All_Players as an Enemy
      • Player Group - Make All_Players treat (Player group((Player(Player_Int)))) as an Enemy
      • -------- -- --------
      • Custom script: call DestroyForce(udg_All_Players)
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
You clean up udg_All_Players but you do not clean up (Player group((Player(...)))). This all occurs on map initialization so cleaning up individual leaks is not super obligatory, but if you're going to clean up your forces then you might as well make sure you've got all of them.

All he needs to do is move his "Set Integer = ..." line outside of the player-group loop. The reason he's experiencing problems is because each iteration of the loop it will select a different random player.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
They'll probably both work. I don't know, I haven't even tested his. Why don't you try it out yourself and see which one works instead of getting us to do 100% of your work. Being a newbie doesn't mean you don't have to try at anything.

newbchu said:
but how =S thats what i meant lol

If you're incapable of dragging and dropping GUI code then I'm sorry but the World Editor is not for you.
 
Status
Not open for further replies.
Top