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

Hero/es Swap System

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Ok here it is, first uploaded spell/system from me!
User requested this so I created it for him!

Hero/es swap system!

Where to use this, how it works, what is it?

Hero swap system can be used in any team play based map (Arena, AoS and so on), it allow 2 players to swap (change owner of) their hero/es!

Everything is very well explained, there are 2 teams in test map, each one has 2 user and 2 computer controlled players!

Why computer players?
To see difference between user and cp!
If you request swap with computer it will swap heroes right away!
Still if you request swap with another user you need to wait for his approval!

All you need to do is to write:

-swap

and fallow instructions!

Versions:

Version 1.0
-Uploaded
Version 1.1
-Removed Wait 0.00 action (work fine without it)
Version 1.2
-Reduced number of triggering triggers a lot, only 1 trigger do job now!
-Optimized [-swap] trigger as well

Credits:

-Thanks to Maker for ideas


  • Swap Command
    • Events
      • Player - Player 1 (Red) types a chat message containing -swap as An exact match
      • Player - Player 2 (Blue) types a chat message containing -swap as An exact match
      • Player - Player 3 (Teal) types a chat message containing -swap as An exact match
      • Player - Player 4 (Purple) types a chat message containing -swap as An exact match
      • Player - Player 7 (Green) types a chat message containing -swap as An exact match
      • Player - Player 8 (Pink) types a chat message containing -swap as An exact match
      • Player - Player 9 (Gray) types a chat message containing -swap as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -swap as An exact match
    • Conditions
    • Actions
      • -------- ----------- --------
      • -------- Simple conditions that check if players play, show their numbers and so on! --------
      • -------- ----------- --------
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) slot status) Equal to Is playing
              • ((Triggering player) is an ally of (Player((Integer A)))) Equal to True
              • (Triggering player) Not equal to (Player((Integer A)))
            • Then - Actions
              • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: (To Request Swap with + ((Name of (Player((Integer A)))) + ( write -swap + (String((Player number of (Player((Integer A)))))))))
            • Else - Actions
  • Swap Setup
    • Events
      • Player - Player 1 (Red) types a chat message containing -swap as A substring
      • Player - Player 2 (Blue) types a chat message containing -swap as A substring
      • Player - Player 3 (Teal) types a chat message containing -swap as A substring
      • Player - Player 4 (Purple) types a chat message containing -swap as A substring
      • Player - Player 7 (Green) types a chat message containing -swap as A substring
      • Player - Player 8 (Pink) types a chat message containing -swap as A substring
      • Player - Player 9 (Gray) types a chat message containing -swap as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -swap as A substring
    • Conditions
    • Actions
      • -------- ----------- --------
      • -------- Maybe silly but without this check game will be crashed if we write only "-swap " --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to -swap
        • Then - Actions
        • Else - Actions
          • -------- ----------- --------
          • -------- We add player that write command into variable! --------
          • Set HSS_Player[1] = (Triggering player)
          • -------- ----------- --------
          • -------- We add requested player into variable as well! --------
          • Set HSS_String = (Integer((Substring((Entered chat string), 6, 8))))
          • -------- ----------- --------
          • -------- Now we check number of requested player! --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • HSS_String Greater than or equal to 1
                  • HSS_String Less than or equal to 4
              • Or - Any (Conditions) are true
                • Conditions
                  • HSS_String Greater than or equal to 7
                  • HSS_String Less than or equal to 10
            • Then - Actions
              • -------- ----------- --------
              • -------- Add Requested player into variable --------
              • Set HSS_Player[2] = (Player(HSS_String))
            • Else - Actions
          • -------- ----------- --------
          • -------- Main part of problem, we need 3th neutral player, will explain below why! --------
          • Set HSS_Player[3] = Neutral Passive
          • -------- ----------- --------
          • -------- Boolean variable used as vote system for user controled swap requests! --------
          • Set HSS_Request[(Player number of HSS_Player[1])] = True
          • -------- ----------- --------
          • -------- This will check if you try to swap with yourself or hero from enemy team^^ --------
          • -------- ----------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • HSS_Player[1] Equal to HSS_Player[2]
                  • (HSS_Player[1] is an ally of HSS_Player[2]) Equal to False
            • Then - Actions
            • Else - Actions
              • -------- ----------- --------
              • -------- Simpe display messages used to inform players that someone want to swap hero/es with them --------
              • -------- ----------- --------
              • Game - Display to (Player group(HSS_Player[1])) for 10.00 seconds the text: (You requested swap with + (Name of HSS_Player[2]))
              • Game - Display to (Player group(HSS_Player[2])) for 10.00 seconds the text: ((Name of HSS_Player[1]) + requested swap with you!)
              • -------- ----------- --------
              • -------- Now when all variables are set we can run main trigger to do main checking! --------
              • -------- ----------- --------
              • Trigger - Run Swap <gen> (checking conditions)
  • Swap
    • Events
    • Conditions
    • Actions
      • -------- ----------- --------
      • -------- This check if player is controled by user or computer! --------
      • -------- If you requested to swap with CP main trigger actions will be activated, if not it must check request or approval from other player to run main swap trigger actions! --------
      • -------- ----------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (HSS_Player[2] controller) Equal to User
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HSS_Request[(Player number of HSS_Player[1])] Equal to True
              • HSS_Request[(Player number of HSS_Player[2])] Equal to True
            • Then - Actions
              • Set HSS_Request[(Player number of HSS_Player[1])] = False
              • Set HSS_Request[(Player number of HSS_Player[2])] = False
              • Trigger - Run Swap Loop <gen> (ignoring conditions)
            • Else - Actions
        • Else - Actions
          • Trigger - Run Swap Loop <gen> (ignoring conditions)
  • Swap Loop
    • Events
    • Conditions
    • Actions
      • -------- ----------- --------
      • -------- Swap System --------
      • -------- ----------- --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by HSS_Player[1] matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit - Change ownership of (Picked unit) to HSS_Player[3] and Change color
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by HSS_Player[2] matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit - Change ownership of (Picked unit) to HSS_Player[1] and Change color
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by HSS_Player[3] matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit - Change ownership of (Picked unit) to HSS_Player[2] and Change color


