]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
DP_SV_BOUNCEFACTOR
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 13 Jun 2009 18:36:58 +0000 (18:36 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 13 Jun 2009 18:36:58 +0000 (18:36 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9019 d7cf8633-e32d-0410-b094-e92efae38249

progsvm.h
prvm_edict.c
sv_phys.c
svvm_cmds.c

index c66763862807f9ab5be6d7b9cc9dda9b3c0b9cd7..b14c99fa8f873b07911453dd0946e1b5628afecb 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -226,6 +226,8 @@ typedef struct prvm_prog_fieldoffsets_s
        int viewmodelforclient; // ssqc
        int viewzoom; // ssqc
        int yaw_speed; // ssqc / csqc
+       int bouncefactor; // ssqc
+       int bouncestop; // ssqc
 }
 prvm_prog_fieldoffsets_t;
 
index c7ecc92e1dc32dbf0972124f293a9089a102597e..e0f3773275c14789a983cb7dbdab01e7e6a06aa6 100644 (file)
@@ -1529,6 +1529,8 @@ void PRVM_FindOffsets(void)
        prog->fieldoffsets.viewmodelforclient             = PRVM_ED_FindFieldOffset("viewmodelforclient");
        prog->fieldoffsets.viewzoom                       = PRVM_ED_FindFieldOffset("viewzoom");
        prog->fieldoffsets.yaw_speed                      = PRVM_ED_FindFieldOffset("yaw_speed");
+       prog->fieldoffsets.bouncefactor                   = PRVM_ED_FindFieldOffset("bouncefactor");
+       prog->fieldoffsets.bouncestop                     = PRVM_ED_FindFieldOffset("bouncestop");
        prog->funcoffsets.CSQC_ConsoleCommand             = PRVM_ED_FindFunctionOffset("CSQC_ConsoleCommand");
        prog->funcoffsets.CSQC_Ent_Remove                 = PRVM_ED_FindFunctionOffset("CSQC_Ent_Remove");
        prog->funcoffsets.CSQC_Ent_Spawn                  = PRVM_ED_FindFunctionOffset("CSQC_Ent_Spawn");
index 434d08346b05f8a3b7312652782c3ee1a1dea0d5..bc4d42f1f598c0e1e5d0748a38e3755f50655eee 100644 (file)
--- a/sv_phys.c
+++ b/sv_phys.c
@@ -1985,7 +1985,18 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                {
                        float d, ent_gravity;
                        prvm_eval_t *val;
-                       ClipVelocity (ent->fields.server->velocity, trace.plane.normal, ent->fields.server->velocity, 1.5);
+                       float bouncefactor = 0.5f;
+                       float bouncestop = 60.0f / 800.0f;
+
+                       val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.bouncefactor);
+                       if (val!=0 && val->_float)
+                               bouncefactor = val->_float;
+
+                       val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.bouncestop);
+                       if (val!=0 && val->_float)
+                               bouncestop = val->_float;
+
+                       ClipVelocity (ent->fields.server->velocity, trace.plane.normal, ent->fields.server->velocity, 1 + bouncefactor);
                        // LordHavoc: fixed grenades not bouncing when fired down a slope
                        val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.gravity);
                        if (val!=0 && val->_float)
@@ -1995,7 +2006,7 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                        if (sv_gameplayfix_grenadebouncedownslopes.integer)
                        {
                                d = DotProduct(trace.plane.normal, ent->fields.server->velocity);
-                               if (trace.plane.normal[2] > 0.7 && fabs(d) < sv_gravity.value * (60.0 / 800.0) * ent_gravity)
+                               if (trace.plane.normal[2] > 0.7 && fabs(d) < sv_gravity.value * bouncestop * ent_gravity)
                                {
                                        ent->fields.server->flags = (int)ent->fields.server->flags | FL_ONGROUND;
                                        ent->fields.server->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
@@ -2007,7 +2018,7 @@ void SV_Physics_Toss (prvm_edict_t *ent)
                        }
                        else
                        {
-                               if (trace.plane.normal[2] > 0.7 && ent->fields.server->velocity[2] < sv_gravity.value * (60.0 / 800.0) * ent_gravity)
+                               if (trace.plane.normal[2] > 0.7 && ent->fields.server->velocity[2] < sv_gravity.value * bouncestop * ent_gravity)
                                {
                                        ent->fields.server->flags = (int)ent->fields.server->flags | FL_ONGROUND;
                                        ent->fields.server->groundentity = PRVM_EDICT_TO_PROG(trace.ent);
index 05979415c3c8d7d076dc10ff2dd3c1f76f88e11b..8bd628f5ea7e60caf2fc2fc48212a4cedb4d09f0 100644 (file)
@@ -121,6 +121,7 @@ char *vm_sv_extensions =
 "DP_SOLIDCORPSE "
 "DP_SPRITE32 "
 "DP_SV_BOTCLIENT "
+"DP_SV_BOUNCEFACTOR "
 "DP_SV_CLIENTCOLORS "
 "DP_SV_CLIENTNAME "
 "DP_SV_CMD "