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

[Solved] Coord-based incorrect trigger behaviour

Status
Not open for further replies.
Level 3
Joined
Mar 2, 2017
Messages
13
Greetings. I am not sure whether this or a trigger forum is a better place to post this. I've encountered an extremely weird bug I have no idea how to fix.

So, a trigger procs whenever I cast an ability (Multi Shot).
The trigger itself is kinda basic - it makes 5 dummies and forces each to cast an "arrow spell" offset by angle, so it makes a cone of arrows.

It works... 99% of the time. Absolutely as intended, by spawning 5 dummies and letting each shoot an arrow.
1% of the time, IF you are in a very specific condition, it does not.
That's when it gets weird.

When you enter a specific spot in my map, it might spawn only one dummy, get (and show) absolutely incorrect coords for casts, it might spawn 2 or 3 instead. It might spawn all 5 if you are a bit off that spot, and shoot the incorrect place.

I honestly have no idea what causes this trouble. That location has literally nothing to do with the game's specifics. Well... map was a 32x32 at some point, but is that even possible to make it cause issues? I was not able to replicate the bug at, say, bottom of the map.

Here is the trigger. I've tweaked it to make it easier to debug.
  • ArcherMultiShot
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Multi Shot
    • Actions
      • Set TargetMultishot = ((Position of (Casting unit)) offset by 800.00 towards (Facing of (Casting unit)) degrees)
      • Unit - Create 1 dummy - multishot for (Owner of (Casting unit)) at (Position of (Casting unit)) facing Default building facing degrees
      • Unit - Set level of ArrowMS for (Last created unit) to (Level of Multi Shot for (Casting unit))
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Archmage - Blizzard TargetMultishot
      • Game - Display to (All players) the text: MS coord 1
      • Game - Display to (All players) the text: ((String((X of TargetMultishot))) + ( + (String((Y of TargetMultishot)))))
      • Set TargetMultishot = ((Position of (Casting unit)) offset by 800.00 towards ((Facing of (Casting unit)) + 10.00) degrees)
      • Unit - Create 1 dummy - multishot for (Owner of (Casting unit)) at (Position of (Casting unit)) facing Default building facing degrees
      • Unit - Set level of ArrowMS for (Last created unit) to (Level of Multi Shot for (Casting unit))
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Archmage - Blizzard TargetMultishot
      • Game - Display to (All players) the text: MS coord 2
      • Game - Display to (All players) the text: ((String((X of TargetMultishot))) + ( + (String((Y of TargetMultishot)))))
      • Set TargetMultishot = ((Position of (Casting unit)) offset by 800.00 towards ((Facing of (Casting unit)) + 20.00) degrees)
      • Unit - Create 1 dummy - multishot for (Owner of (Casting unit)) at (Position of (Casting unit)) facing Default building facing degrees
      • Unit - Set level of ArrowMS for (Last created unit) to (Level of Multi Shot for (Casting unit))
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Archmage - Blizzard TargetMultishot
      • Game - Display to (All players) the text: MS coord 3
      • Game - Display to (All players) the text: ((String((X of TargetMultishot))) + ( + (String((Y of TargetMultishot)))))
      • Set TargetMultishot = ((Position of (Casting unit)) offset by 800.00 towards ((Facing of (Casting unit)) - 10.00) degrees)
      • Unit - Create 1 dummy - multishot for (Owner of (Casting unit)) at (Position of (Casting unit)) facing Default building facing degrees
      • Unit - Set level of ArrowMS for (Last created unit) to (Level of Multi Shot for (Casting unit))
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Archmage - Blizzard TargetMultishot
      • Game - Display to (All players) the text: MS coord 4
      • Game - Display to (All players) the text: ((String((X of TargetMultishot))) + ( + (String((Y of TargetMultishot)))))
      • Set TargetMultishot = ((Position of (Casting unit)) offset by 800.00 towards ((Facing of (Casting unit)) - 20.00) degrees)
      • Unit - Create 1 dummy - multishot for (Owner of (Casting unit)) at (Position of (Casting unit)) facing Default building facing degrees
      • Unit - Set level of ArrowMS for (Last created unit) to (Level of Multi Shot for (Casting unit))
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Order (Last created unit) to Human Archmage - Blizzard TargetMultishot
      • Game - Display to (All players) the text: MS coord 5
      • Game - Display to (All players) the text: ((String((X of TargetMultishot))) + ( + (String((Y of TargetMultishot)))))
The trigger for ArrowMS is kinda complicated and I suspected it being bugged, also added a debug line into that, but turns out dummys don't spawn, so the issue is in this trigger.

I am attaching the map in case you want to see it yourself. Pick an archer, and here is the screenie (just a bit up from the start) on what your "multi shot" cast has to be like to make the bug happen.
Clip2net_170309153937.png


That's it, hoping for someone grateful enough to save me!

There is also another gamebreaking complicated bug, and it is also location-related (but... different location, duh), but much harder to reproduce and I think is connected to this one.
 

Attachments

  • ordo ab chao 0.42experiment.w3x
    1.2 MB · Views: 28
Level 15
Joined
Mar 25, 2016
Messages
1,327
Try saving casting unit to a variable and use it instead. It can possibly be overwritten by triggers that are run on the event "enters region", because you create units and "is issued an order".
In general it's better to use a variable, if you often use casting unit to reduce the amount of function calls (everytime you use casting unit one function is called).
 
Level 3
Joined
Mar 2, 2017
Messages
13
Thanks, together with some tweaking towards the angle (basically doing the similar approach and saving it as a variable) it solved my problem entirely. That's some really weird WC3 logic, considering there is zero events bound to this particular zone!

Now let's hope the more complicated bug has exact the same root, otherwise another thread might pop up soon...
 
Status
Not open for further replies.
Top