• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS/GUI] Simple Patrol Script (with quest)

Status
Not open for further replies.
There is an orc base (the player, red) and a human base (blue). The patrols are teal.
There are 3 camps. The patrols move between these camps and the blue base.

When a red and a teal unit get in range, the quest will start. From then on, each time the player encounters teal units, one of them will run back to the blue base (unless there is only one unit) and the rest will attack move to the red base.

When the unit running back reaches a certain region, the quest is lost and the patrols stop.
When the player attacks blue, the quest is complete and the patrols stop.
When the patrols stop, AI attack waves are started for blue.

That's basically it, maybe it will be useful for someone :)


  • PatrolCamp1
  • PatrolCamp2
  • PatrolCamp3
  • PatrolCamp1Facing
  • PatrolCamp3Facing
  • PatrolCamp1Meet
  • PatrolCamp2Meet
  • PatrolCamp3Meet
  • HumanOutpost (Patrol Home/Outpost)
  • PatrolHomeMeet
  • PatrolHomeAlert
  • OrcTown (Player home/base)



Players:
  • AP1_Player (Player 1)
  • P02_Humans (Player 2)
  • P03_Humans (Player 3)
Unit: PatrolApproachedFootman
Unit Groups:
  • PatrolAlertGr
  • PatrolRunGr
  • PatrolApproachedTempGr
  • PatrolCampsGr Array[3]
  • PatrolCampsLeaving Array[3]
  • PatrolFootmenTempGr
Regions: PatrolCampsRct Array[3]
Timers:

  • PatrolApproachedTimer
  • PatrolSendTimer
Points:
  • PatrolCampsFacing Array[3]
  • PatrolCampsLoc Array[3]
  • PatrolCampsMeet Array[3]
  • PatrolHomeLoc
Triggers: PatrolRelieveTrg Array[3]
Quest:
QuestPatrol
Quest Requirements:
  • QuestPatrolReqHide
  • QuestPatrolReqSeek
Integers:
  • PatrolAlertIndex
  • PatrolCampsAmt (3)
  • PatrolCampsTarget Array[3]
  • PatrolSendTarget
Booleans:
  • GameOver (False)
  • PatrolSendOn (False)



JASS:
function GetGroupFootmenCallback takes nothing returns nothing
   if(GetUnitTypeId(GetEnumUnit()) == 'hfoo') then
       call GroupAddUnit( udg_PatrolFootmenTempGr, GetEnumUnit() )
   endif
endfunction

function GetGroupFootmen takes group patrolGroup returns group
   set udg_PatrolFootmenTempGr = CreateGroup()
   call ForGroup( patrolGroup, function GetGroupFootmenCallback )
   return udg_PatrolFootmenTempGr
endfunction



  • Start Patrols
    • Events
    • Conditions
    • Actions
      • Trigger - Run Patrol Script Toggle <gen> (checking conditions)



  • Quest Patrol Create
    • Events
    • Conditions
      • ((This trigger) is on) Equal to True
    • Actions
      • Trigger - Turn off (This trigger)
      • -------- Create the quest objects --------
      • Quest - Create a Optional, undiscovered quest titled Patrol Quest with the description ..., using icon path ReplaceableTextures\CommandButtons\BTNPatrol.blp
      • Set QuestPatrol = (Last created quest)
      • Quest - Create a quest requirement for QuestPatrol with the description Find the enemy outp...
      • Set QuestPatrolReqSeek = (Last created quest requirement)
      • Quest - Create a quest requirement for QuestPatrol with the description Prevent the patrols...
      • Set QuestPatrolReqHide = (Last created quest requirement)
  • Quest Patrol Discover
    • Events
    • Conditions
    • Actions
      • -------- Ensure that the quest exists --------
      • Trigger - Run Quest Patrol Create <gen> (checking conditions)
      • -------- Update the quest --------
      • Quest - Mark QuestPatrol as Discovered
      • -------- Display a quest message. --------
      • Quest - Display to (All players) the Quest Discovered message: |cffffcc00OPTIONAL ...
  • Quest Patrol Failed
    • Events
    • Conditions
    • Actions
      • -------- Ensure that the quest exists --------
      • Trigger - Run Quest Patrol Create <gen> (checking conditions)
      • -------- Update the quest --------
      • Quest - Mark QuestPatrol as Discovered
      • Quest - Mark QuestPatrolReqHide as Incomplete
      • Quest - Mark QuestPatrolReqSeek as Incomplete
      • Quest - Mark QuestPatrol as Failed
      • -------- Display a quest message. --------
      • Quest - Display to (All players) the Quest Failed message: |cffffcc00OPTIONAL ...
  • Quest Patrol Completed
    • Events
    • Conditions
    • Actions
      • -------- Ensure that the quest exists --------
      • Trigger - Run Quest Patrol Create <gen> (checking conditions)
      • -------- Update the quest --------
      • Quest - Mark QuestPatrol as Discovered
      • Quest - Mark QuestPatrolReqHide as Completed
      • Quest - Mark QuestPatrolReqSeek as Completed
      • Quest - Mark QuestPatrol as Completed
      • -------- Display a quest message. --------
      • Quest - Display to (All players) the Quest Completed message: |cffffcc00OPTIONAL ...



Patrol Script
JASS:
function PatrolScriptStopFnc takes nothing returns nothing
   local group patrolGroup = GetUnitsOfPlayerAll(udg_P03_Humans)
   local integer index = 0
   
   loop
       exitwhen index >= udg_PatrolCampsAmt
       call GroupRemoveGroup(udg_PatrolCampsGr[index], patrolGroup)
       set index = index+1
   endloop
   
   if(IsUnitGroupEmptyBJ(patrolGroup)) then
       call DisableTrigger(gg_trg_Patrol_Script)
       call DisableTrigger(gg_trg_Patrol_Approached_Timer)
       call DestroyTimer(udg_PatrolApproachedTimer)
       call DestroyGroup(udg_PatrolAlertGr)
       call DestroyGroup(udg_PatrolAlertRunGr)
       call RemoveLocation(udg_PatrolHomeLoc)
       
       set index = 0
       loop
           exitwhen index >= udg_PatrolCampsAmt
           
           call DisableTrigger(udg_PatrolRelieveTrg[index])
           call DestroyGroup(udg_PatrolCampsGr[index])
           call DestroyGroup(udg_PatrolCampsLeaving[index])
           call RemoveRect(udg_PatrolCampsRct[index])
           call RemoveLocation(udg_PatrolCampsMeet[index])
           call RemoveLocation(udg_PatrolCampsFacing[index])
           call RemoveLocation(udg_PatrolCampsLoc[index])

           set index = index+1
       endloop
       
       //call RemoveRect()
       //call RemoveRegion()
       //call DestroyBoolexpr
       //call DestroyCondition DestroyFilter
       //remove rects/regions
       //also null all vars
   endif
   
   call DestroyGroup(patrolGroup)   
   set patrolGroup = null
endfunction

function PatrolCleanupFnc takes nothing returns nothing
    local integer index
    local unit triggerUnit = null

    if(not udg_GameOver and IsTriggerEnabled(GetTriggeringTrigger())) then
       set triggerUnit = GetEnteringUnit()
       if(triggerUnit != null) then
           if(GetOwningPlayer(triggerUnit) == udg_P03_Humans) then
               call SetUnitMoveSpeed(triggerUnit, 270)
               call SetUnitOwner( triggerUnit, udg_P02_Humans, true )
               call RecycleGuardPosition( triggerUnit )
           endif
           
       else
           set triggerUnit = GetDyingUnit()
           if(triggerUnit != null) then
               set index = 0
               loop
                   exitwhen index >= udg_PatrolCampsAmt
                   call GroupRemoveUnit( udg_PatrolCampsGr[index], triggerUnit )
                   set index = index+1
               endloop
           endif
       endif
           
       if(triggerUnit != null) then
           call GroupRemoveUnit( udg_PatrolAlertGr, triggerUnit )
           call GroupRemoveUnit( udg_PatrolAlertRunGr, triggerUnit )

           set triggerUnit = null
       endif
       
       if(not udg_PatrolSendOn and IsTriggerEnabled(gg_trg_Patrol_Script)) then
           call PatrolScriptStopFnc()
       endif
    endif
endfunction

