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

[JASS] Why aren't my triggers running at Map Initialization?

Status
Not open for further replies.
Level 6
Joined
Jul 8, 2008
Messages
150
I made 2 triggers:

JASS:
scope SetGame initializer Init

private function AddItemsToArmory takes nothing returns boolean
    local unit u = GetEnumUnit()
    local integer i = 0
    
    if GetUnitTypeId(u) == ARMORY then
        set ARMCOUNT = 14
        set ARM[1] = 'I00O' //CLAWS OF ATTACK +5
        set ARM[2] = 'I00L' //CLAWS OF ATTACK +5
        set ARM[3] = 'I00M' //CLAWS OF ATTACK +5
        set ARM[4] = 'I00N' //CLAWS OF ATTACK +5
        set ARM[5] = 'I015' //ARMOR OF PROTECTION +2
        set ARM[6] = 'I014' //ARMOR OF PROTECTION +2
        set ARM[7] = 'I00W' //ARMOR OF PROTECTION +2
        set ARM[8] = 'I013' //ARMOR OF PROTECTION +2
        set ARM[9] = 'I00T' //CROWN OF KINGS
        set ARM[10] = 'I00U' //HERO'S HELM
        set ARM[11] = 'I00V' //WIZARD'S ROBES
        set ARM[12] = 'I018' //JOKER'S MASK
        set ARM[13] = 'I01L' //NATALYA'S MARK
        set ARM[14] = 'I01K' //NATALYA'S ESCAPE
        
        loop
        set i = i + 1
            set RNDINTEGER = GetRandomInt(1, ARMCOUNT)
            
            call AddItemToStock(u, ARM[RNDINTEGER], 1, 1)
            
            set ARM[RNDINTEGER] = ARM[ARMCOUNT]
            set ARMCOUNT = (ARMCOUNT - 1)
        exitwhen i > 11
        endloop
    endif
    
    set u = null
    return false
endfunction


private function AddItemsToMarketplace takes nothing returns nothing //UNFINISHED FUNCTION!
    local integer i = 0
    set TRINKETCOUNT = 12
    set TRINKET[1] = 'I011' //AMULET OF RECALL
    set TRINKET[2] = 'I012' //ANKH OF REINCARNATION
    set TRINKET[3] = 'I016' //CRYSTAL BALL
    set TRINKET[4] = 'I010' //HERO'S HORN OF MIGHT
    set TRINKET[5] = 'I00X' //JADE RING
    set TRINKET[6] = 'I017' //PENDANT OF ENERGY
    set TRINKET[7] = 'I00Y' //SPIDER RING
    set TRINKET[8] = 'I00Z' //SPY SCOPE
    set TRINKET[9] = 'I019' //GEM OF GREED
    set TRINKET[10] = 'I01A' //KEG OF THUNDERWATER
    set TRINKET[11] = 'I01B' //MEDALLION OF COURAGE
    set TRINKET[12] = 'I01C' //WARSONG BATTLE DRUMS
    
    loop
    set i = i + 1
        set RNDINTEGER = GetRandomInt(1, TRINKETCOUNT)
        
        call AddItemToStock(GetEnumUnit(), TRINKET[RNDINTEGER], 1, 1)
        
        set TRINKET[RNDINTEGER] = TRINKET[TRINKETCOUNT]
        set TRINKETCOUNT = (TRINKETCOUNT - 1)
    exitwhen i > 11
    endloop
endfunction

