Falling damage

Locked
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Falling damage

Post 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:
[color=#FF0000]/callvote kick all_enemies[/color]
Silicone_Milk
Posts: 2237
Joined: Sat Mar 12, 2005 10:49 pm

Re: Falling damage

Post 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.
User avatar
MKJ
Posts: 32581
Joined: Fri Nov 24, 2000 8:00 am

Re: Falling damage

Post 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?
Silicone_Milk
Posts: 2237
Joined: Sat Mar 12, 2005 10:49 pm

Re: Falling damage

Post 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.
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Re: Falling damage

Post 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
[color=#FF0000]/callvote kick all_enemies[/color]
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Re: Falling damage

Post 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?
[color=#FF0000]/callvote kick all_enemies[/color]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Falling damage

Post by ^misantropia^ »

Depends. Is this a server-side only mod?
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Re: Falling damage

Post by Rawing »

It's supposed to become a standalone some day :D :!:
[color=#FF0000]/callvote kick all_enemies[/color]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Falling damage

Post 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.
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Re: Falling damage

Post 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);", ...
[color=#FF0000]/callvote kick all_enemies[/color]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Falling damage

Post by ^misantropia^ »

Pmove(&pm) is the function call I meant.
Rawing
Posts: 107
Joined: Tue Oct 23, 2007 1:40 pm

Re: Falling damage

Post by Rawing »

Pmove isn't even called there. It's just switch(event), case EV_FALL_FAR, damage=10, g_damage() :question:
[color=#FF0000]/callvote kick all_enemies[/color]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Falling damage

Post by ^misantropia^ »

I already spelled it out for you. I suggest you apply comprehension.
Locked