Template Jumping Spell Template v3

M

milkman

Guest
Hi, the units animation is freezed after using this jump ability, any suggests how to make the unit use the "stand" animation after the jump? (i am new to jass)
 

Kenny

Back for now.
Reaction score
202
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.)
        call DisplayTextToPlayer(Player(0),0.,0.,&quot;ZLoc = &quot;+R2S(GetLocationZ(GetUnitLoc(d.u)))+&quot; : FlyHeight = &quot;+R2S(GetUnitFlyHeight(d.u)))
        
        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;) // &lt;&lt;&lt;&lt;&lt;&lt;--------------------------------
            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>


That should work i think. I've highlighted what i added with a big arrow.
 
M

milkman

Guest
Yep it's working. Thanks. I kinda had the same command but in the wrong place.

Offtopic: are there any tutorials out there on getting into jass?
 

tommerbob

Minecraft. :D
Reaction score
110
Is it possible to use this, but instead have the location in front of the caster at X distance? I'm trying to create a leap spell, but it is instant cast with no target. How would I do this?
 

emjlr3

Change can be a good thing
Reaction score
395
polar project out from the caster along its facing angle and use that as the target location
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/
  • The Helper The Helper:
    Here is another comfort food favorite - Million Dollar Casserole - https://www.thehelper.net/threads/recipe-million-dollar-casserole.193614/

      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