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
 
Level 13
Joined
Jan 2, 2016
Messages
978
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
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
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.
 
Level 1
Joined
Mar 26, 2016
Messages
3
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...
 
Level 25
Joined
May 11, 2007
Messages
4,650
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.
Top