• 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.

[Solved] -set kills #

Status
Not open for further replies.
Level 1
Joined
Oct 14, 2011
Messages
6
I need help about limiting kills in my map. When map finishes loading player 1 have to enter -set kills 'some integer' . i cant figure it out. i need some variable or what??
 
Level 13
Joined
Jun 1, 2008
Messages
360
Here is an example from one of my maps:

  • TEST set wave
    • Events
      • Player - Player 1 (Red) types a chat message containing wave as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 4)) Equal to wave
    • Actions
      • Set x = (Integer((Substring((Entered chat string), 5, (Length of (Entered chat string))))))
 
I think, you want set a kill limit and when a team reach this limit, she win the game.

Here is the "-kill max" mode from my map :

  • KillMax XX
    • Events
      • Player - Player 1 (Red) types a chat message containing -km as A substring
    • Conditions
    • Actions
      • Set KM_bol_on = TRUE
      • Set KM_Limit = (Integer((Substring((Entered chat string), 5, (Length of (Entered chat string))))))
      • Game - Display to (All players) the text: (Player 1 has activated the -km mode with a limit of + ((String(KM_Limit)) + kills.))
  • KM limit
    • Events
      • Unit - A unit Die
    • Conditions
      • ((Dying unit) is A hero) Equal to TRUE
      • KM_bol_on Equal to TRUE
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Dying unit) belongs to an enemy of (Owner of (Killing unit))) Equal to TRUE
        • Then - Actions
          • Set TeamKills[(Team number of (Owner of (Killing unit)))] = (TeamKills[(Team number of (Owner of (Killing unit)))] + 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KM_bol_on Equal to TRUE
          • TeamKills[(Team number of (Owner of (Killing Unit)))] Superior or Equal to KM_Limit
        • Then - Actions
          • Player Group - Pick every player in (All enemies of (Owner of (Killing unit))) and do (Actions)
            • Loop - Actions
              • Game - Defeat (Picked player) with the message: The Other Team win the game.
          • Player Group - Pick every player in (All allies of (Owner of (Killing unit))) and do (Actions)
            • Loop - Actions
              • Game - Victory (Picked player) (Show dialogs, Show scores)
          • Unit - Pause all units
        • Else - Actions
 
Last edited:
Level 8
Joined
Jan 8, 2010
Messages
493
if you can see both triggers have a "Substring()" function in them. the Substring function is very useful when you use the chat to enter something into the game. you can actually see how the function works when you select it at the Trigger Editor.

you can look at this tutorial to know something about chat commands. especially what you want is a "-set kills" chat command using Substrings. if you have any questions feel free to ask X]
 
Level 8
Joined
Jan 8, 2010
Messages
493
Substring(String,Integer1,Integer2)
String - is the string you wanted, whether it is an inputted command, a unit type, hero's name, etc.
Integer1 - the first character for your substring
Integer2 - the last character for your substring
*any characters between the first and last character is included in your substring

take a look at Vladadamm's example. he types a "-km" command which tells that it will set the kill max.

lets say you put "-km 100". the trigger with the
  • Player - Player 1 (Red) types a chat message containing -km as A substring
starts, since the player entered a chat message containing a "-km" in it. then the action
  • Set KM_Limit = (Integer((Substring((Entered chat string), 5, (Length of (Entered chat string))))))
will set the KM_Limit to 100. for the Substring((Entered chat string), 5, (Length of (Entered chat string))), it commands the computer to take the substring from the Entered chat string, which is "-km 100". the 5 states that the first character of the substring is the 5th character on your string, which is 1
1234567
-km 100

lastly, the (Length of (Entered chat string)) states that the last character for the substring is the length of entered chat, so if you input "-km 100", the length will be 7 character, so it will be 0
1234567
-km 100

therefore, the substring will be "100", which you will need to convert to an integer and set it to KM_Limit. the two integer values

for you, since the one you wanted to type is "-set kills xxx", the first integer should be 11.
 
Status
Not open for further replies.
Top