[ZScript]Changing damage reduction based on amount of armor
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
[ZScript]Changing damage reduction based on amount of armor
Is there a simple way to do this? E.g. if the player picks up an armor bonus that puts them above 100 armor, it gives them damage reduction similar to blue armor. Alternatively, if the player takes damage that puts them at 100 armor or lower, it downgrades the damage reduction to match green armor.
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: [ZScript]Changing damage reduction based on amount of ar
If you've got a custom playerpawn and you only care about the player, you can use a DamageMobj override.
For a general solution I think a ThingDamaged eventhandler works but I've never tried it.
For a general solution I think a ThingDamaged eventhandler works but I've never tried it.
Re: [ZScript]Changing damage reduction based on amount of ar
Is there a way for me to directly access the player's armor and what savepercent it has? If not to the second question, what's the easiest way to swap between green armor and blue armor seamlessly?
Re: [ZScript]Changing damage reduction based on amount of ar
Use absorb damage override virtual on armor class.
For example
For example
Code: Select all
version "2.4"
class ar_mor : bluearmor
{
override void AbsorbDamage (int damage, Name damageType, out int newdamage)
{
super.absorbdamage(damage, damagetype, newdamage);
if(self.SaveAmount >= 100) {newdamage = damage * 0.5;}
if(self.SaveAmount < 100) {newdamage = damage * 0.66;}
}
states
{
spawn:
ARM1 A 6 bright;
ARM2 A 6 bright;
loop;
}
}
Re: [ZScript]Changing damage reduction based on amount of ar
Ok, I got a solution working that I was looking for:
Spoiler:Basically, I had to write in my own armor functionality. This unfortunately involves changing all of the Doom armor types so that their SavePercent is 0 as to not absorb any damage when taking a hit. This armor works off a degradation system instead of the normal system to avoid having to dance around green armor that always seems to be placed right in the middle of the path you need to take. Now you can pick up armor whenever without feeling like you're wasting blue armor. Also a nice buff for armor bonuses since they can now give blue armor tier damage absorption without needing to first pick up blue armor.
Last edited by Boondorl on Sat Jan 12, 2019 1:18 pm, edited 1 time in total.
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: [ZScript]Changing damage reduction based on amount of ar
That in my view is the easiest way, just going around the old Doom armour system instead of trying to work with it to do things it was never designed to do or even allow to be done.Basically, I had to write in my own armor functionality. This unfortunately involves changing all of the Doom armor types so that their SavePercent is 0 as to not absorb any damage when taking a hit.
- StroggVorbis
- Posts: 866
- Joined: Wed Nov 08, 2017 4:23 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Germany
Re: [ZScript]Changing damage reduction based on amount of ar
So now it's more like Hexen, S.T.A.L.K.E.R., Oblivion, Fallout 3, New Vegas and any other game that employs a condition system? Neat