• 🏆 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!

Better way to do this?

Status
Not open for further replies.
Level 12
Joined
Jan 2, 2016
Messages
973
  • seconds
    • 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
          • seconds Equal to 60.00
        • Then - Actions
          • Set seconds = 1.00
        • Else - Actions
          • Set seconds = (seconds + 1.00)
      • Custom script: if bj_dncIsDaytime != udg_DayNight then
      • Custom script: set udg_DayNight = bj_dncIsDaytime
      • Custom script: call BJDebugMsg("change")
      • Set DayNightEvent = 1.00
      • Set DayNightEvent = 0.00
      • Custom script: endif
Is there any better way to register day/night change?
(I'm kind a combining 2 triggers, the 1-st part is irrelevant to the event. The debug msg was there for testing purposes) :p
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
I don't know what you're trying to achieve, but what about this:

  • Untitled Trigger 001
    • 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
          • -------- it's day --------
        • Else - Actions
          • -------- it's night --------
 
Level 12
Joined
Jan 2, 2016
Messages
973
JASS:
function WereWell takes unit well, boolean b returns nothing
    if b then
        call UnitAddAbility(well, 'A00K')
        call UnitRemoveAbility(well, 'A00K')
    else
        call UnitAddAbility(well, 'A02R')
        call UnitRemoveAbility(well, 'A02R')
    endif
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\Taunt\\TauntCaster.mdl", GetUnitX(well), GetUnitY(well)))
    call SetUnitAnimation( well , "stand" )
endfunction

function Moon_Wells_Night takes nothing returns boolean
    local group g = CreateGroup()
    local unit FoG
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
    loop
        set FoG = FirstOfGroup(g)
        exitwhen FoG == null
        if GetPlayerTechCount(GetOwningPlayer(FoG), 'R00R', true) == 1 and GetUnitTypeId(FoG) == 'e005' and GetUnitAbilityLevel(FoG, 'Abds') == 0 then
            call WereWell(FoG, true)
        endif
        call GroupRemoveUnit(g, FoG)
    endloop
    call DestroyGroup(g)
    set g = null
    return false
endfunction

function Moon_Wells_Day takes nothing returns boolean
    local group g = CreateGroup()
    local unit FoG
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
    loop
        set FoG = FirstOfGroup(g)
        exitwhen FoG == null
        if GetUnitTypeId(FoG) == 'e00L' then
            call WereWell(FoG, false)
        endif
        call GroupRemoveUnit(g, FoG)
    endloop
    call DestroyGroup(g)
    set g = null
    return false
endfunction

function Moon_Wells_Upg takes nothing returns boolean
    local group g
    local unit FoG
    if GetResearched() == 'R00R' and not bj_dncIsDaytime then
        set g = CreateGroup()
        call GroupEnumUnitsOfPlayer(g, GetTriggerPlayer(), null)
        loop
            set FoG = FirstOfGroup(g)
            exitwhen FoG == null
            if GetUnitTypeId(FoG) == 'e005' and GetUnitAbilityLevel(FoG, 'Abds') == 0 then
                call WereWell(FoG, true)
            endif
            call GroupRemoveUnit(g, FoG)
        endloop
        call DestroyGroup(g)
        set g = null
    endif
    return false
endfunction

function Moon_Wells_Constr takes nothing returns boolean
    if GetPlayerTechCount(GetTriggerPlayer(), 'R00R', true) == 1 and GetUnitTypeId(GetTriggerUnit()) == 'e005' and not bj_dncIsDaytime then
        call WereWell(GetTriggerUnit(), true)
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Moon_Wells takes nothing returns nothing
    local trigger day = CreateTrigger()
    local trigger upg = CreateTrigger()
    local trigger constr = CreateTrigger()
    set gg_trg_Moon_Wells = CreateTrigger(  )
    call TriggerRegisterGameStateEventTimeOfDay( gg_trg_Moon_Wells, GREATER_THAN_OR_EQUAL, bj_TOD_DUSK )
    call TriggerRegisterGameStateEventTimeOfDay( gg_trg_Moon_Wells, LESS_THAN, bj_TOD_DAWN )
    call TriggerAddCondition( gg_trg_Moon_Wells, Condition(function Moon_Wells_Night) )
    call TriggerRegisterGameStateEventTimeOfDay( day , LESS_THAN, bj_TOD_DUSK )
    call TriggerRegisterGameStateEventTimeOfDay( day , GREATER_THAN_OR_EQUAL, bj_TOD_DAWN )
    call TriggerAddCondition( day , Condition(function Moon_Wells_Day) )
    call TriggerRegisterAnyUnitEventBJ( upg , EVENT_PLAYER_UNIT_RESEARCH_FINISH )
    call TriggerAddCondition( upg , Condition(function Moon_Wells_Upg) )
    call TriggerRegisterAnyUnitEventBJ( constr , EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
    call TriggerAddCondition( constr , Condition( function Moon_Wells_Constr ) )
    set day = null
    set upg = null
    set constr = null
endfunction
that's what I did.. any way to improve it? :p

What it does: Turns moon wells into Corrupted moon wells during the night, and corrupted moon wells into moon wells during the day.
Only works for players who have 1 research complete.
It also runs when a moon well if built during the night (and the player who built it has the research), and it also runs when the player finishes the said research during nighttime.
GetUnitAbilityLevel(FoG, 'Abds') == 0 is used to filter out the moon wells, that are still being constructed.
 
Status
Not open for further replies.
Top