AceLegend90
New Member
- Reaction score
- 6
After much time spent debugging this code, I've figured out that the problem is that GetCSData(GetTriggeringTrigger()) isn't actually getting the struct that I attached.
Does anyone see the problem with my code? (It uses Vexorian's Caster System.)
Does anyone see the problem with my code? (It uses Vexorian's Caster System.)
JASS:
scope Envision
private struct Envision
unit caster
unit target
real damage
trigger effects
timer clock
static method Conditions takes nothing returns boolean
if GetSpellAbilityId() == 039;A077039; and GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_CAST then
if GetUnitAbilityLevel(GetSpellTargetUnit(), 039;B01E039;) > 0 then
call PauseUnit(GetTriggerUnit(), true)
call IssueImmediateOrder(GetTriggerUnit(), "stop")
call PauseUnit(GetTriggerUnit(), false)
call DisplayErrorToPlayer(GetTriggerPlayer(), "Cannot stack Envision.")
endif
return false
endif
return GetSpellAbilityId() == 039;A077039;
endmethod
static method Start takes nothing returns nothing
local Envision spell = Envision.allocate()
set spell.caster = GetTriggerUnit()
set spell.target = GetSpellTargetUnit()
set spell.damage = 0.
set spell.effects = CreateTrigger()
call SetCSData(spell.effects, spell)
call TriggerRegisterTimerEvent(spell.effects, .05, true)
call TriggerRegisterUnitEvent(spell.effects, spell.target, EVENT_UNIT_DAMAGED)
call TriggerAddCondition(spell.effects, Condition(function Envision.TimerEnd))
endmethod
static method TimerEnd takes nothing returns boolean
local Envision spell = GetCSData(GetTriggeringTrigger())
if GetTriggerEventId() == EVENT_UNIT_DAMAGED then
call spell.DamageTarget()
else
call spell.IncreaseDamage()
endif
return false
endmethod
method IncreaseDamage takes nothing returns nothing
if .damage < 50. then
set .damage = .damage + .05 + .0375 * GetUnitAbilityLevel(.caster, 039;A077039;)
endif
if IsUnitFogged(.target, GetOwningPlayer(.caster)) or GetWidgetLife(.target) <= 0. then
call .destroy()
endif
endmethod
method DamageTarget takes nothing returns nothing
call DisableTrigger(.effects)
if GetEventDamageSource() == .caster and GetEventDamage() > 5. then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl", .target, "chest"))
call UnitDamageTarget(.caster, .target, .damage, true, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
endif
call EnableTrigger(.effects)
endmethod
method onDestroy takes nothing returns nothing
call UnitRemoveAbility(.target, 039;B01E039;)
call SafeDestroyTrigger(.effects)
endmethod
endstruct
function Start_Envision takes nothing returns nothing
local trigger init = CreateTrigger()
call TriggerRegisterAnyUnitEvent(init, EVENT_PLAYER_UNIT_SPELL_CAST)
call TriggerRegisterAnyUnitEvent(init, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(init, Condition(function Envision.Conditions))
call TriggerAddAction(init, function Envision.Start)
endfunction
endscope
function InitTrig_Envision takes nothing returns nothing
endfunction