Pain chance factor on weapons

Moderator: GZDoom Developers

User avatar
Rowsol
Posts: 982
Joined: Wed Mar 06, 2013 5:31 am

Pain chance factor on weapons

Post by Rowsol »

I could really use a way to adjust pain chance on weapons, without the need to edit monsters. A setting like PainChanceFactor would work wonders. Currently, if I want a powerful weapon to have a higher chance of stunning, my only recourse is adding a bunch of mini a_explodes to the impact.
User avatar
Zhs2
Posts: 1288
Joined: Fri Nov 07, 2008 3:29 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Maryland, USA, but probably also in someone's mod somewhere

Re: Pain chance factor on weapons

Post by Zhs2 »

This is a "just" tier solution but here's how you can legally hack it:

Code: Select all

// Do this on a puff or projectile.
override void BeginPlay()
{
	Super.BeginPlay();
	if(random(1, 100) <= 40) // 40% chance to commit pain, which of course stacks on top of any current painchances. Edit to fit your needs.
	{
		bFORCEPAIN = true;
	}
}
User avatar
Rowsol
Posts: 982
Joined: Wed Mar 06, 2013 5:31 am

Re: Pain chance factor on weapons

Post by Rowsol »

Appreciate the help.
User avatar
De-M-oN
Posts: 206
Joined: Mon May 26, 2008 3:24 pm
Preferred Pronouns: He/Him
Location: Germany

Re: Pain chance factor on weapons

Post by De-M-oN »

Is it also possible the opposite way?
So that I can have a faster chaingun, but the painchance stays same/similar?
User avatar
Zhs2
Posts: 1288
Joined: Fri Nov 07, 2008 3:29 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Maryland, USA, but probably also in someone's mod somewhere

Re: Pain chance factor on weapons

Post by Zhs2 »

The PAINLESS flag on your puffs or projectiles can be used to achieve the opposite effect.
User avatar
De-M-oN
Posts: 206
Joined: Mon May 26, 2008 3:24 pm
Preferred Pronouns: He/Him
Location: Germany

Re: Pain chance factor on weapons

Post by De-M-oN »

But that would disable pain entirely.
User avatar
Rachael
Posts: 13794
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her

Re: Pain chance factor on weapons

Post by Rachael »

The flag can be applied randomly based on chance. In the case of puffs you can use inheritance and swap a painless puff out for another when you need a lower pain chance for the puff.

I know this is far from ideal, it's a bit hacky, but a proper implementation ("fix" if you prefer) for this will require a full flag anyway because it would require overriding behavior that would likely break old mods without it.
Professor Hastig
Posts: 255
Joined: Mon Jan 09, 2023 2:02 am
Graphics Processor: nVidia (Modern GZDoom)

Re: Pain chance factor on weapons

Post by Professor Hastig »

Aren't there enough questionable pain flags already? The code looks horrendously convoluted to handle all the special exceptions that were added to it.
User avatar
Rachael
Posts: 13794
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her

Re: Pain chance factor on weapons

Post by Rachael »

Professor Hastig wrote: Thu Dec 05, 2024 5:37 am Aren't there enough questionable pain flags already? The code looks horrendously convoluted to handle all the special exceptions that were added to it.
Actually I agree. There's absolutely *WAY* too much override-of-override-of-override-of-override-of-override cruft in the Actor class as it is and this post reminded me of that.
User avatar
Zhs2
Posts: 1288
Joined: Fri Nov 07, 2008 3:29 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Maryland, USA, but probably also in someone's mod somewhere

Re: Pain chance factor on weapons

Post by Zhs2 »

De-M-oN wrote: Mon Dec 02, 2024 10:26 am But that would disable pain entirely.
Yes. You do not want to place it in a puff or projectile's default field, but rather randomize whether it is true at the puff or projectile's creation, as per the above post. Just replace bFORCEPAIN with bPAINLESS.
User avatar
De-M-oN
Posts: 206
Joined: Mon May 26, 2008 3:24 pm
Preferred Pronouns: He/Him
Location: Germany

Re: Pain chance factor on weapons

Post by De-M-oN »

ahh yes that might work. thank you

Return to “Closed Feature Suggestions [GZDoom]”