5939 Posts in 1233 Topics - by 2135 Members - Latest Member: Jamepoison

Author Topic: [System] Unit Recycler & Simple Damage Detection System  (Read 11280 times)

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 976
  • WC3 Models: 5
  • WC3 Tutorials: 11
  • WC3 Tools: 9
  • WC3 Maps: 11
  • WC3 Skins: 6
  • WC3 Icons: 2
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
[System] Unit Recycler & Simple Damage Detection System
« on: February 05, 2012, 09:18:48 AM »
Unit Recycler & Uber simple damage detection
By moyack - 2009


Introduction:

This system is the result of working with a damage detection system that actually can be safe (AKA avoid totally the DestroyTrigger() function), so one solution to this issue is to avoid as much as possible (hopefully completely) the destruction of units and therefore the EVENT_DAMAGED triggers related to them, and the only way to make it possible is by recycling the units. The current result is a system that recycle most type of units (summoned and buildings simply don't work for their harcoded properties).


Why is convenient this system?

because the game won't need to allocate memory creating units, instead, they'll be backed up for a later use, which can improve your map performance. This can be very useful in maps where the unit spawning is a very common task (like AoS, footies, etc).


What's the issue with buildings and summoned units??

Buildings have limitations in moving them (they can be moved but their basement remains in the original place, which won't allow the construction of new units in those places). About summoned units, their dead is totally harcoded by the summoning abilities and can't be stopped by detecting the damage, therefore they can't be recycled.


How it works?

This library takes into account units that are being damaged, and detects if they're going to die (if the damage dealt to a unit is enough to kill them), if that situation happens, then it will be moved to the heaven, a place that you define in your map where the units are restored, cleaned and left ready for later use. Additionally this system offer a set of replacement functions which will help to this system to recycle units more efficiently.


How to install & final comments

  • Create a trigger and call it "UnitRecycler" or whatever you consider it best.
  • Convert it to custom text
  • Paste the content below.
  • In the configuration globals, set the  AUTO_LOC = true if you want the system set automatically the Heaven location. Set it to false if you need to set it manually in the HEAVEN_POS variable.
  • That's all :)

That's all??? not actually. By doing only this the library will be able to add damage detection to units and store the fallen units into the heaven. But it's up to you to develop the code to recycle the units. How?? using the functions provided (you can see them in the library comments).

Core Library
Code: jass  [Select]
  1. library UnitRecycler
  2. //******************************************************************************
  3. //*
  4. //* Unit Recycler
  5. //* By moyack. 2009
  6. //*
  7. //* ============================================================================
  8. //* Credits to Litany, DioD, Captain Griffen, Troll Brain and other nice guys  *
  9. //* for their suggestions, comments and ideas.                                 *
  10. //* ============================================================================
  11. //*
  12. //* This library allows to your map to reuse died units, which saves memory.
  13. //* It's very useful in AoS or footies games, where the unit spawning is a
  14. //* common task.
  15. //*
  16. //* How it works?
  17. //* =============
  18. //*
  19. //* The script detects if a unit reach the dying point (defined by the MIN_LIFE
  20. //* constant), and if the damage can kill the unit, then it is sent to the dump
  21. //* for further recycling. For custom situations like summoning or when a unit
  22. //* enters to the map, you just have to use the functions provided by this
  23. //* library.
  24. //*
  25. //* Functions
  26. //* =========
  27. //*
  28. //* in order to recycle a unit, you can use these function:
  29. //*
  30. //*  => RecycleUnit(<unit variable>) returns unit
  31. //*     -----------------------------------------
  32. //*     This function takes as argument a unit, and returns the unit recycled.
  33. //*     if there's a unit of the same typeid in the dump, it will use this unit
  34. //*     instead of the one from the function input, removing it immediately,
  35. //*     otherwise this script will return the same unit.
  36. //*
  37. //*  => CreateUnitEx(player, unitid, x, y, angle) returns unit
  38. //*     ------------------------------------------------------
  39. //*     Like the native function but tries to recycle the unit if avaliable in the dump
  40. //*
  41. //*  => KillUnitEx(<unit variable>) returns nothing
  42. //*     -------------------------------------------
  43. //*     Like the native function but it recycles the unit before killing it.
  44. //*
  45. //*  => RemoveUnitEx(<unit variable>) returns nothing
  46. //*     ---------------------------------------------
  47. //*     Like the native function but it recycles the unit.
  48. //*
  49. //*  => IsUnitDead(<unit variable>) returns boolean
  50. //*     -------------------------------------------
  51. //*     This function returns a boolean argument that indicates if the unit is dead or not.
  52. //*     Remember that a unit is dead if it's in the Heaven group.
  53. //*
  54. //*  => ReplaceDummy(<unit variable>) returns unit
  55. //*     -------------------------------------------
  56. //*     This function returns a replacement unit without killing the output unit.
  57. //*
  58. //*  => CreateDummy(player, unitid, x, y, angle) returns unit
  59. //*     ------------------------------------------------------
  60. //*     Like the CreateUnit function but the returned unit won't be affected by the damage
  61. //*     detection nor will be recycled automatically
  62. //*
  63. //*  => TriggerRegisterAnyUnitRecycleEvent(trigger t) returns nothing
  64. //*     -------------------------------------------------------------
  65. //*     All the trigger registered in this way will activate when a unit is about to be recycled
  66. //*     (in other words, it triggers before it dies). You can use this functions to retrieve the
  67. //*     the units involved in this event:
  68. //*
  69. //*      # GetRecycledUnit() returns the units that is going to be recycled
  70. //*      # GetRecycleDummyUnit() returns the dummy unit which will die instead of the recycled unit
  71. //*      # GetRecycleAttacker() returns the unit that "kills" the recycled unit
  72. //*
  73. //*  => IsUnitDummy(unit u) returns boolean
  74. //*     -----------------------------------
  75. //*     Checks if a unit can be recycled or not. Dummy units are not recycled, they're used as
  76. //*     placeholder of the unit about to die...
  77. //*
  78. //*  => GetUnitsInHeaven() returns group
  79. //*     --------------------------------
  80. //*     Returns the group which contains the units in the heaven. Useful to do checks and
  81. //*     operations on them.
  82. //*
  83. //*
  84. //* For Damage detection, you just need to use these functions:
  85. //*
  86. //*  => AddDamageCondition(<Boolexpr variable>) returns nothing
  87. //*     -------------------------------------------------------
  88. //*     Just add a condition function which manage the damaged unit and the script
  89. //*     will use it with all the the units in the DD.D group.
  90. //*
  91. //*  => DoNonDetectableDamage(unit, widget, damage, boolean_attack, boolean_ranged, attacktype, damagetype, weapontype) returns boolean
  92. //*     --------------------------------------------------------------------------------------
  93. //*     Like the UnitDamageTarget function, but it can be used inside condition functions.
  94. //*     How to know if you need to use it? if you use UnitDamageTarget() inside a DD function and
  95. //*     it freezes the game until it kills the attacked unit(s), then you have to replace that
  96. //*     function by this custom one.
  97. //********************************************************************************
  98. //* CONFIGURATION PART
  99. globals
  100.     private constant real     MIN_LIFE = 0.405 // the experimental death value that will be used to activate
  101.                                          // the fake death of units. units that reach this value or less
  102.                                          // won't die and they will be recycled.
  103.     private constant boolean  AUTO_LOC = false// If it's set to true, it will place automatically the heaven in one
  104.                                               // non visible corner of the map, else, it will use the HEAVEN_POS
  105.                                               // as a heaven location
  106.     private constant player   DUMMY_PLAYER = Player(15) // sets the player owner of the unit's heaven
  107.     private constant real     MANA_FACTOR = 0.5 // sets the initial mana amount (as percentage of maximum mana)
  108.                                                 // to recycled units when they are just placed in the game.
  109.                                                 // This constant is used only by CreateUnitEx function.
  110.    
  111.     private location HEAVEN_POS = Location(2700., -4700.) // Indicates the heaven's location.
  112. endglobals
  113. //* END CONFIGURATION PART
  114.  
  115. globals
  116.     private group Heaven // where worthy units go when they die...
  117. endglobals
  118.  
  119. // this is a key functions part just to make homogeneus the unit management, please don't edit this unless
  120. // you know what are you doing, ok??
  121. private keyword Kill
  122.  
  123. private function PrepareUnit takes unit u returns nothing
  124.     call SelectUnit(u, false)
  125.     call UnitRemoveBuffs(u, true, true)
  126.     call UnitResetCooldown(u)
  127.     call SetUnitInvulnerable(u, true)
  128.     call SetWidgetLife(u, GetUnitState(u, UNIT_STATE_MAX_LIFE))
  129.     call PauseUnit(u, true)
  130.     call GroupAddUnit(Heaven, u)
  131. endfunction
  132.  
  133. private function MoveUnit takes unit u returns nothing
  134.     call SetUnitOwner(u, DUMMY_PLAYER, true)
  135.     call SetUnitX(u, GetLocationX(HEAVEN_POS))
  136.     call SetUnitY(u, GetLocationY(HEAVEN_POS))
  137. endfunction
  138.  
  139. private function PlaceDummy takes unit d, unit u returns nothing
  140.     call GroupAddUnit(Kill.corpse, d)
  141.     call SetUnitUseFood(d, false)
  142.     call SetUnitState(d, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MANA))
  143.     call SetUnitFlyHeight(d, GetUnitFlyHeight(u), 0.)
  144.     //call SetCSData(d, GetCSData(u)) //used to pass attached data via CSData to the corpse...
  145.     call SetUnitPathing(d, false)
  146.     call SetUnitX(d, GetUnitX(u))
  147.     call SetUnitY(d, GetUnitY(u))
  148. endfunction
  149. // end key functions...
  150.  
  151. private struct Trigger // struct to manage the EventRecycleUnit
  152.     private static integer i = 0
  153.     static unit R = null // recycled unit
  154.     static unit D = null // dummy unit
  155.     static unit A = null // attacker unit
  156.     trigger t
  157.    
  158.     static method AddTrigger takes trigger t returns nothing
  159.         local Trigger T = Trigger.allocate()
  160.         set T.t = t
  161.         set Trigger.i = integer(T)
  162.     endmethod
  163.    
  164.     static method evaluate takes unit r, unit d, unit a returns nothing
  165.         local integer i = 1
  166.         local Trigger T
  167.         set Trigger.R = r
  168.         set Trigger.D = d
  169.         set Trigger.A = a
  170.         loop
  171.             exitwhen i > Trigger.i
  172.             set T =Trigger(i)
  173.             if T.t != null and TriggerEvaluate(T.t) then
  174.                 call TriggerExecute(T.t)
  175.             endif
  176.             set i = i + 1
  177.         endloop
  178.     endmethod
  179. endstruct
  180.  
  181. private struct Kill // struct used to manage the killed units...
  182.     static group corpse // group of units that won't be touched by the damage detection (corpses and dummy units for instance)
  183.    
  184.     static method Do takes unit u, unit killer returns nothing
  185.         local unit d = CreateUnit(GetOwningPlayer(u), GetUnitTypeId(u), GetUnitX(u), GetUnitY(u), GetUnitFacing(u))
  186.         call SetUnitInvulnerable(u, true)
  187.         call PlaceDummy(d, u)
  188.         call SetWidgetLife(d, 1.)
  189.         call Trigger.evaluate(u, d, killer)
  190.         call UnitDamageTarget(killer, d, 2., true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
  191.         call PrepareUnit(u)
  192.         call MoveUnit(u)
  193.         set d = null
  194.     endmethod
  195.    
  196.     private static method ManageSummoned takes nothing returns nothing
  197.         if IsUnitInGroup(GetSummonedUnit(), Kill.corpse) then
  198.             // this part will run when a corpse is resurrected, so this units are suitable to
  199.             // be controlled by the damage detection.
  200.             call GroupRemoveUnit(Kill.corpse, GetSummonedUnit())
  201.             call SetUnitPathing(GetSummonedUnit(), true)
  202.         endif
  203.     endmethod
  204.    
  205.     private static method onInit takes nothing returns nothing
  206.         local trigger t = CreateTrigger()
  207.         call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SUMMON)
  208.         call TriggerAddAction(t, function Kill.ManageSummoned)
  209.         set Kill.corpse = CreateGroup()
  210.         set t = null
  211.     endmethod
  212. endstruct
  213.  
  214. private struct DD // damage detection struct, because damage detection can be so easy...
  215.     static group D // group of unit that will have damage detection
  216.     static trigger T
  217.    
  218.     // Add the attacked unit to the damage detection if the unit is not in the unit group
  219.     private static method AddUnit takes unit d returns nothing
  220.         if not IsUnitInGroup(d, DD.D) and not IsUnitInGroup(d, Kill.corpse) then
  221.             debug call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,2,"Added " + GetUnitName(d) + " to the DD")
  222.             call TriggerRegisterUnitEvent(DD.T, d, EVENT_UNIT_DAMAGED)
  223.             call GroupAddUnit(DD.D, d)
  224.         endif
  225.     endmethod
  226.    
  227.     private static method Attacked takes nothing returns nothing
  228.         call DD.AddUnit(GetTriggerUnit())
  229.     endmethod
  230.    
  231.     private static method Spelled takes nothing returns nothing
  232.         if GetSpellTargetUnit() != null then
  233.             call DD.AddUnit(GetSpellTargetUnit())
  234.         endif
  235.     endmethod
  236.    
  237.     static method AntiLoop takes nothing returns nothing
  238.         call EnableTrigger(DD.T)
  239.     endmethod
  240.    
  241.     private static method onInit takes nothing returns nothing
  242.         set DD.T = CreateTrigger()
  243.         set DD.D = CreateGroup()
  244.         call TriggerRegisterAnyUnitEventBJ(DD.T, EVENT_PLAYER_UNIT_ATTACKED)
  245.         call TriggerAddAction(DD.T, function DD.Attacked)
  246.         set DD.T = CreateTrigger()
  247.         call TriggerRegisterAnyUnitEventBJ(DD.T, EVENT_PLAYER_UNIT_SPELL_EFFECT)
  248.         call TriggerAddAction(DD.T, function DD.Spelled)
  249.         set DD.T = CreateTrigger()
  250.     endmethod
  251.  
  252. endstruct // you see, it's not bigger than this :)
  253.  
  254. private struct UR // unit recycling struct
  255.     static group Temp = CreateGroup()
  256.     static unit U = null
  257.    
  258.     static method FromDump takes nothing returns boolean
  259.         if IsUnitInGroup(GetFilterUnit(), Heaven) and IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD) == false then
  260.             set UR.U = GetFilterUnit()
  261.         endif
  262.         return false
  263.     endmethod
  264.    
  265.     static method UseRecycled takes unit u returns unit
  266.         local real x = GetUnitX(u)
  267.         local real y = GetUnitY(u)
  268.         local real f = GetUnitFacing(u)
  269.         local real m = GetUnitState(u, UNIT_STATE_MANA)
  270.         local player p = GetOwningPlayer(u)
  271.         set UR.U = null
  272.         call GroupEnumUnitsOfTypeCounted(UR.Temp, UnitId2String(GetUnitTypeId(u)), Condition(function UR.FromDump), 1)
  273.         if UR.U != null then
  274.             debug call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,2, GetUnitName(UR.U) + " is being reused...")
  275.             call SetUnitInvulnerable(UR.U, false)
  276.             call GroupRemoveUnit(Heaven, UR.U)
  277.             call PauseUnit(UR.U, true)
  278.             call SetUnitPosition(UR.U, x, y)
  279.             call SetUnitFacing(UR.U, f)
  280.             call SetUnitOwner(UR.U, p, true)
  281.             call SetUnitState(UR.U, UNIT_STATE_MANA, m)
  282.             call SetUnitPathing(UR.U, true)
  283.             call PauseUnit(UR.U, false)
  284.             call RemoveUnit(u)
  285.             set u = null
  286.             return UR.U
  287.         else
  288.             return u
  289.         endif
  290.     endmethod
  291.    
  292.     private static method onRecycle takes nothing returns boolean
  293.         local unit u = GetTriggerUnit()
  294.         if IsUnitType(u, UNIT_TYPE_HERO) == false and IsUnitType(u, UNIT_TYPE_STRUCTURE) == false and IsUnitType(u, UNIT_TYPE_SUMMONED) == false and GetWidgetLife(u) - GetEventDamage() <= MIN_LIFE then
  295.             call Kill.Do(u, GetEventDamageSource()) // place a dummy to replace the unit
  296.                                                        // and returns the corpse
  297.             debug call DisplayTimedTextFromPlayer(Player(15),0,0,2, GetUnitName(u) + " has been sent to the dump...")
  298.         endif
  299.         set u = null
  300.         return false
  301.     endmethod
  302.    
  303.     private static method onInit takes nothing returns nothing
  304.         local rect r= GetWorldBounds()
  305.         set Heaven = CreateGroup()
  306.         call TriggerAddCondition(DD.T, Condition(function UR.onRecycle))
  307.         if AUTO_LOC then
  308.             call MoveLocation(HEAVEN_POS, GetRectMinX(r), GetRectMinY(r))
  309.         endif
  310.         call RemoveRect(r)
  311.         set r=null
  312.     endmethod
  313. endstruct
  314.  
  315. //*====================
  316. //* User functions... *
  317. //*====================
  318. function RecycleUnit takes unit u returns unit
  319.     return UR.UseRecycled(u)
  320. endfunction
  321.  
  322. function CreateUnitEx takes player p, integer id, real x, real y, real f returns unit
  323.     set UR.U = null
  324.     call GroupEnumUnitsOfTypeCounted(UR.Temp, UnitId2String(id), Condition(function UR.FromDump), 1)
  325.     if UR.U != null then
  326.         debug call DisplayTimedTextToForce(bj_FORCE_ALL_PLAYERS,2, GetUnitName(UR.U) + " is being reused...")
  327.         call SetUnitInvulnerable(UR.U, false)
  328.         call GroupRemoveUnit(Heaven, UR.U)
  329.         call PauseUnit(UR.U, true)
  330.         call SetUnitPosition(UR.U, x, y)
  331.         call SetUnitFacing(UR.U, f)
  332.         call SetUnitOwner(UR.U, p, true)
  333.         call SetUnitState(UR.U, UNIT_STATE_MANA, GetUnitState(UR.U, UNIT_STATE_MAX_MANA) * MANA_FACTOR)
  334.         call SetUnitPathing(UR.U, true)
  335.         call PauseUnit(UR.U, false)
  336.         return UR.U
  337.     endif
  338.     return CreateUnit(p, id, x, y, f)
  339. endfunction
  340.  
  341. function KillUnitEx takes unit u returns nothing
  342.     local unit d
  343.     if IsUnitType(u, UNIT_TYPE_HERO) == false and IsUnitType(u, UNIT_TYPE_STRUCTURE) == false then
  344.         set d = CreateUnit(GetOwningPlayer(u), GetUnitTypeId(u), GetUnitX(u), GetUnitY(u), GetUnitFacing(u))
  345.         call Trigger.evaluate(u, d, null)
  346.         call PrepareUnit(u)
  347.         call PlaceDummy(d, u)
  348.         call KillUnit(d)
  349.         call MoveUnit(u)
  350.     endif
  351.     set d = null
  352. endfunction
  353.  
  354. function RemoveUnitEx takes unit u returns nothing
  355.     if IsUnitType(u, UNIT_TYPE_HERO) == false and IsUnitType(u, UNIT_TYPE_STRUCTURE) == false then
  356.         call Trigger.evaluate(u, null, null)
  357.         call PrepareUnit(u)
  358.         call MoveUnit(u)
  359.     endif
  360. endfunction
  361.  
  362. function IsUnitDead takes unit u returns boolean
  363.     return IsUnitInGroup(u, Heaven)
  364. endfunction
  365.  
  366. function ReplaceDummy takes unit u returns unit
  367.     local unit d
  368.     if IsUnitType(u, UNIT_TYPE_HERO) == false and IsUnitType(u, UNIT_TYPE_STRUCTURE) == false then
  369.         set d = CreateUnit(GetOwningPlayer(u), GetUnitTypeId(u), GetUnitX(u), GetUnitY(u), GetUnitFacing(u))
  370.         call PlaceDummy(d, u)
  371.         call SetWidgetLife(d, GetWidgetLife(u))
  372.         call PrepareUnit(u)
  373.         call MoveUnit(u)
  374.         call SetUnitPathing(d, true)
  375.     else
  376.         set d = null
  377.     endif
  378.     return d
  379. endfunction
  380.  
  381. function CreateDummy takes player p, integer id, real x, real y, real f returns unit
  382.     local unit u = CreateUnit(p, id, x, y, f)
  383.     call GroupAddUnit(Kill.corpse, u)
  384.     return u
  385. endfunction
  386.  
  387. // TriggerRecyclefunctions. this trigger happens before the triggered unit is going to die...
  388. function TriggerRegisterAnyUnitRecycleEvent takes trigger t returns nothing
  389.     call Trigger.AddTrigger(t)
  390. endfunction
  391.  
  392. constant function GetRecycledUnit takes nothing returns unit
  393.     // returns the recycled unit...
  394.     return Trigger.R
  395. endfunction
  396.  
  397. constant function GetRecycleDummyUnit takes nothing returns unit
  398.     // returns the dummy unit...
  399.     return Trigger.D
  400. endfunction
  401.  
  402. constant function GetRecycleAttacker takes nothing returns unit
  403.     // returns the attacker who "kills" the recycled unit...
  404.     return Trigger.A
  405. endfunction
  406.  
  407. constant function IsUnitDummy takes unit u returns boolean
  408.     // Checks if a unit can be recycled or not. Dummy units are not recycled, they're used as placeholder...
  409.     return IsUnitInGroup(u, Kill.corpse)
  410. endfunction
  411.  
  412. constant function GetUnitsInHeaven takes nothing returns group
  413.     // Checks if a unit can be recycled or not. Dummy units are not recycled, they're used as placeholder...
  414.     return Heaven
  415. endfunction
  416.  
  417. // Damage detection system functions...
  418. function AddDamageCondition takes boolexpr b returns nothing
  419.     call TriggerAddCondition(DD.T, b)
  420. endfunction
  421.  
  422. function DoNonDetectableDamage takes unit u, widget t, real damage, boolean attack, boolean ranged, attacktype AT, damagetype DT, weapontype WT returns boolean
  423.     local boolean b
  424.     call DisableTrigger(DD.T)
  425.     set b = UnitDamageTarget(u, t, damage, attack, ranged, AT, DT, WT)
  426.     call EnableTrigger(DD.T)
  427.     return b
  428. endfunction
  429.  
  430. endlibrary

