• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] [OLY] LightShield - Coding solution needed !!!

Status
Not open for further replies.
And, for good coding, I am using it on the Init function, where all triggers should be set.

However I have a problem ... this event takes a unit !!!
I don't see a way to fix this without using dynamic triggers, but I know they are evil !
Please some one help me find a solution !

[jass=full code]
//Uses TimerUtils so far
scope LightShield initializer Init
globals
private constant integer AID = 'A001'
endglobals

private constant function Duration takes integer level returns real
return level * 20.
endfunction

private constant function DamageAbsorbed takes integer level returns real
return level * 100.
endfunction
//===========================================================================
private struct MyStruct
unit caster
unit target
integer level
timer dur

static method create takes unit caster, unit target, integer level returns MyStruct
local MyStruct data = MyStruct.allocate()

set data.caster = caster
set data.level = level
set data.target = target
set data.dur = NewTimer()

return data
endmethod

method onDestroy takes nothing returns nothing
call ReleaseTimer(.dur)
endmethod
endstruct
//===========================================================================
private function onDamage takes nothing returns boolean
return true
endfunction
//===========================================================================
private function PreventDamage takes nothing returns nothing
endfunction
//===========================================================================
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == AID
endfunction
//===========================================================================
private function Actions takes nothing returns nothing
local MyStruct data = MyStruct.create(GetTriggerUnit(), GetSpellTargetUnit(), GetUnitAbilityLevel(GetTriggerUnit(), AID))

endfunction
//===========================================================================
private function Init takes nothing returns nothing
//when the hero casts the spell
local trigger LightShieldTrg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( LightShieldTrg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(LightShieldTrg, Condition(function Conditions))
call TriggerAddAction(LightShieldTrg, function Actions)

//when the hero takes damage
set LightShieldTrg = CreateTrigger( )

//PROBLEM !!! This takes a unit !! how do I make this without a dinamic trigger ?
// call TriggerRegisterUnitEvent (LightShieldTrg, targ, EVENT_UNIT_DAMAGED )
call TriggerAddCondition(LightShieldTrg, Condition(function onDamage))
call TriggerAddAction(LightShieldTrg, function PreventDamage)

set LightShieldTrg = null
endfunction
endscope[/code]
 
Thx for posting friend. I am using a Damage Detection small system made by Moyack. Let's see where this leads me.

EDIT EDIT EDIT

OMG, Moyacks Damage Detection engine doesn't work to cause damage.
PP, I need help ! is there any other Damage Detection engines you know that may help me ?? (that are not outdated and not made by Rising_Dusk xD) ???

If this continues, I will have to do my own damage system ... but I don't even know how =(
 
Status
Not open for further replies.
Top