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

[JASS] Adding to groups without the unit creation

Status
Not open for further replies.
Level 6
Joined
Mar 20, 2008
Messages
208
I'm trying to add a unit to a unit group, without actually making the unit.

When a player purchasing a unit, I create the unit in an unentered spot oin the map, then add it to the unit group.

Its not large enough to lag the map, but I'd still prefer a different way of doing it.

I've tried removing the units, but that takes the mout of the grou pas well.

I've looked into unitpools, which would work out great, but it looks like blizzard got lazy again.

Would using the game cache help any?
 
Level 13
Joined
May 11, 2008
Messages
1,198
can't you just do event a unit buys a unit... action add purchased unit to unit group?
i'm bad with unit groups but i think this adding to unit group would be very simple method. maybe you're doing that already but it sounded like you're adding the unit entering the region to the unit group, if that's so, that's too many steps imo. but putting it in the region might still suit your other purposes...i'm not sure.
 
Level 6
Joined
Mar 20, 2008
Messages
208
  • Unit - Hide Unit

It is impossible to have a unit that doesn't exist in a unit group. Try using unit type arrays or something instead.

Well, for these two, does hide unit prevent the game from lagging up?
Currently, I have the unit just shuffled into the area of map that blocked off from players.
Is hide unit just like setting their transparency?

As for the array system, I did think about that idea, but my problem is that it sort of needs to be dynamic.

I suppose an array size of 100 will suffice as I haven't seen armies go above 30 units yet before the game ended.
Will Jass's arrays dynamic expand should they go over the cap or should I expect null pointer crashes?

can't you just do event a unit buys a unit... action add purchased unit to unit group?
i'm bad with unit groups but i think this adding to unit group would be very simple method. maybe you're doing that already but it sounded like you're adding the unit entering the region to the unit group, if that's so, that's too many steps imo. but putting it in the region might still suit your other purposes...i'm not sure.

My apologies, I didn't add enough detail.

Players purchase a unit from a shop, its not meant to be used by the player, but added to their spawning army, computer AI controlled.

Every X seconds, their army will spawn a copy of every unit in that unit group.

IE: Player purchases 3 grunts, 1 peon
Every X seconds, 3 grunts and 1 peon will spawn.
Player then purchases a catapult
Every X seconds, 3 grunts, 1 peon, 1 catapult will spawn.

What I do is spawn them outside the barriers, then add them to a group. Whe nthe group spawns I pick every unit in the group and spawn a copy of it.
 
Level 7
Joined
Jul 20, 2008
Messages
377
Using unit groups would be awkward here. I suggest a single array of unit types and a matching array of integers for each player to track how many you want to spawn. Then you can do something like this:

  • For each integer A from 0 to 10
    • Loop - Do Actions
      • Unit - Create Player1howMany[Integer A] typeToSpawn[Integer A] at (blah blah)
      • Unit - Create Player2howMany[Integer A] typeToSpawn[Integer A] at (blah blah)
      • ...
      • Unit - Create PlayerNhowMany[Integer A] typeToSpawn[Integer A] at (blah blah)
Yeah, too bad WC3 doesn't support two-dimensional arrays (well... you can IMPLICITLY have two-dimensional arrays).
 
Level 6
Joined
Mar 20, 2008
Messages
208
Using unit groups would be awkward here. I suggest a single array of unit types and a matching array of integers for each player to track how many you want to spawn. Then you can do something like this:

Yeah, too bad WC3 doesn't support two-dimensional arrays (well... you can IMPLICITLY have two-dimensional arrays).

Yeah, thats a damn shame it doesn't.
I'll try switching over to a double array system.

Thanks
 
Level 6
Joined
Mar 20, 2008
Messages
208
Right, but I imagine theres a whole lot of overhead that comes with it, that I do not want. I'd rather get a minimal static system going with a few smalle arrays then overload it with methods and function calls and etc.
 
Level 6
Joined
Mar 20, 2008
Messages
208
There is no "overhead". You declare a multi-dimensional array with

<type> array <name> [SIZE1][SIZE2]...[SIZEn]

and then use it like

set <name>[INDEX1][INDEX2]...[INDEXn]

vJASS is an extension of jass, which means to me that none of its functionality would be native to jass, which means overhead, especially since it would need to be compiled into viable jass code.

That is not overhead I would like, also taking into consideration that efficiency tends to be better from working in lower level coding rather than higher level coding.

