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

[Trigger] Passive spell occasionaly doesn't work.

Status
Not open for further replies.

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Hello, Hive!

I've been hearing reports of a spell in my map, sometimes not working. It's a passive ability that gives each spellcast % chance to reset its own cooldown, to restore a bit mana and to create a special effect. The spell works like.. >80% of the time, but sometimes the special effect occurs, but the cooldown is not reset (I am not sure about the mana part). Posting ability description + triggers below. Oh, and.. I am using waits but they are paired with turn on/off trigger. This is explained in the tooltip as: the effect cannot occur more than once per second. Why does the wait exist you ask? Since heroes have certain animation delay when they cast spells, if you cast an ability without using wait and it resets --> the ability doesn't have time to get cast, because the reset removes it before hero animation occurs.

240844-albums7679-picture89981.png
Arcane Master (Passive): Each spellcast of the Mage (except Polar Blast) has 12% to reset its own cooldown. Every 15 points of Intelligence increase that chance by 1%. In addition, whenever a cooldown reset occurs, the Mage will restore 6 mana (+3 per Hero Level). This effect cannot occur more than once each second.

Trigger
[trigger=""]Arcane Master
Events
Unit - A unit Starts the effect of an ability
Conditions
Or - Any (Conditions) are true
Conditions
(Ability being cast) Equal to Fire Bomb
(Ability being cast) Equal to Pyroblast
(Ability being cast) Equal to Ring of Frost
(Ability being cast) Equal to Arcane Pulse
Actions
Trigger - Turn off (This trigger)
Wait 0.20 seconds
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Random integer number between 0 and 100) Less than or equal to (12 + ((Intelligence of (Triggering unit) (Include bonuses)) / 15))
Then - Actions
-------- MANA --------
Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + (6.00 + (3.00 x (Real((Hero level of (Triggering unit)))))))
-------- RESET --------
Set ArcaneMaster_Ability = (Ability being cast)
Set ArcaneMaster_AbilityLevel = (Level of ArcaneMaster_Ability for (Triggering unit))
Unit - Remove ArcaneMaster_Ability from (Triggering unit)
Unit - Add ArcaneMaster_Ability to (Triggering unit)
Unit - Set level of ArcaneMaster_Ability for (Triggering unit) to ArcaneMaster_AbilityLevel
Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
Special Effect - Destroy (Last created special effect)
Else - Actions
Wait 0.80 seconds
Trigger - Turn on (This trigger)
[/trigger]
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
For this:
Since heroes have certain animation delay when they cast spells, if you cast an ability without using wait and it resets --> the ability doesn't have time to get cast, because the reset removes it before hero animation occurs.

Try the event Finishes casting a spell.

I think the problem here is that (Ability being cast) is lost in this trigger because of the wait. (Triggering unit) can deal with waits, but I think (Ability being cast) is overwritten by other spells that get cast. So if another player casts a spell during that 0.20 second window, it would break this passive.
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
I think the problem here is that (Ability being cast) is lost in this trigger because of the wait. (Triggering unit) can deal with waits, but I think (Ability being cast) is overwritten by other spells that get cast. So if another player casts a spell during that 0.20 second window, it would break this passive.

Shouldn't the "Turn trigger on/off" prevent further casts to bother with both (Ability being cast) and (Triggering unit) until all actions are executed (or in other words, until the trigger gets back on?)?
Assuming that's not the case, does this solve it:

[trigger=""]Arcane Master
Events
Unit - A unit Starts the effect of an ability
Conditions
Or - Any (Conditions) are true
Conditions
(Ability being cast) Equal to Fire Bomb
(Ability being cast) Equal to Pyroblast
(Ability being cast) Equal to Ring of Frost
(Ability being cast) Equal to Arcane Pulse
Actions
Trigger - Turn off (This trigger)
Set ArcaneMaster_Ability = (Ability being cast)
Set ArcaneMaster_AbilityLevel = (Level of ArcaneMaster_Ability for (Triggering unit))
Wait 0.20 seconds
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Random integer number between 0 and 100) Less than or equal to (12 + ((Intelligence of (Triggering unit) (Include bonuses)) / 15))
Then - Actions
-------- MANA --------
Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + (6.00 + (3.00 x (Real((Hero level of (Triggering unit)))))))
-------- RESET --------
Unit - Remove ArcaneMaster_Ability from (Triggering unit)
Unit - Add ArcaneMaster_Ability to (Triggering unit)
Unit - Set level of ArcaneMaster_Ability for (Triggering unit) to ArcaneMaster_AbilityLevel
Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
Special Effect - Destroy (Last created special effect)
Else - Actions
Wait 0.80 seconds
Trigger - Turn on (This trigger)
[/trigger]
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I've been hearing reports of a spell in my map, sometimes not working. It's a passive ability that gives each spellcast % chance to reset its own cooldown, to restore a bit mana and to create a special effect. The spell works like.. >80% of the time,

