Spell Magic Net

Cohadar

master of fugue
Reaction score
209
Basically a version of Pudge Hook.
With a small exception that this one works with blinking.

JASS:

//===========================================================================
//  Demo spell for use of ABC timer attaching and PUI unit attaching
//  Author: Cohadar.
//  Date: 02.December.2007
//
//  How to implement:
//  Copy triggers ABC, PUI, CSSafety, and this trigger in your map
//  Copy all units and abilities into your map, then change raw codes in triggers
//  Make sure your trigger names are the same as scope names
//  or spells will not work. (I use local triggers)
//===========================================================================

scope MagicNet

globals
    private constant integer AID_MAGIC_NET = 'A001'
    private constant real PERIOD = 0.035
    private constant string NET_MODEL = "Abilities\\Spells\\Human\\AerialShackles\\AerialShacklesTarget.mdl"
    private constant string LIGHTNING = "LEAS"
    private constant real AOE = 96.
    private constant real PROXIMITY_BORDER = 10000. // 100*100
endglobals

private function distance takes integer level returns real
    return 400. + (level * 200.)
endfunction
    
private function speed takes integer level returns real
    return 300. + (level * 150.)
endfunction

private function damage takes integer level returns real
    return 100. + (level * 50.)
endfunction

//===========================================================================
private struct Data
    unit hero
    timer tim
    private static Data array PUI
    
    boolean inProgress = false
    boolean extending
    real x
    real y
    real tx
    real ty
    lightning net
    integer ticks
    real delta
    unit snatched
    group g
    effect fx

    //-------------------------------------------------------------------------  
    static method create takes unit hero returns Data
        local Data ret = Data.allocate()
        set ret.hero = hero
        set ret.tim = NewTimer() // CSSafety
        call SetTimerStructA(ret.tim, ret) // ABC
        set Data.PUI[GetUnitIndex(hero)] = ret // PUI
        set ret.g = CreateGroup()
        return ret
    endmethod
    
    //-------------------------------------------------------------------------  
    private method HandleGraphics takes nothing returns nothing
        local real angle
        local real dx
        local real dy    
        if .extending then
            set dx = .tx-.x
            set dy = .ty-.y
            set angle = Atan2(dy, dx)
            set .x = .x + .delta*Cos(angle)
            set .y = .y + .delta*Sin(angle)        
            call MoveLightning(.net, false, GetUnitX(.hero), GetUnitY(.hero), .x, .y)
            set .ticks = .ticks - 1            
            if (.ticks <= 0) then
                set .extending = false
            endif
        else
            set dx = GetUnitX(.hero) - .x
            set dy = GetUnitY(.hero) - .y
            set angle = Atan2(dy, dx)
            set .x = .x + .delta*Cos(angle)
            set .y = .y + .delta*Sin(angle)        
            call MoveLightning(.net, false, GetUnitX(.hero), GetUnitY(.hero), .x, .y)
            if (dx*dx < PROXIMITY_BORDER) and (dy*dy < PROXIMITY_BORDER) then
                call DestroyLightning(.net)
                call PauseTimer(.tim)
                set .inProgress = false
                if .snatched != null then
                    call DestroyEffect(.fx)
                endif                
            endif
        endif    
    endmethod
    
    
    private static unit gp_hero
    //-------------------------------------------------------------------------  
    private static method filter takes nothing returns boolean
        if GetFilterUnit() == Data.gp_hero then
            return false
        endif
        if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) < .405 then
            return false
        endif
        if IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) then
            return false
        endif
        return true
    endmethod
    
    //-------------------------------------------------------------------------  
    private static method Periodic takes nothing returns nothing
        local Data data = GetTimerStructA(GetExpiredTimer()) // ABC
        call data.HandleGraphics()
        if data.snatched == null then
            call GroupClear(data.g)
            set Data.gp_hero = data.hero
            call GroupEnumUnitsInRange(data.g, data.x, data.y, AOE, Filter(function Data.filter))
            set data.snatched = FirstOfGroup(data.g)
            if data.snatched != null then
                set data.fx = AddSpecialEffectTarget(NET_MODEL, data.snatched, "chest")
                set data.extending = false
                if IsUnitEnemy(data.hero, GetOwningPlayer(data.snatched)) then
                    call UnitDamageTarget(data.hero, data.snatched, damage(GetUnitAbilityLevel(data.hero, AID_MAGIC_NET)), true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                endif
            endif
        else
            call SetUnitX(data.snatched, data.x)
            call SetUnitY(data.snatched, data.y)
        endif
    endmethod
    
    //-------------------------------------------------------------------------  
    method Start takes real tx, real ty returns nothing
        local integer level
        local real dx
        local real dy
        if .inProgress then
            call SimError(GetOwningPlayer(.hero), "Magic Net is already casted!")
        else
            set .inProgress = true
            set .extending = true
            set .snatched = null
            set .tx = tx
            set .ty = ty
            set .x = GetUnitX(.hero)
            set .y = GetUnitY(.hero)
            set .net = AddLightning(LIGHTNING, false, .x, .y, .x, .y)
            set level = GetUnitAbilityLevel(.hero, AID_MAGIC_NET)
            set .delta = speed(level)*PERIOD
            set dx = .tx-.x
            set dy = .ty-.y
            set .ticks = R2I(RMinBJ(distance(level), SquareRoot(dx*dx+dy*dy))/.delta)
            call TimerStart(.tim, PERIOD, true, function Data.Periodic)
        endif
    endmethod
    
    //-------------------------------------------------------------------------  
    static method Get takes unit hero returns Data
        local integer index
    
        set index = GetUnitIndex(hero) // PUI
        if Data.PUI[index] == 0 then
            debug call BJDebugMsg("|c00FFCC00"+"MagicNet_Data struct created on first use for hero: " + GetHeroProperName(hero))
            return Data.create(hero)
        endif
        
        return Data.PUI[index]
    endmethod    

    //-------------------------------------------------------------------------
    method onDestroy takes nothing returns nothing
        call ClearTimerStructA(.tim) // ABC
        call ReleaseTimer(.tim) // CSSafety
        set Data.PUI[GetUnitIndex(.hero)] = 0 // PUI
        call RemoveUnit(.hero)
        call DestroyGroup(.g)
    endmethod
endstruct

//===========================================================================
private function Actions takes nothing returns nothing
    local Data data = Data.Get(GetTriggerUnit())
    local location temp = GetSpellTargetLoc()
    call data.Start(GetLocationX(temp), GetLocationY(temp))
    call RemoveLocation(temp)
    set temp = null
endfunction

//===========================================================================
private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == AID_MAGIC_NET
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions )
    set trig = null
