toxicfluff Posted August 1, 2003 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. 0 Share this post Link to post
exl Posted August 1, 2003 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 0 Share this post Link to post
Graf Zahl Posted August 1, 2003 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. 0 Share this post Link to post
toxicfluff Posted August 1, 2003 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? 0 Share this post Link to post
Graf Zahl Posted August 1, 2003 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. 0 Share this post Link to post
toxicfluff Posted August 2, 2003 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. 0 Share this post Link to post
Aliotroph? Posted August 2, 2003 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. 0 Share this post Link to post