Spell is screwed

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 :confused:

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, 'Aroa')
                  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, 'ANab')
                  call SetUnitAbilityLevel(u, 'ANab', f.A01TLevel)
                  call IssueTargetOrder(u, "acidbomb", u)
                  call UnitRemoveAbility(u, 'ANab')
               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, 'Aroa') > 0 then
                call UnitRemoveAbility(u, 'Aroa')
            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, 'A01P')
            set f.A01TLevel = GetUnitAbilityLevel(f.caster, 'A01T')
            set f.AGI = GetHeroAgi(f.caster, true)
            set f.t = CreateTimer()
            set f.A01YLevel = GetUnitAbilityLevel(f.caster, 'A01Y')
            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), 'h004', 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), 'h005', 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() == 'A01Y'
   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
 

LearningCode

New Member
Reaction score
24
Didn't want to do this =/
Bump.

I could post a map with the triggers if it helps..

I'm assuming that this spell is not MUI, because, apparently, A01TLEvel and A01PLevel are being over-written, I guess.
And something is making the dummies behave strangely =/
 

millz-

New Member
Reaction score
25
I am not really good at vJass so, should those methods be in the struct? I don't know, I thought structs only contain the variables that it should have. Please correct me if I am wrong.
 

LearningCode

New Member
Reaction score
24
methods are something like, functions, except in a struct xD
I really don't know =x

The spell works absolutely fine.
Except for one bug and I am not happy with that bug ._.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
zz, you didn't add damaged units in a group. They are keeping picked and damaged.
[ljass] ModuloInteger(f.A01PLevel, 2) == 0 [/ljass], what are you trying to do this with?
If you wan proc the change, use [ljass]GetRandomInt[/ljass].
 

LearningCode

New Member
Reaction score
24
I want to see if the level of the ability that the hero currently has is divisable by 2 =x
I thought ModuloInteger was the thing xD

Yea, I kinda' realized that the units are repeatedly getting picked and damaged after a while =/
But if you add the damaged units to a group..
Then won't it only be possible to damage units once?

I want it such that enemy units are damaged as they get hit by the spell every time.
Not enemy units getting damaged only once per cast.
Because the enemy units are getting damaged repeatedly, I scaled the damage down so that it doesn't kill enemies off so easily.

But me bugs have nothing to do with those =x
 

LearningCode

New Member
Reaction score
24
bump with slightly modified trigger =x

Still having the same issues with fire dummy dealing ice damage and ice dummy dealing fire damage.

I added the Damaged Units group thingy, so that the enemy units don't get picked repeatedly.
I also added that if the ticks is divisible by 10, it'll clear the group.

Problem is, now, the dummy only damages enemy units once and never seems to clear the Damaged Units group =/
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top