Warcraft III: MapsModelsSkinsIconsSpellsToolsTutorials
WC3 JASS: Code SnippetsJASS and vJASS Spells and SystemsJass Tutorials
Chat @Discord

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - AGD

Pages: [1]
1
Codes & Snippets / BoolexprUtils
« on: November 08, 2016, 08:04:14 AM »
True and False BooleanExpressions

Credits goes to Vexorian for the first idea.


Vjass version
Code: jass  [Select]
  1. library BoolexprUtils
  2.  
  3.     globals
  4.         boolexpr BOOLEXPR_TRUE
  5.         boolexpr BOOLEXPR_FALSE
  6.     endglobals
  7.  
  8.     private module Init
  9.  
  10.         private static method filterTrue takes nothing returns boolean
  11.             return true
  12.         endmethod
  13.  
  14.         private static method filterFalse takes nothing returns boolean
  15.             return false
  16.         endmethod
  17.  
  18.         private static method onInit takes nothing returns nothing
  19.             set BOOLEXPR_TRUE = Filter(function thistype.filterTrue)
  20.             set BOOLEXPR_TRUE = Filter(function thistype.filterFalse)
  21.         endmethod
  22.  
  23.     endmodule
  24.  
  25.     private struct S extends array
  26.         implement Init
  27.     endstruct
  28.  
  29. endlibrary

Zinc version
Code: jass  [Select]
  1. //! zinc
  2. library BoolexprUtils {
  3.  
  4.     public boolexpr BOOLEXPR_TRUE, BOOLEXPR_FALSE;
  5.  
  6.     module Init {
  7.         static method onInit() {
  8.             BOOLEXPR_TRUE = Filter(function() -> boolean {return true;});
  9.             BOOLEXPR_FALSE = Filter(function() -> boolean {return false;});
  10.         }
  11.     }
  12.  
  13.     struct S extends array {module Init;}
  14.  
  15. }
  16. //! endzinc

2
Codes & Snippets / Re: UnitRecycler
« on: November 05, 2016, 09:25:50 AM »
Oh, nice to know that you already have conceived the concept a long time ago =D Though the two resources have a bit different approach.
Btw, mine does not account for summoned units and structures yet.

3
Codes & Snippets / UnitRecycler
« on: November 02, 2016, 03:36:36 AM »
A useful library which allows you to recycle units (even dead ones, but they must leave a corpse), avoiding yet another permanent 0.04kb memory leak for each future CreateUnit() call.


Script
Code: jass  [Select]
  1. library UnitRecycler /* v1.3b
  2.  
  3.  
  4.     |=============|
  5.     | Author: AGD |
  6.     |=============|
  7.  
  8.     */requires /*
  9.  
  10.     */ReviveUnit                        /*  http://www.hiveworkshop.com/threads/snippet-reviveunit.186696/
  11.     */UnitDex                           /*  http://www.hiveworkshop.com/threads/system-unitdex-unit-indexer.248209/
  12.     */optional Table                    /*  http://www.hiveworkshop.com/threads/snippet-new-table.188084/
  13.     */optional TimerUtils               /*  http://www.wc3c.net/showthread.php?t=101322
  14.     */optional RegisterPlayerUnitEvent  /*  http://www.hiveworkshop.com/threads/snippet-registerevent-pack.250266/
  15.  
  16.     This system is important because CreateUnit() is one of the most processor-intensive function in
  17.     the game and there are reports that even after they are removed, they still leave some bit of memory
  18.     consumption (0.04 KB) on the RAM. Therefore it would be very helpful if you can minimize unit
  19.     creation or so. This system also allows you to recycle dead units to avoid permanent 0.04 KB memory
  20.     leak for each future CreateUnit() call.                                                                 */
  21.  
  22. //! novjass
  23.  
  24.     [Credits]
  25.         Aniki - For suggesting ideas on further improvements
  26.  
  27.  
  28.     |-----|
  29.     | API |
  30.     |-----|
  31.  
  32.         function GetRecycledUnit takes player owner, integer rawCode, real x, real y, real facing returns unit/*
  33.             - Returns unit of specified ID from the stock of recycled units. If there's none in the stock that
  34.               matched the specified unit's rawcode, it will create a new unit instead
  35.             - Returns null if the rawcode's unit-type is a hero or non-existent
  36.  
  37.       */function GetRecycledUnitEx takes player owner, integer rawCode, real x, real y, real facing returns unit/*
  38.             - Works similar to GetRecycledUnit() except that if the input rawcode's unit-type is a hero, it will
  39.               be created via CreateUnit() instead
  40.             - You can use this as an alternative to CreateUnit()
  41.  
  42.       */function RecycleUnit takes unit u returns boolean/*
  43.             - Recycles the specified unit and returns a boolean value depending on the success of the operation
  44.             - Does nothing to hero units
  45.  
  46.       */function RecycleUnitEx takes unit u returns boolean/*
  47.             - Works similar to RecycleUnit() except that if <u> is not recyclable, it will be removed via
  48.               RemoveUnit() instead
  49.             - You can use this as an alternative to RemoveUnit()
  50.  
  51.       */function RecycleUnitDelayed takes unit u, real delay returns nothing/*
  52.             - Recycles the specified unit after <delay> seconds
  53.  
  54.       */function RecycleUnitDelayedEx takes unit u, real delay returns nothing/*
  55.             - Works similar to RecycleUnitDelayed() except that it calls RecycleUnitEx() instead of RecycleUnit()
  56.  
  57.       */function UnitAddToStock takes integer rawCode returns boolean/*
  58.             - Creates a unit of type ID and adds it to the stock of recycled units then returns a boolean value
  59.               depending on the success of the operation
  60.  
  61. *///! endnovjass
  62.  
  63.     //CONFIGURATION SECTION
  64.  
  65.  
  66.     globals
  67.  
  68. /*      The owner of the stocked/recycled units
  69. */      private constant player OWNER               = Player(15)
  70.  
  71. /*      Determines if dead units will be automatically recycled
  72.         after a delay designated by the <constant function
  73.         DeathTime below>
  74. */      private constant boolean AUTO_RECYCLE_DEAD  = true
  75.  
  76. /*      Error debug message prefix
  77. */      private constant string ERROR_PREFIX        = "|CFFFF0000Operation Failed: "
  78.  
  79.     endglobals
  80.  
  81.     /* The delay before dead units will be recycled in case AUTO_RECYCLE_DEAD == true */
  82.     static if AUTO_RECYCLE_DEAD then
  83.         private constant function DeathTime takes unit u returns real
  84.             /*if <condition> then
  85.                   return someValue
  86.               elseif <condition> then
  87.                   return someValue
  88.               endif                 */
  89.             return 8.00
  90.         endfunction
  91.     endif
  92.  
  93.     /* When recycling a unit back to the stock, these resets will be applied to the
  94.        unit. You can add more actions to this or you can delete this textmacro if you
  95.        don't need it.                                                                       */
  96.         //! textmacro_once UNIT_RECYCLER_RESET
  97.             call SetUnitScale(u, 1, 0, 0)
  98.             call SetUnitVertexColor(u, 255, 255, 255, 255)
  99.             call SetUnitFlyHeight(u, GetUnitDefaultFlyHeight(u), 0)
  100.         //! endtextmacro
  101.  
  102.  
  103.     //END OF CONFIGURATION
  104.  
  105.     /*==== Do not do changes below this line if you're not so sure on what you're doing ====*/
  106.     native UnitAlive takes unit u returns boolean
  107.  
  108.     globals
  109.         private keyword S
  110.         private integer count = 0
  111.         private real unitCampX
  112.         private real unitCampY
  113.         private integer array stack
  114.         private boolean array stacked
  115.     endglobals
  116.  
  117.     private function GetIndex takes integer rawCode returns integer
  118.         static if LIBRARY_Table then
  119.             local integer i = S.table.integer[rawCode]
  120.             if i == 0 then
  121.                 set count = count + 1
  122.                 set S.table.integer[rawCode] = count
  123.                 set i = count
  124.             endif
  125.         else
  126.             local integer i = LoadInteger(S.hash, -1, rawCode)
  127.             if i == 0 then
  128.                 set count = count + 1
  129.                 call SaveInteger(S.hash, -1, rawCode, count)
  130.                 set i = count
  131.             endif
  132.         endif
  133.         return i
  134.     endfunction
  135.  
  136.     static if DEBUG_MODE then
  137.         private function Debug takes string msg returns nothing
  138.             call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "|CFFFFCC00[Unit Recycler]|R " + msg)
  139.         endfunction
  140.     endif
  141.  
  142.     function GetRecycledUnit takes player owner, integer rawCode, real x, real y, real facing returns unit
  143.         local integer i
  144.         if not IsHeroUnitId(rawCode) then
  145.             set i = GetIndex(rawCode)
  146.             if stack[i] == 0 then
  147.                 set bj_lastCreatedUnit = CreateUnit(owner, rawCode, x, y, facing)
  148.                 debug call Debug(GetUnitName(bj_lastCreatedUnit) + " stock is empty, creating new " + GetUnitName(bj_lastCreatedUnit))
  149.             else
  150.                 static if LIBRARY_Table then
  151.                     set bj_lastCreatedUnit = S.hash[i].unit[stack[i]]
  152.                 else
  153.                     set bj_lastCreatedUnit = LoadUnitHandle(S.hash, i, stack[i])
  154.                 endif
  155.                 set stacked[GetUnitId(bj_lastCreatedUnit)] = false
  156.                 call PauseUnit(bj_lastCreatedUnit, false)
  157.                 call SetUnitOwner(bj_lastCreatedUnit, owner, true)
  158.                 call SetUnitPosition(bj_lastCreatedUnit, x, y)
  159.                 call SetUnitFacing(bj_lastCreatedUnit, facing)
  160.                 set stack[i] = stack[i] - 1
  161.                 debug call Debug("Retrieving " + GetUnitName(bj_lastCreatedUnit) + " from stock")
  162.             endif
  163.             debug if bj_lastCreatedUnit == null then
  164.                 debug call Debug(ERROR_PREFIX + "Specified unit-type does not exist")
  165.             debug endif
  166.         else
  167.             debug call Debug(ERROR_PREFIX + "Attemp to retrieve a hero unit")
  168.             return null
  169.         endif
  170.         return bj_lastCreatedUnit
  171.     endfunction
  172.  
  173.     function GetRecycledUnitEx takes player owner, integer rawCode, real x, real y, real facing returns unit
  174.         if not IsHeroUnitId(rawCode) then
  175.             return GetRecycledUnit(owner, rawCode, x, y, facing)
  176.         endif
  177.         debug call Debug("Cannot retrieve a hero unit, creating new unit")
  178.         return CreateUnit(owner, rawCode, x, y, facing)
  179.     endfunction
  180.  
  181.     function RecycleUnit takes unit u returns boolean
  182.         local integer rawCode = GetUnitTypeId(u)
  183.         local integer uDex = GetUnitId(u)
  184.         local integer i
  185.         if not IsHeroUnitId(rawCode) and not stacked[uDex] and u != null then
  186.             set i = GetIndex(rawCode)
  187.             if not UnitAlive(u) and not ReviveUnit(u) then
  188.                 debug call Debug(ERROR_PREFIX + "Unable to recycle unit: Unable to revive dead unit")
  189.                 return false
  190.             endif
  191.             set stacked[uDex] = true
  192.             call PauseUnit(u, true)
  193.             call SetUnitOwner(u, OWNER, true)
  194.             call SetUnitX(u, unitCampX)
  195.             call SetUnitY(u, unitCampY)
  196.             call SetUnitFacing(u, 270)
  197.             call SetWidgetLife(u, GetUnitState(u, UNIT_STATE_MAX_LIFE))
  198.             call SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MAX_MANA))
  199.             //! runtextmacro optional UNIT_RECYCLER_RESET()
  200.             set stack[i] = stack[i] + 1
  201.             static if LIBRARY_Table then
  202.                 set S.hash[i].unit[stack[i]] = u
  203.             else
  204.                 call SaveUnitHandle(S.hash, i, stack[i], u)
  205.             endif
  206.             debug call Debug("Successfully recycled " + GetUnitName(u))
  207.             return true
  208.         debug else
  209.             debug if stacked[uDex] then
  210.                 debug call Debug(ERROR_PREFIX + "Attempt to recycle an already recycled unit")
  211.             debug elseif u == null then
  212.                 debug call Debug(ERROR_PREFIX + "Attempt to recycle a null unit")
  213.             debug else
  214.                 debug call Debug(ERROR_PREFIX + "Attempt to recycle a hero unit")
  215.             debug endif
  216.         endif
  217.         return false
  218.     endfunction
  219.  
  220.     function RecycleUnitEx takes unit u returns boolean
  221.         if not RecycleUnit(u) then
  222.             call RemoveUnit(u)
  223.             debug call Debug("Cannot recycle the specified unit, removing unit")
  224.             return false
  225.         endif
  226.         return true
  227.     endfunction
  228.  
  229.     //! textmacro DELAYED_RECYCLE_TYPE takes EX
  230.     private function RecycleTimer$EX$ takes nothing returns nothing
  231.         local timer t = GetExpiredTimer()
  232.         static if LIBRARY_TimerUtils then
  233.             call RecycleUnit$EX$(GetUnitById(GetTimerData(t)))
  234.             call ReleaseTimer(t)
  235.         else
  236.             local integer key = GetHandleId(t)
  237.             static if LIBRARY_Table then
  238.                 call RecycleUnit$EX$(S.hash[0].unit[key])
  239.                 call S.hash[0].remove(key)
  240.             else
  241.                 call RecycleUnit$EX$(LoadUnitHandle(S.hash, 0, key))
  242.                 call RemoveSavedHandle(S.hash, 0, key)
  243.             endif
  244.             call DestroyTimer(t)
  245.         endif
  246.         set t = null
  247.     endfunction
  248.  
  249.     function RecycleUnitDelayed$EX$ takes unit u, real delay returns nothing
  250.         static if LIBRARY_TimerUtils then
  251.             call TimerStart(NewTimerEx(GetUnitId(u)), delay, false, function RecycleTimer$EX$)
  252.         else
  253.             local timer t = CreateTimer()
  254.             static if LIBRARY_Table then
  255.                 set S.hash[0].unit[GetHandleId(t)] = u
  256.             else
  257.                 call SaveUnitHandle(S.hash, 0, GetHandleId(t), u)
  258.             endif
  259.             call TimerStart(t, delay, false, function RecycleTimer$EX$)
  260.             set t = null
  261.         endif
  262.     endfunction
  263.     //! endtextmacro
  264.  
  265.     //! runtextmacro DELAYED_RECYCLE_TYPE("")
  266.     //! runtextmacro DELAYED_RECYCLE_TYPE("Ex")
  267.  
  268.     function UnitAddToStock takes integer rawCode returns boolean
  269.         local unit u
  270.         local integer i
  271.         if not IsHeroUnitId(rawCode) then
  272.             set u = CreateUnit(OWNER, rawCode, unitCampX, unitCampY, 270)
  273.             if u != null then
  274.                 set i = GetIndex(rawCode)
  275.                 call SetUnitX(u, unitCampX)
  276.                 call SetUnitY(u, unitCampY)
  277.                 call PauseUnit(u, true)
  278.                 set stacked[GetUnitId(u)] = true
  279.                 set stack[i] = stack[i] + 1
  280.                 static if LIBRARY_Table then
  281.                     set S.hash[i].unit[stack[i]] = u
  282.                 else
  283.                     call SaveUnitHandle(S.hash, i, stack[i], u)
  284.                 endif
  285.                 debug call Debug("Adding " + GetUnitName(u) + " to stock")
  286.                 return true
  287.             debug else
  288.                 debug call Debug(ERROR_PREFIX + "Attemp to stock a null unit")
  289.             endif
  290.             set u = null
  291.         debug else
  292.             debug call Debug(ERROR_PREFIX + "Attemp to stock a hero unit")
  293.         endif
  294.         return false
  295.     endfunction
  296.  
  297.     static if AUTO_RECYCLE_DEAD then
  298.         private function OnDeath takes nothing returns nothing
  299.             local unit u = GetTriggerUnit()
  300.             if not IsUnitType(u, UNIT_TYPE_HERO) and not IsUnitType(u, UNIT_TYPE_STRUCTURE) then
  301.                 call RecycleUnitDelayed(u, DeathTime(u))
  302.             endif
  303.             set u = null
  304.         endfunction
  305.     endif
  306.  
  307.     private module Init
  308.  
  309.         static if LIBRARY_Table then
  310.             static TableArray hash
  311.             static Table table
  312.         else
  313.             static hashtable hash = InitHashtable()
  314.         endif
  315.  
  316.         private static method onInit takes nothing returns nothing
  317.             local rect bounds = GetWorldBounds()
  318.             static if AUTO_RECYCLE_DEAD then
  319.                 static if LIBRARY_RegisterPlayerUnitEvent then
  320.                     static if RPUE_VERSION_NEW then
  321.                         call RegisterAnyPlayerUnitEvent(EVENT_PLAYER_UNIT_DEATH, function OnDeath)
  322.                     else
  323.                         call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_DEATH, function OnDeath)
  324.                     endif
  325.                 else
  326.                     local trigger t = CreateTrigger()
  327.                     local code c = function OnDeath
  328.                     local integer i = 16
  329.                     loop
  330.                         set i = i - 1
  331.                         call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_DEATH, null)
  332.                         exitwhen i == 0
  333.                     endloop
  334.                     call TriggerAddCondition(t, Filter(c))
  335.                 endif
  336.             endif
  337.             static if LIBRARY_Table then
  338.                 set hash = TableArray[0x2000]
  339.                 set table = Table.create()
  340.             endif
  341.             // Hides recycled units at the top of the map beyond reach of the camera
  342.             set unitCampX = 0.00
  343.             set unitCampY = GetRectMaxY(bounds) + 1000.00
  344.             call RemoveRect(bounds)
  345.             set bounds = null
  346.         endmethod
  347.  
  348.     endmodule
  349.  
  350.     private struct S extends array
  351.         implement Init
  352.     endstruct
  353.  
  354.  
  355. endlibrary

