JASS dash spell Inifinite Loops?

cleeezzz

The Undead Ranger.
Reaction score
268
does the move even work?

JASS:
private function Move takes nothing returns nothing
local data d = data(GetTimerData(GetExpiredTimer()))
local unit t = GetEnumUnit()
local real ux = GetUnitX(t)
local real uy = GetUnitY(t)
local real angle = Atan2(uy-d.y,ux-d.x)
local real cos = Cos(angle)
local real sin = Sin(angle)
set ux = ux + cos * TIME * d.speed
set uy = uy + sin * TIME * d.speed
call SetUnitPosition(t,ux,uy)
call DestroyEffect(AddSpecialEffect(EFFECT,ux,uy))
endfunction

i dont see how data d would be set to anything, its not set off by a timer

and 8 sfx per unit? or 8 sfx total
 

wraithseeker

Tired.
Reaction score
122
the whole code works , I am using TimerUtils , Right now I want to try and limit SFX and setting a speed limit , answer above.

8 SFX per unit.
 

wraithseeker

Tired.
Reaction score
122
Bump

New Error found , when ever I set

JASS:
set d.speed = d.speed + 30


to
JASS:

set d.speed = d.speed - 30


The unit gets pushed back and then pushed back to the caster location , stuck there for eternity. Anybody know why? I am trying to do acceleration, from fast to slow pushback. I merely changed + 30 to - 30.
 

wraithseeker

Tired.
Reaction score
122
Making my dash spell stop

Right now I have made the basics of dash spells , it moves to the target but never stops as I don't know how do I detect when the caster reaches the target.

Basicly , this spell is cast on a unit by the caster and the caster will charge towards the target no matter where he goes.

Here is the code , my first dash spell , comments are <3

JASS:
scope Dash initializer Init

globals
private constant integer SPELL = &#039;A003&#039;
private constant real TIME = 0.03
private constant real SPEED = 800

endglobals

private struct data
unit caster
unit target
real cos
real sin
real angle
real distance
timer t

static method create takes nothing returns data
local data d = data.allocate()
set d.caster = GetTriggerUnit()
set d.target = GetSpellTargetUnit()
set d.t = NewTimer()
return d
endmethod

method onDestroy takes nothing returns nothing
call ReleaseTimer(.t)
endmethod
endstruct

private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL
endfunction

private function Move takes nothing returns nothing
local data d = data(GetTimerData(GetExpiredTimer()))
local real cx = GetUnitX(d.caster)
local real cy = GetUnitY(d.caster)
local real tx = GetUnitX(d.target)
local real ty = GetUnitY(d.target)
local real angle = Atan2(ty-cy,tx-cx)
local real sin = Sin(angle)
local real cos = Cos(angle)
set cx = cx + cos * TIME * SPEED
set cy = cy + sin * TIME * SPEED
call SetUnitPosition(d.caster,cx,cy)
endfunction

private function Actions takes nothing returns nothing
local data d = data.create()
local real cx = GetUnitX(d.caster)
local real cy = GetUnitY(d.caster)
local real tx = GetUnitX(d.target)
local real ty = GetUnitY(d.target)
local real angle = Atan2(ty-cy,tx-cx)
local real cos = Cos(angle)
local real sin = Sin(angle)
call SetTimerData(d.t,integer (d))
call TimerStart(d.t,0.03,true,function Move)
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction( t, function Actions)
    call TriggerAddCondition(t,Condition(function Conditions))
endfunction

endscope
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
JASS:

if SquareRoot(cx - tx * cx - tx + cy - ty * cy - ty) &lt;= 128 then
   call d.destroy()
endif
 

wraithseeker

Tired.
Reaction score
122
hmm... when I added that line .. The caster doesn't move anymore...

Code

JASS:
scope Dash initializer Init

globals
private constant integer SPELL = &#039;A003&#039;
private constant real TIME = 0.03
private constant real SPEED = 800

endglobals

