From da6a8c361b146efc7d66dec754faa45a9d58baf1 Mon Sep 17 00:00:00 2001 From: driAn Date: Thu, 23 Jun 2005 22:32:59 +0000 Subject: [PATCH] source update git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@16 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 28 ++++++++----- source/src/cube.h | 19 +++++---- source/src/entities.cpp | 58 +++++++++++++++++++-------- source/src/physics.cpp | 7 +++- source/src/renderextras.cpp | 11 +++-- source/src/savegamedemo.cpp | 4 +- source/src/serverutil.cpp | 4 +- source/src/weapon.cpp | 80 +++++++++++++++++++++++++++++++++---- source/src/world.cpp | 3 +- source/src/worldio.cpp | 10 +++-- 10 files changed, 165 insertions(+), 59 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index e120eb99..6151cbc8 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -44,12 +44,16 @@ void spawnstate(dynent *d) // reset player state not persistent acc d->timeinair = 0; d->health = 100; d->armour = 0; - d->armourtype = A_BLUE; + //d->hasarmour = false; d->quadmillis = 0; d->gunselect = GUN_PISTOL; d->gunwait = 0; d->attacking = false; + if(d->primary==GUN_SNIPER && d->altattack) + setvar("fov",getvar("fov")+55); + d->altattack = false; d->lastaction = 0; + d->gunselect = d->primary; radd(d); //loopi(NUMGUNS) if(d->nextprimary!=i) d->ammo[i] = 0; @@ -139,7 +143,9 @@ dynent *newdynent() // create a new blank player or monster d->state = CS_ALIVE; d->shots = 0; d->reloading = false; + d->altattack = false; d->nextprimary = 1; + d->nextarmour = false; spawnstate(d); return d; }; @@ -239,14 +245,11 @@ void checkgame(int time) player1->maxspeed=22; return; } - else //otherwise max speed is 16 and 14 with armour - { - if(player1->armour>50) - player1->maxspeed = 14; - if(player1->armour>0) - player1->maxspeed = 15; - player1->maxspeed = 16; - }; + + if(player1->hasarmour) + player1->maxspeed = 14; + else player1->maxspeed = 16; + //force to a team if team mode @@ -437,7 +440,7 @@ void selfdamage(int damage, int actor, dynent *act) if(player1->state!=CS_ALIVE || editmode || intermission) return; damageblend(damage); demoblend(damage); - int ad = damage*(player1->armourtype+1)*20/100; // let armour absorb when possible + int ad = damage*25/100; // let armour absorb when possible armour absorbs 25% if(ad>player1->armour) ad = player1->armour; player1->armour -= ad; damage -= ad; @@ -477,7 +480,10 @@ void selfdamage(int damage, int actor, dynent *act) player1->state = CS_DEAD; player1->pitch = 0; player1->roll = 60; - playsound(S_DIE1+rnd(2)); + if(actor==-1) //suicide + playsound(S_SUICIDE); + else + playsound(S_DIE1+rnd(2)); //add suicide sound spawnstate(player1); player1->lastaction = lastmillis; } diff --git a/source/src/cube.h b/source/src/cube.h index d996666f..47824bb2 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -40,7 +40,7 @@ enum // static entity types NOTUSED = 0, // entity slot not in use in map LIGHT, // lightsource, attr1 = radius, attr2 = intensity PLAYERSTART, // attr1 = angle - I_SHOTGUN, I_SUBGUN, I_SNIPER, I_ASSULT, I_GRENADE, I_PISTOL, + I_AMMO, I_PISTOL, I_GRENADE, I_HEALTH, I_ARMOUR, I_QUAD, MAPMODEL, // attr1 = angle, attr2 = idx CARROT, // attr1 = tag, attr2 = type @@ -108,7 +108,7 @@ 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, quadmillis; //removed armour type int gunselect, gunwait; int lastaction, lastattackgun, lastmove; bool attacking; @@ -120,7 +120,7 @@ struct dynent // players & monsters float targetyaw; // monster wants to look in this direction bool blocked, moving; // used by physics to signal ai int trigger; // millis at which transition to another monsterstate takes place - vec attacktarget; // delayed attacks +// vec attacktarget; // delayed attacks int anger; // how many times already hit by fellow monster string name, team; int startheight; @@ -128,11 +128,14 @@ struct dynent // players & monsters bool reloading; int primary; //primary gun int nextprimary; + bool altattack; + bool hasarmour; + bool nextarmour; }; #define SAVEGAMEVERSION 6 // bump if dynent/netprotocol changes or any other savegame/demo data bumped from 5 -enum { A_BLUE, A_GREEN, A_YELLOW }; // armour types... take 20/40/60 % off +//enum { A_BLUE, A_GREEN, A_YELLOW }; // armour types... take 20/40/60 % off enum { M_NONE = 0, M_SEARCH, M_HOME, M_ATTACKING, M_PAIN, M_SLEEP, M_AIMING }; // monster states #define MAXCLIENTS 256 // in a multiplayer game, can be arbitrarily changed @@ -236,13 +239,15 @@ extern bool demoplayback; 3 - survivor 4 - team survior 5 - ctf +6 - pistols only */ -#define m_noitems (false) -#define m_noitemsrail (false) +#define m_noitems (gamemode==3 || gamemode==4 || gamemode==6) +#define m_noitemsrail (false) //dunno what this does +#define m_pistols (gamemode==6) #define m_arena (gamemode==3 || gamemode==4) #define m_tarena (gamemode==4) -#define m_teammode (gamemode==0 || gamemode>=4) +#define m_teammode (gamemode==0 || (gamemode>=4 & !m_pistols)) #define m_ctf (gamemode==5) //#define m_sp (gamemode<0) //#define m_dmsp (gamemode==-1) diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 03314829..90cd32c4 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -35,8 +35,8 @@ void renderentities() if(e.type!=CARROT) { if(!e.spawned) continue; - if(e.typeI_QUAD) continue; - renderent(e, entmdlnames[e.type-I_SHOTGUN], (float)(1+sin(lastmillis/100.0+e.x+e.y)/20), lastmillis/10.0f); + if(e.typeI_QUAD) continue; + renderent(e, entmdlnames[e.type-I_AMMO], (float)(1+sin(lastmillis/100.0+e.x+e.y)/20), lastmillis/10.0f); } else switch(e.attr2) { @@ -63,10 +63,10 @@ struct itemstat { int add, max, sound; } itemstats[] = 30, 90, S_ITEMAMMO, //subgun 5, 15, S_ITEMAMMO, //sniper 20, 40, S_ITEMAMMO, //assult - 1, 2, S_ITEMAMMO, //grenade 5, 10, S_ITEMAMMO, //pistol + 1, 2, S_ITEMAMMO, //grenade 25, 100, S_ITEMHEALTH, //health - 100, 150, S_ITEMARMOUR, //armour + 100, 125, S_ITEMARMOUR, //armour 20000, 30000, S_ITEMPUP, //powerup }; @@ -77,7 +77,7 @@ void baseammo(int gun) { player1->ammo[gun] = itemstats[gun-1].add*2; }; void radditem(int i, int &v) { - itemstat &is = itemstats[ents[i].type-I_SHOTGUN]; + itemstat &is = itemstats[ents[i].type-I_AMMO]; ents[i].spawned = false; v += is.add; if(v>is.max) v = is.max; @@ -88,17 +88,19 @@ void realpickup(int n, dynent *d) { switch(ents[n].type) { - case I_PISTOL: radditem(n, d->ammo[1]); break; - case I_SHOTGUN: radditem(n, d->ammo[2]); break; +/* case I_PISTOL: radditem(n, d->ammo[1]); break; + + case I_AMMO: radditem(n, d->ammo[2]); break; case I_SUBGUN: radditem(n, d->ammo[3]); break; case I_SNIPER: radditem(n, d->ammo[4]); break; - case I_ASSULT: radditem(n, d->ammo[5]); break; + case I_ASSAULT: radditem(n, d->ammo[5]); break; case I_GRENADE: radditem(n, d->ammo[6]); break; +*/ case I_HEALTH: radditem(n, d->health); break; case I_ARMOUR: radditem(n, d->armour); - d->armourtype = A_YELLOW; + d->hasarmour = true; break; case I_QUAD: @@ -112,7 +114,7 @@ void realpickup(int n, dynent *d) void additem(int i, int &v, int spawnsec) { - if(vammo[1], ammo); break; - case I_SHOTGUN: additem(n, d->ammo[2], ammo); break; + + case I_AMMO: additem(n, d->ammo[2], ammo); break; case I_SUBGUN: additem(n, d->ammo[3], ammo); break; case I_SNIPER: additem(n, d->ammo[4], ammo); break; - case I_ASSULT: additem(n, d->ammo[5], ammo); break; + case I_ASSAULT: additem(n, d->ammo[5], ammo); break; case I_GRENADE: additem(n, d->ammo[6], ammo); break; +*/ case I_HEALTH: additem(n, d->health, np*5); break; case I_ARMOUR: @@ -170,7 +175,7 @@ void checkitems() void putitems(uchar *&p) // puts items in network stream and also spawns them locally { - loopv(ents) if((ents[i].type>=I_SHOTGUN && ents[i].type<=I_QUAD) || ents[i].type==CARROT) + loopv(ents) if((ents[i].type>=I_AMMO && ents[i].type<=I_QUAD) || ents[i].type==CARROT) { putint(p, i); ents[i].spawned = true; @@ -184,10 +189,17 @@ void radd(dynent *d) { loopi(NUMGUNS) if(d->nextprimary!=i) d->ammo[i] = 0; d->mag[GUN_KNIFE] = 1; - + d->mag[GUN_PISTOL] = 8; d->ammo[GUN_PISTOL] = 24; + if(m_pistols) + { + d->primary=GUN_PISTOL; + d->ammo[GUN_PISTOL] = 48; //change? + return; + }; + if (d->primary==GUN_PISTOL) // || pistol only mode! { d->ammo[d->primary] = 48; @@ -208,13 +220,25 @@ void radd(dynent *d) d->armour = 100; } */ + //if(m_noitems) { conoutf("i am (not) sorry, but an armour choice is only for ts and lms"); return; }; + + if(d->nextarmour==true) + { + if(!m_noitems) return;{ conoutf("armour is only for ts and lms modes, maybe you can hide"); return; }; + d->hasarmour = true; + d->armour=itemstats[7].add; + } + else + { + d->hasarmour = false; + }; }; void add(int num) { - - - if (num>0 && num<8) player1->nextprimary = num; + if (num>0 && num<6) player1->nextprimary = num; + if (num==7 && m_noitems) player1->nextarmour=!player1->nextarmour; + else conoutf("armour is only for ts and lms modes, maybe you can hide"); }; COMMAND(add,ARG_1INT); \ No newline at end of file diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 703dbb13..aedd7db3 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -234,8 +234,8 @@ void moveplayer(dynent *pl, int moveres, bool local, int curtime) { if (pl->onfloor || !pl->vel.z) { - int damage = (int)pl->startheight - (int)pl->o.z; - if (damage > 8 && local) //try adding "&& local" if falling not fixed + int damage = ((int)pl->startheight - (int)pl->o.z)*2; + if (damage > 20 && local) //try adding "&& local" if falling not fixed { selfdamage(damage,-1,pl); demodamage(damage, player1->o); @@ -247,6 +247,9 @@ void moveplayer(dynent *pl, int moveres, bool local, int curtime) if(pl->jumpnext) { pl->jumpnext = false; + if (pl->hasarmour) + pl->vel.z = 1.9f; + else 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); diff --git a/source/src/renderextras.cpp b/source/src/renderextras.cpp index d07ecc27..3b4eae02 100644 --- a/source/src/renderextras.cpp +++ b/source/src/renderextras.cpp @@ -142,7 +142,7 @@ string closeent; char *entnames[] = { "none?", "light", "playerstart", - "shotgun", "submachinegun", "sniperrifle", "assultrifle", "grenade", "pistol", + "primary", "secondary", "grenade", "health", "armour", "quaddamage", "mapmodel", "trigger", "ladder", "?", "?", "?", "?", @@ -352,7 +352,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glPushMatrix(); glOrtho(0, VIRTW/2, VIRTH/2, 0, -1, 1); draw_textf("%d", 90, 827, 2, player1->health); - if(player1->armour) draw_textf("%d", 390, 827, 2, player1->armour); + if(player1->hasarmour) draw_textf("%d", 390, 827, 2, player1->armour); //draw_textf("%d", 690, 827, 2, player1->mag[player1->gunselect]); if (!player1->reloading && player1->gunselect!=GUN_KNIFE) { @@ -369,15 +369,14 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glPushMatrix(); glOrtho(0, VIRTW, VIRTH, 0, -1, 1); glDisable(GL_BLEND); - drawicon(128, 128, 20, 1650); - if(player1->armour) drawicon((float)(player1->armourtype*64), 0, 620, 1650); + drawicon(64, 0, 20, 1650); + if(player1->hasarmour) drawicon(128, 0, 620, 1650); int g = player1->gunselect; - int r = 64; + int r = 64; if(g>2) { g -= 3; r = 128; }; drawicon((float)(g*64), (float)r, 1220, 1650); glPopMatrix(); }; - glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); diff --git a/source/src/savegamedemo.cpp b/source/src/savegamedemo.cpp index 7cc79d41..73669ea8 100644 --- a/source/src/savegamedemo.cpp +++ b/source/src/savegamedemo.cpp @@ -166,7 +166,7 @@ void incomingdemodata(uchar *buf, int len, bool extras) gzputi(player1->gunwait); gzputi(player1->health); gzputi(player1->armour); - gzput(player1->armourtype); + gzput(player1->hasarmour); loopi(NUMGUNS) gzput(player1->ammo[i]); gzput(player1->state); gzputi(bdamage); @@ -271,7 +271,7 @@ void demoplaybackstep() target->gunwait = gzgeti(); target->health = gzgeti(); target->armour = gzgeti(); - target->armourtype = gzget(); + target->hasarmour = gzget(); loopi(NUMGUNS) target->ammo[i] = gzget(); target->state = gzget(); target->lastmove = playbacktime; diff --git a/source/src/serverutil.cpp b/source/src/serverutil.cpp index 1f9e25c6..34e6c2ee 100644 --- a/source/src/serverutil.cpp +++ b/source/src/serverutil.cpp @@ -29,11 +29,11 @@ void sendstring(char *t, uchar *&p) const char *modenames[] = { "team deathmatch", "coopedit", "deathmatch", "survior", - "team survior", "ctf", + "team survior", "ctf", "pistols", }; //const char *modestr(int n) { return (n>=-2 && n<12) ? modenames[n+2] : "unknown"; }; -const char *modestr(int n) { return (n>=0 && n<6) ? modenames[n] : "unknown"; }; +const char *modestr(int n) { return (n>=0 && n<7) ? modenames[n] : "unknown"; }; char msgsizesl[] = // size inclusive message token, 0 for variable or not-checked sizes diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 446b004d..6f670bb9 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -13,10 +13,10 @@ guninfo guns[NUMGUNS] = { { S_KNIFE, S_NULL, 0, 250, 50, 0, 0, 1, 1, 1, "knife" }, { S_PISTOL, S_RPISTOL, 1400, 170, 20, 0, 0, 20, 10, 8, "pistol" }, // *SGRAYS - { S_SHOTGUN, S_RSHOTGUN, 2400, 1100, 7, 0, 0, 1, 35, 7, "shotgun" }, - { S_SUBGUN, S_RSUBGUN, 1650, 90, 12, 0, 0, 45, 15, 30, "subgun" }, + { S_SHOTGUN, S_RSHOTGUN, 2400, 1100, 6, 0, 0, 1, 35, 7, "shotgun" }, //reload time is for 1 shell from 7 too powerful to 6 + { S_SUBGUN, S_RSUBGUN, 1650, 90, 14, 0, 0, 45, 15, 30, "subgun" }, { S_SNIPER, S_RSNIPER, 1950, 1500, 72, 0, 0, 60, 50, 5, "sniper" }, - { S_ASSULT, S_RASSULT, 2000, 130, 33, 0, 0, 90, 44, 20, "assult" }, + { S_ASSULT, S_RASSULT, 2000, 130, 33, 0, 0, 90, 40, 20, "assult" }, //recoil was 44 { S_GRENADE, S_NULL, 0, 2000, 40, 30, 6, 1, 1, 1, "grenade" }, }; @@ -50,6 +50,25 @@ void previous() COMMAND(next,ARG_NONE); COMMAND(previous,ARG_NONE); +void primary() +{ + player1->gunselect=player1->primary; +}; + +void secondary() +{ + player1->gunselect=GUN_PISTOL; +}; + +void melee() +{ + player1->gunselect=GUN_KNIFE; +}; + +COMMAND(primary,ARG_NONE); +COMMAND(secondary,ARG_NONE); +COMMAND(melee,ARG_NONE); + void reload() { if(player1->gunselect==GUN_KNIFE) return; @@ -60,11 +79,14 @@ void reload() player1->reloading = true; player1->lastaction = lastmillis; + int a = guns[player1->gunselect].magsize - player1->mag[player1->gunselect]; + player1->gunwait = guns[player1->gunselect].reloadtime; //temp hack in drawhudgun() so no guns drawn while reloading, needs fixed - int a = guns[player1->gunselect].magsize - player1->mag[player1->gunselect]; + + if (a >= player1->ammo[player1->gunselect]) { player1->mag[player1->gunselect] += player1->ammo[player1->gunselect]; @@ -287,7 +309,7 @@ void shootv(int gun, vec &from, vec &to, dynent *d, bool local) // create vi case GUN_SNIPER: particle_splash(0, 50, 200, to); - particle_trail(1, 500, from, to); + //particle_trail(1, 500, from, to); break; }; }; @@ -326,9 +348,12 @@ void spreadandrecoil(vec & from, vec & to, dynent * d) //recoil int rcl = guns[d->gunselect].recoil*-0.01f; - if ((d->gunselect==GUN_ASSULT) && (d->shots<=3)) + if (d->gunselect==GUN_ASSULT) { - spd = spd / 5; + if (d->shots<=3) + spd = spd / 5; + + rcl += (rnd(8)*-0.01f); }; if ((d->gunselect==GUN_SNIPER) && (d->vel.x<.25f && d->vel.y<.25f)) @@ -343,6 +368,8 @@ void spreadandrecoil(vec & from, vec & to, dynent * d) vec r = { RNDD, RNDD, RNDD }; vadd(to, r); }; + + //increase pitch for recoil vdiv(unitv, dist); @@ -402,3 +429,42 @@ void shoot(dynent *d, vec &targ) }; }; + + +void altattack(void) +{ + player1->altattack = !player1->altattack; + + switch(player1->gunselect) + { + case(GUN_SHOTGUN): + if(player1->mag[player1->gunselect]>=guns[player1->gunselect].magsize) return; + if(player1->ammo[player1->gunselect]<=0) return; + if(player1->reloading) return; + + player1->reloading = true; + player1->lastaction = lastmillis; + + player1->gunwait = guns[player1->gunselect].reloadtime / 2; + + if(player1->ammo[GUN_SHOTGUN]>1) + player1->mag[GUN_SHOTGUN]++; + player1->ammo[GUN_SHOTGUN]--; + + playsoundc(guns[player1->gunselect].reload); + break; + + case(GUN_SNIPER): + if(player1->altattack) + setvar("fov",getvar("fov")-55); + else + setvar("fov",getvar("fov")+55); + break; + + + } + + +}; + +COMMAND(altattack, ARG_NONE); diff --git a/source/src/world.cpp b/source/src/world.cpp index 46bbf811..d5d7a338 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -307,7 +307,8 @@ void empty_world(int factor, bool force) // main empty world creation routine s->defer = 0; }; - strncpy(hdr.head, "CUBE", 4); + //strncpy(hdr.head, "CUBE", 4); + strncpy(hdr.head, "ACMP", 4); hdr.version = MAPVERSION; hdr.headersize = sizeof(header); hdr.sfactor = sfactor; diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 1c0ba2cf..fedd06b2 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -242,7 +242,7 @@ void load_world(char *mname) // still supports all map formats that have }; - if (hdr.version