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

Shield Trigger

Status
Not open for further replies.
Level 2
Joined
Apr 3, 2020
Messages
6
Hi all,

Is it possible to make an auto-cast spell where if a unit casts the spell, the unit can generate a shield around a different unit giving that unit a shield which absorbs incoming damage.

For example, let's take the priest and his heal ability. Instead of healing the targeted unit, the priest instead creates a shield around the targeted unit absorbing up to lets say the next 150 damage that shielded unit takes. How could I possibly tackle such a trigger?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
You could use a Damage Engine + an autocast ability that serves no purpose other than to apply a buff (optional) and trigger a cast Event.

Then trigger the shield's effects using a Unit Indexer or Hashtable. You want to store the shield as a Real value to the unit since you'll be subtracting damage from it.

Then with the Damage Engine you detect when a unit takes damage, check if it has a Shield value > 0.00, and reduce the damage taken by the appropriate amount, also reducing the Shield value in the process.

The calculations could look something like this:

If damage taken <= shield life then subtract damage taken from shield life and set damage taken = 0, in that order.

ELSE, if damage taken is > shield life then subtract shield life from damage taken and set shield life = 0, in that order.

So with the above setup, if your unit takes 200 damage with a 150 Shield, the ELSE will happen resulting in 200-150=50 damage taken with 0 Shields left.

If your unit takes 100 damage with a 150 Shield, it'll result in 150-100=50 Shields left with 0 Damage taken.

Damage Engine 5.6.1.0
Hashtables and MUI
GUI Unit Indexer 1.4.0.0
 
Last edited:
Status
Not open for further replies.
Top