private struct data
unit caster
unit target
real cos
real sin
real angle
real distance
timer t

static method create takes nothing returns data
local data d = data.allocate()
set d.caster = GetTriggerUnit()
set d.target = GetSpellTargetUnit()
set d.t = NewTimer()
return d
endmethod

method onDestroy takes nothing returns nothing
call ReleaseTimer(.t)
endmethod
endstruct

private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL
endfunction

private function Move takes nothing returns nothing
local data d = data(GetTimerData(GetExpiredTimer()))
local real cx = GetUnitX(d.caster)
local real cy = GetUnitY(d.caster)
local real tx = GetUnitX(d.target)
local real ty = GetUnitY(d.target)
local real angle = Atan2(ty-cy,tx-cx)
local real sin = Sin(angle)
local real cos = Cos(angle)
set cx = cx + cos * TIME * SPEED
set cy = cy + sin * TIME * SPEED
call SetUnitPosition(d.caster,cx,cy)
if SquareRoot(cx - tx * cx - tx + cy - ty * cy - ty) &lt;= 128 then
   call d.destroy()
endif
endfunction

private function Actions takes nothing returns nothing
local data d = data.create()
local real cx = GetUnitX(d.caster)
local real cy = GetUnitY(d.caster)
local real tx = GetUnitX(d.target)
local real ty = GetUnitY(d.target)
local real angle = Atan2(ty-cy,tx-cx)
local real cos = Cos(angle)
local real sin = Sin(angle)
call SetTimerData(d.t,integer (d))
call TimerStart(d.t,0.03,true,function Move)
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction( t, function Actions)
    call TriggerAddCondition(t,Condition(function Conditions))
endfunction

endscope
 

Azlier

Old World Ghost
Reaction score
461
Computers follow the order of operations. There is no parenthesis usage in your distance calculation, so it'll end up skewed.
 

wraithseeker

Tired.
Reaction score
122
I don't get what you mean, are you saying that 128 should be replaced with a variable that is my speed for the unit per 0.03 seconds?
 

Artificial

Without Intelligence
Reaction score
326
What he meant was this:
JASS:
(cx - tx * cx - tx + cy - ty * cy - ty)
// Change to:
((cx - tx) * (cx - tx) + (cy - ty) * (cy - ty))
 

wraithseeker

Tired.
Reaction score
122
Works nice + REP.

Since all has been done , right now what I want to know is how do I knock units away that the caster comes in contact with when he is charging at the target
 

wraithseeker

Tired.
Reaction score
122
With reference to my dash spell thread just now , now I have a problem , when the caster charges, I want it that units near them will get knocked back away.

Here is my code

JASS:
scope Dash initializer Init

globals
private constant integer SPELL = &#039;A003&#039;
private constant real TIME = 0.03
private constant real SPEED = 800
private boolexpr Check
endglobals

private function DISTANCE takes integer level returns integer
return level * 250
endfunction

private struct data
unit caster
unit target
real cos
real sin
real angle
real distance
timer t
timer h
group g

static method create takes nothing returns data
local data d = data.allocate()
set d.caster = GetTriggerUnit()
set d.target = GetSpellTargetUnit()
set d.t = NewTimer()
set d.h = NewTimer()
set d.distance = DISTANCE(GetUnitAbilityLevel(d.caster,SPELL))
set d.g = CreateGroup()
return d
endmethod

method onDestroy takes nothing returns nothing
call ReleaseTimer(.h)
endmethod
endstruct

private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL
endfunction

private function KnockCheck takes nothing returns boolean
return true
endfunction

private function Knock takes nothing returns nothing
local data d = data(GetTimerData(GetExpiredTimer()))
local real cx = GetUnitX(d.caster)
local real cy = GetUnitY(d.caster)
local real tx = GetUnitX(d.target)
local real ty = GetUnitY(d.target)
local real angle = Atan2(ty-cy,tx-cx)
local real sin = Sin(angle)
local real cos = Cos(angle)
set tx = tx + cos * TIME * SPEED
set ty = ty + sin * TIME * SPEED
call SetUnitX(d.target,tx)
call SetUnitY(d.target,ty)
set d.distance = d.distance - TIME * SPEED
if d.distance &lt;= 0 then
call d.destroy()
endif
endfunction