Working with two seperate arrays is simple enough, I already have a pair containing constantly used region centers, having another set shouldn't be hard to manage.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
That is not overhead I would like, also taking into consideration that efficiency tends to be better from working in lower level coding rather than higher level coding.

Many vjass features don't give overhead. To give a small list:

- globals / endglobals: doesn't give any overhead at all
- public / private / constant qualifiers : no overhead at all
- getters / setters : automatically inlined (in most cases), no overhead at all
- 2D arrays simply calculate an index in a 1D array using a formula such as array[start*max + offset]. If you want to implement that with normal jass you have to make the exact same calculation, hence no overhead.

I do have to say that in the case of 2d arrays, things tend to be buggy in my experience, which is why I just simply make the calculation.
 
Level 6
Joined
Mar 20, 2008
Messages
208
Many vjass features don't give overhead. To give a small list:

- globals / endglobals: doesn't give any overhead at all
- public / private / constant qualifiers : no overhead at all
- getters / setters : automatically inlined (in most cases), no overhead at all
- 2D arrays simply calculate an index in a 1D array using a formula such as array[start*max + offset]. If you want to implement that with normal jass you have to make the exact same calculation, hence no overhead.

I do have to say that in the case of 2d arrays, things tend to be buggy in my experience, which is why I just simply make the calculation.

Unless you can show me the backend code for these, I'm having a hard time believing there will be no excess code that is not neccessary. Something has to lay down the neccessary groundwork for those methods to work.

Seeing how I don't need the extra features, theres no point in going through the trouble of getting vjass.

With the idea of using array1[unittype] with array2[#amount], I don't have to worry much about the growth or bugs within the array.
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Unless you can show me the backend code for these, I'm having a hard time believing there will be no excess code that is not neccessary. Something has to lay down the neccessary groundwork for those methods to work.

Seeing how I don't need the extra features, theres no point in going through the trouble of getting vjass.

With the idea of using array1[unittype] with array2[#amount], I don't have to worry much about the growth or bugs within the array.

Try it out yourself, save a vjass script and extract the mapscript if you don't believe me.
Also note that I never said there will be no excess code at all. But the code after compiling vjass isn't visible to the programmer anyway, and in some cases it's even more efficient than when you would have written it in normal jass.

Also: the fact you don't need vjass when you CAN actually use it makes me think you've never written anything complex...
 
Level 9
Joined
May 30, 2008
Messages
430
I don't read all the posts but as far as i got what u wonna do is somthing like TTW right? that's prety simple but i don't get u wonna GUI or JASS (i still don't know JASS) but whatever u can do

  • Set
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Entering unit)) Equal to Player 1 (Red)
          • (Unit-type of (Entering unit)) Equal to Footman
        • Then - Actions
          • Unit - Remove (Entering unit) from the game
          • Set SpawnFoot = (SpawnFoot + 1)
        • Else - Actions
  • Spawn units
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Create SpawnFoot Footman for Player 6 (Orange) at (Center of (Playable map area)) facing Default building facing degrees
 
Level 6
Joined
Mar 20, 2008
Messages
208
Try it out yourself, save a vjass script and extract the mapscript if you don't believe me.
Also note that I never said there will be no excess code at all. But the code
after compiling vjass isn't visible to the programmer anyway, and in some cases it's even more efficient than when you would have written it in normal jass.

Also: the fact you don't need vjass when you CAN actually use it makes me think you've never written anything complex...

Right, its the excess code I do not want.

Most of all my code I write in jass uses natives, and I have a good sense of efficiency, so I don't see it making enough of a difference to warrant me moving into a new environment and learning new tools.

You are right again, I have not written anything excessively complex, but my map works, has custom abilities and heros that aren't just carbon copies of the regular ones, no lag complaints, and has gotten mostly positive feedback from my testers.

So, why should I switch over now when I do not need to? I am competent enough to keep track of static arrays and can do what I need to do just using jass itself.
I'm not insulting vJASS, I'm merely saying I do not need its additonal features, when what I need to do is fairly simple.
 
Level 6
Joined
Mar 20, 2008
Messages
208
I don't read all the posts but as far as i got what u wonna do is somthing like TTW right? that's prety simple but i don't get u wonna GUI or JASS (i still don't know JASS) but whatever u can do

I wasn't asking for how to build a system, its already built, the method I went with had a flaw in it, and I was asking if that could be fixed easily.
 
Status
Not open for further replies.
Top