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

[vJASS] Strange Issues With Script

Status
Not open for further replies.
Level 17
Joined
Feb 11, 2011
Messages
1,860
I have a map which requires all players' heroes to be in a region before the game starts. The region is like this:

screen1qc.jpg


Details
TopGate and BottomGate are set on map initialization. The function LevelBegin spawns the creeps, owned by Player 12.
At map initialization, the top gate is opened. When all players are in the region (between the two gates), the top one is meant to close and the bottom one is meant to open. Here is the script:

JASS:
library AllReady initializer onInit requires OpenGate, CloseGate, LevelBegin

    private function Actions takes nothing returns nothing
        local integer count
        local unit filter
        call GroupEnumUnitsInRect(bj_lastCreatedGroup, gg_rct_ReadyArea, null)
        loop
            set filter = FirstOfGroup(bj_lastCreatedGroup)
            exitwhen filter == null
            if IsUnitType(filter, UNIT_TYPE_HERO) and GetOwningPlayer(filter) != Player(11) then
                set count = count + 1
            endif
            call GroupRemoveUnit(bj_lastCreatedGroup, filter)
        endloop
        call BJDebugMsg("Count is: " + I2S(count))
        if count == udg_Number_of_Players then
            call CloseGate(TopGate)
            call OpenGate(BottomGate)
            call LevelBegin_Actions()
        endif
    endfunction

    private function Conditions takes nothing returns boolean
        if GetDestructableLife(TopGate) <= 0 and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetOwningPlayer(GetTriggerUnit()) != Player(11) then
            call Actions()
        endif
        return false
    endfunction

    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterEnterRectSimple(t, gg_rct_ReadyArea)        
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction

endlibrary

In the above script, there is a debug message. It displays "Count is: 0" when a hero enters (when it is meant to say "Count is: 1").

The other libraries are:

JASS:
library OpenGate

    public function Actions takes destructable gate returns nothing
        if GetDestructableLife(gate) > 0 then
            call KillDestructable(gate)
        endif
        call SetDestructableAnimation(gate, "death alternate")
        set gate = null
    endfunction

endlibrary

library CloseGate

    public function Actions takes destructable gate returns nothing
        if GetDestructableLife(gate) <= 0 then
            call DestructableRestoreLife(gate, GetDestructableMaxLife(gate), true)
        endif
        call SetDestructableAnimation(gate, "stand")
        set gate = null
    endfunction

endlibrary

Also, when the game starts, some creeps spawn in the region (they spawn randomly around the map). This causes the game to freeze completely (not crash, though).

Any thoughts?
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Changed that, but still no difference. The gates don't open/close and it still freezes when the creeps spawn. It also displays "Count is: 0", but the actions still fire.

JASS:
library GateState

    public function Open takes destructable gate returns nothing
        if GetDestructableLife(gate) > 0 then
            call KillDestructable(gate)
        endif
        call SetDestructableAnimation(gate, "death alternate")
        set gate = null
    endfunction

    public function Close takes destructable gate returns nothing
        if GetDestructableLife(gate) <= 0 then
            call DestructableRestoreLife(gate, GetDestructableMaxLife(gate), true)
        endif
        call SetDestructableAnimation(gate, "stand")
        set gate = null
    endfunction
    
endlibrary

JASS:
library AllReady initializer onInit requires GateState, LevelBegin

    private function Actions takes nothing returns nothing
        local integer count = 0
        local unit filter
        call GroupEnumUnitsInRect(bj_lastCreatedGroup, gg_rct_ReadyArea, null)
        loop
            set filter = FirstOfGroup(bj_lastCreatedGroup)
            exitwhen filter == null
            if IsUnitType(filter, UNIT_TYPE_HERO) and GetOwningPlayer(filter) != Player(11) then
                set count = count + 1
            endif
            call GroupRemoveUnit(bj_lastCreatedGroup, filter)
        endloop
        call BJDebugMsg("Count is: " + I2S(count))
        if count == udg_Number_of_Players then
            call GateState_Close(TopGate)
            call GateState_Open(BottomGate)
            call LevelBegin_Actions()
        endif
    endfunction

    private function Conditions takes nothing returns boolean
        if GetDestructableLife(TopGate) <= 0 and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetOwningPlayer(GetTriggerUnit()) != Player(11) then
            call Actions()
        endif
        return false
    endfunction

    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterEnterRectSimple(t, gg_rct_ReadyArea)        
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction

