[Quake2world-dev] r487 - in quake2world/trunk/src: . game/default
jdolan at jdolan.dyndns.org
jdolan at jdolan.dyndns.org
Fri May 22 03:45:57 UTC 2009
Author: jdolan
Date: 2009-05-22 03:45:56 +0000 (Fri, 22 May 2009)
New Revision: 487
Modified:
quake2world/trunk/src/cl_entity.c
quake2world/trunk/src/cl_view.c
quake2world/trunk/src/game/default/g_misc.c
quake2world/trunk/src/game/default/p_client.c
quake2world/trunk/src/pmove.c
quake2world/trunk/src/r_mesh.c
quake2world/trunk/src/shared.h
Log:
Consolidate all player bbox initialization and introduce scalable player.
Modified: quake2world/trunk/src/cl_entity.c
===================================================================
--- quake2world/trunk/src/cl_entity.c 2009-05-19 19:19:42 UTC (rev 486)
+++ quake2world/trunk/src/cl_entity.c 2009-05-22 03:45:56 UTC (rev 487)
@@ -624,6 +624,7 @@
ent.skin = cl.baseclientinfo.skin;
ent.model = cl.baseclientinfo.model;
}
+ VectorSet(ent.scale, PM_SCALE, PM_SCALE, PM_SCALE);
} else {
ent.skinnum = state->skinnum;
ent.skin = NULL;
@@ -762,8 +763,8 @@
// project back and to the right
AngleVectors(ent.angles, fwd, rgt, NULL);
- VectorMA(ent.origin, -8.0, fwd, ent.origin);
- VectorMA(ent.origin, 3.0, rgt, ent.origin);
+ VectorMA(ent.origin, -8.0 * PM_SCALE, fwd, ent.origin);
+ VectorMA(ent.origin, 3.0 * PM_SCALE, rgt, ent.origin);
f = sin(cl.time * 0.004) * 0.5;
ent.origin[0] += f;
@@ -776,6 +777,7 @@
ent.model = cl.model_draw[state->modelindex3];
VectorSet(ent.scale, 0.6, 0.6, 0.6);
+ VectorScale(ent.scale, PM_SCALE, ent.scale);
R_AddEntity(&ent);
}
Modified: quake2world/trunk/src/cl_view.c
===================================================================
--- quake2world/trunk/src/cl_view.c 2009-05-19 19:19:42 UTC (rev 486)
+++ quake2world/trunk/src/cl_view.c 2009-05-22 03:45:56 UTC (rev 487)
@@ -118,7 +118,15 @@
*/
static void Cl_UpdateDucking(void){
static int ducktime, standtime;
+ vec3_t mins, maxs;
+ float height, viewheight;
+ VectorScale(PM_MINS, PM_SCALE, mins);
+ VectorScale(PM_MAXS, PM_SCALE, maxs);
+
+ height = maxs[2] - mins[2];
+ viewheight = mins[2] + (height * 0.75);
+
if(cl.frame.playerstate.pmove.pm_flags & PMF_DUCKED){
if(standtime > ducktime) // go back down
@@ -127,7 +135,7 @@
ducktime = cls.realtime + 200;
if(ducktime > cls.realtime)
- r_view.origin[2] += (ducktime - cls.realtime) * 22 / 200;
+ r_view.origin[2] += (ducktime - cls.realtime) * viewheight / 200;
return;
}
@@ -136,11 +144,11 @@
standtime = cls.realtime;
if(cls.realtime - standtime <= 200){ // rise
- r_view.origin[2] += (cls.realtime - standtime) * 22 / 200;
+ r_view.origin[2] += (cls.realtime - standtime) * viewheight / 200;
}
else { // cancel ducking, add normal height
ducktime = standtime = 0;
- r_view.origin[2] += 22;
+ r_view.origin[2] += viewheight;
}
}
Modified: quake2world/trunk/src/game/default/g_misc.c
===================================================================
--- quake2world/trunk/src/game/default/g_misc.c 2009-05-19 19:19:42 UTC (rev 486)
+++ quake2world/trunk/src/game/default/g_misc.c 2009-05-22 03:45:56 UTC (rev 487)
@@ -324,5 +324,7 @@
/*QUAKED misc_teleporter_dest(1 0 0)(-32 -32 -24)(32 32 -16)
Point teleporters at these.
*/
-void G_misc_teleporter_dest(edict_t *ent){}
+void G_misc_teleporter_dest(edict_t *ent){
+ ent->s.origin[2] += (PLAYER_MINS[2] - PLAYER_MINS[2] * PM_SCALE);
+}
Modified: quake2world/trunk/src/game/default/p_client.c
===================================================================
--- quake2world/trunk/src/game/default/p_client.c 2009-05-19 19:19:42 UTC (rev 486)
+++ quake2world/trunk/src/game/default/p_client.c 2009-05-22 03:45:56 UTC (rev 487)
@@ -26,29 +26,39 @@
/*QUAKED info_player_start(1 0 0)(-16 -16 -24)(16 16 32)
The normal starting point for a level.
*/
-void G_info_player_start(edict_t *self){}
+void G_info_player_start(edict_t *self){
+ self->s.origin[2] += (PM_MINS[2] - PM_MINS[2] * PM_SCALE);
+}
/*QUAKED info_player_intermission(1 0 1)(-16 -16 -24)(16 16 32)
Level intermission point will be at one of these
Use 'angles' instead of 'angle', so you can set pitch or roll as well as yaw.
'pitch yaw roll'
*/
-void G_info_player_intermission(edict_t *self){}
+void G_info_player_intermission(edict_t *self){
+ self->s.origin[2] += (PM_MINS[2] - PM_MINS[2] * PM_SCALE);
+}
/*QUAKED info_player_deathmatch(1 0 1)(-16 -16 -24)(16 16 32)
potential spawning position for deathmatch games
*/
-void G_info_player_deathmatch(edict_t *self){}
+void G_info_player_deathmatch(edict_t *self){
+ self->s.origin[2] += (PM_MINS[2] - PM_MINS[2] * PM_SCALE);
+}
/*QUAKED info_player_team1(1 0 1)(-16 -16 -24)(16 16 32)
potential spawning position for team games
*/
-void G_info_player_team1(edict_t *self){}
+void G_info_player_team1(edict_t *self){
+ self->s.origin[2] += (PM_MINS[2] - PM_MINS[2] * PM_SCALE);
+}
/*QUAKED info_player_team2(1 0 1)(-16 -16 -24)(16 16 32)
potential spawning position for team games
*/
-void G_info_player_team2(edict_t *self){}
+void G_info_player_team2(edict_t *self){
+ self->s.origin[2] += (PM_MINS[2] - PM_MINS[2] * PM_SCALE);
+}
/*
@@ -685,9 +695,8 @@
* The grunt work of putting the client into the server on [re]spawn.
*/
static void P_PutClientInServer(edict_t *ent){
- vec3_t mins = { -16, -16, -24};
- vec3_t maxs = {16, 16, 32};
vec3_t spawn_origin, spawn_angles, old_angles;
+ float height;
gclient_t *client;
client_locals_t locals;
int i;
@@ -709,10 +718,14 @@
client->locals = locals;
// clear entity values
+ VectorScale(PM_MINS, PM_SCALE, ent->mins);
+ VectorScale(PM_MAXS, PM_SCALE, ent->maxs);
+ height = ent->maxs[2] - ent->mins[2];
+
ent->groundentity = NULL;
ent->takedamage = true;
ent->movetype = MOVETYPE_WALK;
- ent->viewheight = 22;
+ ent->viewheight = ent->mins[2] + (height * 0.75);
ent->inuse = true;
ent->classname = "player";
ent->mass = 200.0;
@@ -733,8 +746,6 @@
ent->health = ent->client->locals.health;
ent->max_health = ent->client->locals.max_health;
- VectorCopy(mins, ent->mins);
- VectorCopy(maxs, ent->maxs);
VectorClear(ent->velocity);
ent->velocity[2] = 150.0;
Modified: quake2world/trunk/src/pmove.c
===================================================================
--- quake2world/trunk/src/pmove.c 2009-05-19 19:19:42 UTC (rev 486)
+++ quake2world/trunk/src/pmove.c 2009-05-22 03:45:56 UTC (rev 487)
@@ -10,7 +10,7 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
@@ -71,10 +71,12 @@
#define PM_SPEED_WATER 200.0
#define PM_SPEED_WATER_DOWN 20.0
-
#define CLIP_BACKOFF 1.001
#define STOP_EPSILON 0.1
+vec3_t PM_MINS = { -16.0, -16.0, -24.0};
+vec3_t PM_MAXS = { 16.0, 16.0, 42.0};
+
/*
* Pm_ClipVelocity
*
@@ -173,7 +175,7 @@
// update the origin
VectorCopy(trace.endpos, pml.origin);
-
+
if(trace.fraction == 1.0) // moved the entire distance
break;
@@ -525,7 +527,7 @@
// clamp to server defined max speed
maxspeed = (pm->s.pm_flags & PMF_DUCKED) ? PM_SPEED_DUCKED : PM_SPEED_RUN;
-
+
// account for speed modulus
maxspeed = (pm->cmd.buttons & BUTTON_WALK ? maxspeed * 0.66 : maxspeed);
@@ -790,35 +792,30 @@
* Sets mins, maxs, and pm->viewheight
*/
static void Pm_CheckDuck(void){
+ float height;
trace_t trace;
- pm->mins[0] = -16.0;
- pm->mins[1] = -16.0;
+ VectorScale(PM_MINS, PM_SCALE, pm->mins);
+ VectorScale(PM_MAXS, PM_SCALE, pm->maxs);
- pm->maxs[0] = 16.0;
- pm->maxs[1] = 16.0;
+ height = pm->maxs[2] - pm->mins[2];
+ pm->viewheight = pm->mins[2] + (height * 0.75);
- pm->mins[2] = -24.0;
-
if(pm->s.pm_type == PM_DEAD){
pm->s.pm_flags |= PMF_DUCKED;
} else if(pm->cmd.upmove < 0 && (pm->s.pm_flags & PMF_ON_GROUND)){ // duck
pm->s.pm_flags |= PMF_DUCKED;
} else { // stand up if possible
if(pm->s.pm_flags & PMF_DUCKED){ // try to stand up
- pm->maxs[2] = 32.0;
trace = pm->trace(pml.origin, pm->mins, pm->maxs, pml.origin);
if(!trace.allsolid)
pm->s.pm_flags &= ~PMF_DUCKED;
}
}
- if(pm->s.pm_flags & PMF_DUCKED){
- pm->maxs[2] = 4.0;
- pm->viewheight = -2.0;
- } else {
- pm->maxs[2] = 32.0;
- pm->viewheight = 22.0;
+ if(pm->s.pm_flags & PMF_DUCKED){ // ducked, reduce height
+ pm->viewheight = pm->mins[2] + (height * 0.5);
+ pm->maxs[2] = pm->maxs[2] + pm->mins[2] / 2.0;
}
}
@@ -843,7 +840,7 @@
/*
* Pm_SnapPosition
- *
+ *
* On exit, the origin will have a value that is pre-quantized to the 0.125
* precision of the network channel and in a valid position.
*/
@@ -982,7 +979,7 @@
// reset stair climbing flag on every move
pm->s.pm_flags &= ~PMF_ON_STAIRS;
-
+
// decrement the movement timer
if(pm->s.pm_time){
int msec;
Modified: quake2world/trunk/src/r_mesh.c
===================================================================
--- quake2world/trunk/src/r_mesh.c 2009-05-19 19:19:42 UTC (rev 486)
+++ quake2world/trunk/src/r_mesh.c 2009-05-22 03:45:56 UTC (rev 487)
@@ -69,6 +69,9 @@
sh->scale = 5.0 / (0.5 * h + 1);
sh->scale = sh->scale > 1.0 ? 1.0 : sh->scale;
+
+ if(e->skin) // scale up player shadows
+ sh->scale *= 2.0;
}
Modified: quake2world/trunk/src/shared.h
===================================================================
--- quake2world/trunk/src/shared.h 2009-05-19 19:19:42 UTC (rev 486)
+++ quake2world/trunk/src/shared.h 2009-05-22 03:45:56 UTC (rev 487)
@@ -378,6 +378,12 @@
struct edict_s *ent; // not set by CM_*() functions
} trace_t;
+// player bbox and viewheight scaling
+extern vec3_t PM_MINS;
+extern vec3_t PM_MAXS;
+
+#define PM_SCALE 1.2 // global player scale factor
+
#define PM_STAIR_HEIGHT 16.0 // maximum stair height player can walk up
#define PM_STAIR_NORMAL 0.7 // can't step up onto very steep slopes
More information about the Quake2World-dev
mailing list