- Joined
- Jul 10, 2007
- Messages
- 6,306
JASS:
library UnitRegen /* v2.0.0.1
*************************************************************************************
*
* A snippet that allows negative hp regeneration. Just copy and paste into the map
* and watch it work.
*
*************************************************************************************
* */uses/*
*
* */ UnitStateEvent /* hiveworkshop.com/forums/submissions-414/snippet-unitstateevent-191707/
*
************************************************************************************/
private struct UnitRegen extends array
private static method h takes nothing returns boolean
local integer i = GetEventUnitStateUnitId()
local real r = GetUnitState(GetUnitById(i), UNIT_STATE_MAX_LIFE)
set r = r-r*0.000050000
if (GetWidgetLife(GetUnitById(i)) >= r) then
call EnableEventUnitState(false)
call SetWidgetLife(GetUnitById(i), r)
call EnableEventUnitState(true)
endif
return false
endmethod
private static method m takes nothing returns boolean
local integer i = GetEventUnitStateUnitId()
local real r = GetUnitState(GetUnitById(i), UNIT_STATE_MAX_MANA)
set r = r-r*0.000050000
if (GetUnitState(GetUnitById(i), UNIT_STATE_MANA) >= r) then
call EnableEventUnitState(false)
call SetUnitState(GetUnitById(i), UNIT_STATE_MANA, r)
call EnableEventUnitState(true)
endif
return false
endmethod
private static method a takes nothing returns boolean
local real r
local integer i = GetIndexedUnitId()
set r = GetUnitState(GetUnitById(i), UNIT_STATE_MAX_LIFE)
set r = r-r*0.000050000
call EnableEventUnitState(false)
if (GetWidgetLife(GetUnitById(i)) >= r) then
call SetWidgetLife(GetUnitById(i), r)
endif
set r = GetUnitState(GetUnitById(i), UNIT_STATE_MAX_MANA)
set r = r-r*0.000050000
if (GetUnitState(GetUnitById(i), UNIT_STATE_MANA) >= r) then
call SetUnitState(GetUnitById(i), UNIT_STATE_MANA, r)
endif
call EnableEventUnitState(true)
return false
endmethod
private static method onInit takes nothing returns nothing
call GetHealthEvent().register(Condition(function thistype.h))
call GetManaEvent().register(Condition(function thistype.m))
call RegisterUnitIndexEvent(Condition(function thistype.a), UnitIndexer.INDEX)
endmethod
endstruct
endlibrary
Last edited: