Trigger that works at night?

I_RULE_YOU

New Member
Reaction score
34
I'm trying to give my hero an ability that works at night time only, like the Night Stalker in DotA. When it turns night time, the hero gains attack speed and movement speed. I know how I'd do this, add 2 abilities and such when its night time. But I can't find time of day in conditions anywhere, I can only find it in Events. But I could'nt figure out how to do the trigger with the event of it being 18.00 game time (exactly when it turns night). So how would I accomplish this spell?

(Note, when it turns day time the abilities should be removed).
 

foodflare

You can change this now in User CP.
Reaction score
32
its a real comparison use two and click on life of (triggering unit) then go to game - time of day
Code:
Or - Any (Conditions) are true
    Conditions
        (In-game time of day) Greater than or equal to 18.00
        (In-game time of day) Less than or equal to 6.00
 

I_RULE_YOU

New Member
Reaction score
34
Ok, heres the trigger so far:

Code:
Rage of Darkness
    Events
        Unit - A unit Learns a skill
    Conditions
        (Learned Hero Skill) Equal to Rage of Darkness (Dummy)
    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 18.00
                        (In-game time of day) Less than or equal to 6.00
            Then - Actions
                Unit - Add Dark Nova (Trigger) to (Triggering unit)
                Unit - Set level of Dark Nova (Trigger) for (Triggering unit) to (Level of Rage of Darkness (Dummy) for (Triggering unit))
                Unit - Add Night Speed  to (Triggering unit)
                Unit - Set level of Night Speed  for (Triggering unit) to (Level of Rage of Darkness (Dummy) for (Triggering unit))
            Else - Actions

How would I make those 2 abilities go away at day time?
 

Weyrling

New Member
Reaction score
25
Code:
Event: Game - Time of Day becomes > 6 (this meaning 6 AM, standard 24 hour day).
Action: Remove 'Night Spell' from 'Unit', Add 'Day Spell', etcetera..
 

esb

Because none of us are as cruel as all of us.
Reaction score
329
Remember, you may only remove abilities if they were added with triggers in the first place.
 

Weyrling

New Member
Reaction score
25
esb said:
Remember, you may only remove abilities if they were added with triggers in the first place.
False. Ever played an RP map?

Which reminds me, you will want to make the actual hero ability invisible and use totally different ones for the effects.
The fact that the hero can learn the ability can't be removed, but the ability itself CAN be removed from the unit.
This means that if you use the same ability your hero selects as, say, the night-time ability, when you switch it to daytime the hero could learn the night one a second time since you removed it from the unit itself, yet it's still in their 'hero abilities' list.
 

I_RULE_YOU

New Member
Reaction score
34
That's what I did, I made it so at night time 2 abilities were added if he had the spell learned ( It's a dummy spell, based it off Critical Strike). I'm at school right now so I cant test the remove ability part, but I will soon.
 

I_RULE_YOU

New Member
Reaction score
34
Code:
Rage of Darkness
    Events
        Unit - A unit Learns a skill
    Conditions
        (Learned Hero Skill) Equal to Rage of Darkness (Dummy)
    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 18.00
                        (In-game time of day) Less than 6.00
            Then - Actions
                Unit - Add Dark Nova (Trigger) to (Triggering unit)
                Unit - Set level of Dark Nova (Trigger) for (Triggering unit) to (Level of Rage of Darkness (Dummy) for (Triggering unit))
                Unit - Add Night Speed  to (Triggering unit)
                Unit - Set level of Night Speed  for (Triggering unit) to (Level of Rage of Darkness (Dummy) for (Triggering unit))
            Else - Actions


Code:
Rage of Darkness B
    Events
        Unit - A unit Learns a skill
    Conditions
        (Learned Hero Skill) Equal to Rage of Darkness (Dummy)
    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 18.00
            Then - Actions
                Unit - Remove Dark Nova (Trigger) from (Triggering unit)
                Unit - Remove Night Speed  from (Triggering unit)
            Else - Actions


Those are my two triggers for the spel. It isn't working. Night time comes, and nothing happens. What am I doing wrong?
 

Weyrling

New Member
Reaction score
25
The only event is 'unit learns a skill'.
You need to make another trigger with the event:
Code:
Game - in game time becomes >= 6
This will detect the game time entering Day
Code:
Game - in game time becomes >= 18
This will detect the game time entering Night
The previous 2 code strings were events.
You need to make corresponding actions to both of those events, meaning 2 more triggers or one complexified one.
 

I_RULE_YOU

New Member
Reaction score
34
Well that's what I wanted to do, but I got stuck here:

Code:
Action: Remove 'Night Spell' from 'Unit'

Could not find a place where I choose a specific kind of unit to remove the ability from, only (triggering unit) and such.
 

Weyrling

New Member
Reaction score
25
Assuming there is only one unit with that ability, simply make a global 'unit' variable, and set it when you add the skill.
 

I_RULE_YOU

New Member
Reaction score
34
Well there could be multiple heroes of that type running around.

How would I make a global unit variable and set it when the skill is added? Im kinda nooby at triggers.
 

Weyrling

New Member
Reaction score
25
If you can potentially have multiple of this unit type running around, use the following:
First, make a unit group variable (Select the X in the trigger editor, make new, go down til you find 'Unit Group').
Code:
Event: Game - in game time becomes >= 6
Set UnitGroupVariable to Units of Type HeroGuy
[b]Pick every unit in UnitGroupVariable and do:
     Remove NightSpell from Picked Unit
     Add DaySpell to Picked Unit
     Set DaySpell level to level of DummyAbility for Picked Unit[/b]
CustomScript: "call DestroyGroup(udg_UnitGroupVariable)"
For the Custom Script at the end, use udg_ then the name of your Unit Group variable.
If the variable was named TempGroup, you'd say "call DestroyGroup(udg_TempGroup)".
Good luck with your map.
 

Kelvin87

New Member
Reaction score
14
But, If with a single code to Trigger this Day and Night Event Ability isn't enough. It still got bugs. You need to have 2 trigger to code this. but 1st, you need to create a global variable of Is_Day_Flag (false as default) Boolean 1st, then pick every triggering unit of owning of the ability to do action.
The working as below:(Not really follow the jass code)
Code A:
If GetTriggerUnit != null and count number of Triggering Unit in playable map area > 0 and udg_Is_Day_Flag == false then
set udg_Is_Day_Flag = true
else
return
endif

Code B:
If udg_Is_Day_Flag == true and TimeofDay > 6.00 and TimeofDay < 18.00 then
call SetUnitAbilityLevel( GetTriggerUnit(), 'abilcode', lvlofskill )
endif

If udg_Is_Day_Flag != false and count number of Triggering Unit in playable map area <0 then
set udg_Is_Day_Flag == false
endif

from Thelder Clan
 

Naga'sShadow

Ultra Cool Member
Reaction score
49
How many of this unit can a single player have? If the answer is 1 then you can also use the disable- spell for player action. If you do that its the same as if you removed the spell but you don't need to store the level to add it back in come nightfall.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top