First Shot at a "Dash" Spell

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
Help me with my "Dash Spell"

Yep. This is the only way to learn...through trial and error. I was reading Daelin's guide on the knockback, but I tried my best to make it like a dash spell. Here's the code:

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 location casterpos = GetUnitLoc(caster)
    local real xtarget = GetHandleReal(dashtimer, "xtarget")
    local real ytarget = GetHandleReal(dashtimer, "ytarget")
    local location targetpoint = Location(xtarget, ytarget)
    local real dist = GetHandleReal(dashtimer, "dist")
    local real angle = AngleBetweenPoints(casterpos,targetpoint)
    local real X      = GetUnitX(caster)
    local real Y      = GetUnitY(caster)
    local real polarX = X + 75.00 * Cos(angle)  
    local real polarY = Y + 75.00 * Sin(angle)
         
  //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 SetUnitPosition(caster,X,Y)
      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)
      call FlushHandleLocals(dashtimer)
    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


I can't get this right. It worked before and now it doesn't work. Please help me correct this problem.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
JASS:
if DistanceBetweenPoints(x1,y1,x2,y2) != 0 then


What's going on here? The distance between points function should only be used with two points. It looks like you're trying to use 4.

JASS:
call SetUnitAnimation(caster, "attack)


You only have one quotation there.


JASS:
endfunction
    
endfunction


I don't think you need that second endfunction.

See if that helps any. :D
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
I hate to say this, but you should use vjass. It is guaranteed to work (if you code it right, that is). Handle vars and gamecache can bug if the person using them has a full gamecache file. That's why I love structs. I've always understood Jass, and Handle Vars, but Handle Vars suddenly stopped working for me one day (it bugged out). Structs are globals and therefore the pwn. Also, it is much easier to code with structs once you learn how to use them. To completely eliminate gamecache, you can use Cohadar's Struct Attachment System. But, yeah... it's just much easier.



You have an extra endfunction just above your InitTrig.


EDIT: CMON Ghan! Stop STEALING MY POSTS~! :p
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> CMON Ghan! Stop STEALING MY POSTS~!

Hey, don't look at me. You know way more JASS than I do. :p
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> 2 locations, 4 points.

But if you did that, wouldn't you have to convert the coordinates to locations first with the native Location function?
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> What is JassNewGen Pack?

In reality, it is a hack of the WC3 system created by Vexorian that adds to the powers of the JASS coding language. You can find it on wc3campaigns.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
I found it but i'm having a lot of trouble opening this up. Anyone help?
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> i'm having a lot of trouble opening this up.

What kind of trouble? Have you found out how to unzip it?
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
I DL'd the program but it just opens the command script for .5 seconds then it closes. I don't know how to open the file.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
EDIT: I got it I think.

So what will this program do for me?
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> So what will this program do for me?

What you want it to do. Within the bounds of its capabilities, of course. :p Some interesting things that come with the New Gen pack are structs, libraries, and globals.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
How do I access this? I opened WE up and I see the stuff at the top but I don't know how to use the syntax checker or the script highlightor thingy. Help?
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> I don't know how to use the syntax checker or the script highlightor thingy.

Create a JASS trigger.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
I convert it to custom text and nothing is showing up. How do I get the high lightor thing and the syntax checker? This program is confusing me.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
Did you open up the WE from the New Gen file? Or did you open it normally? To get the enhancements, you have to open it from the New Gen folder that you unzipped.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
I opened it with the cooler looking WE icon, the one that I extracted to a folder. I opened it up and when I look at a JASS trigger, there's no highlighting and there's no Syntax Checker. Well?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top