Crusher
You can change this now in User CP.
- Reaction score
- 121
In this trigger, when the caster is knocked back, the lightning effects stay on the position of caster, eg. previous casting location, but they aren't removed. So, I thought maybe the solution is to add additional line of function which will check if the caster stopped channeling a spell, but the problem is: I don't know to JASS that!
If anyone could help or you have any other possibilities to fix this, please reply here at this very thread.
If anyone could help or you have any other possibilities to fix this, please reply here at this very thread.
JASS:
//******************************************************************************
//* *
//* Quench Life *
//* v1.02 *
//* *
//* By: Rising_Dusk *
//* *
//******************************************************************************
//**************************************
//* LIBRARY REQUIREMENTS:
//* - GroupUtils
//* - UnitIndexingUtils
//*
scope QuenchLife initializer Init
globals
//*************************************************************
//* Configuration Constants
//* Raw codes
private constant integer SPELL_ID = 039;A03O039;
private constant integer DUMMY_ID = 039;h012039;
private constant string ORDER_STRING = "starfall"
//* Lightning related
private constant integer LIGHTNING_COUNT = 6
private constant integer LIGHTNING_TO_GO_LEFT = 3
private constant string LIGHTNING_TYPE = "DRAL"
private constant real LIGHTNING_Z_OFFSET = 450.
private constant real LIGHTNING_ANGLE_OFFSET = 2*bj_PI/3
private constant real LIGHTNING_ANGLE_SHIFT = bj_PI/40
//* Spell related
private constant real AREA_OF_EFFECT = 600.
//* Damage properties
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_UNIVERSAL
//* System related
private constant real TIMER_INTERVAL = 0.10
private constant integer ITERATIONS_TIL_EFFECT = 5
//* Effect placement
private constant string EFFECT_POINT = "origin"
//*************************************************************
//* System Variables
private group CastGroup = CreateGroup()
private timer ScanTimer = CreateTimer()
private player TempPlayer = null
private boolexpr HealChecker = null
private boolexpr DamageChecker = null
private integer array Glowies
private trigger Trg = CreateTrigger()
endglobals
//*****************************************************************
//* Configuration Functions
private constant function LifeStolen takes integer lvl returns real
//* Life stolen per second
return 9.
endfunction
private function EndConditions takes unit u, integer lvl returns boolean
//* Conditions that bring about the spell's end
//* Returns false if conditions not met
return GetUnitCurrentOrder(u) != OrderId(ORDER_STRING)
endfunction
private function DamageCheck takes nothing returns boolean
//* Boolean expression for which units to damage
return IsUnitEnemy(GetFilterUnit(), TempPlayer) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) and GetWidgetLife(GetFilterUnit()) > 0.405 and GetUnitAbilityLevel(GetFilterUnit(), 039;Avul039;) <= 0.
endfunction
private function HealCheck takes nothing returns boolean
//* Boolean expression for which units to heal
return IsUnitAlly(GetFilterUnit(), TempPlayer) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) and GetWidgetLife(GetFilterUnit()) > 0.405 and GetUnitAbilityLevel(GetFilterUnit(), 039;Avul039;) <= 0.
endfunction
//*****************************************************************
private struct glowyhax
lightning array orbital[4]
integer level = 0
integer index = 0
unit attach = null
real angle1 = 0.
real angle2 = 0.
static method create takes unit u returns glowyhax
local glowyhax g = glowyhax.allocate()
local integer i = 1
local real x = GetUnitX(u)
local real y = GetUnitY(u)
set g.attach = CreateUnit(GetOwningPlayer(u), DUMMY_ID, x, y, 0.)
set g.level = GetUnitAbilityLevel(u, SPELL_ID)
set g.angle1 = GetUnitFacing(u)*bj_DEGTORAD
set g.angle2 = g.angle1 + bj_PI/2
if IsUnitType(g.attach, UNIT_TYPE_GROUND) then
call UnitAddAbility(g.attach, 039;Amrf039;)
call UnitRemoveAbility(g.attach, 039;Amrf039;)
endif
call SetUnitFlyHeight(g.attach, LIGHTNING_Z_OFFSET, 0.)
call PauseUnit(g.attach, true)
call SetUnitX(g.attach, x)
call SetUnitY(g.attach, y)
loop
exitwhen i > LIGHTNING_COUNT
set g.orbital<i> = null
set i = i + 1
endloop
return g
endmethod
private method onDestroy takes nothing returns nothing
local integer i = 1
//* Clean up all lightning effects
loop
exitwhen i > LIGHTNING_COUNT
call DestroyLightning(this.orbital<i>)
set i = i + 1
endloop
call KillUnit(this.attach)
endmethod
endstruct
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function Enumeration takes nothing returns nothing
local unit e = GetEnumUnit()
local unit s = null
local integer id = GetUnitId(e)
local glowyhax g = Glowies[id]
local integer lvl = g.level
local integer i = 1
local location l = GetUnitLoc(e)
local real dmg = LifeStolen(lvl)
local real xi = GetLocationX(l)
local real yi = GetLocationY(l)
local real zi = GetLocationZ(l)
local real xf = 0.
local real yf = 0.
local real zf = 0.
local real a = g.angle1
local real r = 0.
//* Do stuff for the channeled ability's visual
call RemoveLocation(l)
loop
exitwhen i > LIGHTNING_COUNT
//* Do some projections
set xf = xi + AREA_OF_EFFECT*Cos(a)
set yf = yi + AREA_OF_EFFECT*Sin(a)
set l = Location(xf, yf)
set zf = GetLocationZ(l)
call RemoveLocation(l)
//* Move the lightning effect
if g.orbital<i> != null then
call MoveLightningEx(g.orbital<i>, true, xi, yi, LIGHTNING_Z_OFFSET+zi, xf, yf, zf)
else
set g.orbital<i> = AddLightningEx(LIGHTNING_TYPE, true, xi, yi, LIGHTNING_Z_OFFSET+zi, xf, yf, zf)
endif
call DestroyEffect(AddSpellEffectTargetById(SPELL_ID, EFFECT_TYPE_EFFECT, g.attach, "origin"))
call DestroyEffect(AddSpellEffectById(SPELL_ID, EFFECT_TYPE_EFFECT, xf, yf))
//* Update the angle of the rotation properly
if i < LIGHTNING_TO_GO_LEFT then
set a = a - LIGHTNING_ANGLE_OFFSET
elseif i == LIGHTNING_TO_GO_LEFT then
set a = g.angle2
elseif i > LIGHTNING_TO_GO_LEFT then
set a = a + LIGHTNING_ANGLE_OFFSET
endif
set i = i + 1
endloop
set g.angle1 = g.angle1 + LIGHTNING_ANGLE_SHIFT
set g.angle2 = g.angle2 - LIGHTNING_ANGLE_SHIFT
set g.index = g.index + 1
//* Don't forget to have the ability actually do something useful
set TempPlayer = GetOwningPlayer(e)
call GroupEnumUnitsInRange(ENUM_GROUP, xi, yi, AREA_OF_EFFECT, DamageChecker)
loop
set s = FirstOfGroup(ENUM_GROUP)
exitwhen s == null
if ModuloInteger(g.index, ITERATIONS_TIL_EFFECT) == 0 then
call DestroyEffect(AddSpellEffectTargetById(SPELL_ID, EFFECT_TYPE_TARGET, s, EFFECT_POINT))
endif
call UnitDamageTarget(e, s, dmg*TIMER_INTERVAL, false, false, ATTACK_TYPE, DAMAGE_TYPE, null)
set r = r + dmg*TIMER_INTERVAL
call GroupRemoveUnit(ENUM_GROUP, s)
endloop
//* Now distribute the life evenly to allies
call GroupEnumUnitsInRange(ENUM_GROUP, xi, yi, AREA_OF_EFFECT, HealChecker)
if FirstOfGroup(ENUM_GROUP) != null and r > 0. then
//* Make sure no divide by zero or bad stuff
set bj_groupCountUnits = 0
call ForGroup(ENUM_GROUP, function CountUnitsInGroupEnum)
set r = r / bj_groupCountUnits
loop
set s = FirstOfGroup(ENUM_GROUP)
exitwhen s == null
if ModuloInteger(g.index, ITERATIONS_TIL_EFFECT) == 0 then
call DestroyEffect(AddSpellEffectTargetById(SPELL_ID, EFFECT_TYPE_SPECIAL, s, EFFECT_POINT))
endif
call SetWidgetLife(s, GetWidgetLife(s) + dmg)
call GroupRemoveUnit(ENUM_GROUP, s)
endloop
endif
//* Check duration and do stuff if spell is over
if EndConditions(e, lvl) then
call GroupRemoveUnit(CastGroup, e)
call g.destroy()
endif
call GroupClear(ENUM_GROUP)
set e = null
set s = null
set l = null
endfunction
private function Callback takes nothing returns nothing
call ForGroup(CastGroup, function Enumeration)
if FirstOfGroup(CastGroup) == null then
call PauseTimer(ScanTimer)
endif
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer id = GetUnitId(u)
local glowyhax g = glowyhax.create(u)
//* Load caster to group for enumeration
if FirstOfGroup(CastGroup) == null then
call TimerStart(ScanTimer, TIMER_INTERVAL, true, function Callback)
endif
call GroupAddUnit(CastGroup, u)
set Glowies[id] = g
set u = null
endfunction
private function Init takes nothing returns nothing
call TriggerAddAction(Trg, function Actions)
call TriggerAddCondition(Trg, Condition(function Conditions))
call TriggerRegisterAnyUnitEventBJ(Trg, EVENT_PLAYER_UNIT_SPELL_EFFECT)
set DamageChecker = Condition(function DamageCheck)
set HealChecker = Condition(function HealCheck)
endfunction
endscope
</i></i></i></i></i>