4
Codes & Snippets / Re: Resource Preloader
« on: October 28, 2016, 01:03:52 AM »
UPDATED


- Made Table optional
- Added UnitRecycler as an optional requirement
- Upon calling PreloadUnit(), if the unit is not a hero and UnitRecycler is found, the unit will be added to the unit stock instead. Otherwise, it goes with normal preloading.
- dummy unit's movement is disabled to prevent possible game crash.
- You can now preload at any time during the game instead of only during the map initialization
- Significantly optimized the code
- Removed the unnecessary custom function for checking preload duplicates
- Added Table to the library requirements
- Preloading does not anymore happen in a single phase at the GUI Map Initialization
- Resources are now preloaded at the instant you call the preload function
- Other changes

5
Updated to v1.3

- Added some optional library requirements including TimerUtils, GroupUtils, PlayerUtils
- Simplified some script sections
- Added the API for registering an illusion death event
- Fixed a bug in the previous version where illusions' death effect visibility are not properly managed
- Updated the demo spell
- Added a new API GetIllusionElapsedTime() for getting the elapsed time of an illusion
- Shortened the function AdjustTimedLife
- Removed some unnecessary extra return values when in debug mode in the public functions
- Some other code restructuring and some other fixes

6
Codes & Snippets / Random Iteration
« on: September 04, 2016, 09:16:22 AM »
This snippet is a replacement to the BJ function GetRandomSubGroup with the advantage of being able to directly enumerate random number of units in a group instead of creating another subgroup of an already existing group. Notice that this is not the same as GroupEnumUnitsInRangeCounted in which case the enumerated units are not random but is based on which units are picked first.


Code: jass  [Select]
  1. library RandomIteration
  2.  
  3.     globals
  4.         private group tempGroup = CreateGroup()
  5.         private integer unitCount
  6.     endglobals
  7.  
  8.     private function EnumUnits takes nothing returns boolean
  9.         call GroupAddUnit(tempGroup, GetFilterUnit())
  10.         set unitCount = unitCount + 1
  11.         return false
  12.     endfunction
  13.  
  14.     function EnumRandomUnitsInRangeCounted takes group g, real x, real y, real radius, integer limit returns nothing
  15.         local real chance
  16.         local unit u
  17.         call GroupEnumUnitsInRange(g, x, y, radius, Filter(function EnumUnits))
  18.         set chance = I2R(limit)/I2R(unitCount)
  19.         loop
  20.             set u = FirstOfGroup(tempGroup)
  21.             exitwhen u == null or limit == 0
  22.             call GroupRemoveUnit(tempGroup, u)
  23.             if GetRandomReal(0, 1) <= chance then
  24.                 call GroupAddUnit(g, u)
  25.                 set limit = limit - 1
  26.             endif
  27.         endloop
  28.         set u = null
  29.     endfunction
  30.  
  31.     function EnumRandomUnitsInRectCounted takes group g, rect r, integer limit returns nothing
  32.         local real chance
  33.         local unit u
  34.         call GroupEnumUnitsInRect(g, r, Filter(function EnumUnits))
  35.         set chance = I2R(limit)/I2R(unitCount)
  36.         loop
  37.             set u = FirstOfGroup(tempGroup)
  38.             exitwhen u == null or limit == 0
  39.             call GroupRemoveUnit(tempGroup, u)
  40.             if GetRandomReal(0, 1) <= chance then
  41.                 call GroupAddUnit(g, u)
  42.                 set limit = limit - 1
  43.             endif
  44.         endloop
  45.         set u = null
  46.     endfunction
  47.  
  48. endlibrary

7
Codes & Snippets / InvulnerabilityChecker
« on: September 04, 2016, 12:09:44 AM »
A simple snippet used to check if a unit is invulnerable. False positives from mana shields are also accounted for.

Code: jass  [Select]
  1. library InvulnerabilityChecker
  2.  
  3.     function CheckInvulnerability takes unit u returns boolean
  4.         local real origHP = GetWidgetLife(u)
  5.         local real origMP = GetUnitState(u, UNIT_STATE_MANA)
  6.         local boolean check
  7.         call UnitDamageTarget(u, u, 0.01, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL, null)
  8.         set check = GetWidgetLife(u) == origHP and GetUnitState(u, UNIT_STATE_LIFE) == origMP
  9.         call SetWidgetLife(u, origHP)
  10.         call SetUnitState(u, UNIT_STATE_MANA, origMP)
  11.         return check
  12.     endfunction
  13.  
  14. endlibrary

8
Codes & Snippets / TimerIndexer v1.2
« on: September 03, 2016, 10:49:40 PM »
Useful system especially in making an MUI spell which uses timers. Instead of saving the spell data in a hashtable with the handleid of the timer as the parent key, you can just use normal arrays with the timerid as the index. This also allows you to pass custom data (integer) to timers.

System Features:
  • Indexed timers (Array safe, 1-8190 but can also be customized to be 8190+) NEW
  • Timer custom data (integer) attachment [NEW]
  • Timer double free protection
  • Automatic timer replacement (Useful safety feature which automatically replaces timers belonging to this system with a timer of the same timerid and handleid when destroyed)
