diff --git a/source/src/bot/ac_bot.cpp b/source/src/bot/ac_bot.cpp index e3d8e905..27ae0e01 100644 --- a/source/src/bot/ac_bot.cpp +++ b/source/src/bot/ac_bot.cpp @@ -30,7 +30,7 @@ void CACBot::Spawn() m_pMyEnt->primary = m_pMyEnt->nextprimary = 2 + rnd(4); m_pMyEnt->targetyaw = m_pMyEnt->targetpitch = 0.0f; - radd(this->m_pMyEnt); + equip(this->m_pMyEnt); m_pMyEnt->armour = 50; m_pMyEnt->pBot = this; diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index fe106946..98fe9985 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -40,15 +40,16 @@ void spawnstate(playerent *d) // reset player state not persistent if(d==player1) { gun_changed = true; - player1->primary = player1->nextprimary; + //player1->primary = m_pistol ? GUN_PISTOL : (m_ss ? GUN_SNIPER : player1->nextprimary); + player1->primary = m_osok ? GUN_SNIPER : player1->nextprimary; if(player1->skin!=player1->nextskin) { c2sinit=false; player1->skin=player1->nextskin; } - scoped = false; + setscope(false); }; - radd(d); + equip(d); dblend = 0; }; diff --git a/source/src/command.cpp b/source/src/command.cpp index 14f5c181..6d8ffd70 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -328,6 +328,4 @@ int gt(int a, int b) { return (int)(a>b); }; COMMANDN(>, gt, ARG_2EXP); int strcmpa(char *a, char *b) { return strcmp(a,b)==0; }; COMMANDN(strcmp, strcmpa, ARG_2EST); -int rndn(int a) { return a>0 ? rnd(a) : 0; }; COMMANDN(rnd, rndn, ARG_1EXP); - - +int rndn(int a) { return a>0 ? rnd(a) : 0; }; COMMANDN(rnd, rndn, ARG_1EXP); \ No newline at end of file diff --git a/source/src/cube.h b/source/src/cube.h index 403692bc..dfe140bc 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -180,8 +180,7 @@ struct vec struct block { int x, y, xs, ys; }; enum { GUN_KNIFE = 0, GUN_PISTOL, GUN_SHOTGUN, GUN_SUBGUN, GUN_SNIPER, GUN_ASSAULT, GUN_GRENADE, NUMGUNS }; -enum { G_PRIMARY = 0, G_SECONDARY, G_MELEE, G_GRENADE, G_NUM }; -#define reloadable_gun(g) (g!=GUN_KNIFE || g!=GUN_GRENADE) +#define reloadable_gun(g) (g != GUN_KNIFE || g != GUN_GRENADE) enum { MCMD_KICK = 0, MCMD_BAN, MCMD_REMBANS }; @@ -363,7 +362,6 @@ struct playerent : dynent health = 100; armour = 0; hasarmour = false; - //armourtype = A_BLUE; lastaction = akimbolastaction[0] = akimbolastaction[1] = 0; akimbomillis = 0; gunselect = GUN_PISTOL; @@ -535,20 +533,25 @@ extern bool demoplayback; 7 bot tdm 8 bot dm 9 last swiss standing -10 last sniper standing +10 sniper survivor */ +#define m_ctf (gamemode==5) +#define m_pistol (gamemode==6) +#define m_lss (gamemode==9) +#define m_osok (gamemode==10) + #define m_noitems (gamemode==3 || gamemode==4 || gamemode==10) #define m_noitemsnade (gamemode==9) -#define m_nogun (gamemode==9) +#define m_nopistol (gamemode==10) +#define m_noprimary (m_pistol) +#define m_noguns (m_nopistol && m_noprimary) #define m_noitemsrail (false) #define m_arena (gamemode==3 || gamemode==4 || gamemode==9 || gamemode==10) #define m_tarena (gamemode==4) #define m_teammode (gamemode==0 || gamemode==4 || gamemode==5 || gamemode==7) #define m_botmode (gamemode==7 || gamemode == 8) -#define m_ctf (gamemode==5) -#define m_pistol (gamemode==6) -#define m_lss (gamemode==9) + //#define m_sp (gamemode<0) //#define m_dmsp (gamemode==-1) diff --git a/source/src/entities.cpp b/source/src/entities.cpp index c002a46a..85f86ba4 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -100,7 +100,7 @@ void baseammo(int gun, playerent *d) { d->ammo[gun] = itemstats[gun].add*2; }; // these two functions are called when the server acknowledges that you really // picked up the item (in multiplayer someone may grab it before you). -void radditem(int i, int &v, int t) +void equipitem(int i, int &v, int t) { itemstat &is = itemstats[t]; ents[i].spawned = false; @@ -116,26 +116,26 @@ void realpickup(int n, playerent *d) switch(ents[n].type) { case I_CLIPS: - radditem(n, d->ammo[1], 1); + equipitem(n, d->ammo[1], 1); break; case I_AMMO: - radditem(n, d->ammo[d->primary], d->primary); + equipitem(n, d->ammo[d->primary], d->primary); break; case I_GRENADE: - radditem(n, d->mag[6], 6); + equipitem(n, d->mag[6], 6); player1->thrownademillis = 0; break; case I_HEALTH: - radditem(n, d->health, 7); + equipitem(n, d->health, 7); break; case I_ARMOUR: - radditem(n, d->armour, 8); + equipitem(n, d->armour, 8); //d->hasarmour = true; break; case I_AKIMBO: d->akimbomillis = lastmillis+30000; d->mag[GUN_PISTOL] = 16; - radditem(n, d->ammo[1], 9); + equipitem(n, d->ammo[1], 9); weaponswitch(GUN_PISTOL); break; }; @@ -264,7 +264,7 @@ void resetspawns() }; void setspawn(int i, bool on) { if(i=0) ents[i].spawned = on; }; -void radd(playerent *d) +void equip(playerent *d) { loopi(NUMGUNS) if(d->nextprimary!=i) d->ammo[i] = 0; @@ -273,7 +273,6 @@ void radd(playerent *d) if(m_pistol || d->primary==GUN_PISTOL) // pistol only mode { - d->primary = GUN_PISTOL; d->ammo[GUN_PISTOL] = itemstats[GUN_PISTOL].max; } if(m_lss) @@ -281,7 +280,7 @@ void radd(playerent *d) d->mag[d->primary] = d->mag[GUN_PISTOL] = 0; d->primary = GUN_KNIFE; } - else if(!m_nogun) + else if(!m_noguns) { d->ammo[GUN_PISTOL] = itemstats[GUN_PISTOL].start-magsize(GUN_PISTOL); d->mag[GUN_PISTOL] = magsize(GUN_PISTOL); diff --git a/source/src/main.cpp b/source/src/main.cpp index 833c77fb..c9a06172 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -292,6 +292,9 @@ int main(int argc, char **argv) loadingscreen(); + log("hudgun models"); + preload_hudguns(); + log("sound"); initsound(); diff --git a/source/src/protos.h b/source/src/protos.h index 5e8624b7..32acf271 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -231,6 +231,8 @@ extern void rendermodel(char *mdl, int anim, int tex, float rad, float x, float extern mapmodelinfo &getmminfo(int i); extern int findanim(const char *name); extern void loadskin(const char *dir, const char *altdir, Texture *&skin, model *m); +extern void preload_hudguns(); +extern void preload_mapmodels(); // hudgun extern void renderhudgun(); @@ -292,7 +294,7 @@ extern void resetspawns(); extern void setspawn(int i, bool on); extern void baseammo(int gun, playerent *d); extern void checkitems(); -extern void radd(playerent *d); +extern void equip(playerent *d); extern bool intersect(entity *e, vec &from, vec &to, vec *end=NULL); // rndmap diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 0c5e9a40..cda1f50f 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -159,3 +159,8 @@ void preload_mapmodels() }; }; +extern void renderhudgun(int gun, int lastaction, int index = 0); +void preload_hudguns() +{ + loopi(NUMGUNS) renderhudgun(i, 0); +} \ No newline at end of file diff --git a/source/src/server.cpp b/source/src/server.cpp index bbe70148..b2a43773 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -5,7 +5,7 @@ // fixme: share with clientside gamemode #define m_ctf_s (mode==5) -#define m_teammode_s (mode==0 || mode==4 || mode==5) +#define m_teammode_s (mode==0 || mode==4 || mode==5 || mode==7) #define valid_client(c) (clients.inrange(c) && clients[c]->type!=ST_EMPTY) #define valid_flag(f) (f >= 0 && f < 2) @@ -407,10 +407,10 @@ void resetvotes() loopv(clients) clients[i]->mapvote[0] = 0; }; -void resetmap(const char *newname, int newmode, int newtime, bool notify = true) +void resetmap(const char *newname, int newmode, int newtime = -1, bool notify = true) { mode = newmode; - minremain = newtime; + minremain = newtime >= 0 ? newtime : (m_teammode_s ? 15 : 10); s_strcpy(smapname, newname); mapend = lastsec+minremain*60; @@ -625,7 +625,7 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1 int reqmode = getint(p); if(reqmode<0) reqmode = 0; if(smapname[0] && !mapreload && !vote(text, reqmode, sender)) return; - resetmap(text, reqmode, m_ctf_s ? 10 : (m_teammode_s ? 15 : 10)); + resetmap(text, reqmode); break; }; diff --git a/source/src/serverutil.cpp b/source/src/serverutil.cpp index 0b298668..59dbfe0c 100644 --- a/source/src/serverutil.cpp +++ b/source/src/serverutil.cpp @@ -77,7 +77,7 @@ void getstring(char *text, ucharbuf &p, int len) const char *modenames[] = { "team deathmatch", "coopedit", "deathmatch", "survior", - "team survior", "ctf", "pistols frenzy", "bot team deathmatch", "bot deathmatch", "last swiss standing", "last sniper standing" + "team survior", "ctf", "pistols frenzy", "bot team deathmatch", "bot deathmatch", "last swiss standing", "one shot, one kill" }; const char *modestr(int n) { return (n>=0 && (size_t)n < sizeof(modenames)/sizeof(modenames[0])) ? modenames[n] : "unknown"; }; diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 6a357341..83eaa2cd 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -59,44 +59,37 @@ void weaponswitch(int gun) playsound(S_GUNCHANGE); }; +int currentprimary() { return player1->primary; }; + void weapon(int gun) { - if(m_nogun && gun!=G_MELEE && gun!=G_GRENADE) return; - if(player1->state!=CS_ALIVE || player1->weaponchanging) return; + if(player1->state!=CS_ALIVE || player1->weaponchanging || NADE_IN_HAND || player1->reloading) return; + if(gun != GUN_KNIFE && gun != GUN_GRENADE && gun != GUN_PISTOL && gun != player1->primary) return; + + if(m_noguns && gun != GUN_KNIFE && gun != GUN_GRENADE) return; + if(m_noprimary && gun != GUN_KNIFE && gun != GUN_GRENADE && gun != GUN_KNIFE) return; + if(m_nopistol && gun == GUN_PISTOL) return; + if(gun == GUN_GRENADE && !player1->mag[GUN_GRENADE]) return; + setscope(false); - if(NADE_IN_HAND || player1->reloading) return; - - gun %= G_NUM; - if(gun<0) gun = G_NUM+gun; - switch(gun) - { - case G_PRIMARY: gun=player1->primary; break; - case G_SECONDARY: gun=GUN_PISTOL; break; - case G_MELEE: gun=GUN_KNIFE; break; - case G_GRENADE: if(player1->mag[GUN_GRENADE]) gun=GUN_GRENADE; else return; - }; - - if(gun!=player1->gunselect) weaponswitch(gun); + + weaponswitch(gun); }; -void shiftweapon(int i) +void shiftweapon(int s) { - if(player1->state!=CS_ALIVE || player1->weaponchanging) return; - int gun; - switch(player1->gunselect) + for(int i = 0; i < NUMGUNS && !player1->weaponchanging; i++) { - 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; + int trygun = player1->gunselect + s + (s < 0 ? -i : i); + if((trygun %= NUMGUNS) < 0) trygun += NUMGUNS; + weapon(trygun); }; - gun += i; - weapon(gun); - for(int j = 0; j <= G_NUM && !player1->weaponchanging; j++) { gun += i > 0 ? 1 : -1; weapon(gun); } -} +}; COMMAND(weapon, ARG_1INT); COMMAND(shiftweapon, ARG_1INT); +COMMAND(currentprimary, ARG_1EST); + VAR(scopefov, 5, 50, 50); bool scoped = false; diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 69e11566..dd07e2d6 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -207,7 +207,6 @@ void save_world(char *mname) }; extern void preparectf(bool cleanonly = false); -extern void preload_mapmodels(); void load_world(char *mname) // still supports all map formats that have existed since the earliest cube betas! {