Changelog
(14/10/2008):
 - Small improvements in the core library
 - Developed a better example (a tiny AOS, much better than AotZ, DoE and ToB together :P)

(09/09/2008):
 - Added a custom trigger event so the system can detect when a unit is about to be recycled
 - Added some improvements

(31/12/2008):
 - Other minor and final improvements (hopefully)

(06/01/2009):
 - Now you can set up the system so it automatically set the heaven in a non playable area of the map (Thanks Troll brain for the idea)
 - Added IsUnitDummy function to define if a unit is a placeholder or not.
 - Added GetUnitsInHeaven function to retrieve the group that stores the units in Heaven. Useful to do operations with those units.
 - Improved the test map with a leaderboard which shows data about units killed per player, units in map, units taht are being recycled, and the percentage of units recycled respect the total of active units.

(29/01/2009):
 - Minor improvement in the DD code, now it's more efficient getting units in to the DD group.

(05/04/2009):
 - Fixed an unit leak (thanks a lot Litany :D) and improved the CreateUnitEx function.

Please download the test map for further testing. (last updated: 05/04/2009)
« Last Edit: June 25, 2013, 08:48:51 PM by moyack »


We can give you full hosting for your projects. Not only a forum, a complete page!!.

A custom altered melee map where you can play Naga and Demons. Featuring a nice additions in features and game style. Check it out!!
Save your important files fast and easy

  • Awesome Global Code Moderator
  • Recognized User
  • Rookie - level 2
  • *
  • Posts: 83
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • Reputation: 516
  • vJass Incarnate
    • View Profile
