phyrex1an
Staff Member and irregular helper
- Reaction score
- 447
JASS:
// ...
function Prism_End takes nothing returns boolean
local trigger trig = GetTriggeringTrigger()
local Prism prism = GetData(trig)
call prism.stopChannelPrism()
call DestroyTrigger(trig)
set trig = null
return false
endfunction
// The attach method here is currently global.
// In my "maps" I use the same struct id for all structs that a unit has attached
// so I can use the unit custom value without any problems.
// Note: I don't really know if this code works, it is supposed to make sure that
// a unit have one and never more Prism.
// Note2: The Prism are NEVER destroyed in this code, this has to be fixed. I suggest that you destroy them when a unit dies.
function Unit2Prism takes unit u returns Prism
local Prism p = Prism( GetData(u) )
if p == 0 then
set p = Prism.new(u)
call SetData(u, p)
endif
return p
endfunction
function Trig_Prism_Actions takes nothing returns nothing
local unit cast = GetTriggerUnit()
local unit targ = GetSpellTargetUnit()
local trigger trig = CreateTrigger()
local Prism prism = Unit2Prism(cast)
call prism.castPrismOn(Unit2Prism(targ))
call TriggerRegisterUnitEvent(trig,cast,EVENT_UNIT_SPELL_ENDCAST)
call TriggerAddCondition(trig,Condition(function Prism_End))
call SetData(trig,prism)
set cast = null
set targ = null
set trig = null
endfunction
// ...
JASS:
struct Prism
// ...
public method addBonus takes integer bonus returns nothing
set this.selfBonus = this.selfBonus + bonus
if this.selfBonus==1 then
call UnitAddAbility(this.prismUnit,get_abil(this.prismUnit))
else
call SetUnitAbilityLevel(this.prismUnit,get_abil(this.prismUnit),this.selfBonus)
endif
if this.target != 0 then
call this.target.addBonus(bonus)
endif
endmethod
public method removeBonus takes integer bonus returns nothing
set this.selfBonus = this.selfBonus - bonus
if this.selfBonus==0 then
call UnitRemoveAbility(this.prismUnit,get_abil(this.prismUnit))
else
call SetUnitAbilityLevel(this.prismUnit,get_abil(this.prismUnit),this.selfBonus)
endif
if this.target != 0 then
call this.target.removeBonus(bonus)
endif
endmethod
// ...
endstruct
It can work... Maybe...
>we need it updated, and I still dont get how to do it, do transfer bonuses around as links grow, to the last tower in a series, and to transfer the bonuses back to the last in a series if a part of the current series is broken
Is it important that just the last unit in the chain has the bonus? For a damage bonus that wouldn't matter but for a aura it is important. If it does matter then Prism.addBonus and Prism.removeBonus need to be somewhat changed.