kingkingyyk3
Visitor (Welcome to the Jungle, Baby!)
- Reaction score
- 216
Bump~
// /\ \ /\ \ /\ \ /\ \
// /::\____\ /::\ \ /::\ \ /::\____\
// /:::/ / /::::\ \ /::::\ \ /:::/ /
// /:::/ / /::::::\ \ /::::::\ \ /:::/ /
// /:::/ / /:::/\:::\ \ /:::/\:::\ \ /:::/ /
// /:::/____/ /:::/__\:::\ \ /:::/__\:::\ \ /:::/ /
// /::::\ \ /::::\ \:::\ \ /::::\ \:::\ \ /:::/ /
// /::::::\ \ _____ /::::::\ \:::\ \ /::::::\ \:::\ \ /:::/ /
// /:::/\:::\ \ /\ \ /:::/\:::\ \:::\ \ /:::/\:::\ \:::\ \ /:::/ /
// /:::/ \:::\ /::\____\/:::/__\:::\ \:::\____\/:::/ \:::\ \:::\____\/:::/____/
// \::/ \:::\ /:::/ /\:::\ \:::\ \::/ /\::/ \:::\ /:::/ /\:::\ \
// \/____/ \:::\/:::/ / \:::\ \:::\ \/____/ \/____/ \:::\/:::/ / \:::\ \
// \::::::/ / \:::\ \:::\ \ \::::::/ / \:::\ \
// \::::/ / \:::\ \:::\____\ \::::/ / \:::\ \
// /:::/ / \:::\ \::/ / /:::/ / \:::\ \
// /:::/ / \:::\ \/____/ /:::/ / \:::\ \
// /:::/ / \:::\ \ /:::/ / \:::\ \
// /:::/ / \:::\____\ /:::/ / \:::\____\
// \::/ / \::/ / \::/ / \::/ /
// \/____/ \/____/ \/____/ \/____/
///////////////////////////////////////////////
//
// set HPRegenByType['hpea'].amount = 10.
//
// set UnitBasedRegen[unit].amount = 20.
//
///////////////////////////////////////////////
library CustomUnitRegenSystem requires T32, AIDS, Heal, Hash
globals
HealType NORMAL_UNIT_HP_REGEN
endglobals
struct HPRegenByType extends array
real hp
static method operator [] takes integer unitType returns thistype
return Hash(unitType)
endmethod
method operator amount= takes real r returns nothing
set .hp = r * T32_PERIOD
endmethod
method operator amount takes nothing returns real
return hp * T32_FPS
endmethod
endstruct
struct UnitBasedRegen extends array
private real hp
method operator amount= takes real r returns nothing
set .hp = r * T32_PERIOD
endmethod
method operator amount takes nothing returns real
return .hp * T32_FPS
endmethod
private method periodic takes nothing returns nothing
call HealUnit(.unit,.unit,HPRegenByType[GetUnitTypeId(.unit)].hp + .hp,NORMAL_UNIT_HP_REGEN)
//Prevent bug when a unit is upgraded/transformed.
endmethod
implement T32x
private method AIDS_onCreate takes nothing returns nothing
call .startPeriodic()
endmethod
private method AIDS_onDestroy takes nothing returns nothing
set .amount = 0.
call .stopPeriodic()
endmethod
//! runtextmacro AIDS()
private static method AIDS_onInit takes nothing returns nothing
set NORMAL_UNIT_HP_REGEN = HealType.new()
endmethod
endstruct
endlibrary
///////////////////////////////////////////////
//
// set ItemRegenAbiltiy['I000'].amount = 10.
//
// set ItemBasedRegen[item].amount = 20.
//
///////////////////////////////////////////////
library CIRAS requires IDEA, Heal, UID, T32, Hash
//Custom Item Regeneration Ability System
globals
HealType NORMAL_ITEM_HP_REGEN_ABILITY
endglobals
struct ItemRegenAbility
real hp
static method operator [] takes integer itemType returns thistype
return Hash(itemType)
endmethod
method operator amount= takes real r returns nothing
set .hp = r * T32_PERIOD
endmethod
method operator amount takes nothing returns real
return hp * T32_FPS
endmethod
endstruct
struct ItemBasedRegen
private real hp
method operator amount= takes real r returns nothing
set .hp = r * T32_PERIOD
endmethod
method operator amount takes nothing returns real
return .hp * T32_FPS
endmethod
private method periodic takes nothing returns nothing
call HealUnit(GetItemOwner(.item),GetItemOwner(.item),ItemRegenAbiltiy[GetItemTypeId(.item)].hp + .amount,NORMAL_ITEM_HP_REGEN_ABILITY)
endmethod
implement T32x
private method IDEA_onCreate takes nothing returns nothing
call .startPeriodic()
endmethod
private method IDEA_onDestroy takes nothing returns nothing
set .amount = 0.
call .stopPeriodic()
endmethod
implement IDEA
private static method onInit takes nothing returns nothing
set NORMAL_ITEM_HP_REGEN_ABILITY = HealType.new()
endmethod
endstruct
endlibrary
New system, new thread, unless it is tightly coupled with the thread the system is about (ie. a plugin). Imagine if I put Damage in the AIDS thread...Added useful library - HealCraft.
struct Armor
real percentageToBlock
private static method [] takes integer whichId returns thistype
return //Some hashing algorithm.
endmethod
private static method cond takes nothing returns boolean
call Heal_Block(Heal_GetAmount()*thistype[GetUnitTypeId(Heal_GetTarget())].percentageToBlock)
return false
endmethod
private static method onInit takes nothing returns nothing
local trigger trig = CreateTrigger()
call Heal_RegisterEvent(trig)
call TriggerAddCondition(trig,Condition(function cond))
endmethod
endstruct