function PatrolRelieveFnc takes integer index, unit enteringUnit returns nothing
    local boolean   sendPatrol
   local boolean   enteringStays
   local group       campFootmen
   local group       patrolLeavingGr
    local unit       patrolLeaving
   local location   randomLoc
   
   if(GetOwningPlayer(enteringUnit) == udg_P03_Humans and not IsUnitInGroup(enteringUnit, udg_PatrolCampsLeaving[index]) and not IsUnitInGroup(enteringUnit, udg_PatrolAlertGr)) then
       set sendPatrol = false
       set enteringStays = true
       
       if( not IsUnitInGroup(enteringUnit, udg_PatrolCampsGr[index]) and CountUnitsInGroup(udg_PatrolCampsGr[index]) >= 3 ) then
           set campFootmen = GetGroupFootmen(udg_PatrolCampsGr[index])
           
           if(not IsUnitGroupEmptyBJ(campFootmen) or GetUnitTypeId(enteringUnit) == 'hfoo') then
               set sendPatrol = true
               set patrolLeavingGr = CreateGroup()
               
               if(IsUnitGroupEmptyBJ(campFootmen)) then
                   set enteringStays = false
                   set patrolLeaving = enteringUnit
               else
                   set patrolLeaving = GroupPickRandomUnit(campFootmen)
                   call GroupRemoveUnit( udg_PatrolCampsGr[index], patrolLeaving )
               endif
               call GroupAddUnit( udg_PatrolCampsLeaving[index], patrolLeaving )
               call GroupAddUnit( patrolLeavingGr, patrolLeaving )
               
               set patrolLeaving = GroupPickRandomUnit(udg_PatrolCampsGr[index])
               call GroupRemoveUnit( udg_PatrolCampsGr[index], patrolLeaving )
               call GroupAddUnit( udg_PatrolCampsLeaving[index], patrolLeaving )
               call GroupAddUnit( patrolLeavingGr, patrolLeaving )
               
               call GroupPointOrderLoc( patrolLeavingGr, "attack", udg_PatrolCampsMeet[index] )
           endif
           
           call DestroyGroup(campFootmen)
       endif

       if(enteringStays) then
           if( not IsUnitInGroup(enteringUnit, udg_PatrolCampsGr[index]) ) then
               call GroupAddUnit( udg_PatrolCampsGr[index], enteringUnit )
           endif
           
           set randomLoc = GetRandomLocInRect(udg_PatrolCampsRct[index])
           call IssuePointOrderLoc( enteringUnit, "attack", randomLoc )
           call RemoveLocation(randomLoc)
           
           call TriggerSleepAction( 1.50 )
           if( IsUnitInGroup(enteringUnit, udg_PatrolCampsGr[index]) ) then
               call SetUnitFacingToFaceLocTimed( enteringUnit, udg_PatrolCampsFacing[index], 0.50 )
           endif
       endif

       if(sendPatrol) then
           call TriggerSleepAction( 3.50 )
           if(not udg_PatrolSendOn or udg_PatrolCampsTarget[index] == udg_PatrolCampsAmt) then
               call GroupPointOrderLoc( patrolLeavingGr, "attack", udg_PatrolHomeLoc )
           else
               call GroupPointOrderLoc( patrolLeavingGr, "attack", udg_PatrolCampsLoc[ udg_PatrolCampsTarget[index] ] )
           endif
           
           if(udg_PatrolCampsAmt < 1) then
               set udg_PatrolCampsTarget[index] = 0
           else
               loop
                   set udg_PatrolCampsTarget[index] = udg_PatrolCampsTarget[index] + 1
                   if(udg_PatrolCampsTarget[index] > udg_PatrolCampsAmt) then
                       set udg_PatrolCampsTarget[index] = 0
                   endif
                   
                   exitwhen udg_PatrolCampsTarget[index] != index and udg_PatrolCampsTarget[index] <= udg_PatrolCampsAmt
               endloop
           endif
           
           call TriggerSleepAction( 15.00 )
           call GroupRemoveGroup( patrolLeavingGr, udg_PatrolCampsLeaving[index] )
           call DestroyGroup(patrolLeavingGr)
           
       elseif(not udg_PatrolSendOn and IsTriggerEnabled(gg_trg_Patrol_Script)) then
           call PatrolScriptStopFnc()
       endif
   endif
   
   set enteringUnit = null
   set patrolLeaving = null
   set patrolLeavingGr = null
   set campFootmen = null
   set randomLoc = null
