Warcraft 3 documentation
vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

[Snippet] ReviveUnit No New Posts Codes & Snippets

Started by
moyack

0 Members and 1 Guest are viewing this topic.

[Snippet] ReviveUnit
on: December 28, 2011, 08:24:45 AM
Category: Units
Language: vJASS
Download Demo Map

ReviveUnit

Revives a unit in a similar fashion to reviving a hero. Note it does not work on units who do not leave a corpse (e.g. exploded, does not decay etc.).

Here is the code:
Code: jass
  1. library ReviveUnit /* 2.0.0.0
  2. ***************************************************
  3. *
  4. *   Resurrects a unit from his corpse, retaining
  5. *   its handle ID, facing, and position.
  6. *
  7. ***************************************************
  8. *
  9. *   ReviveUnit(unit whichUnit) returns boolean
  10. *       - Resurrects the input unit.
  11. *
  12. ***************************************************
  13. *
  14. *   Configurables
  15. *       - Remove the ! from //! after saving.
  16. */
  17.     //! external ObjectMerger w3a AHre URez anam "Dummy Resurrection" aher 0 acat "" atat "" Hre1 1 1 aare 1 0 aran 1 0 acdn 1 0 amcs 1 0 atar 1 "Air,Dead,Enemy,Friend,Ground,Neutral"
  18.     //! external ObjectMerger w3u ushd eRez unam "Dummy" uabi "Aloc,Avul" ucbs 0 ucpt 0 umdl ".mdl" usca "0.01" ushu "None" umvh 0 umvs 0 ufoo 0 umpi 100000 umpm 100000 umpr 1000
  19.        
  20.     globals
  21.         private constant integer DUMMY = 'eRez'
  22.         private constant integer RESURRECT = 'URez'
  23.     endglobals
  24. /*
  25. ***************************************************
  26. *
  27. *   Notes
  28. *       - Does not work on units without corpses.
  29. *       - The resurrected unit's mana is determined
  30. *         by the field: "Mana - Initial Amount"
  31. *
  32. ***************************************************
  33. *
  34. *   Importing: Automatic
  35. *       - Copy and paste this trigger.
  36. *       - Save the map, close it, and reopen it
  37. *       - Remove the exclamation ! from the object
  38. *         merger lines above.
  39. *
  40. *   Importing: Manual
  41. *       - Copy and paste this trigger.
  42. *       - Copy and paste the dummy unit and resurrection
  43. *         ability from the object editor.
  44. *       - Change the configurable raw codes as necessary.
  45. *
  46. ***************************************************/
  47.  
  48.     globals
  49.         private unit reviver
  50.         private real rx
  51.         private real ry
  52.     endglobals
  53.    
  54.     function ReviveUnit takes unit u returns boolean
  55.         local boolean success
  56.         if IsUnitType(u, UNIT_TYPE_HERO) == true then
  57.             return ReviveHero(u, GetUnitX(u), GetUnitY(u), false)
  58.         else
  59.             call SetUnitX(reviver, GetUnitX(u))
  60.             call SetUnitY(reviver, GetUnitY(u))
  61.             set success = IssueImmediateOrderById(reviver, 852094)
  62.             call SetUnitX(reviver, rx)
  63.             call SetUnitY(reviver, ry)
  64.         endif
  65.         return success
  66.     endfunction
  67.    
  68.     private module Init
  69.         private static method onInit takes nothing returns nothing
  70.             set rx = GetRectMaxX(bj_mapInitialPlayableArea) - 1
  71.             set ry = GetRectMaxY(bj_mapInitialPlayableArea) - 1
  72.             set reviver = CreateUnit(Player(15), DUMMY, rx, ry, 0)
  73.             call SetUnitPathing(reviver, false)
  74.             call UnitAddAbility(reviver, RESURRECT)
  75.         endmethod
  76.     endmodule
  77.    
  78.     struct Revive extends array
  79.         /* For backwards compatibility */
  80.         static method Unit takes unit whichUnit returns boolean
  81.             return ReviveUnit(whichUnit)
  82.         endmethod
  83.        
  84.         implement Init
  85.     endstruct
  86. endlibrary

Here is a demo map.
« Last Edit: December 19, 2017, 11:26:41 PM by moyack »



 

Started by PitzerMike

Replies: 0
Views: 1638
Codes & Snippets

Started by Bribe

Replies: 0
Views: 1968
Codes & Snippets

Started by moyack

Replies: 0
Views: 9880
Codes & Snippets

Started by Magtheridon96

Replies: 1
Views: 8662
Codes & Snippets
Vivir aprendiendo.co - A place for learning stuff, in Spanish   Chaos Realm - The world of Game modders and wc3 addicts   Diplo, a gaming community   Power of Corruption, an altered melee featuring Naga and Demon. Play it now!!!   WC3JASS.com - The JASS Vault + vJASS and Zinc   Jetcraft - A Starcraft II mod   WormTastic Clan (wTc)   Warcraft RESOURCES Reforged: Modelos, mapas, proyectos y mas...