1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] check what is wrong with these jass code please

Discussion in 'Triggers & Scripts' started by AnonymousPro, Sep 11, 2016.

  1. AnonymousPro

    AnonymousPro

    Joined:
    Nov 18, 2012
    Messages:
    311
    Resources:
    0
    Resources:
    0
    Hello, I am making a random portal function, which teleports my unit when entering the right portal which has boolean = true.
    Can anyone point out my mistake, it doesn't run in WE
    Code (Text):

    function RandomPortal takes nothing returns integer
    return GetRandomInt(1,4)
    endfunction
    function SetPortalNumber takes nothing returns nothing
    set AccessofPortal[RandomPortal()]=true
    set AccessofPortal[5]=false
    endfunction
    function RegionofPortal takes boolean b2b returns region
    if IsPointInRegion(gg_rct_Region_009,0,0)==b2b then
    return gg_rct_Region_009
    elseif IsPointInRegion(gg_rct_Region_010,0,0)==b2b then
    return gg_rct_Region_010
    elseif IsPointInRegion(gg_rct_Region_011,0,0)==b2b then
    return gg_rct_Region_011
    elseif IsPointInRegion(gg_rct_Region_012,0,0)==b2b then
    return gg_rct_Region_012
    endif
    return null
    endfunction
    function Trig_RandomGen_Actions takes nothing returns nothing
    local unit u=GetEnteringUnit()
    if IsUnitInRegion(RegionofPortal(AccessofPortal[RandomPortal()]),u)==true then
    call SetUnitPositionLoc(u,GetRectCenter(gg_rct_Region_13))
    endif
    set u=null      
    endfunction

    //===========================================================================
    function InitTrig_RandomGen1 takes nothing returns nothing
    call SetPortalNumber()
    set gg_trg_RandomGen1 = CreateTrigger(  )
    call TriggerRegisterEnterRegionSimple(gg_trg_RandomGen1,gg_rct_TrainingGround1)
        call TriggerAddAction( gg_trg_RandomGen1, function Trig_RandomGen_Actions )
    endfunction

     
     
    Last edited: Sep 11, 2016
  2. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Your trigger has no event. Only an action

    Code (vJASS):
    function InitTrig_RandomGen1 takes nothing returns nothing
    call SetPortalNumber()
    set gg_trg_RandomGen1 = CreateTrigger(  )
        call TriggerAddAction( gg_trg_RandomGen1, function Trig_RandomGen_Actions )
    endfunction
     
  3. AnonymousPro

    AnonymousPro

    Joined:
    Nov 18, 2012
    Messages:
    311
    Resources:
    0
    Resources:
    0
    @Pyrogasm true.. but that will not cause the map to be unable to host.. I think there's something else. Thanks~ I have fixed this part you mentioned!
     
  4. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Is that all of your code? Are you sure the map saves and can be launched with just this trigger disabled? The only thing I see is an errant
    endglobals
    at the top of your code:
    Code (vJASS):
    //globals within WE
    endglobals


    and

    Code (vJASS):
     returns region @r4r@ //can't do that should just be "returns region"
     
  5. AnonymousPro

    AnonymousPro

    Joined:
    Nov 18, 2012
    Messages:
    311
    Resources:
    0
    Resources:
    0
    yes it's just this part which causes the not able to launch.
    Oh yes the return part.. anddd i fixed this part too, it's still not launching
     
  6. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Can you please post your current code (everything in the trigger) again? Maybe I missed something.
     
  7. AnonymousPro

    AnonymousPro

    Joined:
    Nov 18, 2012
    Messages:
    311
    Resources:
    0
    Resources:
    0
    Code (Text):

    //===========================================================================
    //
    // RPG
    //
    //   Warcraft III map script
    //   Generated by the Warcraft III World Editor
    //   Date: Mon Sep 12 06:37:39 2016
    //   Map Author: AshleyColton
    //
    //===========================================================================

    //***************************************************************************
    //*
    //*  Global Variables
    //*
    //***************************************************************************

    globals
        // User-defined
        boolean                 udg_AmITheOnlyOnePlaying   = false
        timer                   udg_DungeonTimer           = null
        boolean array           udg_AccessofPortal

        // Generated
        rect                    gg_rct_RegionFirstArea     = null
        rect                    gg_rct_RegionMaskedStartPoint = null
        rect                    gg_rct_RegionStartCharacters = null
        rect                    gg_rct_SHOP_Spawn_Location = null
        rect                    gg_rct_TrainingGround1     = null
        rect                    gg_rct_TrainingGround1_Portal = null
        rect                    gg_rct_RegionStartMask     = null
        rect                    gg_rct_TrapToMap           = null
        rect                    gg_rct_TrapSpawnArea       = null
        rect                    gg_rct_Region_009          = null
        rect                    gg_rct_Region_010          = null
        rect                    gg_rct_Region_011          = null
        rect                    gg_rct_Region_012          = null
        rect                    gg_rct_Region_013          = null
        camerasetup             gg_cam_Camera_Startloc     = null
        sound                   gg_snd_Wintergatan         = null
        trigger                 gg_trg_RPG_Initialization  = null
        trigger                 gg_trg_Text_Tag            = null
        trigger                 gg_trg_Unit_Selection      = null
        trigger                 gg_trg_Anti_SP             = null
        trigger                 gg_trg_Enter_TG_2          = null
        trigger                 gg_trg_EnterTrainingGround1 = null
        trigger                 gg_trg_SpawnTrainingGround1 = null
        trigger                 gg_trg_Enter_Trap1         = null
        trigger                 gg_trg_SpawnMobAtTrap1     = null
        trigger                 gg_trg_LeaveTrainingGround1 = null
        trigger                 gg_trg_Trap_Enter_TrainingGround1 = null
        trigger                 gg_trg_SpawnMobAtTrap2     = null
        trigger                 gg_trg_SpawnMobAtTrap3     = null
        trigger                 gg_trg_RandomGen1          = null
        trigger                 gg_trg_Randomized_Portal_Loc = null
        trigger                 gg_trg_TeleportonPortal    = null
        trigger                 gg_trg_PlayerDies          = null
        trigger                 gg_trg_Tiles               = null
    endglobals

    function InitGlobals takes nothing returns nothing
        local integer i = 0
        set udg_AmITheOnlyOnePlaying = false
        set udg_DungeonTimer = CreateTimer()
        set i = 0
        loop
            exitwhen (i > 1)
            set udg_AccessofPortal[i] = false
            set i = i + 1
        endloop

    endfunction

    //***************************************************************************
    //*
    //*  Sounds
    //*
    //***************************************************************************

    function InitSounds takes nothing returns nothing
        set gg_snd_Wintergatan = CreateSound( "Wintergatan.mp3", true, false, false, 10, 10, "DefaultEAXON" )
        call SetSoundDuration( gg_snd_Wintergatan, 234344 )
        call SetSoundChannel( gg_snd_Wintergatan, 0 )
        call SetSoundVolume( gg_snd_Wintergatan, 127 )
        call SetSoundPitch( gg_snd_Wintergatan, 1.0 )
    endfunction

    //***************************************************************************
    //*
    //*  Unit Creation
    //*
    //***************************************************************************

    //===========================================================================
    function CreateBuildingsForPlayer10 takes nothing returns nothing
        local player p = Player(10)
        local unit u
        local integer unitID
        local trigger t
        local real life

        set u = CreateUnit( p, 'n004', -13829.5, 12960.7, 32.521 )
        set u = CreateUnit( p, 'n007', -13690.8, 12864.8, 81.521 )
        set u = CreateUnit( p, 'n003', -13836.1, 13189.9, 342.059 )
        set u = CreateUnit( p, 'n001', -13536.4, 13307.2, 258.110 )
        set u = CreateUnit( p, 'n005', -13709.0, 13307.2, 284.456 )
        set u = CreateUnit( p, 'n009', -13415.9, 13215.2, 148.056 )
        set u = CreateUnit( p, 'n008', -13405.9, 12997.4, 206.978 )
        set u = CreateUnit( p, 'n006', -13498.3, 12894.6, 117.645 )
    endfunction

    //===========================================================================
    function CreatePlayerBuildings takes nothing returns nothing
        call CreateBuildingsForPlayer10(  )
    endfunction

    //===========================================================================
    function CreatePlayerUnits takes nothing returns nothing
    endfunction

    //===========================================================================
    function CreateAllUnits takes nothing returns nothing
        call CreatePlayerBuildings(  )
        call CreatePlayerUnits(  )
    endfunction

    //***************************************************************************
    //*
    //*  Regions
    //*
    //***************************************************************************

    function CreateRegions takes nothing returns nothing
        local weathereffect we

        set gg_rct_RegionFirstArea = Rect( -15264.0, 9280.0, -10432.0, 13952.0 )
        set we = AddWeatherEffect( gg_rct_RegionFirstArea, 'MEds' )
        call EnableWeatherEffect( we, true )
        set gg_rct_RegionMaskedStartPoint = Rect( -16384.0, 9824.0, -9984.0, 16320.0 )
        set gg_rct_RegionStartCharacters = Rect( -14816.0, 11968.0, -12448.0, 14176.0 )
        set gg_rct_SHOP_Spawn_Location = Rect( -16096.0, 10656.0, -13600.0, 11840.0 )
        set gg_rct_TrainingGround1 = Rect( -12384.0, 10656.0, -11264.0, 11840.0 )
        set gg_rct_TrainingGround1_Portal = Rect( -14048.0, 10912.0, -13600.0, 11616.0 )
        set gg_rct_RegionStartMask = Rect( -13664.0, 13024.0, -13632.0, 13056.0 )
        set gg_rct_TrapToMap = Rect( -12896.0, 14336.0, -12800.0, 15200.0 )
        set gg_rct_TrapSpawnArea = Rect( -16000.0, 14240.0, -12896.0, 15328.0 )
        set gg_rct_Region_009 = Rect( -12064.0, 10656.0, -11680.0, 10720.0 )
        set gg_rct_Region_010 = Rect( -11328.0, 11072.0, -11264.0, 11488.0 )
        set gg_rct_Region_011 = Rect( -12032.0, 11776.0, -11648.0, 11840.0 )
        set gg_rct_Region_012 = Rect( -12384.0, 11072.0, -12320.0, 11488.0 )
        set gg_rct_Region_013 = Rect( -15808.0, 14752.0, -15776.0, 14784.0 )
    endfunction

    //***************************************************************************
    //*
    //*  Cameras
    //*
    //***************************************************************************

    function CreateCameras takes nothing returns nothing

        set gg_cam_Camera_Startloc = CreateCameraSetup(  )
        call CameraSetupSetField( gg_cam_Camera_Startloc, CAMERA_FIELD_ZOFFSET, 30.0, 0.0 )
        call CameraSetupSetField( gg_cam_Camera_Startloc, CAMERA_FIELD_ROTATION, 90.0, 0.0 )
        call CameraSetupSetField( gg_cam_Camera_Startloc, CAMERA_FIELD_ANGLE_OF_ATTACK, 0.0, 0.0 )
        call CameraSetupSetField( gg_cam_Camera_Startloc, CAMERA_FIELD_TARGET_DISTANCE, 931.4, 0.0 )
        call CameraSetupSetField( gg_cam_Camera_Startloc, CAMERA_FIELD_ROLL, 0.0, 0.0 )
        call CameraSetupSetField( gg_cam_Camera_Startloc, CAMERA_FIELD_FIELD_OF_VIEW, 70.0, 0.0 )
        call CameraSetupSetField( gg_cam_Camera_Startloc, CAMERA_FIELD_FARZ, 5000.0, 0.0 )
        call CameraSetupSetDestPosition( gg_cam_Camera_Startloc, -13453.8, 12717.3, 0.0 )

    endfunction

    //***************************************************************************
    //*
    //*  Triggers
    //*
    //***************************************************************************

    //===========================================================================
    // Trigger: RPG Initialization
    //
    // Enable vision in start point
    // play the music wintergatan
    // set the sky to universe model
    // set camera bount to start point
    // locks any selected unit to unit's perspective
    // text tag are beta
    // VARIABLES to set stages, if 1 go to area 1 from trap, if 2 go to area 2..
    //===========================================================================
    function Trig_RPG_Initialization_Actions takes nothing returns nothing
        call CreateLeaderboardBJ( GetPlayersAll(), "TRIGSTR_033" )
        call CreateFogModifierRectBJ( true, Player(0), FOG_OF_WAR_VISIBLE, gg_rct_RegionStartCharacters )
        call PlaySoundAtPointBJ( gg_snd_Wintergatan, 100, GetPlayerStartLocationLoc(Player(0)), 0 )
        call SetSkyModel( "MoonySky.mdx" )
        call SetCameraBoundsToRectForPlayerBJ( Player(0), gg_rct_RegionStartMask )
        call SetCameraTargetControllerNoZForPlayer( Player(0), GetTriggerUnit(), 0, 0, true )
        call SetTimeOfDay( 19.00 )
        call UseTimeOfDayBJ( false )
    endfunction

    //===========================================================================
    function InitTrig_RPG_Initialization takes nothing returns nothing
        set gg_trg_RPG_Initialization = CreateTrigger(  )
        call TriggerAddAction( gg_trg_RPG_Initialization, function Trig_RPG_Initialization_Actions )
    endfunction

    //===========================================================================
    // Trigger: Text Tag
    //===========================================================================
    function Trig_Text_Tag_Conditions takes nothing returns boolean
        if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == true ) ) then
            return false
        endif
        return true
    endfunction

    function Trig_Text_Tag_Actions takes nothing returns nothing
        call CreateTextTagUnitBJ( GetUnitName(GetFilterUnit()), GetFilterUnit(), 0, 24.00, 100, 100, 100, 60.00 )
        call CreateTextTagLocBJ( "TRIGSTR_035", Location(15200.00, 11540.00), 0, 10, 100, 100, 100, 0 )
        call ShowTextTagForceBJ( true, GetLastCreatedTextTag(), GetPlayersAll() )
    endfunction

    //===========================================================================
    function InitTrig_Text_Tag takes nothing returns nothing
        set gg_trg_Text_Tag = CreateTrigger(  )
        call TriggerRegisterTimerEventSingle( gg_trg_Text_Tag, 0.00 )
        call TriggerAddCondition( gg_trg_Text_Tag, Condition( function Trig_Text_Tag_Conditions ) )
        call TriggerAddAction( gg_trg_Text_Tag, function Trig_Text_Tag_Actions )
    endfunction

    //===========================================================================
    // Trigger: Unit Selection
    //
    // any player selects a unit, if target= true then add unit to player
    // conditions:
    // region start point has the selected unit
    // number of units in region owned by red = 0, cant have more than 1 characters
    // selected unit must be a structure(in actions)
    // actions:
    // creates the unit, at the new location
    // lock camera to last created unit
    //===========================================================================
    function Trig_Unit_Selection_Conditions takes nothing returns boolean
        if ( not ( CountUnitsInGroup(GetUnitsInRectOfPlayer(gg_rct_RegionFirstArea, Player(0))) == 0 ) ) then
            return false
        endif
        return true
    endfunction

    function Trig_Unit_Selection_Func002001 takes nothing returns boolean
        return ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) == true )
    endfunction

    function Trig_Unit_Selection_Actions takes nothing returns nothing
        if ( Trig_Unit_Selection_Func002001() ) then
            call CreateNUnitsAtLoc( 1, String2UnitIdBJ(UnitId2StringBJ(GetUnitTypeId(GetTriggerUnit()))), Player(0), Location(-15000.00, 11200.00), bj_UNIT_FACING )
        else
            call DoNothing(  )
        endif
        call SetCameraBoundsToRectForPlayerBJ( Player(0), gg_rct_SHOP_Spawn_Location )
        call SetCameraTargetControllerNoZForPlayer( Player(0), GetLastCreatedUnit(), 0, 0, false )
        call FogModifierStop( GetLastCreatedFogModifier() )
    endfunction

    //===========================================================================
    function InitTrig_Unit_Selection takes nothing returns nothing
        set gg_trg_Unit_Selection = CreateTrigger(  )
        call TriggerRegisterPlayerSelectionEventBJ( gg_trg_Unit_Selection, Player(0), true )
        call TriggerAddCondition( gg_trg_Unit_Selection, Condition( function Trig_Unit_Selection_Conditions ) )
        call TriggerAddAction( gg_trg_Unit_Selection, function Trig_Unit_Selection_Actions )
    endfunction

    //===========================================================================
    // Trigger: EnterTrainingGround1
    //
    // --working--
    // Unit enter TG1 portal
    // Move to TG1
    // Camerabound to TG1
    // Camera on unit from red
    // Start DungeonTimer Countdown to be expelled from dungeon
    //===========================================================================
    function Trig_EnterTrainingGround1_Actions takes nothing returns nothing
        call SetUnitPositionLoc( GetTriggerUnit(), GetRectCenter(gg_rct_TrainingGround1) )
        call SetCameraBoundsToRectForPlayerBJ( Player(0), gg_rct_TrainingGround1 )
        call SetCameraTargetControllerNoZForPlayer( Player(0), GroupPickRandomUnit(GetUnitsInRectOfPlayer(gg_rct_TrainingGround1, Player(0))), 0, 0, false )
        call StartTimerBJ( udg_DungeonTimer, false, 600.00 )
    endfunction

    //===========================================================================
    function InitTrig_EnterTrainingGround1 takes nothing returns nothing
        set gg_trg_EnterTrainingGround1 = CreateTrigger(  )
        call TriggerRegisterEnterRectSimple( gg_trg_EnterTrainingGround1, gg_rct_TrainingGround1_Portal )
        call TriggerAddAction( gg_trg_EnterTrainingGround1, function Trig_EnterTrainingGround1_Actions )
    endfunction

    //===========================================================================
    // Trigger: SpawnTrainingGround1
    //
    // works
    //===========================================================================

    function Trig_SpawnTrainingGround1_Conditions takes nothing returns boolean
        if ( not ( CountUnitsInGroup(GetUnitsInRectAll(gg_rct_TrainingGround1)) <= 15 ) ) then
            return false
        endif
        if (not (CountUnitsInGroup(GetUnitsInRectAll(gg_rct_TrainingGround1)) > 0)) then
        return false
        endif
        return true
    endfunction


    function Trig_SpawnTrainingGround1_Actions takes nothing returns nothing
            call TriggerRegisterTimerEventPeriodic( GetTriggeringTrigger(), 5.00 )
        call CreateNUnitsAtLoc( 1, 'hfoo', Player(11), GetRandomLocInRect(gg_rct_TrainingGround1), bj_UNIT_FACING )
    endfunction
    function InitTrig_SpawnTrainingGround1 takes nothing returns nothing
        set gg_trg_SpawnTrainingGround1 = CreateTrigger(  )
        call TriggerRegisterEnterRectSimple( gg_trg_SpawnTrainingGround1, gg_rct_TrainingGround1 )
        call TriggerAddCondition( gg_trg_SpawnTrainingGround1, Condition( function Trig_SpawnTrainingGround1_Conditions ) )
        call TriggerAddAction( gg_trg_SpawnTrainingGround1, function Trig_SpawnTrainingGround1_Actions )
    endfunction
    //===========================================================================
    // Trigger: SpawnMobAtTrap1
    //
    // need condition unit is hero, to prevent mob units entering next map
    //===========================================================================
    function Trig_SpawnMobAtTrap1_Conditions takes nothing returns boolean
        if ( not ( RectContainsUnit(gg_rct_TrapSpawnArea, GetEnteringUnit()) == true ) ) then
            return false
        endif
        return true
    endfunction

    function Trig_SpawnMobAtTrap1_Actions takes nothing returns nothing
        call CreateNUnitsAtLoc( 1, 'hfoo', Player(11), GetRandomLocInRect(gg_rct_TrapSpawnArea), bj_UNIT_FACING )
    endfunction

    //===========================================================================
    function InitTrig_SpawnMobAtTrap1 takes nothing returns nothing
        set gg_trg_SpawnMobAtTrap1 = CreateTrigger(  )
        call TriggerRegisterTimerEventPeriodic( gg_trg_SpawnMobAtTrap1, 0.50 )
        call TriggerAddCondition( gg_trg_SpawnMobAtTrap1, Condition( function Trig_SpawnMobAtTrap1_Conditions ) )
        call TriggerAddAction( gg_trg_SpawnMobAtTrap1, function Trig_SpawnMobAtTrap1_Actions )
    endfunction

    //===========================================================================
    // Trigger: LeaveTrainingGround1
    //
    // if leave region, destroy the timer
    // destroy units
    //===========================================================================
    function Trig_LeaveTrainingGround1_Actions takes nothing returns nothing
        call DisableTrigger( gg_trg_SpawnMobAtTrap1 )
    endfunction

    //===========================================================================
    function InitTrig_LeaveTrainingGround1 takes nothing returns nothing
        set gg_trg_LeaveTrainingGround1 = CreateTrigger(  )
        call TriggerRegisterLeaveRectSimple( gg_trg_LeaveTrainingGround1, gg_rct_TrainingGround1 )
        call TriggerAddAction( gg_trg_LeaveTrainingGround1, function Trig_LeaveTrainingGround1_Actions )
    endfunction

    //===========================================================================
    // Trigger: Trap Enter TrainingGround1
    //
    // //working
    //===========================================================================
    function Trig_Trap_Enter_TrainingGround1_Actions takes nothing returns nothing
        call SetUnitPositionLoc( GetTriggerUnit(), GetRectCenter(gg_rct_TrainingGround1) )
    endfunction

    //===========================================================================
    function InitTrig_Trap_Enter_TrainingGround1 takes nothing returns nothing
        set gg_trg_Trap_Enter_TrainingGround1 = CreateTrigger(  )
        call TriggerRegisterEnterRectSimple( gg_trg_Trap_Enter_TrainingGround1, gg_rct_TrapToMap )
        call TriggerAddAction( gg_trg_Trap_Enter_TrainingGround1, function Trig_Trap_Enter_TrainingGround1_Actions )
    endfunction

    //===========================================================================
    // Trigger: PlayerDies
    //
    // if player dies kick player
    //===========================================================================
    function Trig_PlayerDies_Actions takes nothing returns nothing
    endfunction

    //===========================================================================
    function InitTrig_PlayerDies takes nothing returns nothing
        set gg_trg_PlayerDies = CreateTrigger(  )
        call TriggerAddAction( gg_trg_PlayerDies, function Trig_PlayerDies_Actions )
    endfunction

    //===========================================================================
    // Trigger: Tiles
    //===========================================================================
    function Trig_Tiles_Actions takes nothing returns nothing
        call SetTerrainTypeBJ( GetRectCenter(GetPlayableMapRect()), 'Ldrt', -1, 5, 0 )
    endfunction

    //===========================================================================
    function InitTrig_Tiles takes nothing returns nothing
        set gg_trg_Tiles = CreateTrigger(  )
        call TriggerAddAction( gg_trg_Tiles, function Trig_Tiles_Actions )
    endfunction

    //===========================================================================
    function InitCustomTriggers takes nothing returns nothing
        call InitTrig_RPG_Initialization(  )
        call InitTrig_Text_Tag(  )
        call InitTrig_Unit_Selection(  )
        call InitTrig_EnterTrainingGround1(  )
        call InitTrig_SpawnTrainingGround1(  )
        call InitTrig_SpawnMobAtTrap1(  )
        call InitTrig_LeaveTrainingGround1(  )
        call InitTrig_Trap_Enter_TrainingGround1(  )
        call InitTrig_PlayerDies(  )
        call InitTrig_Tiles(  )
    endfunction

    //===========================================================================
    function RunInitializationTriggers takes nothing returns nothing
        call ConditionalTriggerExecute( gg_trg_RPG_Initialization )
        call ConditionalTriggerExecute( gg_trg_Tiles )
    endfunction

    //***************************************************************************
    //*
    //*  Players
    //*
    //***************************************************************************

    function InitCustomPlayerSlots takes nothing returns nothing

        // Player 0
        call SetPlayerStartLocation( Player(0), 0 )
        call ForcePlayerStartLocation( Player(0), 0 )
        call SetPlayerColor( Player(0), ConvertPlayerColor(0) )
        call SetPlayerRacePreference( Player(0), RACE_PREF_HUMAN )
        call SetPlayerRaceSelectable( Player(0), false )
        call SetPlayerController( Player(0), MAP_CONTROL_USER )

        // Player 1
        call SetPlayerStartLocation( Player(1), 1 )
        call ForcePlayerStartLocation( Player(1), 1 )
        call SetPlayerColor( Player(1), ConvertPlayerColor(1) )
        call SetPlayerRacePreference( Player(1), RACE_PREF_HUMAN )
        call SetPlayerRaceSelectable( Player(1), false )
        call SetPlayerController( Player(1), MAP_CONTROL_USER )

        // Player 2
        call SetPlayerStartLocation( Player(2), 2 )
        call ForcePlayerStartLocation( Player(2), 2 )
        call SetPlayerColor( Player(2), ConvertPlayerColor(2) )
        call SetPlayerRacePreference( Player(2), RACE_PREF_HUMAN )
        call SetPlayerRaceSelectable( Player(2), false )
        call SetPlayerController( Player(2), MAP_CONTROL_USER )

        // Player 3
        call SetPlayerStartLocation( Player(3), 3 )
        call ForcePlayerStartLocation( Player(3), 3 )
        call SetPlayerColor( Player(3), ConvertPlayerColor(3) )
        call SetPlayerRacePreference( Player(3), RACE_PREF_HUMAN )
        call SetPlayerRaceSelectable( Player(3), false )
        call SetPlayerController( Player(3), MAP_CONTROL_USER )

        // Player 4
        call SetPlayerStartLocation( Player(4), 4 )
        call ForcePlayerStartLocation( Player(4), 4 )
        call SetPlayerColor( Player(4), ConvertPlayerColor(4) )
        call SetPlayerRacePreference( Player(4), RACE_PREF_HUMAN )
        call SetPlayerRaceSelectable( Player(4), false )
        call SetPlayerController( Player(4), MAP_CONTROL_USER )

        // Player 5
        call SetPlayerStartLocation( Player(5), 5 )
        call ForcePlayerStartLocation( Player(5), 5 )
        call SetPlayerColor( Player(5), ConvertPlayerColor(5) )
        call SetPlayerRacePreference( Player(5), RACE_PREF_HUMAN )
        call SetPlayerRaceSelectable( Player(5), false )
        call SetPlayerController( Player(5), MAP_CONTROL_USER )

        // Player 6
        call SetPlayerStartLocation( Player(6), 6 )
        call ForcePlayerStartLocation( Player(6), 6 )
        call SetPlayerColor( Player(6), ConvertPlayerColor(6) )
        call SetPlayerRacePreference( Player(6), RACE_PREF_HUMAN )
        call SetPlayerRaceSelectable( Player(6), false )
        call SetPlayerController( Player(6), MAP_CONTROL_USER )

        // Player 7
        call SetPlayerStartLocation( Player(7), 7 )
        call ForcePlayerStartLocation( Player(7), 7 )
        call SetPlayerColor( Player(7), ConvertPlayerColor(7) )
        call SetPlayerRacePreference( Player(7), RACE_PREF_HUMAN )
        call SetPlayerRaceSelectable( Player(7), false )
        call SetPlayerController( Player(7), MAP_CONTROL_USER )

        // Player 8
        call SetPlayerStartLocation( Player(8), 8 )
        call ForcePlayerStartLocation( Player(8), 8 )
        call SetPlayerColor( Player(8), ConvertPlayerColor(8) )
        call SetPlayerRacePreference( Player(8), RACE_PREF_HUMAN )
        call SetPlayerRaceSelectable( Player(8), false )
        call SetPlayerController( Player(8), MAP_CONTROL_USER )

        // Player 9
        call SetPlayerStartLocation( Player(9), 9 )
        call ForcePlayerStartLocation( Player(9), 9 )
        call SetPlayerColor( Player(9), ConvertPlayerColor(9) )
        call SetPlayerRacePreference( Player(9), RACE_PREF_HUMAN )
        call SetPlayerRaceSelectable( Player(9), false )
        call SetPlayerController( Player(9), MAP_CONTROL_USER )

        // Player 10
        call SetPlayerStartLocation( Player(10), 10 )
        call ForcePlayerStartLocation( Player(10), 10 )
        call SetPlayerColor( Player(10), ConvertPlayerColor(10) )
        call SetPlayerRacePreference( Player(10), RACE_PREF_HUMAN )
        call SetPlayerRaceSelectable( Player(10), false )
        call SetPlayerController( Player(10), MAP_CONTROL_NEUTRAL )

        // Player 11
        call SetPlayerStartLocation( Player(11), 11 )
        call ForcePlayerStartLocation( Player(11), 11 )
        call SetPlayerColor( Player(11), ConvertPlayerColor(11) )
        call SetPlayerRacePreference( Player(11), RACE_PREF_NIGHTELF )
        call SetPlayerRaceSelectable( Player(11), false )
        call SetPlayerController( Player(11), MAP_CONTROL_COMPUTER )

    endfunction

    function InitCustomTeams takes nothing returns nothing
        // Force: TRIGSTR_016
        call SetPlayerTeam( Player(0), 0 )
        call SetPlayerTeam( Player(1), 0 )
        call SetPlayerTeam( Player(2), 0 )
        call SetPlayerTeam( Player(3), 0 )
        call SetPlayerTeam( Player(4), 0 )
        call SetPlayerTeam( Player(5), 0 )
        call SetPlayerTeam( Player(6), 0 )
        call SetPlayerTeam( Player(7), 0 )
        call SetPlayerTeam( Player(8), 0 )
        call SetPlayerTeam( Player(9), 0 )

        //   Allied
        call SetPlayerAllianceStateAllyBJ( Player(0), Player(1), true )
        call SetPlayerAllianceStateAllyBJ( Player(0), Player(2), true )
        call SetPlayerAllianceStateAllyBJ( Player(0), Player(3), true )
        call SetPlayerAllianceStateAllyBJ( Player(0), Player(4), true )
        call SetPlayerAllianceStateAllyBJ( Player(0), Player(5), true )
        call SetPlayerAllianceStateAllyBJ( Player(0), Player(6), true )
        call SetPlayerAllianceStateAllyBJ( Player(0), Player(7), true )
        call SetPlayerAllianceStateAllyBJ( Player(0), Player(8), true )
        call SetPlayerAllianceStateAllyBJ( Player(0), Player(9), true )
        call SetPlayerAllianceStateAllyBJ( Player(1), Player(0), true )
        call SetPlayerAllianceStateAllyBJ( Player(1), Player(2), true )
        call SetPlayerAllianceStateAllyBJ( Player(1), Player(3), true )
        call SetPlayerAllianceStateAllyBJ( Player(1), Player(4), true )
        call SetPlayerAllianceStateAllyBJ( Player(1), Player(5), true )
        call SetPlayerAllianceStateAllyBJ( Player(1), Player(6), true )
        call SetPlayerAllianceStateAllyBJ( Player(1), Player(7), true )
        call SetPlayerAllianceStateAllyBJ( Player(1), Player(8), true )
        call SetPlayerAllianceStateAllyBJ( Player(1), Player(9), true )
        call SetPlayerAllianceStateAllyBJ( Player(2), Player(0), true )
        call SetPlayerAllianceStateAllyBJ( Player(2), Player(1), true )
        call SetPlayerAllianceStateAllyBJ( Player(2), Player(3), true )
        call SetPlayerAllianceStateAllyBJ( Player(2), Player(4), true )
        call SetPlayerAllianceStateAllyBJ( Player(2), Player(5), true )
        call SetPlayerAllianceStateAllyBJ( Player(2), Player(6), true )
        call SetPlayerAllianceStateAllyBJ( Player(2), Player(7), true )
        call SetPlayerAllianceStateAllyBJ( Player(2), Player(8), true )
        call SetPlayerAllianceStateAllyBJ( Player(2), Player(9), true )
        call SetPlayerAllianceStateAllyBJ( Player(3), Player(0), true )
        call SetPlayerAllianceStateAllyBJ( Player(3), Player(1), true )
        call SetPlayerAllianceStateAllyBJ( Player(3), Player(2), true )
        call SetPlayerAllianceStateAllyBJ( Player(3), Player(4), true )
        call SetPlayerAllianceStateAllyBJ( Player(3), Player(5), true )
        call SetPlayerAllianceStateAllyBJ( Player(3), Player(6), true )
        call SetPlayerAllianceStateAllyBJ( Player(3), Player(7), true )
        call SetPlayerAllianceStateAllyBJ( Player(3), Player(8), true )
        call SetPlayerAllianceStateAllyBJ( Player(3), Player(9), true )
        call SetPlayerAllianceStateAllyBJ( Player(4), Player(0), true )
        call SetPlayerAllianceStateAllyBJ( Player(4), Player(1), true )
        call SetPlayerAllianceStateAllyBJ( Player(4), Player(2), true )
        call SetPlayerAllianceStateAllyBJ( Player(4), Player(3), true )
        call SetPlayerAllianceStateAllyBJ( Player(4), Player(5), true )
        call SetPlayerAllianceStateAllyBJ( Player(4), Player(6), true )
        call SetPlayerAllianceStateAllyBJ( Player(4), Player(7), true )
        call SetPlayerAllianceStateAllyBJ( Player(4), Player(8), true )
        call SetPlayerAllianceStateAllyBJ( Player(4), Player(9), true )
        call SetPlayerAllianceStateAllyBJ( Player(5), Player(0), true )
        call SetPlayerAllianceStateAllyBJ( Player(5), Player(1), true )
        call SetPlayerAllianceStateAllyBJ( Player(5), Player(2), true )
        call SetPlayerAllianceStateAllyBJ( Player(5), Player(3), true )
        call SetPlayerAllianceStateAllyBJ( Player(5), Player(4), true )
        call SetPlayerAllianceStateAllyBJ( Player(5), Player(6), true )
        call SetPlayerAllianceStateAllyBJ( Player(5), Player(7), true )
        call SetPlayerAllianceStateAllyBJ( Player(5), Player(8), true )
        call SetPlayerAllianceStateAllyBJ( Player(5), Player(9), true )
        call SetPlayerAllianceStateAllyBJ( Player(6), Player(0), true )
        call SetPlayerAllianceStateAllyBJ( Player(6), Player(1), true )
        call SetPlayerAllianceStateAllyBJ( Player(6), Player(2), true )
        call SetPlayerAllianceStateAllyBJ( Player(6), Player(3), true )
        call SetPlayerAllianceStateAllyBJ( Player(6), Player(4), true )
        call SetPlayerAllianceStateAllyBJ( Player(6), Player(5), true )
        call SetPlayerAllianceStateAllyBJ( Player(6), Player(7), true )
        call SetPlayerAllianceStateAllyBJ( Player(6), Player(8), true )
        call SetPlayerAllianceStateAllyBJ( Player(6), Player(9), true )
        call SetPlayerAllianceStateAllyBJ( Player(7), Player(0), true )
        call SetPlayerAllianceStateAllyBJ( Player(7), Player(1), true )
        call SetPlayerAllianceStateAllyBJ( Player(7), Player(2), true )
        call SetPlayerAllianceStateAllyBJ( Player(7), Player(3), true )
        call SetPlayerAllianceStateAllyBJ( Player(7), Player(4), true )
        call SetPlayerAllianceStateAllyBJ( Player(7), Player(5), true )
        call SetPlayerAllianceStateAllyBJ( Player(7), Player(6), true )
        call SetPlayerAllianceStateAllyBJ( Player(7), Player(8), true )
        call SetPlayerAllianceStateAllyBJ( Player(7), Player(9), true )
        call SetPlayerAllianceStateAllyBJ( Player(8), Player(0), true )
        call SetPlayerAllianceStateAllyBJ( Player(8), Player(1), true )
        call SetPlayerAllianceStateAllyBJ( Player(8), Player(2), true )
        call SetPlayerAllianceStateAllyBJ( Player(8), Player(3), true )
        call SetPlayerAllianceStateAllyBJ( Player(8), Player(4), true )
        call SetPlayerAllianceStateAllyBJ( Player(8), Player(5), true )
        call SetPlayerAllianceStateAllyBJ( Player(8), Player(6), true )
        call SetPlayerAllianceStateAllyBJ( Player(8), Player(7), true )
        call SetPlayerAllianceStateAllyBJ( Player(8), Player(9), true )
        call SetPlayerAllianceStateAllyBJ( Player(9), Player(0), true )
        call SetPlayerAllianceStateAllyBJ( Player(9), Player(1), true )
        call SetPlayerAllianceStateAllyBJ( Player(9), Player(2), true )
        call SetPlayerAllianceStateAllyBJ( Player(9), Player(3), true )
        call SetPlayerAllianceStateAllyBJ( Player(9), Player(4), true )
        call SetPlayerAllianceStateAllyBJ( Player(9), Player(5), true )
        call SetPlayerAllianceStateAllyBJ( Player(9), Player(6), true )
        call SetPlayerAllianceStateAllyBJ( Player(9), Player(7), true )
        call SetPlayerAllianceStateAllyBJ( Player(9), Player(8), true )

        //   Shared Vision
        call SetPlayerAllianceStateVisionBJ( Player(0), Player(1), true )
        call SetPlayerAllianceStateVisionBJ( Player(0), Player(2), true )
        call SetPlayerAllianceStateVisionBJ( Player(0), Player(3), true )
        call SetPlayerAllianceStateVisionBJ( Player(0), Player(4), true )
        call SetPlayerAllianceStateVisionBJ( Player(0), Player(5), true )
        call SetPlayerAllianceStateVisionBJ( Player(0), Player(6), true )
        call SetPlayerAllianceStateVisionBJ( Player(0), Player(7), true )
        call SetPlayerAllianceStateVisionBJ( Player(0), Player(8), true )
        call SetPlayerAllianceStateVisionBJ( Player(0), Player(9), true )
        call SetPlayerAllianceStateVisionBJ( Player(1), Player(0), true )
        call SetPlayerAllianceStateVisionBJ( Player(1), Player(2), true )
        call SetPlayerAllianceStateVisionBJ( Player(1), Player(3), true )
        call SetPlayerAllianceStateVisionBJ( Player(1), Player(4), true )
        call SetPlayerAllianceStateVisionBJ( Player(1), Player(5), true )
        call SetPlayerAllianceStateVisionBJ( Player(1), Player(6), true )
        call SetPlayerAllianceStateVisionBJ( Player(1), Player(7), true )
        call SetPlayerAllianceStateVisionBJ( Player(1), Player(8), true )
        call SetPlayerAllianceStateVisionBJ( Player(1), Player(9), true )
        call SetPlayerAllianceStateVisionBJ( Player(2), Player(0), true )
        call SetPlayerAllianceStateVisionBJ( Player(2), Player(1), true )
        call SetPlayerAllianceStateVisionBJ( Player(2), Player(3), true )
        call SetPlayerAllianceStateVisionBJ( Player(2), Player(4), true )
        call SetPlayerAllianceStateVisionBJ( Player(2), Player(5), true )
        call SetPlayerAllianceStateVisionBJ( Player(2), Player(6), true )
        call SetPlayerAllianceStateVisionBJ( Player(2), Player(7), true )
        call SetPlayerAllianceStateVisionBJ( Player(2), Player(8), true )
        call SetPlayerAllianceStateVisionBJ( Player(2), Player(9), true )
        call SetPlayerAllianceStateVisionBJ( Player(3), Player(0), true )
        call SetPlayerAllianceStateVisionBJ( Player(3), Player(1), true )
        call SetPlayerAllianceStateVisionBJ( Player(3), Player(2), true )
        call SetPlayerAllianceStateVisionBJ( Player(3), Player(4), true )
        call SetPlayerAllianceStateVisionBJ( Player(3), Player(5), true )
        call SetPlayerAllianceStateVisionBJ( Player(3), Player(6), true )
        call SetPlayerAllianceStateVisionBJ( Player(3), Player(7), true )
        call SetPlayerAllianceStateVisionBJ( Player(3), Player(8), true )
        call SetPlayerAllianceStateVisionBJ( Player(3), Player(9), true )
        call SetPlayerAllianceStateVisionBJ( Player(4), Player(0), true )
        call SetPlayerAllianceStateVisionBJ( Player(4), Player(1), true )
        call SetPlayerAllianceStateVisionBJ( Player(4), Player(2), true )
        call SetPlayerAllianceStateVisionBJ( Player(4), Player(3), true )
        call SetPlayerAllianceStateVisionBJ( Player(4), Player(5), true )
        call SetPlayerAllianceStateVisionBJ( Player(4), Player(6), true )
        call SetPlayerAllianceStateVisionBJ( Player(4), Player(7), true )
        call SetPlayerAllianceStateVisionBJ( Player(4), Player(8), true )
        call SetPlayerAllianceStateVisionBJ( Player(4), Player(9), true )
        call SetPlayerAllianceStateVisionBJ( Player(5), Player(0), true )
        call SetPlayerAllianceStateVisionBJ( Player(5), Player(1), true )
        call SetPlayerAllianceStateVisionBJ( Player(5), Player(2), true )
        call SetPlayerAllianceStateVisionBJ( Player(5), Player(3), true )
        call SetPlayerAllianceStateVisionBJ( Player(5), Player(4), true )
        call SetPlayerAllianceStateVisionBJ( Player(5), Player(6), true )
        call SetPlayerAllianceStateVisionBJ( Player(5), Player(7), true )
        call SetPlayerAllianceStateVisionBJ( Player(5), Player(8), true )
        call SetPlayerAllianceStateVisionBJ( Player(5), Player(9), true )
        call SetPlayerAllianceStateVisionBJ( Player(6), Player(0), true )
        call SetPlayerAllianceStateVisionBJ( Player(6), Player(1), true )
        call SetPlayerAllianceStateVisionBJ( Player(6), Player(2), true )
        call SetPlayerAllianceStateVisionBJ( Player(6), Player(3), true )
        call SetPlayerAllianceStateVisionBJ( Player(6), Player(4), true )
        call SetPlayerAllianceStateVisionBJ( Player(6), Player(5), true )
        call SetPlayerAllianceStateVisionBJ( Player(6), Player(7), true )
        call SetPlayerAllianceStateVisionBJ( Player(6), Player(8), true )
        call SetPlayerAllianceStateVisionBJ( Player(6), Player(9), true )
        call SetPlayerAllianceStateVisionBJ( Player(7), Player(0), true )
        call SetPlayerAllianceStateVisionBJ( Player(7), Player(1), true )
        call SetPlayerAllianceStateVisionBJ( Player(7), Player(2), true )
        call SetPlayerAllianceStateVisionBJ( Player(7), Player(3), true )
        call SetPlayerAllianceStateVisionBJ( Player(7), Player(4), true )
        call SetPlayerAllianceStateVisionBJ( Player(7), Player(5), true )
        call SetPlayerAllianceStateVisionBJ( Player(7), Player(6), true )
        call SetPlayerAllianceStateVisionBJ( Player(7), Player(8), true )
        call SetPlayerAllianceStateVisionBJ( Player(7), Player(9), true )
        call SetPlayerAllianceStateVisionBJ( Player(8), Player(0), true )
        call SetPlayerAllianceStateVisionBJ( Player(8), Player(1), true )
        call SetPlayerAllianceStateVisionBJ( Player(8), Player(2), true )
        call SetPlayerAllianceStateVisionBJ( Player(8), Player(3), true )
        call SetPlayerAllianceStateVisionBJ( Player(8), Player(4), true )
        call SetPlayerAllianceStateVisionBJ( Player(8), Player(5), true )
        call SetPlayerAllianceStateVisionBJ( Player(8), Player(6), true )
        call SetPlayerAllianceStateVisionBJ( Player(8), Player(7), true )
        call SetPlayerAllianceStateVisionBJ( Player(8), Player(9), true )
        call SetPlayerAllianceStateVisionBJ( Player(9), Player(0), true )
        call SetPlayerAllianceStateVisionBJ( Player(9), Player(1), true )
        call SetPlayerAllianceStateVisionBJ( Player(9), Player(2), true )
        call SetPlayerAllianceStateVisionBJ( Player(9), Player(3), true )
        call SetPlayerAllianceStateVisionBJ( Player(9), Player(4), true )
        call SetPlayerAllianceStateVisionBJ( Player(9), Player(5), true )
        call SetPlayerAllianceStateVisionBJ( Player(9), Player(6), true )
        call SetPlayerAllianceStateVisionBJ( Player(9), Player(7), true )
        call SetPlayerAllianceStateVisionBJ( Player(9), Player(8), true )

        // Force: TRIGSTR_019
        call SetPlayerTeam( Player(11), 1 )

        // Force: TRIGSTR_023
        call SetPlayerTeam( Player(10), 2 )

    endfunction

    function InitAllyPriorities takes nothing returns nothing

        call SetStartLocPrioCount( 0, 9 )
        call SetStartLocPrio( 0, 0, 1, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 0, 1, 2, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 0, 2, 3, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 0, 3, 4, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 0, 4, 5, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 0, 5, 6, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 0, 6, 7, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 0, 7, 8, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 0, 8, 9, MAP_LOC_PRIO_HIGH )

        call SetStartLocPrioCount( 1, 9 )
        call SetStartLocPrio( 1, 0, 0, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 1, 1, 2, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 1, 2, 3, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 1, 3, 4, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 1, 4, 5, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 1, 5, 6, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 1, 6, 7, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 1, 7, 8, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 1, 8, 9, MAP_LOC_PRIO_HIGH )

        call SetStartLocPrioCount( 2, 9 )
        call SetStartLocPrio( 2, 0, 0, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 2, 1, 1, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 2, 2, 3, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 2, 3, 4, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 2, 4, 5, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 2, 5, 6, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 2, 6, 7, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 2, 7, 8, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 2, 8, 9, MAP_LOC_PRIO_HIGH )

        call SetStartLocPrioCount( 3, 9 )
        call SetStartLocPrio( 3, 0, 0, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 3, 1, 1, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 3, 2, 2, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 3, 3, 4, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 3, 4, 5, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 3, 5, 6, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 3, 6, 7, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 3, 7, 8, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 3, 8, 9, MAP_LOC_PRIO_HIGH )

        call SetStartLocPrioCount( 4, 9 )
        call SetStartLocPrio( 4, 0, 0, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 4, 1, 1, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 4, 2, 2, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 4, 3, 3, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 4, 4, 5, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 4, 5, 6, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 4, 6, 7, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 4, 7, 8, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 4, 8, 9, MAP_LOC_PRIO_HIGH )

        call SetStartLocPrioCount( 5, 9 )
        call SetStartLocPrio( 5, 0, 0, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 5, 1, 1, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 5, 2, 2, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 5, 3, 3, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 5, 4, 4, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 5, 5, 6, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 5, 6, 7, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 5, 7, 8, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 5, 8, 9, MAP_LOC_PRIO_HIGH )

        call SetStartLocPrioCount( 6, 9 )
        call SetStartLocPrio( 6, 0, 0, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 6, 1, 1, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 6, 2, 2, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 6, 3, 3, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 6, 4, 4, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 6, 5, 5, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 6, 6, 7, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 6, 7, 8, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 6, 8, 9, MAP_LOC_PRIO_HIGH )

        call SetStartLocPrioCount( 7, 9 )
        call SetStartLocPrio( 7, 0, 0, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 7, 1, 1, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 7, 2, 2, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 7, 3, 3, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 7, 4, 4, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 7, 5, 5, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 7, 6, 6, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 7, 7, 8, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 7, 8, 9, MAP_LOC_PRIO_HIGH )

        call SetStartLocPrioCount( 8, 9 )
        call SetStartLocPrio( 8, 0, 0, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 8, 1, 1, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 8, 2, 2, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 8, 3, 3, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 8, 4, 4, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 8, 5, 5, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 8, 6, 6, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 8, 7, 7, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 8, 8, 9, MAP_LOC_PRIO_HIGH )

        call SetStartLocPrioCount( 9, 9 )
        call SetStartLocPrio( 9, 0, 0, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 9, 1, 1, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 9, 2, 2, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 9, 3, 3, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 9, 4, 4, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 9, 5, 5, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 9, 6, 6, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 9, 7, 7, MAP_LOC_PRIO_HIGH )
        call SetStartLocPrio( 9, 8, 8, MAP_LOC_PRIO_HIGH )
    endfunction

    //***************************************************************************
    //*
    //*  Main Initialization
    //*
    //***************************************************************************

    //===========================================================================
    function main takes nothing returns nothing
        call SetCameraBounds( -16128.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), -15872.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 16000.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 15360.0 - GetCameraMargin(CAMERA_MARGIN_TOP), -16128.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 15360.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 16000.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), -15872.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) )
        call SetDayNightModels( "Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl" )
        call NewSoundEnvironment( "Default" )
        call SetAmbientDaySound( "NorthrendDay" )
        call SetAmbientNightSound( "NorthrendNight" )
        call SetMapMusic( "Music", true, 0 )
        call InitSounds(  )
        call CreateRegions(  )
        call CreateCameras(  )
        call CreateAllUnits(  )
        call InitBlizzard(  )
        call InitGlobals(  )
        call InitCustomTriggers(  )
        call RunInitializationTriggers(  )

    endfunction

    //***************************************************************************
    //*
    //*  Map Configuration
    //*
    //***************************************************************************

    function config takes nothing returns nothing
        call SetMapName( "TRIGSTR_003" )
        call SetMapDescription( "TRIGSTR_005" )
        call SetPlayers( 12 )
        call SetTeams( 12 )
        call SetGamePlacement( MAP_PLACEMENT_TEAMS_TOGETHER )

        call DefineStartLocation( 0, -13632.0, 12992.0 )
        call DefineStartLocation( 1, -13632.0, 12992.0 )
        call DefineStartLocation( 2, -13632.0, 12992.0 )
        call DefineStartLocation( 3, -13632.0, 12992.0 )
        call DefineStartLocation( 4, -13632.0, 12992.0 )
        call DefineStartLocation( 5, -13632.0, 12992.0 )
        call DefineStartLocation( 6, -13632.0, 12992.0 )
        call DefineStartLocation( 7, -13632.0, 12992.0 )
        call DefineStartLocation( 8, -13632.0, 12992.0 )
        call DefineStartLocation( 9, -13632.0, 12992.0 )
        call DefineStartLocation( 10, 1280.0, -6400.0 )
        call DefineStartLocation( 11, 12416.0, -3776.0 )

        // Player setup
        call InitCustomPlayerSlots(  )
        call InitCustomTeams(  )
        call InitAllyPriorities(  )
    endfunction
     
    PS: i have no idea how to post in vjass code
     
  8. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    No not the war3map.j I just mean whatever is in your RandomGen trigger. The current version of what you posted in your first post. Also you should use [jass] tags instead of [code] tags.
     
  9. AnonymousPro

    AnonymousPro

    Joined:
    Nov 18, 2012
    Messages:
    311
    Resources:
    0
    Resources:
    0
    Code (vJASS):

    function RandomPortal takes nothing returns integer
    return GetRandomInt(1,4)
    endfunction
    function SetPortalNumber takes nothing returns nothing
    set AccessofPortal[RandomPortal()]=true
    set AccessofPortal[5]=false
    endfunction
    function RegionofPortal takes boolean b2b returns region
    if IsPointInRegion(gg_rct_Region_009,0,0)==b2b then
    return gg_rct_Region_009
    elseif IsPointInRegion(gg_rct_Region_010,0,0)==b2b then
    return gg_rct_Region_010
    elseif IsPointInRegion(gg_rct_Region_011,0,0)==b2b then
    return gg_rct_Region_011
    elseif IsPointInRegion(gg_rct_Region_012,0,0)==b2b then
    return gg_rct_Region_012
    endif
    return null
    endfunction
    function Trig_RandomGen_Actions takes nothing returns nothing
    local unit u=GetEnteringUnit()
    if IsUnitInRegion(RegionofPortal(AccessofPortal[RandomPortal()]),u)==true then
    call SetUnitPositionLoc(u,GetRectCenter(gg_rct_Region_13))
    endif
    set u=null      
    endfunction

    //===========================================================================
    function InitTrig_RandomGen1 takes nothing returns nothing
    call SetPortalNumber()
    set gg_trg_RandomGen1 = CreateTrigger(  )
    call TriggerRegisterEnterRegionSimple(gg_trg_RandomGen1,gg_rct_TrainingGround1)
        call TriggerAddAction( gg_trg_RandomGen1, function Trig_RandomGen_Actions )
    endfunction
     
     
  10. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    The 0s in
    IsPointInRegion(gg_rct_Region_009,0,0)
    and related calls should be 0.00s because the native expects real inputs. Granted ints will work just fine but it won't work the other way around (typecasting reals to ints).

    When you want to use JASS to refer a variable you've made in the variable editor, note that you must change all spaces to underscores and append "udg_" to the beginning of it because that's what the WE does for user defined globals. For example you have
    boolean array udg_AccessofPortal
    defined but your functions reference
    AccessofPortal[...]
    without its prefix.

    Array variables DON'T have initialized values unless you set them that way in the variable editor. You can't access one that hasn't been defined, like a local variable:
    Code (vJASS):
    //Causes a crash
        local integer foo
        call BJDebugMsg(I2S(foo)) //'foo' has no value

    //No crash
        local integer foo
        set foo = 5 //now it has a value!
        call BJDebugMsg(I2S(foo))

    //Causes a crash
        integer array foo //no indices of foo have values
        call BJDebugMsg(I2S(foo[2]))

    //No crash
        integer array foo
        set foo[3] = 7 //only foo[3] is defined
        call BJDebugMsg(I2S(foo[3]))

    //Crash again
        integer array foo
        set foo[253] = 99 //only foo[253] is defined
        call BJDebugMsg(I2S(foo[1])) //foo[1] isn't defined!


    //What you did:
    function SetPortalNumber takes nothing returns nothing
        set AccessofPortal[RandomPortal()]=true //call this AccessofPortal[R]
        set AccessofPortal[5]=false
    endfunction
    //Only AccessofPortal[R] and AcessofPortal[5] are defined, so
    //Getting the 'value' of AccessofPortal[2] will cause a crash if R != 2
    //This might not happen with booleans-- they could be auto-initialized to true or false, idk
     


    None of these is likely causing the crash, though, and I believe the problem is with rects and regions. What GUI calls a "region" is really a collection of different rect objects (rectangles). Since a rect can only be rectangular (granted, any dimension, but rectangular nonetheless), you can create more complex triggerable areas by combining multiple rects under the grouping of a Region. It was handy you posted the war3map.j because it shows me you have:
    Code (vJASS):
        rect                    gg_rct_RegionFirstArea     = null
        rect                    gg_rct_RegionMaskedStartPoint = null
        rect                    gg_rct_RegionStartCharacters = null
        rect                    gg_rct_SHOP_Spawn_Location = null
        rect                    gg_rct_TrainingGround1     = null
        rect                    gg_rct_TrainingGround1_Portal = null
        rect                    gg_rct_RegionStartMask     = null
        rect                    gg_rct_TrapToMap           = null
        rect                    gg_rct_TrapSpawnArea       = null
        rect                    gg_rct_Region_009          = null
        rect                    gg_rct_Region_010          = null
        rect                    gg_rct_Region_011          = null
        rect                    gg_rct_Region_012          = null
        rect                    gg_rct_Region_013          = null

    //All rects!

    But the call you're using takes regions:
    native IsPointInRegion region whichRegion, real x, real y returns boolean
    and there isn't an equivalent call for rects. You are left with two options:
    1. Use
      native CreateRegion takes nothing returns nothing
      ,
      native RegionAddRect takes region whichRegion, rect r
      , and
      native RemoveRegion takes region whichRegion
      in sequence to create region versions of the rects before you check and return the appropriate region.

      Why not create a global region variable that you only have to set once? You can't make a region variable with the variable editor-- only rects! So unless you have the JNGP installed you won't be able to just make your own
      Code (vJASS):
      globals
          region array MoveRegions
      endglobals

    2. Change your method entirely, which I would recommend because option 1. is inefficient and will inevitably leak regions you don't destroy before returning them. You can wildly simplify what you've done by instead getting the unit's x and y coordinates and then checking if they're in the boundaries for each rect.
     
  11. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    What I would do:
    Code (vJASS):
    function RandomPortal takes nothing returns integer
        return GetRandomInt(1,4)
    endfunction

    function SetPortalNumber takes nothing returns nothing
        local integer i = 1

        loop
            set udg_AccessofPortal[i] = false
            set i = i+1
            exitwhen i > TOTAL_PORTALS //I'm guessing this is 4 for your map? Confused by you using 5 since there are only 4 rects you check in.
        endloop

        set udg_AccessofPortal[RandomPortal()] = true
    endfunction

    function Trig_RandomGen_Actions takes nothing returns nothing
        local unit u = GetTriggerUnit()
        local real ux = GetUnitX(u)     //Always ALWAYS avoid locations wherever you can-- they are the DEVIL in wc3 (memory leaks, slow, not useful, etc.)
        local real uy = GetUnitY(u)
        local real rxMax
        local real rxMin
        local real ryMax
        local real ryMin
        local integer i = 1
        local rect CheckRect

        loop
            if i == 1 then
                set CheckRect = gg_rct_Region_009
            elseif i == 2 then
                set CheckRect = gg_rct_Region_010
            elseif i == 3 then
                set CheckRect = gg_rct_Region_011
            elseif i == 4 then
                set CheckRect = gg_rct_Region_012
            else
                set CheckRect = null //this is a safety call, probably unnecessary
            endif

            set rxMax = GetRectMaxX(CheckRect)
            set rxMin = GetRectMinX(CheckRect)
            set ryMax = GetRectMaxY(CheckRect)
            set ryMin = GetRectMinY(CheckRect)

            if (rxMax >= ux and ux >= rxMin) and (ryMax >= uy and uy >= ryMin)
                //If ux and uy are within its boundary then the unit must be inside
                call SetUnitX(GetRectCenterX(gg_rct_Region_13))
                call SetUnitY(GetRectCenterY(gg_rct_Region_13))
                exitwhen true //leave the loop early, no need to do more
            endif

            set i = i+1
            exitwhen i > TOTAL_PORTALS // Probably 4, again
        endloop

        set u = null
        set CheckRect = null
    endfunction

    //===========================================================================
    function InitTrig_RandomGen1 takes nothing returns nothing
        call SetPortalNumber()
        set gg_trg_RandomGen1 = CreateTrigger(  )
        call TriggerRegisterEnterRegionSimple(gg_trg_RandomGen1,gg_rct_TrainingGround1)
        call TriggerAddAction( gg_trg_RandomGen1, function Trig_RandomGen_Actions )
    endfunction
     
    Last edited: Sep 12, 2016
  12. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,101
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Automatic type cast... Integers can be mixed with real expressions and they get automatically typecast to real. Reals will never be automatically typecast to integer and instead need to be rounded with functions like R2I.

    All JASS arrays have all indices initialized to a default value. I incorrectly stated the opposite in the past but I was wrong. You can access array indices that have never been touched before and they will have default values such as null, 0, 0.0, etc.

    It is only non-array variables that must be initialized before first access. Trying to access a non-array variable, either global or local, before it has been initialized will result in a thread crash.

    AnonymousPro do you get a syntax error on map save? Or does the trigger not work as intended in game?

    If you get a syntax error please post it. As a rough guess the cause will be because you are not using "udg_" prefix for GUI global variables.
     
  13. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,788
    Resources:
    1
    Spells:
    1
    Resources:
    1
    !
    Good to know I remembered this wrong.
     
  14. AnonymousPro

    AnonymousPro

    Joined:
    Nov 18, 2012
    Messages:
    311
    Resources:
    0
    Resources:
    0
    @Pyrogasm thank you for the very detailed explanation, I might need some time to digest.

    can region array be used in jass, or is it vjass?
    i have never used it in jass before, i need to clarify this because I don't know how to use vjass

    @Dr Super Good Thank you for the clarification, that helps me a lot

    Most likely it is a syntax error, I don't know how to run syntax check on JNGP, and I didn't run syntax check on war3map.j either.
    The syntax error, is most likely udg_AccessofPortal, which made my variable undeclared as I wrote as AccessofPortal

    now my solution is
    1. fix the syntax error real quick.
    2. use a region array for now
     
  15. DracoL1ch

    DracoL1ch

    Joined:
    Dec 12, 2010
    Messages:
    2,037
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    guys, as a said note
    do not return integer in functions which returns real
    Code (vJASS):

    function a takes nothing returns real
    return 1234
    endfunction

    will fuck you up
    Code (vJASS):

    function a takes nothing returns real
    return 1234.
    endfunction

    is fine
     
  16. AnonymousPro

    AnonymousPro

    Joined:
    Nov 18, 2012
    Messages:
    311
    Resources:
    0
    Resources:
    0
    Ok now syntax error is fixed.
    Gets fatal error.
    I suppose it's the region problem as @Pyrogasm mentioned. Trying to use his example with my boolean array and see what happens
     
  17. AnonymousPro

    AnonymousPro

    Joined:
    Nov 18, 2012
    Messages:
    311
    Resources:
    0
    Resources:
    0
    what u said contradicts to @Dr Super Good . He said integers get automatically typecast to reals, so it should be fine.

    @Pyrogasm , I have used a lot of locations when I started with GUI, this is my first map so I just happened to learn how to convert code in jass yesterday.

    noted
    Code (vJASS):
     //Always ALWAYS avoid locations wherever you can-- they are the DEVIL in wc3 (memory leaks, slow, not useful, etc.)


    I am making a dungeon-like game, masking the map, set camera on the character, when character move to portals, there is random chance one of the portal is real.
    if it's real, it would send you to the next town, or next dungeon.
    if you enter the fake portal you will be sent to trap, a hell flock of monsters and you might die.

    so for this area, it has 4 portals, and the rect where the portals are will be the portals that will be used for random teleporting.
     
    Last edited: Sep 12, 2016
  18. DracoL1ch

    DracoL1ch

    Joined:
    Dec 12, 2010
    Messages:
    2,037
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    ye, returns are exception. you have to use correct type in returns
     
  19. AnonymousPro

    AnonymousPro

    Joined:
    Nov 18, 2012
    Messages:
    311
    Resources:
    0
    Resources:
    0
    ok, did i make any mistake in returning reals?
     
  20. AnonymousPro

    AnonymousPro

    Joined:
    Nov 18, 2012
    Messages:
    311
    Resources:
    0
    Resources:
    0
    @Pyrogasm
    I'm using this to remove the leak of the
    Code (vJASS):
    SetTerrainTypeBJ
    , by using
    Code (vJASS):
    SetTerrainType

    The loop onnly seem to run once, why is that so?
    it only set my first rct to the new tiles
    Code (vJASS):
    function Trig_Tiles_Actions takes nothing returns nothing
    //Always ALWAYS avoid locations wherever you can-- they are the DEVIL in wc3 (memory leaks, slow, not useful, etc.)
        local real rxMax
        local real rxMin
        local real ryMax
        local real ryMin
        local integer i = 1

        loop
        exitwhen i>4
            if i == 1 then
                set udg_CheckRect[i] = gg_rct_Area14
            elseif i == 2 then
                set udg_CheckRect[i] = gg_rct_Area15
            elseif i == 3 then
                set udg_CheckRect[i] = gg_rct_Area16
            elseif i == 4 then
                set udg_CheckRect[i] = gg_rct_Area17
            else
                set udg_CheckRect[i] = null //this is a safety call, probably unnecessary
            endif
            set rxMax = GetRectMaxX(udg_CheckRect[i])
            set rxMin = GetRectMinX(udg_CheckRect[i])
            set ryMax = GetRectMaxY(udg_CheckRect[i])
            set ryMin = GetRectMinY(udg_CheckRect[i])
    //    call SetTerrainTypeBJ( GetRectCenter(gg_rct_Region_013), 'Ldrt', -1, 8, 1 )

    call SetTerrainType(GetRectCenterX(udg_CheckRect[i]),GetRectCenterY(udg_CheckRect[i]), 'Ldrt', -1, 8, 1 )
      set i = i+1

        endloop

        set udg_CheckRect[i] = null
    endfunction



    //===========================================================================
    function InitTrig_Tiles takes nothing returns nothing
        set gg_trg_Tiles = CreateTrigger(  )
        call TriggerAddAction( gg_trg_Tiles, function Trig_Tiles_Actions )
    endfunction