endfunction

function PatrolRelieveCamp1 takes nothing returns nothing
   if(not udg_GameOver and IsTriggerEnabled(GetTriggeringTrigger())) then
       call PatrolRelieveFnc(0, GetEnteringUnit())
   endif
endfunction

function PatrolRelieveCamp2 takes nothing returns nothing
   if(not udg_GameOver and IsTriggerEnabled(GetTriggeringTrigger())) then
       call PatrolRelieveFnc(1, GetEnteringUnit())
   endif
endfunction

function PatrolRelieveCamp3 takes nothing returns nothing
   if(not udg_GameOver and IsTriggerEnabled(GetTriggeringTrigger())) then
       call PatrolRelieveFnc(2, GetEnteringUnit())
   endif
endfunction

//===========================================================================
function InitTrig_Patrol_Script takes nothing returns nothing
    local integer index
   
    set gg_trg_Patrol_Script = CreateTrigger()
    call TriggerRegisterEnterRectSimple( gg_trg_Patrol_Script, gg_rct_HumanOutpost )
    call TriggerRegisterPlayerUnitEvent( gg_trg_Patrol_Script, udg_P03_Humans, EVENT_PLAYER_UNIT_DEATH, null )
    call TriggerAddAction( gg_trg_Patrol_Script, function PatrolCleanupFnc )
   
   set udg_PatrolHomeLoc = GetRectCenter(gg_rct_HumanOutpost)
    set udg_PatrolCampsRct[0] = gg_rct_PatrolCamp1
    set udg_PatrolCampsRct[1] = gg_rct_PatrolCamp2
    set udg_PatrolCampsRct[2] = gg_rct_PatrolCamp3
   set udg_PatrolCampsFacing[0] = GetRectCenter(gg_rct_PatrolCamp1Facing)
   set udg_PatrolCampsFacing[1] = GetRectCenter(gg_rct_PatrolCamp2)
   set udg_PatrolCampsFacing[2] = GetRectCenter(gg_rct_PatrolCamp3Facing)
   set udg_PatrolCampsMeet[0] = GetRectCenter(gg_rct_PatrolCamp1Meet)
   set udg_PatrolCampsMeet[1] = GetRectCenter(gg_rct_PatrolCamp2Meet)
   set udg_PatrolCampsMeet[2] = GetRectCenter(gg_rct_PatrolCamp3Meet)
   set udg_PatrolCampsTarget[0] = 1
   set udg_PatrolCampsTarget[1] = 3
   set udg_PatrolCampsTarget[2] = 0

   set index = 0
    loop
        exitwhen index >= udg_PatrolCampsAmt

       set udg_PatrolCampsLoc[index] = GetRectCenter(udg_PatrolCampsRct[index])
       set udg_PatrolCampsGr[index] = GetUnitsInRectOfPlayer(udg_PatrolCampsRct[index], udg_P03_Humans)
       set udg_PatrolRelieveTrg[index] = CreateTrigger()
        call TriggerRegisterEnterRectSimple( udg_PatrolRelieveTrg[index], udg_PatrolCampsRct[index] )

        set index = index+1
    endloop
   
   call TriggerAddAction( udg_PatrolRelieveTrg[0], function PatrolRelieveCamp1 )
   call TriggerAddAction( udg_PatrolRelieveTrg[1], function PatrolRelieveCamp2 )
   call TriggerAddAction( udg_PatrolRelieveTrg[2], function PatrolRelieveCamp3 )
endfunction

