Jump Spell

HydraRancher

Truth begins in lies
Reaction score
197
JASS:
//***************************************************************************
//*                                                                         *
//* Jumping Spell Template v3                                               *
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯            **URL in the works                 *
//* Parabola function by Shadow1500                                         *
//* System by emjlr3                                                        *
//*                                                                         *
//* Requires:                                                               *
//* ¯¯¯¯¯¯¯¯¯                                                               *
//*                                                                         *
//* - A vJASS Preprocessor                                                 *
//*                                                                         *
//***************************************************************************

library JST initializer InitJST

globals
    // Speed at which unit's periodic movement is completed (.01-.04 recommended)
    private constant real Interval          = .025
    // Value which represents the arc of the jump movement (1.-2.), closer to 2. for a flatter arc
    private constant real Arc               = 1.3 
    // Rawcode of the Crow Form ability in your map.  This need only be changed if you have edited this ability
    // in which case, create a new, unedited copy and use it here
    private constant integer CrowForm       = 'Amrf' 
    // Rawcode of peasant unit in your map.  This need only be changed if you have edited this unit
    // in which case, create a new, unedited copy and ise it here
    private constant integer Peasant        = 'hpea'
endglobals

//=====No touching past this point=====\\

globals
    private real Game_MaxX 
    private real Game_MinX 
    private real Game_MaxY 
    private real Game_MinY
    
    private constant real Runs = 1./Interval
    private constant integer HalfRuns = R2I(Runs/2.)
    
    private location L
    
    private sound S = CreateSoundFromLabel( "InterfaceError",false,false,false,10,10)
endglobals

private function Parabola takes real dist, real maxdist returns real
    local real t = (dist*2)/maxdist-1
    return (-t*t+1)*(maxdist/Arc)
endfunction
private function InitJST takes nothing returns nothing
    set Game_MaxX = GetRectMaxX(bj_mapInitialPlayableArea)-50.
    set Game_MinX = GetRectMinX(bj_mapInitialPlayableArea)+50.
    set Game_MaxY = GetRectMaxY(bj_mapInitialPlayableArea)-50.
    set Game_MinY = GetRectMinY(bj_mapInitialPlayableArea)+50.
endfunction

public function CheckLocPathing takes location l returns boolean
    local unit u = CreateUnitAtLoc( Player(13), Peasant, l, 0. )
    local real x = GetUnitX(u) - GetLocationX(l)
    local real y = GetUnitY(u) - GetLocationY(l)
    local boolean b = false
    
    if x < 1. and x > -1. and  y < 1. and y > -1. then        
        set b = true
    endif
    call ShowUnit(u,false)
    call KillUnit(u)
    
    call RemoveLocation(l)
    set u = null
    return b
endfunction

private function SafeX takes real x returns real
    if x<Game_MinX then
        return Game_MinX
    elseif x>Game_MaxX then
        return Game_MaxX
    endif
    return x
endfunction
private function SafeY takes real y returns real
    if y<Game_MinY then
        return Game_MinY
    elseif y>Game_MaxY then
        return Game_MaxY
    endif
    return y
endfunction

private struct dat
    unit u
    real area
    real damage
    real maxdist
    real movedist
    real cos
    real sin
    real diff
    real start_z
    string sfx  
    integer i = 0
endstruct

globals
    private timer T = CreateTimer()
    private dat array D
    private integer Total = 0
endglobals