Timer Indexer v1.2
Code: jass  [Select]
  1. library TimerIndexer //v1.2
  2.  
  3.  
  4. //! novjass
  5.      ________________
  6.     |                |
  7.     | Written by AGD |
  8.     |________________|
  9.  
  10.  
  11.     |=====|
  12.     | API |
  13.     |=====|
  14.  
  15.         function GetTimer takes nothing returns timer/*
  16.         - Allocates a new usable timer from the stock
  17.  
  18.       */function GetTimerEx takes integer i returns timer/*
  19.         - Retrieves a new usable timer from the stock and initializes
  20.           its custom integer data to <i>
  21.  
  22.       */function GetTimerById takes integer i returns timer/*
  23.         - Retrieves a timer of ID <i> from the stock but returns
  24.           null if that timer is not free
  25.  
  26.       */function FreeTimer takes timer t returns nothing/*
  27.         - Releases the timer back to the stock
  28.  
  29.       */function GetTimerId takes timer t returns integer/*
  30.         - Returns the index of the timer
  31.  
  32.       */function GetTimerData takes timer t returns integer/*
  33.         - Returns the custom integer data attached to the timer
  34.  
  35.       */function SetTimerData takes timer t, integer i returns nothing/*
  36.         - Attaches a custom integer data to the timer
  37.  
  38.       */function IsTimerStocked takes timer t returns boolean/*
  39.         - Checks if the timer is free
  40.  
  41.       */function GetTimerFlag takes timer t returns boolean/*
  42.         - Checks if the timer is included in this system's timer stock
  43.  
  44. *///! endnovjass
  45.  
  46.     globals
  47. /*
  48.         Determines the total number of timers on the stock          */
  49.         private constant integer TIMER_STOCK_SIZE = 8190
  50.  
  51. /*      Determines the delay of timer replacement in case a
  52.         timer belonging to the stock is accidentally destroyed
  53.         Note that this value should be greater than the time
  54.         delay of the handleId recycling which is approximately
  55.         0.0050000 ( It's not advised to change this anyway )        */
  56.         private constant real REPLACE_DELAY = 0.0050001
  57.  
  58.     endglobals
  59.  
  60.     //================================================================
  61.  
  62.     globals
  63.         private timer array T[TIMER_STOCK_SIZE]
  64.         private timer tempTimer
  65.         private integer START_HANDLE
  66.         private integer destroyed
  67.         private integer current
  68.         private integer pitStop
  69.         private integer this
  70.         private integer array recycler[TIMER_STOCK_SIZE]
  71.         private integer array data[TIMER_STOCK_SIZE]
  72.         private boolean dont = false
  73.         private boolean array isTimerStocked[TIMER_STOCK_SIZE]
  74.     endglobals
  75.  
  76.     static if DEBUG_MODE then
  77.         private function Debug takes string msg returns nothing
  78.             call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "|CFFFFCC00[Timer Indexer]|R : " + msg)
  79.         endfunction
  80.     endif
  81.  
  82.     function GetTimerId takes timer t returns integer
  83.         return GetHandleId(t) - START_HANDLE
  84.     endfunction
  85.  
  86.     function GetTimerData takes timer t returns integer
  87.         return data[GetTimerId(t)]
  88.     endfunction
  89.  
  90.     function SetTimerData takes timer t, integer i returns nothing
  91.         set data[GetTimerId(t)] = i
  92.     endfunction
  93.  
  94.     function IsTimerStocked takes timer t returns boolean
  95.         return isTimerStocked[GetTimerId(t)]
  96.     endfunction
  97.  
  98.     function GetTimerFlag takes timer t returns boolean
  99.         return GetTimerId(t) > 0 and GetTimerId(t) <= TIMER_STOCK_SIZE
  100.     endfunction
  101.  
  102.     function GetTimer takes nothing returns timer
  103.         set this = recycler[0]
  104.         set recycler[0] = recycler[this]
  105.         if isTimerStocked[this] then
  106.             set isTimerStocked[this] = false
  107.             debug call Debug("Retrieving Timer [" + I2S(this) + "] from stock")
  108.             return T[this]
  109.         endif
  110.         debug call Debug("ERROR: No free timers available, creating a temporary timer.")
  111.         return CreateTimer()
  112.     endfunction
  113.  
  114.     function GetTimerById takes integer i returns timer
  115.         if isTimerStocked[i] then
  116.             debug call Debug("Retrieving Timer [" + I2S(i) + "] from stock")
  117.             return T[i]
  118.         endif
  119.         debug if i < 1 or i > TIMER_STOCK_SIZE then
  120.             debug call Debug("ERROR: Specified timer ID is out of bounds")
  121.         debug else
  122.             debug call Debug("ERROR: Timer [" + I2S(i) + "] is not free")
  123.         debug endif
  124.         return null
  125.     endfunction
  126.  
  127.     function GetTimerEx takes integer i returns timer
  128.         set tempTimer = GetTimer()
  129.         set data[GetTimerId(tempTimer)] = i
  130.         return tempTimer
  131.     endfunction
  132.  
  133.     function FreeTimer takes timer t returns nothing
  134.         local integer i = GetTimerId(t)
  135.         if not isTimerStocked[i] and GetTimerFlag(t) then
  136.             call TimerStart(t, 0, false, null)
  137.             set isTimerStocked[i] = true
  138.             set data[i] = 0
  139.             set recycler[i] = recycler[0]
  140.             set recycler[0] = i
  141.             debug call Debug("Releasing Timer [" + I2S(i) + "] back to the stock")
  142.         elseif not GetTimerFlag(t) then
  143.             call DestroyTimer(t)
  144.             debug call Debug("ERROR: Freed timer does not belong to the stack, destroying timer")
  145.         debug else
  146.             debug call Debug("ERROR: Attempt to double-free Timer [" + I2S(i) + "]")
  147.         endif
  148.     endfunction
  149.  
  150.     private function Replace takes nothing returns nothing
  151.         local integer i = destroyed
  152.         set T[i] = CreateTimer()
  153.         if GetTimerId(T[i]) == i then
  154.             set isTimerStocked[i] = true
  155.             debug call Debug("Timer [" + I2S(GetTimerId(T[i])) + "] was replaced")
  156.         else
  157.             debug call Debug("ERROR: Unable to replace Timer [" + I2S(i) + "]")
  158.             set dont = true
  159.             call DestroyTimer(T[i])
  160.             set dont = false
  161.             set T[i] = null
  162.         endif
  163.         call FreeTimer(GetExpiredTimer())
  164.     endfunction
  165.  
  166.     private function OnDestroy takes timer t returns nothing
  167.         local integer i = GetTimerId(t)
  168.         local trigger trig
  169.         if not dont and GetTimerFlag(t) then
  170.             set T[i] = null
  171.             set isTimerStocked[i] = false
  172.             set destroyed = i
  173.             call DestroyTimer(null)
  174.             call TimerStart(GetTimer(), REPLACE_DELAY, false, function Replace)
  175.             debug call Debug("WARNING: Timer [" + I2S(i) + "] got destroyed!")
  176.             set trig = null
  177.         endif
  178.     endfunction
  179.  
  180.     hook DestroyTimer OnDestroy
  181.  
  182.     private function Delegate takes nothing returns nothing
  183.         local integer i = current
  184.         loop
  185.             set i = i + 1
  186.             set T[i] = CreateTimer()
  187.             set isTimerStocked[i] = true
  188.             set recycler[i] = i + 1
  189.             if i == TIMER_STOCK_SIZE then
  190.                 debug call Debug("Total number of timers created: " + I2S(i))
  191.                 debug call Debug("Timer stock count is complete")
  192.                 return
  193.             endif
  194.             exitwhen i == current + pitStop
  195.         endloop
  196.         set current = i
  197.         call Delegate.evaluate()
  198.     endfunction
  199.  
  200.     private module M
  201.         private static method onInit takes nothing returns nothing
  202.             local integer i = 1
  203.             if TIMER_STOCK_SIZE <= 8190 then
  204.                 set pitStop = TIMER_STOCK_SIZE
  205.             else
  206.                 set pitStop = 1000
  207.             endif
  208.             set recycler[TIMER_STOCK_SIZE] = 0
  209.             set recycler[0] = 1
  210.             set recycler[1] = 2
  211.             set T[i] = CreateTimer()
  212.             set START_HANDLE = GetHandleId(T[i]) - 1
  213.             set isTimerStocked[i] = true
  214.             loop
  215.                 set i = i + 1
  216.                 set T[i] = CreateTimer()
  217.                 set isTimerStocked[i] = true
  218.                 set recycler[i] = i + 1
  219.                 exitwhen i == pitStop
  220.             endloop
  221.             set current = i
  222.             if TIMER_STOCK_SIZE > current then
  223.                 call Delegate.evaluate()
  224.             debug else
  225.                 debug call Debug("Total number of timers created: " + I2S(i))
  226.                 debug call Debug("Timer stock count is complete")
  227.             endif
  228.         endmethod
  229.     endmodule
  230.  
  231.     private struct S extends array
  232.         implement M
  233.     endstruct
  234.  
  235. endlibrary


Changelogs
v1.2
- Added more functionalities such as attaching custom timer data, now the system comprises all but is not limited to the main functionalities of Vexorian's TimerUtils
- Optimized the code especially in the part in updating the timer stack
- Fixed some bugs

v1.1
- Added the possibility for users to configure the timer stock size above 8190
- Some fixes

v1.0
- First Release

9
Codes & Snippets / Resource Preloader
« on: September 03, 2016, 10:32:39 PM »
Useful snippet for preloading your map resources and avoiding duplicates in preloading.

Code: jass  [Select]
  1. library ResourcePreloader /*v1.4
  2.  
  3.  
  4.     */uses /*
  5.  
  6.     */BJObjectId            /* http://www.hiveworkshop.com/threads/bjobjectid.287128/
  7.     */optional Table        /* http://www.hiveworkshop.com/threads/snippet-new-table.188084/
  8.     */optional UnitRecycler /* http://www.hiveworkshop.com/threads/snippet-unit-recycler.286701/
  9.  
  10.     *///! novjass
  11.  
  12.     |================|
  13.     | Written by AGD |
  14.     |================|
  15.  
  16.         [CREDITS]
  17. /*          IcemanBo - for suggesting further improvements
  18.             Silvenon - for the sound preloading method                            */
  19.  
  20.  
  21.         |-----|
  22.         | API |
  23.         |-----|
  24.  
  25.             function PreloadUnit takes integer rawcode returns nothing/*
  26.                 - Assigns a certain type of unit to be preloaded
  27.  
  28.           */function PreloadItem takes integer rawcode returns nothing/*
  29.                 - Assigns a certain type of item to be preloaded
  30.  
  31.           */function PreloadAbility takes integer rawcode returns nothing/*
  32.                 - Assigns a certain type of ability to be preloaded
  33.  
  34.           */function PreloadEffect takes string modelPath returns nothing/*
  35.                 - Assigns a certain type of effect to be preloaded
  36.  
  37.           */function PreloadSound takes string soundPath returns nothing/*
  38.                 - Assigns a certain type of sound to be preloaded
  39.  
  40.  
  41.           */function PreloadUnitEx takes integer start, integer end returns nothing/*
  42.                 - Assigns a range of unit rawcodes to be preloaded
  43.  
  44.           */function PreloadItemEx takes integer start, integer end returns nothing/*
  45.                 - Assigns a range of item rawcodes to be preloaded
  46.  
  47.           */function PreloadAbilityEx takes integer start, integer end returns nothing/*
  48.                 - Assigns a range of ability rawcodes to be preloaded
  49.  
  50.  
  51.     *///! endnovjass
  52.  
  53.     //========================================================================================================//
  54.     /* Do not try to change below this line if you're not so sure on what you're doing. Unless you want to
  55.        change, check, or study the core of the system, it is not advised that you scroll any further.         */
  56.     //========================================================================================================//
  57.  
  58.     private keyword S
  59.  
  60.  
  61.     static if DEBUG_MODE then
  62.         private function Debug takes string msg returns nothing
  63.             call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "|CFFFFCC00[Resource Preloader]|R  " + msg)
  64.         endfunction
  65.     endif
  66.  
  67.     //============================================== TextMacros ==============================================//
  68.  
  69.     //! textmacro ASSIGN takes NAME, ARG, TYPE, INDEX, I
  70.     function Preload$NAME$ takes $ARG$ what returns nothing
  71.         static if LIBRARY_Table then
  72.             if not S.tb[$I$].boolean[$INDEX$] then
  73.                 set S.tb[$I$].boolean[$INDEX$] = true
  74.                 call Do$NAME$Preload(what)
  75.             debug else
  76.                 debug call Debug("|CFFFF0000Operation Cancelled :|R Entered $TYPE$ data was already preloaded")
  77.             endif
  78.         else
  79.             if not LoadBoolean(S.tb, $I$, $INDEX$) then
  80.                 call SaveBoolean(S.tb, $I$, $INDEX$, true)
  81.                 call Do$NAME$Preload(what)
  82.             debug else
  83.                 debug call Debug("|CFFFF0000Operation Cancelled :|R Entered $TYPE$ data was already preloaded")
  84.             endif
  85.         endif
  86.     endfunction
  87.     //! endtextmacro
  88.  
  89.     //! textmacro ASSIGNWITHRANGE takes NAME
  90.     function Preload$NAME$Ex takes integer start, integer end returns nothing
  91.         local BJObjectId this = BJObjectId(start)
  92.         local BJObjectId last = BJObjectId(end)
  93.         loop
  94.             call Preload$NAME$(this)
  95.             exitwhen this == last
  96.             if this > last then
  97.                 set this = this.minus_1()
  98.             else
  99.                 set this = this.plus_1()
  100.             endif
  101.         endloop
  102.     endfunction
  103.     //! endtextmacro
  104.  
  105.     //========================================================================================================//
  106.  
  107.  
  108.     private function DoUnitPreload takes integer id returns nothing
  109.         static if LIBRARY_UnitRecycler then
  110.             call RecycleUnitEx(CreateUnit(Player(15), id, 0, 0, 0))
  111.         else
  112.             call RemoveUnit(CreateUnit(Player(15), id, 0, 0, 0))
  113.         endif
  114.     endfunction
  115.  
  116.     private function DoItemPreload takes integer id returns nothing
  117.         call RemoveItem(UnitAddItemById(S.dummy, id))
  118.     endfunction
  119.  
  120.     private function DoAbilityPreload takes integer id returns nothing
  121.         if UnitAddAbility(S.dummy, id) and UnitRemoveAbility(S.dummy, id) then
  122.         endif
  123.     endfunction
  124.  
  125.     private function DoEffectPreload takes string path returns nothing
  126.         call DestroyEffect(AddSpecialEffectTarget(path, S.dummy, "origin"))
  127.     endfunction
  128.  
  129.     private function DoSoundPreload takes string path returns nothing
  130.         local sound s = CreateSound(path, false, false, false, 10, 10, "")
  131.         call SetSoundVolume(s, 0)
  132.         call StartSound(s)
  133.         call KillSoundWhenDone(s)
  134.         set s = null
  135.     endfunction
  136.  
  137.     //! runtextmacro ASSIGN("Unit", "integer", "unit", "what", "0")
  138.     //! runtextmacro ASSIGN("Item", "integer", "item", "what", "1")
  139.     //! runtextmacro ASSIGN("Ability", "integer", "ability", "what", "2")
  140.     //! runtextmacro ASSIGN("Effect", "string", "effect", "StringHash(what)", "3")
  141.     //! runtextmacro ASSIGN("Sound", "string", "sound", "StringHash(what)", "4")
  142.  
  143.     //! runtextmacro ASSIGNWITHRANGE("Unit")
  144.     //! runtextmacro ASSIGNWITHRANGE("Item")
  145.     //! runtextmacro ASSIGNWITHRANGE("Ability")
  146.  
  147.     //========================================================================================================//
  148.  
  149.     private module Init
  150.         private static method onInit takes nothing returns nothing
  151.             local rect bounds = GetWorldBounds()
  152.             static if LIBRARY_Table then
  153.                 set tb = TableArray[5]
  154.             endif
  155.             set dummy = CreateUnit(Player(15), 'hpea', 0, 0, 0)
  156.             call UnitAddAbility(dummy, 'AInv')
  157.             call UnitAddAbility(dummy, 'Avul')
  158.             call UnitRemoveAbility(dummy, 'Amov')
  159.             call SetUnitY(dummy, GetRectMaxY(bounds) + 1000)
  160.             call RemoveRect(bounds)
  161.             set bounds = null
  162.         endmethod
  163.     endmodule
  164.  
  165.     private struct S extends array
  166.         static if LIBRARY_Table then
  167.             static TableArray tb
  168.         else
  169.             static hashtable tb = InitHashtable()
  170.         endif
  171.         static unit dummy
  172.         implement Init
  173.     endstruct
  174.  
  175.  
  176. endlibrary

