Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Grimm

Question HOW Monsters Leave Things Behind

Recommended Posts

Um, first I'd like to say sorry if maybe I shoulda put this in my "Changing What Monsters Leave Behind Thread". It's a different question (though kinda on the same topic), and that thread is old (though it did get bumped), so . . . meh.

Anyway, my question is how are the item drops linked to the monsters? Is it:

A) Linked to the Thing
B) Controlled by a Code Pointer (so could I give another onster the Code Pointer and they'd drop stuff . . . ? Seems unlikely.)
C) Linked directly to a certain frame

I think I know the answer but I wanna be sure.

Share this post


Link to post

Linked to the thing is the answer. Certain enemies are hard coded to drop items when they die. They have the same death pointers as other monsters, but the code that defines the monster has some specific information about dropping items. There are no "drop a shotgun" pointers.

From the Zdoom code, by way of an example, I think this could be the relevant lines for the shotgun guy.

void AShotgunGuy::NoBlockingSet ()
{
	P_DropItem (this, "Shotgun", -1, 256);
}

Share this post


Link to post

it's linked to the death frames of certain enemies. I believe you can for instance, swap out the frames of monster X for, say, the shotgun guy and then monster X will drop a shotgun.

also what you can do, if you're willing to sacrifice a projectile, is make a monster spawn a projectile when it dies (via codepointers) and then switch the frames of said projectile to whatever you want to be dropped (also you'll need to flag the projectile to have gravity, zero damage, no death frames and make it pickupable).

so for instance, say you alter the cacodemon fireball to be the supershotgun. now you attach a fire cacodemon ball code pointer to one of the arch-vile's death frames so all archies will appear to drop a supershotgun (not overly useful, but it's just an example).

Share this post


Link to post

Very useful. Thanks. Very tricky, Cyb. :) So, uh, generally what frame in an attack sequence has the fire projectile pointer? The first frame in every attack sequence?

Share this post


Link to post

Hell freaking yeah! Much thanks!

This raises two questions for me.

1) Is it possible to use two code pointers on the same frame? I don't think it is, but I'd like to double check.

2) I remember reading in these here forums a little while back that the enemies that had constant action sounds had a little piece of code in their fourth walking frames (or something like that) that played the sound when it got to said frame. Could I give another enemy without a constant action sound a constant action sound by putting a play sound code pointer into their fourth walking frame?

Share this post


Link to post
Cyb said:

it's linked to the death frames of certain enemies. I believe you can for instance, swap out the frames of monster X for, say, the shotgun guy and then monster X will drop a shotgun.


Nah, I've tried that before. Give the Zombiemen death frames 222 and 227 (the shotgun guys death frames) and they still drop clips. Give imps the same death frames and they still drop nothing.

Conversely, if you give an enemy that normally drops an item death frames from an enemy that normally doesn't, it will still drop the item. (eg give a zombieman the imp death of 457 and 462 and it still drops a clip.)

Both the above hold true for doom.exe, PRBoom and Zdoom.

However, if you remove the "set dead body mode" pointer from the death sequence in Zdoom (2.0.47) (replacing it with a "face target one" for ease), the body still falls and becomes non blocking, but no longer drops a clip. In PRBoom, removing the dead body pointer means the body remains a blocking item, but still drops a clip. Doom.exe behaves like PRBoom. So Zdoom seems to have a slightly different behviour here.

What I'm guessing Zdoom does, is that whenever an enemy uses a "set dead body mode" pointer, the code is checked to see if that enemy should drop anything, if it should then the item is spawned. This has a spin off that I have been using for some time. I put 2 death pointers on one of my enemies (modified SS guy) and when you kill it, it drops 2 clips.

For a silly (or maybe not) example - you can put a death code pointer in a monster's walking sequence (in Zdoom) to create a monster that does not block you (but can still be shot), and which wanders around after you dropping clips or shotguns etc.

also what you can do, if you're willing to sacrifice a projectile, is make a monster spawn a projectile when it dies...


Now that is a cunning idea. I'll have to try that some time. Of course, I really only use Zdoom these days, so (as you know) simply getting a monster to spawn a specified item on death is easier most of the time.

Share this post


Link to post
Grimm said:

1) Is it possible to use two code pointers on the same frame?


No, but using a boom derivative port (Boom, MBF, Eternity, PRBoom, Zdoom etc) you can give pointers to frames that didn't have pointers before (impossible with the old EXE). If you make the first frame duration 0, then both pointers get played at the same time.

2) Could I give another enemy without a constant action sound a constant action sound by putting a play sound code pointer into their fourth walking frame?


This applies to specific enemies. A few enemies have a special walking code pointer that plays every now and again that not only says "walk" but says "play sound X" as well. The Spider Demon (DSMETAL), Cyber Demon (DSHOOF) and I think Arachnotron (DSBSPWLK IIRC) are ones that jump to mind. You can give these pointers to other enemies, and they will play the sound specified by the pointer. All enemies with the same pointer will play the same sounds (eg all enemies with the pointer for the spider will normally play DSMETAL).

Edit: Oh yeah, may as well mention it. There are some basic to intermediate dehacked tutorials on my site.

Share this post


Link to post

