Landmine-like projectile?

Archive of the old editing forum
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.
Locked
User avatar
Zero X. Diamond
Posts: 676
Joined: Tue Dec 22, 2009 12:46 am
Contact:

Landmine-like projectile?

Post by Zero X. Diamond »

I usually wouldn't post a thread asking for something so piddling as I have a buddy to whom I go in search of these answers, but he's not around and this is something that's really bothering me since I can't seem to figure out how to get it to work right. What I'm trying to do at the moment is basically make shards of glass that I'm having an enemy throw like grenades. They should bounce a bit, then stop on the ground and wait for something (either a player, enemy or another projectile) to walk over them, then doing damage to them. Unfortunately, with my limited DECORATE skills I can either get it to almost behave right in either one of two ways:

1.) With +MISSILE, it bounces around, does damage on impact, but vanishes just a moment after hitting the ground.
2.) Without +MISSILE, it stays around after it hits the ground, but it no longer bounces, doesn't do any sort of damage at all, and also doesn't disappear when it hits water.

I'm interested in learning how to do this as I'm also thinking about making actual land mines in this little thing I'm cobbing together over here, but right now it's one step at a time. For reference, here is the code for both the projectile itself and, if it's at all relevant, the monster that is throwing it.

Code: Select all

ACTOR GlassShard1
{
	+NOBLOCKMAP
	+DROPOFF
//	+MISSILE
	+ACTIVATEIMPACT
	+ACTIVATEPCROSS
	+NOTELEPORT
	+FORCEPAIN
	+NOEXTREMEDEATH
	RenderStyle "Translucent"
	Alpha "0.2"
	Damage 2
	BounceType "Doom"
	SeeSound "misc/chat2"
	BounceSound "misc/chat2"
	States
	{
	Spawn:
		ICEC A 1
		Wait
	Death:
		ICEC A 1 A_Explode (1, 0, false, false)
		Stop
	}
}

ACTOR GlassImp : DoomImp
{
	+MISSILEMORE
	+NOBLOOD
	+AVOIDMELEE
	Translation "61:79=[255,255,255]:[84,152,180]","171:191=193:207"
	RenderStyle "Translucent"
	Alpha "0.2"
	Speed 10
	Health 25
	PainChance 255
	Obituary "%o was shattered by a glass imp."
	States
	{
	Melee:
    	TROO EF 8 A_FaceTarget
    	TROO G 6 A_CustomMeleeAttack(random (1,4)*3,"imp/melee")
		TROO G 0
	Missile:
		TROO EF 4 A_FaceTarget
		TROO G 4 A_ThrowGrenade (GlassShard1, 0, random(3,15), random(1,10))
	Goto See
	Death:
    	TROO I 8 A_Scream
    	TROO I -1 A_IceGuyDie
    stop
	}
}
Any help would be greatly appreciated!
User avatar
Ryan Cordell
Posts: 4349
Joined: Sun Feb 06, 2005 6:39 am
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia (Modern GZDoom)
Location: Capital of Explodistan

Re: Landmine-like projectile?

Post by Ryan Cordell »

Ever tried +MISSILE and +CORPSE? There are also several +BOUNCE flags (or is it the Bounce property?) if you're not intending to use the +MISSILE flag. I am not sure however, how +CORPSE would act on it. You'll also want to define a CRASH state - it's when the actor is fully on the ground.
The_Funktasm
Posts: 612
Joined: Tue Mar 17, 2009 5:12 am
Location: done making ZDF free sprites

Re: Landmine-like projectile?

Post by The_Funktasm »

I made a landmine once.

Here's the code for reference.

Code: Select all