Ah I see you set the chance that it would occur to 80%.
Fixed :p

--------------------------------------------------------------------------------------------

Now for real.
First of all I would use different conditions:
Unit-Type of (Triggering unit) equal to Mage
(Ability being cast) not equal to Polar Blast
(Ability being cast) not equal to other-spell-that-may-not-have-this-effect-1
(Ability being cast) not equal to other-spell-that-may-not-have-this-effect-2
etc.

But that doesn't fix your problems.
What this trigger does wrong is that it uses Waits (also use (Wait (...) seconds of gametime) instead of (Wait (...) seconds.)
I won't explain why.
Normal waits are run even when the game is paused or whatever. It also doesn't calculate the game speed. So with a high game speed you will notice that the waits are equal as long as with very low game speed... That is not very good.
Next to that, wait timers have a slight delay in their waits. I use a small decreased amount in my wait timers so they will be more (but not precisely) accurate.
If you run some tests with a game time system, you can determine the delay duration and set the wait timers accordingly.


But after the waits, stuff like "ability being cast" and maybe "triggering unit" too might have been overridden by other spell casts/other stuff.
You should save them in local shadowed variables.

This is how I would do it:
  • Arcane Master
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Blood Mage
      • (Ability being cast) Not equal to Animate Dead
      • ((Triggering unit) is in ArcaneMasterCasters) Equal to False
    • Actions
      • Custom script: local unit udg_TempUnit
      • Custom script: local integer udg_TempAbility
      • Custom script: local integer udg_TempInteger
      • Set TempUnit = (Triggering unit)
      • Set TempAbility = (Ability being cast)
      • Set TempInteger = (Level of TempAbility for TempUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random real number between 0.00 and 100.00) Greater than (12.00 + ((Real((Intelligence of TempUnit (Include bonuses)))) / 15.00))
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • Unit Group - Add TempUnit to ArcaneMasterCasters
      • Wait 0.08 game-time seconds
      • -------- Mana --------
      • Unit - Set mana of TempUnit to ((Mana of TempUnit) + (6.00 + (3.00 x (Real((Hero level of TempUnit))))))
      • -------- Reset --------
      • Unit - Remove TempAbility from TempUnit
      • Unit - Add TempAbility to TempUnit
      • Unit - Set level of TempAbility for TempUnit to TempInteger
      • Special Effect - Create a special effect attached to the origin of TempUnit using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
      • Special Effect - Destroy (Last created special effect)
      • Wait 0.68 game-time seconds
      • Unit Group - Remove TempUnit from ArcaneMasterCasters
Also your trigger is not MUI. I don't know if there could be more than one unit but in the trigger I posted it is MUI.
 

SpasMaster

Hosted Project: SC
Level 23
Joined
Jan 29, 2010
Messages
1,969
Thanks for your suggestion, Wietlol. I just wanted to clear 2 things out:

1.) I don't need the spell to be MUI. Only one hero in the entire game has these abilities and no more than one hero of that type can exist in a single game.
2.) About these conditions:
Wietlol said:
(Ability being cast) not equal to Polar Blast
(Ability being cast) not equal to other-spell-that-may-not-have-this-effect-1
(Ability being cast) not equal to other-spell-that-may-not-have-this-effect-2
etc.

If I use this method, item abilities will be included as "resettable", since it's the hero that uses them. Is it really problematic if I list abilities that are legible for resetting only?

Oh, and, you mention that the problem in the trigger is the existance of waits, yet you use them yourself in your suggested trigger. May I ask, what's going on with that? :p

Thanks in advance.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
If I use this method, item abilities will be included as "resettable", since it's the hero that uses them. Is it really problematic if I list abilities that are legible for resetting only?
No it is not... If you want that, you can keep it.
(Should have added item-check.)

Oh, and, you mention that the problem in the trigger is the existance of waits, yet you use them yourself in your suggested trigger. May I ask, what's going on with that? :p
I do not.
You see there are more waits:
  • Actions
    • Wait 2.00 seconds
    • Wait 2.00 game-time seconds
Go and make an empty map.
Make a trigger like this:
  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Wait 30.00 seconds
      • Game - Display to (All players) the text: ???
Then start the game.
As soon as the game started, open the menu (this will pause the game).
Wait 30 seconds and then close the menu.
You see that the "???" are done immediately. (Maybe even while the menu is still open.)

