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

[Solved] Having a problem with moving a unit

Status
Not open for further replies.
Never mind, I somehow fixed it... Though I am definitely glad hive is here otherwise I would be lost in code.



For some reason this almost like magic works perfectly...

Unit - Move get_unit[1] instantly to ((Position of get_unit[1]) offset by get_real[1] towards get_real[5] degrees)

While the problem code below doesn't.
[trigger=]
Ticking arrow
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Ticking Arrow
Actions
Set set_unit[1] = (Random unit from dummies)
Set set_unit[2] = (Triggering unit)
Custom script: call MoveLocation(udg_rcp1, GetUnitX(udg_set_unit[2]), GetUnitY(udg_set_unit[2]))
Set used_units = 2
Custom script: call MoveLocation(udg_rcp2, GetSpellTargetX(), GetSpellTargetY())
Unit Group - Remove set_unit[1] from dummies
Custom script: call SetUnitX(udg_set_unit[1], GetUnitX(udg_set_unit[2]))
Custom script: call SetUnitY(udg_set_unit[1], GetUnitY(udg_set_unit[2]))
-------- speed --------
Set set_real[1] = 12.00
Custom script: set udg_set_real[2]=GetUnitX(udg_set_unit[1])
Custom script: set udg_set_real[3]=GetUnitY(udg_set_unit[1])
-------- spell duration --------
Set set_real[4] = 60.00
-------- angle --------
Set set_real[5] = (Angle from rcp1 to rcp2)
Set used_reals = 5
Set trigger = Ticking arrow Copy <gen>
Set timeout = 0.05
  • The problem starts with the get reals 2 and 3.
  • [trigger=problem code]
  • Ticking arrow Copy
    • Events
    • Conditions
    • Actions
      • Set get_real[4] = (get_real[4] - 1.50)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • get_real[4] Greater than 0.00
        • Then - Actions
          • Special Effect - Create a special effect attached to the chest of get_unit[1] using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: set udg_get_real[2]=GetUnitX(udg_get_unit[1])
          • Custom script: set udg_get_real[3]=GetUnitY(udg_get_unit[1])
          • Custom script: set udg_get_real[2]=(udg_get_real[2]+udg_get_real[1])*Cos(udg_get_real[5]*bj_DEGTORAD)
          • Custom script: set udg_get_real[3]=(udg_get_real[3]+udg_get_real[1])*Sin(udg_get_real[5]*bj_DEGTORAD)
          • Custom script: call SetUnitX(udg_get_unit[1],udg_get_real[2])
          • Custom script: call SetUnitY(udg_get_unit[1],udg_get_real[3])
        • Else - Actions
          • Unit Group - Add get_unit[1] to dummies
          • Set automaticClean = True
          • Set finish = True
  • [trigger][hidden]
 
Last edited:
Status
Not open for further replies.
Top