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

[JASS] Time of Day Between X and X

Status
Not open for further replies.
Level 14
Joined
Jul 26, 2008
Messages
1,009
JASS:
    if GetFloatGameState(GAME_STATE_TIME_OF_DAY) < 6.00  and GetFloatGameState(GAME_STATE_TIME_OF_DAY) > 18.00  then

Alright this isn't working for whatever reason. However, this is:

JASS:
    if GetFloatGameState(GAME_STATE_TIME_OF_DAY) >= 6.00 and GetFloatGameState(GAME_STATE_TIME_OF_DAY) <= 18.00 then

So what is the proper setup for the first one?

Whole trigger below:

JASS:
scope VampBurn initializer Init

private function GroupEm takes nothing returns nothing
 local integer lvl = GetUnitAbilityLevel(GetEnumUnit(), 'SotH')
 local real life = GetWidgetLife(GetEnumUnit())
    if not(lvl > 0 and life < (60-15*lvl)) and GetInventoryIndexOfItemTypeBJ(GetEnumUnit(), 'IC10') == 0 then
        call SetWidgetLife( GetEnumUnit(), GetWidgetLife(GetEnumUnit()) - (50-15*lvl) )
    endif
endfunction

private function Actions takes nothing returns nothing
    if GetFloatGameState(GAME_STATE_TIME_OF_DAY) >= 6.00 and GetFloatGameState(GAME_STATE_TIME_OF_DAY) <= 18.00 then
        set bj_groupAddGroupDest = udg_BurnGroup
        call ForGroup(udg_RoamingGroup, function GroupAddGroupEnum)
    endif
    if GetFloatGameState(GAME_STATE_TIME_OF_DAY) < 6.00  and GetFloatGameState(GAME_STATE_TIME_OF_DAY) > 18.00  then
        call BJDebugMsg("TEST")
        set bj_groupRemoveGroupDest = udg_BurnGroup
        call ForGroup(udg_RoamingGroup, function GroupRemoveGroupEnum)
    endif
    call ForGroup( udg_BurnGroup, function GroupEm )
endfunction

//===========================================================================
public function Init takes nothing returns nothing
 local timer tim = NewTimer()
    call TimerStart(tim, 0.5, true, function Actions )
endfunction

endscope
 
JASS:
scope VampBurn initializer Init

private function GroupEm takes nothing returns nothing
    local unit u = GetEnumUnit()
    local real life = GetWidgetLife(u)
    local integer lvl = GetUnitAbilityLevel(u, 'SotH')
    if not (lvl > 0 and life < (60 - 15 * lvl)) and GetInventoryIndexOfItemTypeBJ(u, 'IC10') == 0 then
        call SetWidgetLife(u, life - (50 - 15 * lvl))
    endif
    set u = null
endfunction // What is supposed to happen here the code looks scrambled and messy, like you tried to implement 10 ideas and kept changing your mind.

private function Actions takes nothing returns nothing
    local real r = GetFloatGameState(GAME_STATE_TIME_OF_DAY)
    local code c
    
    if r >= 6.00 and r <= 18.00 then
        set c = function GroupAddGroupEnum
        
    else // This already means that the time of day is between those other times!
    
        set c = function GroupRemoveGroupEnum
    endif
    set bj_groupAddGroupDest = udg_BurnGroup
    call ForGroup(udg_RoamingGroup, c)
    call ForGroup(udg_BurnGroup, function GroupEm)
endfunction

//===========================================================================
private function Init takes nothing returns nothing // Why was this function public?
    call TimerStart(CreateTimer(), 0.5, true, function Actions) // You shouldn't use TimerUtils for a timer that never gets released (it's a waste)
endfunction

endscope
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
Very nice. I'll optomize my code accordingly.

One thing I wanted to point out in your trigger suggestion is that you left out a set bj_groupRemoveDest. Without it the remove code won't work.

As for my idea up there, I wanted it so if the unit has a certain ability, he will take less damage and won't die from the damage. Also, if he has a certain item he won't burn at all.
 
Status
Not open for further replies.
Top