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

Falling monster

Recommended Posts

Sometimes when a monster on a ledge dies it will fall off. Other times it won't.

I have used barrels and crushing floors to try to reliably cause this to happen but cannot get more than half to fall. There seems to be a consistency about which ones fall depending on range between barrels and monsters so I don't think it can be random.

Is there a way for me to guarantee or increase the odds of the monster's falling from the ledges by applying any optimal conditions for success?

EDIT: I'm using vanilla Plutonia by the way...

Share this post


Link to post

This code is from P_DamageMobj, the function responsible for dealing damage to game objects:

        // make fall forwards sometimes
	if ( damage < 40
	     && damage > target->health
	     && target->z - inflictor->z > 64*FRACUNIT
	     && (P_Random ()&1) )
	{
	    ang += ANG180;
	    thrust *= 4;
	}
The "damage < 40" specifies a maximum damage that can possibly make the damaged object fall forward. The "damage > target->health" guarantees that the code will only be executed if the game object dies by the damage. The "target->z - inflictor->z > 64*FRACUNIT" means that the damaged object must be over 64 map units higher than the player/monster who fired at him and dealt him this damage. And the "P_Random ()&1" means that the code will only be executed with 50% probability if the previous conditions were already met.

purist said:

Is there a way for me to guarantee or increase the odds of the monster's falling from the ledges by applying any optimal conditions for success?

The player who shoots the monster must be more than 64 units below the monster, and he must use a weapon that doesn't deal more than 39 damage per hit. This will increase the odds up to 50% probability, assuming the monster stays near the edge of a ledge and the player shoots it from below the ledge.

Share this post


Link to post

Thanks scifista42, you're always reliable for technical explanations.

In my .WAD the monsters on the ledge are being killed by crushed barrels. So if I understand you correctly to achieve the maximum success rate of 50% I need the barrels (which are crushed with a raising floor) to cause the damage needed to kill the monsters before they are within 64 map units on the Z axis?

I also need the barrel to cause less than 40 damage but still kill the monster. I can't remember the HP of the (custom) monster but I think it was 40. If I reduce it to 39 this would guarantee the damage condition is made as long as the barrel is close enough to kill immediately.

It's a shame that it is still a 50% probability after these conditions are met. I thought that since IDCLEV and repeating the setup produced consistent results that there wasn't a random element. I assume this might have been because I was triggering the barrels at the same tic each time negating the randomness?

Share this post


Link to post

I'll better be more specific: This code makes monsters fall FORWARD. If you merely want them to fall OFF A LEDGE anyhow, that becomes possible automatically after they die by any means.

Normally, when a monster takes damage, it gets thrust away from the source of the damage by a thrust force that depends on the damage amount and on the mass of the monster. This falling code MERELY makes the thrust force be applied into the OPPOSITE direction than it normally would, that is TOWARDS the source of the damage rather than away from it, and be multiplied by 4 at the same time. Really, it does nothing more than that, as can be seen in the code. It only makes monsters fall off a ledge if the source of damage was down the ledge, so that they get pulled towards it.

If you place your barrels ONTO THE LEDGE in such a way that the MONSTER is BETWEEN the barrels and the edge of the ledge, you can just make them push the monster off the ledge by their sheer force (the bigger, the better), without this part of code getting involved at all - which should be 100% reliable if done properly.

EDIT: Your assumption about 39 HP guaranteeing the damage conditions be met was also wrong: Firstly, it would have to be 38, so that the killing damage would be both strictly lesser than 40 and strictly greater than the monster's HP, secondly, you would have to place the barrel to deal EXACTLY 39 damage to the monster, no more and no less, and thirdly, you could get around the issue by putting multiple barrels, each dealing a fraction of the damage needed to kill the monster, so that the final killing damage would be lesser than 40 for sure, it only would have to be strictly greater than the monster's current health at the moment of dying. But I think this is besides the point now.

Share this post


Link to post
scifista42 said:

If you place your barrels ONTO THE LEDGE in such a way that the MONSTER is BETWEEN the barrels and the edge of the ledge, you can just make them push the monster off the ledge by their sheer force (the bigger, the better), without this part of code getting involved at all - which should be 100% reliable if done properly.


This is exactly the scenario I have in place but am not getting reliable results for. I will try again some more tonight and post the .WAD if it still doesn't work. When I was testing last night it worked less than 50% of the time.

Share this post


Link to post

Well, if you have a setup like this, I could see why it doesn't work for all of the monsters:

+--------------------------------------------------------------------------+
|                                                                          |
|                            Crushing sector                               |
|                                                                          |
|       (B)        (B)        (B)        (B)        (B)        (B)         |
|                                                                          |
|                                                                          |
|                                                                          |
+--------------------------------------------------------------------------+
|                                                                          |
|                                 Ledge                                    |
|                                                                          |
|       (M)        (M)        (M)        (M)        (M)        (M)         |
|                                                                          |
|                                                                          |
|                                                                          |
+----------------------------- Edge of ledge ------------------------------+

(B) = Barrel
(M) = Monster
Even if all barrels exploded in the same tic, the engine would apply their damage onto the monsters one by one. Imagine that the leftmost barrel explodes first. It deals full damage to the closest (leftmost) monster and pushes him straight off the edge of the ledge. It also deals full damage to the 2nd monster from the left and pushes him off the ledge under a 45-degree angle (away from the barrel), which might or might not still suffice to push him fully off. But it also deals damage to the 3rd monster enough to kill him, but not enough to push him far enough off the ledge, due to both lesser thrust force and steeper angle. Then the 2nd barrel explodes and the same happens with the 4th monster, and so on.

Share this post


Link to post

It's very close to that but I have a second row of barrels between the crusher and the monsters. So are you suggesting a better setup would be dividing it up so each barrel will only affect one monster?

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  
×