2987 Posts in 493 Topics - by 2195 Members - Latest Member: Warayurt

Warcraft III: MapsModelsSkinsIconsSpellsToolsTutorials
WC3 JASS: Code SnippetsJASS and vJASS Spells and SystemsJass Tutorials
Chat @Discord

Author Topic: [ vJASS ] About Spawn Unit  (Read 9314 times)

  • Rookie - level 3
  • ***
  • Posts: 123
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 3
  • A FRENGERS
    • View Profile
[ vJASS ] About Spawn Unit
« on: June 16, 2013, 05:53:54 AM »
How do I make:

Quote
-Spawn ( The Unit ID ) ( Value )

Spawn unit with entered unit ID, you can set how much the spawned unit

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 987
  • WC3 Models: 43
  • WC3 Tutorials: 13
  • WC3 Tools: 10
  • WC3 Maps: 11
  • WC3 Skins: 6
  • WC3 Icons: 2
  • WC3 Spells: 5
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
[ vJASS ] About Spawn Unit
« Reply #1 on: June 16, 2013, 12:33:09 PM »
Do you want it as a chat command??

We can give you full hosting for your projects, a complete page!!

A custom altered melee map where you can play Naga and Demons. Check it out!!
Use Dropbox...

  • Rookie - level 3
  • ***
  • Posts: 123
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 3
  • A FRENGERS
    • View Profile
[ vJASS ] About Spawn Unit
« Reply #2 on: June 16, 2013, 07:24:33 PM »
Of course - .. -
Oh I want it vJASS :3 :3 Because it's neat and cute :3 :3

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 987
  • WC3 Models: 43
  • WC3 Tutorials: 13
  • WC3 Tools: 10
  • WC3 Maps: 11
  • WC3 Skins: 6
  • WC3 Icons: 2
  • WC3 Spells: 5
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
[ vJASS ] About Spawn Unit
« Reply #3 on: June 19, 2013, 07:40:28 AM »
Ok, working in a idea, but the part of using unitid to call the unit requires more time.  Could it be:

Quote
-spawn 5 Knights
So we can use the formal name?? I thinkit could be easier

We can give you full hosting for your projects, a complete page!!

A custom altered melee map where you can play Naga and Demons. Check it out!!
Use Dropbox...

  • Rookie - level 3
  • ***
  • Posts: 123
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 3
  • A FRENGERS
    • View Profile
[ vJASS ] About Spawn Unit
« Reply #4 on: June 21, 2013, 02:35:15 AM »
No, I want id Unit ID
I had listed the Unit on the quest :D :D

  • Newbie - level 2
  • **
  • Posts: 21
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 1
    • View Profile
Re: [ vJASS ] About Spawn Unit
« Reply #5 on: August 31, 2015, 12:41:40 PM »
Well, you're going to need to figure out where to put them. Do you have a designated location for each player or do you want to base it off of the current location of a unit, or what? You didn't provide much information. Also, are you trying to make it so units will revive even though they aren't heroes, like in a more traditional RPG, or are you simply trying to create units once?

  • Rookie - level 3
  • ***
  • Posts: 123
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 3
  • A FRENGERS
    • View Profile
Re: [ vJASS ] About Spawn Unit
« Reply #6 on: March 10, 2016, 01:48:14 AM »
sorry bump, it's been a long time, i've been quite busy, anyway, please help me with these :3 :3
-spawn (Unit ID, not formal name!) (amounts, if not entered, just spawn it one)

  • Newbie - level 2
  • **
  • Posts: 21
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 1
    • View Profile
Re: [ vJASS ] About Spawn Unit
« Reply #7 on: March 10, 2016, 02:12:56 PM »
Have you tried the S2I function?

  • Rookie - level 1
  • *
  • Posts: 48
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 8
  • cool != useful
    • View Profile
Re: [ vJASS ] About Spawn Unit
« Reply #8 on: March 10, 2016, 03:26:04 PM »
You have still to convert the string in a valid integer.
It can be done of course, but it's not straight forward, for example 'hpea' (human peasant) is not a decimal base.
Hopefully there is already a resource for that :
http://www.hiveworkshop.com/forums/jass-resources-412/snippet-ascii-190746/

Ok, here we go :

