LearningCode
New Member
- Reaction score
- 24
This spell was supposed to create a "dummy" to circle around the hero.
The dummy damages enemy units that it touches.
The type of dummy the spell creates is based on which passive ability the hero has activated.
1)Fire - Bonus damage, immolation
2)Ice - Bonus damage, slow movespeed
Problem is this:
1) I use the fire passive and cast the spell
2) Spell creates a fire dummy
3) Fire dummy passes through enemy units
4) Enemy units are damaged and receive "Burned" buff
5) Red floating text stating damage dealt is created (22 damage)
6) Fire dummy is still there
7) I use the ice passive and cast the spell
8) Spell creates an ice dummy
9) Fire dummy and Ice dummy now exist and are rotating around hero
10) Fire dummy passes through enemy units
11) Enemy units are damaged but receive "Slowed" buff
12) Blue floating text stating damage dealt is created (11 damage)
13) Ice dummy passes through enemy units
14) Enemy units are damaged and receive "Burned" buff
15) Red floating text stating damage dealt is created (22 damage)
What is supposed to happen:
1) I use the fire passive and cast the spell
2) Spell creates a fire dummy
3) Fire dummy passes through enemy units
4) Enemy units are damaged and receive "Burned" buff
5) Red floating text stating damage dealt is created (22 damage)
6) Fire dummy is still there
7) I use the ice passive and cast the spell
8) Spell creates an ice dummy
9) Fire dummy and Ice dummy now exist and are rotating around hero
10) Fire dummy passes through enemy units
11) Enemy units are damaged and receive "Burned" buff
12) Red floating text stating damage dealt is created (22 damage)
13) Ice dummy passes through enemy units
14) Enemy units are damaged but receive "Slowed" buff
15) Blue floating text stating damage dealt is created (11 damage)
Thing is, when the Fire dummy expires, leaving the Ice dummy behind..
The Ice dummy gives enemies the "Slowed" buff and show a blue floating text.
Meaning, only one Dummy can exist or it bugs.
Same applies if I summon the Ice dummy first, then the Fire dummy
I want this spell to not bug, but don't know how to go about it =/
I tried setting the value of an integer (Element) to a value when the Hero casts the summoning spell..
But it doesn't solve the problem
The dummy damages enemy units that it touches.
The type of dummy the spell creates is based on which passive ability the hero has activated.
1)Fire - Bonus damage, immolation
2)Ice - Bonus damage, slow movespeed
Problem is this:
1) I use the fire passive and cast the spell
2) Spell creates a fire dummy
3) Fire dummy passes through enemy units
4) Enemy units are damaged and receive "Burned" buff
5) Red floating text stating damage dealt is created (22 damage)
6) Fire dummy is still there
7) I use the ice passive and cast the spell
8) Spell creates an ice dummy
9) Fire dummy and Ice dummy now exist and are rotating around hero
10) Fire dummy passes through enemy units
11) Enemy units are damaged but receive "Slowed" buff
12) Blue floating text stating damage dealt is created (11 damage)
13) Ice dummy passes through enemy units
14) Enemy units are damaged and receive "Burned" buff
15) Red floating text stating damage dealt is created (22 damage)
What is supposed to happen:
1) I use the fire passive and cast the spell
2) Spell creates a fire dummy
3) Fire dummy passes through enemy units
4) Enemy units are damaged and receive "Burned" buff
5) Red floating text stating damage dealt is created (22 damage)
6) Fire dummy is still there
7) I use the ice passive and cast the spell
8) Spell creates an ice dummy
9) Fire dummy and Ice dummy now exist and are rotating around hero
10) Fire dummy passes through enemy units
11) Enemy units are damaged and receive "Burned" buff
12) Red floating text stating damage dealt is created (22 damage)
13) Ice dummy passes through enemy units
14) Enemy units are damaged but receive "Slowed" buff
15) Blue floating text stating damage dealt is created (11 damage)
Thing is, when the Fire dummy expires, leaving the Ice dummy behind..
The Ice dummy gives enemies the "Slowed" buff and show a blue floating text.
Meaning, only one Dummy can exist or it bugs.
Same applies if I summon the Ice dummy first, then the Fire dummy
I want this spell to not bug, but don't know how to go about it =/
I tried setting the value of an integer (Element) to a value when the Hero casts the summoning spell..
But it doesn't solve the problem
JASS:
scope Familiar initializer Familiar
private struct Fam
private static Fam data = 0
private static hashtable ht = InitHashtable()
group FamiliarRange = CreateGroup()
unit caster //Hero
unit familiar //Familiar
integer A01PLevel //Napalm Blade
integer A01TLevel //Arctic Blade
integer AGI //Hero Agility
integer ticks=0 //Number of cycles
timer t //Time in between commands
real Cx //Caster X
real Cy //Caster Y
real Fx //Familiar X
real Fy //Familiar Y
real rad //Radian
real r = 400.00 //Distance Between Hero and Familiar
integer i = 0 //To ensure that only one unit casts roar, which has 200AOE
integer Element //To ensure that this trigger takes the correct A01P or A01T level
integer A01YLevel //Familiar Level
group damagedunits = CreateGroup() //Ensures units are damaged once per round?
static method FamGroup takes nothing returns boolean
local unit u = GetFilterUnit()
local Fam f = Fam.data
local real damage
local location l = Location(GetUnitX(u), GetUnitY(u))
if IsUnitEnemy(u, GetOwningPlayer(f.caster)) == true and IsUnitInGroup(u, f.damagedunits) == false then
if f.Element == 1 then
if f.A01PLevel / 2 == 0 then
set damage = I2R(R2I((((f.A01PLevel * 0.5) * f.AGI)))) * (f.A01YLevel * 0.1)
else
set damage = I2R(R2I(((((f.A01PLevel+1) * 0.5) * f.AGI)))) * (f.A01YLevel * 0.1)
endif
if f.i == 0 then
call UnitAddAbility(u, 039;Aroa039;)
call IssueImmediateOrder(u, "roar")
set f.i = 1
endif
call DestroyEffect(AddSpecialEffectTarget("Environment\\UndeadBuildingFire\\UndeadLargeBuildingFire2.mdl", u, "chest"))
call CreateTextTagLocBJ( I2S(R2I(damage))+"!", l, 0, 10, 100, 0,0, 0 )
else
if f.A01TLevel / 2 == 0 then
set damage = I2R(R2I(((((f.A01TLevel) * 0.25) * f.AGI)))) * (f.A01YLevel * 0.1)
else
set damage = I2R(R2I((((((f.A01TLevel)+1) * 0.25) * f.AGI)))) * (f.A01YLevel * 0.1)
endif
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\FrostArmor\\FrostArmorDamage.mdl", u, "chest"))
call CreateTextTagLocBJ( I2S(R2I(damage))+"!", l, 0, 10, 0, 0, 100, 0 )
call UnitAddAbility(u, 039;ANab039;)
call SetUnitAbilityLevel(u, 039;ANab039;, f.A01TLevel)
call IssueTargetOrder(u, "acidbomb", u)
call UnitRemoveAbility(u, 039;ANab039;)
endif
call SetTextTagLifespanBJ( bj_lastCreatedTextTag, 1.00 )
call SetTextTagPermanentBJ( bj_lastCreatedTextTag, false )
call UnitDamageTarget(f.caster,u,damage,false,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_FIRE,null)
call GroupAddUnit(f.damagedunits, u)
endif
if GetUnitAbilityLevel(u, 039;Aroa039;) > 0 then
call UnitRemoveAbility(u, 039;Aroa039;)
endif
set u = null
call RemoveLocation(l)
set l = null
return false
endmethod
static method FamTimer takes nothing returns nothing
local Fam f = LoadInteger(Fam.ht, GetHandleId(GetExpiredTimer()), 0)
local integer tickcount
if f.ticks < 641 then
call GroupEnumUnitsInRange(f.FamiliarRange, f.Fx, f.Fy, 200.00, function Fam.FamGroup)
set f.rad = f.rad + 0.070
set f.Cx = GetUnitX(f.caster)
set f.Cy = GetUnitY(f.caster)
set f.Fx = f.Cx + f.r * Cos(f.rad)
set f.Fy = f.Cy + f.r * Sin(f.rad)
call SetUnitX(f.familiar, f.Fx)
call SetUnitY(f.familiar, f.Fy)
set f.ticks = f.ticks+1
set Fam.data = f
set f.i = 0
set tickcount = f.ticks/10
if tickcount == 0 then
call BJDebugMsg("Clearing groups")
call GroupClear(f.damagedunits)
endif
else
call f.destroy()
endif
endmethod
static method FamAct takes nothing returns nothing
local Fam f = Fam.allocate()
set f.caster = GetTriggerUnit()
set f.Cx = GetUnitX(f.caster)
set f.Cy = GetUnitY(f.caster)
set f.rad = GetUnitFacing(f.caster) * bj_DEGTORAD
set f.Fx = f.Cx + f.r * Cos(f.rad)
set f.Fy = f.Cx + f.r * Sin(f.rad)
set f.A01PLevel = GetUnitAbilityLevel(f.caster, 039;A01P039;)
set f.A01TLevel = GetUnitAbilityLevel(f.caster, 039;A01T039;)
set f.AGI = GetHeroAgi(f.caster, true)
set f.t = CreateTimer()
set f.A01YLevel = GetUnitAbilityLevel(f.caster, 039;A01Y039;)
call SaveInteger(f.ht, GetHandleId(f.t), 0, f)
if f.A01PLevel > f.A01TLevel then
set f.Element = 1
set f.familiar = CreateUnit(GetOwningPlayer(f.caster), 039;h004039;, f.Fx, f.Fy, (f.rad + 1.57))
elseif f.A01TLevel > f.A01PLevel then
set f.Element = 2
set f.familiar = CreateUnit(GetOwningPlayer(f.caster), 039;h005039;, f.Fx, f.Fy, (f.rad + 1.57))
endif
call TimerStart(f.t, 0.03125, true, function Fam.FamTimer)
endmethod
method onDestroy takes nothing returns nothing
call RemoveUnit(this.familiar)
call PauseTimer(this.t)
set this.caster = null
set this.familiar = null
call GroupClear(this.damagedunits)
call DestroyGroup(this.damagedunits)
set this.damagedunits = null
endmethod
endstruct
private function FamCond takes nothing returns boolean
return GetSpellAbilityId() == 039;A01Y039;
endfunction
//===========================================================================
function Familiar takes nothing returns nothing
local trigger t = CreateTrigger( )
local integer i = 0
loop
exitwhen i == 8
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i = i+1
endloop
call TriggerAddCondition(t, Condition(function FamCond))
call TriggerAddAction( t, function Fam.FamAct )
endfunction
endscope