private function Move takes nothing returns nothing
local data d = data(GetTimerData(GetExpiredTimer()))
local real cx = GetUnitX(d.caster)
local real cy = GetUnitY(d.caster)
local real tx = GetUnitX(d.target)
local real ty = GetUnitY(d.target)
local real angle = Atan2(ty-cy,tx-cx)
local real sin = Sin(angle)
local real cos = Cos(angle)
local unit u
local real x
local real y
local real angles
local real sins
local real coss
set cx = cx + cos * TIME * SPEED
set cy = cy + sin * TIME * SPEED
call SetUnitX(d.caster,cx)
call SetUnitY(d.caster,cy)
call GroupEnumUnitsInRange(d.g,cx,cy,180,Check)
loop
set u = FirstOfGroup(d.g)
exitwhen d.g == null
set x = GetUnitX(u)
set y = GetUnitY(u)
set angles = Atan2(cy-y,cx-x)
set sins = Sin(angles)
set coss = Cos(angles)
set x = cx + coss * TIME * SPEED
set y = cy + sins * TIME * SPEED
call SetUnitX(u,x)
call SetUnitY(u,y)
call GroupRemoveUnit(d.g,u)
endloop
if SquareRoot((cx - tx) * (cx - tx) + (cy - ty) * (cy - ty)) &lt;= 128 then
   call SetUnitAnimation(d.caster, &quot;attack slam alternate&quot;)
   call SetUnitAnimation(d.target, &quot;DEATH&quot;)
   call ReleaseTimer(d.t)
   call SetTimerData(d.h,integer (d))
   call TimerStart(d.h,0.03,true,function Knock)
endif
endfunction

private function Actions takes nothing returns nothing
local data d = data.create()
call SetTimerData(d.t,integer (d))
call TimerStart(d.t,0.03,true,function Move)
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction( t, function Actions)
    call TriggerAddCondition(t,Condition(function Conditions))
    set Check = Condition(function KnockCheck)
endfunction

endscope


When I added this block of codes , it lagged like tomorrow was never going to come.


JASS:
call GroupEnumUnitsInRange(d.g,cx,cy,180,Check)
loop
set u = FirstOfGroup(d.g)
exitwhen d.g == null
set x = GetUnitX(u)
set y = GetUnitY(u)
set angles = Atan2(cy-y,cx-x)
set sins = Sin(angles)
set coss = Cos(angles)
set x = cx + coss * TIME * SPEED
set y = cy + sins * TIME * SPEED
call SetUnitX(u,x)
call SetUnitY(u,y)
call GroupRemoveUnit(d.g,u)
endloop
 

Viikuna

No Marlo no game.
Reaction score
265
JASS:
exitwhen d.g == null // this is your group.
// I think what you meam  is exitwhen u==null
 

wraithseeker

Tired.
Reaction score
122
Yeah that solved it silly me ! -.-.

Error spotted , after casting the spell , I noticed the caster and the target seems to sway to a direction due to SetUnitX and Y?
 

Azlier

Old World Ghost
Reaction score
461
>I noticed the caster and the target seems to sway to a direction due to SetUnitX and Y?

What does that even mean?
 

wraithseeker

Tired.
Reaction score
122
I did a test today and had something strange , the first spell didn't bug at all. At the second cast , when I casted on the same target again , When I tried to move downwards, there seems to be a force trying not to let me down which I assume is the problem of SetUnitX and SetUnitY. And when I got near the target , they seem to get pushed back even though no spell was casted
 

Azlier

Old World Ghost
Reaction score
461
It's just so infuriating. Dual polar projection is bad enough, but no indentation at all?! :banghead:
 
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
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top