Page 1 of 1

Falling damage

Posted: Sat Nov 22, 2008 10:53 am
by Rawing
I've looked a bit into EV_FALL_***, which makes you take damage when falling down and hitting the ground. What I'd like to do is that you lose more hp the longer the fall is. I have played around with it but I can't make it work :owned:

Re: Falling damage

Posted: Sun Nov 23, 2008 7:44 am
by Silicone_Milk
Cant give you exact directions since I dont have the source code at hand right now but the way I would do something like this is to take a peek at the physics for a bit.

I think last time I was messing with motion it was in the pmove code. That code checks to see if you're in water, on a surface, etc... iirc. Put in a small chunk of code that sets a shared variable (can be accessed by the EV_FALL_**** code and pmove) to be the value of say, "(distance between last solid surface and current position) all divided by 3" so this shared variable will be a third of the distance fallen.

In EV_FALL just replace the amount of damage being applied with the shared variable.

Probably not the most elegant solution but I just pulled it out of my ass. Try it. See if it works the way you want it to. Sorry I couldnt be more specific about what I'm thinking.

Re: Falling damage

Posted: Wed Nov 26, 2008 3:05 pm
by MKJ
isnt that already in there tho? that is, you dont always suffer 10hp damage; smaller drops take away smaller amount of health.

logically, one could conclude that the calculation is already in there but capped at 10. removing the cap should do it, no?

Re: Falling damage

Posted: Wed Nov 26, 2008 6:46 pm
by Silicone_Milk
is it already in there? I thought it was a constant damage.

If it is, removing the cap would be so much easier than what I was thinking.

Re: Falling damage

Posted: Fri Nov 28, 2008 2:29 pm
by Rawing
there's one function deciding whether to use EV_FALL_MEDIUM or EV_FALL_FAR by checking how great the distance is and a second one that sets the damage to 5 if EV_FALL_MEDIUM or to 10 if EV_FALL_FAR

Re: Falling damage

Posted: Wed Dec 03, 2008 11:47 am
by Rawing
been playing around with this the last days, but I'm too stupid to make it :tard:
how can I set up a variable that is both known in bg_pmove AND g_active?

Re: Falling damage

Posted: Wed Dec 03, 2008 12:46 pm
by ^misantropia^
Depends. Is this a server-side only mod?

Re: Falling damage

Posted: Wed Dec 03, 2008 2:06 pm
by Rawing
It's supposed to become a standalone some day :D :!:

Re: Falling damage

Posted: Wed Dec 03, 2008 2:54 pm
by ^misantropia^
So both client and server side.

1. Add a field to pmove_t
2. Search for Pmove() in game/g_active.c and set your field before said function is called
3. Process it in game/bg_pmove.c

Since bg_pmove.c is also used on the client (in cgame/cg_predict.c), you need to either supply it client-side or decide on some magic value - like zero - that tells bg_pmove.c to not do anything.

Re: Falling damage

Posted: Wed Dec 03, 2008 3:29 pm
by Rawing
so, bg_public.h: int fallingdamage;
g_active: there's no pmove() in there, is it?? all I can find is like "pmove_t *pm", "ent->client->ps.pmove_framecount", "Pmove (&pm);", ...

Re: Falling damage

Posted: Thu Dec 04, 2008 6:32 am
by ^misantropia^
Pmove(&pm) is the function call I meant.

Re: Falling damage

Posted: Thu Dec 04, 2008 5:23 pm
by Rawing
Pmove isn't even called there. It's just switch(event), case EV_FALL_FAR, damage=10, g_damage() :question:

Re: Falling damage

Posted: Fri Dec 05, 2008 9:48 am
by ^misantropia^
I already spelled it out for you. I suggest you apply comprehension.