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

[Trigger] Big Trigger - Leak and effiency question

Status
Not open for further replies.
Level 7
Joined
Mar 12, 2006
Messages
407
Im doing a custom resources system and therefore i need triggers that manage the resource gain
This one is for food.
Food is harvested from sheep, deer or berrys and then returned to a mill or the main building
My question is does it leak ? And is there a better way of doing this ?

Ignore 'equal to' my translation script fucked that up the (==) (>=) etc counts

Ok here it comes, have fun reading :D

  • gain food
    • Events
      • Unit - A unit owned by neutral enemy is being attacked
    • Conditions
      • Multiple ConditionsOr - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacked unit)) equal to (==) deer (dead)
          • (Unit-type of (Attacked unit)) equal to (==) sheep (dead)
          • (Unit-type of (Attacked unit)) equal to (==) berrys
      • Multiple ConditionsOr - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacking unit)) equal to (==) villager
          • (Unit-type of (Attacking unit)) equal to (==) villager (alternate)
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • (Charges remaining in (Item carried by (Attacking unit) in slot 1)) equal to (>=) 10
        • 'THEN'-Actions
          • Set p = (Position of (Triggering unit))
          • Set group = (Units within 1024.00 of p matching ((((Matching unit) is in (Units owned by (Owner of (Attacking unit)))) equal to (==) True) and (((Unit-type of (Matching unit)) equal to (==) mainbuilding) or ((Unit-type of (Matching unit)) equal to (==) mill))))
          • Set mill = (Random unit from group)
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Conditions
              • (Name of mill) equal to (==) <empty string>
            • 'THEN'-Actions
              • Custom script: call DestroyGroup (udg_group)
              • Set group = (Units within 4096.00 of p matching ((((Matching unit) is in (Units owned by (Owner of (Attacking unit)))) equal to (==) True) and (((Unit-type of (Matching unit)) equal to (==) mainbuilding) or ((Unit-type of (Matching unit)) equal to (==) mill))))
              • Set mill = (Random unit from group)
            • 'ELSE'-Actions
          • Wait 0.01 seconds
          • Unit - Order (Attacking unit) to give (Item carried by (Attacking unit) in slot 1) to mill
          • Custom script: call RemoveLocation (udg_p)
          • Custom script: call DestroyGroup (udg_group)
          • Skip remaining actions
        • 'ELSE'-Actions
      • If ((Item-type of (Item carried by (Attacking unit) in slot 1)) equal to (==) stone) then do (Item - Remove (Item carried by (Attacking unit) in slot 1)) else do (Do nothing)
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • (Unit-type of (Attacked unit)) equal to (==) sheep (dead)
        • 'THEN'-Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Conditions
              • (Custom value of (Attacked unit)) equal to (>=) 100
            • 'THEN'-Actions
              • Unit - Remove (Attacked unit) from the game
            • 'ELSE'-Actions
              • Set nahrungcount = (Charges remaining in (Item carried by (Attacking unit) in slot 1))
              • Item - Remove (Item carried by (Attacking unit) in slot 1)
              • hero - Create Nahrung and give it to (Attacking unit)
              • Item - Set charges remaining in (Item carried by (Attacking unit) in slot 1) to (nahrungcount + 1)
              • Unit - Set the custom value of (Attacked unit) to ((Custom value of (Attacked unit)) + 1)
              • Unit - Set mana of (Attacked unit) to (100.00 - (Real((Custom value of (Attacked unit)))))
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Conditions
                  • (Charges remaining in (Item carried by (Attacking unit) in slot 1)) equal to (>=) 10
                • 'THEN'-Actions
                  • Set p = (Position of (Triggering unit))
                  • Set group = (Units within 1024.00 of p matching ((((Matching unit) is in (Units owned by (Owner of (Attacking unit)))) equal to (==) True) and (((Unit-type of (Matching unit)) equal to (==) mainbuilding) or ((Unit-type of (Matching unit)) equal to (==) mill))))
                  • Set mill = (Random unit from group)
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • 'IF'-Conditions
                      • (Name of mill) equal to (==) <empty string>
                    • 'THEN'-Actions
                      • Custom script: call DestroyGroup (udg_group)
                      • Set group = (Units within 4096.00 of p matching ((((Matching unit) is in (Units owned by (Owner of (Attacking unit)))) equal to (==) True) and (((Unit-type of (Matching unit)) equal to (==) mainbuilding) or ((Unit-type of (Matching unit)) equal to (==) mill))))
                      • Set mill = (Random unit from group)
                    • 'ELSE'-Actions
                  • Wait 0.01 seconds
                  • Unit - Order (Attacking unit) to give (Item carried by (Attacking unit) in slot 1) to mill
                  • Custom script: call RemoveLocation (udg_p)
                  • Custom script: call DestroyGroup (udg_group)
                  • Skip remaining actions
                • 'ELSE'-Actions
        • 'ELSE'-Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • (Unit-type of (Attacked unit)) equal to (==) deer (dead)
        • 'THEN'-Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Conditions
              • (Custom value of (Attacked unit)) equal to (>=) 150
            • 'THEN'-Actions
              • Unit - Remove (Attacked unit) from the game
            • 'ELSE'-Actions
              • Set nahrungcount = (Charges remaining in (Item carried by (Attacking unit) in slot 1))
              • Item - Remove (Item carried by (Attacking unit) in slot 1)
              • hero - Create Nahrung and give it to (Attacking unit)
              • Item - Set charges remaining in (Item carried by (Attacking unit) in slot 1) to (nahrungcount + 1)
              • Unit - Set the custom value of (Attacked unit) to ((Custom value of (Attacked unit)) + 1)
              • Unit - Set mana of (Attacked unit) to (150.00 - (Real((Custom value of (Attacked unit)))))
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Conditions
                  • (Charges remaining in (Item carried by (Attacking unit) in slot 1)) equal to (>=) 10
                • 'THEN'-Actions
                  • Set p = (Position of (Triggering unit))
                  • Set group = (Units within 1024.00 of p matching ((((Matching unit) is in (Units owned by (Owner of (Attacking unit)))) equal to (==) True) and (((Unit-type of (Matching unit)) equal to (==) mainbuilding) or ((Unit-type of (Matching unit)) equal to (==) mill))))
                  • Set mill = (Random unit from group)
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • 'IF'-Conditions
                      • (Name of mill) equal to (==) <empty string>
                    • 'THEN'-Actions
                      • Custom script: call DestroyGroup (udg_group)
                      • Set group = (Units within 4096.00 of p matching ((((Matching unit) is in (Units owned by (Owner of (Attacking unit)))) equal to (==) True) and (((Unit-type of (Matching unit)) equal to (==) mainbuilding) or ((Unit-type of (Matching unit)) equal to (==) mill))))
                      • Set mill = (Random unit from group)
                    • 'ELSE'-Actions
                  • Wait 0.01 seconds
                  • Unit - Order (Attacking unit) to give (Item carried by (Attacking unit) in slot 1) to mill
                  • Custom script: call RemoveLocation (udg_p)
                  • Custom script: call DestroyGroup (udg_group)
                  • Skip remaining actions
                • 'ELSE'-Actions
        • 'ELSE'-Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • (Unit-type of (Attacked unit)) equal to (==) berrys
        • 'THEN'-Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Conditions
              • (Custom value of (Attacked unit)) equal to (>=) 125
            • 'THEN'-Actions
              • Unit - Remove (Attacked unit) from the game
            • 'ELSE'-Actions
              • Set nahrungcount = (Charges remaining in (Item carried by (Attacking unit) in slot 1))
              • Item - Remove (Item carried by (Attacking unit) in slot 1)
              • hero - Create Nahrung and give it to (Attacking unit)
              • Item - Set charges remaining in (Item carried by (Attacking unit) in slot 1) to (nahrungcount + 1)
              • Unit - Set the custom value of (Attacked unit) to ((Custom value of (Attacked unit)) + 1)
              • Unit - Set mana of (Attacked unit) to (125.00 - (Real((Custom value of (Attacked unit)))))
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • 'IF'-Conditions
                  • (Charges remaining in (Item carried by (Attacking unit) in slot 1)) equal to (>=) 10
                • 'THEN'-Actions
                  • Set p = (Position of (Triggering unit))
                  • Set group = (Units within 1024.00 of p matching ((((Matching unit) is in (Units owned by (Owner of (Attacking unit)))) equal to (==) True) and (((Unit-type of (Matching unit)) equal to (==) mainbuilding) or ((Unit-type of (Matching unit)) equal to (==) mill))))
                  • Set mill = (Random unit from group)
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • 'IF'-Conditions
                      • (Name of mill) equal to (==) <empty string>
                    • 'THEN'-Actions
                      • Custom script: call DestroyGroup (udg_group)
                      • Set group = (Units within 4096.00 of p matching ((((Matching unit) is in (Units owned by (Owner of (Attacking unit)))) equal to (==) True) and (((Unit-type of (Matching unit)) equal to (==) mainbuilding) or ((Unit-type of (Matching unit)) equal to (==) mill))))
                      • Set mill = (Random unit from group)
                    • 'ELSE'-Actions
                  • Wait 0.01 seconds
                  • Unit - Order (Attacking unit) to give (Item carried by (Attacking unit) in slot 1) to mill
                  • Custom script: call RemoveLocation (udg_p)
                  • Custom script: call DestroyGroup (udg_group)
                  • Skip remaining actions
                • 'ELSE'-Actions
        • 'ELSE'-Actions
 