Please post suggestions, ideas and maybe some hints how to make it better and after all maybe I learn something new!

Thanks and have a good day!
-Kobas-

Keywords:
Swap, System, Hero, Heroes, -Kobas-
Contents

Hero Swap System (Map)

Reviews
http://www.hiveworkshop.com/forums/spells-569/identify-system-1-00-a-183934/?prev=r%3D20%26status%3Dr2%26page%3D4113:36, 4th Mar 2011 Bribe: This is lacking and leaking. Status: Rejected until updated

Moderator

M

Moderator

http://www.hiveworkshop.com/forums/spells-569/identify-system-1-00-a-183934/?prev=r%3D20%26status%3Dr2%26page%3D4113:36, 4th Mar 2011
Bribe:

This is lacking and leaking.

Status: Rejected until updated
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Do like this:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Triggering unit) is A structure) Equal to True
      • ((Triggering unit) is A structure) Equal to True
Not like this:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) is A structure) Equal to True
          • ((Triggering unit) is A structure) Equal to True
You could use substring like this:
  • Set p[2] = (Player((Integer((Substring((Entered chat string), 7, 7))))))
To get the player number. And check that substring 1,6 == -swap .

Make it MPI.
 
I remove it, work fine like this as well!
Btw to answer you with example:

  • Burrow strike
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Impale
    • Actions
      • Set Point_Temp = (Target point of ability being cast)
      • Wait 0.00 seconds
      • Unit - Move (Triggering unit) instantly to Point_Temp
      • Custom script: call RemoveLocation (udg_Point_Temp)
Create this spell and try it with wait and then without it! :razz:

Thanks Maker, Tank-Commander already told me about substring but each time when I try to use that it crush game!
Grrr give me few min I will try again!
 
Level 12
Joined
Apr 16, 2010
Messages
584
Okay this looks interesting. I need this system for my map, but i'm too lazy to do it myself, so i'm gonna wait till you finish it, and +rep and into credits.
Oh wait, you already fixed this, well then i'll just test it myself and see if all works fine.
Edit: eh, sorry won't be using this system, cuz i need a lot more options to my map, such as: checking teams (i have 3 teams), checking controllers, checking levels.
And there's a bug, for example: when you type -swap 2 and then type -swap 3 you will be swapped with player 3, or if you type -swap 3 and then -swap 2 you I'll be swapped with player 2. Also add condition so you couldn't request swap with computers, only with users. Swapping between computers would be a serious problem in some maps, like DotA. Also you need to replace swapped heroes with places. Well i guess thats all, just remember from DotA (if you play it) what swap actions do there.
 