Re: [System] Unit Recycler & Simple Damage Detection System
« Reply #1 on: February 09, 2012, 12:53:14 PM »
Cool, a unit recycler :D

I wish the overhead could be smaller :/

... I know! :D
How about only giving the units the locust ability so nothing could happen to them, and you can pause them so that they can't do anything :D

  • Newbie - level 1
  • *
  • Posts: 8
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • Reputation: 20
  • User
    • View Profile
Re: [System] Unit Recycler & Simple Damage Detection System
« Reply #2 on: August 19, 2012, 04:46:55 PM »
Doing Unit Recycling and DDS in the same lib is a very bad idea. Have you ever heard of the term modularity?

I'd recommend that you split them up into two different libraries.

edit
Also, your DDS leaks mass events.

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 976
  • WC3 Models: 5
  • WC3 Tutorials: 11
  • WC3 Tools: 9
  • WC3 Maps: 11
  • WC3 Skins: 6
  • WC3 Icons: 2
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
Re: [System] Unit Recycler & Simple Damage Detection System
« Reply #3 on: August 20, 2012, 12:40:47 AM »
Doing Unit Recycling and DDS in the same lib is a very bad idea. Have you ever heard of the term modularity?
Yes, I know the term, but one of the reason I could do it in that way was the fact I needed internal and private stuff from the damage detection that should be called into the unit recycling.