ACTOR Diskun2
{
   PROJECTILE
   Radius 12
   Height 3
   Speed 12
   Bouncefactor 0.5
   Damage 14
   ExplosionDamage 26
   ExplosionRadius 128
   SeeSound "weapons/dsnull"
      DeathSound "weapons/splode"
   PROJECTILE
   -NOGRAVITY
   +HEXENBOUNCE
   +ACTIVATEIMPACT
   +ACTIVATEPCROSS
   Obituary "%o stepped on %k's mine."
   States
   {
   Spawn:
      MINE B 1
      Loop
   Death:
        MINE B 0 A_PlaySound("weapons/splode")
        MINE B 0 A_Explode
        MINE E 0 Bright A_custommissile("DiskWave",0,0,0,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,20,2,0)
    	MINE E 0 Bright A_custommissile("DiskWave",0,0,40,2,0)
    	MINE E 0 Bright A_custommissile("DiskWave",0,0,60,2,0)
    	MINE E 0 Bright A_custommissile("DiskWave",0,0,80,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,100,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,120,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,140,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,160,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,180,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,200,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,220,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,240,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,260,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,280,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,300,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,320,2,0)
        MINE E 0 Bright A_custommissile("DiskWave",0,0,340,2,0)
        MINE B 0 A_custommissile("DiskWave",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("DiskWave",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("DiskWave",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("DiskWave",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("DiskWave",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("DiskWave",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("DiskWave",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("DiskWave",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("DiskWave",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_Mushroom("Fragment2",6)
        MINE B 0 A_custommissile("Fragment",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("Fragment",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("Fragment",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("Fragment",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("Fragment",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("Fragment",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("Fragment",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("Fragment",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 A_custommissile("Fragment",0,0,random(-360,360),2,random(-360,360))
        MINE B 0 
        BAMF ABCDEF 1 Bright A_AlertMonsters
      Stop
   }
}
User avatar
Zero X. Diamond
Posts: 676
Joined: Tue Dec 22, 2009 12:46 am
Contact:

Re: Landmine-like projectile?

Post by Zero X. Diamond »

Adapting some bits of Funktasm's code, I was able to get it ALMOST functional. This is what mine looks like now:

Code: Select all

ACTOR GlassShard1
{
	PROJECTILE
	-NOGRAVITY
	+FORCEPAIN
	+NOEXTREMEDEATH
	Radius 1
	Height 1
	Speed 5
	RenderStyle "Translucent"
	Alpha "0.2"
	Damage 1
	BounceType "Hexen"
	BounceFactor "0.5"
	SeeSound "misc/chat2"
	BounceSound "misc/chat2"
	States
	{
	Spawn:
		ICEC A 1
		Loop
	Crash:
		ICEC A 1
		Loop
	Death:
		ICEC A 1 A_Explode (1, 0, false, false)
		Stop
	}
}
The problem now is that it the projectile never stops bouncing ever (once it hits the ground and stops moving it just bounces up and down very slightly) so it continues playing the bounce sound endlessly (and, as previously mentioned, moves slightly up and down, which I'd like to avoid). Once I solve this problem, I'm in the clear. Any suggestions? The only way I can think of right now is to just completely remove the bounce sound and with a projectile so small that doesn't seem wise... the player should be made aware that glass is bouncing near them.
User avatar
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: Landmine-like projectile?

Post by NeuralStunner »

I know how to do this, but it's pretty late here now... I can probably put together a working landmine+grenade for you tomorrow (Thursday that is).
User avatar
Cutmanmike
Posts: 11353
Joined: Mon Oct 06, 2003 3:41 pm
Operating System Version (Optional): Windows 10
Location: United Kingdom
Contact:

Re: Landmine-like projectile?

Post by Cutmanmike »

For my mines I had a mine projectile for falling (shot by the weapon) that shot another projectile with a speed of 0.
User avatar
Zero X. Diamond
Posts: 676
Joined: Tue Dec 22, 2009 12:46 am
Contact:

Re: Landmine-like projectile?

Post by Zero X. Diamond »

Cutmanmike wrote:For my mines I had a mine projectile for falling (shot by the weapon) that shot another projectile with a speed of 0.
This method worked quite well! I had to make them disappear on death in something of a hacky way (there's obviously a way that doesn't require TNT1 to be used) but it now works as expected. Thanks a lot for the help everyone! For anyone who's interested, this is the final code (unless somebody has a suggestion for improvement here).

Code: Select all

ACTOR GlassShard1Spawner
{
	PROJECTILE
	-NOGRAVITY
	+FORCEPAIN
	+NOEXTREMEDEATH
	Speed 5
	RenderStyle "Translucent"
	Alpha "0.2"
	BounceType "Doom"
	BounceFactor "0.5"
	SeeSound "misc/chat2"
	BounceSound "misc/chat2"
	States
	{
	Spawn:
		ICEC A 1
		Loop
	Death:
		ICEC A 0 A_SpawnItemEx (GlassShard1, 0, 0, 0, 0, 0, 0, 0, SXF_TRANSFERPOINTERS)
		TNT1 A -1
		Stop
	}
}

ACTOR GlassShard1
{
	PROJECTILE
	+FORCEPAIN
	+NOEXTREMEDEATH
	Speed 0
	RenderStyle "Translucent"
	Alpha "0.2"
	Damage 1
	States
	{
	Spawn:
		ICEC A 1
		Loop
	Death:
		ICEC A 0
		TNT1 A -1
		Stop
	}
}
EDIT: Actually, just noticed one small problem still exists. Now when a glass shard hits the player while in flight, it spawns another glass shard that just hangs there in space. This happens specifically if the player is hit while standing still.
User avatar
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: Landmine-like projectile?

Post by NeuralStunner »

Try making the radius/height of the spawned projectile a little bigger than the fired one.
User avatar
Zero X. Diamond
Posts: 676
Joined: Tue Dec 22, 2009 12:46 am
Contact:

Re: Landmine-like projectile?

Post by Zero X. Diamond »

Actually, I went the opposite direction and made the thrown projectile smaller. It seems to have worked. Thanks for all your help, everybody!
User avatar
Ichor
Posts: 1784
Joined: Wed Jul 23, 2003 9:22 pm

Re: Landmine-like projectile?

Post by Ichor »

Zero X. Diamond wrote:The problem now is that it the projectile never stops bouncing ever (once it hits the ground and stops moving it just bounces up and down very slightly) so it continues playing the bounce sound endlessly (and, as previously mentioned, moves slightly up and down, which I'd like to avoid). Once I solve this problem, I'm in the clear. Any suggestions? The only way I can think of right now is to just completely remove the bounce sound and with a projectile so small that doesn't seem wise... the player should be made aware that glass is bouncing near them.
Use BounceCount.
Locked

Return to “Editing (Archive)”