Patrol Script Toggle
JASS:
function PatrolScriptToggle takes nothing returns nothing
   local group patrolLeavingGr
   
   if(not udg_GameOver) then
       //STOP PATROL SCRIPT
       if(udg_PatrolSendOn) then
           //Stop quest & patrols
           set udg_PatrolSendOn = false
           call DisableTrigger( gg_trg_Player_Attacks_Outpost )
           call DisableTrigger( gg_trg_Patrol_Alerts_Home )
           call DisableTrigger( gg_trg_Patrol_Send_Timer )
           call DestroyTimer( udg_PatrolSendTimer )
           
           call QueuedTriggerRemoveBJ( gg_trg_Patrol_Send_Q )
       
           call TriggerSleepAction( 2 )
           
           //Start AI
           call TriggerExecute( gg_trg_Start_AI_Attack_Waves )
       
       //START PATROL SCRIPT
       else
           //Enable script
           set udg_PatrolSendOn = true
           call EnableTrigger(gg_trg_Patrol_Script)
           call EnableTrigger(gg_trg_Patrol_Send_Timer)
           call EnableTrigger(gg_trg_Patrol_Approached_Timer)
           
           //Enable quest
           call TriggerExecute(gg_trg_Patrol_Approached_Timer)
           
           //Send initial patrols
           set patrolLeavingGr = CreateGroup()
           call TriggerSleepAction(10)
           call GroupAddUnit(patrolLeavingGr, gg_unit_hfoo_0101)
           call GroupAddUnit(patrolLeavingGr, gg_unit_hrif_0097)
           call GroupPointOrderLoc( patrolLeavingGr, "attack", udg_PatrolCampsLoc[2] )
           
           call GroupRemoveUnit(patrolLeavingGr, gg_unit_hfoo_0101)
           call GroupRemoveUnit(patrolLeavingGr, gg_unit_hrif_0097)
           
           call TriggerSleepAction(20)
           call GroupAddUnit(patrolLeavingGr, gg_unit_hfoo_0052)
           call GroupAddUnit(patrolLeavingGr, gg_unit_hfoo_0130)
           call GroupPointOrderLoc( patrolLeavingGr, "attack", udg_PatrolCampsLoc[2] )
           
           call DestroyGroup(patrolLeavingGr)
           
           //Start patrols
           call TriggerExecute(gg_trg_Patrol_Send_Timer)
       endif
    endif
   
   set patrolLeavingGr = null
endfunction

//===========================================================================
function InitTrig_Patrol_Script_Toggle takes nothing returns nothing
    set gg_trg_Patrol_Script_Toggle = CreateTrigger()

    call TriggerAddAction( gg_trg_Patrol_Script_Toggle, function PatrolScriptToggle )
endfunction

Patrol Send Timer
JASS:
function PatrolSendTimerFnc takes nothing returns nothing
    if(udg_PatrolSendOn and not udg_GameOver and IsTriggerEnabled(GetTriggeringTrigger())) then
        if ( bj_queuedExecTotal <= 0 ) then
            call QueuedTriggerAddBJ( gg_trg_Patrol_Send_Q, true )
            call TimerStart( udg_PatrolSendTimer, 50.00, false, null )
        else
            call TimerStart( udg_PatrolSendTimer, 20.00, false, null )
        endif
    endif
endfunction

//===========================================================================
function InitTrig_Patrol_Send_Timer takes nothing returns nothing
    set gg_trg_Patrol_Send_Timer = CreateTrigger()

    call TriggerRegisterTimerExpireEvent( gg_trg_Patrol_Send_Timer, udg_PatrolSendTimer )
    call TriggerAddAction( gg_trg_Patrol_Send_Timer, function PatrolSendTimerFnc )
endfunction

Patrol Send Q
JASS:
function UnitIsP2Footman takes nothing returns boolean
    return GetOwningPlayer(GetFilterUnit()) == udg_P02_Humans and GetUnitTypeId(GetFilterUnit()) == 'hfoo'
endfunction

function UnitIsP2CombatUnit takes nothing returns boolean
   local integer filterId = GetUnitTypeId(GetFilterUnit())
    return GetOwningPlayer(GetFilterUnit()) == udg_P02_Humans and (filterId == 'hfoo' or filterId == 'hrif' or filterId == 'hmpr')
endfunction

