*** empty log message ***

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@231 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2006-03-20 17:32:18 +00:00
parent 09a3888976
commit 640abb26ac
10 changed files with 49 additions and 282 deletions
+2
View File
@@ -117,6 +117,8 @@ void spawnstate(dynent *d) // reset player state not persistent acc
d->ammo[GUN_SG] = 5;
};
*/
d->akimbo = false;
};
dynent *newdynent() // create a new blank player or monster
+4 -1
View File
@@ -167,9 +167,11 @@ struct dynent // players & monsters
int nextprimary;
md3state animstate[3];
bool onladder, lastonladder;
bool onladder;
int gravity;
bool isphysent; // hack
int thrownademillis;
bool akimbo;
};
enum { PHYSENT_NONE = 0, NADE_ACTIVATED, NADE_THROWED };
@@ -201,6 +203,7 @@ enum
SV_PING, SV_PONG, SV_CLIENTPING, SV_GAMEMODE,
SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE,
SV_SENDMAP, SV_RECVMAP, SV_SERVMSG, SV_ITEMLIST, SV_WEAPCHANGE,
SV_MODELSKIN,
SV_EXT,
};
+3 -225
View File
@@ -1,444 +1,222 @@
// menus.cpp: ingame menu system (also used for scores and serverlist)
#include "cube.h"
#define FIRSTMENU 120
struct mitem { char *text, *action, *hoveraction; };
struct gmenu
{
char *name;
vector<mitem> items;
int mwidth;
int menusel;
int tex; // (optional) bg tex
char *mdl; // (optional) md2 mdl
int frame, range, rotspeed, scale;
};
vector<gmenu> menus;
int vmenu = -1;
ivector menustack;
void menuset(int menu)
{
if((vmenu = menu)>=1) resetmovement(player1);
if(vmenu==1) menus[1].menusel = 0;
};
void showmenu(char *name)
{
loopv(menus) if(i>1 && strcmp(menus[i].name, name)==0)
{
menuset(i);
return;
};
};
int menucompare(mitem *a, mitem *b)
{
int x = atoi(a->text);
int y = atoi(b->text);
if(x>y) return -1;
if(x<y) return 1;
return 0;
};
void sortmenu(int start, int num)
{
qsort(&menus[0].items[start], num, sizeof(mitem), (int (__cdecl *)(const void *,const void *))menucompare);
};
void refreshservers();
bool rendermenu()
{
if(vmenu<0) { menustack.setsize(0); return false; };
if(vmenu==1) refreshservers();
gmenu &m = menus[vmenu];
sprintf_sd(title)(vmenu>1 ? "[ %s menu ]" : "%s", m.name);
int mdisp = m.items.length();
int w = 0;
loopi(mdisp)
{
int x = text_width(m.items[i].text);
if(x>w) w = x;
};
int tw = text_width(title);
if(tw>w) w = tw;
int step = FONTH/4*5;
int h = (mdisp+2)*step;
int y = (VIRTH-h)/2;
int x = (VIRTW-w)/2;
blendbox(x-FONTH/2*3, y-FONTH, x+w+FONTH/2*3, y+h+FONTH, true, m.tex >= 0 ? FIRSTMENU + m.tex : -1);
draw_text(title, x, y,2);
y += FONTH*2;
if(vmenu)
{
int bh = y+m.menusel*step;
blendbox(x-FONTH, bh-10, x+w+FONTH, bh+FONTH+10, false);
};
loopj(mdisp)
{
draw_text(m.items[j].text, x, y, 2);
y += step;
};
return true;
};
void rendermenumdl() // nasty s***
void rendermenumdl()
{
if(vmenu<0) { menustack.setsize(0); return; };
if(vmenu<0) { menustack.setsize(0); return false; };
if(vmenu==1) refreshservers();
gmenu &m = menus[vmenu];
if(!m.mdl) return;
glPushMatrix ();
glTranslatef(player1->o.x, player1->o.z, player1->o.y);
glRotatef(player1->yaw+90+180, 0, -1, 0);
glRotatef(player1->pitch, 0, 0, 1);
glTranslatef(2, 0, 0);
if(m.rotspeed) glRotatef(lastmillis/5.0f/100.0f*m.rotspeed, 0, 1, 0);
rendermodel(m.mdl, m.frame, m.range, 0, 5.0f, 0, 0, 0, 0, 0, false, (float)(m.scale ? m.scale/25.0f : 1), 100, 0, 0);
rendermodel(m.mdl, m.frame, m.range, 0, 5.0f, 0, 0, 0, 0, 0, false, (float)(m.scale ? m.scale/25.0f : 1), 100, 0, 0, false);
glPopMatrix();
}
void newmenu(char *name)
{
gmenu &menu = menus.add();
menu.name = newstring(name);
menu.menusel = 0;
menu.tex = -1;
menu.mdl = NULL;
};
void menumanual(int m, int n, char *text)
{
if(!n) menus[m].items.setsize(0);
mitem &mitem = menus[m].items.add();
mitem.text = text;
mitem.action = "";
}
void menuitem(char *text, char *action, char *hoveraction)
{
gmenu &menu = menus.last();
mitem &mi = menu.items.add();
mi.text = newstring(text);
mi.action = action[0] ? newstring(action) : mi.text;
if(hoveraction) mi.hoveraction = newstring(hoveraction);
else mi.hoveraction = NULL;
};
void menubg(char *tex)
{
gmenu &menu = menus.last();
int curmtex = 0;
loopv(menus) curmtex = max(curmtex, menus[i].tex);
if(curmtex>=100) return;
sprintf_sd(path)("packages/%s", tex);
int xs, ys;
if(installtex(FIRSTMENU + curmtex, path, xs, ys, false, true))
menu.tex = curmtex;
};
void menumdl(char *mdl, char *frame, char *range, char *rotspeed, char *scale)
{
if(!mdl || !frame || !range) return;
gmenu &menu = menus.last();
menu.mdl = newstring(mdl, _MAXDEFSTR);
menu.frame = max(0, atoi(frame));
menu.range = max(1, atoi(range));
menu.rotspeed = max(0, min(atoi(rotspeed), 100));
menu.scale = max(0, min(atoi(scale), 100));
};
void chmenumdl(char *menu, char *mdl, char *frame, char *range, char *rotspeed, char *scale)
{
if(!menu || !mdl) return;
loopv(menus)
{
gmenu &m = menus[i];
if(strcmp(m.name, menu) == 0)
{
if(m.mdl) strcpy_s(m.mdl, mdl);
else m.mdl = newstring(mdl, _MAXDEFSTR);
m.frame = atoi(frame);
m.range = atoi(range);
m.rotspeed = max(0, min(atoi(rotspeed), 100));
m.scale = max(0, min(atoi(scale), 100));
return;
};
};
};
COMMAND(menuitem, ARG_3STR);
COMMAND(showmenu, ARG_1STR);
COMMAND(newmenu, ARG_1STR);
COMMAND(menubg, ARG_1STR);
COMMAND(menumdl, ARG_5STR);
COMMAND(chmenumdl, ARG_6STR);
bool menukey(int code, bool isdown)
{
if(vmenu<=0) return false;
int menusel = menus[vmenu].menusel;
if(isdown)
{
int oldmenusel = menusel;
if(code==SDLK_ESCAPE)
{
menuset(-1);
if(!menustack.empty()) menuset(menustack.pop());
return true;
}
else if(code==SDLK_UP || code==-4) menusel--;
else if(code==SDLK_DOWN || code==-5) menusel++;
int n = menus[vmenu].items.length();
if(menusel<0) menusel = n-1;
else if(menusel>=n) menusel = 0;
menus[vmenu].menusel = menusel;
if(menusel != oldmenusel)execute(menus[vmenu].items[menusel].hoveraction, true);
}
else
{
if(code==SDLK_RETURN || code==-2)
{
char *action = menus[vmenu].items[menusel].action;
if(vmenu==1) connects(getservername(menusel));
menustack.add(vmenu);
menuset(-1);
execute(action, true);
};
};
return true;
};
+18 -31
View File
@@ -198,7 +198,8 @@ void moveplayer(dynent *pl, int moveres, bool local, int curtime)
vec d; // vector of direction we ideally want to move in
int move = pl->onladder && pl->move == -1 ? 0 : pl->move; // fix movement on ladder
int move = pl->onladder && !pl->onfloor && pl->move == -1 ? 0 : pl->move; // fix movement on ladder
d.x = (float)(move*cos(rad(pl->yaw-90)));
d.y = (float)(move*sin(rad(pl->yaw-90)));
@@ -224,6 +225,15 @@ void moveplayer(dynent *pl, int moveres, bool local, int curtime)
vdiv(pl->vel, fpsfric);
d = pl->vel;
vmul(d, speed); // d is now frametime based velocity vector
if(pl->isphysent)
{
pl->pitch += speed*5.0f;
if(pl->pitch>360.0f) pl->pitch = 0.0f;
pl->yaw += speed*5.0f;
if(pl->yaw>360.0f) pl->yaw = 0.0f;
}
pl->blocked = false;
pl->moving = true;
@@ -239,6 +249,7 @@ void moveplayer(dynent *pl, int moveres, bool local, int curtime)
{
if(pl->k_up) pl->vel.z = 0.5;
else if(pl->k_down) pl->vel.z = -0.5;
pl->timeinair = 0;
}
else
{
@@ -265,11 +276,11 @@ void moveplayer(dynent *pl, int moveres, bool local, int curtime)
if(local) playsoundc(S_JUMP);
else if(pl->monsterstate) playsound(S_JUMP, &pl->o);
}
else if(pl->timeinair>800) // if we land after long time must have been a high jump, make thud sound
/*else if(pl->timeinair>800) // if we land after long time must have been a high jump, make thud sound
{
if(local) playsoundc(S_LAND);
else if(pl->monsterstate) playsound(S_LAND, &pl->o);
};
};*/
pl->timeinair = 0;
if(pl->isphysent) pl->vel.z *= 0.7f;
}
@@ -391,34 +402,10 @@ void movephysent(physent *pl)
d = pl->vel;
vmul(d, speed); // d is now frametime based velocity vector
/* if(floating || water)
{
d.x *= (float)cos(rad(pl->pitch));
d.y *= (float)cos(rad(pl->pitch));
d.z = (float)(pl->move*sin(rad(pl->pitch)));
};*/
/*if(pl->onfloor || water)
{
if(pl->jumpnext)
{
pl->jumpnext = false;
pl->vel.z = 1.7f; // physics impulse upwards
if(water) { pl->vel.x /= 8; pl->vel.y /= 8; }; // dampen velocity change even harder, gives correct water feel
//if(local) playsoundc(S_JUMP);
}
else if(pl->timeinair>800) // if we land after long time must have been a high jump, make thud sound
{
//if(local) playsoundc(S_LAND);
//else if(pl->monsterstate) playsound(S_LAND, &pl->o);
};
pl->timeinair = 0;
}
else
{
pl->timeinair += curtime;
};*/
pl->pitch = (pl->pitch+(speed));
if(pl->pitch>360.0f) pl->pitch = 0.0f;
printf("pitch %f\n", pl->pitch);
if(pl->onfloor)
{
+1 -1
View File
@@ -200,7 +200,7 @@ extern void initsound();
extern void cleansound();
// 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);
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 mapmodelinfo &getmminfo(int i);
// rendermd3
+2 -2
View File
@@ -327,11 +327,11 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat
renderscores();
if(!rendermenu())
{
if(scoped)
if(scoped && player1->gunselect == GUN_SNIPER)
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_ALPHA_TEST);
//glAlphaFunc(GL_GREATER, 0.9f);
glAlphaFunc(GL_GREATER, 0.9f);
glBindTexture(GL_TEXTURE_2D, 10);
glBegin(GL_QUADS);
glColor3ub(255,255,255);
+2 -2
View File
@@ -245,11 +245,11 @@ 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)
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)
{
md2 *m = loadmodel(mdl);
if(isoccluded(player1->o.x, player1->o.y, x-rad, z-rad, rad*2)) return;
if(oculling && isoccluded(player1->o.x, player1->o.y, x-rad, z-rad, rad*2)) return;
delayedload(m);
+8 -17
View File
@@ -6,7 +6,7 @@
const int FIRSTMD3 = 20;
enum { MDL_LOWER = 0, MDL_UPPER, MDL_HEAD };
enum { MDL_GUN_IDLE = 0, MDL_GUN_ATTACK, MDL_GUN_RELOAD};
enum { MDL_GUN_IDLE = 0, MDL_GUN_ATTACK, MDL_GUN_RELOAD, MDL_GUN_ATTACK2}; // attack2 is for grenade only
#define MD3_DEFAULT_SCALE 0.08f
@@ -454,16 +454,19 @@ void rendermd3gun()
}
else
{
float kick = 0.0f;
float kick = 0.0f;
bool throwingnade = player1->gunselect==GUN_GRENADE && player1->thrownademillis;
if(player1->gunselect==player1->lastattackgun)
{
int percent_done = (lastmillis-player1->lastaction)*100/attackdelay(player1->gunselect);
{
int timedifference = throwingnade ? (lastmillis-player1->thrownademillis) : (lastmillis-player1->lastaction);
int percent_done = timedifference*100/attackdelay(player1->gunselect);
if(percent_done > 100) percent_done = 100.0;
// f(x) = -sin(x-1.5)^3
kick = -sin(pow((1.5f/100*percent_done)-1.5f,3));
};
if(kick > 0.01f) weapon->setanim(MDL_GUN_ATTACK);
if(kick > 0.01f) throwingnade ? weapon->setanim(MDL_GUN_ATTACK2) : weapon->setanim(MDL_GUN_ATTACK);
else weapon->setanim(MDL_GUN_IDLE);
vdist(dist, unitv, player1->o, worldpos);
@@ -474,15 +477,12 @@ void rendermd3gun()
vec sway(unitv);
int swayt = (lastmillis+1)/10 % 100;
// float swayspeed = (float) (sin((float)lastmillis/swayspeeddiv))/(swaymovediv/10.0f);
float swayspeed = (float) (sin((float)lastmillis/swayspeeddiv))/(swaymovediv/10.0f);
float swayupspeed = (float) (sin((float)lastmillis/swayupspeeddiv-90))/(swayupmovediv/10.0f);
//conoutf("%i up %i", swayspeed*1000, swayupspeed*1000);
#define g0(x) ((x) < 0.0f ? -(x) : (x))
float plspeed = min(1.0f, sqrt(g0(player1->vel.x*player1->vel.x) + g0(player1->vel.y*player1->vel.y)));
// if(plspeed<0.0f) plspeed = -plspeed;
swayspeed *= plspeed/2;
swayupspeed *= plspeed/2;
@@ -494,16 +494,7 @@ void rendermd3gun()
if(swayupspeed<0.0f)swayupspeed = -swayupspeed; // sway a semicirle only
sway.z = 1.0f;
//vec rot = {(float) x/1000.0f, (float) y/1000.0f, (float) z/1000.0f}; // direction: left
//rotatevec(sway, rot);
//vmul(sway, swayspeed);
//rot.x = 0.0f; rot.y = 0.0f; rot.z = 1.0f;
//rotatevec(sway, rot);
//vmul(sway, swayspeed);
sway.x *= swayspeed;
sway.y *= swayspeed;
sway.z *= swayupspeed;
+2 -1
View File
@@ -44,7 +44,8 @@ char msgsizesl[] = // size inclusive message token, 0 for variable
SV_MAPCHANGE, 0, SV_ITEMSPAWN, 2, SV_ITEMPICKUP, 3, SV_DENIED, 2,
SV_PING, 2, SV_PONG, 2, SV_CLIENTPING, 2, SV_GAMEMODE, 2,
SV_EDITH, 7, SV_EDITT, 7, SV_EDITS, 6, SV_EDITD, 6, SV_EDITE, 6,
SV_SENDMAP, 0, SV_RECVMAP, 1, SV_SERVMSG, 0, SV_ITEMLIST, 0, SV_WEAPCHANGE, 2,
SV_SENDMAP, 0, SV_RECVMAP, 1, SV_SERVMSG, 0, SV_ITEMLIST, 0, SV_WEAPCHANGE, 2,
SV_MODELSKIN, 2,
SV_EXT, 0,
-1
};
+7 -2
View File
@@ -330,10 +330,11 @@ void throw_nade(dynent *d, vec &to, physent *p)
if(d==player1)
{
d->thrownademillis = lastmillis;
int percent_done = (lastmillis-p->millis)*100/2000;
if(percent_done < 0 || percent_done > 100) percent_done = 100;
addmsg(1, 9, SV_SHOT, d->gunselect, (int)(from.x*DMF), (int)(from.y*DMF), (int)(from.z*DMF), (int)(to.x*DMF), (int)(to.y*DMF), (int)(to.z*DMF), percent_done);
printf("grenade: %i\n", (lastmillis-curnade->millis)/100);
// printf("grenade: %i\n", (lastmillis-curnade->millis)/100);
if(curnade) curnade = NULL;
};
};
@@ -390,7 +391,11 @@ physent *new_nade(dynent *d, int millis = 0)
p->millis = lastmillis;
p->timetolife = 2000-millis;
p->state = NADE_ACTIVATED;
if(d==player1) curnade = p;
if(d==player1)
{
curnade = p;
d->thrownademillis = 0;
};
return p;
};