• 🏆 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!

Electric Grapple

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
When the hero damages an enemy, it has a chance that the damage will be doubled and the enemy will be pulled.

NOTE: Made in 1.24. This is my old spell, and I just wan't to share it.

v1.1a
All is now native

v1.1
Now can be used for multiple units.
Simplified the spell more.
Fix spell on fly heights

v1.0
Initial Release

Requires:
Damage
Knockback
AIDS
Event

JASS:
//Electric Grapple v1.1a //
//    by: Nherwyziant    //
//=======================//
//Credits:               //
//    Jesus4Lyf          //
//    Silvenon           //
//    PitzerMike         //
//=======================//

scope ElectricGrapple initializer I

    globals
        private constant integer RAWCODE       =   'A000'     //~The rawcode of the spell
        private constant integer LIGHTNINGCODE =   'A004'     //~The rawcode of the chain lightning spell
        private constant integer DUMMYID       =   'h001'     //~The rawcode of the dummy who casts the chain lightning
        private constant real DURATION         =   1          //~The duration of pulling
    endglobals
    
    private constant function ChancePerLvl takes integer lvl returns integer
        return ( lvl * 5 ) + 10  //~The Chance is here
    endfunction
    
    private constant function Damage takes real lvl returns real
        return GetEventDamage() * lvl
    endfunction

    //=======================DO NOT TOUCH==============================\\
    
    private function Conditions takes nothing returns boolean
         return GetUnitTypeId(GetEventDamageSource()) != DUMMYID and GetRandomInt(1,100)<=ChancePerLvl(GetUnitAbilityLevel(GetEventDamageSource(),RAWCODE))
    endfunction

    private function Actions takes nothing returns nothing
        local real r
        local unit c
        local unit d     = GetEventDamageSource()
        local unit u     = GetTriggerUnit()
        local real dx    = GetUnitX(u) - GetUnitX(d)
        local real dy    = GetUnitY(u) - GetUnitY(d)
        local real dist  = SquareRoot(dx * dx + dy * dy)-100
        local real angle = Atan2(GetUnitY(d)-GetUnitY(u),GetUnitX(d)-GetUnitX(u))
        local texttag t  = CreateTextTag()
        if IsUnitType(u,UNIT_TYPE_STRUCTURE)==false then
            if GetUnitAbilityLevel(d,RAWCODE)>0 then
                set c = CreateUnit(GetOwningPlayer(d),DUMMYID,GetUnitX(d),GetUnitY(d),GetUnitFacing(d))
                set r = GetEventDamage()+Damage(GetUnitAbilityLevel(d,RAWCODE))
                call Knockback(u,dist,angle,DURATION)
                call UnitAddAbility(c,'Amrf')
                call UnitRemoveAbility(c,'Amrf')
                call SetUnitFlyHeight(c,GetUnitFlyHeight(d),0)
                call UnitAddAbility(c,LIGHTNINGCODE)
                call IssueTargetOrder(c,"fingerofdeath",u)
                call UnitDamageTarget(c,u,Damage(GetUnitAbilityLevel(d,RAWCODE)),true,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
                call SetTextTagText(t,"|cffff0000"+I2S(R2I(r))+"!|r", 0.023)
                call SetTextTagPos(t,GetUnitX(d),GetUnitY(d),GetUnitFlyHeight(d))
                call SetTextTagColor(t,255,255,255,255)
                call SetTextTagFadepoint(t,3)
                call SetTextTagPermanent(t,false)
                call SetTextTagVelocity(t,0,0.0455)
                call SetTextTagLifespan(t,4)
                call SetTextTagVisibility(t,true)
            endif
        endif
        set u = null
        set d = null
        set t = null
    endfunction

    private function I takes nothing returns nothing
        local trigger g=CreateTrigger()
        call Damage_RegisterEvent(g)
        call TriggerAddCondition(g,Condition(function Conditions))
        call TriggerAddAction(g,function Actions)
    endfunction

endscope

Keywords:
Electric, Grapple, Nherwyziant, Spell, Lightning, Shock, Cool, Awesome, Simple, Passive
Contents

Electric Grapple v1.1 (Map)

Reviews
17:43, 1st Jan 2010 TriggerHappy: Link to the required libraries please.

Moderator

M

Moderator

17:43, 1st Jan 2010
TriggerHappy:

Link to the required libraries please.
 
Level 15
Joined
Jan 31, 2007
Messages
502
hm..the code iself looks quite ok.. maybe because its quite small and simple due it mainly calls libraries

anyway - there are still things you should change
JASS:
        local location l1  = GetUnitLoc(u)
        local location l2  = GetUnitLoc(d)
        local real dist    = DistanceBetweenPoints(l2,l1) - 100
        local real angle   = AngleBetweenPoints(l1,l2) * bj_DEGTORAD
fix this, the locations are not necessary due you can simply replace those BJs

JASS:
local real x = GetUnitX(u)
local real xx = GetUnitX(d)
local real y = GetUnitY(u)
local real yy = GetUnitY(d)
local real dist = SquareRoot((x-xx)*(x-xx)+(y-yy)*(y-yy))
local real angle   = bj_RADTODEG * Atan2(yy - y, xx - x)

due you use your GetRandomInt(1,100) just once you dont need that local integer for it

furthermore you should replace those BJs of the Texttag

JASS:
call CreateTextTagUnitBJ(I2S(R2I(b*2))+"!",d,0,10,100,0,0,0)
                    call SetTextTagVelocityBJ(bj_lastCreatedTextTag,64,90)

one important thing is that the spell would be able to retrigger itself.. fix that
e.g. 100% would instantly kill the unit

also i would suggest to make the damage dependent on the level
 
Level 5
Joined
Jul 4, 2008
Messages
27
SPELL UPDATED!!!

Why does it only work for 1 unit type? Why not all with a certain ability?
Fixed now!

hm..the code iself looks quite ok.. maybe because its quite small and simple due it mainly calls libraries

anyway - there are still things you should change
JASS:
        local location l1  = GetUnitLoc(u)
        local location l2  = GetUnitLoc(d)
        local real dist    = DistanceBetweenPoints(l2,l1) - 100
        local real angle   = AngleBetweenPoints(l1,l2) * bj_DEGTORAD
fix this, the locations are not necessary due you can simply replace those BJs

JASS:
local real x = GetUnitX(u)
local real xx = GetUnitX(d)
local real y = GetUnitY(u)
local real yy = GetUnitY(d)
local real dist = SquareRoot((x-xx)*(x-xx)+(y-yy)*(y-yy))
local real angle   = bj_RADTODEG * Atan2(yy - y, xx - x)

I already tried that, and the spell knockback angle and distance is weird, so why don't you try it yourself, you will see why i turned it into BJ.

one important thing is that the spell would be able to retrigger itself.. fix that
e.g. 100% would instantly kill the unit

Your wrong, damaging is a dummy, and the condition needs to be the hero! zzzz, and due to a suggestion from someone I made the spell can be used for multiple units

furthermore you should replace those BJs of the Texttag

JASS:
call CreateTextTagUnitBJ(I2S(R2I(b*2))+"!",d,0,10,100,0,0,0)
                    call SetTextTagVelocityBJ(bj_lastCreatedTextTag,64,90)

Can you make does texttab unBJ?
 
Last edited:
Level 15
Joined
Jan 31, 2007
Messages
502
I already tried that, and the spell knockback angle and distance is weird, so why don't you try it yourself, you will see why i turned it into BJ.

a BJ is a Blizzard function which does various things. You can replace it with simply doing the same directly instead of calling the BJ

e.g.
JASS:
function DistanceBetweenPoints takes location locA, location locB returns real
    local real dx = GetLocationX(locB) - GetLocationX(locA)
    local real dy = GetLocationY(locB) - GetLocationY(locA)
    return SquareRoot(dx * dx + dy * dy)
endfunction

due it does the same nothing should get messed up


Your wrong, damaging is a dummy, and the condition needs to be the hero! zzzz, and due to a suggestion from someone I made the spell can be used for multiple units

Hmm.. ye.. i got messed up with your local unit c and d
i thought c was the "caster" and d would be the dummy.. but i was wrong


Can you make does texttab unBJ?

sure, why not?
Same as i said before , if you got JassCraft or JNGP you cann see what done with each BJ and replace it

e.g.
JASS:
    set t = CreateTextTag()
    call SetTextTagText(t,"blubb", 0.023)
    call SetTextTagPos(t, GetUnitX(d), GetUnitY(d), GetUnitFlyHeight(d))
    call SetTextTagColor(t,255,255,255,255)
    call SetTextTagFadepoint(t,3.00)
    call SetTextTagPermanent(t,false)
    call SetTextTagVelocity(t,  0, 0.0455)
    call SetTextTagLifespan(t, 4.00)
    call SetTextTagVisibility(t, true)
 
Level 5
Joined
Jul 4, 2008
Messages
27
a BJ is a Blizzard function which does various things. You can replace it with simply doing the same directly instead of calling the BJ

e.g.
function DistanceBetweenPoints takes location locA, location locB returns real
local real dx = GetLocationX(locB) - GetLocationX(locA)
local real dy = GetLocationY(locB) - GetLocationY(locA)
return SquareRoot(dx * dx + dy * dy)
endfunction

due it does the same nothing should get messed up

Plz download the spell, change the DistanceBetwen and the Angle between into it's native, and you will see the difference....

EDIT: ok, so the native of distbetpoints is working, but the native of anglebetpoints is wreck!
EDIT2: ok the anglebetpoint native seems to be working now when i removed the bj_degtorad
 
Last edited:
Level 15
Joined
Jan 31, 2007
Messages
502
Why is this still need fix?

->
TriggerHappy said:
Link to the required libraries please.



Map is simplified in best.
images


Is it?
It´s always risky to claim that it would be perfect
There are nearly always things swhich can changed/improved/advanced.

e.g. you never null then unit c ... just as an example

or a bigger description how to implent would be nice
for example you never notice that the dummy spell which is used must have the order "fingerofdeath"
anyone who is not very familiar with jass could get problems
 
Top