10
Codes & Snippets / [Snippet] IsLineWalkable
« on: August 27, 2016, 10:29:10 PM »
This simple snippet allows you to check for the walkability of the terrain between two points.


Code: jass  [Select]
  1. library IsLineWalkable /*
  2.  
  3.     */uses /*
  4.  
  5.     */TerrainPathability /*
  6.           - http://www.wc3c.net/showthread.php?t=103862 */
  7.  
  8. //! novjass
  9.      ________________
  10.     |                |
  11.     | Written by AGD |
  12.     |________________|
  13.  
  14.  
  15.     |=====|
  16.     | API |
  17.     |=====|
  18.  
  19.         function IsLineWalkable takes real x1, real y1, real x2, real y2 returns boolean/*
  20.         - Checks if the line between points P1(x1, y1) and P2(x2, y2) does not contain any
  21.           any unwalkable coordinates including some doodads, cliffs, mapboundary, and other similar stuffs
  22.  
  23.       */function GetLastWalkableX takes nothing returns real/*
  24.         - Returns the value of the x-coordinate of the last walkable terrain when using IsLineWalkable
  25.  
  26.       */function GetLastWalkableY takes nothing returns real/*
  27.         - Returns the value of the y-coordinate of the last walkable terrain when using IsLineWalkable
  28.  
  29. *///! endnovjass
  30.  
  31.     globals
  32.         ///////////////////////////////////////////
  33.         // The path walkability check distance   //
  34.         // interval. Lower value increases       //
  35.         // precision but may cost performance.   //
  36.         // Suggested value limit (10.00 - 25.00) //
  37.         ///////////////////////////////////////////
  38.         private constant real checkInterval = 20.00
  39.     endglobals
  40.  
  41.     //==============================================================================
  42.  
  43.     globals
  44.         private real X
  45.         private real Y
  46.     endglobals
  47.  
  48.     function IsLineWalkable takes real x1, real y1, real x2, real y2 returns boolean
  49.         local real dx = x2 - x1
  50.         local real dy = y2 - y1
  51.         local real angle
  52.         local real x
  53.         local real y
  54.         if dx*dx + dy*dy < checkInterval*checkInterval then
  55.             if not IsTerrainWalkable(x2, y2) then
  56.                 set X = TerrainPathability_X
  57.                 set Y = TerrainPathability_Y
  58.                 return false
  59.             endif
  60.         else
  61.             set angle = Atan2(dy, dx)
  62.             set x = checkInterval*Cos(angle)
  63.             set y = checkInterval*Sin(angle)
  64.             loop
  65.                 set x1 = x1 + x
  66.                 set y1 = y1 + y
  67.                 exitwhen x1 > x2 or y1 > y2
  68.                 if not IsTerrainWalkable(x1, y1) then
  69.                     set X = TerrainPathability_X
  70.                     set Y = TerrainPathability_Y
  71.                     return false
  72.                 endif
  73.             endloop
  74.         endif
  75.         set X = TerrainPathability_X
  76.         set Y = TerrainPathability_Y
  77.         return true
  78.     endfunction
  79.  
  80.     function GetLastWalkableX takes nothing returns real
  81.         return X
  82.     endfunction
  83.  
  84.     function GetLastWalkableY takes nothing returns real
  85.         return Y
  86.     endfunction
  87.  
  88.  
  89. endlibrary

11
Codes & Snippets / LoopCode
« on: August 27, 2016, 10:51:21 AM »
LoopCode v1.3

This system allows you to register a code that will run every specified timeout. Note that this system only uses one timer for all registered codes. Therefore, codes with periods indivisible by 0.03125 doesn't run with a constant time interval. Although the difference will not exceed 0.03125, you probably don't want it to be that way. But this will not be much of a problem for codes with low frequency period such as those with timeouts greater than 2 seconds since the difference wouldn't be so noticeable.

In short, this works best for codes with timeout divisible by 0.03125 seconds.

Main Script
Code: jass  [Select]
  1. library LoopCode
  2.  
  3.  
  4.     //! novjass
  5.      ________________
  6.     |                |
  7.     | Written by AGD |
  8.     |________________|
  9.  
  10.     |=====|
  11.     | API |
  12.     |=====|
  13.  
  14.       function interface LoopCode takes nothing returns nothing/*
  15.         - Interface of functions to be registered in the loop
  16.  
  17.     */function RegisterLoopCode takes LoopCode c, real timeout returns boolean/*
  18.         - Registers a code to run every <timeout> seconds and returns a boolean value depending
  19.         on the success of the operation
  20.  
  21.     */function RemoveLoopCode takes LoopCode c returns boolean/*
  22.         - Unregisters a code from the loop and returns a boolean value depending
  23.         on the success of the operation
  24.  
  25.     */function SetCodeTimeout takes LoopCode c, real timeout returns boolean/*
  26.         - Sets a new loop timeout for a code
  27.  
  28.     *///! endnovjass
  29.  
  30.     //======================================================================================
  31.  
  32.     globals
  33.         private constant real TIMEOUT = 0.03125
  34.         private constant boolean AUTO_ADJUST = true
  35.     endglobals
  36.  
  37.     //======================================================================================
  38.  
  39.     globals
  40.         private LoopCode array codes
  41.         private timer Timer = CreateTimer()
  42.         private integer id = 0
  43.         private integer count = 0
  44.         private real array codeTimeout
  45.         private real array elapsed
  46.         private integer array index
  47.         private boolean array check
  48.     endglobals
  49.  
  50.     //======================================================================================
  51.  
  52.     function interface LoopCode takes nothing returns nothing
  53.  
  54.     static if DEBUG_MODE then
  55.         private function Debug takes string msg returns nothing
  56.             call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "|CFFFFCC00[LoopEvent] :|R" + msg)
  57.         endfunction
  58.     endif
  59.  
  60.     private function RunLoop takes nothing returns nothing
  61.         set id = 0
  62.         loop
  63.             set id = id + 1
  64.             set elapsed[id] = elapsed[id] + TIMEOUT
  65.             if elapsed[id] >= codeTimeout[id] then
  66.                 call codes[id].evaluate()
  67.                 set elapsed[id] = elapsed[id] - codeTimeout[id]
  68.             endif
  69.             exitwhen id == count
  70.         endloop
  71.     endfunction
  72.  
  73.     function RegisterLoopCode takes LoopCode c, real timeout returns boolean
  74.         static if AUTO_ADJUST then
  75.             if timeout < TIMEOUT then
  76.                 set timeout = TIMEOUT
  77.                 debug call Debug("Entered code execution timeout is less than the minimum value (" + R2S(TIMEOUT) + "), auto-adjusting timeout to (" + R2S(TIMEOUT) + ")")
  78.             endif
  79.         else
  80.             if timeout < TIMEOUT then
  81.                 debug call Debug("ERROR: Entered code execution timeout is less than the minimum value (" + R2S(TIMEOUT) + ")")
  82.                 return false
  83.             endif
  84.         endif
  85.         if not check[c] then
  86.             debug if timeout - (timeout/TIMEOUT)*TIMEOUT > 0.00 then
  87.                 debug call Debug("WARNING: Entered code timeout is not divisible by " + R2S(TIMEOUT) + ", this code's execution interval will not be even")
  88.             debug endif
  89.             set count = count + 1
  90.             set elapsed[count] = 0.00
  91.             set codeTimeout[count] = timeout
  92.             set codes[count] = c
  93.             set index[c] = count
  94.             set check[c] = true
  95.             if count == 1 then
  96.                 call TimerStart(Timer, TIMEOUT, true, function RunLoop)
  97.                 debug call Debug("There is one code instance registered, starting to run timer")
  98.             endif
  99.             return true
  100.         endif
  101.         debug call Debug("ERROR: Attempt to double register a code")
  102.         return false
  103.     endfunction
  104.  
  105.     function RemoveLoopCode takes LoopCode c returns boolean
  106.         local integer i = index[c]
  107.         if check[c] then
  108.             debug call Debug("Removing a code from the loop")
  109.             set check[c] = false
  110.             set index[codes[count]] = i
  111.             set codes[i] = codes[count]
  112.             set codeTimeout[i] = codeTimeout[count]
  113.             if id >= i then
  114.                 set id = id - 1
  115.             endif
  116.             set count = count - 1
  117.             if count == 0 then
  118.                 call TimerStart(Timer, 0, false, null)
  119.                 debug call Debug("There are no code instances running, stopping timer")
  120.             endif
  121.             return true
  122.         endif
  123.         debug call Debug("ERROR: Attempt to remove a null or an already removed code")
  124.         return false
  125.     endfunction
  126.  
  127.     function SetCodeTimeout takes LoopCode c, real timeout returns boolean
  128.         local integer i = index[c]
  129.         if check[c] then
  130.             static if AUTO_ADJUST then
  131.                 if codeTimeout[i] >= TIMEOUT then
  132.                     set codeTimeout[i] = timeout
  133.                 else
  134.                     set codeTimeout[i] = TIMEOUT
  135.                     debug call Debug("Entered code execution timeout is less than the minimum value (" + R2S(TIMEOUT) + "), auto-adjusting timeout to (" + R2S(TIMEOUT) + ")")
  136.                 endif
  137.                 return true
  138.             else
  139.                 if codeTimeout[i] >= TIMEOUT then
  140.                     set codeTimeout[i] = timeout
  141.                     return true
  142.                 endif
  143.                 debug call Debug("ERROR: Entered code execution timeout is less than the minimum value (" + R2S(TIMEOUT) + ")")
  144.                 return false
  145.             endif
  146.         endif
  147.         debug call Debug("ERROR: Specified code is not registered")
  148.         return false
  149.     endfunction
  150.  
  151.  
  152. endlibrary


