• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Find location and move unit there

Status
Not open for further replies.
Hello! Guys/girls, i got problems with my trigger, i want to move unit to some location offset by (let's say 10) and towards (let's say 240 degrees), but i also want to play that unit animation during its moving. I'm new to JASS to i don't really know hot to do that, i searched a lot of forums but still...
Okay so i did this
  • Custom script: call SetUnitX( udg_Caster , GetUnitX(udg_Caster) )
  • Custom script: call SetUnitY( udg_Caster , GetUnitY(udg_Caster) )
But as i know (hopefully) it should look something like that:
  • Custom script: SetUnitX(udg_Caster),GetUnitX(udg_Caster)+udg_Range*Cos(udg_Angle)
  • Custom script: SetUnitY(udg_Caster),GetUnitY(udg_Caster)+udg_Range*Sin(udg_Angle)
I get syntax error in here ^^ Any help?

But i need to know where and how to add distance and angle (if i did it wrong)? and why do i need to make angle in radians only?
Also i need a third script that finally move Caster to the point.
Hope i told everything clear and you'll easily understand!
Help is really appreciated!
 
What baassee said.

In GUI (bj functions), angles are in degrees, in JASS (non-bj functions) angles are in radians.

SetUnitX(udg_Caster[udg_Index3]),GetUnitX(udg_Caster[udg_Index3])+udg_Speed[udg_Index3]*Cos(udg_Angle[udg_Index] * bj_DEGTORAD)

->
SetUnitX(udg_Caster[udg_Index3],GetUnitX(udg_Caster[udg_Index3])+udg_Speed[udg_Index3]*Cos(udg_Angle[udg_Index] * bj_DEGTORAD))

Remove the first ")" and add one ")" at the very end.
 
Every opeing brackets "(" needs a closing brackets ")"

Functions take all thair arguments as a list within brackets.

call DSG(1,2,3)

Brackets can also be used like in mathematics to change the order code gets executed.
call DSG(1,2,(4+5)/3)

You can do completly retarded brackets as well
call DSG(((1)),(2),((4+5)/3))
as long as they all match up.

You also often need to pass a function as an argument to another function which again takes a list of arguments between brackets.
call DSG(pro(1),good(2),error(doublenested(8,6)))
As long as the functions with the approtiate arguments exist, the above is valid as well.
 
Well here's a examble of how you could do it.
JASS:
local real X = GetUnitX( udg_Caster[ udg_Index3 ] )
local real Y = GetUnitY( udg_Caster[ udg_Index3 ] )
call SetUnitX( udg_Caster[ udg_Index3 ], X + udg_Speed[ udg_Index3 ] * Cos( udg_Angle[ udg_Index ] * bj_DEGTORAD ) )
call SetUnitY( udg_Caster[ udg_Index3 ], Y + udg_Speed[ udg_Index3 ] * Sin( udg_Angle[ udg_Index ] * bj_DEGTORAD ) )

NOTE: Locals are always effective, and easily implemented to GUI / Jass.
Just remember that they need to be in the very beginning of the trigger, otherwise you'll get a error.

Also~ Always remember to make clear triggers, simple examble here...
JASS:
// ##### ##### #####
// TEMPLATE A
//   Use this Template instead of Template B.
//
local real oPosX = GetUnitX( udg_oUnit[ udg_oIndex ] )      // Return unit's X position..
local real oPosY = GetUnitY( udg_oUnit[ udg_oIndex ] )      // ..and Y position.
local real oPosA = GetUnitFacing( udg_oUnit[ udg_oIndex ] ) // Examble Angle, the unit's angle.
local real oMovS = 15                                       // The speed, you can use udg_* also in it.

call SetUnitX( udg_oUnit[ udg_oIndex ], oPosX + oMovS * Cos( oPosA * bj_DEGTORAD ) )
call SetUnitY( udg_oUnit[ udg_oIndex ], oPosY + oMovS * Sin( oPosA * bj_DEGTORAD ) )

// ##### ##### #####
// TEMPLATE B
//   Use Template A instead of this.
//
call SetUnitX( udg_oUnit[ udg_oIndex ], GetUnitX( udg_oUnit[ udg_oIndex ] ) + udg_oSpeed[ udg_oIndex ] * Cos( udg_oAngle[ udg_oIndex ] * bj_DEGTORAD ) )
call SetUnitY( udg_oUnit[ udg_oIndex ], GetUnitY( udg_oUnit[ udg_oIndex ] ) + udg_oSpeed[ udg_oIndex ] * Sin( udg_oAngle[ udg_oIndex ] * bj_DEGTORAD ) )
 
Last edited:
Status
Not open for further replies.
Back
Top