Last edited:
Level 7
Joined
Mar 12, 2006
Messages
407
yep except for that i used a little script to replace most german words so everyone can understand it ^^
I just edited my post a bit, now it should look exactly like my trigger in WE
It is working and all but im not too sure about its performance
And the map is not yet playable so i could only test in singleplayer with a few workers using it
 
Level 6
Joined
Feb 2, 2005
Messages
205
there are some strange thing i noted.

why is nahrungscount a global, is that intended?
the trigger would benefit from jass and locals

this stuff can go to the very beginning, you need it only once

  • Set p = (Position of (Triggering unit))
  • Set group = (Units within 1024.00 of p matching ((((Matching unit) is in (Units owned by (Owner of (Attacking unit)))) equal to (==) True) and (((Unit-type of (Matching unit)) equal to (==) mainbuilding) or ((Unit-type of (Matching unit)) equal to (==) mill))))
  • Set mill = (Random unit from group)
    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Name of mill) equal to (==) <empty string>
      • Then - Actions
        • Custom script: call DestroyGroup (udg_group)
        • Set group = (Units within 4096.00 of p matching ((((Matching unit) is in (Units owned by (Owner of (Attacking unit)))) equal to (==) True) and (((Unit-type of (Matching unit)) equal to (==) mainbuilding) or ((Unit-type of (Matching unit)) equal to (==) mill))))
        • Set mill = (Random unit from group)