endlibrary
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
JASS:
library AllReady initializer onInit requires GateState, LevelBegin

    globals
        private timer t = CreateTimer()
    endglobals

    private function Actions takes nothing returns nothing
        local integer count = 0
        local unit filter
        call GroupEnumUnitsInRect(bj_lastCreatedGroup, gg_rct_ReadyArea, null)
        loop
            set filter = FirstOfGroup(bj_lastCreatedGroup)
            exitwhen filter == null
            if IsUnitType(filter, UNIT_TYPE_HERO) and GetOwningPlayer(filter) != Player(11) then
                set count = count + 1
            endif
            call GroupRemoveUnit(bj_lastCreatedGroup, filter)
        endloop
        call BJDebugMsg("Count is: " + I2S(count))
        if count == udg_Number_of_Players then
            call GateState_Close(TopGate)
            call GateState_Open(BottomGate)
            call LevelBegin_Actions()
        endif
    endfunction

    private function Conditions takes nothing returns boolean
        if GetDestructableLife(TopGate) <= 0 and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetOwningPlayer(GetTriggerUnit()) != Player(11) then
            call TimerStart(t, 0.1, false, function Actions)
        endif
        return false
    endfunction

    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterEnterRectSimple(t, gg_rct_ReadyArea)        
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction

endlibrary

This is what Maker suggested, and it works. Thanks guys!
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Update:
New problem. My globals don't initialize properly! I have a library in the map header which contains a function which sets all the global variables (like creep types, hero types and more). For example, it is meant to make two gates invulnerable, but it doesn't! It is also meant to open one of them - it doesn't. What can I do?

JASS:
globals
    constant integer DUMMY = 'h003'
    
    boolean AllReady = false
    
    destructable TopGate = gg_dest_LTg1_0104
    destructable BottomGate = gg_dest_LTg1_0099
endglobals

