
Falling damage
Falling damage
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 

[color=#FF0000]/callvote kick all_enemies[/color]
-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Falling damage
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.
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
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?
logically, one could conclude that the calculation is already in there but capped at 10. removing the cap should do it, no?
-
- Posts: 2237
- Joined: Sat Mar 12, 2005 10:49 pm
Re: Falling damage
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.
If it is, removing the cap would be so much easier than what I was thinking.
Re: Falling damage
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]
Re: Falling damage
been playing around with this the last days, but I'm too stupid to make it
how can I set up a variable that is both known in bg_pmove AND g_active?

how can I set up a variable that is both known in bg_pmove AND g_active?
[color=#FF0000]/callvote kick all_enemies[/color]
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: Falling damage
Depends. Is this a server-side only mod?
Re: Falling damage
It's supposed to become a standalone some day



[color=#FF0000]/callvote kick all_enemies[/color]
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: Falling damage
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.
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
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);", ...
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]
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: Falling damage
Pmove(&pm) is the function call I meant.
Re: Falling damage
Pmove isn't even called there. It's just switch(event), case EV_FALL_FAR, damage=10, g_damage() 

[color=#FF0000]/callvote kick all_enemies[/color]
-
- Posts: 4022
- Joined: Sat Mar 12, 2005 6:24 pm
Re: Falling damage
I already spelled it out for you. I suggest you apply comprehension.