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

Need help with simple spell

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2010
Messages
950
so this is the trigger
  • Change Places
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Change Places
    • Actions
      • Set Temp_Point = (Position of (Triggering unit))
      • Set Temp_Point2 = (Position of (Target unit of ability being cast))
      • Unit - Move (Target unit of ability being cast) instantly to Temp_Point
      • Unit - Move (Triggering unit) instantly to Temp_Point2
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Custom script: call RemoveLocation (udg_Temp_Point2)
The spell im using for this is Channel configured to target units.

simple enough, i just want the units to change places, and they do. Its works.. But the prob is there needs to be some sort of delay time so he can finish casting the spell becuz when they change places, the Hero that casted the spell the spell cd doesnt kick in. It happens to fast it ignores the cd on that hero completely..
 
Level 9
Joined
Dec 26, 2010
Messages
475
Try this ^^
  • Change Places
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Change Places
    • Actions
      • Set Temp_Target = (Target Unit of ability being cast)
      • Set Temp_Point = (Position of (Triggering unit))
      • Set Temp_Point2 = (Position of (Target unit of ability being cast))
      • Unit - Move (Target unit of ability being cast) instantly to Temp_Point
      • Unit - Move (Triggering unit) instantly to Temp_Point2
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Custom script: call RemoveLocation (udg_Temp_Point2)
  • Change Place
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Change Place
    • Actions
      • Set Temp_Target = Temp_Target
      • Set Temp_Point = (Position of (Temp_Target))
 
Level 13
Joined
Mar 24, 2010
Messages
950
lol did you try that out? i can see what your getting at but that wont quite work :/ also this needs to be MUI so that will have a small time delay and will try to reuse the temp unit variable if 2 ppl happened to cast that spell near the same time.

Edit:

I did it that way and it seems to work fast enough, i hope it doesnt run into a prob with lag on bnet throwing off its timing or something but oh well its the best i got for now lol

  • Change Places Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Change Places
    • Actions
      • Set unit = (Target unit of ability being cast)
  • Change Places Copy 2
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Change Places
    • Actions
      • Set Temp_Point = (Position of (Triggering unit))
      • Set Temp_Point2 = (Position of unit)
      • Unit - Move unit instantly to Temp_Point
      • Unit - Move (Triggering unit) instantly to Temp_Point2
      • Custom script: call RemoveLocation (udg_Temp_Point)
      • Custom script: call RemoveLocation (udg_Temp_Point2)
      • Game - Display to (All players) the text: (Name of (Triggering unit))
      • Game - Display to (All players) the text: (Name of unit)
works not to bad :)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
^But that's not MUI.

Try this:

  • Untitled Trigger 062
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to *ability*
    • Actions
      • Custom script: local unit caster = GetTriggerUnit()
      • Custom script: local unit target = GetSpellTargetUnit()
      • Custom script: local real x = GetUnitX(target)
      • Custom script: local real y = GetUnitY(target)
      • Custom script: call SetUnitX( target , GetUnitX(caster) )
      • Custom script: call SetUnitY( target , GetUnitY(caster) )
      • Custom script: call SetUnitX( caster , x )
      • Custom script: call SetUnitY( caster , y )
      • Custom script: set target = null
      • Custom script: set caster = null
 
Level 4
Joined
Jul 23, 2008
Messages
99
Notice that Starts an effect of ability triggered when your model starts cast animation. You should add some seconds of wait (equal to model's cast take time) then put the code above.

Example :
A model of Firelord takes 0.37 seconds to finish his cast.

Put your variable declaration.
Add Wait 0.37 + tolerance seconds.
The Real Actions begin here.

So copied from above :

  • Custom script: local unit caster = GetTriggerUnit()
  • Custom script: local unit target = GetSpellTargetUnit()
  • Custom script: local real x = GetUnitX(target)
  • Custom script: local real y = GetUnitY(target)
  • Custom script: call PolledWait(0.37 + tolerance) <--- SEE HERE
  • Custom script: call SetUnitX( target , GetUnitX(caster) )
  • Custom script: call SetUnitY( target , GetUnitY(caster) )
  • Custom script: call SetUnitX( caster , x )
  • Custom script: call SetUnitY( caster , y )
  • Custom script: set target = null
  • Custom script: set caster = null
'tolerance' value is up to you. If it is a random value or fixed one.
 
Status
Not open for further replies.
Top