1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  5. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  6. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  7. The results are out! Check them out.
    Dismiss Notice
  8. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  9. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  10. 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.

Patrol System v1.2.1

Submitted by loktar
This bundle is marked as pending. It has not been reviewed by a staff member yet.
[​IMG]
  • Periodically send patrols from Patrol base to camps
  • Camps send patrols to other camps or Patrol base when full
  • Encountered patrols attack Target base and send a Runner to Patrol base
  • New patrols attack Target base instead, when:
    • A Runner reaches Patrol base
    • Target player attacks Patrol player (excl. patrol units)


API
Test map commands:
  • -units: create units in Patrol player's base
  • -toggle: toggle the script (TogglePatrolScript(false))
  • -attackon: enable attack mode (TogglePatrolAttack(true))
  • -attackoff: disable attack mode (TogglePatrolAttack(false))
  • -destroy: destroy the script (DestroyPatrolScript(false))
Code (vJASS):
         ConfigPatrolScript()
//          - Configure the script and apply settings
//          -- Script must be disabled
//          -- If already configured, destroy configured objects
//
         ApplyPatrolSettings()
//          - Apply settings
//          -- Does not include players, regions, points, or targets
//
         TogglePatrolScript(boolean forceDisable)
//          - Enable or disable the script
//          -- Script must be configured to enable
//          -- Certain triggers remain enabled until no units are patrolling
//          --- unless forceDisable == true
//
         TogglePatrolAttack(boolean enable)
//          - Enable or disable Attack Mode
//          -- New patrols attack Target player base instead of patrolling
//          -- Disable or enable Patrol Base alerting and Runner pings
//
         DestroyPatrolScript(boolean forceDestroy)
//          - Permanently destroy the script and its objects and give all Dummy player units to Patrol player
//          -- There must be no units patrolling
//          --- unless forceDestroy == true
//          --- otherwise turn on script autodestruct and disable script


Configuration
Code (vJASS):
boolean udg_PatrolScriptAutoDestruct // Whether to automatically destroy the script when toggled off
boolean udg_PatrolChangeColor // Whether to change unit color when switching owner between Patrol and Dummy

// Players
player udg_PatrolPlayerTarget
player udg_PatrolPlayerPatrol
player udg_PatrolPlayerDummy // Patrolling units owner

integer udg_PatrolCampSizeMax // Maximum number of units in a camp
integer udg_PatrolBaseGuardSize // Minimum "guards" staying in base
integer udg_PatrolGroupGuardSize // Number of "guards" in a patrol group
integer udg_PatrolGroupSize // Total number of units in a patrol group
integer udg_PatrolGroupAttackGuardSize // Number of "guards" in an attack group
integer udg_PatrolGroupAttackSize // Total number of units in an attack group

real udg_PatrolBaseLeaveQTimeout // Timeout between queueing patrols
real udg_PatrolBaseLeaveTimeout // Timeout when patrol is queued
real udg_PatrolAttackQTimeout // Timeout between queueing attacks
real udg_PatrolAttackTimeout // Timeout when attack is queued

real udg_PatrolBaseOrderDelay // Delay (Sleep) between order to rally and to target
real udg_PatrolBaseCleanDelay // Delay (Sleep) between order to target and removing from temp group
real udg_PatrolCampOrderDelay // Delay (Sleep) between order to rally and to target
real udg_PatrolCampFacingDelay // Delay (Sleep) between order to random point in camp and turning

integer udg_PatrolGuardTypesCount // Number of "guard" types
integer udg_PatrolExcludeTypesCount // Number of excluded types
integer udg_PatrolExcludeClassesCount // Number of excluded classifications
integer array udg_PatrolGuardTypes // "Guard" types
integer array udg_PatrolExcludeTypes // Excluded types
unittype array pubExcludeClasses // Excluded classifications (not a UDG - must be set with Custom script)

// These are automatically assigned to the correct player based on start location
integer udg_PatrolBasesCount // Number of bases (start locs)
rect array udg_PatrolBaseRegions // Regions containing bases (start locs)
location array udg_PatrolBaseRallyPoints // Rally points for bases

integer udg_PatrolCampsCount // Number of camps
rect array udg_PatrolCampRegions // Regions for camps
location array udg_PatrolCampFacingPoints // Point units should face in camps
location array udg_PatrolCampRallyPoints // Rally points for camps

// Targets (camp index) are incremented each time a patrol is sent out
integer array udg_PatrolCampTargets // Next target for each camp - udg_PatrolCampsCount targets base
integer udg_PatrolBaseTarget // Next target for Patrol base

