From a4bab13d216a4d6b9854ad0fccf54395e75baf03 Mon Sep 17 00:00:00 2001 From: driAn Date: Thu, 27 Apr 2006 14:37:27 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@275 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/client.cpp | 50 ++++++++++++---------------- source/src/clientextras.cpp | 65 ++++++++++++++++--------------------- source/src/clientgame.cpp | 50 ++++++++++++++-------------- source/src/cube.h | 11 ++++--- source/src/entities.cpp | 11 ++++--- source/src/physics.cpp | 4 +-- source/src/protos.h | 6 ++-- source/src/renderextras.cpp | 13 +++++++- source/src/rendergl.cpp | 2 +- source/src/rendermd3.cpp | 10 ++++-- source/src/server.cpp | 1 + source/src/weapon.cpp | 56 ++++++++++++++++++-------------- source/src/world.cpp | 6 ++-- source/src/worldio.cpp | 2 -- 14 files changed, 147 insertions(+), 140 deletions(-) diff --git a/source/src/client.cpp b/source/src/client.cpp index 5bfc1f9b..333c03f2 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -41,37 +41,28 @@ void throttle() }; void ctf_team(char *name) -{ - c2sinit = false; +{ + bool isvalidteam = strcmp(name, "RVSF") == 0 || strcmp(name, "CLA") == 0; + if(strcmp(name, player1->team) == 0 && isvalidteam) return; + c2sinit = false; + ctf_death(); + if(isvalidteam) strcpy_s(player1->team, name); + else strcpy_s(player1->team, rb_team_string(rnd(2))); + player1->lastaction = lastmillis; + player1->state = CS_DEAD; +}; - if(strcmp(name, "red") == 0 || strcmp(name, "blue") == 0) - { - if(strcmp(name, player1->team) != 0) - { - ctf_death(); - strcpy(player1->team, name); // avoid spawning on the enemy side - player1->lastaction = lastmillis; - player1->state = CS_DEAD; - }; - } - else - { - ctf_death(); - strcpy(player1->team, rb_team_string(rnd(2))); - player1->lastaction = lastmillis; - player1->state = CS_DEAD; - } -} - -void newname(char *name) { c2sinit = false; strn0cpy(player1->name, name, 16); }; -void newteam(char *name) -{ - c2sinit = false; - ctf_team(name); +void newname(char *name) { c2sinit = false; strn0cpy(player1->name, name, 16); }; +void newskin(int skin) { player1->nextskin = min(0, max(skin, (rb_team_int(player1->team)==TEAM_CLA ? 3 : 5))); }; +void newteam(char *name) +{ + if(m_teammode) ctf_team(name); + else { strn0cpy(player1->team, name, 5); c2sinit=false; }; }; COMMANDN(team, newteam, ARG_1STR); -COMMANDN(name, newname, ARG_1STR); +COMMANDN(name, newname, ARG_1STR); +COMMANDN(skin, newskin, ARG_1INT); void connects(char *servername) { @@ -202,7 +193,7 @@ void initclientnet() toservermap[0] = 0; clientpassword[0] = 0; newname("unnamed"); - newteam("red"); + ctf_team("red"); }; void sendpackettoserv(void *packet) @@ -271,7 +262,8 @@ void c2sinfo(dynent *d) // send update to the server c2sinit = true; putint(p, SV_INITC2S); sendstring(player1->name, p); - sendstring(player1->team, p); + sendstring(player1->team, p); + sendstring(player1->skin, p); putint(p, player1->lifesequence); }; loopv(messages) // send messages collected during the previous frames diff --git a/source/src/clientextras.cpp b/source/src/clientextras.cpp index 29c515fc..df615312 100644 --- a/source/src/clientextras.cpp +++ b/source/src/clientextras.cpp @@ -17,7 +17,7 @@ void renderclient(dynent *d, bool team, char *mdlname, bool vwep, float scale) int basetime = -((int)d&0xFFF); if(d->state==CS_DEAD) { - d->pitch = 90.0f; + d->pitch = 180.0f; //if(vwep) mz = S((int)d->o.x, (int)d->o.y)->floor; int r; n = (int)d%3; r = range[n]; @@ -45,48 +45,39 @@ void renderclient(dynent *d, bool team, char *mdlname, bool vwep, float 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); }; -extern int democlientnum; +extern int democlientnum; + +void renderplayer(dynent *d) +{ + if(!d) return; + + int team = rb_team_int(d->team); + sprintf_sd(mdl)("playermodels/%s/%i", team==TEAM_CLA ? "terrorist" : "counterterrorist", min(0, max(d->skin, (rb_team_int(d->team)==TEAM_CLA ? 3 : 5)))); + renderclient(d, isteam(player1->team, d->team), mdl, false, 1.6f); + + if(d->gunselect>=0 && d->gunselectgunselect]); + renderclient(d, isteam(player1->team, d->team), vwep, true, 1.6f); + }; +} void renderclients() { dynent *d; loopv(players) - if((d = players[i]) && (!demoplayback || i!=democlientnum)) - { - //if (d->state==CS_DEAD) break; //cheap hack fix of - if(strcmp(d->name, "dummy") == 0) - { - d->gunselect = player1->gunselect; - d->moving = true; - d->health != 1 ? d->state=CS_ALIVE : d->state=CS_DEAD; - }; - - if (!strcmp(d->team,"CT")) - { - renderclient(d, isteam(player1->team, d->team), "playermodels/counterterrorist", false,1.4f); - } - else //if (!strcmp(d->team,"T")) - { - renderclient(d, isteam(player1->team, d->team), "playermodels/terrorist", false, 1.4f); - } - - if(d->gunselect>=0 && d->gunselectgunselect]); - renderclient(d, isteam(player1->team, d->team), vwep, true, 1.4f); - }; - - }; - if(player1->state==CS_DEAD) + if((d = players[i]) && (!demoplayback || i!=democlientnum)) { - if (!strcmp(player1->team,"CT")) - renderclient(player1, true, "playermodels/counterterrorist", false,1.4f); - else - renderclient(player1, true, "playermodels/terrorist", false, 1.4f); - - sprintf_sd(vwep)("weapons/%s/world", hudgunnames[player1->gunselect]); - renderclient(player1, true, vwep, true, 1.4f); - }; + if(strcmp(d->name, "dummy") == 0) + { + d->gunselect = player1->gunselect; + d->moving = true; + d->health != 1 ? d->state=CS_ALIVE : d->state=CS_DEAD; + }; + renderplayer(d); + }; + + if(player1->state==CS_DEAD) renderplayer(d); }; void spawn_dummy() diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 3767e2d7..726aa7f4 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -40,6 +40,8 @@ void resetmovement(dynent *d) d->move = 0; }; +extern bool c2sinit; + void spawnstate(dynent *d) // reset player state not persistent accross spawns { resetmovement(d); @@ -50,9 +52,8 @@ void spawnstate(dynent *d) // reset player state not persistent acc d->armour = 0; //d->hasarmour = false; //d->armourtype = A_BLUE; - //d->quadmillis = 0; + d->akimbomillis = 0; d->gunselect = GUN_PISTOL; - d->mag[6]=10; d->gunwait = 0; d->attacking = false; d->lastaction = 0; @@ -60,11 +61,14 @@ void spawnstate(dynent *d) // reset player state not persistent acc { gun_changed = true; player1->primary = player1->nextprimary; + if(player1->skin!=player1->nextskin) + { + c2sinit=false; + player1->skin=player1->nextskin; + } scoped = false; }; - radd(d); - d->akimbo = false; }; @@ -193,15 +197,15 @@ void arenarespawn() }; -void checkquad(int time) +void checkakimbo(int time) { -/* if(player1->quadmillis && (player1->quadmillis -= time)<0) + if(player1->gunselect==GUN_PISTOL && player1->akimbo && (player1->akimbomillis -= time)<0) { - player1->quadmillis = 0; + player1->akimbomillis = 0; + player1->akimbo = false; playsoundc(S_PUPOUT); - conoutf("quad damage is over"); + //conoutf("quad damage is over"); }; -*/ }; void zapdynent(dynent *&d) @@ -256,8 +260,9 @@ void updateworld(int millis) // main game update loop curtime = millis - lastmillis; if(sleepwait && lastmillis>sleepwait) { execute(sleepcmd); sleepwait = 0; }; physicsframe(); + checkakimbo(curtime); //if(m_arena) arenarespawn(); - arenarespawn(); + arenarespawn(); moveprojectiles((float)curtime); demoplaybackstep(); if(!demoplayback) @@ -316,7 +321,7 @@ int nearestenemy(vec *v, string team) { dynent *other = players[i]; if(!other) continue; - if(isteam(team,other->team))continue; // its a teammate + if(m_teammode && isteam(team,other->team))continue; // its a teammate vec place = {v->x, v->y, v->z}; vdistsquared(distsquared, t, place, other->o); if(nearestPlayerDistSquared == -1) nearestPlayerDistSquared = distsquared; // first run @@ -334,12 +339,12 @@ void spawnplayer(dynent *d, bool secure) // place at random spawn loopj(10) // EDIT: AH { int r = fixspawn-->0 ? 4 : rnd(10)+1; - loopi(r) spawncycle = m_ctf ? findteamplayerstart(rb_team_int(d->team), spawncycle+1) : findentity(PLAYERSTART, spawncycle+1); + loopi(r) spawncycle = findplayerstart(rb_team_int(d->team), spawncycle+1, m_teammode); if(spawncycle!=-1 && secure) { entity &e = ents[spawncycle]; vec pos = { e.x, e.y, e.z }; - if(nearestenemy(&pos, d->team) == -1) break; + if(m_teammode && nearestenemy(&pos, d->team) == -1) break; } else break; }; if(spawncycle!=-1) @@ -446,7 +451,7 @@ void selfdamage(int damage, int actor, dynent *act) }; }; // EDIT: AH - if(m_ctf) ctf_death(); + if(m_teammode) ctf_death(); showscores(true); addmsg(1, 2, SV_DIED, actor); player1->lifesequence++; @@ -498,9 +503,11 @@ void initclient() initclientnet(); }; -void preparectf(bool cleanonly = false) +entity flagdummies[2]; // in case the map does not provide flags + +void preparectf(bool cleanonly=false) { - loopi(2) flaginfos[i].flag = NULL; + loopi(2) flaginfos[i].flag = &flagdummies[i]; if(!cleanonly) { loopv(ents) @@ -518,19 +525,14 @@ void preparectf(bool cleanonly = false) f.originalpos.z = (float) e.z; }; }; + newteam(player1->team); // ensure valid team }; - loopi(2) // ignore missing flags - { - flaginfo &f = flaginfos[i]; - if(f.flag == NULL) f.flag = new entity(); - } - ctf_team(player1->team); // ensure valid team }; void startmap(char *name) // called just after a map load { - //if(netmapstart()) { gamemode = 0;}; //needs fixed to switch modes? - netmapstart(); //should work + if(netmapstart()) { gamemode = 0;}; //needs fixed to switch modes? + //netmapstart(); //should work sleepwait = 0; //put call to clear/restart game mode extras here projreset(); diff --git a/source/src/cube.h b/source/src/cube.h index b7633544..b90a1d30 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -91,7 +91,8 @@ struct vec { float x, y, z; }; struct block { int x, y, xs, ys; }; struct mapmodelinfo { int rad, h, zoff, snap; char *name; }; -enum { GUN_KNIFE = 0, GUN_PISTOL, GUN_SHOTGUN, GUN_SUBGUN, GUN_SNIPER, GUN_ASSULT, GUN_GRENADE, NUMGUNS }; +enum { GUN_KNIFE = 0, GUN_PISTOL, GUN_SHOTGUN, GUN_SUBGUN, GUN_SNIPER, GUN_ASSULT, GUN_GRENADE, NUMGUNS }; +enum { G_PRIMARY=0, G_SECONDARY, G_MELEE, G_GRENADE, G_NUM }; struct md3state { @@ -146,7 +147,8 @@ struct dynent // players & monsters int lifesequence; // sequence id for each respawn, used in damage test int state; // one of CS_* below int frags; - int health, armour; //armourtype, quadmillis; + int health, armour; //armourtype, quadmillis; + int akimbomillis; int gunselect, gunwait; int lastaction, lastattackgun, lastmove; bool attacking; @@ -166,7 +168,8 @@ struct dynent // players & monsters int shots; //keeps track of shots from auto weapons bool reloading, hasarmour; int primary; //primary gun - int nextprimary; + int nextprimary; + int skin, nextskin; md3state animstate[3]; bool onladder; @@ -324,8 +327,6 @@ extern bool demoplayback; //#define m_dmsp (gamemode==-1) //#define m_classicsp (gamemode==-2) #define isteam(a,b) (m_teammode && strcmp(a, b)==0) -// EDIT: AH -#define m_ctf (gamemode==5) #define TEAM_CLA 0 // #define TEAM_RVSF 1 // diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 1460e177..824ecc05 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -38,7 +38,7 @@ void renderentities() sprintf_sd(path)("pickups/flags/small_%s", rb_team_string(e.attr2)); mapmodelinfo mmi = {10, 4, 0, 0, path}; if(!&mmi) continue; - rendermodel(mmi.name, 0, 1, 0, 0, f.thief->o.x, f.thief->o.z+0.3f+(sin(lastmillis/100.0f)+1)/10, f.thief->o.y, lastmillis/2.5f, 0, false, 1.0f, 120.0f, mmi.snap); + rendermodel(mmi.name, 0, 1, 0, 0, f.thief->o.x, f.thief->o.z+0.3f+(sin(lastmillis/100.0f)+1)/10, f.thief->o.y, lastmillis/2.5f, 0, false, 0.6f, 120.0f, mmi.snap); } else { @@ -112,9 +112,9 @@ void radditem(int i, int &v, int t) v += is.add; if(v>is.max) v = is.max; playsoundc(is.sound); -}; +}; -extern void secondary(); +extern void changeweapon(int gun); void realpickup(int n, dynent *d) { @@ -142,10 +142,11 @@ void realpickup(int n, dynent *d) break; case I_AKIMBO: - d->akimbo = true; + d->akimbo = true; + d->akimbomillis = 30000; d->mag[GUN_PISTOL] = 16; radditem(n, d->ammo[1], 9); - secondary(); + changeweapon(G_SECONDARY); conoutf("a lesser man would use a single pistol"); break; }; diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 0e4f9e62..0042b536 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -246,8 +246,8 @@ void moveplayer(dynent *pl, int moveres, bool local, int curtime) { if(pl->onladder) { - if(pl->k_up) pl->vel.z = 0.5; - else if(pl->k_down) pl->vel.z = -0.5; + if(pl->k_up) pl->vel.z = 0.75; + else if(pl->k_down) pl->vel.z = -0.75; pl->timeinair = 0; } else diff --git a/source/src/protos.h b/source/src/protos.h index 9edaf52f..9176aca2 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -73,7 +73,7 @@ extern void initclientnet(); extern bool netmapstart(); extern int getclientnum(); extern void changemapserv(char *name, int mode); -extern void ctf_team(char *name); +extern void newteam(char *name); // clientgame extern flaginfo flaginfos[2]; @@ -111,7 +111,7 @@ extern void remip(block &b, int level = 0); extern void remipmore(block &b, int level = 0); extern int closestent(); extern int findentity(int type, int index = 0); -extern int findteamplayerstart(int team, int index = 0); +extern int findplayerstart(int team, int index, bool team); extern void trigger(int tag, int type, bool savegame); extern void resettagareas(); extern void settagareas(); @@ -170,7 +170,7 @@ extern void addshotline(dynent *d, vec &from, vec &to); extern void rendershotlines(); extern void shotlinereset(); extern void renderphysents(); -extern int scoped; +extern bool scoped; // renderparticles extern void setorient(vec &r, vec &u); diff --git a/source/src/renderextras.cpp b/source/src/renderextras.cpp index e0eca82b..1c89c5a8 100644 --- a/source/src/renderextras.cpp +++ b/source/src/renderextras.cpp @@ -270,7 +270,18 @@ void damageblend(int n) { dblend += n; }; VAR(hidestats, 0, 0, 1); VAR(crosshairfx, 0, 1, 1); -VAR(scoped, 0, 0, 1); + +bool scoped = false; +int oldfov = 100; + +void togglescope() +{ + if(player1->gunselect!=GUN_SNIPER) return; + if(!scoped) oldfov = getvar("fov"); + scoped = !scoped; + setvar("fov", scoped ? 50 : oldfov); +} +COMMAND(togglescope, ARG_NONE); void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater) { diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 903c51f8..52e0d425 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -268,7 +268,7 @@ void transplayer() }; }; -VAR(fov, 10, 105, 120); +VAR(fov, 90, 105, 120); int xtraverts; diff --git a/source/src/rendermd3.cpp b/source/src/rendermd3.cpp index 0b13b4c0..0efd0ac4 100644 --- a/source/src/rendermd3.cpp +++ b/source/src/rendermd3.cpp @@ -444,7 +444,7 @@ struct weaponmove else if(player1->reloading) { anim = MDL_GUN_RELOAD; - int rtime = reloadtime(player1->gunselect) / (akimbo ? 2 : 1); + int rtime = reloadtime(player1->gunselect); float percent_done = (float)(timediff)*100.0f/rtime; if(percent_done >= 100) percent_done = 100; k_rot = -(sin((float)(percent_done*2/100.0f*90.0f)*PI/180.0f)*90); @@ -452,6 +452,7 @@ struct weaponmove else { vec sway = base; + float k_back = 0.0f; if(player1->gunselect==player1->lastattackgun) { @@ -467,8 +468,11 @@ struct weaponmove else anim = MDL_GUN_ATTACK; }; - k_rot = kick_rot(player1->gunselect)*kick; - float k_back = kick_back(player1->gunselect)*kick/10; + if(player1->gunselect!=GUN_GRENADE && player1->gunselect!=GUN_KNIFE) + { + k_rot = kick_rot(player1->gunselect)*kick; + k_back = kick_back(player1->gunselect)*kick/10; + }; int swayt = (lastmillis+1)/10 % 100; float swayspeed = (float) (sin((float)lastmillis/swayspeeddiv))/(swaymovediv/10.0f); diff --git a/source/src/server.cpp b/source/src/server.cpp index 70661eaa..e612df84 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -337,6 +337,7 @@ void process(ENetPacket * packet, int sender) // sender may be -1 sgetstr(); strcpy_s(clients[cn].name, text); sgetstr(); + getint(p); getint(p); break; diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index a11e2ced..bb7d11c8 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -21,30 +21,38 @@ guninfo guns[NUMGUNS] = }; -bool gun_changed = false; - -void primary() -{ - player1->gunselect=player1->primary; - gun_changed = true; -}; - -void secondary() -{ - player1->gunselect=GUN_PISTOL; - gun_changed = true; -}; - -void melee() -{ - player1->gunselect=GUN_KNIFE; - gun_changed = true; -}; - -COMMAND(primary,ARG_NONE); -COMMAND(secondary,ARG_NONE); -COMMAND(melee,ARG_NONE); +bool gun_changed = false; + +void changeweapon(int gun) +{ + if(gun>=0) gun %= G_NUM; + else gun = G_NUM-(gun % G_NUM); + gun_changed = true; + switch(gun) + { + case G_PRIMARY: player1->gunselect=player1->primary; break; + case G_SECONDARY: player1->gunselect=GUN_PISTOL; break; + case G_MELEE: player1->gunselect=GUN_KNIFE; break; + case G_GRENADE: player1->gunselect=GUN_GRENADE; break; + }; +}; + +void shiftweapon(int i) +{ + int gun; + switch(player1->gunselect) + { + case GUN_KNIFE: gun=G_MELEE; break; + case GUN_PISTOL: gun=G_SECONDARY; break; + case GUN_GRENADE: gun=G_GRENADE; break; + default: gun=G_PRIMARY; break; + }; + gun += i; + changeweapon(gun); +} +COMMAND(changeweapon, ARG_1INT); +COMMAND(shiftweapon, ARG_1INT); void reload() { @@ -454,8 +462,6 @@ void raydamage(dynent *o, vec &from, vec &to, dynent *d, int i) } else if(intersect(o, from, to)) hitpush(i, qdam, o, d, from, to); }; - -extern int scoped; void spreadandrecoil(vec & from, vec & to, dynent * d) { diff --git a/source/src/world.cpp b/source/src/world.cpp index 92ca8276..36dc7ca1 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -294,10 +294,10 @@ int findentity(int type, int index) return -1; }; -int findteamplayerstart(int team, int index) +int findplayerstart(int team, int index, bool checkteam) { - for(int i = index; i32) e.attr1 = 32; // 12_03 and below }; - if (hdr.version