Help with shootable crates

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
Post Reply
stevet1
Posts: 36
Joined: Thu Jan 28, 2021 5:30 am

Help with shootable crates

Post by stevet1 »

First off - I wasn't sure which sub-forum this belonged in so mods please move if there's a better one for it.
I'd like to add some shootable crates to my map, I have no problem making the crate disappear and an object spawn in it's place but I'm failing badly at how to spawn debris. Basically I need a crate shard actor I can spawn? Or is there a better way?
Thanks for any help.
User avatar
ramon.dexter
Posts: 1520
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Help with shootable crates

Post by ramon.dexter »

The question is: How to spawn one actor from another actor. Yes, the crate shards have to be defined as an actor.

Here, take a look at this, a destructible pot:

Code: Select all

class dest_Pot : Pot Replaces Pot {
    Default {
        //$Category "Decorations/WoS"
        //$Title "Pot destructible"
        +SOLID
        +SHOOTABLE
        +NOBLOOD
        tag "earthenware pot";
        Radius 12;
        Height 24;
        
        Health 10;
    }
	
	States {
        Spawn:
            VASE A -1;
            Stop;
        Death:
            TNT1 A 0 A_Scream();
            TNT1 AAAAAAA 0 A_SpawnProjectile ("VasePieces", 5, 0, random (0, 360), 2, random (30, 160));
            TNT1 A 0 A_NoBlocking();
            Stop;
	}
}

class VasePieces : actor {
    Default {
        +DOOMBOUNCE
        +MISSILE
        +NOBLOCKMAP
        +NOTELEPORT
        +CLIENTSIDEONLY
        Radius 5;
        Height 5;
        Speed 6;
        Mass 1;
        BounceFactor 0.5;
    }
    
    States {
        Spawn:
            PBIT ABCDEFGHIJ 1;
            Loop;
        Death:
            NULL A 0 A_Jump(90,2);
            PBIT G -1;
            Stop;
            NULL A 0 A_Jump(90,2);
            PBIT H -1;
            Stop;
            PBIT J -1;
            Stop;
    }
}
stevet1
Posts: 36
Joined: Thu Jan 28, 2021 5:30 am

Re: Help with shootable crates

Post by stevet1 »

Thanks, I thought it would be something similar to this although of course a crate isn't an actor - just a sector with crate sidedefs. I'm using "when projectile hits" trigger to call a script to instantly lower the crate. The crate pieces though - I guess they would be actors, but I can't find anything suitable.
User avatar
ramon.dexter
Posts: 1520
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Help with shootable crates

Post by ramon.dexter »

You can already make the crate an actor...it would be better for this approach than some hacks with lowering floors...
stevet1
Posts: 36
Joined: Thu Jan 28, 2021 5:30 am

Re: Help with shootable crates

Post by stevet1 »

Okay that sounds interesting, tell me more?
User avatar
ramon.dexter
Posts: 1520
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Help with shootable crates

Post by ramon.dexter »

You can make the crate either a voxel, or a 3d model. 3d model is better approach.
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Help with shootable crates

Post by Enjay »

Yes, it's possible to make a 3D model that is almost indistinguishable from a sector-made crate.

If you did wish to continue using sector based ones though, the method that Hexen uses to spawn glass shards when a window breaks could also work for you. An ACS script spawns a shower of debris particles from a map spot.

I have used both methods but I think, in your case, an actor and model as your crate would probably be best.
User avatar
Enjay
 
 
Posts: 26517
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Help with shootable crates

Post by Enjay »

Meh! I decided to make an example.
CrateBang.pk3
(58.6 KiB) Downloaded 35 times
These don't spawn debris - which I realise was the whole point of the thread :P - I couldn't be bothered defining a debris actor and sprites.

It would be easy enough to define a bunch of projectile actors, extend the death sequence of the crates and use something like [wiki]A_SpawnProjectile[/wiki] to throw them around.

However, the crates do spawn a separate actor as their explosion. I made two crates (a brown and a grey one) so I thought that it would be more efficient to get them to just spawn the same explosion actor.

So, you could add your debris to the crates' death sequence, or to the explosion. If your debris is going to be coloured appropriately to your crates, then doing it in each crate would make sense.

I mentioned in my earlier post that model crates can be "almost indistinguishable from a sector-made crate". The obvious differences that spring to mind are:
  • Model crates would not appear as lines on the automap.
  • Model crates would not get decals on them when shot.
  • All actors are square and their collision is always aligned to the NESW orientation of the grid, regardless of the actor's angle in game. So a model crate at 45 degrees would still occupy a 64x64 space aligned to the grid, whereas a sector crate would have its collision wherever its lines were.
  • Model crates will not be subject to effects such as "[wiki]Fake_contrast[/wiki]".
Anyway, have a look at the attached example (it just runs in Doom 2). Feel free to use (or not) anything that you find within.
stevet1
Posts: 36
Joined: Thu Jan 28, 2021 5:30 am

Re: Help with shootable crates

Post by stevet1 »

Thanks Enjay, much appreciated - I'll take a look and hopefully be able to modify it to spawn the debris,
Post Reply

Return to “General”