• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Unit Group Problem

Status
Not open for further replies.

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Anyone knows why the first four actions in the following trigger are not executed?

[trigger=""]Research Chain Lightning
Events
Unit - A unit Finishes research
Conditions
(Unit-type of (Triggering unit)) Equal to Abilities (Shaman)
(Researched tech-type) Equal to Chain Lightning
Actions
Set Level_Group = (Units in Hero Levels <gen> matching ((Owner of (Matching unit)) Equal to (Owner of (Triggering unit))))
Unit - Remove (Random unit from Level_Group) from the game
Set TypeRestriction_Group = (Units in Type 1 Dummies <gen> matching ((Owner of (Matching unit)) Equal to (Owner of (Triggering unit))))
Unit - Remove (Random unit from TypeRestriction_Group) from the game
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Chain Lightning for Shaman) Greater than or equal to 1
Then - Actions
Unit - Set level of Chain Lightning for Shaman to (Current research level of Chain Lightning for (Owner of (Triggering unit)))
Else - Actions
Unit - Add Chain Lightning to Shaman
Custom script: call DestroyGroup(udg_Level_Group)
Custom script: call DestroyGroup(udg_TypeRestriction_Group)[/trigger]
 
Last edited:
Level 11
Joined
Mar 27, 2011
Messages
293
Good morning spasorc,

See my suggestions for your problem:

  • The Triggering unit should be assigned to any variable of type unit.
  • Enter data types (unit, area, position ...) you use this trigger.
  • The condition used for the group should not be correct.

Enjoy to tell what your goal with these codes, so I think I'll help you best. Anything, please contact me friend.
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
The Triggering unit should be assigned to any variable of type unit.

Alright will try that.

Enter data types (unit, area, position ...) you use this trigge

I don't quite understand what do you mean here.

The condition used for the group should not be correct.

Why not?

Enjoy to tell what your goal with these codes

It is irrelevant. It's a new system I am making and it doesn't have much to do with this particular trigger. Also, it's only the first four actions that don't work.
 
Level 11
Joined
Mar 27, 2011
Messages
293
Well, what could it mean quiz inform data types (types of variables: the unit, group of units, regions), so I can better understand your question.
Additionally, you can rest assured, I do not like and will not steal the intellectual property of someone.

I believe that the condition:

[trigger=](Unit-type of (Triggering unit)) Equal to Abilities (Shaman)[/trigger]

Does not meet what you need.
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Alright "Abilities (Shaman)" is a Building that contains abilities for the Shaman unit to research.

Whenever this building makes a research, two dummy units are removed from specific regions. The Regions are [Hero Levels <gen> and Type 1 Dummies <gen>. I try to do that with

[trigger=""]
Set Level_Group = (Units in Hero Levels <gen> matching ((Owner of (Matching unit)) Equal to (Owner of (Triggering unit))))
Unit - Remove (Random unit from Level_Group) from the game
Set TypeRestriction_Group = (Units in Type 1 Dummies <gen> matching ((Owner of (Matching unit)) Equal to (Owner of (Triggering unit))))
Unit - Remove (Random unit from TypeRestriction_Group) from the game
[/trigger]

After that, the ability is given to the Shaman. (Shaman is a variable that is set in an initialization trigger. That part not bugged though, it works.
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Try Triggering unit with reference to a variable of type unit.

Like this?

[trigger=""]
Set ResearchUnit = (Triggering unit)
Set Level_Group = (Units in Hero Levels <gen> matching ((Owner of (Matching unit)) Equal to (Owner of ResearchUnit)))
Unit - Remove (Random unit from Level_Group) from the game
Set TypeRestriction_Group = (Units in Type 1 Dummies <gen> matching ((Owner of (Matching unit)) Equal to (Owner of ResearchUnit)))
Unit - Remove (Random unit from TypeRestriction_Group) from the game
[/trigger]
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Are those dummies locusts? You cannot pick such by location. I dunno what you try to achieve by removing a random unit from the area. What is there? Can any unit enter this place? You can implement debug messages to check your parameters or if something is picked.

The Locust was the issue. Thanks for helping guys. +rep!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Locusts are ignored from area searches as they are not placed in many of the systems that standard units are. Locusts are not ignored from player unit searches as they still remain in the unit lists those use.

There are two main choices for a workaround...
If you know who the owner of the Locust Unit is you can iterate through all his units and filter for the units owning the Locust ability that are also within the Rect. This always works however it can be very processor intensive if the player owns a lot of units due to the O(n) nature.

You can also create a special constant unit group that holds all locusts on the map (or a unit group array for all locusts of a specific player). When such locusts are created you add them to the group(s) and when they are removed you remove them from the groups (dead units are not automatically removed from groups so can be considered a leak if care is not taken). This gives you some nice little groups that you can use to iterate through all locust units very fast making a much more scalable system than player wide unit iteration. The disadvantage is some control overhead.
 
Status
Not open for further replies.
Top