Spell Spells - Simple Dash Spell

K

Knyves

Guest
When your tutorial uses more then one costom trigger code, I think it's kind of redundant to call it "Simple". just a thought...
 

emjlr3

Change can be a good thing
Reaction score
395
lol

its got like 3 custom functions....to me...or most JASSers, that is pretty simple

I called it a simple DASH spell bacause, it a DASH spell, which is a popular thing, as easy as can be done in JASS

its not even many lines, not even 100 I think

I've got plenty of spells that are 300+ lines of code, with a dozen custom functions
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
JASS:
local real ang = bj_RADTODEG * Atan2(ytargy, xtargx)


What is this line doing? Can't you just use "AngleBetweenPoints()"? You can just use locations and get the angle.

Edit: This tutorial is WAY too much for me, I don't get any of this.
 

Sim

Forum Administrator
Staff member
Reaction score
534
It's to prevent the use of BJs, or pre-made functions by Blizzard.

Instead of calling the function you do what it does directly.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
Well, this tutorial is FAR FROM "simple", I don't get any of these "GetAttachment" stuff and reading this, I caught myself just copying and not learning because I do NOT get what he's doing in this tutorial.
 

Sim

Forum Administrator
Staff member
Reaction score
534
He's using the CScache, by Vexorian. That's why maybe you see function calls you don't understand at all, such as the tables.
 

emjlr3

Change can be a good thing
Reaction score
395
this is a simple dash spell, not a simple jass tut, it is required u know jass and how to use cscache/other handle vars system to read this, or did you jsut skip my whole intro?
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
JASS:
//*************************************************************
//* Constant Functions (Only edit things under this section.) *
//*************************************************************
constant function FW_Raw_Code takes nothing returns integer
  return 'A003'
endfunction

//**************
//* Conditions *
//**************

function FW_Spell_Check takes nothing returns boolean
  return GetSpellAbilityId() == FW_Raw_Code()
endfunction

//*************
//* Functions *
//*************

function FW_Dash takes nothing returns nothing
  //Local Varibles and Handles
    local timer dashtimer = GetExpiredTimer()
    local unit caster = GetHandleUnit(dashtimer, "caster")
    local real dist = GetHandleReal(dashtimer, "dist")
    local location casterpos = GetUnitLoc(caster)
    local real xtarget = GetHandleReal(dashtimer, "xtarget")
    local real ytarget = GetHandleReal(dashtimer, "ytarget")
    local location targetpoint = Location(xtarget, ytarget)
    local real angle = AngleBetweenPoints(casterpos,targetpoint)
    
  //Functions
    if GetHandleReal(dashtimer, "dist") >= 0.0 then //Cannot be exact.  Must go into negatives to take effect so weird distances can be detected
      call SetUnitPositionLoc(caster, PolarProjectionBJ(casterpos, 75.00, angle))
      call SetHandleReal(dashtimer, "dist", dist-75.00) //This is my indicator which will keep decreasing until it's below 0
      call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl", GetUnitX(caster), GetUnitY(caster)))
    else
      call PauseUnit(caster, false)
      call ResetUnitAnimation(caster)
      call SetUnitPathing(caster, false)
    endif      
        
  //Null Variables
    set caster = null
    call RemoveLocation(casterpos)
    call RemoveLocation(targetpoint)
    set casterpos = null
    set targetpoint = null   
endfunction

function FW_Spell takes nothing returns nothing
  //Local Variables
    local unit caster = GetTriggerUnit()
    local timer dashtimer = CreateTimer()
    local location targetpoint = GetSpellTargetLoc()
    local real xtarget = GetLocationX(targetpoint)
    local real ytarget = GetLocationY(targetpoint)
    local real dist = DistanceBetweenPoints(GetUnitLoc(caster), targetpoint)
      
  //Handles
    call SetHandleHandle(dashtimer, "caster", caster)
    call SetHandleReal(dashtimer, "xtarget", xtarget)
    call SetHandleReal(dashtimer, "ytarget", ytarget)
    call SetHandleReal(dashtimer, "dist", dist)
       
  //Functions
    call PauseUnit(caster, true)
    call SetUnitAnimation(caster, "attack")
    call SetUnitPathing(caster, true)
    call TimerStart(dashtimer, 0.035, true, function FW_Dash)
    
  //Null Variables
    call ResetUnitAnimation(caster)
    call PauseTimer(dashtimer)
    call DestroyTimer(dashtimer)
    set dashtimer = null
    call FlushHandleLocals(dashtimer)
    set caster = null
    call RemoveLocation(targetpoint)
    set targetpoint = null
endfunction

//===========================================================================
function InitTrig_Flame_Walk takes nothing returns nothing
local integer i
    set i = 0
    set gg_trg_Flame_Walk = CreateTrigger(  )
    loop
      exitwhen i>12
      call TriggerRegisterPlayerUnitEventSimple( gg_trg_Flame_Walk, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT)
      set i = i + 1
    endloop
    call TriggerAddCondition( gg_trg_Flame_Walk, Condition(function FW_Spell_Check))    
    call TriggerAddAction( gg_trg_Flame_Walk, function FW_Spell )
    call Preload("Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl")
endfunction


Edit: WOW! I had it working then it magically stopped (just kidding about the magic), I don't know what I did wrong. Please help me complete this tedious spell!
 
R

Rode

Guest
Well this was way to hard for me at the moment. maybe when I get better this will help me.
Is there a tutorial like this but with a VERY simple spell? That would be more helpful for me.
:)
 

