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

Doom code questions

Recommended Posts

Well, I've decided to make a custom executable for my Legacy project Rust, to circumvent some of Legacy's more annoying inflexibilities. But since I know absolutely fuck-all about coding, and this is my first dabble, there's a lot of stuff I don't understand.

1). Where the hell is the code which determines what an item does when the player picks it up. E.g. where is it defined that the player's health increases when s/he runs over health, or that s/he acquires a bfg when a bfg is picked up? Because I want to add two new weapons and one new ammotype, but I can't beat this problem.

2). I'm having a problem with certain effects. Now I want this attack to get stronger in proportion to the distance between you and the target.

So I use:

fixed_t     distance;
fixed_t     thrust;

if(source && source->player && (source == inflictor)
   && source->player->readyweapon == wp_pulvx76
   && damage > target->health)
	{
	distance = P_AproxDistance (source->x-target->x,
				    source->y-target->y);
	thrust = 35 /(distance/10);
	}
Which should make the pushback on the enemy stronger the closer you are. E.g if the attack was from 128 units away 128/10 = 12.8, 35/12.8 = 2.73. From 64 it would be 5.4. But for some reason this doesn't work.

However, if I use thrust = distance/10; or something, the pushback works fine. Could anyone tell me why is this happening? Because my maths are bad, and my programming is far, far worse.

Share this post


Link to post

1. That's determined by the sprite of the thing, e.g. RKEY would be a red key, BON would be a health potion, etc.

2. My math sucks too, can't help you there

Share this post


Link to post

1. P_TouchSpecialThing in p_inter.c
2. Distances are measured as fixed point values. Which means that a distance of 1 is represented as 65536 and so on. If you divide 35 by such a high value you get always 0! Thus no thrust.

Share this post


Link to post
Graf Zahl said:

1. P_TouchSpecialThing in p_inter.c
2. Distances are measured as fixed point values. Which means that a distance of 1 is represented as 65536 and so on. If you divide 35 by such a high value you get always 0! Thus no thrust.


Ok, thanks a lot for that.

//Edit: Would FRACUNIT have anything to do with scaling this value down by any chance?

Share this post


Link to post
ToXiCFLUFF said:

Ok, thanks a lot for that.

//Edit: Would FRACUNIT have anything to do with scaling this value down by any chance?



Yes, this is the value 1 as a fixed value.

I forgot to mention that in your case you cannot use a normal division because that would cause some problems because thrust is also a fixed value so your line should look like this:

thrust=FixedDiv(35*FRACUNIT,distance/10);
to get the desired result.

Share this post


Link to post

Thanks a load Graf. Knowing what the hell FRACUNIT is will greatly benefit my miniscule understanding of some of the maths in the Doom code from here on.

Share this post


Link to post

If you want extra weapons in Legacy you are supposed to be able to use the extra frames from Heretic in Dehacked. I don't know if anyone has made that work yet though.

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  
×