private function Actions takes nothing returns nothing
    local integer i = 0

    //ADD ITEMS TO ARMORY
    call GroupEnumUnitsOfPlayer(TEMPGROUP, Player(PLAYER_NEUTRAL_PASSIVE), Condition(function AddItemsToArmory))
    //ADD ITEMS TO MARKETPLACE
    call GroupEnumUnitsOfPlayer(TEMPGROUP, Player(PLAYER_NEUTRAL_PASSIVE), Condition(function AddItemsToArmory))
    
    //RUNING MISC. ACTIONS
    call SetGameSpeed(MAP_SPEED_FASTEST)
    call SetMapFlag(MAP_LOCK_SPEED, true)
    call SuspendTimeOfDay(false)
    call SetFloatGameState(GAME_STATE_TIME_OF_DAY, GetRandomReal(0.0, 23.59))
    call CameraSetSmoothingFactor(5.0)
    call SetPlayerState(Player(PLAYER_NEUTRAL_AGGRESSIVE), PLAYER_STATE_NO_CREEP_SLEEP, IntegerTertiaryOp(true, 0, 1))
    call SetCreepCampFilterState(false)
    call SetAllyColorFilterState(2)
    call MultiboardSuppressDisplay(false)
    call SetSkyModel("Environment\\Sky\\LordaeronSummerSky\\LordaeronSummerSky.mdl")
    call FlashQuestDialogButton()
    
    //WEATHER
    if GetRandomInt(1, 5) == 1 then
        call EnableWeatherEffect(WEATHEREFFECT[GetRandomInt(0, 4)], true)
    else
        loop
            call EnableWeatherEffect(WEATHEREFFECT[i], false)
        set i = i + 1
        exitwhen i > 4
        endloop
    endif
    
    call DestroyTrigger(GetTriggeringTrigger())
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction
endscope

JASS:
scope SetTeams initializer Init

globals
    private constant integer HEROSELECTORID = 'n00R'
    private constant integer STARTGOLD = 750
    private constant real CENTERSHOPX = GetUnitX(gg_unit_n01E_0006)
    private constant real CENTERSHOPY = GetUnitY(gg_unit_n01E_0006)
    private constant real RECTX = GetRectCenterX(gg_rct_Select_Hero_Center)
    private constant real RECTY = GetRectCenterY(gg_rct_Select_Hero_Center)
    
    private boolexpr SharedVisionConditions
endglobals

private function SharedVision takes nothing returns boolean
    local unit u = GetFilterUnit()
    call UnitShareVision(u, Player(0), true)
    set u = null
    return false
endfunction

