• 🏆 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] Magic resistance

Level 14
Joined
Jan 24, 2017
Messages
247
I want an ability that gives magic resistance for a short duration of time to the caster. There are a bunch of magic restiance abilities, but they do not seem to work with duration.
Is there a simple way to achieve that or do I have to trigger the duration by adding and removing the ability?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
You have to trigger it.
  • Actions
    • Unit - Add Magic Resistance (Temp) to (Triggering unit)
    • Wait 5.00 game-time seconds
    • Unit - Remove Magic Resistance (Temp) from (Triggering unit)
This will work fine assuming your Unit cannot gain the ability again during the 5.00 second Wait.

If that's going to be a problem then you can use Unit Indexing and a Unit Group to fix the issue. That or a Hashtable and Timers, or some combination of these methods. That's assuming you want to do things in GUI.

Edit: Threw this map together real quick. You can use this same design for any type of timed spell.

Note that Dispels/Control Magic will need to be accounted for if you're using Buffs with your custom spell. Dispels can be solved by checking if the Unit still has the Buff in the Loop trigger's Conditions (next to the Is Unit Alive condition). But Control Magic won't transfer any of the custom bonuses like the Magic Resistance to the casting unit which may be a problem.
 

Attachments

  • Magic Resistance Timed 1.w3m
    23.8 KB · Views: 2
Last edited:
Level 14
Joined
Jan 24, 2017
Messages
247
You have to trigger it.
  • Actions
    • Unit - Add Magic Resistance (Temp) to (Triggering unit)
    • Wait 5.00 game-time seconds
    • Unit - Remove Magic Resistance (Temp) from (Triggering unit)
This will work fine assuming your Unit cannot gain the ability again during the 5.00 second Wait.

If that's going to be a problem then you can use Unit Indexing and a Unit Group to fix the issue. That or a Hashtable and Timers, or some combination of these methods. That's assuming you want to do things in GUI.
Alright, this is what I had too. Was just wondering if there is a better ability to get this working.
Thanks
 
Level 8
Joined
Oct 25, 2018
Messages
68
Easiest, and most efficient way to do this is to use a damage detection engine.
Give caster a buff.
When the caster takes damage, do a trigger which first checks if damage is of magical type.
If it is, reduce it by what you want.

If you need help getting into Damage Engine, let me know. You can find it here : Damage Engine 5.9.0.0

Using Waits in a trigger is not only not multiplayer available, but it can also cause big issues.
Using DE makes it so:
-When buff is dispelled, so is magic resistance
-Can change or stack values accordingly
-Multiple units can use this without issues
 
Last edited:
Level 14
Joined
Jan 24, 2017
Messages
247
Easiest, and most efficient way to do this is to use a damage detection engine.
Give caster a buff.
When the caster is hit, do a trigger which first checks if damage is magical type.
If it is, reduce it by what you want.

If you need help getting into Damage Engine, let me know. You can find it here : Damage Engine 5.9.0.0
That is definitly no the easiest way. But I give you efficient.
 
Level 8
Joined
Oct 25, 2018
Messages
68
It's as easy as copying the system, making a trigger which checks when unit takes damage, then checking if unit has buff, then checking if damage type is magical.

If you have no knowledge of coding it's probably the hardest thing in the world for you.
If you're any decent with triggering, even GUI, it takes maximum of 5 minutes to set this up.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
I'm curious, since I can't find a single downside to using DE, what do you think it is? It doesn't slow down FPS/game. It doesn't cost much map size. It can even help in the long run by making non-armor based damage reduction spells. What's the downside?
I feel like it must slow the game down, there's 1000 lines of code running every time a unit takes damage, which can happen 1000s of times per second. Maybe it's not too noticeable on modern hardware and/or on less action packed maps but I know of people intentionally avoiding such a system in their map because of performance issues. Also, Bribe's system in particular introduces a lot of variables which bloat the editor.

That being said, it's not that big of a deal. I use the system in all of my non-Lua maps and have helped many people on here figure out how to use it as well. The downsides are there, although you may not care about them since the upsides are so great.
 
Last edited:
Top