function PatrolSendFnc takes nothing returns nothing
   local conditionfunc tempCond
   local location meetLoc
   local unit patrolLeaving
   local group patrolPool
   local group patrolPoolFoot
   local group patrolLeavingGr
   
    if(not udg_GameOver and udg_PatrolSendOn) then
       set tempCond = Condition(function UnitIsP2CombatUnit)
       set patrolPool = GetUnitsInRectMatching(gg_rct_HumanOutpost, tempCond)
       call DestroyCondition(tempCond)
       
       set tempCond = Condition(function UnitIsP2Footman)
       set patrolPoolFoot = GetUnitsInRectMatching(gg_rct_HumanOutpost, tempCond)
       call DestroyCondition(tempCond)
       
       if(not IsUnitGroupEmptyBJ(patrolPoolFoot) and CountUnitsInGroup(patrolPool) > 1) then
           set patrolLeavingGr = CreateGroup()
           
           set patrolLeaving = GroupPickRandomUnit(patrolPoolFoot)
           call GroupAddUnit(patrolLeavingGr, patrolLeaving)
           call GroupRemoveUnit(patrolPool, patrolLeaving)
           call SetUnitOwner( patrolLeaving, udg_P03_Humans, false )
           call RemoveGuardPosition( patrolLeaving )
           
           set patrolLeaving = GroupPickRandomUnit(patrolPool)
           call GroupAddUnit(patrolLeavingGr, patrolLeaving)
           call SetUnitOwner( patrolLeaving, udg_P03_Humans, false )
           call RemoveGuardPosition( patrolLeaving )
           
           set meetLoc = GetRectCenter(gg_rct_PatrolHomeMeet)
           call GroupPointOrderLoc( patrolLeavingGr, "attack", meetLoc )
           call RemoveLocation(meetLoc)
           
           call QueuedTriggerRemoveBJ( GetTriggeringTrigger() )
           
           call TriggerSleepAction( 5.00 )
           
           set udg_PatrolSendTarget = udg_PatrolSendTarget+1
           if ( udg_PatrolSendTarget >= udg_PatrolCampsAmt ) then
               set udg_PatrolSendTarget = 0
           endif
           call GroupPointOrderLoc( patrolLeavingGr, "attack", udg_PatrolCampsLoc[udg_PatrolSendTarget] )
           
           call DestroyGroup(patrolLeavingGr)
       endif
       
       call DestroyGroup(patrolPool)
       call DestroyGroup(patrolPoolFoot)       
   endif
   
   call QueuedTriggerRemoveBJ( GetTriggeringTrigger() )
   
   set meetLoc = null
   set tempCond = null
   set patrolLeaving = null
   set patrolLeavingGr = null
   set patrolPool = null
   set patrolPoolFoot = null
endfunction

//===========================================================================
function InitTrig_Patrol_Send_Q takes nothing returns nothing
    set gg_trg_Patrol_Send_Q = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Patrol_Send_Q, function PatrolSendFnc )
endfunction



Patrol Approached Timer
JASS:
function OwnerIsP1 takes nothing returns boolean
    return ( GetOwningPlayer(GetFilterUnit()) == udg_AP1_Player )
endfunction

function OwnerIsP3NotAlert takes nothing returns boolean
    return ( GetOwningPlayer(GetFilterUnit()) == udg_P03_Humans and not IsUnitInGroup(GetFilterUnit(), udg_PatrolAlertGr) )
endfunction