Code: jass  [Select]
  1. library SpawnUnitByChat requires Ascii initializer init
  2.  
  3.    globals
  4.       private constant string KEY = "-spawn"
  5.       private constant player PLAYER = Player(0) // first player (red)
  6.       private constant real X = 0
  7.       private constant real Y = 0
  8.    endglobals
  9.  
  10.    private function Actions takes nothing returns nothing
  11.       local string chat = GetEventPlayerChatString()
  12.       local integer i = -1
  13.       local string s = ""
  14.       local string unitid = ""
  15.       local string count = ""
  16.      
  17.       chat = SubString(chat,StringLength(KEY)+1,StringLength(chat))
  18.       loop
  19.       set i = i+1
  20.       set s = SubString(chat,i,i+1)
  21.       exitwhen s == " " or s == null
  22.          set unitid = unitid+s
  23.       endloop
  24.  
  25.       loop
  26.       set i = i+1
  27.       set s = SubString(chat,i,i+1)
  28.       exitwhen s == " " or s == null
  29.          set count= count+s
  30.       endloop
  31.      
  32.       set i = S2I(count)
  33.       loop
  34.       set i = i-1
  35.          call CreateUnit(PLAYER,S2A(unitid),X,Y,0)
  36.       exitwhen i <= 0
  37.       endloop
  38.      
  39.    endfunction
  40.  
  41.    private function init takes nothing returns nothing
  42.        local trigger trig = CreateTrigger()
  43.  
  44.        call TriggerRegisterPlayerChatEvent(trig,PLAYER,KEY,false)
  45.        call TriggerAddAction(trig,function Actions)
  46.    endfunction
  47.  
  48. endlibrary

Note that i've written the code directly here, not tested, it could have errors, also you need to follow exactly this pattern :
-spawn unitid X

Where X is the numbers of units (optional).
We could improve the script and allow or not more spaces between the arguments, and add safety, but oh well i have not found an interesting string parsing library, so meh ...
« Last Edit: March 10, 2016, 04:55:51 PM by Troll-Brain »
vJass is already a jass preprocessor, no need to (ab)use vJass features in order to make some inferior vJass preprocessor coded "by hand".

  • Rookie - level 1
  • *
  • Posts: 48
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 8
  • cool != useful
    • View Profile
Re: [ vJASS ] About Spawn Unit
« Reply #9 on: March 11, 2016, 06:46:24 PM »
Now since i've the JNGP again, i've tried and fixed the two syntax errors.
The code seems to work as it should, after a short test with these commands :

-spawn hfoo 3
-spawn hpea

Code: jass  [Select]
  1.     library SpawnUnitByChat initializer init requires Ascii
  2.      
  3.        globals
  4.           private constant string KEY = "-spawn"
  5.           private constant player PLAYER = Player(0) // first player (red)
  6.           private constant real X = 0
  7.           private constant real Y = 0
  8.        endglobals
  9.      
  10.        private function Actions takes nothing returns nothing
  11.           local string chat = GetEventPlayerChatString()
  12.           local integer i = -1
  13.           local string s = ""
  14.           local string unitid = ""
  15.           local string count = ""
  16.          
  17.           set chat = SubString(chat,StringLength(KEY)+1,StringLength(chat))
  18.           loop
  19.           set i = i+1
  20.           set s = SubString(chat,i,i+1)
  21.           exitwhen s == " " or s == null
  22.              set unitid = unitid+s
  23.           endloop
  24.      
  25.           loop
  26.           set i = i+1
  27.           set s = SubString(chat,i,i+1)
  28.           exitwhen s == " " or s == null
  29.              set count= count+s
  30.           endloop
  31.          
  32.           set i = S2I(count)
  33.           loop
  34.           set i = i-1
  35.              call CreateUnit(PLAYER,S2A(unitid),X,Y,0)
  36.           exitwhen i <= 0
  37.           endloop
  38.          
  39.        endfunction
  40.      
  41.        private function init takes nothing returns nothing
  42.            local trigger trig = CreateTrigger()
  43.      
  44.            call TriggerRegisterPlayerChatEvent(trig,PLAYER,KEY,false)
  45.            call TriggerAddAction(trig,function Actions)
  46.        endfunction
  47.      
  48.     endlibrary

Enjoy :)
vJass is already a jass preprocessor, no need to (ab)use vJass features in order to make some inferior vJass preprocessor coded "by hand".

  • Rookie - level 3
  • ***
  • Posts: 123
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 3
  • A FRENGERS
    • View Profile
Re: [ vJASS ] About Spawn Unit
« Reply #10 on: March 12, 2016, 03:20:10 AM »
Now since i've the JNGP again, i've tried and fixed the two syntax errors.
The code seems to work as it should, after a short test with these commands :

-spawn hfoo 3
-spawn hpea

