- Joined
- Jul 10, 2007
- Messages
- 6,306
Will eventually have an AutoEvent API to support things running on that system : D.
So you've basically remade AutoIndex and AutoEvents, considering this requires your unit indexer, you don't even have optional support for AutoIndex. AutoIndex is about as good as unit indexing gets.
I see, so you want to have support for that; I still think that this is not a necessity to JASS programming, you're remaking what has already been made.
private static method addRessurrect takes nothing returns nothing // Coming back to life -> allocate
local unit u = GetTriggerUnit()
local real decay = DECAY_TIME + 10.0
if IsUnitType(u, UNIT_TYPE_HERO) then
set decay = HERO_REVIVE_TIME + 100.0
endif
loop
call TriggerSleepAction(0.25)
if UnitAlive(u) then
call retro.add(u)
exitwhen true
endif
set decay = decay - 0.25
exitwhen decay <= 0.00
exitwhen u == null
endloop
set u = null
endmethod
private static method removeOnDeath takes nothing returns boolean // Death -> deallocate
local retro this = retro.create(GetTriggerUnit())
if this > 0 then
call .remove()
call ExecuteFunc(addRessurrect.name)
endif
return false
endmethod
private static method addInitial takes nothing returns boolean // Exists -> allocate
local retro this = retro.add(AIDS_GetEnteringIndexUnit())
if this > 0 and .deathEvent == null then
set .deathEvent = CreateTrigger()
call TriggerAddCondition(.deathEvent, Filter(function retro.removeOnDeath))
call TriggerRegisterUnitStateEvent(.deathEvent, .subject, UNIT_STATE_LIFE, LESS_THAN, 0.405)
endif
return false
endmethod
call TriggerRegisterUnitStateEvent(.deathEvent, .subject, UNIT_STATE_LIFE, LESS_THAN, 0.405)
Super epic design failure, eh? I fail to see how jumping on the bandwagon of "undefend" makes everything super epic fail, because I don't like to "test" things into existence, I like to see exactly what I'm working with so that if I come across a similar problem in the future I have a logical solution to it.
An "undefend" detection is not going to help in real scope.
Indeed.
You've got a lot of skills in the JASS field that I feel are just being thrown away by creating something anew that's been done before
Any way you could make it require something more generally used, or even nothing at all?
Why does this need to be a seperate library from UnitIndexer? I'm curious, if a hero dies with reincarnation, will the onDeath event fire?
I just need: HP goes below zero; unit comes back to life; unit enters/exits transport (and of course the events provided by unit indexer).
//
private method unitStartReincarnate takes nothing returns nothing
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(this)+":"+ GetUnitName(unit) + " is reincarnating")
endmethod
private method unitReincarnate takes nothing returns nothing
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(this)+":"+ GetUnitName(unit) + " reincarnated")
endmethod
unit enters/exits transport
struct MyStruct extends array
implement UnitEventStruct
endstruct
//
private method unitDeath takes nothing returns nothing
private method unitRemove takes nothing returns nothing
private method unitDecay takes nothing returns nothing
private method unitExplode takes nothing returns nothing
private method unitResurrect takes nothing returns nothing
private method unitStartReincarnate takes nothing returns nothing
private method unitReincarnate takes nothing returns nothing
private method unitAnimate takes nothing returns nothing
readonly unit unit
function OnUnitDeath takes boolexpr c returns nothing
function OnUnitRemove takes boolexpr c returns nothing
function OnUnitDecay takes boolexpr c returns nothing
function OnUnitExplode takes boolexpr c returns nothing
function OnUnitResurrect takes boolexpr c returns nothing
function OnUnitStartReincarnate takes boolexpr c returns nothing
function OnUnitReincarnate takes boolexpr c returns nothing
function OnUnitAnimate takes boolexpr c returns nothing
function GetEventUnit takes nothing returns unit
function GetEventUnitId takes nothing returns integer
call TriggerRegisterCustomUnitEvent(trigger, EVENT_UNIT_REINCARNATION)
function OnUnitMove takes boolexpr b returns nothing
from http://www.hiveworkshop.com/forums/jass-functions-413/isunitmoving-178341/public function RegisterOnEnterAllocated takes boolexpr b returns triggercondition
constant integer UNIT_EVENT_DEATH = 0
constant integer UNIT_EVENT_REMOVE = 1
constant integer UNIT_EVENT_DECAY = 2
constant integer UNIT_EVENT_EXPLODE = 3
constant integer UNIT_EVENT_RESURRECT = 4
constant integer UNIT_EVENT_START_REINCARNATE = 5
constant integer UNIT_EVENT_REINCARNATE = 6
constant integer UNIT_EVENT_ANIMATE = 7
public function RunEvent takes integer i returns nothing
loop
set i = next[i]
exitwhen end[i]
if (IsTriggerEnabled(trig[i])) then
if (TriggerEvaluate(trig[i])) then
call TriggerExecute(trig[i])
endif
else
call EnableTrigger(trig[i])
if (IsTriggerEnabled(trig[i])) then
call DisableTrigger(trig[i])
else
set previous[next[i]] = previous[i]
set next[previous[i]] = next[i]
set trig[i] = null
set next[i] = recycle
set recycle = i
endif
endif
endloop
endfunction
exitwhen end[i]
is correct, but exitwhen end[i] == true
works as well, although it is slower.And please never do this for UnitIndexer. Tooltip seems to be a nutter for wanting a setup like this in the first place.
function IsUnitDead takes integer index returns boolean
return z[index]
endfunction
IsUnitDeadById, IsUnitReincarnatingById, IsUnitAnimatedById
.405<GetWidgetLife(u) and 0!=GetUnitTypeId(u)
= ).it'll break whatever's using it ;p