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

Remove Random Unit from Group/ Add Unit to another Group

Status
Not open for further replies.
Level 7
Joined
Jun 8, 2010
Messages
283
Ive made a dialog system for a game mode. Basically at the beginning all unused players are removed from the game. Those who are in "Is Playing" slot status condition, will be added to the unit group "Team_Human" which is basically the human team. Then when selecting the corresponding dialog button selecting One, Two, or Three player zombies would randomy remove those player's Units from the Unit Group "Team_Human" and add them to the unit group "Team_Zombie" also creating a zombie unit for those selected.

I have 3 different variations of this trigger that will randomly select a player's unit, remove their "Human" unit and then create a zombie unit.

Heres the current trigger, theres 2 (first one is when Host selects 1 Zombie, and second trigger is when host selects 2 zombies). I didnt include the third trigger because its pretty much the same except with the creation of 3 units.

I know I didnt use the variable there properly, and it does nothing, but I just left it there so you can get a general idea of what im trying to accomplish.

  • infection 1 zombie
    • Events
      • Dialog - A dialog button is clicked for dialogwindow
    • Conditions
      • (Clicked dialog button) Equal to dialogbutton[5]
    • Actions
      • Game - Display to (All players) for 10.00 seconds the text: ((Name of Host) + has selected Infection Mode)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • Unit Group - Add (Random unit from team_human) to team_zombie
          • Set a_selectedunit[1] = (Random unit from team_zombie)
          • Unit Group - Remove a_selectedunit[1] from team_human
          • Unit - Create 1 Zombie (Hooked Flesh) for (Owner of a_selectedunit[1]) at (Center of start squad mode 1 <gen>) facing Default building facing degrees
        • Else - Actions
      • Unit Group - Pick every unit in team_human and do (Actions)
        • Loop - Actions
          • Unit - Move (Picked unit) instantly to (Random point in start squad mode 1 <gen>), facing Default building facing degrees
      • Cinematic - Fade in over 5.00 seconds using texture Black Mask and color (100.00%, 100.00%, 100.00%) with 0.00% transparency
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Camera - Lock camera target for (Player((Player number of (Picked player)))) to PlayersHero[(Player number of (Picked player))], offset by (0.00, 0.00) using Default rotation
          • Set CurrentCamera[(Player number of (Picked player))] = 2
  • infection 2 zombies
    • Events
      • Dialog - A dialog button is clicked for dialogwindow
    • Conditions
      • (Clicked dialog button) Equal to dialogbutton[5]
    • Actions
      • Game - Display to (All players) for 10.00 seconds the text: ((Name of Host) + has selected Infection Mode)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • Unit Group - Add (Random unit from team_human) to team_zombie
          • Set a_selectedunit[1] = (Random unit from team_zombie)
          • Unit Group - Remove a_selectedunit[1] from team_human
          • Unit - Create 1 Zombie (Hooked Flesh) for (Owner of a_selectedunit[1]) at (Center of start squad mode 1 <gen>) facing Default building facing degrees
          • Unit Group - Add (Random unit from team_human) to team_zombie
          • Set a_selectedunit[2] = (Random unit from team_zombie)
          • Unit Group - Remove a_selectedunit[2] from team_human
          • Unit - Create 1 Zombie (Hooked Flesh) for (Owner of a_selectedunit[2]) at (Center of start squad mode 1 <gen>) facing Default building facing degrees
          • Unit Group - Add (Random unit from team_human) to team_zombie
          • Set a_selectedunit[3] = (Random unit from team_zombie)
          • Unit Group - Remove a_selectedunit[3] from team_human
          • Unit - Create 1 Zombie (Hooked Flesh) for (Owner of a_selectedunit[3]) at (Center of start squad mode 1 <gen>) facing Default building facing degrees
        • Else - Actions
      • Unit Group - Pick every unit in team_human and do (Actions)
        • Loop - Actions
          • Unit - Move (Picked unit) instantly to (Random point in start squad mode 1 <gen>), facing Default building facing degrees
      • Cinematic - Fade in over 5.00 seconds using texture Black Mask and color (100.00%, 100.00%, 100.00%) with 0.00% transparency
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Camera - Lock camera target for (Player((Player number of (Picked player)))) to PlayersHero[(Player number of (Picked player))], offset by (0.00, 0.00) using Default rotation
          • Set CurrentCamera[(Player number of (Picked player))] = 2
EDIT: I also have this trigger that would create randomly a zombie at a random point position of a human unit.
  • Unit - Create 1 Zombie (Hooked Flesh) for Neutral Hostile at (Random point in (Region centered at (Position of (Random unit from team_human)) with size (10.00, 10.00))) facing (Random angle) degrees
But this will also create zombies in places where zombies cant even get out of. I know the "Playable" map function will create units where that can move around (this excludes small tight places like trees where a unit cant get out of) but I dont know how to incorporate it to my trigger so it would be something like:

Unit - Create 1 Zombie (Hooked Flesh) for Neutral Hostile at (Random point in (Region centered at (Playable Map Position of (Random unit from team_human)) with size (10.00, 10.00))) facing (Random angle) degrees
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
But this will also create zombies in places where zombies cant even get out of. I know the "Playable" map function will create units where that can move around (this excludes small tight places like trees where a unit cant get out of) but I dont know how to incorporate it to my trigger so it would be something like:

Unit - Create 1 Zombie (Hooked Flesh) for Neutral Hostile at (Random point in (Region centered at (Playable Map Position of (Random unit from team_human)) with size (10.00, 10.00))) facing (Random angle) degrees

The problem here is that the zombie is being placed in a playable map area. The game doesn't really know whether or not you can "escape" an area that you are placed - you're going to have to note these positions yourself and avoid them manually. I suppose you could check the pathability at points around the placed unit and see whether it is "trapped" or not but that isn't guaranteed to work 100% of the time.
 
Level 7
Joined
Jun 8, 2010
Messages
283
Oh, I assumed Playable Map Area took into account the pathings whereas Entire Map included every aspect of the map.
Anyways how do you propose you would trigger it? Is that the only possible way, or are there other alternatives I can take?
 
Level 7
Joined
Jun 8, 2010
Messages
283
Never mind, well I got it working now.

How would I set alliances of players using unit groups? Right now I have units organized in unit groups because the setup for unit groups were much more easier and I didnt know how to do it through Player Groups.

Can anyone help me on this :|?
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Never mind, well I got it working now.

So what did you end up doing to solve the problem?

How would I set alliances of players using unit groups? Right now I have units organized in unit groups because the setup for unit groups were much more easier and I didnt know how to do it through Player Groups.

You could use the owning player of the unit to determine the associated player - this is a fairly simple approach, though using player groups in conjunction with unit groups isn't all that complex either.
 
Level 7
Joined
Jun 8, 2010
Messages
283
With the implementation of the player groups in conjunction with the unit groups, I was able to successfully create the dialog trigger using variables and working my way around it.

Anyways.. I still cant seem to get that spawn trigger correctly. Also, the zombies are stupid, AI is terrible. They just run into walls and stay there.. Theres openings and doorways but only 1/4 of the mobs walk into the houses.

The other 3/4 just stand next to the other side of the wall trying to get the survivors within..
 
Level 7
Joined
Jun 8, 2010
Messages
283
Yeah just right into the wall. I only spawn them one at a time. if spawned inside the house then it will manuever its way through... Very slowly though, bit by bit

which i guess slowly is fine since its a zombie but right into the wall ruins the gameplay... just terrible
 
Level 7
Joined
Jun 8, 2010
Messages
283
Cant remember the exact size but its the size of wc3's stone wall models, only the 90 degree oriented ones though (horizontal and vertical). I think 3x1?

So if not this size then by how much would you suggest? Also why a bigger pathing texture, does wc's AI not detect such sizes?

Also when created a zombie, I would store the created unit in a variable and order it to attack a random unit in the unit group (Human_Team). Perhaps thr issue orders cayse the problem? Is their a more efficient way of ordering units to attack another?
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I would try issuing an "attack move" order rather than an "attack" order; it will cause heroes that could possibly come in the path of the zombie to be attacked instead of the zombie simply trying to bypass it; it also may help with the pathing calculations.
 
Status
Not open for further replies.
Top