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: 706
  • MagicNet.w3x
    56.3 KB · Views: 527

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.
  • The Helper The Helper:
    that sucks i bet they are expensive
  • Varine Varine:
    Not really
  • Varine Varine:
    The entire hot end is like 20 dollars, I just can't get anymore until next week
  • Varine Varine:
    I ordered like five blocks for 15 dollars. They're just little aluminum blocks with holes drilled into them
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such

      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