• 🏆 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] Events

Status
Not open for further replies.
Level 13
Joined
Mar 4, 2009
Messages
1,156
Problem with unit EVENTS

Is it possible to make this events?
EVENT -unit enters in with 512 range of unit of type FIRE (not specific unit)
EVENT - unit of type WORKER mane/life becomes equal to 40 (not specific unit)
or is it possible this events work only on specific unit? :(
 
Last edited:
Level 12
Joined
May 4, 2008
Messages
1,111
hmmmm, it would work, Generic unit enters 512 rang of unit type FIRE

condition - Unit type of Entering unit Equals to WORKER

Action Mana/LIfe of entering unit set to 40


tho im not sure if thats what u wanted since u just sent in an Event condition and Action and put them in a single line

it can be put Unit-specific by setting a unit to a Variable and then setting that trigger to that unit's Variable
 
Level 4
Joined
Jan 24, 2009
Messages
124
Hope i helped u.

Is it possible to make this events?
EVENT -unit enter in with 512 range of unit of type FIRE
EVENT - unit of type WORKER mane/life becomes equal to 40
or is it possible this events work only on selected unit? :(

can't fix the range i guess...
but the WORKER :
  • Worker
    • Events
      • Unit - a units lifr/mana becomes les than 40
    • Conditions
      • Unit - unit type of triggering unit equal to WORKER.
    • Actions
      • YOUR ACTIONS
:grin:
 
Level 3
Joined
Sep 11, 2004
Messages
63
Theres an event for specific units life becomes less than X, but none for generic unit :(

Simply assign the triggering "generic unit" to a global temporary unit variable,then specific unit events/actions will become available through that global.
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
Try to use:
  • Trigger
  • Events
    • Unit - A unit Is attacked
    • Unit - A unit Begins casting an ability
  • Conditions
    • Unit-Type of (Triggering Unit) Equal to WORKER
    • Life of (Triggering Unit) Equal to or Less than 40
    • Mana of (Triggering Unit) Equal to or Less than 40
  • Actions
    • ACTIONS
 
Level 8
Joined
Apr 7, 2008
Messages
176
This is where Unit Groups become fun.

  • Untitled Trigger 001
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Life of (Picked unit)) Less than or equal to 40.00) or ((Mana of (Picked unit)) Less than or equal to 40.00)
              • ((Picked unit) is A peon-type unit) Equal to True
            • Then - Actions
            • Else - Actions
If you are able to put the units you need to be part of the trigger into a Unit Group in some way then the trigger doesn't have to select EVERY unit in the map and can only select that group.
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
This is where Unit Groups become fun.

  • Untitled Trigger 001
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Life of (Picked unit)) Less than or equal to 40.00) or ((Mana of (Picked unit)) Less than or equal to 40.00)
              • ((Picked unit) is A peon-type unit) Equal to True
            • Then - Actions
            • Else - Actions
If you are able to put the units you need to be part of the trigger into a Unit Group in some way then the trigger doesn't have to select EVERY unit in the map and can only select that group.
Not really solved but its a good idea for both events :) i think its bad becouse it is every 1 second....
you just need to pick every unit in unit group matching condition...and set it to a veriable so you can fix the leak

set "YourUnitGroup"
pick every unit in "YourUnitGroup"
call DestroyGroup(udg_YourUnitGroup)
 
Level 8
Joined
Apr 7, 2008
Messages
176
Yeah the leaks are up to you. If you need help with em I can add that in. I just didnt bother with em since you werent asking about leaks. And to fix the problem with it running all the time.
Simply add an Action in your initializing trigger that turns on the looping trigger.
And add a fuction that if the Unit group becomes empty the looping trigger turns itself off.
 
Level 6
Joined
Sep 13, 2008
Messages
261
Is it possible to make this events?
EVENT -unit enters in with 512 range of unit of type FIRE (not specific unit)
EVENT - unit of type WORKER mane/life becomes equal to 40 (not specific unit)
or is it possible this events work only on specific unit? :(

To answer your question it is not possible to make those events.

You can pseudo make those events with conditions etc.
1. For this you will have to use the action pick all units in a group matching condition. Then pick all units within 512 range of that unit matching unit-type fire.

2.For this you will either have to do a periodic pick all units of type event or
use generic event with a wait timer of like one second to check his hp/mp

example-
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Peasant
    • Actions
      • Wait 0.80 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of (Triggering unit)) Less than 40.00
          • (Mana of (Triggering unit)) Less than 40.00
        • Then - Actions
        • Else - Actions
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
i wanted to do this with event "unit enters witin 512 range of unit" but it is inpossible becouse it is only for specific unit so i needed to do it like this:ugly:

  • do action within 512 range of unit type
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set UNITGROUP = (Units of type Tracker)
      • Unit Group - Pick every unit in UNITGROUP and do (Actions)
        • Loop - Actions
          • Set FIXLAGS = (Position of (Picked unit))
          • Set UNITGROUP = (Units within 512.00 of FIXLAGS matching ((Unit-type of (Matching unit)) Not equal to Tracker))
          • Unit Group - Pick every unit in UNITGROUP and do (Actions)
            • Loop - Actions
              • Unit - Kill (Picked unit)
this will kill everything on Tracker´s way :D

