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

Mana Reduce in Night Time

Status
Not open for further replies.
Level 14
Joined
Nov 30, 2013
Messages
926
I'm trying to make a trigger that the unit's mana will starting to reduce in night time and it will stop in day time.
  • Night And Day
    • 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
          • ((In-game time of day) Greater than 18.00) and ((In-game time of day) Less than 6.00)
        • Then - Actions
          • Unit Group - Pick every unit in (Units of type Survivor) and do (Actions)
            • Loop - Actions
              • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - 1.00)
        • Else - Actions
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,220
"And" should be "or"


nope

edit: or actually.. it depends.. if the time works like a circle I am right else you are right xD

anyway, why not use game time events instead? When time becomes 18:00 turn on a loop that reduce mana. When it becomes 06:00 turn off the loop. It's a better solution.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,220
0e1bc4c9c762f5ed8909f6ceb4280635.png


get what I mean? Technically it will be an never ending loop.

edit: I just noticed I should have written greater than..
 
The problem is the code doesn't understand your logic. It just has a game time, let's say 23.00 o'clock.

Now you condition is time > 18 (true), and time < 6 (false). Because obviously 23 is in between 18 and 6 in our imagination for time, but not the value itself. :D

Solution: (18 < time AND time < 24) OR (time < 6)
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
The approach that chaosy wrote makes the most sense imo. Make trigger which decreases mana of all survivors and switch it off (untick the "Initially On" check box above the trigger) and make other trigger which fires when time becomes 18:00 or 6:00 which switches on, respectively off, the first trigger.

Also, beware of memory leaks!
  • Unit Group - Pick every unit in (Units of type Survivor) and do (Actions)
    • Loop - Actions
The action: "Unit Group - Pick every unit of type" causes permanent leak that you can do nothing with. Use instead "Pick every unit Region Matching Condition". You'll need to use custom scripts to prevent memory leaks (the custom script is basically copy'n'paste).

Here's what I had in mind:
  • Time of Day
    • Events
      • Game - The in-game time of day becomes Equal to 6.00
      • Game - The in-game time of day becomes Equal to 18.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (In-game time of day) Equal to 6.00
        • Then - Actions
          • Trigger - Turn off Mana Decreasing <gen>
        • Else - Actions
          • Trigger - Turn on Mana Decreasing <gen>
  • Mana Decreasing
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Survivor)) and do (Actions)
        • Loop - Actions
          • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - 1.00)
The whole thing could be even more optimized by using temp unit variable and unit group variable, but whatever...
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
Lawl everyone went full retard or what?

Ceday, Iceman and Waterknight got it right (obviously). "Time of day" is just a function that returns a real value. For a real value t the equation "t < 6 && t > 18" can never be true.

The whole "time is a circle" discussion makes zero sense.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,220
Lawl everyone went full retard or what?

Ceday, Iceman and Waterknight got it right (obviously). "Time of day" is just a function that returns a real value. For a real value t the equation "t < 6 && t > 18" can never be true.

The whole "time is a circle" discussion makes zero sense.

Good thing I said 'technically' ^^ My first suggestion was to use the method Nichilus posted later on :p
Technically
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
ands are useless in wc3, it's better to put both in the conditions without the and, just or's are useful.

No. I guess you are referring to GUI. The default concatenation is the And, so you do not need to explicitly state it there. But you may want to have an Or-Structure and one or more of the Or-parts itself you want to be an And.

Ex:

  • Or - Any (Conditions) are true
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) is alive) Equal To True
          • ((Triggering unit) is A structure) Equal To True
      • (Owner of (Triggering unit)) Equal To Player 1 (Red)
!=

  • Or - Any (Conditions) are true
    • Conditions
      • ((Triggering unit) is alive) Equal To True
      • ((Triggering unit) is A structure) Equal To True
      • (Owner of (Triggering unit)) Equal To Player 1 (Red)
Also, as for the past, apart from the trigger conditions block, in RoC the ifs in GUI were single line, then you had to pick a concatenation if you did not want to nest whole ifs, work with variables etc., was super ugly.
 
Status
Not open for further replies.
Top