• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Magic Hook

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
I did this spell in vjass, hope you all enjoy ..

Systems useds :

- Timer Utils
- XProps
________________

here it comes the trigger

JASS:
scope ML initializer Init

native UnitAlive takes unit id returns boolean

globals 

            private constant integer HAID = 'A000'
            private constant integer DUID = 'h000'
            private constant string LFID = "DRAM"
            private constant real period = 0.03
            private constant attacktype att = ATTACK_TYPE_CHAOS
            private constant damagetype dtt = DAMAGE_TYPE_UNKNOWN
            private constant weapontype wtt = WEAPON_TYPE_METAL_HEAVY_BASH
//         -=-=-=-=-=-=-=-=-=-=-            
            private integer lvl

endglobals

private struct Magic

        unit dummy
        unit target
        unit caster
        real tamanho
        real damage
        timer tim
        real x
        real y
        real angle
        boolean hastarget
        group g
        boolean back
        real velocity
        lightning light
        integer level

    private method onDestroy takes nothing returns nothing

      call ReleaseTimer(.tim)
      set .tim = null
      set .caster = null
      call DestroyGroup(.g)
      set .g = null
      call RemoveUnit(.dummy)
      set.dummy = null
      call DestroyLightning(.light)
      set .light = null

    endmethod

endstruct

// # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #

function Comprimento takes integer l returns real
return 550+(150*I2R(l))
endfunction

function DmgPS takes integer l , real vel returns real
return (vel/55)+0.1*I2R(l)
endfunction

function Damag takes integer l returns real
return 25*I2R(l)
endfunction

function velreduct takes real dist returns real
return dist/32.0
endfunction

// # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #

function Loop takes nothing returns nothing
   local Magic data = GetTimerData(GetExpiredTimer())

   local unit t
   set data.g = CreateGroup()

      if data.back and data.tamanho <= 100.0 then
       call data.destroy()

       else
       if data.tamanho <= 10.0 then
        set data.back = true
       endif
        if data.back then
         set data.tamanho = GetDistanceBetweenPoints(data.x,data.y,GetUnitX(data.caster),GetUnitY(data.caster))

           if data.hastarget then
//                                                                              \\
            set data.x = GetUnitX(data.target)
            set data.y = GetUnitY(data.target)
// enables the target to run and receive other skills that involve the movement \\

             set data.angle = GetAngleBetweenPoints(data.x,data.y,GetUnitX(data.caster),GetUnitY(data.caster))

             if data.velocity <= 19.5 then
              set data.velocity = 19.4
             else
              set data.velocity = velreduct(GetDistanceBetweenPoints(data.x,data.y,GetUnitX(data.caster),GetUnitY(data.caster)))
             endif

             set data.x = PolarProjectionX(data.x,data.velocity,data.angle)
             set data.y = PolarProjectionY(data.y,data.velocity,data.angle)
             call SetUnitX(data.target,data.x)
             call SetUnitY(data.target,data.y)
             call SetUnitX(data.dummy,data.x)
             call SetUnitY(data.dummy,data.y)
             call MoveLightning(data.light,true,GetUnitX(data.caster),GetUnitY(data.caster),data.x,data.y)
             call UnitDamageTarget(data.caster,data.target,DmgPS(data.level,data.velocity),true,true,att,dtt,wtt)

           else
             set data.x = GetUnitX(data.dummy)
             set data.y = GetUnitY(data.dummy)
             set data.angle = GetAngleBetweenPoints(data.x,data.y,GetUnitX(data.caster),GetUnitY(data.caster))
             set data.x = PolarProjectionX(data.x,data.velocity,data.angle)
             set data.y = PolarProjectionY(data.y,data.velocity,data.angle)
             call SetUnitX(data.dummy,data.x)
             call SetUnitY(data.dummy,data.y)
             call MoveLightning(data.light,true,GetUnitX(data.caster),GetUnitY(data.caster),data.x,data.y)
            endif

          else
             set data.x = GetUnitX(data.dummy)
             set data.y = GetUnitY(data.dummy)
             set data.x = PolarProjectionX(data.x,data.velocity,data.angle)
             set data.y = PolarProjectionY(data.y,data.velocity,data.angle)
             call SetUnitX(data.dummy,data.x)
             call SetUnitY(data.dummy,data.y)
             call MoveLightning(data.light,true,data.x,data.y,GetUnitX(data.caster),GetUnitY(data.caster))
             call GroupEnumUnitsInRange(data.g,data.x,data.y,90.0,null)

