• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Moving problems...

Status
Not open for further replies.
Level 6
Joined
Jan 7, 2007
Messages
247
Hello again ^___^
So i continue to make some jass thingies, and one day i got an idea to make knockbacking spell... But theres little problem. There goes the code:

this is first part.
  • Motion
  • Events
    • Time - Every 0.03 seconds of game time
  • Conditions
  • Actions
    • For each (Integer i) from 1 to num, do (Actions)
      • Loop - Actions
        • Custom script:call motion(udg_i)
  • Push Stream
  • Events
    • Unit - A unit begins to cast an ability
  • Conditions
    • (Ability being cast) equal to Push Stream
  • Actions
    • Timer - Start PushTimer[num] as a single timer that will expire in 1.0 seconds
    • Set num = (num+1)
    • Set u[num] = (target unit of ability being cast)
    • Set PushPoint[num]= ((Position of u[num]) offset by 1000.00 towards (Angle from(Position of (Triggering Unit)) to (Position of u[num])) degrees)
This is something like initialize part :p

And here goes main code:

JASS:
function motion takes integer i returns nothing

local unit u = udg_u[i]
local location p = GetUnitLoc(u)
local location p2 = udg_PushPoint[i]
local real a
local effect e = null
local timer b = udg_PushTimer[i]

if DistanceBetweenPoints(p, p2) > 0 and ( not ( TimerGetRemaining(GetLastCreatedTimerBJ()) < 0.20 ) ) then
   set a = AngleBetweenPoints(p, p2)
   call MoveLocation(p, GetLocationX(p) + 1 * CosBJ(a), GetLocationY(p) + 1 * SinBJ(a))
   call SetUnitPositionLoc( u, p )
else
    set udg_u[i]=udg_u[udg_num]
    set udg_i = udg_i-1 
    set udg_num = udg_num -1
    call AddSpecialEffectTargetUnitBJ( "origin", u, "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" )
    set e = GetLastCreatedEffectBJ()
    call PolledWait( 2 )
    call DestroyEffectBJ( e )
endif
 set u = null
call RemoveLocation(p)
call RemoveLocation(p2)
 set p = null
 set p2 = null
 set a = 0
endfunction

(ugh, i know that timer leak, but its not main problem, ill fix that later)

Well here is my problem - something strange is with unit moving oO It moves not to PushPoint, but to strange point in my map. I dunno what point is that, its not center of the map, but something little left and down from that. With any point errors in my triggers, these points move to this spot. Dunno why.
So, can someone tell me where is point error here? oO

Ugh i just tried something like that but it didnt work too. whyyyy the heelll. Its absolutely correct. As i think. Lol
JASS:
function motion takes integer i returns nothing

local unit u = udg_u[i]
local location p = GetUnitLoc(u)
local location p2 = udg_PushPoint[i]
local location p3
local real a
local effect e = null
local timer b = udg_PushTimer[i]

if DistanceBetweenPoints(p, p2) > 0 and ( not ( TimerGetRemaining(GetLastCreatedTimerBJ()) < 0.20 ) ) then
   set a = AngleBetweenPoints(p, p2)
   set p3 = PolarProjectionBJ(p, 15.00, a)
   call SetUnitPositionLoc( u, p3 )
else
    set udg_u[i]=udg_u[udg_num]
    set udg_i = udg_i-1 
    set udg_num = udg_num -1
    call AddSpecialEffectTargetUnitBJ( "origin", u, "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" )
    set e = GetLastCreatedEffectBJ()
    call PolledWait( 2 )
    call DestroyEffectBJ( e )
endif
 set u = null
call RemoveLocation(p)
call RemoveLocation(p2)
 set p = null
 set p2 = null
 set a = 0
endfunction
 
Last edited:
Level 13
Joined
Nov 22, 2006
Messages
1,260
I'm so glad that you posted this, the same thing happened to me, and I though I was crazy! Maybe now I'll find out what the hell happened. Oh, and pleeeeeease don't use BJs, I'm allergic to that :)

EDIT: I think I've found it!!! It's the event, try with Starts the effect of an ability.
 
Last edited:
Status
Not open for further replies.
Top