Code: jass  [Select]
  1.     library SpawnUnitByChat initializer init requires Ascii
  2.      
  3.        globals
  4.           private constant string KEY = "-spawn"
  5.           private constant player PLAYER = Player(0) // first player (red)
  6.           private constant real X = 0
  7.           private constant real Y = 0
  8.        endglobals
  9.      
  10.        private function Actions takes nothing returns nothing
  11.           local string chat = GetEventPlayerChatString()
  12.           local integer i = -1
  13.           local string s = ""
  14.           local string unitid = ""
  15.           local string count = ""
  16.          
  17.           set chat = SubString(chat,StringLength(KEY)+1,StringLength(chat))
  18.           loop
  19.           set i = i+1
  20.           set s = SubString(chat,i,i+1)
  21.           exitwhen s == " " or s == null
  22.              set unitid = unitid+s
  23.           endloop
  24.      
  25.           loop
  26.           set i = i+1
  27.           set s = SubString(chat,i,i+1)
  28.           exitwhen s == " " or s == null
  29.              set count= count+s
  30.           endloop
  31.          
  32.           set i = S2I(count)
  33.           loop
  34.           set i = i-1
  35.              call CreateUnit(PLAYER,S2A(unitid),X,Y,0)
  36.           exitwhen i <= 0
  37.           endloop
  38.          
  39.        endfunction
  40.      
  41.        private function init takes nothing returns nothing
  42.            local trigger trig = CreateTrigger()
  43.      
  44.            call TriggerRegisterPlayerChatEvent(trig,PLAYER,KEY,false)
  45.            call TriggerAddAction(trig,function Actions)
  46.        endfunction
  47.      
  48.     endlibrary

Enjoy :)
Woah!! Thank you so much <3 <3
Trying.....

EDIT:
WOW IT WORKS LIKE A CHARM!!
THANK YOU SO MUCH MUCH WE DO!!
Thread Closed :3 :3
« Last Edit: March 12, 2016, 03:32:59 AM by LembidiZ »

  • Rookie - level 3
  • ***
  • Posts: 123
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 3
  • A FRENGERS
    • View Profile
Re: [ vJASS ] About Spawn Unit
« Reply #11 on: March 12, 2016, 05:00:08 AM »
um.. One last question, sorry damn.
How to make spawned units patrol to random points?

  • Rookie - level 1
  • *
  • Posts: 48
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 8
  • cool != useful
    • View Profile
Re: [ vJASS ] About Spawn Unit
« Reply #12 on: March 12, 2016, 06:24:08 AM »
um.. One last question, sorry damn.
How to make spawned units patrol to random points?

That will be the anarchy :s
vJass is already a jass preprocessor, no need to (ab)use vJass features in order to make some inferior vJass preprocessor coded "by hand".

  • Rookie - level 3
  • ***
  • Posts: 123
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • WC3 Spells: 0
  • Reputation: 3
  • A FRENGERS
    • View Profile
Re: [ vJASS ] About Spawn Unit
« Reply #13 on: March 19, 2016, 06:30:06 AM »
That will be the anarchy :s

haha thanks anyway :D :D
You really save me ;D ;D

 

[System] Unit Recycler & Simple Damage Detection System

Started by moyackBoard Codes & Snippets

Replies: 6
Views: 13712
Last post June 25, 2013, 08:50:33 PM
by moyack
[Snippet] Simple Unit Indexer

Started by moyackBoard Codes & Snippets

Replies: 17
Views: 27039
Last post September 30, 2013, 08:07:19 AM
by moyack
Illusion Editor v1.3 [vJass + GUI Support]

Started by AGDBoard Warcraft III Spells and Systems

Replies: 3
Views: 4486
Last post September 08, 2016, 07:38:01 AM
by AGD
[vJass] Rect Utils

Started by WareditorBoard Rejected Codes & Snippets

Replies: 7
Views: 15527
Last post August 31, 2015, 02:41:01 AM
by sankaku
[vJass] LocalHelper

Started by Troll-BrainBoard Codes & Snippets

Replies: 8
Views: 16345
Last post September 02, 2015, 10:03:04 AM
by moyack
Blizzard Modding Information Center Starcraft II Modding Information Center Wacraft III Modding Information Center WC3JASS.com - The JASS Vault Chronicles of Darkness - A Warcraft III mod Jetcraft - A Starcraft II mod Troll Smash - A Warcraft III Arena
  Mod DB - Change the Game Power of Corruption - A Warcraft III altered melee map Chaos Realm - The world of Game modders and wc3 addicts Follow us on Facebook!!