• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

creating units with chat

Status
Not open for further replies.
Level 1
Joined
Mar 26, 2016
Messages
3
I've set 100+ unit type as variables, was wondering is there a shortcut to summon a unit type by just typing their corresponding variable number in event chat? I dont want to put a event chat one by one

here is a example

Events
Player - Player 1 (Red) types a chat message containing 1 as An exact match
Player - Player 1 (Red) types a chat message containing 2 as An exact match
Player - Player 1 (Red) types a chat message containing 3 as An exact match
Player - Player 1 (Red) types a chat message containing 100 as An exact match
Conditions
Actions
Unit - Create 1 RNG_UNIT[(Integer((Entered chat string)))] for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
 
And I would do it like:
Player - Player 1 (Red) types a chat message containing -summon as A substring
Actions:
Set TempInteger = String to Integer(Substring(Entered chat string, 9, String Lenght(Entered chat string)))
Unit - Create 1 RNG_UNIT[TempInteger] for Player 1 (Red) at (Center of (Playable map area)) facing Default building degrees
 
It will do nothing, nothing will happen.
Sometimes it crashes... depends on what you are doing with it.

You should make a command starting with "-" or "/" followed by a string that will be used to summon the minions.

For example:
/summon 192
/summon 5
/summon 0
/summon a

You check if the entered chat string starts with "/summon ",
then you do a substring call to remove that part, so you will get:
"192"
"5"
"0"
"a"

Then you can do an interger conversion (from string to integer).
Then you check if the value is not 0 aka is a valid number (illegal numbers are also displayed as 0).
Then you can use that as your number to spawn the unit.

If you want to have additional parameters like:
/summon unit_type x_coord y_coord
then you have to split up the string in words.
There should be a library around here with the functions to do that.
 
my friend already solved it for me

test summon init
Events
Map initialization
Conditions
Actions
-------- Set how many units in list -1. --------
Set max_summ_var = 1
-------- Set units here, from 0 to max_summ_var. --------
Set summ[0] = Blood Mage
Set summ[1] = Mountain King
Set summ[2] = Archmage
Set summ[3] = Paladin
-------- LIST END --------
-------- Unit text event initialization adding. --------
For each (Integer A) from 1 to 12, do (Actions)
Loop - Actions
Trigger - Add to test summon <gen> the event (Player - (Player((Integer A))) types a chat message containing -n as A substring)

--------------------------------------------------

test summon
Events
Conditions
Actions
Set summ_var = (Integer((Substring((Entered chat string), 3, 6))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
summ_var Less than or equal to summ_var
Then - Actions
Unit - Create 1 summ[summ_var] for (Triggering player) at (Point((Target X of current camera view), (Target Y of current camera view))) facing (Random angle) degrees
Game - Display to (Player group((Triggering player))) the text: (Summoned: + (String(summ[summ_var])))
Else - Actions
Game - Display to (Player group((Triggering player))) the text: No unit yet. Coming...
 
my friend already solved it for me
  • test summon init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Set how many units in list -1. --------
      • Set max_summ_var = 1
      • -------- Set units here, from 0 to max_summ_var. --------
      • Set summ[0] = Blood Mage
      • Set summ[1] = Mountain King
      • Set summ[2] = Archmage
      • Set summ[3] = Paladin
      • -------- LIST END --------
      • -------- Unit text event initialization adding. --------
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Trigger - Add to test summon <gen> the event (Player - (Player((Integer A))) types a chat message containing -n as A substring)
--------------------------------------------------
  • test summon
    • Events
    • Conditions
    • Actions
      • Set summ_var = (Integer((Substring((Entered chat string), 3, 6))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • summ_var Less than or equal to summ_var
        • Then - Actions
          • Unit - Create 1 summ[summ_var] for (Triggering player) at (Point((Target X of current camera view), (Target Y of current camera view))) facing (Random angle) degrees
          • Game - Display to (Player group((Triggering player))) the text: (Summoned: + (String(summ[summ_var])))
        • Else - Actions
          • Game - Display to (Player group((Triggering player))) the text: No unit yet. Coming...

There ya go. Now it's readable.
 
Status
Not open for further replies.
Back
Top