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

[Trigger] Help me about a trigger pls:(

Status
Not open for further replies.
Level 6
Joined
Jun 20, 2007
Messages
60
i tried to do it for 5-6 hours but i couldnt so i'm about to lose my mind:S

For example a spell marks all enemy units in 1000 range of target point of ability being cast with random (-)electron and (+)proton buffs and if a unit which has (-)electron buff comes within 200 of unit which has (+) proton buff then do action(like every 2 seconds of the game time damage each other with 50) .i need just the action part..I marked all units randomly but i cant get the action of second trigger (damaging each other part)??

buffed units are in veriables(unit arrays and unit groups) so i cant use them in events,i tried to get them in conditions but i couldnt succes it..i tested about 100 kind of triggers and got no results...
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
You will have to do a rather unefficent itteration through all affected units I am affraid.
The good news is you only have to compair each combination (pair) once, thus it is better than O(n^2) efficency.

Basically you are after mapping all units into a unit array starting at index 0 and having an integer representing the end of the unit block (so you know when to end your itterations).
Using this you start by pairing unit in index [0] against all other units up to the end integer and doing you opperation on them. After doing that you comapir index [1] against all indices after it (as you have already done a pair with index [0] you can ignore it) and do your opperation on them.

This will for example with 5 units being affected look like this.
0 | - 1 2 3 4
1 | - - 2 3 4
2 | - - - 3 4
3 | - - - - 4
As you can see this algerthim would generate only unique pairs with no duplicates making it highly efficent. For 5 units you get only 10 pair opperations to do. 6 gives 15 and so on.

As for each pair opperation, well its simply the matter of first checking if one of the pair is positive and other negative and if so then getting the distance between the 2 (X1-X2 and Y1-Y2), squaring those and adding them together. Once you done that, you check if that is less than 200^2 (40000) and if so you damage the unit.

Repeat this every 2 seconds only when there is more than 1 unit in the array and your system will work.

This however as you guessed is rather unefficient as you are paring positive against positive which is meaningless opperations however does let you do effects like repulsion of 2 positives if you like. However if you only want the damage when opposites are near, you can lower the opperations even further by mapping the positives into a different array from the negatives.

By doing this, all you need to do is itterate through all the positives, and for each do an itteration through all the negatives and you instantly get all the viable pairs for distance comparison. It will logically work in reverse order. Doing this method on 1 positive and 9 negative will yield only 9 pairs to compair, which is greatly reduced then using the other method described above which would yield 45 pairs. Ofcourse this is not always the case, and even with 5 positive and 5 negative (worst case), it will yield only 25 pairs to compair instead of the 45.
 
Level 6
Joined
Jun 20, 2007
Messages
60
Thank you very much but i cant understand your english coz i'm not good at English that much :)

I can send u my map if u want to edit trigger?

Thank you very much but i cant understand your english coz i'm not good at English that much :)

I can send u my map if u want to edit trigger?


here is the map file..

EDIT:FIXED...Topic can be closed..
 

Attachments

  • ElectronAndProton.w3x
    191.5 KB · Views: 44
Last edited:
Status
Not open for further replies.
Top