1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Need help with simple spell

Discussion in 'Triggers & Scripts' started by Bond009, Mar 2, 2011.

  1. Bond009

    Bond009

    Joined:
    Mar 24, 2010
    Messages:
    917
    Resources:
    3
    Maps:
    3
    Resources:
    3
    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..
     
  2. Marc Mamales

    Marc Mamales

    Joined:
    Dec 26, 2010
    Messages:
    450
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Try this :)

    • Change Place
      • Events
        • Unit - A unit Finishes casting an ability
      • Conditions
        • (Ability being cast) Equal to Change Place
      • Actions
        • Set Temp_Point = (Position of (YOUR UNIT))
     
  3. Bond009

    Bond009

    Joined:
    Mar 24, 2010
    Messages:
    917
    Resources:
    3
    Maps:
    3
    Resources:
    3
    yea i tried that it didnt work for some reason..

    when using finishes being cast it doesn't grab the Target unit of ability being cast, so i cant address anything relating to that unit.. :/
     
  4. Marc Mamales

    Marc Mamales

    Joined:
    Dec 26, 2010
    Messages:
    450
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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))
     
  5. Bond009

    Bond009

    Joined:
    Mar 24, 2010
    Messages:
    917
    Resources:
    3
    Maps:
    3
    Resources:
    3
    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 :)
     
  6. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,174
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    ^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
     
  7. Section

    Section

    Joined:
    Jul 23, 2008
    Messages:
    97
    Resources:
    0
    Resources:
    0
    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.
     
  8. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,174
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    Nope. The animation begins sooner than Starts the effect of an ability triggers.

    I believe the animation begins when "unit begins casting an ability" triggers, starts the effect triggers after a time period defined in Art - Animation - Cast point.
     
  9. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,398
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Moved to Triggers & Scripts.
     
  10. Bond009

    Bond009

    Joined:
    Mar 24, 2010
    Messages:
    917
    Resources:
    3
    Maps:
    3
    Resources:
    3
    so Maker will it need that wait time in there at all or will it work fine like you had it before? i havent been able to test it yet to see
     
  11. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,174
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    No, it isn't needed at all. It is optional, use it if you want to delay the switching a bit.

    I might not use polled wait for the delay but it should work.