• 🏆 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 a weird problem

Sorry, but have you ever seen an error where mana consumed but cooldown not fired?

  • No, how can it even be possible?

    Votes: 0 0.0%

  • Total voters
    3
  • Poll closed .
Status
Not open for further replies.
Level 3
Joined
Mar 26, 2019
Messages
54
I try to make a "teleport" skill, but for some reason, it get really weird. When I cast the ability, for some reason, the mana get consumed, and I get satisfying effect, but the cooldown is not fired. Here is my trigger:
  • Flash
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Flash
    • Actions
      • Set temp_point[1] = (Position of (Triggering unit))
      • Set temp_point[0] = (Target point of ability being cast)
      • Unit - Create 1 DummyChan for (Owner of (Triggering unit)) at temp_point[1] facing Default building facing degrees
      • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
      • Unit - Make (Last created unit) Explode on death
      • Unit - Add Dummy Flash to (Last created unit)
      • Unit - Order (Last created unit) to Neutral Tinker - Cluster Rockets temp_point[0]
      • Unit - Hide (Triggering unit)
      • Unit - Move (Triggering unit) instantly to temp_point[0]
      • Custom script: call RemoveLocation(udg_temp_point[1])
      • Custom script: call RemoveLocation(udg_temp_point[0])
      • Wait 0.75 game-time seconds
      • Set FlashExp[(Player number of (Owner of (Triggering unit)))] = (FlashExp[(Player number of (Owner of (Triggering unit)))] + 1)
      • Unit - Unhide (Triggering unit)
      • Selection - Select (Triggering unit) for (Owner of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Flash for (Triggering unit)) Less than or equal to 4
          • FlashExp[(Player number of (Owner of (Triggering unit)))] Greater than or equal to (15 x ((Level of Flash for (Triggering unit)) x (Level of Flash for (Triggering unit))))
        • Then - Actions
          • Unit - Increase level of Flash for (Triggering unit)
          • Set temp_player[1] = (Player group((Owner of (Triggering unit))))
          • Game - Display to temp_player[1] the text: Flash level up!
          • Custom script: call DestroyForce(udg_temp_player[1])
        • Else - Actions
Here is my map. Well, sorry, it is just a begginning map, so it may look unsighting, but please check and help me. I dont know where is the problem. You can get skill by using the skillbook which I place near spawnpoint.
 

Attachments

  • RPG_Newbie_Maker.w3x
    172.9 KB · Views: 16
