first run with items

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@29 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
arghvark
2005-08-18 20:23:06 +00:00
parent f31e26c5d3
commit dbbb59fcfa
8 changed files with 106 additions and 66 deletions
+3 -3
View File
@@ -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();
+3 -2
View File
@@ -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
+61 -35
View File
@@ -4,10 +4,10 @@
vector<entity> 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.type<I_SHOTGUN || e.type>I_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.type<I_CLIPS || e.type>I_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(v<itemstats[ents[i].type-I_SHOTGUN].max) // don't pick up if not needed
if(v<itemstats[ents[i].type-I_CLIPS].max) // don't pick up if not needed
{
//addmsg(1, 3, SV_ITEMPICKUP, i, m_classicsp ? 100000 : spawnsec); // first ask the server for an ack
addmsg(1, 3, SV_ITEMPICKUP, i, 10000); // first ask the server for an ack
addmsg(1, 3, SV_ITEMPICKUP, i, spawnsec); // first ask the server for an ack
ents[i].spawned = false; // even if someone else gets it first
};
};
*/
void additem(int i, int &v, int spawnsec, int t)
{
if(v<itemstats[t-1].max)
{
addmsg(1, 3, SV_ITEMPICKUP, i, spawnsec);
ents[i].spawned = false;
};
};
void pickup(int n, dynent *d)
{
@@ -128,20 +152,22 @@ void pickup(int n, dynent *d)
int ammo = np*2;
switch(ents[n].type)
{
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_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->primary<GUN_GRENADE)
{
d->ammo[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)
+4
View File
@@ -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;
+1 -1
View File
@@ -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", "?", "?", "?", "?",
+29 -13
View File
@@ -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()
{
+1 -1
View File
@@ -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;
+4 -11
View File
@@ -242,8 +242,9 @@ void load_world(char *mname) // still supports all map formats that have
};
if (hdr.version<MAPVERSION || strncmp(hdr.head,"CUBE",4)==0) //only render lights, pl starts and map models on old maps
if (hdr.version<MAPVERSION && strncmp(hdr.head,"CUBE",4)==0) //only render lights, pl starts and map models on old maps
{
switch(e.type)
{
case 1: //old light
@@ -253,16 +254,10 @@ void load_world(char *mname) // still supports all map formats that have
e.type=PLAYERSTART;
break;
case 3:
e.type=I_SHOTGUN;
break;
case 4:
e.type=I_SUBGUN;
break;
case 4:
case 5:
e.type=I_SNIPER;
break;
case 6:
e.type=I_ASSULT;
e.type=I_AMMO;
break;
case 7: //old health
e.type=I_HEALTH;
@@ -271,8 +266,6 @@ void load_world(char *mname) // still supports all map formats that have
e.type=I_HEALTH;
break;
case 9: //armor
e.type=I_ARMOUR;
break;
case 10: //armor
e.type=I_ARMOUR;
break;