Ripper with puff

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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!)
Post Reply
DivineHero
Posts: 7
Joined: Sun Sep 20, 2020 5:59 pm

Ripper with puff

Post by DivineHero »

I don't think we can do this already for zdoom, but it is in Hexen. I'm asking for a way to do projectiles that pass through enemies, but when they do, they spawn a custom puff over the impact point and do the damage only once when it passes through the enemy. Like the wraithverge ghost. The custom puff can perhaps have different states or sounds depending on whether the target hit was a bleeding actor, a noblood actor, or a wall. There can still be blood splats in addition to the puff.

Also, for rippers, it seems like there's only one ripping sound for when the projectile passes through an enemy for every ripping projectile in the game. Can it be customized for different actors?
User avatar
Zhs2
Posts: 1300
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
Contact:

Re: Ripper with puff

Post by Zhs2 »

DIY in ZScript, [wiki=ZScript_virtual_functions]with a SpecialMissileHit override[/wiki]. You can (conditionally) spawn a puff at the position of the projectile when the override is called, as well as keep track of the last hit victim's pointer so it isn't hit more than once on the same rip-through.
DivineHero
Posts: 7
Joined: Sun Sep 20, 2020 5:59 pm

Re: Ripper with puff

Post by DivineHero »

Zhs2 wrote:DIY in ZScript, [wiki=ZScript_virtual_functions]with a SpecialMissileHit override[/wiki]. You can (conditionally) spawn a puff at the position of the projectile when the override is called, as well as keep track of the last hit victim's pointer so it isn't hit more than once on the same rip-through.
Thank you for the recommendation. I'll see if I can do that.
DivineHero
Posts: 7
Joined: Sun Sep 20, 2020 5:59 pm

Re: Ripper with puff

Post by DivineHero »

When I implemented it, I found that it also showed the puff when launching from the shooting actor. How can I prevent that from happening? Also, if the projectile hits a non-shootable actor, it explodes and displays the puff. Can I make it only explode without displaying the puff in that situation?

Code: Select all

	Actor lastVictim;
	override int SpecialMissileHit (Actor victim)
	{
		if (lastVictim != victim)
		{
			lastVictim = victim;
			A_SpawnItemEx("AxeHitPuff");
			return -1;
		}
		else
		{
			return 1;
		}
	}
also, I'm new to zscript and started converting some relevant classes in my decorate, but now it seems like it's not loading the decorate definitions at all. If I have to convert all of the decorate code to zscript I suppose that's ok.
User avatar
SanyaWaffles
Posts: 848
Joined: Thu Apr 25, 2013 12:21 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11 for the Motorola Powerstack II
Graphics Processor: nVidia with Vulkan support
Location: The Corn Fields
Contact:

Re: Ripper with puff

Post by SanyaWaffles »

Zscript is loaded before DECORATE. you can theoretically load the DEOCRATE definitions, but it must be done afterwards. ZScript can only be done first.
User avatar
Zhs2
Posts: 1300
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
Contact:

Re: Ripper with puff

Post by Zhs2 »

DivineHero wrote:Also, if the projectile hits a non-shootable actor, it explodes and displays the puff. Can I make it only explode without displaying the puff in that situation?
You can check the victim's bShootable flag as a condition for spawning the puff.
DivineHero wrote:also, I'm new to zscript and started converting some relevant classes in my decorate, but now it seems like it's not loading the decorate definitions at all.
You can use ZScript and DECORATE in the same project just fine. Since ZScript is loaded first, any identically named DECORATE classes will produce an error in the console and subsequently be renamed to avoid naming clashes. Do note that DECORATE classes can inherit from ZScript ones and even use functions written in their ZScript parent in a project that will take time to convert from DECORATE to ZScript.
DivineHero
Posts: 7
Joined: Sun Sep 20, 2020 5:59 pm

Re: Ripper with puff

Post by DivineHero »

I am able to load both my zscript and decorate now, thanks to you. But I'm still not sure about how to prevent the puff from appearing on the shooter immediately when it is launched. I thought maybe I could introduce a hitcount variable and increment when it hits a target and just not show the puff if it's the first time. That didn't seem to work right though. Is there a better way?
User avatar
Zhs2
Posts: 1300
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
Contact:

Re: Ripper with puff

Post by Zhs2 »

The victim pointer in the SpecialMissileHit override will equal the projectile's target pointer (aka the shooter) in that case.
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: Ripper with puff

Post by Logan MTM »

What about something like Damagetype, custom pain state that spawn your puff?
Post Reply

Return to “Scripting”