sidenote minimum wait time is arround 0.25 seconds, anything lower will be raised

to get English gui text, use weu. open the map, copy the trigger as text, paste , be happy =)

edit: btw the trigger isnt MPI
 
Level 7
Joined
Mar 12, 2006
Messages
407
thanks for your reply
what does mpi mean ?
if you mean that multi instance stuff... it works for multiple workers
And for the wait.. is there a way of using issue order command without having a wait in front of it ?

And for the jass and local variable stuff, i m not capable of doing any jass :D
The only custom scripts i can do is for removing leaks :D
I would appreciate if some jasser could make this in jass ;)
 
Level 6
Joined
Feb 2, 2005
Messages
205
mpi = the trigger can be "used" by more than one player (mostly done with locals or arrays)
mui = the trigger can be "used" by more than one unit (mostly done with locals and "triggering Unit" etc)
mui isn't mpi and the other way around

i don't know if the issued order command can be used without wait, never messed around with it.

local variables can be used in a limited way within the gui, there was some tutorial thought.

If you are doing a multilayer map you should make it MPI.

If you need some help with that Trigger feel free to contact me via icq etc.
 
Level 7
Joined
Mar 12, 2006
Messages
407
Thanks for your help ! :)

Now I got myself weu for english triggers
Looked up the tutorial and modified my trigger
now it isnt working anymore ^^

