[DECORATE] Projectile spawning other projectiles on hit

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!)
User avatar
Hibachi
Posts: 11
Joined: Sat Mar 31, 2018 2:40 pm

[DECORATE] Projectile spawning other projectiles on hit

Post by Hibachi »

I have an enemy that throws bottles at player. I want the bottles to disappear when they hit player and shatter the glass parts when they hit the wall. I'm struggling with the second part, whenever the projectile hits wall, the glass actors don't appear. What do I do?

Code: Select all

ACTOR Bottle
{
	Radius 6
	Height 8
	Speed 20
	Damage (random(10,20))
	Projectile
	Alpha 1
	States
	{
	Spawn:
		BTTL ABCDEFGH 1 BRIGHT
		Loop
	Crash:
	XDeath:
		SPLS ABCDE 2 BRIGHT
		SPLS A 0 A_PlaySound("pirate/attack")
		Stop
	Death:
		SPLS ABCDE 2 BRIGHT
		TNT1 A 0 A_PlaySound("Bottle/death")
		TNT1 A 0 A_CustomMissile("glass1", 32, 0, random(-8, 8), 1, random(-3, 3))
		TNT1 A 0 A_CustomMissile("glass2", 32, 0, random(-8, 8), 1, random(-3, 3))
		TNT1 A 0 A_CustomMissile("glass3", 32, 0, random(-8, 8), 1, random(-3, 3))
		TNT1 A 0 A_CustomMissile("glass4", 32, 0, random(-8, 8), 1, random(-3, 3)) //random numbers just to check if it works
                Stop
	}
}

ACTOR glass1 : Bottle
{
	Projectile
	speed 20
	+thruspecies
	+doombounce
	species "Player"
	+FORCEXYBILLBOARD
	radius 6
	height 8
	gravity 0.9
	bouncefactor 1.2
	bouncecount 6
	
	states
	{
	spawn:
		GLSA ABCD 2
		stop
	death:
		TNT1 A 1
		stop
	}
}

ACTOR glass2 : Bottle
{
	Projectile
	speed 20
	+thruspecies
	+doombounce
	species "Player"
	+FORCEXYBILLBOARD
	radius 6
	height 8
	gravity 0.9
	bouncefactor 1.2
	bouncecount 6
	
	states
	{
	spawn:
		GLSB ABCD 2
		stop
	death:
		TNT1 A 1
		stop
	}
}

ACTOR glass3 : Bottle
{
	Projectile
	speed 20
	+thruspecies
	+doombounce
	species "Player"
	+FORCEXYBILLBOARD
	radius 6
	height 8
	gravity 0.9
	bouncefactor 1.2
	bouncecount 6
	
	states
	{
	spawn:
		GLSC ABCD 2
		stop
	death:
		TNT1 A 1
		stop
	}
}

ACTOR glass4 : Bottle
{
	Projectile
	speed 20
	+thruspecies
	+doombounce
	species "Player"
	+FORCEXYBILLBOARD
	radius 6
	height 8
	gravity 0.9
	bouncefactor 1.2
	bouncecount 6
	
	states
	{
	spawn:
		GLSD ABCD 2
		stop
	death:
		TNT1 A 1
		stop
	}
}
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: [DECORATE] Projectile spawning other projectiles on hit

Post by Matt »

Please familiarize yourself with [wiki]A_SpawnItemEx[/wiki] and forget about A_CustomMissile, it will solve a lot of headaches in the long run.
User avatar
Hibachi
Posts: 11
Joined: Sat Mar 31, 2018 2:40 pm

Re: [DECORATE] Projectile spawning other projectiles on hit

Post by Hibachi »

Matt wrote:Please familiarize yourself with [wiki]A_SpawnItemEx[/wiki] and forget about A_CustomMissile, it will solve a lot of headaches in the long run.
Thanks for the suggestion, I managed to make it work properly.

Return to “Scripting”