Sample Script
Code: jass  [Select]
  1. scope MySpell initializer Init
  2.  
  3.     globals
  4.         private constant real TIMEOUT = 0.03125
  5.         private integer maxIndex = 0
  6.         private real array elapsed
  7.     endglobals
  8.  
  9.     private function Loop takes nothing returns nothing
  10.         local integer index = 0
  11.         loop
  12.             set index = index + 1
  13.             if elapsed < 10 then
  14.                 set elapsed[index] = elapsed[index] + TIMEOUT
  15.             else
  16.                 set elapsed[index] = elapsed[maxIndex]
  17.                 set maxIndex = maxIndex - 1
  18.                 set index = index - 1
  19.                 if maxIndex == 0 then
  20.                     call RemoveLoopCode(LoopCode.Loop)
  21.                 endif
  22.             endif
  23.             exitwhen index == maxIndex
  24.         endloop
  25.     endfunction
  26.  
  27.     private function OnCast takes nothing returns boolean
  28.         // Setup spell data and oncast effects
  29.         set maxIndex = maxIndex + 1
  30.         set elapsed[maxIndex] = 0.00
  31.         call RegisterLoopCode(LoopCode.Loop, TIMEOUT)
  32.         return false
  33.     endfunction
  34.  
  35.     private function Init takes nothing returns nothing
  36.         local trigger t = CreateTrigger()
  37.         call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
  38.         call TriggerAddCondition(t, FIlter(function OnCast))
  39.     endfunction
  40.  
  41. endscope


Changelogs
v1.3
- Fixed a minor error concerning the index of a registered code in the RunLoop not being decremented by 1 when a code is removed from the loop.

v1.2
- Replaced TriggerEvaluate() with .evaluate() through the use of function interface
- Added an option to the configuration whether or not the system will automatically adjust the code timeout in case the entered timeout is lesser than the minimum supported timeout
- Removed the requirement Table. Instead, uses arrays which were made possible through using interface functions as the index.

v1.1
- Fixed the bug regarding the incorrect unregistering and re-registering codes to the loop
- Uses a TableArray instead of two separate tables

v1.0
- Initial release

Feedback will be appreciated.

12
Quote
WElcome AGD to Blizzmod:

I'll try to get some time to check your system to give you some feedback. I've fixed some stuff in order to get a better presentation in the post.

HUGSS!!!
Thanks =) Btw, documentation was updated.

13
Categories: System, GUI, vJASS
Rating: 5
Image/screenshot:
Warcraft III spell resource
« Created: June 03, 2017, 11:20:28 PM by moyack »

Related Topics or Resources


ILLUSION EDITOR



This system provides users with helpful utilities with regards to creation of illusions as well as the manipulation of many of their aspects.
With this system, you can now create illusions of any type as easily as creating units. This even allows you to create permanent illusions.
Read the script header for more details.

Please give credits to the following people if you use this resource in your map.

Credits:
    - AGD (Author)
    - TriggerHappy (UnitDex)
    - Looking_For_Help (PDDS)
    - Bribe (table)
    - Magtheridon96 (RegisterPlayerUnitEvent)
    - Vexorian (TimerUtils)
    - Rising_Dusk (GroupUtils)
    - Alain.Mark (PlayerUtils)

Main Script
Code: jass  [Select]
  1. library IllusionEditor /*
  2.  
  3.  
  4.   */requires /*
  5.  
  6.   */UnitDex /*
  7.         http://www.hiveworkshop.com/threads/system-unitdex-unit-indexer.248209/
  8.  
  9.   */DamageEvent /*
  10.         http://www.hiveworkshop.com/threads/system-physical-damage-detection.228456/
  11.  
  12.   */Table /*
  13.         http://www.hiveworkshop.com/threads/snippet-new-table.188084/
  14.  
  15.   */optional RegisterPlayerUnitEvent /*
  16.         http://www.hiveworkshop.com/threads/snippet-registerplayerunitevent.203338/
  17.  
  18.   */optional TimerUtils /*
  19.         http://www.wc3c.net/showthread.php?p=1020244
  20.  
  21.   */optional GroupUtils /*
  22.         http://www.wc3c.net/showthread.php?t=104464
  23.  
  24.   */optional PlayerUtils /*
  25.         http://www.hiveworkshop.com/threads/snippet-playerutils.213620/
  26.  
  27.  
  28. *///! novjass
  29.  
  30.      _______________________
  31.     |                       |
  32.     | Illusion Editor v1.3  |
  33.     |    Written by AGD     |
  34.     |_______________________|
  35.  
  36. /*     This system gives you freedom and ease in creating illusions. With this, you
  37.      can now create illusions of any type as easily as creating units or make an
  38.      illusion copy from an already existing unit, with the ability to change many
  39.      of their aspects (such as duration, damage dealt, damage recieved, deathSFX,
  40.      and hero level) dynamically.
  41.  
  42.  
  43.      Hint:
  44.          - Use zero or any negative value for duration to make a permanent illusion
  45.          - Setting a hero illusion's level might cause a change to its proper name
  46.  
  47.      To Import:
  48.          - Copy all the neccessary Object Editor data or alternatively use the object merger
  49.          - Copy this trigger/trigger category together with the requirements
  50.          - Configure the configurable object rawcodes
  51. */
  52.     |=======|
  53.     |  API  |
  54.     |=======|
  55.  
  56.         function CreateIllusion takes player whichPlayer, integer ID, real dur, real damageDealt, real damageReceived, real x, real y, real angle returns unit/*
  57.         - Creates an illusion of type <ID>
  58.  
  59.       */function CopyUnit takes player whichPlayer, unit u, real dur, real damageDealt, real damageReceived, real x, real y, real angle returns unit/*
  60.         - Creates an illusion copy of a unit which possesses the same abilities and items as the original unit
  61.  
  62.       */function SetIllusionLevel takes unit u, integer level, boolean showEyeCandy returns boolean/*
  63.         - Sets the level of the illusion to a desired value and returns boolean value depending on the success of the operation
  64.           (Only works if the illusion is a hero and if it was created using this system)
  65.  
  66.       */function SetIllusionDuration takes unit u, real time returns boolean/*
  67.         - Sets the duration of the illusion and returns a boolean value depending on the success of the operation
  68.           (This only works for illusions created by this system)
  69.  
  70.       */function AddIllusionDuration takes unit u, real extraTime returns boolean/*
  71.         - Adds an extra duration to an illusion's timed life and returns a boolean value depending on the success of the operation
  72.           (This only works for illusions created by this system)
  73.  
  74.       */function SetIllusionDamageFactor takes unit u, real factor returns boolean/*
  75.         - Sets the damagedealt factor of the illusion and returns a boolean value depending on the success of the operation
  76.           (This only works for illusions created by this system)
  77.  
  78.       */function SetIllusionReceiveFactor takes unit u, real factor returns boolean/*
  79.         - Sets the damagereceivefactor of the illusion and returns a boolean value depending on the success of the operation
  80.           (This only works for illusions created by this system)
  81.  
  82.       */function ShowIllusionDeathEffect takes unit u, boolean flag returns boolean/*
  83.         - Sets the illusion's death animation ON/OFF and returns a boolean value depending on the success of the operation
  84.           (This only works for illusions created by this system)
  85.  
  86.       */function SetIllusionDeathEffect takes unit u, string model returns boolean/*
  87.         - Sets the death animation of the illusion and returns a boolean value depending on the success of the operation
  88.           (This only works for illusions created by this system)
  89.  
  90.       */function GetIllusionElapsedTime takes unit u returns real/*
  91.         - Returns the elapsed time of the illusion
  92.           (This will return 0 for illusions not created by this system)
  93.  
  94.       */function GetIllusionRemainingDuration takes unit u returns real/*
  95.         - Returns the remaining duration of the illusion
  96.           (This will return 0 for illusions not created by this system)
  97.  
  98.       */function GetIllusionTotalDuration takes unit u returns real/*
  99.         - Returns the duration of the illusion
  100.           (This will return 0 for illusions not created by this system)
  101.  
  102.       */function GetIllusionDamageFactor takes unit u returns real/*
  103.         - Returns the damagedealt factor of the illusion
  104.           (This will return 0 for illusions not created by this system)
  105.  
  106.       */function GetIllusionReceiveFactor takes unit u returns real/*
  107.         - Returns the damagereceive factor of the illusion
  108.           (This will return 0 for illusions not created by this system)
  109.  
  110.       */function GetLastIllusion takes nothing returns unit/*
  111.         - Returns the last illusion created using this system
  112.  
  113.       */function GetIllusionFlag takes unit u returns boolean/*
  114.         - Checks if the illusion is created by this system or not
  115.  
  116.       */function IllusionDeathEvent takes code c returns nothing/*
  117.         - Adds a code to run when an illusion created from this system dies
  118.  
  119.  
  120. *///! endnovjass
  121.  
  122.  
  123.     globals
  124.  
  125.         ///////////////////////////
  126.         // Configuration Section //
  127.         ///////////////////////////
  128.  
  129.         /////////////////////////////////////////////////////
  130.         // Rawcode of the item used for creating illusions //
  131.         /////////////////////////////////////////////////////
  132.         private constant integer ITEM_ID = 'I000'
  133.         /////////////////////////////////////////////////////
  134.         // Rawcode of the dummy caster                     //
  135.         /////////////////////////////////////////////////////
  136.         private constant integer DUMMY_ID = 'i001'
  137.         /////////////////////////////////////////////////////
  138.         // Illusion timed life check interval              //
  139.         /////////////////////////////////////////////////////
  140.         private constant real LOOP_INTERVAL = 0.03125
  141.         /////////////////////////////////////////////////////
  142.         // Synchronize this value with the duration of     //
  143.         // illusions produced by the the item in the       //
  144.         // object editor so that this system will be able  //
  145.         // to make the neccessary adjustments.             //
  146.         // It would be better to set this value to 3600    //
  147.         // which is the maximum duration you can put in    //
  148.         // the object editor. But always be reminded that  //
  149.         // everytime you change this value, change also    //
  150.         // that of the object editor's!                    //
  151.         /////////////////////////////////////////////////////
  152.         private constant real ITEM_DUR_LIMIT = 5.00
  153.         /////////////////////////////////////////////////////
  154.         // The remaining time of the illusion before it    //
  155.         // would be replaced with another one in case the  //
  156.         // desired duration of the illusion is greater     //
  157.         // than what the item could provide                //
  158.         /////////////////////////////////////////////////////
  159.         private constant real REPLACE_TIME_ALLOWANCE = 0.10
  160.         /////////////////////////////////////////////////////
  161.         // The default death animation of the illusions    //
  162.         /////////////////////////////////////////////////////
  163.         private constant string DEFAULT_DEATH_SFX = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl"
  164.         /////////////////////////////////////////////////////
  165.         // The owning player of the dummy unit             //
  166.         /////////////////////////////////////////////////////
  167.         private constant player DUMMY_OWNER = Player(15)
  168.         /////////////////////////////////////////////////////
  169.         // The prefix of the operation error message when  //
  170.         // debug mode is enabled                           //
  171.         /////////////////////////////////////////////////////
  172.         private constant string ERROR_PREFIX = "Operation Failed: "
  173.  
  174.         //////////////////////////
  175.         // End of Configuration //
  176.         //////////////////////////
  177.  
  178.     endglobals
  179.  
  180.  
  181.     //===== Do not change anything below this line if you're not so sure on what you're doing =====//
  182.     native UnitAlive takes unit u returns boolean
  183.  
  184.     private keyword S
  185.  
  186.     globals
  187.  
  188.         private HashTable hash
  189.         private trigger deathEvent      = CreateTrigger()
  190.         private trigger illuDeathTrig   = null
  191.         private integer index           = 0
  192.         private integer tempInt         = 0
  193.         private integer usedDeathEvent  = 0
  194.         private real illusionDeathEvent = 0.00
  195.         private unit illusion
  196.         private unit U
  197.         private unit dummyCaster
  198.         private item casterItem
  199.         private player localPlayer
  200.         private filterfunc deathHandler
  201.         private code durationUpdater
  202.  
  203.         // These variables are used to store unit specific data for each illusion created using this system
  204.         private integer array maxTargeterCount
  205.         private integer array order
  206.         private integer array orderType
  207.         private boolean array flag
  208.         private boolean array check
  209.         private boolean array showDeath
  210.         private real array targPointX
  211.         private real array targPointY
  212.         private unit array orderTarget
  213.         private real array elapsed
  214.         private real array duration
  215.         private real array damageFactor
  216.         private real array receiveFactor
  217.         private real array X
  218.         private real array Y
  219.         private real array facing
  220.         private player array owner
  221.         private string array deathSFX
  222.  
  223.     endglobals
  224.  
  225.     static if DEBUG_MODE then
  226.         private function Debug takes string msg returns nothing
  227.             call DisplayTimedTextToPlayer( localPlayer, 0, 0, 30, "|CFFFFCC00[Illusion Editor]|R  " + msg )
  228.         endfunction
  229.     endif
  230.  
  231.  
  232.     ///////////////////////////////////////////////////
  233.     // These three functions caches the order of the //
  234.     // expiring illusion units to be passed to their //
  235.     // replacements. Similarly when the expiring     //
  236.     // illusion is targeted with an order, the order //
  237.     // will be redirected to its replacement as well.//
  238.     ///////////////////////////////////////////////////
  239.     private function CacheTargetOrder takes nothing returns nothing
  240.         local unit u = GetOrderedUnit()
  241.         local unit t = GetOrderTargetUnit()
  242.         local integer i = GetUnitId( u )
  243.         local integer tDex = GetUnitId( t )
  244.         if check[i] then
  245.             set orderType[i] = 1
  246.             set orderTarget[i] = t
  247.         endif
  248.         if check[tDex] then
  249.             set order[i] = GetUnitCurrentOrder( u )
  250.             if not flag[i] then
  251.                 loop
  252.                     set maxTargeterCount[tDex] = maxTargeterCount[tDex] + 1
  253.                     if hash[tDex].unit[maxTargeterCount[tDex]] == null then
  254.                         set hash[tDex].unit[maxTargeterCount[tDex]] = u
  255.                         set flag[i] = true
  256.                         break
  257.                     endif
  258.                 endloop
  259.             endif
  260.         endif
  261.         set u = null
  262.         set t = null
  263.     endfunction
  264.  
  265.     private function CachePointOrder takes nothing returns nothing
  266.         local integer i = GetUnitId( GetOrderedUnit() )
  267.         set flag[i] = false
  268.         if check[i] then
  269.             set orderType[i] = 2
  270.             set targPointX[i] = GetOrderPointX()
  271.             set targPointY[i] = GetOrderPointY()
  272.         endif
  273.     endfunction
  274.  
  275.     private function CacheOrder takes nothing returns nothing
  276.         local integer i = GetUnitId( GetOrderedUnit() )
  277.         set flag[i] = false
  278.         if check[i] then
  279.             set orderType[i] = 3
  280.         endif
  281.     endfunction
  282.  
  283.  
  284.     ///////////////
  285.     // On Summon //
  286.     ///////////////
  287.     private function OnSummon takes nothing returns nothing
  288.         local timer t
  289.         local integer i
  290.         local integer uDex
  291.         if GetSummoningUnit() == dummyCaster then
  292.             set i = GetUnitId( dummyCaster )
  293.             set U = GetTriggerUnit()
  294.             set uDex = GetUnitId( U )
  295.             set check[uDex] = true
  296.             set showDeath[uDex] = true
  297.             set duration[uDex] = duration[i]
  298.             set damageFactor[uDex] = damageFactor[i]
  299.             set receiveFactor[uDex] = receiveFactor[i]
  300.             set owner[uDex] = owner[i]
  301.             set deathSFX[uDex] = DEFAULT_DEATH_SFX
  302.             set elapsed[uDex] = 0
  303.             set maxTargeterCount[uDex] = 0
  304.             static if LIBRARY_TimerUtils then
  305.                 set t = NewTimer()
  306.             else
  307.                 set t = CreateTimer()
  308.             endif
  309.             set hash[GetHandleId( t )].unit[0] = U
  310.             call TimerStart( t, LOOP_INTERVAL, true, durationUpdater )
  311.             call SetUnitOwner( U, owner[i], true )
  312.             call SetUnitFacing( U, facing[i] )
  313.             if IsUnitType( U, UNIT_TYPE_STRUCTURE ) then
  314.                 call SetUnitPosition( U, X[i], Y[i] )
  315.             else
  316.                 call SetUnitX( U, X[i] )
  317.                 call SetUnitY( U, Y[i] )
  318.             endif
  319.             call TriggerRegisterUnitStateEvent( deathEvent, U, UNIT_STATE_LIFE, LESS_THAN, UNIT_MIN_LIFE )
  320.             set t = null
  321.         endif
  322.     endfunction
  323.  
  324.  
  325.     //! textmacro CREATOR takes FUNC, TAKE, X, TARGET
  326.     private function $FUNC$ takes player whichPlayer, $TAKE$, real dur, real damageDealt, real damageReceived, real x, real y, real angle returns unit
  327.         local integer i = GetUnitId( dummyCaster )
  328.         $X$local unit tempUnit = CreateUnit( DUMMY_OWNER, ID, x, y, angle )
  329.         if dur < 0 then
  330.             set dur = 0
  331.         endif
  332.         if damageDealt < 0 then
  333.             set damageDealt = 0
  334.         endif
  335.         if damageReceived < 0 then
  336.             set damageReceived = 0
  337.         endif
  338.         set X[i] = x
  339.         set Y[i] = y
  340.         set duration[i] = dur
  341.         set damageFactor[i] = damageDealt
  342.         set receiveFactor[i] = damageReceived
  343.         set facing[i] = angle
  344.         set owner[i] = whichPlayer
  345.         call UnitUseItemTarget( dummyCaster, casterItem, $TARGET$ )
  346.         $X$call RemoveUnit( tempUnit )
  347.         $X$set tempUnit = null
  348.         return U
  349.     endfunction
  350.     //! endtextmacro
  351.     //! runtextmacro CREATOR( "Create", "integer ID", "", "tempUnit" )
  352.     //! runtextmacro CREATOR( "Copy", "unit u", "//", "u" )
  353.  
  354.  
  355.     /////////////////////////////////////////////////
  356.     // This function controls the duration of the  //
  357.     // illusions as well as replacing them in case //
  358.     // their hardcoded lifetime expires before     //
  359.     // meeting the duration desired for them       //
  360.     /////////////////////////////////////////////////
  361.     private function AdjustTimedLife takes nothing returns nothing
  362.         local timer t      = GetExpiredTimer()
  363.         local unit u       = hash[GetHandleId( t )].unit[0]
  364.         local integer i    = GetUnitId( u )
  365.         local integer lastOrder
  366.         local unit new
  367.         local real toAdd
  368.         if UnitAlive( u ) and u != null then
  369.             set elapsed[i] = elapsed[i] + LOOP_INTERVAL
  370.             if duration[i] < ITEM_DUR_LIMIT and ( ( duration[i] > 0 and elapsed[i] >= duration[i] ) or duration[i] < 0.00 ) then
  371.                 call hash.remove( GetHandleId( t ) )
  372.                 call RemoveUnit( u )
  373.                 static if LIBRARY_TimerUtils then
  374.                     call ReleaseTimer( t )
  375.                 else
  376.                     call DestroyTimer( t )
  377.                 endif
  378.             elseif elapsed[i] >= ITEM_DUR_LIMIT - REPLACE_TIME_ALLOWANCE then
  379.                 set toAdd = duration[i] - ( ITEM_DUR_LIMIT - REPLACE_TIME_ALLOWANCE )
  380.                 if toAdd < 0 then
  381.                     set toAdd = 0
  382.                 endif
  383.                 set lastOrder = GetUnitCurrentOrder( u )
  384.                 set new = Copy( owner[i], u, toAdd, damageFactor[i], receiveFactor[i], GetUnitX( u ), GetUnitY( u ), GetUnitFacing( u ) )
  385.                 //! textmacro REDIRECTDATA takes KEY, NEWLIFE, NEWMANA
  386.                 call ShowUnit( u, false )
  387.                 call SetWidgetLife( new, $NEWLIFE$ )
  388.                 call SetUnitState( new, UNIT_STATE_MANA, $NEWMANA$ )
  389.                 set index = 0
  390.                 loop
  391.                     set index = index + 1
  392.                     set U = hash[$KEY$].unit[index]
  393.                     set tempInt = GetUnitId( U )
  394.                     if U != null and flag[tempInt] then
  395.                         set flag[tempInt] = false
  396.                         call IssueTargetOrderById( U, order[tempInt], new )
  397.                     endif
  398.                     exitwhen index > maxTargeterCount[i]
  399.                 endloop
  400.                 if orderType[i] == 1 then
  401.                     call IssueTargetOrderById( new, lastOrder, orderTarget[i] )
  402.                 elseif orderType[i] == 2 then
  403.                     call IssuePointOrderById( new, lastOrder, targPointX[i], targPointY[i] )
  404.                 elseif orderType[i] == 3 then
  405.                     call IssueImmediateOrderById( new, lastOrder )
  406.                 endif
  407.                 if IsUnitSelected( u, localPlayer ) then
  408.                     call SelectUnit( new, true )
  409.                 endif
  410.                 set maxTargeterCount[i] =  0
  411.                 set index = GetUnitId( new )
  412.                 set deathSFX[index] = deathSFX[i]
  413.                 set showDeath[index] = showDeath[i]
  414.                 //! endtextmacro
  415.                 //! runtextmacro REDIRECTDATA( "i", "GetWidgetLife( u )", "GetUnitState( u, UNIT_STATE_MANA )" )
  416.                 call hash.remove( GetHandleId( t ) )
  417.                 set showDeath[i] = false
  418.                 call RemoveUnit( u )
  419.                 static if LIBRARY_TimerUtils then
  420.                     call ReleaseTimer( t )
  421.                 else
  422.                     call DestroyTimer( t )
  423.                 endif
  424.                 if u == illusion then
  425.                     set illusion = new
  426.                 endif
  427.                 set new = null
  428.             endif
  429.         endif
  430.         set t = null
  431.         set u = null
  432.     endfunction
  433.  
  434.  
  435.     /////////////////////////////////
  436.     // Public APIs                 //
  437.     /////////////////////////////////
  438.  
  439.     function CreateIllusion takes player whichPlayer, integer ID, real dur, real damageDealt, real damageReceived, real x, real y, real angle returns unit
  440.         set illusion = Create( whichPlayer, ID, dur, damageDealt, damageReceived, x, y, angle )
  441.         return illusion
  442.     endfunction
  443.  
  444.     function CopyUnit takes player whichPlayer, unit u, real dur, real damageDealt, real damageReceived, real x, real y, real angle returns unit
  445.         set illusion = Copy( whichPlayer, u, dur, damageDealt, damageReceived, x, y, angle )
  446.         return illusion
  447.     endfunction
  448.  
  449.     function SetIllusionLevel takes unit u, integer level, boolean showEyeCandy returns boolean
  450.         local integer i = GetUnitId( u )
  451.         local integer lastOrder
  452.         local unit tempUnit
  453.         local unit new
  454.         local real x
  455.         local real y
  456.         local boolean success = false
  457.         if check[i] then
  458.             if IsUnitType( u, UNIT_TYPE_HERO ) then
  459.                 set x = GetUnitX( u )
  460.                 set y = GetUnitY( u )
  461.                 set tempUnit = CreateUnit( DUMMY_OWNER, GetUnitTypeId( u ), x, y, GetUnitFacing( u ) )
  462.                 set lastOrder = GetUnitCurrentOrder( u )
  463.                 call SetHeroLevel( tempUnit, level, false )
  464.                 set new = Copy( owner[i], tempUnit, duration[i], damageFactor[i], receiveFactor[i], x, y, GetUnitFacing( u ) )
  465.                 set index = 0
  466.                 loop
  467.                     set index = index + 1
  468.                     call UnitAddItemToSlotById( new, GetItemTypeId( UnitItemInSlot( u, index ) ), index )
  469.                     exitwhen index == 6
  470.                 endloop
  471.                 //! runtextmacro REDIRECTDATA( "GetUnitId( u )", "GetWidgetLife( u )*GetWidgetLife( new )/GetUnitState( u, UNIT_STATE_MAX_LIFE )", "GetUnitState( u, UNIT_STATE_MANA )*GetUnitState( new, UNIT_STATE_MANA )/GetUnitState( u, UNIT_STATE_MAX_MANA )" )
  472.                 call RemoveUnit( u )
  473.                 if showEyeCandy then
  474.                     call DestroyEffect( AddSpecialEffectTarget( "Abilities\\Spells\\Other\\Levelup\\LevelupCaster.mdl", new, "origin" ) )
  475.                 endif
  476.                 set success = true
  477.                 set tempUnit = null
  478.                 set new = null
  479.             debug else
  480.                 debug call Debug( ERROR_PREFIX + "Specified illusion is not a hero" )
  481.             endif
  482.         debug else
  483.             debug call Debug( ERROR_PREFIX + "Specified unit is not an illusion created by the system" )
  484.         endif
  485.         return success
  486.     endfunction
  487.  
  488.     //! textmacro DEBUG takes RETURN
  489.     if not check[i] then
  490.         debug call Debug( ERROR_PREFIX + "Specified unit is not an illusion created by the system" )
  491.         $RETURN$
  492.     endif
  493.     //! endtextmacro
  494.  
  495.     function SetIllusionDuration takes unit u, real time returns boolean
  496.         local integer i = GetUnitId( u )
  497.         //! runtextmacro DEBUG( "return false" )
  498.         set duration[i] = time
  499.         return true
  500.     endfunction
  501.  
  502.     function AddIllusionDuration takes unit u, real extraTime returns boolean
  503.         local integer i = GetUnitId( u )
  504.         //! runtextmacro DEBUG( "return false" )
  505.         set duration[i] = duration[i] + extraTime
  506.         return true
  507.     endfunction
  508.  
  509.     function SetIllusionDamageFactor takes unit u, real factor returns boolean
  510.         local integer i = GetUnitId( u )
  511.         //! runtextmacro DEBUG( "return false" )
  512.         set damageFactor[i] = factor
  513.         return true
  514.     endfunction
  515.  
  516.     function SetIllusionReceiveFactor takes unit u, real factor returns boolean
  517.         local integer i = GetUnitId( u )
  518.         //! runtextmacro DEBUG( "return false" )
  519.         set receiveFactor[i] = factor
  520.         return true
  521.     endfunction
  522.  
  523.     function ShowIllusionDeathEffect takes unit u, boolean flag returns boolean
  524.         local integer i = GetUnitId( u )
  525.         //! runtextmacro DEBUG( "return false" )
  526.         set showDeath[i] = flag
  527.         return true
  528.     endfunction
  529.  
  530.     function SetIllusionDeathEffect takes unit u, string model returns boolean
  531.         local integer i = GetUnitId( u )
  532.         //! runtextmacro DEBUG( "return false" )
  533.         set deathSFX[i] = model
  534.         return true
  535.     endfunction
  536.  
  537.     function GetIllusionElapsedTime takes unit u returns real
  538.         local integer i = GetUnitId( u )
  539.         //! runtextmacro DEBUG( "" )
  540.         return elapsed[i]
  541.     endfunction
  542.  
  543.     function GetIllusionRemainingDuration takes unit u returns real
  544.         local integer i = GetUnitId( u )
  545.         //! runtextmacro DEBUG( "" )
  546.         return duration[i] - elapsed[i]
  547.     endfunction
  548.  
  549.     function GetIllusionTotalDuration takes unit u returns real
  550.         local integer i = GetUnitId( u )
  551.         //! runtextmacro DEBUG( "" )
  552.         return duration[i]
  553.     endfunction
  554.  
  555.     function GetIllusionDamageFactor takes unit u returns real
  556.         local integer i = GetUnitId( u )
  557.         //! runtextmacro DEBUG( "" )
  558.         return damageFactor[i]
  559.     endfunction
  560.  
  561.     function GetIllusionReceiveFactor takes unit u returns real
  562.         local integer i = GetUnitId( u )
  563.         //! runtextmacro DEBUG( "" )
  564.         return receiveFactor[i]
  565.     endfunction
  566.  
  567.     function GetLastIllusion takes nothing returns unit
  568.         return illusion
  569.     endfunction
  570.  
  571.     function GetIllusionFlag takes unit u returns boolean
  572.         return check[GetUnitId( u )]
  573.     endfunction
  574.  
  575.     function IllusionDeathEvent takes code c returns nothing
  576.         if illuDeathTrig == null then
  577.             set illuDeathTrig = CreateTrigger()
  578.             call TriggerRegisterVariableEvent( illuDeathTrig, SCOPE_PRIVATE + "illusionDeathEvent", EQUAL, 1 )
  579.         endif
  580.         call TriggerAddCondition( illuDeathTrig, Filter( c ) )
  581.     endfunction
  582.  
  583.  
  584.     ////////////////////////////////////////////////
  585.     // This function adjusts the damage dealt and //
  586.     // taken by the illusions                     //
  587.     ////////////////////////////////////////////////
  588.     private function DamageAdjustment takes nothing returns nothing
  589.         local integer uDex = GetUnitId( PDDS.source )
  590.         local integer tDex = GetUnitId( PDDS.target )
  591.         if check[uDex] and check[tDex] then
  592.             set PDDS.amount = PDDS.amount*damageFactor[uDex]*receiveFactor[tDex]
  593.         elseif check[uDex] then
  594.             set PDDS.amount = PDDS.amount*damageFactor[uDex]
  595.         elseif check[tDex] then
  596.             set PDDS.amount = PDDS.amount*receiveFactor[tDex]
  597.         endif
  598.     endfunction
  599.  
  600.  
  601.     ////////////////////////////////////////////////
  602.     // Registers an illusion death event          //
  603.     ////////////////////////////////////////////////
  604.     private function RefreshDeathTrigger takes nothing returns nothing
  605.         local unit u
  606.         static if LIBRARY_GroupUtils then
  607.             call GroupEnumUnitsInRect( ENUM_GROUP, bj_mapInitialPlayableArea, null )
  608.             loop
  609.                 set u = FirstOfGroup( ENUM_GROUP )
  610.                 exitwhen u == null
  611.                 call GroupRemoveUnit( ENUM_GROUP, u )
  612.                 if check[GetUnitId( u )] then
  613.                     call TriggerRegisterUnitStateEvent( deathEvent, u, UNIT_STATE_LIFE, LESS_THAN, UNIT_MIN_LIFE )
  614.                 endif
  615.             endloop
  616.         else
  617.             call GroupEnumUnitsInRect( S.tempGroup, bj_mapInitialPlayableArea, null )
  618.             loop
  619.                 set u = FirstOfGroup( S.tempGroup )
  620.                 exitwhen u == null
  621.                 call GroupRemoveUnit( S.tempGroup, u )
  622.                 if check[GetUnitId( u )] then
  623.                     call TriggerRegisterUnitStateEvent( deathEvent, u, UNIT_STATE_LIFE, LESS_THAN, UNIT_MIN_LIFE )
  624.                 endif
  625.             endloop
  626.         endif
  627.     endfunction
  628.  
  629.  
  630.     ////////////////////////////////////////////////
  631.     // This function is responsible for hiding or //
  632.     // showing the illusion's death SFX           //
  633.     ////////////////////////////////////////////////
  634.     private function OnDeath takes nothing returns nothing
  635.         local unit u = GetTriggerUnit()
  636.         local integer i = GetUnitId( u )
  637.         call ShowUnit( u, false )
  638.         set illusionDeathEvent = 0
  639.         set illusionDeathEvent = 1
  640.         set illusionDeathEvent = 0
  641.         if showDeath[i] then
  642.             call DestroyEffect( AddSpecialEffect( deathSFX[i], GetUnitX( u ), GetUnitY( u ) ) )
  643.         endif
  644.         set usedDeathEvent = usedDeathEvent + 1
  645.         if usedDeathEvent == 30 then
  646.             set usedDeathEvent = 0
  647.             call DestroyTrigger( deathEvent )
  648.             set deathEvent = CreateTrigger()
  649.             call TriggerAddCondition( deathEvent, deathHandler )
  650.             call RefreshDeathTrigger()
  651.         endif
  652.         set u = null
  653.     endfunction
  654.  
  655.  
  656.     ///////////////////////////////////////////////
  657.     // Initialization                            //
  658.     ///////////////////////////////////////////////
  659.     private module M
  660.         static method onInit takes nothing returns nothing
  661.             local code c = function OnDeath
  662.             static if LIBRARY_RegisterPlayerUnitEvent then
  663.                 call RegisterPlayerUnitEventForPlayer( EVENT_PLAYER_UNIT_SUMMON, function OnSummon, DUMMY_OWNER )
  664.                 call RegisterPlayerUnitEvent( EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, function CacheTargetOrder )
  665.                 call RegisterPlayerUnitEvent( EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, function CachePointOrder )
  666.                 call RegisterPlayerUnitEvent( EVENT_PLAYER_UNIT_ISSUED_ORDER, function CacheOrder )
  667.             else
  668.                 local code c1 = function OnSummon
  669.                 local code c2 = function CacheTargetOrder
  670.                 local code c3 = function CachePointOrder
  671.                 local code c4 = function CacheOrder
  672.                 local trigger t1 = CreateTrigger()
  673.                 local trigger t2 = CreateTrigger()
  674.                 local trigger t3 = CreateTrigger()
  675.                 local trigger t4 = CreateTrigger()
  676.                 set index = 16
  677.                 loop
  678.                     set index = index - 1
  679.                     static if LIBRARY_PlayerUtils then
  680.                         call TriggerRegisterPlayerUnitEvent( t2, GetPlayerById(index), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null )
  681.                         call TriggerRegisterPlayerUnitEvent( t3, GetPlayerById(index), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null )
  682.                         call TriggerRegisterPlayerUnitEvent( t4, GetPlayerById(index), EVENT_PLAYER_UNIT_ISSUED_ORDER, null )
  683.                     else
  684.                         call TriggerRegisterPlayerUnitEvent( t2, Player(index), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null )
  685.                         call TriggerRegisterPlayerUnitEvent( t3, Player(index), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null )
  686.                         call TriggerRegisterPlayerUnitEvent( t4, Player(index), EVENT_PLAYER_UNIT_ISSUED_ORDER, null )
  687.                     endif
  688.                     exitwhen index == 0
  689.                 endloop
  690.                 call TriggerRegisterPlayerUnitEvent( t1, DUMMY_OWNER, EVENT_PLAYER_UNIT_SUMMON, Filter( c1 ) )
  691.                 call TriggerAddCondition( t2, Filter( c2 ) )
  692.                 call TriggerAddCondition( t3, Filter( c3 ) )
  693.                 call TriggerAddCondition( t4, Filter( c4 ) )
  694.             endif
  695.             set deathHandler = Filter( c )
  696.             call TriggerAddCondition( deathEvent, deathHandler )
  697.             call AddDamageHandler( function DamageAdjustment )
  698.             set durationUpdater = function AdjustTimedLife
  699.             set hash = HashTable.create()
  700.             set dummyCaster = CreateUnit( DUMMY_OWNER, DUMMY_ID, 0, 0, 0 )
  701.             set casterItem = UnitAddItemById( dummyCaster, ITEM_ID )
  702.             set localPlayer = GetLocalPlayer()
  703.         endmethod
  704.     endmodule
  705.  
  706.     private struct S extends array
  707.         static if not LIBRARY_GroupUtils then
  708.             static group tempGroup = CreateGroup()
  709.         endif
  710.         implement M
  711.     endstruct
  712.  
  713.  
  714. endlibrary
  715.  