I already discovered the problem but i have no idea how to fix it
As you can see i display the unit names of attacking unit and attacked unit whenever the trigger is run
It returns me same name on both units
now im confused ^^

  • gather food new
    • Events
      • Unit - A unit owned by Neutral Hostile Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacked unit)) Equal to Deer (dead)
          • (Unit-type of (Attacked unit)) Equal to Sheep (dead)
          • (Unit-type of (Attacked unit)) Equal to Berries
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacking unit)) Equal to Villager
          • (Unit-type of (Attacking unit)) Equal to Villager (alternate)
    • Actions
      • Custom script: local unit udg_attackingunit
      • Custom script: local unit udg_attackedunit
      • Custom script: set udg_attackingunit = GetAttacker()
      • Custom script: set udg_attackedunit = GetAttackedUnitBJ()
      • Game - Display to Player 1 (Red), at offset (0.00, 0.00) the text: (Name of attackedunit)
      • Game - Display to Player 1 (Red), at offset (0.00, 0.00) the text: (Name of attackingunit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Charges remaining in (Item carried by attackingunit in slot 1)) Greater than or equal to 10
        • Then - Actions
          • Set p = (Position of attackingunit)
          • Set group = (Units within 1024.00 of p matching ((((Matching unit) is in (Units owned by (Owner of attackingunit))) Equal to True) and (((Unit-type of (Matching unit)) Equal to Villagecenter) or ((Unit-type of (Matching unit)) Equal to Mill))))
          • Set mill = (Random unit from group)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Name of mill) Equal to <Empty String>
            • Then - Actions
              • Custom script: call DestroyGroup (udg_group)
              • Set group = (Units within 4096.00 of p matching ((((Matching unit) is in (Units owned by (Owner of attackingunit))) Equal to True) and (((Unit-type of (Matching unit)) Equal to Villagecenter) or ((Unit-type of (Matching unit)) Equal to Mill))))
              • Set mill = (Random unit from group)
            • Else - Actions
          • Wait 0.01 seconds
          • Unit - Order attackingunit to give (Item carried by attackingunit in slot 1) to mill
          • Custom script: call RemoveLocation (udg_p)
          • Custom script: call DestroyGroup (udg_group)
          • Skip remaining actions
        • Else - Actions
      • If ((Item-type of (Item carried by attackingunit in slot 1)) Equal to Steine) then do (Item - Remove (Item carried by attackingunit in slot 1)) else do (Do nothing)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of attackedunit) Equal to Sheep (dead)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of attackedunit) Greater than or equal to 100
            • Then - Actions
              • Unit - Remove attackedunit from the game
            • Else - Actions
              • Set foodcount = (Charges remaining in (Item carried by attackingunit in slot 1))
              • Item - Remove (Item carried by attackingunit in slot 1)
              • Hero - Create Nahrung and give it to attackingunit
              • Item - Set charges remaining in (Item carried by attackingunit in slot 1) to (foodcount + 1)
              • Unit - Set the custom value of attackedunit to ((Custom value of attackedunit) + 1)
              • Unit - Set mana of attackedunit to (100.00 - (Real((Custom value of attackedunit))))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of attackedunit) Equal to Deer (dead)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of attackedunit) Greater than or equal to 150
            • Then - Actions
              • Unit - Remove attackedunit from the game
            • Else - Actions
              • Set foodcount = (Charges remaining in (Item carried by attackingunit in slot 1))
              • Item - Remove (Item carried by attackingunit in slot 1)
              • Hero - Create Nahrung and give it to attackingunit
              • Item - Set charges remaining in (Item carried by attackingunit in slot 1) to (foodcount + 1)
              • Unit - Set the custom value of attackedunit to ((Custom value of attackedunit) + 1)
              • Unit - Set mana of (Attacked unit) to (150.00 - (Real((Custom value of (Attacked unit)))))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of attackedunit) Equal to Berries
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of attackedunit) Greater than or equal to 125
            • Then - Actions
              • Unit - Remove attackedunit from the game
            • Else - Actions
              • Set foodcount = (Charges remaining in (Item carried by attackingunit in slot 1))
              • Item - Remove (Item carried by attackingunit in slot 1)
              • Hero - Create Nahrung and give it to attackingunit
              • Item - Set charges remaining in (Item carried by attackingunit in slot 1) to (foodcount + 1)
              • Unit - Set the custom value of attackedunit to ((Custom value of attackedunit) + 1)
              • Unit - Set mana of (Attacked unit) to (125.00 - (Real((Custom value of (Attacked unit)))))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Charges remaining in (Item carried by attackingunit in slot 1)) Greater than or equal to 10
        • Then - Actions
          • Set p = (Position of attackingunit)
          • Set group = (Units within 1024.00 of p matching ((((Matching unit) is in (Units owned by (Owner of attackingunit))) Equal to True) and (((Unit-type of (Matching unit)) Equal to Villagecenter) or ((Unit-type of (Matching unit)) Equal to Mill))))
          • Set mill = (Random unit from group)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Name of mill) Equal to <Empty String>
            • Then - Actions
              • Custom script: call DestroyGroup (udg_group)
              • Set group = (Units within 4096.00 of p matching ((((Matching unit) is in (Units owned by (Owner of attackingunit))) Equal to True) and (((Unit-type of (Matching unit)) Equal to Villagecenter) or ((Unit-type of (Matching unit)) Equal to Mill))))
              • Set mill = (Random unit from group)
            • Else - Actions
          • Wait 0.01 seconds
          • Unit - Order attackingunit to give (Item carried by attackingunit in slot 1) to mill
          • Custom script: call RemoveLocation (udg_p)
          • Custom script: call DestroyGroup (udg_group)
          • Skip remaining actions
        • Else - Actions
