• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Need help with a trigger

Status
Not open for further replies.
Level 3
Joined
May 24, 2016
Messages
22
So, I've been trying to create an ability that will trigger when a unit is targeted by an ability. Essentially, when so done, a dummy will throw the ability back at the caster. But, only once every 7 seconds.

But, the problem I'm having is I can't get the dummy to use the ability. I've looked through how other maps have done it, but it doesn't seem to be working. Can anyone help?

I've attached the file here, the trigger is Magic Return. Admittedly, my Jass is terrible (I've only really just started), but based on triggers in other maps not sure what the problem is.
 

Attachments

  • Fun1.w3x
    65.7 MB · Views: 30
  • Magic Return OnOff Trigger.jpg
    Magic Return OnOff Trigger.jpg
    243.2 KB · Views: 31
  • Magic Return Trigger.jpg
    Magic Return Trigger.jpg
    275.9 KB · Views: 32
Level 39
Joined
Feb 27, 2007
Messages
5,038
  • How To Post Your Trigger
  • You're leaking a couple locations. Here's how to fix them: Things That Leak
  • The "this trigger is on" check is pointless; since the trigger can't run if it's not on that condition will always evaluate to true.
  • Similarly the "level of black arrow" check is also unnecessary. If the unit doesn't have it then the random int check will always fail because (random 1-100) > 0
  • This spell is not MUI, but I presume that doesn't matter to you? If that's the case you don't need to use the other timer trigger and can just do:
    Turn off (This trigger)
    Wait 7.00 game-time seconds
    Turn on (this trigger)
  • My presumption as to why it's not working is that the unit's current order is no longer the spellcast order. I would suggest you try printing out the different orders made when issuing the spell vs. what this trigger detects. It might be the case that you need to use a "begins casting" event to properly store the order then issue it when the spell effect is started. You could also use something like LastOrder - Wc3C.net which automatically caches orders to issue the last or secondlast order as necessary.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,596
I managed to get it working by removing the If Then Else from the Return Trigger and putting the conditions in the default Conditions spot. I also added some more variables (and changed some names just because I was getting confused), cleaned up some leaks, and created a new Dummy unit since your Dummy unit had a bunch of problems. Your Dummy should be a non-hero unit, have no movement type/speed, and have no cast backswing/cast point. It should also have enough mana to cast any spell in the game.

  • Magic Return
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Casting unit)) Not equal to Dummy Uncle
    • Actions
      • Set ReturnEnemy = (Casting unit)
      • Set ReturnSource = (Target unit of ability being cast)
      • Set ReturnAbility = (Ability being cast)
      • Set ReturnPoint = (Position of ReturnSource)
      • Custom script: set udg_ReturnAbilityu = GetUnitCurrentOrder(udg_ReturnEnemy)
      • -------- - --------
      • Unit - Create 1 Dummy Uncle for (Owner of ReturnSource) at ReturnPoint facing Default building facing degrees
      • Set WildUnit = (Last created unit)
      • Unit - Add a 7.00 second Generic expiration timer to WildUnit
      • Unit - Add ReturnAbility to WildUnit
      • Unit - Set level of ReturnAbility for WildUnit to (Level of ReturnAbility for ReturnEnemy)
      • Custom script: call IssueTargetOrderById( udg_WildUnit, udg_ReturnAbilityu, udg_ReturnEnemy)
      • -------- - --------
      • -------- Remove Leaks --------
      • Custom script: call RemoveLocation (udg_ReturnPoint)
      • Countdown Timer - Start ReturnTimer as a One-shot timer that will expire in 7.00 seconds
      • Trigger - Turn off Magic Return <gen>
      • Game - Display to (All players) for 5.00 seconds the text: Magic Return - Off
  • Magic Return Timer
    • Events
      • Time - ReturnTimer expires
    • Conditions
    • Actions
      • Trigger - Turn on Magic Return <gen>
      • Game - Display to (All players) for 5.00 seconds the text: Magic Return - On
 

Attachments

  • Fun Uncle.w3x
    65.7 MB · Views: 69
Last edited:
Level 3
Joined
May 24, 2016
Messages
22
Thanks so much! Yes, got it working. And I appreciate the help cleaning up. As Pyrogasm said, was able to just reduce that if code to level of the ability percentage using moon glaive base for the ability.

On a related note, I tried making other dummy units--no matter what unit I base off, the editor makes it a hero, with 0 in all stats. Not sure why. That's why all 3 of my original dummies were hero units.Same problem when I loaded in Uncle's (new units are made into heroes, not units--luckily the dummy there was already a unit).

Again thanks guys! I really appreciate it!
 
Last edited:
Status
Not open for further replies.
Top