function PatrolCheckEnum takes nothing returns nothing
   local integer index
   local conditionfunc tempCond
   local location tempLoc
   local unit enumUnit = GetEnumUnit()
   local group playerGroup
   local group patrolTempGr
   
   if(not IsUnitInGroup(enumUnit, udg_PatrolAlertGr)) then
       set tempCond = Condition(function OwnerIsP1)
       set playerGroup = GetUnitsInRangeOfLocMatching(256.00, GetUnitLoc(enumUnit), tempCond)
       call DestroyCondition(tempCond)
       
       if(not IsUnitGroupEmptyBJ(playerGroup)) then
           call DestroyGroup(playerGroup)
           
           set tempCond = Condition(function OwnerIsP3NotAlert)
           set playerGroup = GetUnitsInRangeOfLocMatching(512.00, GetUnitLoc(enumUnit), tempCond)
           call DestroyCondition(tempCond)
           
           call GroupAddUnit(playerGroup, enumUnit)
           call GroupRemoveGroup( playerGroup, udg_PatrolApproachedTempGr )
           call GroupAddGroup( playerGroup, udg_PatrolAlertGr )
           
           if(udg_PatrolSendOn) then
               if(IsTriggerEnabled(gg_trg_Patrol_Approached_Q) and QueuedTriggerGetIndex(gg_trg_Patrol_Approached_Q) == -1) then               
                   set patrolTempGr = GetGroupFootmen(playerGroup)
                   if(not IsUnitGroupEmptyBJ(patrolTempGr) and CountUnitsInGroup(playerGroup) > 1) then
                       set udg_PatrolApproachedFootman = GroupPickRandomUnit(patrolTempGr)
                       call QueuedTriggerAddBJ( gg_trg_Footman_Attack_Line_Q, true )
                   endif
                   call DestroyGroup(patrolTempGr)
                   
                   call EnableTrigger( gg_trg_Patrol_Alerts_Home )
                   call QueuedTriggerAddBJ( gg_trg_Patrol_Approached_Q, true )
               endif
           
               set patrolTempGr = CreateGroup()
               call GroupAddGroup(playerGroup, patrolTempGr)
               if(CountUnitsInGroup(patrolTempGr) > 1) then
                   call GroupRemoveUnit(patrolTempGr, udg_PatrolApproachedFootman)
                   call GroupAddUnit(udg_PatrolAlertRunGr, GroupPickRandomUnit(patrolTempGr))
               endif
               call DestroyGroup(patrolTempGr)
               
               call GroupRemoveGroup(udg_PatrolAlertRunGr, playerGroup)
           endif
           
           set index = 0
           loop
               exitwhen index >= udg_PatrolCampsAmt
               call GroupRemoveGroup( udg_PatrolCampsGr[index], playerGroup )
               set index = index+1
           endloop
           
           set tempLoc = GetRectCenter(gg_rct_OrcTown)
           call GroupPointOrderLoc( playerGroup, "attack", tempLoc )
           call RemoveLocation(tempLoc)
           call DestroyGroup(playerGroup)
           
       else
           call DestroyGroup(playerGroup)
       endif
   endif
   
   set tempCond = null
   set tempLoc = null
   set enumUnit = null
   set patrolTempGr = null
   set playerGroup = null
endfunction

function PatrolAlertEnum takes nothing returns nothing
   local unit enumUnit
   local real unitX
   local real unitY
       
   if(udg_PatrolSendOn and (udg_PatrolAlertIndex == 5 or udg_PatrolAlertIndex == 10)) then
       set enumUnit = GetEnumUnit()
       set unitX = GetUnitX(enumUnit)
       set unitY = GetUnitY(enumUnit)
       
       if(GetUnitMoveSpeed(enumUnit) == 270) then
           call SetUnitMoveSpeed(enumUnit, 200)
           call IssuePointOrderLoc(enumUnit, "move", udg_PatrolHomeLoc)
           call PingMinimap(unitX, unitY, 3.00)
       
       elseif(udg_PatrolAlertIndex == 5) then
           call PingMinimap(unitX, unitY, 1.00)
       endif
       
       call SetCameraQuickPosition( unitX, unitY )
   endif

   set enumUnit = null
endfunction

function PatrolApproachedFnc takes nothing returns nothing
   if(not udg_GameOver and IsTriggerEnabled(GetTriggeringTrigger())) then
       set udg_PatrolApproachedTempGr = GetUnitsOfPlayerAll(udg_P03_Humans)
       call GroupRemoveGroup(udg_PatrolAlertGr, udg_PatrolApproachedTempGr)
       
       call ForGroup( udg_PatrolApproachedTempGr, function PatrolCheckEnum )
       call DestroyGroup(udg_PatrolApproachedTempGr)
               
       if(not IsUnitGroupEmptyBJ(udg_PatrolAlertRunGr) and QueuedTriggerGetIndex(gg_trg_Footman_Attack_Line_Q) == -1) then
           call ForGroup( udg_PatrolAlertRunGr, function PatrolAlertEnum )
       endif
       
       if(udg_PatrolAlertIndex == 10) then
           set udg_PatrolAlertIndex = 0
       else
           set udg_PatrolAlertIndex = udg_PatrolAlertIndex+1
       endif
       
       call TimerStart( udg_PatrolApproachedTimer, 0.50, false, null )
   endif
endfunction

