From dbbb59fcfad8849e89a4a40ba31b5be1721f6ce4 Mon Sep 17 00:00:00 2001 From: arghvark Date: Thu, 18 Aug 2005 20:23:06 +0000 Subject: [PATCH] first run with items git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@29 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 6 +-- source/src/cube.h | 5 +- source/src/entities.cpp | 96 +++++++++++++++++++++++-------------- source/src/physics.cpp | 4 ++ source/src/renderextras.cpp | 2 +- source/src/weapon.cpp | 42 +++++++++++----- source/src/world.cpp | 2 +- source/src/worldio.cpp | 15 ++---- 8 files changed, 106 insertions(+), 66 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index e120eb99..d59f303b 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -234,7 +234,7 @@ void checkgame(int time) { //allow faster movements when editing - if (editmode) +/* if (editmode) { player1->maxspeed=22; return; @@ -247,7 +247,7 @@ void checkgame(int time) player1->maxspeed = 15; player1->maxspeed = 16; }; - +*/ //force to a team if team mode if (m_teammode) @@ -522,7 +522,7 @@ void initclient() void startmap(char *name) // called just after a map load { - //if(netmapstart()) { gamemode = 0;}; //needs fixed to switch modes? + if(netmapstart()) { gamemode = 0;}; //needs fixed to switch modes? 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 d996666f..a21120c0 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -1,4 +1,4 @@ -// one big bad include file for the whole engine... nasty! +/// one big bad include file for the whole engine... nasty! #include "tools.h" @@ -40,7 +40,8 @@ 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_SHOTGUN, I_SUBGUN, I_SNIPER, I_ASSULT, I_GRENADE, I_PISTOL, + I_CLIPS, I_AMMO,I_GRENADE, I_HEALTH, I_ARMOUR, I_QUAD, MAPMODEL, // attr1 = angle, attr2 = idx CARROT, // attr1 = tag, attr2 = type diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 03314829..32797a7c 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -4,10 +4,10 @@ vector ents; -//fill in 2nd rrounds wth grenade, 3rd with plasma char *entmdlnames[] = { - "shells", "bullets", "rockets", "rrounds", "rrounds", "rrounds", "health", "armour", "quad", +//FIXME : fix the "pickups" infront + "pickups/pistolclips", "pickups/ammobox", "ammobox" /*grenade*/, "pickups/health", "pickups/kevlar", "ammobox" /*dual pistols*/, }; int triggertime = 0; @@ -19,7 +19,7 @@ void renderent(entity &e, char *mdlname, float z, float yaw, int frame = 0, int void renderentities() { - if(lastmillis>triggertime+1000) triggertime = 0; + if(lastmillis>triggertime+1000) triggertime = 0; loopv(ents) { entity &e = ents[i]; @@ -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_CLIPS], (float)(1+sin(lastmillis/100.0+e.x+e.y)/20), lastmillis/10.0f); } else switch(e.attr2) { @@ -59,14 +59,14 @@ void renderentities() struct itemstat { int add, max, sound; } itemstats[] = { + 16, 48, S_ITEMAMMO, //pistol 7, 14, S_ITEMAMMO, //shotgun 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 - 25, 100, S_ITEMHEALTH, //health - 100, 150, S_ITEMARMOUR, //armour + 33, 100, S_ITEMHEALTH, //health + 50, 100, S_ITEMARMOUR, //armour 20000, 30000, S_ITEMPUP, //powerup }; @@ -75,9 +75,20 @@ void baseammo(int gun) { player1->ammo[gun] = itemstats[gun-1].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) { - itemstat &is = itemstats[ents[i].type-I_SHOTGUN]; + itemstat &is = itemstats[ents[i].type-I_CLIPS]; + ents[i].spawned = false; + v += is.add; + if(v>is.max) v = is.max; + playsoundc(is.sound); +}; +*/ + +void radditem(int i, int &v, int t) +{ + itemstat &is = itemstats[t-1]; ents[i].spawned = false; v += is.add; if(v>is.max) v = is.max; @@ -88,37 +99,50 @@ 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_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_GRENADE: radditem(n, d->ammo[6]); break; - case I_HEALTH: radditem(n, d->health); break; + //case I_PISTOL: radditem(n, d->ammo[1]); break; + //case I_SHOTGUN: 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_CLIPS: radditem(n, d->ammo[1], 1); break; + case I_AMMO: radditem(n, d->ammo[d->primary], d->primary); break; + case I_GRENADE: radditem(n, d->ammo[6], 6); break; + case I_HEALTH: radditem(n, d->health, 7); break; case I_ARMOUR: - radditem(n, d->armour); + radditem(n, d->armour, 8); d->armourtype = A_YELLOW; break; case I_QUAD: - radditem(n, d->quadmillis); - conoutf("you got the quad!"); + radditem(n, d->quadmillis, 9); + conoutf("a lesser man would use a single pistol"); break; }; }; // these functions are called when the client touches the item +/* 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_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_GRENADE: additem(n, d->ammo[6], ammo); break; - case I_HEALTH: additem(n, d->health, np*5); break; + //case I_PISTOL: additem(n, d->ammo[1], ammo); break; + //case I_SHOTGUN: 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_CLIPS: additem(n, d->ammo[1], ammo, 1); break; + case I_AMMO: additem(n, d->ammo[d->primary], ammo, d->primary); break; + case I_GRENADE: additem(n, d->ammo[6], ammo, 6); break; + case I_HEALTH: additem(n, d->health, np*5, 7); break; case I_ARMOUR: - additem(n, d->armour, 20); + additem(n, d->armour, 20, 8); break; case I_QUAD: - additem(n, d->quadmillis, 60); + additem(n, d->quadmillis, 60, 9); break; case CARROT: @@ -170,7 +196,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_CLIPS && ents[i].type<=I_QUAD) || ents[i].type==CARROT) { putint(p, i); ents[i].spawned = true; @@ -194,20 +220,20 @@ void radd(dynent *d) } else if (d->primary>GUN_PISTOL && d->primaryammo[d->primary] = itemstats[d->primary-2].max; - d->mag[d->primary] = itemstats[d->primary-2].add; + d->ammo[d->primary] = itemstats[d->primary-1].max; + d->mag[d->primary] = itemstats[d->primary-1].add; } else if (d->primary==GUN_GRENADE) { conoutf("you don't have to worry about blowing your hand off just yet..."); } - /* + if (d->armour) { d->armour = 100; } - */ + }; void add(int num) diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 703dbb13..03c6b939 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -190,6 +190,10 @@ void selfdamage(dynent * d, int dm) void moveplayer(dynent *pl, int moveres, bool local, int curtime) { + if (pl->armour > 0) + pl->maxspeed = 14; + else pl->maxspeed = 16; + const bool water = hdr.waterlevel>pl->o.z-0.5f; const bool floating = (editmode && local) || pl->state==CS_EDITING; diff --git a/source/src/renderextras.cpp b/source/src/renderextras.cpp index d07ecc27..4182d6ed 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", + "clips", "ammobox","grenade", "health", "armour", "quaddamage", "mapmodel", "trigger", "ladder", "?", "?", "?", "?", diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 446b004d..f7734012 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -10,19 +10,18 @@ vec sg[SGRAYS]; //change the particales 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_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_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, 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, 40, 20, "assult" }, //recoil was 44 { S_GRENADE, S_NULL, 0, 2000, 40, 30, 6, 1, 1, 1, "grenade" }, - }; //weapon selection -void next() +void wup() { if(player1->gunselect==GUN_KNIFE) player1->gunselect = GUN_PISTOL; @@ -34,7 +33,7 @@ void next() conoutf("%s selected", (int)guns[player1->gunselect].name); }; -void previous() +void wdw() { if(player1->gunselect==GUN_KNIFE) player1->gunselect = player1->primary; @@ -46,9 +45,26 @@ void previous() conoutf("%s selected", (int)guns[player1->gunselect].name); }; - -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); +COMMAND(wup,ARG_NONE); +COMMAND(wdw,ARG_NONE); void reload() { diff --git a/source/src/world.cpp b/source/src/world.cpp index 46bbf811..daaf2c92 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -307,7 +307,7 @@ void empty_world(int factor, bool force) // main empty world creation routine s->defer = 0; }; - 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..debfda43 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -242,8 +242,9 @@ void load_world(char *mname) // still supports all map formats that have }; - if (hdr.version