Is this spell MUI/MPI/Leakless? (Death-Grip)

LearningCode

New Member
Reaction score
24
Yea, I normally wouldn't be so fussy about this..
(Unless the spell does not work at all =x)
But this spell is not for me, it's for a User named Bananarama1

The spell basically goes like this:
1) Hero casts Death Grip
2) Red Lightning chains hero and targeted unit
3) Targeted unit is dragged towards hero
4) Targeted unit is stunned and damaged

The spell works fine, but I'd like to know if it leaks or isn't MUI and MPI.

There's also one thing I'd like to change but cannot figure out.
If the targeted unit is, say, 600pixels away, the spell takes 0.6 seconds to drag the targeted unit to the hero. (Just an imaginary time)
But when the targeted unit is 50pixels away, the spell will still take 0.6 seconds to drag the targeted unit to the hero.

It's a bit irritating when you cast the spell from close range, lol.
How would I go about making this spell drag enemy units at a constant speed? o.0

This spell isn't my idea, some other guy thought of it first, I don't know who, lol

The gripping spell:
JASS:
// ===============================
// How the idea for this spell was conceived:
// This spell is not my idea.
// I just made a JASS version of a spell Bananarama1 wanted 
// Someone else made a GUI version of this spell
// But the spell could not be targeted on enemy units except for neutral hostile
// The spell also makes the target unit move INSTANTLY to the caster
// Bananarama1 wanted it targetable on any enemy unit and the targeted unit to be 'pulled'
// ===============================
// I looked at the GUI triggers and, yea, it looked like something I could 'simplify'
// But, I'm not sure if this spell in MUI, MPI and leakless
// Could you guys check it out for me? o.0
// ===============================
// Spell name: Death Grip
// Effect: Enemy units targeted are drawn towards the caster and are stunned and damaged
// ===============================
// Question:
// ~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~
// How do I make it such that the targeted unit moves at a constant rate towards the caster?
// The targeted unit takes 0.625 seconds to move to the caster, Regardless of initial distance
// ~+~+~+~+~+~+~+~+~+~+~+~+~+~+~+~


scope DGPull initializer InitTrig

   globals
      private constant integer DGID = 'A000'
      //The raw-code of the Death-Grip Spell
      
      private constant integer DummyID = 'nzin'
      //The raw-code of the dummy summoned to stun the enemy
      
      private constant integer StormID = 'A001'
      //The raw-code of the StormBolt spell that the dummy will cast
      
      private constant integer TickAmount = 20
      //The number of ticks, more ticks mean a longer spell duration.
      
      private constant string WarCry = "COME OVER HERE!"
      //What you want the Floating Text Message to say
   endglobals

   private struct DG
      private static DG data = 0
      private static hashtable ht = InitHashtable()
      unit caster
      unit target
      timer t
      real uX
      real uY
      real uZ
      real cX
      real cY
      real cZ
      real distance
      real radian
      lightning Bzzt
      real movement
      integer ticks = 0
      trigger trig
      integer DGLevel
      real damage
      
      static method DGStun takes nothing returns nothing
         local DG d = DG.data
         local unit dummy
         
         set dummy = CreateUnit(GetOwningPlayer(d.caster), DummyID, d.cX, d.cY, bj_UNIT_FACING)
         call UnitAddAbility(dummy, StormID)
         call IssueTargetOrder(dummy, "thunderbolt", d.target)
         call UnitApplyTimedLife(dummy, 'BTLF', 1.00)
         set dummy = null
         
         call DestroyEffect(AddSpecialEffect("NewGroundEX.mdx", d.uX, d.uY))
         call PauseUnit(d.caster, false)
         call PauseUnit(d.target, false)
         call UnitDamageTarget(d.caster, d.target, d.damage, false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null)
         
         call d.destroy()
      endmethod
      
      
      static method DGTimer takes nothing returns nothing
         local DG d = LoadInteger(DG.ht, GetHandleId(GetExpiredTimer()), 0)
         local real moveit = d.distance - (d.ticks * d.movement)
         
         if d.ticks < TickAmount then
            set d.uX = GetUnitX(d.target)
            set d.uY = GetUnitY(d.target)
            set d.uZ = GetUnitFlyHeight(d.target)
            set d.cX = GetUnitX(d.caster)
            set d.cY = GetUnitY(d.caster)
            set d.cZ = GetUnitFlyHeight(d.caster)
            set d.uX = d.cX + (moveit) * Cos(d.radian)
            set d.uY = d.cY + (moveit) * Sin(d.radian)
            
            call SetUnitX(d.target, d.uX)
            call SetUnitY(d.target, d.uY)
            call MoveLightningEx(d.Bzzt, true, d.cX, d.cY, d.cZ, d.uX, d.uY, d.uZ)
            
            set d.ticks = d.ticks + 1
         
         else
            set DG.data = d
            call DG.DGStun()
         endif
      endmethod
      
      static method DGAct takes nothing returns nothing
         local DG d = DG.allocate()
         local texttag tag
         set d.trig = GetTriggeringTrigger()
         call DisableTrigger(d.trig)
         set d.caster = GetTriggerUnit()
         set d.target = GetSpellTargetUnit()
         set d.t = CreateTimer()
         set d.uX = GetUnitX(d.target)
         set d.uY = GetUnitY(d.target)
         set d.uZ = GetUnitFlyHeight(d.target)
         set d.cX = GetUnitX(d.caster)
         set d.cY = GetUnitY(d.caster)
         set d.cZ = GetUnitFlyHeight(d.caster)
         set d.radian = Atan2((d.uY - d.cY), (d.uX - d.cX))
         set d.distance = (d.uX - d.cX) / Cos(d.radian)
         set d.movement = d.distance / TickAmount
         set d.DGLevel = GetUnitAbilityLevel(d.caster, DGID)
         set d.damage = d.DGLevel * 125
         
         
         call PauseUnit(d.caster, true)
         call PauseUnit(d.target, true)
         call SetUnitPathing(d.target, false)
         set tag = CreateTextTagUnitBJ( WarCry, d.caster, 0, 14.00, 100.00, 0.00, 0.00, 0 )
         call SetTextTagPermanent( tag, false )
         call SetTextTagLifespan( tag, (TickAmount * 0.03125) )
         set d.Bzzt = AddLightningEx("AFOD", true, d.cX, d.cY, d.cZ, d.uX, d.uY, d.uZ)
         
         call TimerStart(d.t, 0.03125, true, function DG.DGTimer)
         call SaveInteger(d.ht, GetHandleId(d.t), 0, d)
         set tag = null
      endmethod
      
      
      method onDestroy takes nothing returns nothing
         call EnableTrigger(.trig)
         set .caster = null
         set .target = null
         call PauseTimer(.t)
         call DestroyTimer(.t)
         set .t = null
         call DestroyLightning(.Bzzt)
         set .Bzzt = null
         set .trig = null
      endmethod
   endstruct

   private function DGCond takes nothing returns boolean
      return GetSpellAbilityId() == DGID
   endfunction
   
   private function InitTrig 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 DGCond))
      call TriggerAddAction(t, function DG.DGAct)
   endfunction