Quote
I'd recommend that you split them up into two different libraries.
Hmm, I think this code should be revised, with the new knowledge in vJASS.

Quote
edit
Also, your DDS leaks mass events.
I'll check it out.


We can give you full hosting for your projects. Not only a forum, a complete page!!.

A custom altered melee map where you can play Naga and Demons. Featuring a nice additions in features and game style. Check it out!!
Save your important files fast and easy

  • Newbie - level 1
  • *
  • Posts: 8
  • WC3 Models: 0
  • WC3 Tutorials: 0
  • WC3 Tools: 0
  • WC3 Maps: 0
  • WC3 Skins: 0
  • WC3 Icons: 0
  • Reputation: 20
  • User
    • View Profile
Re: [System] Unit Recycler & Simple Damage Detection System
« Reply #4 on: August 20, 2012, 12:47:46 AM »
This is the DDS I wrote

http://www.hiveworkshop.com/forums/jass-resources-412/snippet-damageevent-186829/

And here is the Dummy lib I wrote

http://www.hiveworkshop.com/forums/jass-resources-412/system-dummy-213908/


This is before you take the next naive approach of mass refreshes on the DDS and no accounting for unit facing on the dummy recycle ; ).

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 976
  • WC3 Models: 5
  • WC3 Tutorials: 11
  • WC3 Tools: 9
  • WC3 Maps: 11
  • WC3 Skins: 6
  • WC3 Icons: 2
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
Re: [System] Unit Recycler & Simple Damage Detection System
« Reply #5 on: August 20, 2012, 01:02:03 AM »
Would you mind in share your scripts here :) So I can link the requirements in this site.

