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 haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. Let your favorite entries duke it out in the 15th Techtree Contest Poll.
    Dismiss Notice
  5. Weave light to take you to your highest hopes - the 6th Special Effect Contest is here!
    Dismiss Notice
  6. 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.

Trigger Viewer

Disarm System.w3x
Variables
Disarm System
CREDITS
IMPORT MANUAL
Disarm Manual
Disarm Config
Disarm System
Disarm Loop
Requirements
Unit Indexer
TestMap
Opening Message
A
X
Applying Examples
Footman Strike
Paladin Strike
Paladin Spell
State Examples
Disarm Starts Damage
Disarm Loop Damage
Disarm End Damage
Enter map-specific custom script code below. This text will be included in the map script after variables are declared and before any trigger code.

		
Name Type Is Array Initial Value
DisarmAbility abilcode No
DisarmAttachment string No
DisarmCounter integer No
DisarmDuration real No
DisarmDurationIsFrozen boolean Yes
DisarmDurationStack boolean No
DisarmDurationStackBoolean boolean Yes
DisarmDurRemain real Yes
DisarmedUnit unit No
DisarmEffect string No
DisarmGroup group No
DisarmLoop real No
DisarmLoopTrigger trigger No
DisarmSFX effect Yes
DisarmSource unit No
DisarmSourceUnit unit Yes
DisarmState real No
DisarmTrigger trigger No
DisarmUnitValue integer No
IsUnitDisarmed boolean Yes
UDex integer No
UDexGen integer No
UDexNext integer Yes
UDexPrev integer Yes
UDexRecycle integer No
UDexUnits unit Yes
UDexWasted integer No
UnitIndexerEnabled boolean No
UnitIndexEvent real No
UnitIndexLock integer Yes
Systems :
Bribe : Unit Indexer

Inspiration :
unkn0wn_d3str0y3r

Reviewers :
IcemanBo
Preference :
Make sure "Automatically creates Unknown Variables when pasting trigger data" is ticked on

Object Editor :
Copy and Paste "Disarm Ability" to your map

