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

[General] Shield/Barrier that blocks aoe damage, buffs and knockbacks

Status
Not open for further replies.
Level 7
Joined
Feb 9, 2021
Messages
301
What is the best way to create a barrier that blocks damage, stuns and other effects? The idea is that a caster creates a barrier in front of him and then all units behind the shield relative to aoe damage do not get damage or get effected by other effects. Would appreciate any thoughts and ideas on the above. Also, this should not work on all aoe damage.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,515
Here's how I would do it, you'll need multiple systems in place. Use a Damage Engine to detect and prevent damage. Use a custom Buff system so you have control over whether a Buff can be applied or not. Use your own Knockback system or edit an existing one to work the same was as the Buffs.

Then you'll need to mark your units behind the Barrier as "immune" or something. You can use a Unit Indexer, Hashtable, etc...
Unit.IsKnockbackImmune = True
Unit.IsBuffImmune = True
Unit.IsDamageImmune = True

So all of your systems will check for these states before affecting a unit. If the unit is KnockbackImmune then don't apply the knockback. If the unit is BuffImmune then don't apply the buff. If the unit is DamageImmune then Set the damage taken to 0.

It'd probably make more sense to use Integers to track the state of these properties instead of Booleans. For example, Add 1 when a unit gains an instance of KnockbackImmune and subtract 1 when they lose an instance of KnockbackImmune. So if KnockbackImmune is >= 1 then they're immune. This way you can have multiple effects that grant these properties and they'll all play nice together and stack properly.

I wouldn't bother trying this unless you're confident in your triggering/coding capabilities.

Perhaps an alternative solution could be done by Periodically Removing Buffs or making the Units spell immune. It's really only the Buff stuff that is difficult to manage since you can't detect these properly unless you're applying them yourself via triggers. This is the sort of thing that you design your map around from the very beginning, otherwise you're going to have trouble making it work properly. But maybe you can find a nice compromise and make it close enough to what you originally wanted.
 
Last edited:
Level 7
Joined
Feb 9, 2021
Messages
301
Here's how I would do it, you'll need multiple systems in place. Use a Damage Engine to detect and prevent damage. Use a custom Buff system so you have control over whether a Buff can be applied or not. Use your own Knockback system or edit an existing one to work the same was as the Buffs.

Then you'll need to mark your units behind the Barrier as "immune" or something. You can use a Unit Indexer, Hashtable, etc...
Unit.IsKnockbackImmune = True
Unit.IsBuffImmune = True
Unit.IsDamageImmune = True

So all of your systems will check for these states before affecting a unit. If the unit is KnockbackImmune then don't apply the knockback. If the unit is BuffImmune then don't apply the buff. If the unit is DamageImmune then Set the damage taken to 0.

It'd probably make more sense to use Integers to track the state of these properties instead of Booleans. For example, Add 1 when a unit gains an instance of KnockbackImmune and subtract 1 when they lose an instance of KnockbackImmune. So if KnockbackImmune is >= 1 then they're immune. This way you can have multiple effects that grant these properties and they'll all play nice together and stack properly.

I wouldn't bother trying this unless you're confident in your triggering/coding capabilities.

Perhaps an alternative solution could be done by Periodically Removing Buffs or making the Units spell immune. It's really only the Buff stuff that is difficult to manage since you can't detect these properly unless you're applying them yourself via triggers. This is the sort of thing that you design your map around from the very beginning, otherwise you're going to have trouble making it work properly. But maybe you can find a nice compromise and make it close enough to what you originally wanted.
Thanks, this makes sense. I was preparing for this type of spells, so I have all mentioned systems in place. I have some follow up questions on this:
1) The shield will protect only from aoe that happens on the opposite side of the shield. How would you go about detecting it?
2) The shield will not protect from certain types of aoe. How would you go about implementing this?
3) Let's say I make a system that applies different types of immune, using UnitIndexer. So, my system (struct) will have a variable UnitIndex.IsKnockbackImmune. How can I access this variable outside the struct in the buff system (for example)? I think it is not possible to call UnitIndex.IsKnockbackImmune outside the struct.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,515
1. If you're in control of damage using your own system then you can mark it as Area of Effect or not -> DealDamage(source, target, amount, type)
"type" could include all sorts of custom types you define like AoE. I think Bribe's Damage Engine can be setup to do something like this as well.

2. Refer back to 1, creating a custom type like AoE_Special.

3. I only really code in C# (Lua) so I'm unsure of what vJass structs can and can't do but I imagine you can create something like a Unit struct that contains all of the properties that you'd want a Unit to have and then link that to Units in some way so you can Get it whenever you need. If not, then you can rely on a Hashtable/Unit Indexer to track this data which should be accessible anywhere.
 
Level 7
Joined
Feb 9, 2021
Messages
301
1. If you're in control of damage using your own system then you can mark it as Area of Effect or not -> DealDamage(source, target, amount, type)
"type" could include all sorts of custom types you define like AoE. I think Bribe's Damage Engine can be setup to do something like this as well.

2. Refer back to 1, creating a custom type like AoE_Special.

3. I only really code in C# (Lua) so I'm unsure of what vJass structs can and can't do but I imagine you can create something like a Unit struct that contains all of the properties that you'd want a Unit to have and then link that to Units in some way so you can Get it whenever you need. If not, then you can rely on a Hashtable/Unit Indexer to track this data which should be accessible anywhere.
In terms of 1, I can detect who did the damage, but I would need X and Y of the aoe to compare the angle.

Otherwise, I think I got an idea of how to do it. Thanks!
 
Level 7
Joined
Feb 9, 2021
Messages
301
Oops, forgot to answer that. Yes, you would need to compare the position of the damage source / damage target and the barrier.
But damage source X and Y is not the same as aoe X and Y. So, I would need to store somewhere X and Y of AOE they casted.
 
Level 7
Joined
Feb 9, 2021
Messages
301
Oops, forgot to answer that. Yes, you would need to compare the position of the damage source / damage target and the barrier.
I just realised that this will not work well. The problem occurs if a unit cast two aoe spells in a row and the first one finishes later than the second. Then, the position of the first aoe might be lost until it reaches the barrier.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,515
I just realised that this will not work well. The problem occurs if a unit cast two aoe spells in a row and the first one finishes later than the second. Then, the position of the first aoe might be lost until it reaches the barrier.
Then store the initial position and keep track of it. I assume you're coding everything yourself so you should be able to control all of this stuff.
 
Status
Not open for further replies.
Top