Illusion Editor ObjectMerger
ILLUSION EDITOR OBJECT MERGER
Code: jass  [Select]
  1. //!| [ ILLUSION EDITOR OBJECT MERGER ] |
  2. /*
  3.  
  4.     Paste this script to your map and it save it. Close your map, open it again and disable/delete this script.
  5.     Now you have the all the object data needed for the Illusion Editor in your map.
  6.  
  7. */
  8. //! external ObjectMerger w3u nzin i001 anam "Dummy" ansf "(Illusion Editor)" uabi "Ainv, Aloc" ucbs 0 ushr 0 umdl "dummy.mdl" upat "" unbm 0 usid 1000000000 usin 1000000000
  9. //! external ObjectMerger w3a Alil I002 anam "illu" atat "" lild 1 1 lilw 1 1 aare 1 0 aran 1 99999 ahdu 1 5 adur 1 5 atar 1 "air,alive,allies,ancient,bridge,dead,debris,decoration,enemies,friend,ground,hero,invulnerable,item,mechanical,neutral,nonancient,nonhero,nonsapper,notself,organic,player,self,structure,sapper,terrain,tree,vulnerable,wall,ward"
  10. //! external ObjectMerger w3t will I000 anam "" iabi "illu" icla "Permanent" igol 0 iuse 0
  11.  


