no message

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@323 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2006-08-12 19:32:36 +00:00
parent 6453b9a6e3
commit 7353cd8189
11 changed files with 206 additions and 75 deletions
+16 -16
View File
@@ -11,7 +11,7 @@ menuitem "Load Map" "showmenu maps"
menuitem "Options" "showmenu options"
menuitem "Editing" "showmenu editing"
menuitem "About/Credits/Help" "showmenu about"
menuitem "quit" "quit"
menuitem "Quit" "quit"
// menubg "textures/blah..."
// menumdl path frame range rotation-speed{0..100} scale{0..100}
@@ -55,29 +55,29 @@ menuitem "RVSF Skins" "showmenu rvsf"
newmenu "cla"
menumdl playermodels/terrorist/01/menu 0 1 50 5
menuitem "Comandante" "skin 0" "chmenumdl cla playermodels/terrorist/01/menu 0 1 50 5"
menuitem "Psycho" "skin 1" "chmenumdl cla playermodels/terrorist/02/menu 0 1 50 5"
menuitem "Bomber" "skin 2" "chmenumdl cla playermodels/terrorist/03/menu 0 1 50 5"
menuitem "Ripper" "skin 3" "chmenumdl cla playermodels/terrorist/04/menu 0 1 50 5"
menumdl playermodels/terrorist/01 0 197 50 5
menuitem "Comandante" "skin 0" "chmenumdl cla playermodels/terrorist/01 0 197 50 5"
menuitem "Psycho" "skin 1" "chmenumdl cla playermodels/terrorist/02 0 197 50 5"
menuitem "Bomber" "skin 2" "chmenumdl cla playermodels/terrorist/03 0 197 50 5"
menuitem "Ripper" "skin 3" "chmenumdl cla playermodels/terrorist/04 0 197 50 5"
newmenu "rvsf"
menumdl playermodels/counterterrorist/01/menu 0 1 50 5
menuitem "Alpha" "skin 0" "chmenumdl rvsf playermodels/counterterrorist/01/menu 0 1 50 5"
menuitem "Tango" "skin 1" "chmenumdl rvsf playermodels/counterterrorist/02/menu 0 1 50 5"
menuitem "Cobra" "skin 2" "chmenumdl rvsf playermodels/counterterrorist/03/menu 0 1 50 5"
menuitem "Viper" "skin 3" "chmenumdl rvsf playermodels/counterterrorist/04/menu 0 1 50 5"
menuitem "Swat" "skin 4" "chmenumdl rvsf playermodels/counterterrorist/05/menu 0 1 50 5"
menuitem "Police" "skin 5" "chmenumdl rvsf playermodels/counterterrorist/06/menu 0 1 50 5"
menumdl playermodels/counterterrorist/01 0 197 50 5
menuitem "Alpha" "skin 0" "chmenumdl rvsf playermodels/counterterrorist/01 0 197 50 5"
menuitem "Tango" "skin 1" "chmenumdl rvsf playermodels/counterterrorist/02 0 197 50 5"
menuitem "Cobra" "skin 2" "chmenumdl rvsf playermodels/counterterrorist/03 0 197 50 5"
menuitem "Viper" "skin 3" "chmenumdl rvsf playermodels/counterterrorist/04 0 197 50 5"
menuitem "Swat" "skin 4" "chmenumdl rvsf playermodels/counterterrorist/05 0 197 50 5"
menuitem "Police" "skin 5" "chmenumdl rvsf playermodels/counterterrorist/06 0 197 50 5"
newmenu team
menumdl playermodels/terrorist/01/menu 0 1 50 5
menuitem "Cuban Liberations Army" "team CLA" "chmenumdl team playermodels/terrorist/01/menu 0 1 50 5"
menuitem "Rabid Viper Special Forces" "team RVSF" "chmenumdl team playermodels/counterterrorist/03/menu 0 1 50 5"
menumdl playermodels/terrorist/01 0 197 50 5
menuitem "Cuban Liberations Army" "team CLA" "chmenumdl team playermodels/terrorist/01 0 197 50 5"
menuitem "Rabid Viper Special Forces" "team RVSF" "chmenumdl team playermodels/counterterrorist/03 0 197 50 5"
newmenu multiplayer
Binary file not shown.
+1
View File
@@ -44,6 +44,7 @@ void CACBot::Spawn()
m_pMyEnt->state = CS_ALIVE;
m_pMyEnt->anger = 0;
m_pMyEnt->pBot = this;
m_pMyEnt->lastanimswitchtime = -1;
// loopi(NUMGUNS) m_pMyEnt->ammo[i] = m_pMyEnt->mag[i] = 0;
/* UNDONE
+1 -1
View File
@@ -324,7 +324,7 @@ void CBotManager::RenderBots()
if (bots[i] && (bots[i] != m_pBotToView))
{
drawblue = (m_sp || isteam(player1->team, bots[i]->team));
renderclient(bots[i], drawblue, "playermodels/counterterrorist", false, 1.6f);
renderclient(bots[i], drawblue, "playermodels/counterterrorist", 1.6f);
}
}
}
+24 -27
View File
@@ -4,12 +4,16 @@
// render players & monsters
// very messy ad-hoc handling of animation frames, should be made more configurable
// idle, run, attack, pain, jump, land, flipoff, salute, taunt, wave, point, crouch idle, crouch walk, crouch attack, crouch pain, crouch death, death, lying dead
// I R A P P P J L F S T W P CI CW CA CP CD D D D LD LD LD
int frame[] = { 0, 40, 46, 54, 58, 62, 66, 69, 72, 84, 95, 112,123,135,154,160,169,173,178,184,190,183,189,197 };
int range[] = { 40, 5, 8, 4, 4, 4, 3, 3, 12, 11, 17, 11, 13, 19, 6, 9, 4, 5, 6, 6, 8, 1, 1, 1 };
// D D D D' D D D D' A A' P P' I I' R, R' E L J J'
int frame[] = { 178, 184, 190, 137, 183, 189, 197, 164, 46, 51, 54, 32, 0, 0, 40, 1, 162, 162, 67, 168 };
int range[] = { 6, 6, 8, 28, 1, 1, 1, 1, 8, 19, 4, 18, 40, 1, 6, 15, 1, 1, 1, 1 };
// D D D D' D D D D' A A' P P' I I' R, R' Q L J J'
/*int frame[] = { 178, 184, 190, 137, 183, 189, 197, 164, 46, 51, 54, 32, 0, 0, 40, 1, 154, 162, 67, 168 };
int range[] = { 6, 6, 8, 28, 1, 1, 1, 1, 8, 19, 4, 18, 40, 1, 6, 15, 6, 1, 1, 1 };*/
void renderclient(dynent *d, bool team, char *mdlname, bool vwep, float scale)
void renderclient(dynent *d, bool team, char *mdlname, float scale)
{
int n = 3;
float speed = 100.0f;
@@ -17,32 +21,25 @@ void renderclient(dynent *d, bool team, char *mdlname, bool vwep, float scale)
int basetime = -((int)d&0xFFF);
if(d->state==CS_DEAD)
{
d->pitch = 0.1f;
//if(vwep) mz = S((int)d->o.x, (int)d->o.y)->floor;
/* d->pitch = 0.1f;
int r;
n = (int)d%3; r = range[n];
n = ((int)d%3);
r = range[n];
basetime = d->lastaction;
int t = lastmillis-d->lastaction;
if(t<0 || t>20000) return;
if(t>(r-1)*100) { n += 4; if(t>(r+10)*100) { t -= (r+10)*100; mz -= t*t/10000000000.0f*t; }; };
if(mz<-1000) return;
//mdl = (((int)d>>6)&1)+1;
//mz = d->o.z-d->eyeheight+0.2f;
//scale = 1.2f;
/*if(vwep)
{
rendermodel(mdlname, 0, 1, 0, 1.5f, d->o.x, mz, d->o.y, -90, 90, team, scale, speed, 0, basetime);
return;
};*/
if(t>(r-1)*100) { n += 3; if(t>(r+10)*100) { t -= (r+10)*100; mz -= t*t/10000000000.0f*t; }; };
n+=18;
if(mz<-1000) return;*/
}
else if(d->state==CS_EDITING) { n = 16; }
else if(d->state==CS_LAGGED) { n = 17; }
else if(d->monsterstate==M_ATTACKING) { n = 8; }
else if(d->monsterstate==M_PAIN) { n = 10; }
else if((!d->move && !d->strafe) || !d->moving) { n = 12; }
else if(!d->onfloor && d->timeinair>100) { n = 18; }
else { n = 14; speed = 1200/d->maxspeed*scale; };
rendermodel(mdlname, frame[n], range[n], 0, 1.5f, d->o.x, mz, d->o.y, d->yaw+90, d->pitch/2, team, scale, speed, 0, basetime);
else if(d->state==CS_EDITING) { n = 8; }
else if(d->state==CS_LAGGED) { n = 9; }
/*else if(d->monsterstate==M_ATTACKING) { n = 8; }
else if(d->monsterstate==M_PAIN) { n = 10; } */
else if((!d->move && !d->strafe) || !d->moving) { n = 0; }
else if(!d->onfloor && d->timeinair>100) { n = 6; }
else { n = 1; speed = 1200/d->maxspeed*scale; };
rendermodel(mdlname, frame[n], range[n], 0, 1.5f, d->o.x, mz, d->o.y, d->yaw+90, d->pitch/2, team, scale, speed, 0, basetime, true, d);
};
extern int democlientnum;
@@ -53,12 +50,12 @@ void renderplayer(dynent *d)
int team = rb_team_int(d->team);
sprintf_sd(mdl)("playermodels/%s/0%i", team==TEAM_CLA ? "terrorist" : "counterterrorist", 1 + max(0, min(d->skin, (team==TEAM_CLA ? 3 : 5))));
renderclient(d, isteam(player1->team, d->team), mdl, false, 1.6f);
renderclient(d, isteam(player1->team, d->team), mdl, 1.6f);
if(d->gunselect>=0 && d->gunselect<NUMGUNS)
{
sprintf_sd(vwep)("weapons/%s/world", hudgunnames[d->gunselect]);
renderclient(d, isteam(player1->team, d->team), vwep, true, 1.6f);
renderclient(d, isteam(player1->team, d->team), vwep, 1.6f);
};
}
+3 -1
View File
@@ -114,6 +114,7 @@ dynent *newdynent() // create a new blank player or monster
d->bIsBot = false;
d->pBot = NULL;
d->weaponchanging = false;
d->lastanimswitchtime = -1;
spawnstate(d);
return d;
};
@@ -216,8 +217,9 @@ void checkakimbo()
{
player1->akimbo = false;
player1->akimbomillis = 0;
playsoundc(S_PUPOUT);
player1->mag[GUN_PISTOL] = min(magsize(GUN_PISTOL), player1->mag[GUN_PISTOL]);
if(player1->gunselect==GUN_PISTOL) weaponswitch(GUN_PISTOL);
playsoundc(S_PUPOUT);
}
};
+19
View File
@@ -130,6 +130,23 @@ public:
struct itemstat { int add, start, max, sound; };
// End add
struct md2state
{
int anim, frame, range, basetime;
float speed;
//md2state() : anim(0), frame(0), range(0), basetime(0), speed(100.0f) { };
md2state()
{
anim = frame = range = basetime = 0;
speed = 100.0f;
}
bool operator==(const md2state &o) const { return frame==o.frame && range==o.range && basetime==o.basetime && speed==o.speed; };
bool operator!=(const md2state &o) const { return frame!=o.frame || range!=o.range || basetime!=o.basetime || speed!=o.speed; };
};
struct md3state
{
int anim;
@@ -211,6 +228,8 @@ struct dynent // players & monsters
int nextprimary; // primary after respawning
int skin, nextskin; // skin after respawning
md3state animstate[3];
int lastanimswitchtime;
md2state current, prev;
bool onladder;
int gravity;
+14 -4
View File
@@ -105,11 +105,21 @@ void rendermenumdl()
glRotatef(player1->yaw+90+180, 0, -1, 0);
glRotatef(player1->pitch, 0, 0, 1);
if(strstr(m.mdl, "playermodel")==NULL) glTranslatef(2.0f, 1.7f, 0.0f);
else glTranslatef(2.0f, 1.0f, 1.5f);
float z=0.0f;
if(!strncmp(m.mdl, "playermodels", strlen("playermodels")))
{
glTranslatef(2.0f, 1.0f, 1.5f);
z = -1.0f;
}
else
{
glTranslatef(2.0f, 1.7f, 0.0f);
}
if(m.rotspeed) glRotatef(lastmillis/5.0f/100.0f*m.rotspeed, 0, 1, 0);
rendermodel(m.mdl, m.frame, m.range, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, false, (float)(m.scale ? m.scale/25.0f : 1), 100, 0, 0, false);
rendermodel(m.mdl, m.frame, m.range, 0.0f, 0.0f, 0.0f, z, 0, 0, 0, false, (float)(m.scale ? m.scale/25.0f : 1), 100, 0, 0, false);
glPopMatrix();
}
+2 -2
View File
@@ -101,7 +101,7 @@ extern void respawn();
// clientextras
extern void renderclients();
extern void renderclient(dynent *d, bool team, char *mdlname, bool hellpig, float scale);
extern void renderclient(dynent *d, bool team, char *mdlname, float scale);
void showscores(bool on);
extern void renderscores();
@@ -210,7 +210,7 @@ extern void cleansound();
extern void botplaysound(int n, dynent *b); // Added by Rick
// rendermd2
extern void rendermodel(char *mdl, int frame, int range, int tex, float rad, float x, float y, float z, float yaw, float pitch, bool teammate, float scale, float speed, int snap = 0, int basetime = 0, bool oculling=true);
extern void rendermodel(char *mdl, int frame, int range, int tex, float rad, float x, float y, float z, float yaw, float pitch, bool teammate, float scale, float speed, int snap = 0, int basetime = 0, bool oculling=true, dynent *d=NULL);
extern mapmodelinfo &getmminfo(int i);
// rendermd3
+41 -6
View File
@@ -51,19 +51,54 @@ void blendbox(int x1, int y1, int x2, int y2, bool border, int tex)
glBindTexture(GL_TEXTURE_2D, tex);
glEnable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
float texw = 512.0f;
float texh = texw;
int cols = (x2-x1)/texw+1;
int rows = (y2-y1)/texh+1;
loopj(rows)
{
float ytexcut = 0.0f;
float yboxcut = 0.0f;
if((j+1)*texh>y2-y1) // cut last row to match the box height*/
{
yboxcut = (((j+1)*texh)-(y2-y1));
ytexcut = (((j+1)*texh)-(y2-y1))/texh;
}
loopi(cols)
{
float xtexcut = 0.0f;
float xboxcut = 0.0f;
if((i+1)*texw>x2-x1)
{
xboxcut = (((i+1)*texw)-(x2-x1));
xtexcut = (((i+1)*texw)-(x2-x1))/texw;
}
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2i(x1+texw*i, y1+texh*j);
glTexCoord2f(1-xtexcut, 0); glVertex2i(x1+texw*(i+1)-xboxcut, y1+texh*j);
glTexCoord2f(1-xtexcut, 1-ytexcut); glVertex2i(x1+texw*(i+1)-xboxcut, y1+texh*(j+1)-yboxcut);
glTexCoord2f(0, 1-ytexcut); glVertex2i(x1+texw*i, y1+texh*(j+1)-yboxcut);
glEnd();
}
}
}
else
{
if(border) glColor3d(0.7, 0.7, 0.7); //glColor3d(0.5, 0.3, 0.4);
else glColor3d(1.0, 1.0, 1.0);
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2i(x1, y1);
glTexCoord2f(1, 0); glVertex2i(x2, y1);
glTexCoord2f(1, 1); glVertex2i(x2, y2);
glTexCoord2f(0, 1); glVertex2i(x1, y2);
glEnd();
};
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2i(x1, y1);
glTexCoord2f(1, 0); glVertex2i(x2, y1);
glTexCoord2f(1, 1); glVertex2i(x2, y2);
glTexCoord2f(0, 1); glVertex2i(x1, y2);
glEnd();
glDisable(GL_BLEND);
if(tex>=0) glDisable(GL_TEXTURE_2D);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+85 -18
View File
@@ -2,6 +2,38 @@
#include "cube.h"
VARP(animationinterpolationtime, 0, 150, 1000);
struct md2_anpos
{
int fr1, fr2;
float frac1, frac2;
void setframes(md2state &a)
{
int time = lastmillis-a.basetime;
fr1 = (int)(time/a.speed);
frac1 = (time-fr1*a.speed)/a.speed;
frac2 = 1-frac1;
//if(a.anim&ANIM_LOOP) // FIXME
{
fr1 = fr1%a.range+a.frame;
fr2 = fr1+1;
if(fr2>=a.frame+a.range) fr2 = a.frame;
}
/* else
{
fr1 = min(fr1, a.range-1)+a.frame;
fr2 = min(fr1+1, a.frame+a.range-1);
};
if(a.anim&ANIM_REVERSE)
{
fr1 = (a.frame+a.range-1)-(fr1-a.frame);
fr2 = (a.frame+a.range-1)-(fr2-a.frame);
};*/
};
};
struct md2_header
{
int magic;
@@ -46,7 +78,7 @@ struct md2
bool loaded;
bool load(char* filename);
void render(vec &light, int numFrame, int range, float x, float y, float z, float yaw, float pitch, float scale, float speed, int snap, int basetime);
void render(vec &light, int numFrame, int range, float x, float y, float z, float yaw, float pitch, float scale, float speed, int snap, int basetime, dynent *d=NULL);
void scale(int frame, float scale, int sn);
md2() : numGlCommands(0), frameSize(0), numFrames(0), displaylist(0), loaded(false) {};
@@ -123,9 +155,30 @@ void md2::scale(int frame, float scale, int sn)
};
};
void md2::render(vec &light, int frame, int range, float x, float y, float z, float yaw, float pitch, float sc, float speed, int snap, int basetime)
void md2::render(vec &light, int frame, int range, float x, float y, float z, float yaw, float pitch, float sc, float speed, int snap, int basetime, dynent *d)
{
loopi(range) if(!mverts[frame+i]) scale(frame+i, sc, snap);
if(range==0 || frame+range-1>numFrames)
{
return;
}
md2state ai;
ai.frame = frame;
ai.basetime = basetime;
ai.range = range;
ai.speed = speed;
loopi(ai.range) if(!mverts[ai.frame+i]) scale(ai.frame+i, sc, snap);
if(d)
{
if(d->lastanimswitchtime==-1) { d->current = ai; d->lastanimswitchtime = lastmillis-animationinterpolationtime*2; }
else if(d->current != ai)
{
if(lastmillis-d->lastanimswitchtime>animationinterpolationtime/2) d->prev = d->current;
d->current = ai;
d->lastanimswitchtime = lastmillis;
};
};
glPushMatrix ();
glTranslatef(x, y, z);
@@ -134,29 +187,36 @@ void md2::render(vec &light, int frame, int range, float x, float y, float z, fl
glColor3fv((float *)&light);
if(displaylist && frame==0 && range==1)
if(displaylist && ai.frame==0 && ai.range==1)
{
glCallList(displaylist);
xtraverts += displaylistverts;
}
else
{
if(frame==0 && range==1)
if(ai.frame==0 && ai.range==1)
{
static int displaylistn = 10;
glNewList(displaylist = displaylistn++, GL_COMPILE);
displaylistverts = xtraverts;
};
int time = lastmillis-basetime;
int fr1 = (int)(time/speed);
float frac1 = (time-fr1*speed)/speed;
float frac2 = 1-frac1;
fr1 = fr1%range+frame;
int fr2 = fr1+1;
if(fr2>=frame+range) fr2 = frame;
vec *verts1 = mverts[fr1];
vec *verts2 = mverts[fr2];
md2_anpos prev, current;
current.setframes(d ? d->current : ai);
#ifdef _DEBUG
prev.setframes(ai);
#endif
vec *verts1 = mverts[current.fr1], *verts2 = mverts[current.fr2], *verts1p, *verts2p;
float aifrac1, aifrac2;
bool doai = d && lastmillis-d->lastanimswitchtime<animationinterpolationtime;
if(doai)
{
prev.setframes(d->prev);
verts1p = mverts[prev.fr1];
verts2p = mverts[prev.fr2];
aifrac1 = (lastmillis-d->lastanimswitchtime)/(float)animationinterpolationtime;
aifrac2 = 1-aifrac1;
};
for(int *command = glCommands; (*command)!=0;)
{
@@ -172,8 +232,15 @@ void md2::render(vec &light, int frame, int range, float x, float y, float z, fl
int vn = *command++;
vec &v1 = verts1[vn];
vec &v2 = verts2[vn];
#define ip(c) v1.c*frac2+v2.c*frac1
glVertex3f(ip(x), ip(z), ip(y));
#define ip(v1, v2, c) (v1.c*current.frac2+v2.c*current.frac1)
#define ipv(v1, v2, c) (v1 ## p.c*prev.frac2+v2 ## p.c*prev.frac1)
#define ipa(v1, v2, c) (ip(v1, v2, c)*aifrac1+ipv(v1, v2, c)*aifrac2)
if(doai)
{
vec &v1p = verts1p[vn], &v2p = verts2p[vn];
glVertex3f(ipa(v1, v2, x), ipa(v1, v2, z), ipa(v1, v2, y));
}
else glVertex3f(ip(v1, v2, x), ip(v1, v2, z), ip(v1, v2, y));
};
xtraverts += numVertex;
@@ -245,7 +312,7 @@ mapmodelinfo &getmminfo(int i) { return i<mapmodels.length() ? mapmodels[i]->mmi
COMMAND(mapmodel, ARG_5STR);
COMMAND(mapmodelreset, ARG_NONE);
void rendermodel(char *mdl, int frame, int range, int tex, float rad, float x, float y, float z, float yaw, float pitch, bool teammate, float scale, float speed, int snap, int basetime, bool oculling)
void rendermodel(char *mdl, int frame, int range, int tex, float rad, float x, float y, float z, float yaw, float pitch, bool teammate, float scale, float speed, int snap, int basetime, bool oculling, dynent *d)
{
md2 *m = loadmodel(mdl);
@@ -279,5 +346,5 @@ void rendermodel(char *mdl, int frame, int range, int tex, float rad, float x, f
};
*/
m->render(light, frame, range, x, y, z, yaw, pitch, scale, speed, snap, basetime);
m->render(light, frame, range, x, y, z, yaw, pitch, scale, speed, snap, basetime, d);
};