Page 1 of 1

Grenade Issues

Posted: Wed Apr 26, 2017 1:06 pm
by Skwirl
So I found a weapon mod to at least give me an idea of how to program grenades. Turns out the Spawn: state needs to be prolonged to the amount of seconds I want.

Now, I have two problems...

1) I'm not getting a satisfying full-on explosion sound. Merely something that sounds like puffing air into the mic. It's not blowing up like my missile explosions can.

2) I'm showering the grenade I threw with tracer shots, and it absolutely will not blow up.

Here's the code. What did I do wrong?

Code: Select all

// Projectile
actor grenade_frag_p {
	Tag "grenade_frag_p"
	Damage 0
	Health 1
	Height 4
	Radius 2
	Speed 35
	Mass 5 
	BounceFactor 0.3
	WallBounceFactor 0.25
	BounceCount 3
	+SHOOTABLE
	+NOBLOOD
	+DONTGIB
	+NOICEDEATH
	+FORCEXYBILLBOARD
	+VULNERABLE
	-NOGRAVITY
	-NOBLOCKMAP

	States {
		Spawn:
			BON2 A 175
			Goto Death
		Death:
			TNT1 A 0 A_Quake(5, 25, 0, 400)
			TNT1 A 1 Bright A_SpawnItemEx("GrenadeExplosion")
			Stop
	}
}

Code: Select all

/*

Effect - Grenade Explosion

The effect that happens when a grenade explodes.

*/

actor GrenadeExplosion {
	+NOBLOCKMAP
	+ALLOWPARTICLES
	+RANDOMIZE
	+NOBLOOD
	+NOGRAVITY
	RenderStyle Translucent
	Alpha 0.5
	VSpeed 15
	Mass 3
	
	States {
		Spawn:
			BEXP A 2 Bright A_PlaySound("weapons/pistol")
			BEXP B 2 Bright A_SetScale(1.2, 1.2)
			BEXP C 4 Bright 
			BEXP D 1 Bright A_SetScale(1.2, 1.2)
			BEXP D 1 Bright
			BEXP D 1 Bright 
			BEXP D 1 Bright A_SetScale(1.4, 1.4)
			BEXP D 1 Bright 
			BEXP D 1 Bright A_FadeOut(0.25)
			BEXP D 1 Bright A_SetScale(1.6, 1.6)
			BEXP D 1 Bright 
			BEXP E 1 Bright A_FadeOut(0.05)
			BEXP E 1 Bright A_SetScale(1.8, 1.8)
			BEXP E 1 Bright 
			BEXP E 1 Bright A_FadeOut(0.05)
			BEXP E 1 Bright A_SetScale(2.0, 2.0)
			BEXP E 1 Bright 
			BEXP E 1 Bright A_FadeOut(0.05)
			BEXP E 1 Bright A_FadeOut(0.05)
			BEXP E 1 Bright A_FadeOut(0.05)
			Stop
	}
}

Re: Grenade Issues

Posted: Sun Jun 18, 2017 5:25 pm
by Skwirl
Bumping because I'd like the help.

Also good news, I was able to migrate this into GZDoom 3.1 without fatal errors.

Re: Grenade Issues

Posted: Sun Jun 18, 2017 11:41 pm
by Matt
Unfortunately the first frame of spawn state still needs the nodelay keyword:

Code: Select all

BEXP A 2 nodelay Bright A_PlaySound("weapons/pistol")
(I don't remember if the nodelay goes first or bright or if it even matters, if that doesn't work switch 'em around)

I don't know what you mean by "showering the grenade I threw with tracer shots".

Why the +ALLOWPARTICLES?

Re: Grenade Issues

Posted: Mon Jun 19, 2017 6:41 am
by Skwirl
Vaecrius wrote:Unfortunately the first frame of spawn state still needs the nodelay keyword:

Code: Select all

BEXP A 2 nodelay Bright A_PlaySound("weapons/pistol")
(I don't remember if the nodelay goes first or bright or if it even matters, if that doesn't work switch 'em around)

I don't know what you mean by "showering the grenade I threw with tracer shots".
I slang a lot when I talk... I was shooting the grenade, but each time I did, it was not exploding. I was "showering it in bullets", as in I used a machine gun on it and everything, but it just will not blow up. And I don't know why.
Vaecrius wrote:Why the +ALLOWPARTICLES?
[/quote]

It's been a long time since I touched the code, but I do want to make different types of explosions, including fragmentation that like shoots out a circle of different effects (shrapnel, smoke clouds, etc.), and I figured Particles were the way to do it.

Re: Grenade Issues

Posted: Mon Jun 19, 2017 9:46 am
by Matt
I just gave this a try.

Everything seems to work as it ought after I add the nodelay.

Shooting it detonates it as it ought, but with that sprite and those dimensions it's really hard to hit and the hitbox isn't where I would think it is.

Re: Grenade Issues

Posted: Mon Jun 19, 2017 2:45 pm
by Skwirl
Vaecrius wrote:I just gave this a try.

Everything seems to work as it ought after I add the nodelay.

Shooting it detonates it as it ought, but with that sprite and those dimensions it's really hard to hit and the hitbox isn't where I would think it is.
Son of a bitch it worked. Thanks!

At one point I removed the A_Quake because I found that was eating up the sound time of the explosion which was why it sounded like a puff. I also resized the radius/height, and it worked. Just as it should.

Now I have a grenade that can be blown up before the timer, a grenade that gives a quake effect when you're close enough, etc.

Re: Grenade Issues

Posted: Mon Jun 19, 2017 3:41 pm
by Matt
I like that quake effect!

If you have the explosion sound on CHAN_AUTO and/or after the quake call it should not get cut off.