Alright, how bout this? What if I were to add a 0 duration fifth frame after every every fourth walking frame? Assuming there was a code pointer that played the sound I wanted, if I used that pointer there, it would achieve the same effect, right?

Share this post


Link to post
Enjay said:

What I'm guessing Zdoom does, is that whenever an enemy uses a "set dead body mode" pointer, the code is checked to see if that enemy should drop anything, if it should then the item is spawned. This has a spin off that I have been using for some time. I put 2 death pointers on one of my enemies (modified SS guy) and when you kill it, it drops 2 clips.


actually looking at the source code you pasted:

void AShotgunGuy::NoBlockingSet ()
	P_DropItem (this, "Shotgun", -1, 256);
that executes P_DropItem() whenever the specified actor (shotgunguy in this case) has noblocking set, so indeed, you're exactly right. However, removing the deathstate from a zdoom monster doesn't make them non-blocking, zdoom reduces dead things heights when their health goes below 0, so they're still solid, you're just walking over them (you'll see what I'm talking about if you kill something on a fairly steep slope).

I poked around the original source a bit but I couldn't find anything that specifies for certain enemies to drop junk, but it wasn't defined as a function in p_enemy.c which defines stuff like the romero head end game and commander keen pointers, so it does explain why you can't use the itemdrops elsewhere... I expect it's probably explicitly linked to that specific thing (the specific doomednum) being set to dead... weird... the original doom source is so full of odd hacks like that, it's really kind of a mess, I have trouble believeing carmack did all of this sometimes heh

oh and yah, the projectile thing is neat, but sacrificing projectiles is bad :( (and as you've said not really necessary for dropping stuff if you use zdoom) I actually used this in massm2 a loooong time ago before I redid most of my original work from almost 3 years ago, but I think I got the idea from zanzan tc which had that neato boomerang thing which was a plasma bullet that shot a cellpack back at the player when it hit the wall, thus creating the illusion of returning to the player. neat stuff. zanzan probably has some of the most extensive dehacked work I've seen, second only to batman doom (not surprising since they were both made by the same guy) some really awesome stuff in both those tcs, all around really

Share this post


Link to post
Cyb said:

Lots of useful stuff.


Thanks for that.


I didn't realise that's how the boomerang worked. Cool info.

Just for completeness, I don't think this is quite correct...

I expect it's probably explicitly linked to that specific thing (the specific doomednum) being set to dead

because ID# swapping can be used to prevent enemies dropping items. If you give a blue torch (for example) all the characteristics of a shotgun guy, including giving it the shotgun guy's doomed number (and change the blue torch to avoid conflicts) when you load up a map, all your shotgun guys will appear in the same place as normal and behave as normal until you you kill them when they will drop nothing. So the item dropping code will be explicitly linked to that specific thing, but not by the doomed number which is just another characteristic of the thing.

Share this post


Link to post
Enjay said:

because ID# swapping can be used to prevent enemies dropping items. If you give a blue torch (for example) all the characteristics of a shotgun guy, including giving it the shotgun guy's doomed number (and change the blue torch to avoid conflicts) when you load up a map, all your shotgun guys will appear in the same place as normal and behave as normal until you you kill them when they will drop nothing. So the item dropping code will be explicitly linked to that specific thing, but not by the doomed number which is just another characteristic of the thing.


ahh, very interesting, I always figured the doomednum of a thing WAS what defined it. lesse, the original source defines all things in an array of mobj structs, so the player is index 0, zombieman is index 1, shotgunguy is index 2 (nothing to do with their doomednums, player is doomednum -1, zombie 3004 and shotguy 9) (this is all in info.c of the original source if you want to take a look), so it must do some sort of check for a specific index in the array or something... heh so damned weird if that's the case, I really wish I could find the damned weapondrops in here... ah well

Share this post


Link to post

Heh, your trick works with Doom II projectiles in The Ultimate Doom, Cyb, which kicks ass! Also, if you don't mind possiblly fudging up Pain Elementals (or if you're using The Ultimate Doom), I found another way to make monsters leave stuff behind. Change the Lost Soul to whatever you want to spawn. (Make sure it has an attack sound.) Give whatever enemy code pointer 711 (spawn 1 Lost Soul) or maybe even 718 (spawn 3 or 4 Lost Souls) in their death frame, and voila! You can even paste the Lost Soul into some pointless thing type (such as Guts and Bones 2) so you won't lose it!

Share this post


Link to post

I recently discovered a lil trick on stopping a monster dropping an item.

(using the chaingunner as an example)

Go into dehacked. Go to the frames editor go to the start of the death\splat animation and set the code pointer a few frames ahead. This stops the chaingunner from dropping the chaingunner. However

a) now he doesn't play his death sfx
b) it obviously messes up the frames of the death animation.

You may wanna play around with the settings (frames etc) to suit your needs.

Or you can just change the starting deathframes codepointer to another monster's death frame as everyone else put it. =P

Share this post


Link to post

I have created sort of an example patch that makes shotgunners drop clips and SS Nazis drop shotguns using the ID swapping technique. The link below leads to a thread that talks about doing this, and close to the bottom of the page, The patch is attached to one of my posts.

The thread is here:
http://www.zdoom.org/forum/viewtopic.php?t=134&start=15

It may be on the Zdoom forums, but this trick will work in any exe.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×