• 🏆 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!

Set unit X/Y Custom script Error !!!

Status
Not open for further replies.
Level 4
Joined
Jul 15, 2012
Messages
89
hello everyone
this is what im trying to do :
  • trigger
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Target is in (Units within 400.00 of (Position of Caster))) Equal to False
        • Then - Actions
          • Set ShklHero = (Target unit of ability being cast)
          • Set ShklPoint = (Position of ShklHero)
          • Set ShklX = (X of ShklPoint)
          • Set ShklY = (Y of ShklPoint)
          • Custom script: call SetUnitX( ShklHero , ShklX )
        • Else - Actions
but the
  • Custom script: call SetUnitX( ShklHero , ShklX )
part doesnt work and this error apears:
compiler error :line 408 Expected a name
(that custom script is line 408)
i learned this method here http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/things-gui-user-should-know-233242/#Section 2 Ch 24
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
First:
Global variables have an "udg_" prefix. That means "User Defined Global" (These you create with the variable editor) It should be
  • Custom script: call SetUnitX( udg_ShklHero , udg_ShklX )
Second: You're leaking. Add this after using the point variable to clear the leak:
  • Custom script: call RemoveLocation(udg_ShklPoint)
Third: You're leaking twice in the condition, the "Position of Caster" should be declared in a variable. The second leak is in the Unit Group.. ""Units within 400 of PointVariable"" should be declared in a variable, then use this to clear the group leak
  • Custom script: call DestroyGroup(udg_GroupVariableName)
Fourth: 0.02 is too fast. 0.03 is fast enough.

Where are the Target and Caster variables declared? There is no "Target Unit of abiltity being cast" in a Periodic Event...
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
  • Custom script: call SetUnitX(udg_TempUnit), GetUnitX(udg_TempUnit) + udg_AmountOffset * Cos(bj_DEGTORAD * udg_Angle))
  • Custom script: call SetUnitY(udg_TempUnit), GetUnitY(udg_TempUnit) + udg_AmountOffset * Sin(bj_DEGTORAD * udg_Angle))
Angle's a real.
AmountOffset is an int.
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
native SetUnitX takes unit whichUnit, real newX returns nothing

You need to put the prefix udg_ before every globals name declared in the variable editor.
udg for user defined globals.

Then never forget to give good type arguments ;)
You can use the conversion function
native I2R takes integer i returns real
native R2I takes real r returns integer
 
Status
Not open for further replies.
Top