Can this make lags becouse it is happening EVERY 0.5 seconds?
 
Level 6
Joined
Sep 13, 2008
Messages
261
If you destroy the unitgroup to clean the leak it probably won't cause much lag. just keep the periodic check at .50 or above.
 
Level 4
Joined
Mar 14, 2009
Messages
98
Use three triggers to do it.
  • Initial Fire
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Fire)) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Fire Trigger <gen> the event (Unit - A unit comes within 512.00 of (Picked unit))
  • Fire Enters Map
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Fire
    • Actions
      • Trigger - Add to Fire Trigger <gen> the event (Unit - A unit comes within 512.00 of (Triggering unit))
  • Fire Trigger
    • Events
    • Conditions
    • Actions
      • -------- Insert actions here --------
Same thing applies to your worker HP/Mana problem, just modify it a bit.
 
Level 4
Joined
Mar 14, 2009
Messages
98
...And the only difference being you can't use GetTriggerPlayer(). You can use GetOwningPlayer(GetTriggerUnit()). It's really the same thing as it simulates generic unit events with specific unit events. It's the same thing damage detection systems are based off.

Edit: Howl2000, I just read your solution, you were suggesting a periodic trigger which: first, is further than what he was asking for than my solution; second, less efficient than my solution. Also, unless you do some pretty complicated things with unit groups attached to each unit, your trigger would fire several times when another unit is close to the fire instead of just when it comes close to the fire.

Your other solution, with regards to the hp/mana does not take into account things like triggered effects reducing hp/mana and triggered damage. Furthermore, it won't work with things with really, REALLY slow projectile speeds or really big distances.
 
Last edited:
Level 13
Joined
Mar 4, 2009
Messages
1,156
Use three triggers to do it.
  • Initial Fire
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Fire)) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Fire Trigger <gen> the event (Unit - A unit comes within 512.00 of (Picked unit))
  • Fire Enters Map
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Fire
    • Actions
      • Trigger - Add to Fire Trigger <gen> the event (Unit - A unit comes within 512.00 of (Triggering unit))
  • Fire Trigger
    • Events
    • Conditions
    • Actions
      • -------- Insert actions here --------
Same thing applies to your worker HP/Mana problem, just modify it a bit.

Are you shure you can add event unit comes within 512 range of PICKED or TRIGGERING unit?
 
Level 4
Joined
Mar 14, 2009
Messages
98
I'm sure that works. Try it.

The first trigger groups all the Fires and creates an event for each of them. It adds each of those events to the Fire Trigger so that Fire Trigger would run whenever a unit comes within range of any of the Fires initially created on the map. Picked Unit refers to each of the units inside the unit group created to group all the Fires. So, yes, Picked Unit does exist in this case.

The second trigger detects when a Fire enters the map, that is, when a Fire is created. It then creates an event for that Fire that triggers when something gets close to it. It adds that event to Fire Trigger. Triggering Unit refers to the Fire that enters the map. So, again, Triggering Unit exists.

Fire Trigger is the actual trigger that does stuff. At first it has no events, but as Fires are created, events are added to the trigger to make it work. Any more questions?

I know it works. If you actually try it instead of saying that it's wrong, you'll know that it works perfectly fine.
P.S. Those are three seperate triggers that each do their part to simulate the generic unit event.
P.P.S. The first trigger leaks one unit group for the entire game, so it really shouldn't matter. If you're that obsessed with leak removal, read up on some tutorials on how to get rid of the leak if you don't know how.
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
Use three triggers to do it.
  • Initial Fire
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Fire)) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Fire Trigger <gen> the event (Unit - A unit comes within 512.00 of (Picked unit))
  • Fire Enters Map
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Fire
    • Actions
      • Trigger - Add to Fire Trigger <gen> the event (Unit - A unit comes within 512.00 of (Triggering unit))
  • Fire Trigger
    • Events
    • Conditions
    • Actions
      • -------- Insert actions here --------
Same thing applies to your worker HP/Mana problem, just modify it a bit.

:thumbs_up: works perfectly :D but i have a question how can it work if you pick unit only at map initialization xD?
i think its enought just pick every units of type
i dont know how to remove position leak becouse my variable "FIXLAGS" (variable type- point) is not avaible to that triggers,probably becouse its only unit position

i want to do osomething when unit leaves 512 range of that unit ,will i need to pick all units that are not in his range every 0.5 seconds?
 
Last edited:
Level 6
Joined
Sep 13, 2008
Messages
261
Damn i tought it dont exist but i does when you are adding event to trigger and specific unit events will be generic unit events too :D man that guy really knows something :D

It doesn't change it to a generic unit event. You are just adding every fire type unit on the map as a specific event. So if you have 100 fire types you will have 100 event for one trigger and 1000 will be 1000. So watch how many units you spawn or this trigger will lag the game.
 
Level 13
Joined
Mar 4, 2009
Messages
1,156
It doesn't change it to a generic unit event. You are just adding every fire type unit on the map as a specific event. So if you have 100 fire types you will have 100 event for one trigger and 1000 will be 1000. So watch how many units you spawn or this trigger will lag the game.

just turn off the trigger or destroy it i dont know witch way is batter
You can mark this as solved....
 
Last edited:
Status
Not open for further replies.
Top