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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top