endscope

The Remove Dummy Trigger:
JASS:
scope Dead initializer RemoveDummy
   
   globals
      private constant integer DummyID = 'nzin' 
      //The raw-code of the dummy summoned to stun the enemy
   endglobals
   
   private struct Dead
      private static Dead data = 0
      unit u
      
      static method DeadAct takes nothing returns nothing
         local Dead d = Dead.data
         call RemoveUnit(d.u)
         call d.destroy()
      endmethod
      
      static method DeadCond takes nothing returns boolean
         local Dead d = Dead.allocate()
         set d.u = GetTriggerUnit()
         set Dead.data = d
         if GetUnitTypeId(d.u) == DummyID then
            return true
         else
            call d.destroy()
            return false
         endif
      endmethod
      
      method onDestroy takes nothing returns nothing
         set .u = null
      endmethod
   
   endstruct
   
   private function RemoveDummy takes nothing returns nothing
      local trigger t = CreateTrigger()
      local integer i = 0
      
      loop
      exitwhen i == 12
         call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_DEATH, null)
      set i = i+1
      endloop
      call TriggerAddCondition(t, Condition(function Dead.DeadCond))
      call TriggerAddAction(t, function Dead.DeadAct)
   endfunction

endscope

[EDIT]
Wtf, the Spoilers don't work =/
 

Attachments

  • SS1.png
    SS1.png
    75.6 KB · Views: 174
  • SS2.png
    SS2.png
    52.6 KB · Views: 129
  • SS3.png
    SS3.png
    132.2 KB · Views: 156
  • SS4.png
    SS4.png
    207.6 KB · Views: 165
  • Death Grip JASSified.w3x
    23.5 KB · Views: 125

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
You can throw away the dummy removal trigger. Death units are auto removed after their death time.
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
It looks Mui and Leakless.

Thought, you should use TimerUtils or KT (Timer Systems) instead of using Hashtables.
 

LearningCode

New Member
Reaction score
24
If I use a timer system, the dude Bananarama1 will have to import 2 triggers for one spell =/

Lol, I'll just make a 2nd version and make it available as an option xD
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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