Trigger Editor :
Copy and Paste "Disarm System" folder to your map
Set the variables in the "Disarm Config" to the correct values
Configure the system using the instructions in the "Disarm Manual"
If it's still not enough, look at the Example folder on the test map for actual usage
Disarm Manual
  Events
  Conditions
  Actions
    -------- Below are the available variables that needs to be modified by user to use the system --------
    -------- Check "Applying Examples" for more information --------
    -------- The affected unit --------
    Set VariableSet DisarmedUnit = (Last created unit)
    -------- The source --------
    Set VariableSet DisarmSource = (Last created unit)
    -------- Duration of disarm to target --------
    Set VariableSet DisarmDuration = 0.00
    -------- File path for SFX on affected unit, needs DisarmAttachment to be placed on unit's body properly --------
    Set VariableSet DisarmEffect =
    -------- Location of SFX attachment --------
    Set VariableSet DisarmAttachment =
    -------- If this set to true, the duration will stack else it will overrides (the highest one will take place) --------
    -------- e.g1 : a unit has 3 non-stack second duration, then another unit gives a new registration --------
    -------- the new registration is stack and has 2 second, this means the affected unit now take 3 + 2 = 5 seconds --------
    -------- e.g2 : a unit has 3 stack second duration, then another unit gives a new registration --------
    -------- the new registration is non-stack and has 2 second, this means the affected unit now take 3 seconds (as the newest one doesn't stack and has less duration) --------
    Set VariableSet DisarmDurationStack = False
    -------- ======================================== --------
    -------- WARNING --------
    -------- Due to limitation with the current script for SFX (1 SFX per unit) and only the latest one will take effect --------
    -------- ======================================== --------
    -------- BASIC USAGE --------
    -------- ======================================== --------
    -------- Below are available states that players can get from a disarmed unit --------
    Set VariableSet DisarmState = 0.00
    -------- A unit takes disarm = 1.00 (triggers when units are registered to the system) --------
    -------- Disarm in progress = 1.50 (remember to calculate that this run 32 times in 1 second) --------
    -------- Disarm ends = 2.00 (triggers on death or duration ends) --------
    -------- To avoid taking wrong units, it's advised to use buffs on disarmed units that takes additional effects so they can be used as filters --------
    -------- To attain correct unit on disarm end, it's recommended that it has a disarm buff that has a very slight longer duration than the disarm itself (0.04-0.10) --------
    -------- There's another method involving detect the disarm --------
    Set VariableSet IsUnitDisarmed[(Custom value of DisarmedUnit)] = False
    -------- The above variable will return true (the system does the checking automatically) and you can use this for detections --------
    -------- Check in condition of a trigger for it's status, and the value will be used --------
    -------- Check Applying Examples folder, the Paladin Spell trigger for more information --------
    -------- ======================================== --------
    -------- ADVANCED USAGE --------
    -------- ======================================== --------
    -------- Below is how to check for duration --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        DisarmDurRemain[(Custom value of DisarmedUnit)] Less than 3.00
      Then - Actions
        -------- ACTIONS HERE --------
      Else - Actions
    -------- To modify duration, we do as seen below, the below example sets the duration to 10 seconds --------
    Set VariableSet DisarmDurRemain[(Custom value of DisarmedUnit)] = 10.00
    -------- Duration can be frozen, which halt it from decreased by the loop, do as shown below to apply it --------
    Set VariableSet DisarmDurationIsFrozen[(Custom value of DisarmedUnit)] = True
    -------- However, make sure to release the freeze else it will be permanent, a frozen duration can be released with below technique --------
    Set VariableSet DisarmDurationIsFrozen[(Custom value of DisarmedUnit)] = False
    -------- A "frozen" duration disarm is AUTOMATICALLY released when the disarmed unit dies --------
Disarm Config
  Events
    Map initialization
  Conditions
  Actions
    -------- ======================================== --------
    -------- This is the base ability to erase 'Attack' ability --------
    -------- Copy the one from sample map and paste it on your map then set this variable to that ability --------
    Set VariableSet DisarmAbility = Disarm Ability
    -------- Use variable below with Run Trigger function to run the system --------
    -------- Set this variable to Disarm System trigger --------
    Set VariableSet DisarmTrigger = Disarm_System <gen>
    -------- Set this to Disarm Loop trigger --------
    Set VariableSet DisarmLoopTrigger = Disarm_Loop <gen>
    -------- END OF DETAIL - BELOW ARE CORE PART --------
    -------- This is the loop value, 32 execution per second --------
    Custom script: set udg_DisarmLoop = 0.03125
    Trigger - Add to DisarmLoopTrigger the event (Every DisarmLoop seconds of game time)
Disarm System
  Events
  Conditions
  Actions
    -------- Start the system --------
    Set VariableSet DisarmUnitValue = (Custom value of DisarmedUnit)
    Set VariableSet DisarmDurationStackBoolean[DisarmUnitValue] = DisarmDurationStack
    Set VariableSet DisarmSourceUnit[DisarmUnitValue] = DisarmSource
    -------- Duration input --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        DisarmDurationStackBoolean[DisarmUnitValue] Equal to True
      Then - Actions
        Set VariableSet DisarmDurRemain[DisarmUnitValue] = (DisarmDurRemain[DisarmUnitValue] + DisarmDuration)
      Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            DisarmDurRemain[DisarmUnitValue] Less than or equal to DisarmDuration
          Then - Actions
            Set VariableSet DisarmDurRemain[DisarmUnitValue] = DisarmDuration
          Else - Actions
    -------- Check state of current units, is it already disarmed or not --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        IsUnitDisarmed[DisarmUnitValue] Equal to False
      Then - Actions
        -------- Apply effect if doesn't applied yet --------
        Set VariableSet IsUnitDisarmed[DisarmUnitValue] = True
        Unit - Add DisarmAbility to DisarmedUnit
        Special Effect - Create a special effect attached to the DisarmAttachment of DisarmedUnit using DisarmEffect
        Set VariableSet DisarmSFX[DisarmUnitValue] = (Last created special effect)
        -------- Insert to system loop --------
        Unit Group - Add DisarmedUnit to DisarmGroup
        Set VariableSet DisarmCounter = (DisarmCounter + 1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            DisarmCounter Equal to 1
          Then - Actions
            Trigger - Turn on DisarmLoopTrigger
          Else - Actions
      Else - Actions
        Special Effect - Destroy DisarmSFX[DisarmUnitValue]
        Special Effect - Create a special effect attached to the DisarmAttachment of DisarmedUnit using DisarmEffect
        Set VariableSet DisarmSFX[DisarmUnitValue] = (Last created special effect)
    -------- Return State --------
    Set VariableSet DisarmState = 1.00
    Set VariableSet DisarmState = 0.00
Disarm Loop
  Events
  Conditions
  Actions
    Unit Group - Pick every unit in DisarmGroup and do (Actions)
      Loop - Actions
        Set VariableSet DisarmedUnit = (Picked unit)
        Set VariableSet DisarmUnitValue = (Custom value of DisarmedUnit)
        -------- Return state --------
        Set VariableSet DisarmState = 1.50
        Set VariableSet DisarmState = 0.00
        -------- Duration check --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            DisarmDurationIsFrozen[DisarmUnitValue] Equal to False
          Then - Actions
            Set VariableSet DisarmDurRemain[DisarmUnitValue] = (DisarmDurRemain[DisarmUnitValue] - DisarmLoop)
          Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            Or - Any (Conditions) are true
              Conditions
                DisarmDurRemain[DisarmUnitValue] Less than 0.00
                (DisarmedUnit is dead) Equal to True
          Then - Actions
            -------- Return state --------
            Set VariableSet DisarmState = 2.00
            Set VariableSet DisarmState = 0.00
            -------- Unregister --------
            Set VariableSet IsUnitDisarmed[DisarmUnitValue] = False
            Set VariableSet DisarmDurationIsFrozen[DisarmUnitValue] = False
            Set VariableSet DisarmDurRemain[DisarmUnitValue] = 0.00
            Set VariableSet DisarmSourceUnit[DisarmUnitValue] = No unit
            Special Effect - Destroy DisarmSFX[DisarmUnitValue]
            Unit - Remove DisarmAbility from DisarmedUnit
            Unit Group - Remove DisarmedUnit from DisarmGroup.
            Set VariableSet DisarmCounter = (DisarmCounter - 1)
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                DisarmCounter Equal to 0
              Then - Actions
                Trigger - Turn off DisarmLoopTrigger
              Else - Actions
          Else - Actions
Unit Indexer gives you an array-safe (1-8190) custom value for units, eliminating the need for hashtables to store unit-specific data.
Just use "Set MyArrayData[(Custom value of Unit)] = (Some data)".
--------
If you want to get the unit assigned to an index (reverse lookup) use "UDexUnits[(Index)]".
--------
If you want to detect when an index is created or when it is released, use "UnitIndexEvent Equal to 1.00" (created) or "UnitIndexEvent Equal to 2.00" (released). The index being created/released is called "UDex".
--------
You can enable/disable Unit Indexer to protect some of your undesirable units from being indexed like this:

Trigger - Turn off Unit Indexer <gen>
Unit - Create 1 Dummy for (Triggering player) at TempPoint facing 0.00 degrees
Trigger - Turn on Unit Indexer <gen>
--------
If you want to use a Map Initialization trigger that uses custom value of units, to make sure that UnitIndexer initializes first, use the event "UnitIndexEvent Equal to 3.00". Otherwise the custom value of units may be zero.
--------
Advanced:
--------
If you want to lock the index of a unit, use "Set UnitIndexLock[(Index)] = (UnitIndexLock[(Index)] + 1)". This will prevent the index from being recycled. If you want to unlock it and allow it to be recycled, run the Unit Indexer <gen> trigger.

Note: Make sure if you add a lock that you will eventually remove the lock, otherwise the index will never be recycled.
Unit Indexer
  Events
    Map initialization
  Conditions
  Actions
    Custom script: call ExecuteFunc("InitializeUnitIndexer")
    Custom script: endfunction
    Custom script:
    Custom script: function ClearUnitIndex takes nothing returns nothing
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Custom value of UDexUnits[UDex]) Equal to 0
      Then - Actions
        Set VariableSet UnitIndexLock[UDex] = (UnitIndexLock[UDex] - 1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            UnitIndexLock[UDex] Equal to 0
          Then - Actions
            Set VariableSet UDexNext[UDexPrev[UDex]] = UDexNext[UDex]
            Set VariableSet UDexPrev[UDexNext[UDex]] = UDexPrev[UDex]
            Set VariableSet UDexPrev[UDex] = 0
            Set VariableSet UnitIndexEvent = 0.00
            Set VariableSet UnitIndexEvent = 2.00
            Set VariableSet UnitIndexEvent = 0.00
            Set VariableSet UDexUnits[UDex] = No unit
            Set VariableSet UDexNext[UDex] = UDexRecycle
            Set VariableSet UDexRecycle = UDex
          Else - Actions
      Else - Actions
    Custom script: endfunction
    Custom script:
    Custom script: function IndexUnit takes nothing returns boolean
    Custom script: local integer pdex = udg_UDex
    Custom script: local integer ndex
    -------- - --------
    -------- You can customize the following block - if conditions are false the (Matching unit) won't be indexed. --------
    -------- - --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        UnitIndexerEnabled Equal to True
        (Custom value of (Matching unit)) Equal to 0
      Then - Actions
        Set VariableSet UDexWasted = (UDexWasted + 1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            UDexWasted Equal to 15
          Then - Actions
            Set VariableSet UDexWasted = 0
            Set VariableSet UDex = UDexNext[0]
            Custom script: loop
            Custom script: exitwhen udg_UDex == 0
            Custom script: set ndex = udg_UDexNext[udg_UDex]
            Custom script: call ClearUnitIndex()
            Custom script: set udg_UDex = ndex
            Custom script: endloop
          Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            UDexRecycle Equal to 0
          Then - Actions
            Set VariableSet UDex = (UDexGen + 1)
            Set VariableSet UDexGen = UDex
          Else - Actions
            Set VariableSet UDex = UDexRecycle
            Set VariableSet UDexRecycle = UDexNext[UDex]
        Set VariableSet UDexUnits[UDex] = (Matching unit)
        Unit - Set the custom value of UDexUnits[UDex] to UDex
        Set VariableSet UDexPrev[UDexNext[0]] = UDex
        Set VariableSet UDexNext[UDex] = UDexNext[0]
        Set VariableSet UDexNext[0] = UDex
        Set VariableSet UnitIndexLock[UDex] = 1
        Set VariableSet UnitIndexEvent = 0.00
        Set VariableSet UnitIndexEvent = 1.00
        Set VariableSet UnitIndexEvent = 0.00
        Custom script: set udg_UDex = pdex
      Else - Actions
    Custom script: return false
    Custom script: endfunction
    Custom script:
    Custom script: function InitializeUnitIndexer takes nothing returns nothing
    Custom script: local integer i = 16
    Custom script: local boolexpr b = Filter(function IndexUnit)
    Custom script: local region re = CreateRegion()
    Custom script: local trigger t = GetTriggeringTrigger()
    Custom script: local rect r = GetWorldBounds()
    Custom script: call RegionAddRect(re, r)
    Custom script: call TriggerRegisterEnterRegion(t, re, b)
    Custom script: call TriggerClearActions(t)
    Custom script: call TriggerAddAction(t, function ClearUnitIndex)
    Set VariableSet UnitIndexerEnabled = True
    Custom script: loop
    Custom script: set i = i - 1
    Custom script: call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, Player(i), b)
    Custom script: exitwhen i == 0
    Custom script: endloop
    Custom script: call RemoveRect(r)
    Custom script: set re = null
    Custom script: set r = null
    Custom script: set t = null
    Custom script: set b = null
    Set VariableSet UnitIndexEvent = 3.00
    Set VariableSet UnitIndexEvent = 0.00
Opening Message
  Events
    Time - Elapsed game time is 0.00 seconds
    Player - Player 1 (Red) types a chat message containing help (stringnoformat) as An exact match
  Conditions
  Actions
    Cinematic - Clear the screen of text messages for (All players).
    Game - Display to (All players) for 30.00 seconds the text: Welcome to Disarm System test map!In this test map, Footman attacks Disarms for 1 second, Paladin attacks for 3 seconds, Paladin Spells Disarms all units in 512 range (even himself) for 10 seconds, also the spell will deal 1000 damage to already disarmed units.Unit that is disarmed takes 1000 damage then takes 320 damage per second and takes 500 damage when disarm ends, with 3000 damage bonus for ghouls. Paladin Spells duration stacks while others don't.Type a to spawn a ghoul to testType x to kill all spawned ghoulsType help to show this message again
A
  Events
    Player - Player 1 (Red) types a chat message containing a (stringnoformat) as An exact match
  Conditions
  Actions
    Unit - Create (Random integer number between 1 and 3).Ghoul for Player 2 (Blue) at (Center of (Playable map area)) facing Default building facing degrees
X
  Events
    Player - Player 1 (Red) types a chat message containing x (stringnoformat) as An exact match
  Conditions
  Actions
    Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 2 (Blue)) and do (Actions)
      Loop - Actions
        Unit - Kill (Picked unit)
Footman Strike
  Events
    Unit - A unit Is attacked
  Conditions
    (Unit-type of (Attacking unit)) Equal to Footman
  Actions
    Set VariableSet DisarmDuration = 1.00
    Set VariableSet DisarmEffect = Abilities\Weapons\FlyingMachine\FlyingMachineImpact.mdl
    Set VariableSet DisarmAttachment = origin
    Set VariableSet DisarmedUnit = (Triggering unit)
    Set VariableSet DisarmSource = (Attacking unit)
    Set VariableSet DisarmDurationStack = False
    Trigger - Run DisarmTrigger (ignoring conditions)
Paladin Strike
  Events
    Unit - A unit Is attacked
  Conditions
    (Unit-type of (Attacking unit)) Equal to Paladin
  Actions
    Set VariableSet DisarmDuration = 3.00
    Set VariableSet DisarmEffect = Abilities\Spells\Human\InnerFire\InnerFireTarget.mdl
    Set VariableSet DisarmAttachment = origin
    Set VariableSet DisarmedUnit = (Triggering unit)
    Set VariableSet DisarmSource = (Attacking unit)
    Set VariableSet DisarmDurationStack = False
    Trigger - Run DisarmTrigger (ignoring conditions)
Paladin Spell
  Events
    Unit - A unit Starts the effect of an ability
  Conditions
    (Unit-type of (Triggering unit)) Equal to Paladin
  Actions
    Set VariableSet DisarmDuration = 10.00
    Set VariableSet DisarmEffect = Abilities\Spells\Human\InnerFire\InnerFireTarget.mdl
    Set VariableSet DisarmAttachment = origin
    Set VariableSet DisarmDurationStack = True
    Set VariableSet DisarmSource = (Triggering unit)
    Unit Group - Pick every unit in (Units within 512 of (Position of (Triggering unit)).) and do (Actions)
      Loop - Actions
        Set VariableSet DisarmedUnit = (Picked unit)
        Trigger - Run DisarmTrigger (ignoring conditions)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            IsUnitDisarmed[(Custom value of (Picked unit))] Equal to True
          Then - Actions
            Unit - Cause (Triggering unit) to damage (Picked unit), dealing 1000.00 damage of attack type Spells and damage type Normal
          Else - Actions
Disarm Starts Damage
  Events
    Game - DisarmState becomes Equal to 1.00
  Conditions
  Actions
    Unit - Cause DisarmSourceUnit[DisarmUnitValue] to damage DisarmedUnit, dealing 1000.00 damage of attack type Spells and damage type Normal
Disarm Loop Damage
  Events
    Game - DisarmState becomes Equal to 1.50
  Conditions
  Actions
    Unit - Cause DisarmSourceUnit[DisarmUnitValue] to damage DisarmedUnit, dealing 10.00 damage of attack type Spells and damage type Normal
Disarm End Damage
  Events
    Game - DisarmState becomes Equal to 2.00
  Conditions
  Actions
    Unit - Cause DisarmSourceUnit[DisarmUnitValue] to damage DisarmedUnit, dealing 500.00 damage of attack type Spells and damage type Normal
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of DisarmedUnit) Equal to Ghoul
      Then - Actions
        Unit - Cause DisarmSourceUnit[DisarmUnitValue] to damage DisarmedUnit, dealing 3000.00 damage of attack type Spells and damage type Normal
        Special Effect - Create a special effect attached to the origin (attachpoint) of DisarmedUnit using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
        Special Effect - Destroy (Last created special effect)
      Else - Actions