Fastprojectiles w/ damage falloff
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
- rollingcrow
- Posts: 733
- Joined: Tue Mar 02, 2010 8:30 pm
- Graphics Processor: nVidia with Vulkan support
Fastprojectiles w/ damage falloff
Is it possible for an fastprojectile's damage to reduce in games like Wolfenstein 3D or most modern games' hitscan weapons?
Re: Fastprojectiles w/ damage falloff
Hacky method: send several projectiles, without any spread. Make them of different types, all derived from each other through inheritance.
Use code this form:
The number of A in the spawn state determines how long it exists, and therefore, how long it travels. The first class should be the one that travels the least, then you can just copy/paste the exact same code, changing only the name of the bullet actor and its parent, to get even increments in this way.
Shoot all of these projectiles at once and without any sort of variance (you can use args[] or user variables if you do want random spread, compute it once and use the same values for each projectile) so that they'll overlap and just disappear when they run out of their range. There will be gradually less bullets, and therefore gradually less damage.
Use code this form:
Code: Select all
Actor BulletThatGoesABitFarther : BulletThatStopsAfterAWhile
{
States
{
Spawn:
BULL AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1
Goto Super::Spawn
}
}
Shoot all of these projectiles at once and without any sort of variance (you can use args[] or user variables if you do want random spread, compute it once and use the same values for each projectile) so that they'll overlap and just disappear when they run out of their range. There will be gradually less bullets, and therefore gradually less damage.
- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Fastprojectiles w/ damage falloff
Alternate method:
A hitscan can also use the A_Explode method, but would need the [wiki=Actor_flags#PUFFGETSOWNER]PUFFGETSOWNER[/wiki] flag a large number of [wiki]A_JumpIfCloser[/wiki] calls to determine how far it is from the shooter.
- Fire a single projectile.
- Give it Damage (0).
- Include an arg or user var that decreases each tic.
- If the variable drops to zero, have the missile terminate itself.
- On impact, pass the variable to A_Explode, give it a radius/fulldamageradius slighly larger than the projectile's size, and make it not hurt the shooter.
- Make sure it has the [wiki=Actor_flags#FORCERADIUSDMG]FORCERADIUSDMG[/wiki] flag, so it can actually hurt explosive-immune bosses and such.
A hitscan can also use the A_Explode method, but would need the [wiki=Actor_flags#PUFFGETSOWNER]PUFFGETSOWNER[/wiki] flag a large number of [wiki]A_JumpIfCloser[/wiki] calls to determine how far it is from the shooter.
- rollingcrow
- Posts: 733
- Joined: Tue Mar 02, 2010 8:30 pm
- Graphics Processor: nVidia with Vulkan support
Re: Fastprojectiles w/ damage falloff
I'll give these methods a try soon, thanks!
- rollingcrow
- Posts: 733
- Joined: Tue Mar 02, 2010 8:30 pm
- Graphics Processor: nVidia with Vulkan support
Re: Fastprojectiles w/ damage falloff
I have two questions:NeuralStunner wrote:Alternate method
- Is there a way to make the damage not fall below a minimum value?
- I should have asked this earlier, but how do I use an Arg?
- NeuralStunner
-
- Posts: 12328
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: No Preference
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: Fastprojectiles w/ damage falloff
[wiki]A_JumpIf[/wiki]Se7eNytes wrote:
- Is there a way to make the damage not fall below a minimum value?
[wiki]A_SetArg[/wiki], Args[] [wiki=DECORATE_expressions]Decorate Expression[/wiki].Se7eNytes wrote:
- I should have asked this earlier, but how do I use an Arg?