• 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.

Item that moves the targeted unit to the caster

Status
Not open for further replies.
Level 2
Joined
Jun 24, 2018
Messages
13
I created an item that is supposed to move the targeted unit to the hero using the item and the targeted unit is slowed for a time (Which the item uses the cripple ability for). Unfortunately the target is not moved to the caster, please let me know what I did wrong! Thanks! (Also this is my first post and I dont know how to get the code from editor to here so I am typing it... Sorry!

The item is called Staff of Domination

"Move Slow (staff of Domination)" is the renamed Cripple ability for the item slow

The variables are:
staff_of_domo_move_cast_select is a unit variable
staff_of_domo_move_targ_select is a unit variable
staff_of_domo_move_caster_p is a point variable
staff_of_domo_move_targeted_p is a point variable

The Trigger that I have that doesn't work yet is:
________________________________________________

Events-
Unit- A unit Starts the effect of an ability

Conditions-
(Ability being cast) Equal to Move Slow

Actions-
Set staff_of_domo_move_cast_select = (Triggering unit)
Set staff_of_domo_move_targ_select = (Targeted unit)
Set staff_of_domo_move_caster_p = (Position of (triggering unit))
Set staff_of_domo_move_targ_p = (Position of (Targeted unit))
Unit - Move staff_of_domo_move_cast_select instantly to staff_of_domo_move_caster_p. facing staff_of_domo_move_caster_p
Custom script: call RemoveLocation(udg_staff_of_domo_move_cast_select)
Custom script: RemoveLocation(udg_staff_of_domo_move_targ_select)
Custom script: RemoveLocation(udg_staff_of_domo_move_caster_p
Custom script: RemoveLocation(udg_staff_of_domo_move_targeted_p)
________________________________________________
 
Level 42
Joined
Feb 27, 2007
Messages
5,312
(Also this is my first post and I dont know how to get the code from editor to here so I am typing it... Sorry!
Wecome! How To Post Your Trigger

It looks to me like you're doing approximately the right thing in your trigger, though obviously it's not an exact representation of what you actually did. There must be some error in the actual trigger where you didn't do something you thought you did. Post the trigger or the map and we can see.
 
Level 7
Joined
Jul 4, 2007
Messages
249
  • Events-
  • Unit- A unit Starts the effect of an ability
  • Conditions-
  • (Ability being cast) Equal to Move Slow
  • Actions-
  • Set staff_of_domo_move_cast_select = (Casting unit)
  • Set staff_of_domo_move_targ_select = (Target unit of ability being cast)
  • Set staff_of_domo_move_caster_p = (Position of (staff_of_domo_move_cast_select)
  • Set staff_of_domo_move_targ_p = (Position of (staff_of_domo_move_targ_select)
  • Unit - Move staff_of_domo_move_cast_select instantly to staff_of_domo_move_targ_p. facing staff_of_domo_move_targ_p
  • Custom script: call RemoveLocation(udg_staff_of_domo_move_caster_p)
  • Custom script: call RemoveLocation(udg_staff_of_domo_move_targeted_p)
Variables are so long and messy though, could just do
  • Events-
  • Unit- A unit Starts the effect of an ability
  • Conditions-
  • (Ability being cast) Equal to Move Slow
  • Actions-
  • Set unit = (Casting unit)
  • Set target = (Target unit of ability being cast)
  • Set tempLoc = (Position of target)
  • Unit - Move unit instantly tempLoc. facing tempLoc
  • Custom script: call RemoveLocation(udg_tempLoc)
Or atleast rename it to "SoD_unit, SoD_target, SoD_unitLoc, SoD_targetLoc" or something.
And btw you don't need position of unit.
 
Level 2
Joined
Jun 24, 2018
Messages
13
  • Staff of domination
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Move Slow (staff of domination)
    • Actions
      • Set staff_of_domo_move_cast_select = (Triggering unit)
      • Set staff_of_domo_move_targ_select = (Targeted unit)
      • Set staff_of_domo_move_caster_p = (Position of (Triggering unit))
      • Set staff_of_domo_move_targeted_p = (Position of (Targeted unit))
      • Unit - Move staff_of_domo_move_cast_select instantly to staff_of_domo_move_caster_p, facing staff_of_domo_move_caster_p
      • Custom script: call RemoveLocation(udg_staff_of_domo_move_cast_select)
      • Custom script: call RemoveLocation(udg_staff_of_domo_move_targ_select)
      • Custom script: call RemoveLocation(udg_staff_of_domo_move_caster_p)
      • Custom script: call RemoveLocation(udg_staff_of_domo_move_targeted_p)
This is the code I have, but I will try all of your suggestions now! Thank you!
 
Level 2
Joined
Jun 24, 2018
Messages
13
(Targeted unit) is not the target of a spellcast. Try another one having a name more suited for spell/ability casting.

Thank you for clarifying this, I never realized that this did not apply to spells.


Wecome! How To Post Your Trigger

It looks to me like you're doing approximately the right thing in your trigger, though obviously it's not an exact representation of what you actually did. There must be some error in the actual trigger where you didn't do something you thought you did. Post the trigger or the map and we can see.

Thank you for this link is was extremely helpful for better communication about the trigger!


  • Events-
  • Unit- A unit Starts the effect of an ability
  • Conditions-
  • (Ability being cast) Equal to Move Slow
  • Actions-
  • Set staff_of_domo_move_cast_select = (Casting unit)
  • Set staff_of_domo_move_targ_select = (Target unit of ability being cast)
  • Set staff_of_domo_move_caster_p = (Position of (staff_of_domo_move_cast_select)
  • Set staff_of_domo_move_targ_p = (Position of (staff_of_domo_move_targ_select)
  • Unit - Move staff_of_domo_move_cast_select instantly to staff_of_domo_move_targ_p. facing staff_of_domo_move_targ_p
  • Custom script: call RemoveLocation(udg_staff_of_domo_move_caster_p)
  • Custom script: call RemoveLocation(udg_staff_of_domo_move_targeted_p)
Variables are so long and messy though, could just do
  • Events-
  • Unit- A unit Starts the effect of an ability
  • Conditions-
  • (Ability being cast) Equal to Move Slow
  • Actions-
  • Set unit = (Casting unit)
  • Set target = (Target unit of ability being cast)
  • Set tempLoc = (Position of target)
  • Unit - Move unit instantly tempLoc. facing tempLoc
  • Custom script: call RemoveLocation(udg_tempLoc)
Or atleast rename it to "SoD_unit, SoD_target, SoD_unitLoc, SoD_targetLoc" or something.
And btw you don't need position of unit.

This trigger worked almost perfectly except it moved the caster to the target instead of the other way around, but that was a really simple fix. I apologize for the long drawn out name of the triggers, I am not real sure why I thought it necessary to not abbreviate.


Also stop using excessive variables when they're not necessary, that's a misconception to just think "store everything in variables and then use them". You're literally just doing 1 action.

This was my first attempt at using variables so I was not exactly sure where I needed them, but regardless thank you for the advice, I'll keep it in mind


Thank you all for your help! I finally have a working version of the item! here is the code I used

  • Staff of domination
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Move Slow (staff of domination)
    • Actions
      • Set staff_of_domo_move_cast_select = (Casting unit)
      • Set staff_of_domo_move_targ_select = (Target unit of ability being cast)
      • Set staff_of_domo_move_caster_p = (Position of staff_of_domo_move_cast_select)
      • Set staff_of_domo_move_targeted_p = (Position of staff_of_domo_move_targ_select)
      • Unit - Move staff_of_domo_move_targ_select instantly to staff_of_domo_move_caster_p, facing staff_of_domo_move_targeted_p
      • Custom script: call RemoveLocation(udg_staff_of_domo_move_caster_p)
      • Custom script: call RemoveLocation(udg_staff_of_domo_move_targeted_p)
 
Level 42
Joined
Feb 27, 2007
Messages
5,312
  • In general I would suggest to avoid the 'specific' event responses like "casting unit", "attacked unit", "ordered unit", etc. and instead use "Triggering unit" as it's the most general and always works. Those other responses all point to the unit that triggered the event anyway (read the event text and it should be clear which unit is triggering in a case that involves multiple units like A unit is attacked).
  • Variables are actually very helpful if you need to refer to a specific object multiple times in a trigger.
 
Status
Not open for further replies.
Top