First Shot at a "Dash" Spell

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
When NewGen starts at the main menu, it is because you have not saved the map yet. Go into the main editor (terrain), and save your map. Then test it. It will boot directly (and, if you have it enabled, in a window)

EDIT: Hey Sooda! :p
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
I can't follow you're tutorial on the "Dash" it's way too much and It's way too hard to understand. I don't find it simple. This is hella confusing...............................................I'm hating this. I think I might go back to GUI.
 

emjlr3

Change can be a good thing
Reaction score
395
worst choice you would ever make...
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
Edit: Here's my script. I used the HandleVars sytem and tried to mimic your tutorail Emij, it's not working though.

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 angle = AngleBetweenPoints(casterpos,targetpoint)
    
  //Functions
    if DistanceBetweenPoints(casterpos,targetpoint) != 0 then
      call SetUnitPositionLoc(caster, PolarProjectionBJ(casterpos, 50.00, angle))
    else
      call PauseUnit(caster, false)
      call ResetUnitAnimation(caster)
    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)
  
  //Handles
    call SetHandleHandle(dashtimer, "caster", caster)
    call SetHandleReal(dashtimer, "xtarget", xtarget)
    call SetHandleReal(dashtimer, "ytarget", ytarget)
    
  //Functions
    call PauseUnit(caster, true)
    call SetUnitAnimation(caster, "attack")
    call TimerStart(dashtimer, 0.035, true, function FW_Dash)
    
  //Null Variables
    call DestroyTimer(dashtimer)
    set dashtimer = null
    call FlushHandleLocals(dashtimer)
    set caster = null
    call RemoveLocation(targetpoint)
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 )  
endfunction


I don't know what I'm doing wrong, like always, this stuff is WAY too hard. And yes, I used the BJ because I'm WAY too lazy to get the formulas, 1 extra formula call won't hurt.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
***bump***

I updated the current script and it's still not working. Please help me fix this!
 

substance

New Member
Reaction score
34
dood tell us what's happening!

Do the actions run at all? does it give you an error? does your computer blow up when you try to run it?
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
When I cast the spell, the unit doesn't get paused, nothing happens. The Raw Code is correct. I don't know what's happening or causing the problem.
 

WarLuvr3393

Hmmm...too many things to play (WoW, COD4, WC3)
Reaction score
54
Edit: I fixed a few things and now the unit gets paused, so that's an UP but no movement occurs, the FW_Dash function doesn't work.

*Sorry for the double post, I thought I had editted but I guess I added a reply.
 

substance

New Member
Reaction score
34
JASS:
call TimerStart(dashtimer, 0.035, true, function FW_Dash)
call DestroyTimer(dashtimer)
You destroy the timer right after creating it which means its functions wont run. You are supposed to destroy the timer after you're done using it.
JASS:
call PauseUnit(caster, true)
call SetUnitAnimation(caster, "attack")
[del]I think if you pause a unit you can't set it's animation.. I could be wrong though.[/del] I was wrong, what you did is fine.
JASS:
call RemoveLocation(targetpoint)
You should null this too.

Also, as a general rule of thumb you should use coordinates instead of locations. Locations are slower and using coordinates is easy if you know what the native location functions do (which you would if you're using TESH or JASS Craft).
 

Tinki3

Special Member
Reaction score
418
>I think if you pause a unit you can't set it's animation.. I could be wrong though.

You are :)

EDIT:

Here is a simple knockback trigger I made for my map.
The InitTrig function is different to yours, and so is a few other things, as the trigger is for a passive spell, but it gives you the basic idea of how to use X and Ys instead of locs for making a unit slide.

The actions you should pay attention to are in bold:
Code:
constant function Power_Bash_Timer_Delay takes nothing returns real
    return 0.03
endfunction

constant function Power_Bash_Knockback_Value takes nothing returns real
    return 14.00
endfunction

constant function Power_Bash_Knockback_Range_Base_Value takes nothing returns real
    return 75.00
endfunction

constant function Power_Bash_Chance takes nothing returns real
    return 15.00
endfunction

constant function Power_Bash_SFX takes nothing returns string
    return "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"  //Created on targ's chest, 1 shot
endfunction

constant function Power_Bash_SFX_2 takes nothing returns string
    return "Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl"         //Created on targ's chest, cntnus shot
endfunction

constant function Power_Bash_Ability_ID takes nothing returns integer
    return 'A008'
endfunction

function Power_Bash_Actions_2 takes nothing returns nothing
[B]    local timer t     = GetExpiredTimer()
    local unit targ   = GetHandleUnit(t, "targ")
    local real X      = GetUnitX(targ)
    local real Y      = GetUnitY(targ)
    local real ang    = GetHandleReal(t, "ang")
    local real polarX = X + Power_Bash_Knockback_Value() * Cos(ang)  //Sets the offset from targ's X, using the "ang" var we set earlier
    local real polarY = Y + Power_Bash_Knockback_Value() * Sin(ang)  //...
    
    if GetHandleReal(t, "count") >= 0.00 then
        call SetHandleReal(t, "count", GetHandleReal(t, "count") - Power_Bash_Knockback_Value())
        call SetUnitPosition(targ, polarX, polarY)  //Move targ to the offsets[/B]
        call DestroyEffect(AddSpecialEffectTarget(Power_Bash_SFX_2(), targ, "chest"))
    [B]else
        call FlushHandleLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)
    endif[/B]

    set t = null
    set targ = null
endfunction

function Power_Bash_Actions takes nothing returns nothing
[B]    local unit cast = GetAttacker()
    local unit targ = GetAttackedUnitBJ()
    local real x    = GetUnitX(cast)
    local real y    = GetUnitY(cast)
    local real X    = GetUnitX(targ)
    local real Y    = GetUnitY(targ)
    local real ang  = Atan2(Y-y, X-x)  //Gets the angle between the coords.[/B]
    local real dmg  = GetHeroStr(cast, true)
[B]    local real i    = GetUnitAbilityLevel(cast, Power_Bash_Ability_ID()) * Power_Bash_Knockback_Range_Base_Value()
    local timer t   = CreateTimer()

    call SetHandleHandle(t, "targ", targ)
    call SetHandleReal(t, "ang", ang)
    call SetHandleReal(t, "count", i)
    call TimerStart(t, Power_Bash_Timer_Delay(), true, function Power_Bash_Actions_2)[/B]
    call UnitDamageTarget(cast, targ, dmg, false, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
    call DestroyEffect(AddSpecialEffectTarget(Power_Bash_SFX(), targ, "chest"))

    set cast = null
    set targ = null
    set t = null
endfunction

function Power_Bash_Conditions takes nothing returns boolean
    return GetUnitAbilityLevelSwapped(Power_Bash_Ability_ID(), GetAttacker()) > 0  
endfunction

function InitTrig_Power_Bash takes nothing returns nothing
    set gg_trg_Power_Bash = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Power_Bash, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Power_Bash, Condition( function Power_Bash_Conditions ) )
    call TriggerAddAction( gg_trg_Power_Bash, function Power_Bash_Actions )
endfunction
 

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!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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