HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

[Question] Using Unit Groups and SPFX

07-20-2008, 07:54 AM#1
Tide-Arc Ephemera
Yeah, I've got a number of questions on the topics of unit groups and the topic of special effects (not together) and this time around I'm using Jass, I've also got a few random questions. No vJass please.

Using Groups of Units
  1. I'm performing actions on X units every 0.04 seconds, it's roughly 0.5 to 1.5 pages worth of actions per unit. What will X be before lag gets moderate/high?
  2. What happens when I try to GroupEnum units with locust?
  3. What happens when I try to GroupEnum units that were locusted? (I don't want them to be click-selectable)
  4. What happens when I hide units?
  5. If I can't GroupEnum hidden units, do I have to store them in a group to unhide them?
  6. New: How do I get group A then filter it out B until I have group C? (e.g Get all the units of a player, then slim it down to just Wisps)

Special Effects
  1. How "heavy" are the SPFX memory leaks in comparison to other leaks?
  2. How do I move units with ribbons without leaving a ribbon?
  3. What's the best way to store special effects to variables if I have multiples on one unit?

Random questions.
  1. What do boolexprs look like? This is like the 2nd or 100th time I've asked but I can't find my old threads...
  2. What do player IDs look like? Player(0) or something like that?
  3. What do unit IDs "strings" look like? Are they the h000 stuff or the custom_h000 stuff?

EDIT!
Is my syntax checker broken?
Collapse JASS:
    loop
        set u = FirstOfGroup(g)
        call GroupRemoveUnit(u, g)
    exitwhen u==null
    endloop

//Obviously it's incomplete, but the error message is:
//Line 117: Invalid argument type (group)
07-20-2008, 09:29 AM#2
Alexander244
Using Groups of Units
Quote:
I'm performing actions on X units every 0.04 seconds, it's roughly 0.5 to 1.5 pages worth of actions per unit. What will X be before lag gets moderate/high?
That would depend almost entirely upon the complexity of the actions.

Quote:
What happens when I try to GroupEnum units with locust?
Depends of the native used. GroupEnumUnitsOfPlayer & GroupEnumUnitsOfType will enum them as expected, GroupEnumUnitsInRange will miss them out.

Quote:
What happens when I try to GroupEnum units that were locusted? (I don't want them to be click-selectable)
Probably won't work. If you remove it while the unit is hidden, as you will be, it works fine. Otherwise it doesn't.

Quote:
What happens when I hide units?
They will also not be caught with certain enum natives. GroupEnumUnitsOfPlayer still works with them.

Quote:
If I can't GroupEnum hidden units, do I have to store them in a group to unhide them?
Can still be useful, although it's not nessesary.

Quote:
New: How do I get group A then filter it out B until I have group C? (e.g Get all the units of a player, then slim it down to just Wisps)
a ForGroup call, where you remove any units from the group that are not of said type, or add all units of said type to a new group. Many other methods will work.


Special Effects
Quote:
How "heavy" are the SPFX memory leaks in comparison to other leaks?
No idea on a quantitative value, but as with all leaks, they are worth avoiding.

Quote:
How do I move units with ribbons without leaving a ribbon?
Destroy and re-add the effect might work.

Quote:
What's the best way to store special effects to variables if I have multiples on one unit?
Arrays Without global declaration freedom gamecache may be easier.


Random questions.
Quote:
What do boolexprs look like? This is like the 2nd or 100th time I've asked but I can't find my old threads...
They are functions that return a boolean, with a Filter(function XX) or Condition(function XX).

(Condition and Filter actually create child types of boolexprs, but they are what you use.)

Quote:
What do player IDs look like? Player(0) or something like that?
The id is the number (0 -> 15, with 0 being red and 15 being neutral passive.)

Quote:
What do unit IDs "strings" look like? Are they the h000 stuff or the custom_h000 stuff?
I presume you are refering to the unit name used in EnumUnitsOfType. That is "custom_h000".

Collapse JASS:
native GroupRemoveUnit takes group whichGroup, unit whichUnit returns nothing
You just got the group and the unit the wrong way round.
07-20-2008, 09:57 AM#3
Tide-Arc Ephemera
Oh right, haha I was trusting WC3's editor and it said the null thing was wrong... I'll work on it soon enough.

Thanks for all those answers, I fear that's not the complete end of my queries though.
07-20-2008, 01:04 PM#4
DioD
you cant enum locust unit.
07-20-2008, 01:11 PM#5
Alexander244
You can with OfPlayer and OfType.
07-21-2008, 07:55 AM#6
Tide-Arc Ephemera
Alrighty, I'm back with one more question:

If I remove a unit from a group and then add it again, will it be put in last or first of group?
07-21-2008, 10:38 AM#7
Deaod
last.
07-21-2008, 10:46 AM#8
Tide-Arc Ephemera
I'm not 100% sure about that answer 'cause I put two statements up and "first" is the last statement...

So it gets moved to last of group?
____

Problem!

Here's how the recorded events in game go:
1. Cast Hurl Chain
2. Message: "Hurl Chain has been cast"
3. End.

Main trigger:
Expand JASS:

Assistant triggers:
Expand JASS:

Expand JASS:

What's meant to happen is all the wisps are meant to be pulled in (that's all these triggers are concerned with) and then be shot out in a straight line making a chain-like body that stretches out and whacks the enemy (which is up to a separate trigger).
07-21-2008, 11:47 AM#9
Alexander244
Collapse JASS:
local group g   
//...
call GroupEnumUnitsOfPlayer(g, p, null)
g is not initialized
07-21-2008, 11:49 AM#10
Tide-Arc Ephemera
Blergh... how does one go about initializing group variables? I've never quite understood/learned properly how to.
07-21-2008, 11:50 AM#11
Alexander244
local group g = CreateGroup()
Or preferably use a global group.

set tempg = g
Here you want to have tempg as a new group and add the contents of g to it. At the moment you're just making them reference the same group.

Collapse JASS:
loop
    exitwhen u==null
    set counter = counter + 1
    set u = FirstOfGroup(tempg)
    call GroupRemoveUnit(tempg, u)
endloop
That's not going to work either. You need to have set u = FirstOfGroup(tempg) at the start of the loop, and initialize u to null at the start of the function.
07-21-2008, 11:51 AM#12
Tide-Arc Ephemera
Thank you.

Rep's on waiting list...

Another problem, very sadly.

What's going on this time...
1. I cast the spell
2. All the messages from the starter appear
3. End.
4. Unable to cast spell again

What's meant to be going on:
1. I cast the spell
2. All wisps are pulled in
3. A series of messages from the starter appear
4. The chain extends out and a series of messages from the extender appear
5. The chain retracts and a series of messages from the retractor appear
6. Ready for recast

The starter
Expand JASS:

The extender
Expand JASS:

The retractor
Expand JASS:

The time "engine"
Expand JASS:

As been shown, coding is not my specialty. Could anyone assist me in my brain-crackingly bad coding?
07-21-2008, 12:28 PM#13
Alexander244
set tempg = g That doesn't do what you're expecting. It simply makes tempg point to the same group g is pointing to.

What you need is:
Collapse JASS:
set tempg = CreateGroup()
call GroupAddGroup(g, tempg)

Edit:

Collapse JASS:
set udg_TS_WispGroup[leader] = g
//....
call DestroyGroup(g)
You just destroyed udg_TS_WispGroup[leader] there.
You do the same thing in The extender and The retractor, while all you should be doing is set g = null.
07-21-2008, 12:30 PM#14
Tide-Arc Ephemera
Alrighty, will do and I'll return with my awesomely long list of problems (should any remain).
[Question] Using Unit Groups and SPFX - Wc3C.net