emjlr3

Change can be a good thing
Reaction score
395
you can try my "So you want to learn JASS" tut., that may help a bit
 

Hatebreeder

So many apples
Reaction score
380
Emj, I have made a Spell due to your Tut.
JASS:
function Trig_Dash_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Trig_Dash_Condition takes nothing returns boolean
    local string String2 = GetAttachmentTable(GetTriggeringTrigger())
    return IsUnitEnemy(Caster,GetFilterUnit(), GetOwningPlayer(GetTableUnit(String,"Caster"))) == true and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) >= 0 and IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) == false) and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE) == false)
endfunction

function Trig_Dash_Damage takes nothing returns nothing
    local string String2 = GetAttachmentTable(GetTriggeringTrigger())
    local unit Caster = GetTableUnit(String2,"Caster")
    local unit Victim = GetTriggerUnit()
    local real Damage = GetHeroAgi(Caster,true)
    
    call UnitDamageTarget(Caster,Victim,Damage,true,true,ATTACK_TYPE_HERO,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
    call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl",Victim,chest)
    
    set Caster = null
    set Victim = null
endfunction

function Trig_Dash_Effects takes nothing returns nothing
    local timer Timer = GetExpiredTimer()
    local string String2 = GetAttachmentTable(Timer)
    local trigger Trigger
    local string String
    local unit Caster = GetTableUnit(String2,"Caster",Caster)
    local real Angle = GetTableReal(String2,"Angle",Angle)
    local real Distance = GetTableReal(String2,"Distance",Distance)
    local real Moved = GetTableReal(String2,"Moved",Moved)
    
    call SetUnitPosition(Caster,GetUnitX(Caster) + 30 Cos(Angle * bj_DEGTORAD), GetUnitY(Caster) + 30 Sin(Angle * bj_DEGTORAD))
    call SetUnitAnimationByIndex(Caster,10)
    set Moved = Moved + 30
    
    if Moved <= Distance or UNIT_STATE_LIFE <= 0 then
        set Trigger = GetTableTrigger(String2,"Trigger",Trigger)
        set String = GetAttTable(Trig)
        call TriggerRemoveAction(Trigger,GetTableTriggerAction(String,"ta"))
        call ClearTable(String)
        call DestroyTrigger(Trigger)
        set Trigger = null
        call SetUnitTimeScalePercent(Caster,100)
        call SetUnitPathing(Caster,true)
        call SetUnitAnimationByIndex(Caster,0)
        call ClearTable(String2)
        call PauseTimer(Timer)
        call DestroyTimer(Timer)
    else
        call SetTableReal(String2,"Moved",Moved)
    endif
endfunction

function Trig_Dash_Actions takes nothing returns nothing
    local unit Caster = GetTriggerUnit()
    local location Target = GetSpellTargetLoc()
    local real CasterX = GetUnitX(Caster)
    local real CasterY = GetUnitY(Caster)
    local real TargetX = GetLocationX(Target)
    local real TargetY = GetLocationY(Target)
    local real Angle = bj_RADTODEG * Atan2(TargetY - Y, TargetX - X)
    local real DistanceX = TargetX - X
    local real DistanceY = TargetY - Y
    local real Distance = SquareRoot(DistanceX * DistanceX + DistanceY * DistanceY)
    local trigger Trigger = CreateTrigger()
    local string String = GetAttachmentTable(Trigger)
    local timer Timer = CreateTimer()
    local string String2 = GetAttachmentTable(Timer)
    
    call TriggerRegisterUnitInRange(Trigger,Caster,150,null)
    call TriggerAddCondition(Trigger,Condition(function Trig_Dash_Condition))
    call SetTableObject(String,"TimerAction",TriggerAddAction(Trigger, function Trig_Dash_Damage))
    call SetTableObject(String,"Caster",Caster)
    
    call SetTableReal(String2,"Angle",Angle)
    call SetTableReal(String2,"Distance",Distance)
    call SetTableReal(String2,"Moved",Moved)
    call SetTableObject(String2,"Caster",Caster)
    call SetTableObject(String2,"Trigger",Trigger)
    call TimerStart(Timer,0.03,true,function Trig_Dash_Effects)
    
    call SetUnitTimeScalePercent(Caster,400)
    call SetUnitPathing(Caster,false)
    call SetUnitAnimationByIndex(Caster,10)
    
    set Caster = null
    call RemoveLocation(Target)
    set Target = null
    set Trigger = null
endfunction

//===========================================================================
function InitTrig_Dash takes nothing returns nothing
    set gg_trg_Dash = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Dash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Dash, Condition( function Trig_Dash_Conditions ) )
    call TriggerAddAction( gg_trg_Dash, function Trig_Dash_Actions )
    call Preload("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl")
endfunction

Gave the Variables a longer Name, so I know what what they all mean.
JASS Craft gives me alot of errors when I parse.
Did I do something wrong? Or, Is it because of CScache, that is not "Implemented" in JASSCraft?
Hehe ^^ Some Explanation of this would make me happy =)
 

emjlr3

Change can be a good thing
Reaction score
395
JASSCraft will only show correct syntax on functions it has, if you do not add CSCache to the funcions which JASSCraft contains, then ofcourse it will give you errors
 

Sim

Forum Administrator
Staff member
Reaction score
534
Broken due to the CSCache using the now-fixed H2I return bug.
 

emjlr3

Change can be a good thing
Reaction score
395
the premise is still sound - just replace Table with struct members and timersafety
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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
  • 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 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