library MapSetup initializer onInit

    private function Player_Conditions takes nothing returns boolean
        return (GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING) and (GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER)
    endfunction

    private function onInit takes nothing returns nothing
        local integer i = 1
        local real x = GetRectCenterX(gg_rct_WholeArena)
        local real y = GetRectCenterY(gg_rct_WholeArena)
        local force Force = CreateForce()
        call ForceEnumPlayers(Force, Condition(function Player_Conditions))
        set udg_Number_of_Players = CountPlayersInForceBJ(Force)
        call DestroyForce(Force)
        set Force = null
        set udg_Gambler = gg_unit_n013_0006
        set udg_Selector[1] = gg_unit_h00K_0008
        set udg_Selector[2] = gg_unit_h00K_0010
        set udg_Selector[3] = gg_unit_h00K_0011
        set udg_Selector[4] = gg_unit_h00K_0012
        set udg_Next_Level = gg_unit_h00N_0005
        set udg_Cyclone_Spawn[1] = gg_rct_Cyclone1
        set udg_Cyclone_Spawn[2] = gg_rct_Cyclone2
        set udg_Cyclone_Spawn[3] = gg_rct_Cyclone3
        set udg_Cyclone_Spawn[4] = gg_rct_Cyclone4
        set udg_Cyclone_Spawn[5] = gg_rct_Cyclone5
        set udg_Hero_Type[1] = 'E000'
        set udg_Hero_Type[2] = 'H004'
        set udg_Hero_Type[3] = 'H008'
        set udg_Hero_Type[4] = 'H001'
        set udg_Hero_Type[5] = 'H00G'
        set udg_Hero_Type[6] = 'H006'
        set udg_Hero_Type[7] = 'O003'
        set udg_Hero_Type[8] = 'O004'
        set udg_Hero_Type[9] = 'U006'
        set udg_Normal_Creep_Type[1] = 'h009'
        set udg_Normal_Creep_Type[2] = 'h00A'
        set udg_Normal_Creep_Type[3] = 'h007'
        set udg_Normal_Creep_Type[4] = 'h00D'
        set udg_Normal_Creep_Type[5] = 'U007'
        set udg_Normal_Creep_Type[6] = 'h00E'
        set udg_Normal_Creep_Type[7] = 'h00F'
        set udg_Normal_Creep_Type[8] = 'u004'
        set udg_Normal_Creep_Type[9] = 'h00I'
        set udg_Normal_Creep_Type[10] = 'U00A'
        set udg_Normal_Creep_Type[11] = 'n007'
        set udg_Normal_Creep_Type[12] = 'o000'
        set udg_Normal_Creep_Type[13] = 'o001'
        set udg_Normal_Creep_Type[14] = 'u005'
        set udg_Normal_Creep_Type[15] = 'N00W'
        set udg_Normal_Creep_Type[16] = 'n008'
        set udg_Normal_Creep_Type[17] = 'n00A'
        set udg_Normal_Creep_Type[18] = 'n00B'
        set udg_Normal_Creep_Type[19] = 'n00C'
        set udg_Normal_Creep_Type[20] = 'H00L'
        set udg_Normal_Creep_Type[21] = 'n00D'
        set udg_Normal_Creep_Type[22] = 'n00E'
        set udg_Normal_Creep_Type[23] = 'n00F'
        set udg_Normal_Creep_Type[24] = 'n00G'
        set udg_Normal_Creep_Type[25] = 'U00B'
        set udg_Special_Creep_Type[1] = 'h002'
        set udg_Special_Creep_Type[2] = 'o002'
        set udg_Special_Creep_Type[3] = 'h005'
        set udg_Special_Creep_Type[4] = 'o005'
        set udg_Special_Creep_Type[5] = 0
        set udg_Special_Creep_Type[6] = 'h00B'
        set udg_Special_Creep_Type[7] = 'n00H'
        set udg_Special_Creep_Type[8] = 'u008'
        set udg_Special_Creep_Type[9] = 'h00C'
        set udg_Special_Creep_Type[10] = 0
        set udg_Special_Creep_Type[11] = 'n00K'
        set udg_Special_Creep_Type[12] = 'o006'
        set udg_Special_Creep_Type[13] = 'n00L'
        set udg_Special_Creep_Type[14] = 'u009'
        set udg_Special_Creep_Type[15] = 0
        set udg_Special_Creep_Type[16] = 'n00N'
        set udg_Special_Creep_Type[17] = 'e001'
        set udg_Special_Creep_Type[18] = 'n00M'
        set udg_Special_Creep_Type[19] = 'n00O'
        set udg_Special_Creep_Type[20] = 0
        set udg_Special_Creep_Type[21] = 'n00P'
        set udg_Special_Creep_Type[22] = 'n00Q'
        set udg_Special_Creep_Type[23] = 'n00R'
        set udg_Special_Creep_Type[24] = 'n00S'
        set udg_Special_Creep_Type[25] = 0
        set udg_Creep_Ability[1] = 'A00U'
        set udg_Creep_Ability[2] = 'A013'
        set udg_Creep_Ability[3] = 'A01C'
        set udg_Creep_Ability[4] = 'A01K'
        set udg_Creep_Ability[5] = 0
        set udg_Creep_Ability[6] = 'A03J'
        set udg_Creep_Ability[7] = 'A03K'
        set udg_Creep_Ability[8] = 'A03O'
        set udg_Creep_Ability[9] = 'A03P'
        set udg_Creep_Ability[10] = 0
        set udg_Creep_Ability[11] = 'A03Q'
        set udg_Creep_Ability[12] = 'A03R'
        set udg_Creep_Ability[13] = 'A03S'
        set udg_Creep_Ability[14] = 'A03U'
        set udg_Creep_Ability[15] = 0
        set udg_Creep_Ability[16] = 'A03Z'
        set udg_Creep_Ability[17] = 'A040'
        set udg_Creep_Ability[18] = 'S002'
        set udg_Creep_Ability[19] = 'A041'
        set udg_Creep_Ability[20] = 0
        set udg_Creep_Ability[21] = 'A042'
        set udg_Creep_Ability[22] = 'A043'
        set udg_Creep_Ability[23] = 'A044'
        set udg_Creep_Ability[24] = 'A045'
        set udg_Creep_Ability[25] = 0
        set udg_Special_Ability[1] = "|cffffcc00Headshot|r. Gives a 12 percent per attack to deal 1.75x damage."
        set udg_Special_Ability[2] = "|cffffcc00Rage|r. Increases attack speed by 25 percent for 10 seconds."
        set udg_Special_Ability[3] = "|cffffcc00Slow|r. Decreases movement speed by 60 percent and attack speed by 20 percent for 10 seconds."
        set udg_Special_Ability[4] = "|cffffcc00Bloodlust|r. Increases damage by 10 percent and armour by 3 for 10 seconds."
        set udg_Special_Ability[5] = "|cffffcc00Breath of Frost; Frost Armour; Frost Pulse; Ice Aura.|r"
        set udg_Special_Ability[6] = "|cffffcc00Smash|r. 15 percent chance per attack to deal 15 bonus damage and stun for 1 second,"
        set udg_Special_Ability[7] = "|cffffcc00Faerie Fire|r. Causes the target's armour to be reduced by 3 for 5 seconds."
        set udg_Special_Ability[8] = "|cffffcc00Essence of Blight|r. Heals nearby allied units by 10 hit points."
        set udg_Special_Ability[9] = "|cffffcc00Blessing|r. Increases attack damage by 15 percent, armour by 5 and HP regen by 3."
        set udg_Special_Ability[10] = "|cffffcc00Weakness Aura; Death Coil; Vampire Attack; Frighten.|r"
        set udg_Special_Ability[11] = "|cffffcc00Slow Poison|r. Slows movement speed by 50 percent, attack speed by 20 percent and deals 5 damage per second for 5 seconds."
        set udg_Special_Ability[12] = "|cffffcc00Voodoo Aura|r. Increases nearby allied units' hit point regeneration by 5HP/s."
        set udg_Special_Ability[13] = "|cffffcc00Fireball|r. Throws a fireball, dealing 200 damage and stunning for 0.5 seconds."
        set udg_Special_Ability[14] = "|cffffcc00Curse|r. Causes the target to miss on 20 percent of its attacks for 5 seconds."
        set udg_Special_Ability[15] = "|cffffcc00Bash; Mighty Stomp; Battle Cry; Confusion.|r"
        set udg_Special_Ability[16] = "|cffffcc00Tidal Wave|r. Sends out a giant wave, dealing 300 damage to enemies in a cone."
        set udg_Special_Ability[17] = "|cffffcc00Tidal Eruption|r. Blasts a unit, dealing 250 damage and slows movement speed by 30 percent and attack speed by 25 percent. Lasts 5 seconds."
        set udg_Special_Ability[18] = "|cffffcc00Endurance Aura|r. Increases attack speeds of nearby allies by 15 percent."
        set udg_Special_Ability[19] = "|cffffcc00Pain Aura|r. Increases attack damage of nearby allies by 15 percent."
        set udg_Special_Ability[20] = "|cffffcc00Incinerate; Flame Surge; Pillar of Flame; Dodge.|r"
        set udg_Special_Ability[21] = "|cffffcc00Chilling Aura|r. Decreases the mana regeneration of nearby enemies by 100 percent."
        set udg_Special_Ability[22] = "|cffffcc00Electric Shock|r. Deals 500 damage to the target hero."
        set udg_Special_Ability[23] = "|cffffcc00Devotion Aura|r. Increases the armour of nearby allies by 10."
        set udg_Special_Ability[24] = "|cffffcc00Heal|r. Restores 200 hit points."
        set udg_Special_Ability[25] = "|cffffcc00Summon Demon; Ascendancy; Armegeddon; Flame Lash.|r"
        set udg_Boss_Speech[1] = "|cffffcc00Lich:|r You should see the skeletons in |cffff0000my|r closet!"
        set udg_Boss_Speech[2] = "|cffffcc00Death Knight:|r Don't touch me - I'm evil!"
        set udg_Boss_Speech[3] = "|cffffcc00Warlock:|r You know what burns my ass? A flame about this high!"
        set udg_Boss_Speech[4] = "|cffffcc00Cyclone Invoker:|r If you don't master your anger, your anger will master you...I should know."
        set udg_Boss_Speech[5] = "|cffffcc00Archimonde:|r The Scourge will devour all!"
        set udg_Boss_Ability[1] = 'A02L'
        set udg_Boss_Ability[2] = 'A02M'
        set udg_Boss_Ability[3] = 'A02R'
        set udg_Boss_Ability[4] = 'S001'
        set udg_Boss_Ability[5] = 'A03V'
        set udg_Boss_Ability[6] = 'A03W'
        set udg_Boss_Ability[7] = 'A03X'
        set udg_Boss_Ability[8] = 'A03Y'
        set udg_Boss_Ability[9] = 'A011'
        set udg_Boss_Ability[10] = 'A04P'
        set udg_Boss_Ability[11] = 'A04R'
        set udg_Boss_Ability[12] = 'A04B'
        set udg_Boss_Ability[13] = 'A04U'
        set udg_Boss_Ability[14] = 'A04W'
        set udg_Boss_Ability[15] = 'A04D'
        set udg_Boss_Ability[16] = 'A050'
        set udg_Boss_Ability[17] = 'A047'
        set udg_Boss_Ability[18] = 'A048'
        set udg_Boss_Ability[19] = 'A04N'
        set udg_Boss_Ability[20] = 'A04O'
        set udg_Level_Sound[1] = gg_snd_Level1
        set udg_Level_Sound[2] = gg_snd_Level2
        set udg_Level_Sound[3] = gg_snd_Level3
        set udg_Level_Sound[4] = gg_snd_Level4
        set udg_Level_Sound[5] = gg_snd_Level5BOSS
        set udg_Level_Sound[6] = gg_snd_Level6
        set udg_Level_Sound[7] = gg_snd_Level7
        set udg_Level_Sound[8] = gg_snd_Level8
        set udg_Level_Sound[9] = gg_snd_Level9
        set udg_Level_Sound[10] = gg_snd_Level10BOSS
        set udg_Level_Sound[11] = gg_snd_Level11
        set udg_Level_Sound[12] = gg_snd_Level12
        set udg_Level_Sound[13] = gg_snd_Level13
        set udg_Level_Sound[14] = gg_snd_Level14
        set udg_Level_Sound[15] = gg_snd_Level15BOSS
        set udg_Level_Sound[16] = gg_snd_Level16
        set udg_Level_Sound[17] = gg_snd_Level17
        set udg_Level_Sound[18] = gg_snd_Level18
        set udg_Level_Sound[19] = gg_snd_Level19
        set udg_Level_Sound[20] = gg_snd_Level20BOSS
        set udg_Level_Sound[21] = gg_snd_Level21
        set udg_Level_Sound[22] = gg_snd_Level22
        set udg_Level_Sound[23] = gg_snd_Level23
        set udg_Level_Sound[24] = gg_snd_Level24
        set udg_Level_Sound[25] = gg_snd_Level25BOSS
        call SetPlayerState(Player(11), PLAYER_STATE_GIVES_BOUNTY, 1)
        call SetPlayerName(Player(0), "|cffFF0202" + GetPlayerName(Player(0)) + "|r")
        call SetPlayerName(Player(1), "|cff0041FF" + GetPlayerName(Player(1)) + "|r")
        call SetPlayerName(Player(2), "|cff1BE5B8" + GetPlayerName(Player(2)) + "|r")
        call SetPlayerName(Player(3), "|cff530080" + GetPlayerName(Player(3)) + "|r")
        call SetPlayerName(Player(9), "|cff7DBEF1" + GetPlayerName(Player(9)) + "|r")
        call SetPlayerName(Player(11), "|cff4D2903" + GetPlayerName(Player(11)) + "|r")        
        call SuspendTimeOfDay(true)
        call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 12.00)
        call FogMaskEnable(false)
        call FogModifierStart(bj_lastCreatedFogModifier)
        loop
            if (GetPlayerSlotState(Player(i - 1)) != PLAYER_SLOT_STATE_PLAYING) or (GetPlayerController(Player(i - 1)) == MAP_CONTROL_COMPUTER) then
                call RemoveUnit(udg_Selector[i])
                set udg_Selector[i] = null
            endif
            exitwhen i == 4
            set i = i + 1
        endloop
        call CinematicFadeBJ(bj_CINEFADETYPE_FADEOUT, 0.00, "ReplaceableTextures\\CameraMasks\\Black_mask.blp", 0, 0, 0, 0)
        if (IsPlayerInForce(GetLocalPlayer(), bj_FORCE_ALL_PLAYERS) == true) then
            call FogModifierStart(bj_lastCreatedFogModifier)
            call SetPlayerTechMaxAllowed(GetLocalPlayer(), 'HERO', 1)
            call SetPlayerState(GetLocalPlayer(), PLAYER_STATE_RESOURCE_GOLD, (750 + ((4 - udg_Number_of_Players) * 150)))
            call SetPlayerAlliance(Player(9), GetLocalPlayer(), ALLIANCE_SHARED_CONTROL, true)
            call ClearTextMessages()
        endif
        call TriggerExecute(gg_trg_Level_Setup)
        set udg_DifficultyDummy = CreateUnit(Player(11), DUMMY, x, y, 0)
        call RemoveGuardPosition(udg_DifficultyDummy)
        call UnitAddAbility(udg_DifficultyDummy, 'A04M')
        call SetUnitAbilityLevel(udg_DifficultyDummy, 'A04M', udg_Number_of_Players)
        call UnitAddAbility(udg_DifficultyDummy, 'A059')
        call SetUnitAbilityLevel(udg_DifficultyDummy, 'A059', udg_Number_of_Players)
        call GateState_Open(TopGate)
        call SetDestructableInvulnerable(TopGate, true)
        call SetDestructableInvulnerable(BottomGate, true)
    endfunction