//===========================================================================
function InitTrig_Patrol_Approached_Timer takes nothing returns nothing   
    set gg_trg_Patrol_Approached_Timer = CreateTrigger()
   
    call TriggerRegisterTimerExpireEvent( gg_trg_Patrol_Approached_Timer, udg_PatrolApproachedTimer )
    call TriggerAddAction( gg_trg_Patrol_Approached_Timer, function PatrolApproachedFnc )
endfunction

  • Patrol Approached Q
    • Events
    • Conditions
      • GameOver Equal to False
    • Actions
      • Trigger - Turn off (This trigger)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero is alive) Equal to True
        • Then - Actions
          • Sound - Setup all volume channels for speech
          • Cinematic - Send transmission to (All players) from ...
          • Wait for ... to be 0.00 seconds from finished playing
          • Sound - Reset all volume channels to 100%
        • Else - Actions
          • Wait 1.00 seconds
      • Trigger - Run Quest Patrol Discover <gen> (checking conditions)
      • Wait Campaign quest delay seconds
      • Trigger - Remove (This trigger) from the trigger queue
  • Footman Attack Line Q
    • Events
    • Conditions
      • GameOver Equal to False
      • (PatrolApproachedFootman is alive) Equal to True
    • Actions
      • Trigger - Turn off (This trigger)
      • Sound - Setup all volume channels for speech
      • Cinematic - Send transmission to (All players) from PatrolApproachedFootman named Footman: Play ...
      • Wait for ... to be 0.00 seconds from finished playing
      • Sound - Reset all volume channels to 100%
      • Wait 1.00 seconds
      • Trigger - Remove (This trigger) from the trigger queue
  • Player Attacks Outpost
    • Events
      • Unit - A unit owned by Player 2 (Blue) Is attacked
    • Conditions
      • GameOver Equal to False
      • PatrolSendOn Equal to True
      • ((This trigger) is on) Equal to True
      • (Owner of (Attacking unit)) Equal to AP1_Player
    • Actions
      • Trigger - Turn off (This trigger)
      • Trigger - Add Player Attacks Outpost Q <gen> to the trigger queue (Checking conditions)
      • Trigger - Run Patrol Script Toggle <gen> (checking conditions)
  • Player Attacks Outpost Q
    • Events
    • Conditions
      • GameOver Equal to False
      • PatrolSendOn Equal to True
      • (QuestPatrol is discovered) Equal to True
    • Actions
      • Wait 2.00 seconds
      • Trigger - Run Quest Patrol Completed <gen> (checking conditions)
      • Wait Campaign quest delay seconds
      • Trigger - Remove (This trigger) from the trigger queue
  • Patrol Alerts Home
    • Events
      • Unit - A unit enters PatrolHomeAlert <gen>
    • Conditions
      • GameOver Equal to False
      • PatrolSendOn Equal to True
      • ((This trigger) is on) Equal to True
      • (Owner of (Entering unit)) Equal to P03_Humans
      • ((Entering unit) is in PatrolAlertGr) Equal to True
    • Actions
      • Trigger - Turn off (This trigger)
      • Unit - Order (Entering unit) to Move To (Center of HumanOutpost <gen>)
      • Trigger - Add Patrol Alerts Home Q <gen> to the trigger queue (Checking conditions)
      • Trigger - Run Patrol Script Toggle <gen> (checking conditions)
  • Patrol Alerts Home Q
    • Events
    • Conditions
      • GameOver Equal to False
      • PatrolSendOn Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero is alive) Equal to True
          • ((Units owned by AP1_Player of type Grunt) is empty) Equal to False
        • Then - Actions
          • Sound - Setup all volume channels for speech
          • Cinematic - Send transmission to (All players) from (Random unit from (Units owned by AP1_Player of type Grunt)) named Grunt: ...
          • Wait for ... to be 0.00 seconds from finished playing
          • Cinematic - Send transmission to (All players) from Hero...
          • Wait for ... to be 0.00 seconds from finished playing
          • Sound - Reset all volume channels to 100%
        • Else - Actions
      • Wait 5.00 seconds
      • Trigger - Run Quest Patrol Failed <gen> (checking conditions)
      • Wait Campaign quest delay seconds
      • Trigger - Remove (This trigger) from the trigger queue
 
Status
Not open for further replies.
Top