private function Actions takes nothing returns nothing
    local integer i = 0
    local fogmodifier fog = null
    
    loop
        if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
        
            //TEAM 1
            if i < 5 and Player(i) != Player(i) then
                //PLAYER >> CONTROLLER
                call SetPlayerAllianceStateAllyBJ(Player(i), Player(5), true)
                call SetPlayerAllianceStateVisionBJ(Player(i), Player(5), false)
                call SetPlayerAllianceStateControlBJ(Player(i), Player(5), false)
                call SetPlayerAllianceStateFullControlBJ(Player(i), Player(5), false)
                //CONTROLLER >> PLAYER
                call SetPlayerAllianceStateAllyBJ(Player(5), Player(i), true)
                call SetPlayerAllianceStateVisionBJ(Player(5), Player(i), false)
                call SetPlayerAllianceStateControlBJ(Player(5), Player(i), true)
                call SetPlayerAllianceStateFullControlBJ(Player(5), Player(i), true)
                call GroupEnumUnitsOfPlayer(TEMPGROUP, Player(5), SharedVisionConditions)
                
            //TEAM 2
            elseif Player(i) != Player(i) then
                //PLAYER >> CONTROLLER
                call SetPlayerAllianceStateAllyBJ(Player(i), Player(11), true)
                call SetPlayerAllianceStateVisionBJ(Player(i), Player(11), false)
                call SetPlayerAllianceStateControlBJ(Player(i), Player(11), false)
                call SetPlayerAllianceStateFullControlBJ(Player(i), Player(11), false)
                //CONTROLLER >> PLAYER
                call SetPlayerAllianceStateAllyBJ(Player(11), Player(i), true)
                call SetPlayerAllianceStateVisionBJ(Player(11), Player(i), false)
                call SetPlayerAllianceStateControlBJ(Player(11), Player(i), true)
                call SetPlayerAllianceStateFullControlBJ(Player(11), Player(i), true)
                call GroupEnumUnitsOfPlayer(TEMPGROUP, Player(11), SharedVisionConditions)
            endif
            
            //ALL PLAYERS
            set HEROSELECTOR[i] = CreateUnit(Player(i), HEROSELECTORID, CENTERSHOPX, CENTERSHOPY, 0.0)
            set fog = CreateFogModifierRect(Player(i), FOG_OF_WAR_VISIBLE, MAPENTIRE, false, false)
            set CAMDIST[i] = 2500.00
            
            call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, CAMDIST[i], 0.0)
            call PanCameraToTimed(RECTX, RECTY, 0.0)
            call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD, STARTGOLD)
            //call SetPlayerAllianceStateBJ( ConvertedPlayer(GetForLoopIndexA()), Player(bj_PLAYER_NEUTRAL_EXTRA), bj_ALLIANCE_NEUTRAL )
            call SetPlayerTechMaxAllowed(Player(i), 'HERO', 2)
            //call SetPlayerFlagBJ( PLAYER_STATE_GIVES_BOUNTY, true, ConvertedPlayer(GetForLoopIndexA()) )
            call SetPlayerState(Player(i),  PLAYER_STATE_GIVES_BOUNTY, IntegerTertiaryOp(true, 1, 0))
            
            //DISABLE ABILITIES
            call SetPlayerAbilityAvailable(Player(i), 'Aatk', false) //ATTACK
            call SetPlayerAbilityAvailable(Player(i), 'A075', false) //HERO CONTROL
            call SetPlayerAbilityAvailable(Player(i), 'A00N', false) //HERO STATS
            call SetPlayerAbilityAvailable(Player(i), 'ASS1', false) //SKILL SLOT 1
            call SetPlayerAbilityAvailable(Player(i), 'ASS2', false) //SKILL SLOT 2
            call SetPlayerAbilityAvailable(Player(i), 'ASS3', false) //SKILL SLOT 3
            call SetPlayerAbilityAvailable(Player(i), 'ASS4', false) //SKILL SLOT 4
            
            call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 20.0, "|cff1FBF00HINT: If you've never played before, I recommand you read the|r |cffFFCC00Help & Info Dialog|r |cff1FBF00(|r|cffFFCC00F9|r|cff1FBF00) to learn how to play.|r")
            
            call DestroyFogModifier(fog)
            set fog = null
        endif
    set i = i + 1
    exitwhen i > bj_MAX_PLAYER_SLOTS
    endloop
    
    call DestroyBoolExpr(SharedVisionConditions)
    call DestroyTrigger(GetTriggeringTrigger())
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function Actions )
    set t = null
    
     set SharedVisionConditions = Condition(function SharedVision)
endfunction
endscope

Neither of them run at Map Initialization even though I checked the box that says "Run on Map Initialization".
 
Level 4
Joined
Mar 23, 2008
Messages
87
JASS:
function RunInitializationTriggers takes nothing returns nothing
    call ConditionalTriggerExecute(gg_trg_YourTrigger)
endfunction
I'm using NewGen Editor and this is in my thingy when i compile map with map init triggers
not an expert on the subject though. hope it helps :)
 
Level 9
Joined
Aug 21, 2008
Messages
533
Use time 0.1 instead

I want initialization though...

Some things you cant do at initialization
You used multibard somewhere-> but multiboards cant be used at map initialazion. if you use at 0.1 its jsut like the same. You even could make at 0,0 alttought it isnt the same what you want you have to use it if you want use multiboards.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Well did you honestly expect it to work? Nowhere did you tell anything to run, you only set up a trigger with the code as actions and never did anything with it at all.

Triggers do not run magically, you actually need to execute them (how normal WE does map init triggers) or execute a function directly (via call or however).
 
Status
Not open for further replies.
Top