//  LOOPSTART  \\
               loop
                 set t = FirstOfGroup(data.g)
                 exitwhen t == null
                 if UnitAlive(t) then

                  if IsUnitEnemy(t,GetOwningPlayer(data.caster)) then
                   if data.hastarget == false then
                    set data.target = t
                    set data.hastarget = true
                    set data.back = true
                    call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl",data.target,"chest"))
                    call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\ManaFlare\\ManaFlareBoltImpact.mdl",data.target,"chest"))
                    call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl",data.target,"chest"))
                    call UnitDamageTarget(data.caster,data.target,Damag(data.level),true,true,att,dtt,wtt)
                    call GroupRemoveUnit(data.g,t)
                    set t = null
                    set data.tamanho = GetDistanceBetweenPoints(data.x,data.y,GetUnitX(data.caster),GetUnitY(data.caster))
                   else
                    call GroupRemoveUnit(data.g,t)
                    set t = null
                   endif
                   
                  else
                    call GroupRemoveUnit(data.g,t)
                    set t = null
                endif

            else
              call GroupRemoveUnit(data.g,t)
              set t = null
            endif
            
               endloop 
//  ENDLOOP  \\
 
               call DestroyGroup(data.g)
               set data.g = null
             set  data.tamanho = data.tamanho-data.velocity
            endif

        endif

endfunction

  private function Actions takes nothing returns nothing
    local Magic MyStruct = Magic.create()

    set MyStruct.caster = GetTriggerUnit()
    set MyStruct.x = GetUnitX(MyStruct.caster)
    set MyStruct.y = GetUnitY(MyStruct.caster)
    set MyStruct.hastarget = false
    set MyStruct.back = false
    set MyStruct.level = GetUnitAbilityLevel(MyStruct.caster,HAID)
    set MyStruct.tamanho = Comprimento(MyStruct.level)
    set MyStruct.dummy = CreateUnit(GetOwningPlayer(GetTriggerUnit()),DUID,MyStruct.x,MyStruct.y,0.00)
    set MyStruct.light = AddLightning(LFID,true,MyStruct.x,MyStruct.y,GetUnitX(MyStruct.caster),GetUnitY(MyStruct.caster))
    set MyStruct.angle = GetAngleBetweenPoints(MyStruct.x,MyStruct.y,GetSpellTargetX(),GetSpellTargetY())
    set MyStruct.velocity = 23.5
    set MyStruct.tim = NewTimer()

    call SetTimerData(MyStruct.tim,MyStruct)
    call TimerStart(MyStruct.tim,period,true,function Loop)

  endfunction

     private function Condit takes nothing returns boolean
            return GetSpellAbilityId() == HAID
     endfunction

  function Init takes nothing returns nothing

    local trigger trg = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( trg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(trg,Condition(function Condit))    
    call TriggerAddAction( trg, function Actions )
    set trg = null
    
  endfunction

endscope

Credits :

- Vexorian.
- Who created Xprops.
- WeTrainner.

Keywords:
Hook , pudge , dota , magic , energy , lightning , butcher, jass , vjass, human , bloodelf
Contents

[ SPELL ] Magic Hook ( Jass ) (Map)

Reviews
12th Dec 2015 IcemanBo: Too long time as NeedsFix. Rejected. 17:36, 12th Mar 2011 Bribe: My Review Status: Rejected until fixed

Moderator

M

Moderator

12th Dec 2015
IcemanBo: Too long time as NeedsFix. Rejected.

17:36, 12th Mar 2011
Bribe:

My Review

Status: Rejected until fixed
 
Level 7
Joined
Oct 11, 2008
Messages
304
Never use I2R, if want a real from a integer, use integer + .0


JASS:
function Damag takes integer l returns real
return 25*I2R(l)
endfunction

>>


JASS:
function Damag takes integer l returns real
return 25. * l
endfunction

Same goes to other functions.


Use private before every function, you don't want people to use it outside this spell.


JASS:
                    call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl",data.target,"chest"))
                    call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\ManaFlare\\ManaFlareBoltImpact.mdl",data.target,"chest"))
                    call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl",data.target,"chest"))

configurable?

Try don't use FirstOfGroup and use ForGroup.

I don't understand your way to code... sometimes you use no space before functions (to organize it), sometimes you use LOTS of spaces before functions (?)

I can't read all your code at all :)

Attachment: Oops... The ball just dislike the link :vw_unimpressed:
 

Attachments

  • WC3ScrnShot_012411_064953_02.png
    WC3ScrnShot_012411_064953_02.png
    1.1 MB · Views: 187

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
  • Wasteful use of conditions
  • Indentation doesn't come close to following the standards
  • onDestroy is useless. The destroy method can be overridden and "deallocate" called from it, otherwise what you experience is generated-code duplication and senseless trigger evaluations, which nobody wants.
  • return 25*I2R(l) should be: 25 * l
  • return (vel/55)+0.1*I2R(l) should be: vel / 55.0 + l * 0.1
  • return 550+(150*I2R(l)) should be: 550 + 150 * l
  • Need to use private functions. What you have cannot be approved as you have public functions with names than need to be localized as they are very common names.
  • Constants should always be capitalized.
  • The "0.03" period is too low for a system like TimerUtils and should use a simple struct loop or Timer32.
  • This should use MoveLightningEx, not MoveLightning.
 
Last edited:
Top