endfunction

endscope


Magic leash will extend from caster in the throw direction searching for something to grab.
Once it finds something it will engulf it with magic threads and pull it towards the caster.
Enemies caught inside net will be damaged.
 

Attachments

  • MagicNet.PNG
    MagicNet.PNG
    394.3 KB · Views: 709
  • MagicNet.w3x
    56.3 KB · Views: 532

duyen

New Member
Reaction score
214
Huh what does this do? Do you expect everyone to play dota and know who pudge is?
 

Sim

Forum Administrator
Staff member
Reaction score
534
A short description should be included. Generally speaking, the tooltip.
 

hell_knight

Playing WoW
Reaction score
126
Nice as usual , imo put all your spells in a spellpack instead of releasing 3 day after day.
Rep if I could XD
 

Psiblade94122

In need of sleep
Reaction score
138
for those who dont know what "puge's hook" is, basicaly puge is an abomination, you know, the fat undead peice of sewed up corpses.... so he has this hook that he can trow (acutaly on the model it looks like its a part of him, anyways..) he trows it forward and when it touches something itll drag it back to himself, the hook will retract after a certain distance

anyways the simple version as usual
Code:
Abomination trows a projectile -> If projectile hits -> drags a unit back with the hook
                                             |
                                             v
                                      Hook comes back
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
It's really strange when two nets grab a unit... It looks like it is slowly duplicating and ... it's scary ^.^
 

Cohadar

master of fugue
Reaction score
209
It does not make errors, so it is fine by me.
I am not going to add 200 more lines of code just to correct a rare glitch.

It could be done by allowing chain pooling (multiple units pulling each other) like in pudge wars, but why would I want to recreate pudge wars for a purpose of a single spell.

And even if I did that there is no guarantee that some other spell that moves units will not interfere with this.

So basically it is a problem for the one who uses this in their map,
and it is commonly solved by using a joint movement (physics) engine for all spells that move objects, but that is like I said a personal problem of your map.
 

hell_knight

Playing WoW
Reaction score
126
Couldn't adding a hooked unit to a global group , while its hook then make a condition to check if it was already hooked? That would remove one unit being hooked twice problem in a few lines would it not?
 

Hero

─║╣ero─
Reaction score
250
Couldn't adding a hooked unit to a global group , while its hook then make a condition to check if it was already hooked? That would remove one unit being hooked twice problem in a few lines would it not?

Or check for the buff.

That is if you used Shackle for it?
 

hell_knight

Playing WoW
Reaction score
126
o_O Well I tried bugging the spell by adding a quite simple new trigger that runs at 5 seconds elapsed. Simply moves the heroes on both side of the death knight and orders to shackle him so to see what happens if he is shackled at the exact same time.

Funny thing is when I tried to test every single trigger disabled itself and gave me all these errors. ( I was using newgen )
 

Cohadar

master of fugue
Reaction score
209
NewGen did not load properly if it disabled all triggers.
Make sure there are Extensions, Grimoire and Jasshelper menus visible before attempting to compile anything with newgen.

If newgen does not load those menus at once, try again.
(turning all other applications when newgen is loading prevents this error)
 

Komaqtion

You can change this now in User CP.
Reaction score
469
This spell could use a PUI update, and also needs a CS update and ABC to work with 1.23+ patches...
 
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

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top