If you use "Wait (real) game-time seconds" instead, you will not have that problem.
You would still have the inaccuracy problem though.
And the other problem was that the variables are overridden when another spell is cast if you use waits.
That is why I added the "Custom Script: local unit udg_TempUnit" etc.
Those are called shadowed variables. Everytime you use TempUnit in that trigger, you will refer to that variable instead of the global variable.
With that you can have multiple values in one variable... kind of.

This is why our trigger didnt work:
The mage casts a spell.
(Triggering unit) is now the mage.
then you wait 0.2 seconds.
Within those 0.2 seconds another unit casts a spell.
Now that other unit is (Triggering unit).
Now that unit will have its cooldown reset... That akward face when you see that your ultimate has its cooldown reset for some weird reason.

Btw can I download and play that map?
 

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
  • Unit - A unit Starts the effect of an ability
On that event the ability hasn't been cool-ed down yet. Try what rulerofiron suggested.

If it doesn't work, try to use all ability events: begin casting, spell effect, finish casting, and cancel cast. But now you have to equalize the chance by dividing the chance by 4 (because you have 4 events). ;) Hope that works.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
  • Unit - A unit Starts the effect of an ability
On that event the ability hasn't been cool-ed down yet. Try what rulerofiron suggested.
You've got it wrong. The ability is actually on cooldown when this event fires. The "starts the effect of an ability" event fires once cooldown has started and mana has been taken.
You're mistaking this event for "begins casting an ability" which fires before cooldown starts and before mana is taken.
 

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
You've got it wrong. The ability is actually on cooldown when this event fires. The "starts the effect of an ability" event fires once cooldown has started and mana has been taken.
You're mistaking this event for "begins casting an ability" which fires before cooldown starts and before mana is taken.

Based on my experience, when I tried to "stop" the casting unit on "begins casting an ability" event, the unit stopped and the ability wasn't cooldown. Anyway, going to test this again, sec....

Try this demo, result: mana taken, spell not cooldown.
 

Attachments

  • test.w3x
    16.2 KB · Views: 51
Level 24
Joined
Aug 1, 2013
Messages
4,657
You've got it wrong. The ability is actually on cooldown when this event fires. The "starts the effect of an ability" event fires once cooldown has started and mana has been taken.
You're mistaking this event for "begins casting an ability" which fires before cooldown starts and before mana is taken.

If you could be able to see the code of the ability effect you could see something like this:

call Event(StartsAbilityEffect)
if aborted then
return
endif
call RemoveMana(ability)
call SetOnCooldown(ability)
call StartEffect(ability)

I have had enough tests with ability cooldowns to make sure that this is how it works... ofcourse the code is different but that is no point.

If you want to do something after the ability is on cooldown, you can use a 0 seconds timer.
 
Level 18
Joined
Nov 21, 2012
Messages
835
Hi,
if you have unit indexer in map , please consider using loop triggers: 2 triggers / spell, and all will be Mui then, no waits needed.

Have idea with timer, its not Mui but easy to implement no waits needed also:
  • arcane
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Random integer number between 1 and 100) Greater than 50
          • Or - Any (Conditions) are true
            • Conditions
              • (Ability being cast) Equal to Animate Dead
              • (Ability being cast) Equal to Avatar
              • (Ability being cast) Equal to Thunder Clap
    • Actions
      • Trigger - Turn off (This trigger)
      • -------- --------
      • Custom script: call BJDebugMsg ("spell casted")
      • -------- mana action --------
      • Set TempUnit = (Triggering unit)
      • Unit - Set mana of TempUnit to 200.00
      • -------- reset action --------
      • -------- --------
      • Countdown Timer - Start TimerAttackInterval as a One-shot timer that will expire in 5.00 seconds
      • -------- --------
and:
  • arcane timer
    • Events
      • Time - TimerAttackInterval expires
    • Conditions
    • Actions
      • Trigger - Turn on arcane <gen>
      • Custom script: call BJDebugMsg ("aviable again")
regards, zibi
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
You've got it wrong. The ability is actually on cooldown when this event fires. The "starts the effect of an ability" event fires once cooldown has started and mana has been taken.
You're mistaking this event for "begins casting an ability" which fires before cooldown starts and before mana is taken.

At this point the ability cast can't be interrupted through normal means, but the cooldown and stuff like that hasn't been applied yet. I know that for sure because I have exploited this for variable cooldowns.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Now that you mention it Xonok...

How is it going?
I'd like to use it at some point but it is too hard for me to read :D

If I would have such a unique thing, I would make a system of it (very dynamic coding and a lot of documentation and a few examples) and ofcourse upload it here.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
I've still not made a version that allows setting an ability on cooldown through triggers. That would be quite necessary for improving.

Otherwise the system is already quite workable if you create the abilities with its macros. There is very little that has to be done manually tbh.
Let's not spam this thread with my system though. I am online on skype.
 
Status
Not open for further replies.
Top