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

duyen

New Member
Reaction score
215
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
251
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.
  • Varine Varine:
    I'll also probably need to set up a server at some point because these scans take up a huge amount of space. I'll worry about that when I have an office though
  • The Helper The Helper:
    I am sure Ghan could give you some solid advice on the Server stuff
  • The Helper The Helper:
    I hear that the latest IPhones and Samsungs have some of the best cameras out there.
  • jonas jonas:
    phone cameras are good for sending pics on whatsapp, but no good for macro photography
  • jonas jonas:
    I think you should buy a used macro lens, do you already have a system camera?
  • Varine Varine:
    No, I'm still looking into them and kind of leaning towards a Rebel T7 at the moment because it's pretty cheap and lenses seem pretty easy to come by. Used ones are only like 3-400 dollars, which is much cheaper than I was planning
  • jonas jonas:
    I can't really recommend you any specific lens or body due to lack of knowledge, but in my experience camera shops are very helpful, especially those that also sell used parts
  • Varine Varine:
    There's only one camera shop in my town and they seem to specialize in film, but I have time before I need it. I'm not in a rush so I'll keep researching them
  • jonas jonas:
    I think since you have such specific needs, you should find a way to give a try for different systems without having to commit to one
  • jonas jonas:
    It would suck to spend 400$ on a system that doesn't have the capability you need
  • jonas jonas:
    and it will probably take a couple of tries to get the settings right
  • Varine Varine:
    It would but I can also just make sure I can return them. The system I have works, it's pretty straightforward and I tested it with a camera I have. All it really is is a little cartridge that holds the transparency film and a white light source behind it that projects the image into the lens
  • Varine Varine:
    I'll have to fuck with the light a bit and try some different lighting methods to get color accuracy, but I have IT8 targets for that
    +1
  • The Helper The Helper:
    get that color accuracy :)
  • Varine Varine:
    They're really helpful for calibrating things because I'm really colorblind, so I'm not great at doing it by eye
    +2
  • Varine Varine:
    Well the long, slow slog of winter has officially begun here
  • Varine Varine:
    I have a bunch of community service I have to do, and I have a feeling there will be a lot of snow shoveling involved now
  • The Helper The Helper:
    don't know why people choose to live in that kind of weather :)
  • Varine Varine:
    Well
  • Varine Varine:
    My job is here
  • Varine Varine:
    I was born here man I didn't choose shit
  • Varine Varine:
    And also, I keep moving away and it doesn't get any better. I moved to San Antonio and shit froze there AND we had blackouts

    The Helper Discord

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top