and godless i tried to send you my icq number via hives send to icq thingy, dunno if it worked
 
Level 6
Joined
Feb 2, 2005
Messages
205
Use GetTriggerUnit() instead of GetAttackedUnitBJ(). On the other hand, that shouldn't change a thing....

i think there was an odd bug with nearly equal names of variables which i encountered several times.... dunno how to solve it in gui
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Via the use of a table (array) system you could up effeciency even in GUI. In JASS locals can avoid un needed native calling and also usless BJ calls.

Basically, what you could do is create an array system that it can instantly return the values to use instead of having to prefrom multiple comparisons. That would mean that the overall speed of the spell would be more constant (and more efficent).
 
Level 7
Joined
Mar 12, 2006
Messages
407
@dr super good
I tried to change it the way you said. Did i get you right ?


@godless
aaahm seems to be a bug with local variables in general ?
I tried to rename variables, tried to use another unit variable and tried to use set variable in gui (and triggering unit instead of attacked)
It always sets all local unit variables to the same value (i tried with 3 different ones, all set to same unit)
Yeah and as soon as i have a global variable it works again

Any ideas ?
Im getting realy frustrated on this stuff :(

  • gather food new
    • Events
      • Unit - A unit owned by Neutral Hostile Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacked unit)) Equal to Deer (dead)
          • (Unit-type of (Attacked unit)) Equal to Sheep (dead)
          • (Unit-type of (Attacked unit)) Equal to Berries
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacking unit)) Equal to Villager
          • (Unit-type of (Attacking unit)) Equal to Villager (alternate)
    • Actions
      • Custom script: local unit udg_attacker
      • Custom script: local unit udg_target
      • Custom script: set udg_attacker = GetAttacker()
      • Custom script: set udg_target = GetTriggerUnit()
      • Game - Display to Player 1 (Red), at offset (0.00, 0.00) the text: (Name of target)
      • Game - Display to Player 1 (Red), at offset (0.00, 0.00) the text: (Name of attacker)
      • Game - Display to Player 1 (Red), at offset (0.00, 0.00) the text: (Name of unit)
      • If ((Item-type of (Item carried by attacker in slot 1)) Equal to Steine) then do (Item - Remove (Item carried by attacker in slot 1)) else do (Do nothing)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Charges remaining in (Item carried by attacker in slot 1)) Greater than or equal to 10
        • Then - Actions
          • Set p = (Position of attacker)
          • Set group = (Units within 1024.00 of p matching ((((Matching unit) is in (Units owned by (Owner of attacker))) Equal to True) and (((Unit-type of (Matching unit)) Equal to Villagecenter) or ((Unit-type of (Matching unit)) Equal to Mill))))
          • Set mill = (Random unit from group)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Name of mill) Equal to <Empty String>
            • Then - Actions
              • Custom script: call DestroyGroup (udg_group)
              • Set group = (Units within 4096.00 of p matching ((((Matching unit) is in (Units owned by (Owner of attacker))) Equal to True) and (((Unit-type of (Matching unit)) Equal to Villagecenter) or ((Unit-type of (Matching unit)) Equal to Mill))))
              • Set mill = (Random unit from group)
            • Else - Actions
          • Wait 0.01 seconds
          • Unit - Order attacker to give (Item carried by attacker in slot 1) to mill
          • Custom script: call RemoveLocation (udg_p)
          • Custom script: call DestroyGroup (udg_group)
          • Skip remaining actions
        • Else - Actions
      • For each (Integer B) from 1 to 3, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of target) Equal to restarget[(Integer B)]
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Custom value of target) Greater than or equal to rescapacity[(Integer B)]
                • Then - Actions
                  • Unit - Remove target from the game
                • Else - Actions
                  • Set foodcount = (Charges remaining in (Item carried by attacker in slot 1))
                  • Item - Remove (Item carried by attacker in slot 1)
                  • Hero - Create Food and give it to attacker
                  • Item - Set charges remaining in (Item carried by attacker in slot 1) to (foodcount + 1)
                  • Unit - Set the custom value of target to ((Custom value of target) + 1)
                  • Unit - Set mana of target to ((Real(rescapacity[(Integer B)])) - (Real((Custom value of target))))
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Charges remaining in (Item carried by attacker in slot 1)) Greater than or equal to 10
        • Then - Actions
          • Set p = (Position of attacker)
          • Set group = (Units within 1024.00 of p matching ((((Matching unit) is in (Units owned by (Owner of attacker))) Equal to True) and (((Unit-type of (Matching unit)) Equal to Villagecenter) or ((Unit-type of (Matching unit)) Equal to Mill))))
          • Set mill = (Random unit from group)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Name of mill) Equal to <Empty String>
            • Then - Actions
              • Custom script: call DestroyGroup (udg_group)
              • Set group = (Units within 4096.00 of p matching ((((Matching unit) is in (Units owned by (Owner of attacker))) Equal to True) and (((Unit-type of (Matching unit)) Equal to Villagecenter) or ((Unit-type of (Matching unit)) Equal to Mill))))
              • Set mill = (Random unit from group)
            • Else - Actions
          • Wait 0.01 seconds
          • Unit - Order attacker to give (Item carried by attacker in slot 1) to mill
          • Custom script: call RemoveLocation (udg_p)
          • Custom script: call DestroyGroup (udg_group)
          • Skip remaining actions
        • Else - Actions
 
