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.
  • 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

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top