//Spell:
private function Filt takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(),bj_groupEnumOwningPlayer) and IsUnitType(GetFilterUnit(),UNIT_TYPE_FLYING)!=true
endfunction    
private function Damage takes unit u, real dam, real x, real y, real area returns nothing
    local group g = CreateGroup()
    local unit v

    set bj_groupEnumOwningPlayer = GetOwningPlayer(u)
    call GroupEnumUnitsInRange(g, x, y, area, Condition(function Filt))
    loop
        set v = FirstOfGroup(g)
        exitwhen v == null
        call GroupRemoveUnit(g,v)
        call UnitDamageTarget(u,v,dam,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
    endloop 
   
    call DestroyGroup(g)
    set g = null
endfunction

private function Movement takes nothing returns nothing
    local dat d
    local integer i = 1
    local real dist  
    local real height
    local real x
    local real y
    
    loop
        exitwhen i>Total
        set d = D<i>
    
        set d.i = d.i + 1
        set dist = d.i*d.movedist
        
        set L = GetUnitLoc(d.u)
        set height = GetLocationZ(L)
        if height&lt;d.start_z then
            set height = (d.start_z-height)+Parabola(dist,d.maxdist)
        elseif height&gt;d.start_z then
            if d.start_z+Parabola(dist,d.maxdist)&lt;=height then
                set height = 0.
            else
                set height = Parabola(dist,d.maxdist)-(height-d.start_z)
            endif
        else
            set height = Parabola(dist,d.maxdist)
        endif
        call RemoveLocation(L)
        
        call SetUnitX(d.u,SafeX(GetUnitX(d.u)+d.movedist*d.cos))
        call SetUnitY(d.u,SafeY(GetUnitY(d.u)+d.movedist*d.sin))
        call SetUnitFlyHeight(d.u,height,0.)
        
        if d.i == HalfRuns then
            call SetUnitTimeScale(d.u, 1.)
        elseif height&lt;=1. then
            call PauseUnit( d.u,false )
            call SetUnitPathing( d.u, true )           
            call SetUnitFlyHeight(d.u,GetUnitDefaultFlyHeight(d.u),0.) 
            call SetUnitAnimation(d.u,&quot;stand&quot;)
            set x = GetUnitX(d.u) + d.diff * d.cos
            set y = GetUnitY(d.u) + d.diff * d.sin 
            call DestroyEffect(AddSpecialEffect(d.sfx, x,y))  
            call Damage(d.u, d.area, x, y, d.damage)  
            
            call d.destroy() 
            set D<i> = D[Total]
            set Total = Total - 1
            set i = i - 1
            if Total==0 then
                call PauseTimer(T)
            endif
        endif
        
        set i = i + 1
    endloop
endfunction     

//===========================================================================
public function Cast takes unit u, real damage, real area, real diff, string anim, string sfx returns boolean
    local dat d      
    local real ux
    local real uy   
    local location l 
    local real ang
    local real x
    local real y 
    
    if u==null or damage&lt;0. or area&lt;0. then
        if GetLocalPlayer()==GetOwningPlayer(u) then
            call ClearTextMessages()
            call BJDebugMsg(&quot;|c00FF0000JST Error: Invalid inputs in function Cast.&quot;)
            call StartSound(S)
        endif
        return false
    endif
    
    set d = dat.create()       
    set ux = GetUnitX(u)
    set uy = GetUnitY(u)   
    set l = GetSpellTargetLoc() 
    set ang = Atan2((GetLocationY(l)-uy),(GetLocationX(l)-ux))
    set x = GetLocationX(l) - diff * Cos(ang)
    set y = GetLocationY(l) - diff * Sin(ang)
    
    set d.u = u
    set d.damage = damage
    set d.area = area
    set d.sfx = sfx
    set d.maxdist = SquareRoot((ux-x)*(ux-x) + (uy-y)*(uy-y))
    set d.cos = Cos(ang)
    set d.sin = Sin(ang)
    set d.movedist = d.maxdist/Runs
    set d.diff = diff
    set L = GetUnitLoc(d.u)
    set d.start_z = GetLocationZ(L)
    call RemoveLocation(L)
   
    call PauseUnit( u,true )
    call SetUnitPathing( u, false )
    call UnitAddAbility( u,CrowForm )
    call UnitRemoveAbility( u,CrowForm )
    call SetUnitAnimation(u, anim) 
    call SetUnitTimeScale(u, .30) 
    
    set Total = Total + 1
    if Total == 1 then
        call TimerStart(T,Interval,true,function Movement) 
    endif
    set D[Total] = d
    
    call RemoveLocation(l)
    set l = null 
    return true
endfunction

endlibrary</i></i>


this is the DIRECT C+P trigger in my map.
Its by emjlr3 although, when I attempt it, a cloud effect appears yet nothing else happens, I am also able to cast it anywhere:nuts:.
 

Builder Bob

Live free or don't
Reaction score
249
Doubt you'll get much more help in the Jass section actually, as I wouldn't think the error is in the code.

How do you call the jump function? Can we see that part of your code?
 

HydraRancher

Truth begins in lies
Reaction score
197
I didnt make this, this is a direct c+p from the 1 trigger I have, jump spell template.
 

Builder Bob

Live free or don't
Reaction score
249
Regardless of whether you made it yourself or not (I know Emjlr3 made it), nothing will happen in your map unless you call the function Cast from this template in one of your spell triggers. That's why I ask for the rest of your triggers. If you don't have any, then that's the reason it's not doing anything.

Did any more documentation come with this template?
 

Tt112233

TH.net Regular
Reaction score
6
Just copying and pasting this code will do absolutely nothing. You have to somehow call the code (JST_Jump in this case) somewhere in your trigger. If you haven't done this, then you should go do it now. If yes, then post the code that calls JST_Jump as that's where the problem lies.
 

HydraRancher

Truth begins in lies
Reaction score
197
Sorry I am absolutely HORRIBLE at Jass and I dont know much :eek:. What does this mean - calling a function?
 

saw792

Is known to say things. That is all.
Reaction score
280
To make it work add a custom script line in your spell actions:

JASS:
call JST_Cast(udg_YourUnit, &lt;Damage amount&gt;, &lt;Damage AOE&gt;, &lt;Speed&gt;, &lt;Animation to be player&gt;, &lt;SFX string path&gt;)


So just set a unit to a variable and fill in the remaining fields.
 

emjlr3

Change can be a good thing
Reaction score
395
custom script in a GUI trigger divider

you should really read the Read Me packaged in the demo map
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • 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 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