real udg_PatrolEncounterCheckTimeout // Timeout between checks for encounters
// Set either variables to 0 to use unit's current acquisition range
real udg_PatrolEncounterRange // Range at which Patrols can encounter Targets
real udg_PatrolEncounterGroupRange // Range at which to look for nearby patrols

real udg_PatrolRunnersSpeedMultiplier // Multiplier for movement speed of Runners
real udg_PatrolRunnersPingDuration // Duration of Runners ping
real udg_PatrolRunnersFirstPingDuration // Duration of first Runners ping
real udg_PatrolRunnersPingTimeout // Timeout between pings
string udg_PatrolRunnersEffect // Effect (model path) for Runners (overhead) - null (empty string) to disable

// Set to null ("No sound") to disable
sound udg_PatrolRunnersSound // Played when a patrol starts Running
sound udg_PatrolBaseAlertedSound // Played when an alerted patrol reaches base
sound udg_PatrolTargetAttacksSound // Played when Target player attacks Patrol player or enters its base

// This value can be used with the "Game - Value Of Real Variable" event to add additional triggers to the script
// -1: destroyed; 0: off; 1: on; +0.1: attack mode
// +0.01: Patrol running to base; +0.02: Patrol base alerted; +0.03: Patrol player attacked or base entered, by Target player
real udg_PatrolSystemState

Changelog
v1.2.1
- Script now turned off when Patrol player dies
- Attack Mode now turned off when Target player dies
- Use unit current acquisition range if rngEncounter <= 0 and/or rngEncounterGroup <= 0
- Base region assigning now based on player start location
- Camp Leaving now requeued if camp still full
- Added check for idle patrols in Patrol base (that lost their orders after getting stuck)
- Added several checks for units being alive
- Misc fixes/improvements
- Switched to generic map

v1.2.0
- Separated ConfigPatrol() into ApplyPatrolSettings() and ConfigPatrolScript()
- When disabling script, Enter Base and Enter Camps triggers will now remain enabled until no units are patrolling (unless forced)
- When DestroyPatrolScript fails, AutoDestruct is now turned on and script disabled
- Improved/fixed AutoDestruct behaviour
- Fixed a bug when changing PatrolSystemState
- Replaced Enter Camps trigger array with a single trigger
- Replaced Camp arrays with a struct array
- Replaced TriggerGetCampIndex() with a hashtable
- Fixed some minor leaks
- General code optimization/refactoring

v1.1.2
- Replaced Runners unit and effect arrays with a hashtable
- Some refactoring regarding ^, removed some redundancy
- Fixed trigger for dying patrols
- Misc small fixes/improvements
- PatrolAttackToggle() renamed to TogglePatrolAttack()
- PatrolScriptToggle() renamed to TogglePatrolScript()
- PatrolConfig() renamed to ConfigPatrol()
- PatrolScriptDestroy() renamed to DestroyPatrolScript()

v1.1.1 (fix)
- Fixed leaks (nulled agents)

v1.1.1
- More flexible configuration
- Only units visible to patrols can alert
- Attack mode enabled when plrTarget attacks plrPatrol or enters its base
- Added sound for ^
- Check if base alerted sound is playing before playing
- Initial value set for sound UDGs ("No sound")
- udg_PatrolSystemState: second decimal now reflects alert state

v1.1.0
- Uploaded

v1.0.1
- Used in Exodus of the Horde (loktar's edit) (Mission 3)

v1.0.0
- Thread
Previews
Contents

Patrol System v1.2.1 (Map)

  1. loktar

    loktar

    Joined:
    Nov 2, 2004
    Messages:
    715
    Resources:
    25
    Models:
    3
    Icons:
    16
    Packs:
    1
    Tools:
    2
    Spells:
    2
    Tutorials:
    1
    Resources:
    25
    I didn't null any local handles, is this actually needed to prevent leaks?
     
  2. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,179
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Yes, nulling some local handles (actually agents) is needed. You might take a look at chapter about reference leaks here Memory Leaks.
     
  3. loktar

    loktar

    Joined:
    Nov 2, 2004
    Messages:
    715
    Resources:
    25
    Models:
    3
    Icons:
    16
    Packs:
    1
    Tools:
    2
    Spells:
    2
    Tutorials:
    1
    Resources:
    25
    Does that include function arguments? Or only locals?
    They aren't mentioned in that thread, so probably not?
     
  4. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,179
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Yeh, you're right that is's not needed for function arguments. :) Hope it won't be needed at all some day.
     
  5. loktar

    loktar

    Joined:
    Nov 2, 2004
    Messages:
    715
    Resources:
    25
    Models:
    3
    Icons:
    16
    Packs:
    1
    Tools:
    2
    Spells:
    2
    Tutorials:
    1
    Resources:
    25
    Cool, thanks. Map is updated.