Last edited:
Level 6
Joined
Feb 2, 2005
Messages
205
hmm if you check twice with the if, remove the upper one, it will never be used.

this one
  • (Charges remaining in (Item carried by attacker in slot 1)) Greater than or equal to 10
ye it has something to do with the converter of the unit ids to integers, it only works for globals, as a workaround use a array.

  • Set unit[player number(owner of triggering unit)] = TriggeringUnit
unit is a global
 
Level 7
Joined
Mar 12, 2006
Messages
407
if i move it in the else action and delete the other one the harvester would attack the resource 11 times before he returns his resources ;)
the second if/then/else check for 10 or more items only runs if the villager acquires the 10th item in the trigger

But i just came up to another problem
If i make it use an array refering to the unit[playernumber] and i get the playernumber by refering to owner of attacking unit
And then the trigger is ran by multiple players
And then i refer to unit[playernumber of owner of attacking unit] while another player ran this trigger
Wont it refer to the unit of the other player then ?
Or is there another way to get the right arraynumber ?
 
Level 6
Joined
Feb 2, 2005
Messages
205
well every player triggers in its own instance, it would only conflict if you use an global variable, because it would have the same value for every player.

because of that you trigger will run into trouble when triggered from multiple players, you need array or local variables to make sure it runs as intended.

btw foodcount can give you some trouble because every player/unit will change that value
use this instead
  • Item - Set charges remaining in (Item carried by attacker in slot 1) to (Charges remaining in (Item carried by attacker in slot 1 + 1)
and remove
  • Set foodcount = (Charges remaining in (Item carried by attacker in slot 1))
  • Item - Remove (Item carried by attacker in slot 1)
  • Hero - Create Food and give it to attacker
you can change the value on the fly, no need for remove/give triggers
 
Level 7
Joined
Mar 12, 2006
Messages
407
The item stuff is a good idea, but needs another if/then/else to check if unit has the item and if not give it to unit

But now I encoutered a bunch of new problems :D

First of all i cant refer to local variables in if/then/else conditions
Dont ask why i have no clue

and im still not sure how this array stuff should work

  • Actions
    • Set attacker[(Player number of (Owner of (Attacking unit)))] = (Attacking unit)
    • Item - Set charges remaining in (Item carried by attacker[(Player number of (Owner of (Attacking unit)))] in slot 1) to ((Charges remaining in (Item carried by (attacker[(Player number of (Owner of (Attacking unit))) in slot 1)) + 1)
Just as an example
This is how it should be done ?
Confuses me ?!
If i can refer to owner of attacking unit i can directly refer to attacking unit and dont need any variables ?!
 
Level 6
Joined
Feb 2, 2005
Messages
205
ye locals can't be used within a gui if, because of blizzards code converter.

Your example is right, that is how it is done, you cant refer to attacking unit, because the unitid is always the same no matter which player owns the unit.

btw: i didnt get the message on icq, sended you a pm with my icq number =)
 
Status
Not open for further replies.
Top