GUI Support
Code: jass  [Select]
  1. library IllusionEditorGUISupport uses IllusionEditor
  2.  
  3.  
  4.     private function Operate takes nothing returns nothing
  5.         if udg_IE_Operation == 0 then
  6.             set udg_IE_Illusion = GetLastIllusion()
  7.             return
  8.         elseif udg_IE_Operation == udg_IE_CreateIllusion then
  9.             set udg_IE_Illusion = CreateIllusion( udg_IE_Owner, udg_IE_UnitType, udg_IE_Duration, udg_IE_DamageDealtFactor, udg_IE_DamageReceiveFactor, GetLocationX( udg_IE_Position ), GetLocationY( udg_IE_Position ), udg_IE_Facing )
  10.             set udg_IE_Operation = 0
  11.             set udg_IE_Owner = null
  12.             set udg_IE_UnitType = 0
  13.             set udg_IE_Duration = 0.00
  14.             set udg_IE_DamageDealtFactor = 0.00
  15.             set udg_IE_DamageReceiveFactor = 0.00
  16.             set udg_IE_Facing = 0.00
  17.             return
  18.         elseif udg_IE_Operation == udg_IE_CopyUnit then
  19.             set udg_IE_Illusion = CopyUnit( udg_IE_Owner, udg_IE_BaseUnit, udg_IE_Duration, udg_IE_DamageDealtFactor, udg_IE_DamageReceiveFactor, GetLocationX( udg_IE_Position ), GetLocationY( udg_IE_Position ), udg_IE_Facing )
  20.             set udg_IE_Operation = 0
  21.             set udg_IE_Owner = null
  22.             set udg_IE_BaseUnit = null
  23.             set udg_IE_Duration = 0.00
  24.             set udg_IE_DamageDealtFactor = 0.00
  25.             set udg_IE_DamageReceiveFactor = 0.00
  26.             set udg_IE_Facing = 0.00
  27.             return
  28.         elseif udg_IE_Operation == udg_IE_SetLevel then
  29.             set udg_IE_Flag = SetIllusionLevel( udg_IE_Illusion, udg_IE_NewLevel, udg_IE_Flag )
  30.             set udg_IE_Operation = 0
  31.             return
  32.         elseif udg_IE_Operation == udg_IE_SetDuration then
  33.             set udg_IE_Flag = SetIllusionDuration( udg_IE_Illusion, udg_IE_Duration )
  34.             set udg_IE_Operation = 0
  35.             return
  36.         elseif udg_IE_Operation == udg_IE_AddDuration then
  37.             set udg_IE_Flag = AddIllusionDuration( udg_IE_Illusion, udg_IE_Duration )
  38.             set udg_IE_Operation = 0
  39.             return
  40.         elseif udg_IE_Operation == udg_IE_SetDamageFactor then
  41.             set udg_IE_Flag = SetIllusionDamageFactor( udg_IE_Illusion, udg_IE_DamageDealtFactor )
  42.             set udg_IE_Operation = 0
  43.             return
  44.         elseif udg_IE_Operation == udg_IE_SetReceiveFactor then
  45.             set udg_IE_Flag = SetIllusionReceiveFactor( udg_IE_Illusion, udg_IE_DamageReceiveFactor )
  46.             set udg_IE_Operation = 0
  47.             return
  48.         elseif udg_IE_Operation == udg_IE_ShowDeathEffect then
  49.             set udg_IE_Flag = ShowIllusionDeathEffect( udg_IE_Illusion, udg_IE_Flag )
  50.             set udg_IE_Operation = 0
  51.             return
  52.         elseif udg_IE_Operation == udg_IE_SetDeathEffect then
  53.             set udg_IE_Flag = SetIllusionDeathEffect( udg_IE_Illusion, udg_IE_DeathEffect )
  54.             set udg_IE_Operation = 0
  55.             return
  56.         elseif udg_IE_Operation == udg_IE_GetRemainingDuration then
  57.             set udg_IE_Duration = GetIllusionRemainingDuration( udg_IE_Illusion )
  58.             set udg_IE_Operation = 0
  59.             return
  60.         elseif udg_IE_Operation == udg_IE_GetTotalDuration then
  61.             set udg_IE_Duration = GetIllusionTotalDuration( udg_IE_Illusion )
  62.             set udg_IE_Operation = 0
  63.             return
  64.         elseif udg_IE_Operation == udg_IE_GetDamageFactor then
  65.             set udg_IE_DamageDealtFactor = GetIllusionDamageFactor( udg_IE_Illusion )
  66.             set udg_IE_Operation = 0
  67.             return
  68.         elseif udg_IE_Operation == udg_IE_GetReceiveFactor then
  69.             set udg_IE_DamageReceiveFactor = GetIllusionReceiveFactor( udg_IE_Illusion )
  70.             set udg_IE_Operation = 0
  71.             return
  72.         elseif udg_IE_Operation == udg_IE_GetFlag then
  73.             set udg_IE_Flag = GetIllusionFlag( udg_IE_Illusion )
  74.             set udg_IE_Operation = 0
  75.             return
  76.         endif
  77.     endfunction
  78.  
  79.     hook DoNothing Operate
  80.  
  81.  
  82. endlibrary
  83.  
  84.  
  85. function InitTrig_GUI_Support takes nothing returns nothing
  86.     /* We use an InitTrig function instead of a scope/library
  87.     initializer to initialize the values of our variables to
  88.     make sure that InitGlobals() runs first so that the values
  89.     of our variables would not be reset.                    */
  90.     call Trig_GUI_IllusionEditor_Documentation_Actions.execute()
  91. endfunction
  92.  

GUI Support Documentation
Trigger: Test 1397876899
   
           
  • GUI IllusionEditor Documentation
  •     Events
  •     Conditions
  •     Actions
  •         -------- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| --------
  •         -------- |||||||||||||||||||||||||||||||||||||||||||||||||              GUI ILLUSION EDITOR GUIDE              |||||||||||||||||||||||||||||||||||||||||||||||| --------
  •         -------- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| --------
  •         -------- First you need to choose what operation you want to do using the system. Like this:             --------
  •         Set IE_Operation = IE_CreateIllusion
  •         -------- It can be any from the list below:                                                                                             --------
  •         --------                                                                                                                                                 --------
  •         -------- 1. CreateIllusion - creates an illusion of a certain unit-type.                                                      --------
  •         -------- 2. CopyUnit - creates a mirror image of a unit which possesses the same items and abilities   --------
  •         --------                      as the original unit.                                                                                             --------
  •         -------- 3. SetLevel - sets the level of a hero type illusion to a desired value.                                      --------
  •         -------- 4. SetDuration - sets the total duration of an illusion to a desired value, if the given amount   --------
  •         --------                          is less than the elapsed time of the illusion, it will be destroyed.                      --------
  •         -------- 5. AddDuration - adds an extra time to an illusion's duration.                                                   --------
  •         -------- 6. SetDamageFactor - sets the damage dealt factor of an illusion.                                          --------
  •         -------- 7. SetReceiveFactor - sets the damage receive factor of an illusion                                       --------
  •         -------- 8. ShowDeathEffect - shows/hides the death effect of an illusion.                                         --------
  •         -------- 9. SetDeathEffect - sets a new special effect to replace the default death effect of an          --------
  •         --------                                 illusion.                                                                                                    --------
  •         -------- 10. GetRemainingDuration - gets the remaining duration of an illusion.                                   --------
  •         -------- 11. GetTotalDuration - gets the total duration of an illusion.                                                    --------
  •         -------- 12. GetDamageFactor - gets the damage dealt factor of an illusion.                                       --------
  •         -------- 13. GetReceiveFactor - gets the damage receive factor of an illusion.                                   --------
  •         -------- 14. GetFlag - checks if the illusion was created using this system or not.                                --------
  •         --------                                                                                                                                                 --------
  •         -------- Next, you have to setup all the data necessary for the operation you chose. Below are the   --------
  •         -------- list of data needed for each operation (Note that all these have an IE_ prefix):                       --------
  •         --------                                                                                                                                                 --------
  •         -------- 1. - Owner                                                                                                                                --------
  •         --------     - UnitType                                                                                                                            --------
  •         --------     - Duration                                                                                                                             --------
  •         --------     - DamageDealtFactor                                                                                                           --------
  •         --------     - DamageReceiveFactor                                                                                                      --------
  •         --------     - Position                                                                                                                              --------
  •         --------     - Facing                                                                                                                                --------
  •         --------                                                                                                                                                 --------
  •         -------- 2. - Owner                                                                                                                                --------
  •         --------     - BaseUnit                                                                                                                            --------
  •         --------     - Duration                                                                                                                             --------
  •         --------     - DamageDealtFactor                                                                                                           --------
  •         --------     - DamageReceiveFactor                                                                                                      --------
  •         --------     - Position                                                                                                                              --------
  •         --------     - Facing                                                                                                                                --------
  •         --------                                                                                                                                                 --------
  •         -------- 3. - Illusion                                                                                                                               --------
  •         --------     - NewLevel                                                                                                                          --------
  •         --------     - Flag                                                                                                                                   --------
  •         --------                                                                                                                                                 --------
  •         -------- 4, 5. - Illusion                                                                                                                           --------
  •         --------         - Duration                                                                                                                         --------
  •         --------                                                                                                                                                 --------
  •         -------- 6. - Illusion                                                                                                                               --------
  •         --------     - DamageDealtFactor                                                                                                          --------
  •         --------                                                                                                                                                 --------
  •         -------- 7. - Illusion                                                                                                                               --------
  •         --------     - DamageReceiveFactor                                                                                                     --------
  •         --------                                                                                                                                                 --------
  •         -------- 8. - Illusion                                                                                                                               --------
  •         --------     - Flag                                                                                                                                   --------
  •         --------                                                                                                                                                 --------
  •         -------- 9. - Illusion                                                                                                                               --------
  •         --------     - DeathEffect                                                                                                                       --------
  •         --------                                                                                                                                                 --------
  •         -------- 10, 11, 12, 13, 14. - Illusion                                                                                                     --------
  •         --------                                                                                                                                                 --------
  •         -------- The example we chose is CreateIllusion operation. So as you can see in number 1, we         --------
  •         -------- need to setup those variables so now we do:                                                                          --------
  •         Set IE_Owner = Player 1 (Red)
  •         Set IE_UnitType = Mortar Team
  •         Set IE_Duration = 5.00
  •         Set IE_DamageDealtFactor = 0.35
  •         Set IE_DamageReceiveFactor = 4.00
  •         Set IE_Position = (Center of (Playable map area))
  •         Set IE_Facing = Default building facing
  •         --------                                                                                                                                                 --------
  •         -------- And finally, what we have to do is execute the operation which in this case is very simple.    --------
  •         -------- To execute the opertation we have to use this:                                                                       --------
  •         Do nothing
  •         -------- Easy right? Plus we are also able to add a new functionality to the previously useless            --------
  •         -------- <Do nothing> function. ^-^                                                                                                      --------
  •         --------                                                                                                                                                 --------
  •         --------                                                                                                                                                 --------
  •         --------  ======================================================================= --------
  •         --------                                                                                                                                                 --------
  •         --------                                                                                                                                                 --------
  •         -------- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| --------
  •         -------- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||              CONSTANTS SETTING              ||||||||||||||||||||||||||||||||||||||||||||||||||||||||| --------
  •         -------- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| --------
  •         Set IE_CreateIllusion = 1
  •         Set IE_CopyUnit = 2
  •         Set IE_SetLevel = 3
  •         Set IE_SetDuration = 4
  •         Set IE_AddDuration = 5
  •         Set IE_SetDamageFactor = 6
  •         Set IE_SetReceiveFactor = 7
  •         Set IE_ShowDeathEffect = 8
  •         Set IE_SetDeathEffect = 9
  •         Set IE_GetRemainingDuration = 10
  •         Set IE_GetTotalDuration = 11
  •         Set IE_GetDamageFactor = 12
  •         Set IE_GetReceiveFactor = 13
  •         Set IE_GetFlag = 14
  •         --------                                                                                                                                                 --------
  •         --------                                                                                                                                                 --------
  •         -------- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| --------
  •         -------- Do not enable the following line. However, they are variable creators so do not delete them. --------
  •         -------- ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| --------
  •         Set IE_Operation = 0
  •         Set IE_NewLevel = 0
  •         Set IE_DamageDealtFactor = 0.00
  •         Set IE_DamageReceiveFactor = 0.00
  •         Set IE_Duration = 0.00
  •         Set IE_Facing = 0.00
  •         Set IE_Illusion = No unit
  •         Set IE_Owner = Player 1 (Red)
  •         Set IE_UnitType = No unit-type
  •         Set IE_BaseUnit = No unit
  •         Set IE_Position = IE_Position
  •         Set IE_Flag = False
  •         Set IE_DeathEffect = 
  •         --------  ======================================================================= --------
           

Pages: [1]
Blizzard Modding Information Center Starcraft II Modding Information Center Wacraft III Modding Information Center WC3JASS.com - The JASS Vault Chronicles of Darkness - A Warcraft III mod Jetcraft - A Starcraft II mod Troll Smash - A Warcraft III Arena
  Mod DB - Change the Game Power of Corruption - A Warcraft III altered melee map Chaos Realm - The world of Game modders and wc3 addicts Follow us on Facebook!!