• 🏆 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!

Pick Every Destructible of Type

Status
Not open for further replies.
Level 8
Joined
Sep 23, 2007
Messages
357
In my map I need to make a trigger that picks every unit within a 50 radius of every destructible of a certain type, and add the picked units to a certain unit group. I could find any function that does "Pick every destructible of type", does anyone know how I could do this?
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
In my map I need to make a trigger that picks every unit within a 50 radius of every destructible of a certain type, and add the picked units to a certain unit group. I could find any function that does "Pick every destructible of type", does anyone know how I could do this?

why dont try this?

  • Destructible - Pick every destructible within 256.00 of (Center of (Playable map area)) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
        • Then - Actions
        • Else - Actions
i mean filter with if, there u can make destructible type condition
 
Level 8
Joined
Sep 23, 2007
Messages
357
why dont try this?

  • Destructible - Pick every destructible within 256.00 of (Center of (Playable map area)) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
        • Then - Actions
        • Else - Actions
i mean filter with if, there u can make destructible type condition

Because when I put "Picked Destructable" in the Then section, it uses all picked destructables, not just the one that passes the If condition
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Because when I put "Picked Destructable" in the Then section, it uses all picked destructables, not just the one that passes the If condition

and that why problem? if i do action only in ,,if'' then all other desctructible leave alone what dont fit to if condition.

i dont understand what u mean, when u do pick than its count every unit/destructible who fit the condition in picked function (so all destructible around a point) then make a loop(example if 5 tree have around the point then from tree 1->tree5) and do action with each unit.

see the unit group by player do also same, filter the unit with a function, every pick unit do filtering with function where u give more condition than 1 just its do when WE convert the trigger to jass at save map so u can use the if since game also do it, since at pick all destructible dont have that much option than at pick all unit .

JASS:
function GetUnitsInRectOfPlayer takes rect r, player whichPlayer returns group
    local group g = CreateGroup()
    set bj_groupEnumOwningPlayer = whichPlayer
    call GroupEnumUnitsInRect(g, r, filterGetUnitsInRectOfPlayer)
    return g
endfunction
 
Level 8
Joined
Sep 23, 2007
Messages
357
and that why problem? if i do action only in ,,if'' then all other desctructible leave alone what dont fit to if condition.

i dont understand what u mean, when u do pick than its count every unit/destructible who fit the condition in picked function (so all destructible around a point) then make a loop(example if 5 tree have around the point then from tree 1->tree5) and do action with each unit.

see the unit group by player do also same, filter the unit with a function, every pick unit do filtering with function where u give more condition than 1 just its do when WE convert the trigger to jass at save map so u can use the if since game also do it, since at pick all destructible dont have that much option than at pick all unit .

JASS:
function GetUnitsInRectOfPlayer takes rect r, player whichPlayer returns group
    local group g = CreateGroup()
    set bj_groupEnumOwningPlayer = whichPlayer
    call GroupEnumUnitsInRect(g, r, filterGetUnitsInRectOfPlayer)
    return g
endfunction

Its a problem because when you say
"Pick Every Destructable in Region A"
and then
"If Destructable Type of Picked Destructable is equal to X"
then
"Then Put Picked Destructable into Group Y"

Then it puts EVERY destructable in Region A into Group Y, not only the destructable of type X.

Assuming that X = Tree
So if there is a Tree and two Rocks in Region A, then the only thing it does is detect that one of the destructables is equal to Tree, and then instead of only putting the Tree into Group Y, it puts the rocks into Group Y too.

Understand? If you dont feel free to let me know so that I can cater further to your broken english
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Its a problem because when you say
"Pick Every Destructable in Region A"
and then
"If Destructable Type of Picked Destructable is equal to X"
then
"Then Put Picked Destructable into Group Y"

Then it puts EVERY destructable in Region A into Group Y, not only the destructable of type X.

Assuming that X = Tree
So if there is a Tree and two Rocks in Region A, then the only thing it does is detect that one of the destructables is equal to Tree, and then instead of only putting the Tree into Group Y, it puts the rocks into Group Y too.

Understand? If you dont feel free to let me know so that I can cater further to your broken english

weird coz at me its work only with trees.

check the demo map, type in chat: 1
then see its move remove and recreate only x type of destructibles, at my case only lordearon summer tree
 

Attachments

  • treemove.w3x
    17.4 KB · Views: 115
Level 26
Joined
Aug 18, 2009
Messages
4,097
Its a problem because when you say
"Pick Every Destructable in Region A"
and then
"If Destructable Type of Picked Destructable is equal to X"
then
"Then Put Picked Destructable into Group Y"

Then it puts EVERY destructable in Region A into Group Y, not only the destructable of type X.

Nope, this is not the case. All actions that you put in the loop get together in an outsourced function.

Pseudocode:

JASS:
function Enum takes nothing returns nothing
    if (GetEnumValue() == X) then
        call BJDebugMsg(GetEnumValue())
    endif
endfunction

ForEach(<group>, function Enum)

The Enum function gets consecutively run for each element in <group>. This means that every new call of Enum gains another GetEnumValue() return value. The first element runs its function call to the end, the second does after, then the third etc. GetEnumValue() does not provide a whole array, jass cannot handle array arguments anyway.
 
Level 8
Joined
Sep 23, 2007
Messages
357
Nope, this is not the case. All actions that you put in the loop get together in an outsourced function.

Pseudocode:

JASS:
function Enum takes nothing returns nothing
    if (GetEnumValue() == X) then
        call BJDebugMsg(GetEnumValue())
    endif
endfunction

ForEach(<group>, function Enum)

The Enum function gets consecutively run for each element in <group>. This means that every new call of Enum gains another GetEnumValue() return value. The first element runs its function call to the end, the second does after, then the third etc. GetEnumValue() does not provide a whole array, jass cannot handle array arguments anyway.

Oh.. it wasnt working in GUI :/

I apologize, I think its about time I learn vJass
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
map what i posted work in gui if u want convert to jass u can filter it easily but in gui like i said if u pick every unit in 600 range who is enemy is enemy to group y, then its put everyunit in 600 range just filter function remove from group when it filter each unit

for this dont even need vjass jass convert ur trigger to custom text and use jass craft http://www.wc3c.net/showthread.php?t=80051

ofc u can use vjass, but i noticed for this dont need because work in normal WE too.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Its a problem because when you say
"Pick Every Destructable in Region A"
and then
"If Destructable Type of Picked Destructable is equal to X"
then
"Then Put Picked Destructable into Group Y"

Then it puts EVERY destructable in Region A into Group Y, not only the destructable of type X.

Assuming that X = Tree
So if there is a Tree and two Rocks in Region A, then the only thing it does is detect that one of the destructables is equal to Tree, and then instead of only putting the Tree into Group Y, it puts the rocks into Group Y too.

Understand? If you dont feel free to let me know so that I can cater further to your broken english

Here's a more easy GUI explenation:

For each destructable that is picked it performs the actions.

So for example:

"Pick Every Destructable in Region A"
and then

(So the first destructable is picked inside Region A and then the following action get's performed)

"If Destructable Type of Picked Destructable is equal to X"
then
"Then Put Picked Destructable into Group Y"

(In this case the Picked Destructable would be the first detructable that is picked from all destructables in region A)

When this action is done executing it starts over for the second, third, fourth of the group and so on. Till everything has been picked inside Region A.
And since these actions get executed in split seconds it looks as if it picks all the destructables at the same time, which it in fact does not...
It happens one by one.
 
Status
Not open for further replies.
Top