endlibrary
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Maker said:
When a unit enters region, it won't be picked for instant group enums considering that region.

Well, if i remember correctly it all depends if the unit entered by a trigger action such as
SetUnitPosition or by the "natural" wc3 move system.

trigger action -> instant and the unit is considered in the region

wc3 move system -> depends on which side she came (north/east/south/west).
Half part of these sides (can't remember which ones) -> the unit is considered in the
region.
The other half part -> the unit is not considered in the region.

I consider this way more reliable, since it's instant :

JASS:
library AllReady initializer onInit requires GateState, LevelBegin

    private function Actions takes nothing returns nothing
        local integer count = 0
        local unit filter = GetTriggerUnit()
        call GroupEnumUnitsInRect(bj_lastCreatedGroup, gg_rct_ReadyArea, null)
        if not IsUnitInGroup(filter,bj_lastCreatedGroup) and IsUnitType(filter, UNIT_TYPE_HERO) and GetOwningPlayer(filter) != Player(11) then
            set count = count + 1
        endif
        loop
            set filter = FirstOfGroup(bj_lastCreatedGroup)
            exitwhen filter == null
            if IsUnitType(filter, UNIT_TYPE_HERO) and GetOwningPlayer(filter) != Player(11) then
                set count = count + 1
            endif
            call GroupRemoveUnit(bj_lastCreatedGroup, filter)
        endloop
        call BJDebugMsg("Count is: " + I2S(count))
        if count == udg_Number_of_Players then
            call GateState_Close(TopGate)
            call GateState_Open(BottomGate)
            call LevelBegin_Actions()
        endif
    endfunction

    private function Conditions takes nothing returns boolean
        if GetDestructableLife(TopGate) <= 0 and IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and GetOwningPlayer(GetTriggerUnit()) != Player(11) then
            call Actions()
        endif
        return false
    endfunction

    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterEnterRectSimple(t, gg_rct_ReadyArea)        
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction

endlibrary

For your globals problem :

I'm afraid that all vJass initalizers are done before GUI ones and preplaced objects.
I think your best choice here is to use a timer(0) as an initializer.
But to be sure, before do that, save your map and check the outputwar3map.j (in the subfolder logs of your JNGP)
 
Last edited:
Level 17
Joined
Feb 11, 2011
Messages
1,860
Okay, thanks. I will work on that now.

Another quick question: what is wrong with this (this is in the map header):

JASS:
globals
     unittype array udg_Hero_Type
endglobals

library MapSetup

    set udg_Hero_Type[1] = 'E000'
    set udg_Hero_Type[2] = 'H004'
    set udg_Hero_Type[3] = 'H008'
    set udg_Hero_Type[4] = 'H001'
    set udg_Hero_Type[5] = 'H00G'
    set udg_Hero_Type[6] = 'H006'
    set udg_Hero_Type[7] = 'O003'
    set udg_Hero_Type[8] = 'O004'
    set udg_Hero_Type[9] = 'U006'

endlibrary
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Sorry, it actually is inside a function. I just copied a section of the code and forgot to include the function declaration. It says "Cannot convert integer to unit-type".

JASS:
globals
    unittype array udg_Hero_Type
endglobals

library MapSetup initializer onInit

private function onInit takes nothing returns nothing
    set udg_Hero_Type[1] = 'E000'
    set udg_Hero_Type[2] = 'H004'
    set udg_Hero_Type[3] = 'H008'
    set udg_Hero_Type[4] = 'H001'
    set udg_Hero_Type[5] = 'H00G'
    set udg_Hero_Type[6] = 'H006'
    set udg_Hero_Type[7] = 'O003'
    set udg_Hero_Type[8] = 'O004'
    set udg_Hero_Type[9] = 'U006'
endfunction

endlibrary
Don't worry, I'm using udg_ because I'm converting my GUI triggers to JASS. When that's complete, I will convert the variable names.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
It's because unit rawcodes are integer, just like any object in the object editor.

The type unittype is used for UNIT_TYPE_STRUCTURE and such.
I mean it's the unit classification.

'xxxx' is just an other integer base.
It uses letters as acronyms, for example 'hfoo' stands for human footman.
There is a mathematic link to convert the base 'xxxx' in the decimal base, but first i don't remember it, and secondly you don't need to know it.
Now if you're really interested about it you could still find a link.

In short, the 'xxxx' base is for human beings (we learn/use better accronyms than numbers)

EDIT : I've just remember where to find a nice tutorial related to integers in jass :
http://www.wc3c.net/showthread.php?t=99954
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
The link was just for introduce what sort of integer bases you have in jass, you don't need to understand anything more from it.

Also i've edited my code in this post, since i've realized that it could be simplified.
More, the previous version didn't worked if the trigger unit wasn't in the region.
Now it fully works without any ugly use of timer.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Thanks watermelon_1234 and Troll-Brain.

Using unit pools looks much simpler that the system I made myself :xxd:

Thanks for all the help!

Update:
I'm still having issues with setting globals.

JASS:
globals
    destructable Top_Gate = null
    destructable Bottom_Gate = null
    // Many more other globals being declared...
endglobals

library MapSetup initializer onInit

    private function onInit takes nothing returns nothing
        set Top_Gate = gg_dest_LTg1_0104
        set Bottom_Gate = gg_dest_LTg1_0099
        // Many more other variables being set...
    endfunction

endlibrary
All of the above code is in the map header. It gives me the error messages "Undeclared variable gg_dest_LTg1_0104" and "Undeclared variable gg_dest_LTg1_0099" when saving. These two gates are pre-placed in the map. What am I doing wrong?
 
Last edited by a moderator:
It is better to create the destructables directly in your "onInit" function. This saves duplicate global variables and cuts a lot of time out of opening the map in world editor because there is less stuff to load. Though this may be a problem generating the shadow map (I don't know if trigger-added destructables create shadows or get a shadow from another object) so maybe it's not such a good idea.
 
Status
Not open for further replies.
Top