You played dota ai?
You can swap with computer!
But if you want you can remove it like this:
  • Swap
    • Events
    • Conditions
    • Actions
      • -------- ----------- --------
      • -------- This check if player is controled by user or computer! --------
      • -------- If you requested to swap with CP main trigger actions will be activated, if not it must check request or approval from other player to run main swap trigger actions! --------
      • -------- ----------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (HSS_Player[2] controller) Equal to User
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HSS_Request[(Player number of HSS_Player[1])] Equal to True
              • HSS_Request[(Player number of HSS_Player[2])] Equal to True
            • Then - Actions
              • Set HSS_Request[(Player number of HSS_Player[1])] = False
              • Set HSS_Request[(Player number of HSS_Player[2])] = False
              • Trigger - Run Swap Loop <gen> (ignoring conditions)
            • Else - Actions
        • Else - Actions
          • ----Delete this trigger action in this trigger! -----
Also those conditions you need can be added with simple if then else functions!
This is base setup and idea, I can't create system that will work only for your map!

Also
when you type -swap 2 and then type -swap 3 you will be swapped with player 3
I don't see anything wrong here you swap with 1 player than with another just like in map that you gave as example!

If you want to set limit with 1 swap per player or disable this option after some time, add more teams and shit you need to use triggers that will do that for you!

1 more thing, this will work for 3,4 and more teams, it check player enemies not number to allow switch, map is example to show you, add another force to map and test it, it will work just fine!

Thanks for suggestions btw!
 
Level 13
Joined
Mar 24, 2010
Messages
950
I remove it, work fine like this as well!
Btw to answer you with example:

  • Burrow strike
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Impale
    • Actions
      • Set Point_Temp = (Target point of ability being cast)
      • Wait 0.00 seconds
      • Unit - Move (Triggering unit) instantly to Point_Temp
      • Custom script: call RemoveLocation (udg_Point_Temp)
Create this spell and try it with wait and then without it! :razz:

Thanks Maker, Tank-Commander already told me about substring but each time when I try to use that it crush game!
Grrr give me few min I will try again!

i dont see that you have waits anymore, but if you truely needed to do it that way you shouldnt have the wait after the setting var to point and removing it.
like this
  • Actions
    • Wait 0.00 seconds
    • Set Point_Temp = (Target point of ability being cast)
    • Unit - Move (Triggering unit) instantly to Point_Temp
    • Custom script: call RemoveLocation (udg_Point_Temp)
prob is if by chance more than 1 person did it, the first point would never be removed but the 2nd one would. this also might not work becuz it might not save the target point fast enough with the wait first anway. :/ lol

Also in your 2nd trigger at the top you can improve it by getting rid of that if-then and just putting the check in the first conditions that way the trigger wont even run if they just type -swap
this part
  • Conditions
  • Actions
  • -------- ----------- --------
  • -------- Maybe silly but without this check game will be crashed if we write only "-swap " --------
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Entered chat string) Equal to -swap
  • Then - Actions
  • Else - Actions
  • the rest of your triggers
get rid of the if-then and put it here
  • Conditions
    • (Entered chat string) Not Equal to -swap
  • Actions
then your set :)

nice system though +rep :)
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,456
Swap Command

Game - Display to (Player group((Triggering player))) for 10.00 seconds the text:

- Leaks

All those identical event registries? There are easier ways to do it via loops and "Trigger - Add to X the event (X)"

Swap Setup

Game - Display to (Player group(HSS_Player[1])) for 10.00 seconds the text: (You requested swap with + (Name of HSS_Player[2]))
Game - Display to (Player group(HSS_Player[2])) for 10.00 seconds the text: ((Name of HSS_Player[1]) + requested swap with you!)

- Both of these leak.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,456
What I mean:

Instead of:
  • Player - Player 1 (Red) types a chat message containing -swap as An exact match
  • Player - Player 2 (Blue) types a chat message containing -swap as An exact match
  • Player - Player 3 (Teal) types a chat message containing -swap as An exact match
  • Player - Player 4 (Purple) types a chat message containing -swap as An exact match
  • Player - Player 7 (Green) types a chat message containing -swap as An exact match
  • Player - Player 8 (Pink) types a chat message containing -swap as An exact match
  • Player - Player 9 (Gray) types a chat message containing -swap as An exact match
  • Player - Player 10 (Light Blue) types a chat message containing -swap as An exact matc
Do:

  • Swap Command Setup
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) slot status) Equal to Is playing
            • Then - Actions
              • Trigger - Add to Swap Command the event: Player - (Player((Integer A))) types a chat message containing -swap as An exact match
            • Else - Actions
 
Level 2
Joined
Dec 21, 2018
Messages
12
Does anyone know the colour codes for players 13-24? I have tried to Google it but I cannot find anything. I really want this to work for all 24 players properly :D
 
Top