[ZScript]Changing damage reduction based on amount of armor

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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.

[ZScript]Changing damage reduction based on amount of armor

Postby Boondorl » Thu Jan 10, 2019 6:46 pm

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.
Boondorl
 
Joined: 11 Jul 2018

Re: [ZScript]Changing damage reduction based on amount of ar

Postby Matt » Thu Jan 10, 2019 8:10 pm

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.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
 
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: [ZScript]Changing damage reduction based on amount of ar

Postby Boondorl » Fri Jan 11, 2019 12:38 am

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?
Boondorl
 
Joined: 11 Jul 2018

Re: [ZScript]Changing damage reduction based on amount of ar

Postby Apeirogon » Fri Jan 11, 2019 4:42 am

Use absorb damage override virtual on armor class.

For example
Code: Select allExpand view
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;
}

}
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: [ZScript]Changing damage reduction based on amount of ar

Postby Boondorl » Sat Jan 12, 2019 6:22 am

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 2:18 pm, edited 1 time in total.
Boondorl
 
Joined: 11 Jul 2018

Re: [ZScript]Changing damage reduction based on amount of ar

Postby Matt » Sat Jan 12, 2019 1:44 pm

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.
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.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
 
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: [ZScript]Changing damage reduction based on amount of ar

Postby DabbingSquidward » Mon Jan 14, 2019 3:09 pm

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 :)
User avatar
DabbingSquidward
 
Joined: 08 Nov 2017
Location: Germany


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest