• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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