Hugss :D


We can give you full hosting for your projects. Not only a forum, a complete page!!.

A custom altered melee map where you can play Naga and Demons. Featuring a nice additions in features and game style. Check it out!!
Save your important files fast and easy

  • Site Owner
  • Administrator
  • Starter - level 4
  • *
  • Posts: 976
  • WC3 Models: 5
  • WC3 Tutorials: 11
  • WC3 Tools: 9
  • WC3 Maps: 11
  • WC3 Skins: 6
  • WC3 Icons: 2
  • Reputation: 1153
  • Site Admin - I love fix things
    • View Profile
    • Blizzard Modding Information Center
[System] Unit Recycler & Simple Damage Detection System
« Reply #6 on: June 25, 2013, 08:50:33 PM »
Added download link and preview image...


We can give you full hosting for your projects. Not only a forum, a complete page!!.

A custom altered melee map where you can play Naga and Demons. Featuring a nice additions in features and game style. Check it out!!
Save your important files fast and easy

 

[ vJASS ] About Spawn Unit

Started by LembidiZBoard Triggers & Scripting

Replies: 13
Views: 7643
Last post March 19, 2016, 06:30:06 AM
by LembidiZ
Simple Sword

Started by AnonymousBoard Warcraft III Models

Replies: 1
Views: 4267
Last post March 11, 2016, 11:39:32 PM
by moyack
My custom made spell damage function

Started by rvonsonsnadtzBoard Coding Help

Replies: 10
Views: 14300
Last post October 13, 2012, 06:20:48 AM
by rvonsonsnadtz
New Hero Selection System for version 1.6!!!

Started by SonofJayBoard General Information

Replies: 3
Views: 5116
Last post July 01, 2013, 03:59:31 PM
by Chaosy
Advanced AI system (AKA AMAI 2)

Started by moyackBoard Jass Theory & Questions

Replies: 6
Views: 11528
Last post September 06, 2012, 09:54:35 PM
by moyack
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!!