Prometheus
Everything is mutable; nothing is sacred
- Reaction score
- 590
Synergistic Energy eXchange
This is a system I spent all day (with large breaks) completing and ironing out all the bugs. Hope you enjoy my SEX system, it requires AIDS.
It gives all units on your map the chance to even out their life, great when near high-HP buildings, but can damage them. Can work for or against you.
JASS:
library SEX requires AIDS
// SEX
// Synergistic Energy eXchange
// 'v'one.oh-nein //
// When a unit comes within range of another unit, their hp and mana will balance out.
// If the unit they ran into has a lower maximum health and/or mana, it will still try to balance.
// Permanent!
//
//
// *Credits*
// Jesus5Lyf
// Romeh
// Renend
// Flarz
// Foop
// Ken!
globals
private constant real RANGE = 200
//Range for proc.
private constant integer PROCCHANCE = 10000
//Higher = Greater Chance, up to 10000.
private group g = CreateGroup()
endglobals
private function FailSafe takes nothing returns boolean
return true
endfunction
private function Shares takes nothing returns boolean
local unit u
local unit q
local unit z = GetTriggerUnit()
local real hp = 0
local real mana = 0
local real dist1 = 0
local real dist2 = 0
local real xz = GetUnitX(z)
local real xq
local real yz = GetUnitY(z)
local real yq
call GroupEnumUnitsInRange(g,GetUnitX(z),GetUnitY(z),RANGE,Condition(function FailSafe))
loop
exitwhen FirstOfGroup(g) == null
set q = FirstOfGroup(g)
set xq = GetUnitX(q)
set yq = GetUnitY(q)
set dist2 = ((xz-xq)*(xz-xq))+((yz-yq)*(yz-yq))
if dist1 == 0 or dist1 < dist2 then
set dist1 = dist2
set u = q
endif
call GroupRemoveUnit(g,q)
endloop
if GetRandomInt(1,10000) <= PROCCHANCE then
set hp = GetWidgetLife(z) + GetWidgetLife(u)
set mana = GetUnitState(z,UNIT_STATE_MANA) + GetUnitState(u,UNIT_STATE_MANA)
call SetWidgetLife(z,hp/2)
call SetUnitState(z,UNIT_STATE_MANA,mana/2)
call SetWidgetLife(u,hp/2)
call SetUnitState(u,UNIT_STATE_MANA,mana/2)
endif
set u = null
set q = null
set z = null
return false
endfunction
private struct Spawnings extends array
//! runtextmacro AIDS()
private trigger trig
private static method AIDS_filter takes unit u returns boolean
return GetUnitAbilityLevel(u,039;Aloc039;) == 0
endmethod
private method AIDS_onCreate takes nothing returns nothing
set this.trig = CreateTrigger()
call TriggerAddCondition(this.trig,Condition(function Shares))
call TriggerRegisterUnitInRange(this.trig,this.unit,RANGE,Condition(function FailSafe))
endmethod
private method AIDS_onDestroy takes nothing returns nothing
call DestroyTrigger(this.trig)
endmethod
endstruct
endlibrary
This is a system I spent all day (with large breaks) completing and ironing out all the bugs. Hope you enjoy my SEX system, it requires AIDS.
It gives all units on your map the chance to even out their life, great when near high-HP buildings, but can damage them. Can work for or against you.