Level 3
Joined
Mar 26, 2019
Messages
54
The spell order might be canceled by the move-order.
Add a "Wait 0 seconds" as very first action of the trigger. It should ensure the mana gets consumed before the spell-order gets canceled.
( I don't have editor right now to test map)
But as I say, mana get consumed well, but cooldown is not fired. Though to actually see this, you need to move away from resurrection circle, cause its recovery rate is a bit much.
 
Level 3
Joined
Mar 26, 2019
Messages
54
The spell order might be canceled by the move-order.
Add a "Wait 0 seconds" as very first action of the trigger. It should ensure the mana gets consumed before the spell-order gets canceled.
( I don't have editor right now to test map)
And
+Didn't wait only allow 0.1 sec or higher?
+ If I recall correctly, wait will make "target unit/point of ability being cast" return null, then how can I refer to them?
 
Level 9
Joined
Jul 30, 2018
Messages
445
You could actually try the things people suggest. It is indeed the move instantly function that causes the cooldown not start.

Just add "Wait 0.00 seconds" before it and it works just fine.

  • Flash
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Flash
    • Actions
      • Set temp_point[1] = (Position of (Triggering unit))
      • Set temp_point[0] = (Target point of ability being cast)
      • Unit - Create 1 DummyChan for (Owner of (Triggering unit)) at temp_point[1] facing Default building facing degrees
      • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
      • Unit - Make (Last created unit) Explode on death
      • Unit - Add Dummy Flash to (Last created unit)
      • Unit - Order (Last created unit) to Neutral Tinker - Cluster Rockets temp_point[0]
      • Wait 0.00 seconds
      • Unit - Hide (Triggering unit)
      • Unit - Move (Triggering unit) instantly to temp_point[0]
      • Custom script: call RemoveLocation(udg_temp_point[1])
      • Custom script: call RemoveLocation(udg_temp_point[0])
      • Wait 0.75 game-time seconds
      • Set FlashExp[(Player number of (Owner of (Triggering unit)))] = (FlashExp[(Player number of (Owner of (Triggering unit)))] + 1)
      • Unit - Unhide (Triggering unit)
      • Selection - Select (Triggering unit) for (Owner of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Flash for (Triggering unit)) Less than or equal to 4
          • FlashExp[(Player number of (Owner of (Triggering unit)))] Greater than or equal to (15 x ((Level of Flash for (Triggering unit)) x (Level of Flash for (Triggering unit))))
        • Then - Actions
          • Unit - Increase level of Flash for (Triggering unit)
          • Set temp_player[1] = (Player group((Owner of (Triggering unit))))
          • Game - Display to temp_player[1] the text: Flash level up!
          • Custom script: call DestroyForce(udg_temp_player[1])
        • Else - Actions
 
+Didn't wait only allow 0.1 sec or higher?
Using "0" for the wait action is allowed, but it will wait longer then 0 seconds. But there's no real reason to increase it to an arbitary greater value.
+ If I recall correctly, wait will make "target unit/point of ability being cast" return null, then how can I refer to them?
I haven't noted it something with "target" is used after the wait, but you're right. Sabe's solution looks better, but it might have potential location leak, as the wait action isn't really insant. If you move the RemoveLocation action before the wait, though, it should be good.
In general, to have correct access after wait one can use a trick, local udg_.
 
Level 9
Joined
Jul 30, 2018
Messages
445
Sabe's solution looks better, but it might have potential location leak, as the wait action isn't really insant.

Yeah. I just quickly tested it to prove a point. :p

Will hide a unit protect it from future harm, or I have to set it to invurenable?

You could have just tested it. I just did (took less than 10 mins) and you can damage a unit through triggers even if it was hidden, but other units cannot attack or target hidden units, including AoE spells not dealing damage. Test yourself more if you need more specific criteria.
 
Level 3
Joined
Mar 26, 2019
Messages
54
Sabe posted working code, and the potetial leak can be avoided, too.
Thank you. I has sucesfully fixed it. My trigger:
  • Flash
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Flash
    • Actions
      • Custom script: local unit u = GetTriggerUnit()
      • Custom script: local location p = GetSpellTargetLoc()
      • Custom script: local real x = GetLocationX(p)
      • Custom script: local real y = GetLocationY(p)
      • Custom script: call RemoveLocation(p)
      • Set temp_point[1] = (Position of (Triggering unit))
      • Set temp_point[0] = (Target point of ability being cast)
      • Unit - Create 1 DummyChan for (Owner of (Triggering unit)) at temp_point[1] facing Default building facing degrees
      • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
      • Unit - Make (Last created unit) Explode on death
      • Unit - Add Dummy Flash to (Last created unit)
      • Unit - Order (Last created unit) to Neutral Tinker - Cluster Rockets temp_point[0]
      • Unit - Hide (Triggering unit)
      • Custom script: call RemoveLocation(udg_temp_point[1])
      • Custom script: call RemoveLocation(udg_temp_point[0])
      • Wait 0.75 game-time seconds
      • Set FlashExp[(Player number of (Owner of (Triggering unit)))] = (FlashExp[(Player number of (Owner of (Triggering unit)))] + 1)
      • Custom script: call SetUnitPosition(u, x, y)
      • Unit - Unhide (Triggering unit)
      • Selection - Select (Triggering unit) for (Owner of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Flash for (Triggering unit)) Less than or equal to 4
          • FlashExp[(Player number of (Owner of (Triggering unit)))] Greater than or equal to (15 x ((Level of Flash for (Triggering unit)) x (Level of Flash for (Triggering unit))))
        • Then - Actions
          • Unit - Increase level of Flash for (Triggering unit)
          • Set temp_player[1] = (Player group((Owner of (Triggering unit))))
          • Game - Display to temp_player[1] the text: Flash level up!
          • Custom script: call DestroyForce(udg_temp_player[1])
        • Else - Actions
      • Custom script: set u = null
  • [\trigger]
 
Status
Not open for further replies.
Top