Trigger: Region, unit, time of day problem

slayer

New Member
Reaction score
2
Hello!

I want to use "vampires" on a map I've made, they will only be able to operate during the night, at daytime they will die if they're in a specific region wich I call "daylight".
Daytime would be 06:00-18:00 and nighttime 18:00-06:00.

I have absolutely no idea how to do this. :(

Summarized, I would like this trigger to:
-...kill a certaintype of units.
-... only work during in a certain interval of time (in this case: 06:00-18:00 and 18:00-06:00.
- ...happen in a specific region.

Help would be appreciated ;)
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
A general outline:

1 trigger that fires when the time becomes 'greater than 06:00' (game event) this trigger should turn itself off and turn on all other triggers mentioned below, it should also pick 'every unit in region <daylight matching condition unit type of matching unit = vampire' and kill them.

1 trigger that fires when 'greater than 18:00' this one should turn of all triggers (including itself) and turn on the above trigger.

1 trigger with the event 'unit enters region daylight' and condition 'unit type of triggering unit = vampire' and action 'kill triggering unit'.

A 'cooler' (imo) solution would be to just damage all vampires in that region during the day, you can use a similar setup for this:
First trigger remove the 'kill all action'
Second trigger unchanged
Third trigger Remove
1 new that is never turned off/on by the others, this should have the same event/condition as the third trigger but instead of killing it should add the unit to a unit group.
1 new trigger that will be turned off/on by the other triggers and fires each X second, picks every unit in the unit group and reduces there life.
 

slayer

New Member
Reaction score
2
Yeah great, thx man! :D Like your idéa with the damage trigger, unfortunately It did not work, plz look if you find anything strange in it, here it is:

Trigger#1

daytime

Events
Game - The in-game time of day becomed Greater than 6.00
Conditions
(Unit-type of (Matching unit)) Equal to Vampire
Actions
Trigger - Turn off (this trigger)
Trigger - Turn on night <gen>
Trigger - Turn on damage <gen>

Trigger#2

nightime

Events
Game - The in-game time of day becomed Greater than 18.00
Actions
Trigger - Turn off (this trigger)
Trigger - Turn on daytime <gen>
Trigger - Turn off damage <gen>

Trigger#3

group

Events
Unit - A unit enters daylight region <gen>
Conditions
(Unit-type of (Matching unit)) Equal to Vampire
Actions
Unit Group - Add all units of (Units of type Vampire) to /Units in daylight <gen>)

Trigger#4

damage

Events
Time - Every 0.50 seconds of game time
Conditions
(Unit-type of (Matching unit)) Equal to Vampire
Actions
Unit Group - Pick every unit in (Last created unit group= and do (Unit - Casue (Random unit from (Last created unit group)) to damage (Matching unit), dealing 50.00 damage of attack type Chaos and damage type Fire)
 

Mr Zero

Junior Regular (Got the T-shirt)
Reaction score
64
Well... Since I'm bored anyway, I have made one trigger that does it all :D.
Code:
Damage Vampires
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Or - Any (Conditions) are true
                    Conditions
                        (In-game time of day) Greater than or equal to 6.00
                        (In-game time of day) Less than or equal to 18.00
            Then - Actions
                Set Vampires_Temp_Group = (Units in [B]<Your Region>[/B] <gen> matching ((Unit-type of (Matching unit)) Equal to [B]<Your Unit Type>[/B]))
                Unit Group - Pick every unit in Vampires_Temp_Group and do (Actions)
                    Loop - Actions
                        Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - [B]<The Damage Amout>[/B])
                Custom script:   call DestroyGroup (udg_Vampires_Temp_Group)
            Else - Actions
                Do nothing

Variables used:

Unit Group (Non-Array) = Vampires_Temp_Group

Please say if you need any help.
Hope it helps :)
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Note that the above solution is far more inefficient that the original one, even blizzard suggest that it should be done the first way. Not like blizzard is any good example for perfect code... :)

Anyway, if you are looking at the above trigger you should get some hints on how your triggers should be done.

You need an unit group variable (VampiersInRegion)

Unit Group - Add all units of (Units of type Vampire) to /Units in daylight <gen>)
Should be
Unit Group - Add (Triggering Unit) to (VampiersInRegion)

Unit Group - Pick every unit in (Last created unit group= and do (Unit - Casue (Random unit from (Last created unit group)) to damage (Matching unit), dealing 50.00 damage of attack type Chaos and damage type Fire)
should be (borrowing from above poster :p)

Code:
                Unit Group - Pick every unit in VampiersInRegion and do (Actions)
                    Loop - Actions
                        Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - <The Damage Amout>)
 

Mr Zero

Junior Regular (Got the T-shirt)
Reaction score
64
Yeah yeah... Come and set me in my place... :p

Anyhow here is the (Attach at the buttom) map. I will remove it in 24 hours, else pm me for the map.

:)
 

slayer

New Member
Reaction score
2
yeah, it works very well, except that they still receive damage after 18:00 in the "day" region :confused:
I can't see any wrong with the trigger either..
err? :rolleyes:
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top