windows happy source

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@17 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
arghvark
2005-06-25 12:31:31 +00:00
parent da6a8c361b
commit e861911adb
6 changed files with 817 additions and 814 deletions
+566 -566
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -44,7 +44,7 @@ void toggleedit()
else
{
resettagareas(); // clear trigger areas to allow them to be edited
player1->health = 100;
player1->health = 100;
//put call to clear/restar gamemode
projreset();
};
+246 -243
View File
@@ -1,244 +1,247 @@
// entities.cpp: map entity related functions (pickup etc.)
#include "cube.h"
vector<entity> ents;
//fill in 2nd rrounds wth grenade, 3rd with plasma
char *entmdlnames[] =
{
"shells", "bullets", "rockets", "rrounds", "rrounds", "rrounds", "health", "armour", "quad",
};
int triggertime = 0;
void renderent(entity &e, char *mdlname, float z, float yaw, int frame = 0, int numf = 1, int basetime = 0, float speed = 10.0f)
{
rendermodel(mdlname, frame, numf, 0, 1.1f, e.x, z+S(e.x, e.y)->floor, e.y, yaw, 0, false, 1.0f, speed, 0, basetime);
};
void renderentities()
{
if(lastmillis>triggertime+1000) triggertime = 0;
loopv(ents)
{
entity &e = ents[i];
if(e.type==MAPMODEL)
{
mapmodelinfo &mmi = getmminfo(e.attr2);
if(!&mmi) continue;
rendermodel(mmi.name, 0, 1, e.attr4, (float)mmi.rad, e.x, (float)S(e.x, e.y)->floor+mmi.zoff+e.attr3, e.y, (float)((e.attr1+7)-(e.attr1+7)%15), 0, false, 1.0f, 10.0f, mmi.snap);
}
else
{
if(OUTBORD(e.x, e.y)) continue;
if(e.type!=CARROT)
{
if(!e.spawned) continue;
if(e.type<I_AMMO || e.type>I_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)
{
case 1:
case 3:
continue;
case 2:
case 0:
if(!e.spawned) continue;
renderent(e, "carrot", (float)(1+sin(lastmillis/100.0+e.x+e.y)/20), lastmillis/(e.attr2 ? 1.0f : 10.0f));
break;
case 4: renderent(e, "switch2", 3, (float)e.attr3*90, (!e.spawned && !triggertime) ? 1 : 0, (e.spawned || !triggertime) ? 1 : 2, triggertime, 1050.0f); break;
case 5: renderent(e, "switch1", -0.15f, (float)e.attr3*90, (!e.spawned && !triggertime) ? 30 : 0, (e.spawned || !triggertime) ? 1 : 30, triggertime, 35.0f); break;
};
};
};
};
struct itemstat { int add, max, sound; } itemstats[] =
{
7, 14, S_ITEMAMMO, //shotgun
30, 90, S_ITEMAMMO, //subgun
5, 15, S_ITEMAMMO, //sniper
20, 40, S_ITEMAMMO, //assult
5, 10, S_ITEMAMMO, //pistol
1, 2, S_ITEMAMMO, //grenade
25, 100, S_ITEMHEALTH, //health
100, 125, S_ITEMARMOUR, //armour
20000, 30000, S_ITEMPUP, //powerup
};
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_AMMO];
ents[i].spawned = false;
v += is.add;
if(v>is.max) v = is.max;
playsoundc(is.sound);
};
void realpickup(int n, dynent *d)
{
switch(ents[n].type)
{
/* 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_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->hasarmour = true;
break;
case I_QUAD:
radditem(n, d->quadmillis);
conoutf("you got the quad!");
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_AMMO].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
ents[i].spawned = false; // even if someone else gets it first
};
};
void pickup(int n, dynent *d)
{
int np = 1;
loopv(players) if(players[i]) np++;
np = np<3 ? 4 : (np>4 ? 2 : 3); // spawn times are dependent on number of players
int ammo = np*2;
switch(ents[n].type)
{
/*
case I_PISTOL: additem(n, d->ammo[1], 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_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:
additem(n, d->armour, 20);
break;
case I_QUAD:
additem(n, d->quadmillis, 60);
break;
case CARROT:
ents[n].spawned = false;
triggertime = lastmillis;
trigger(ents[n].attr1, ents[n].attr2, false); // needs to go over server for multiplayer
break;
};
};
void checkitems()
{
if(editmode) return;
loopv(ents)
{
entity &e = ents[i];
if(e.type==NOTUSED) continue;
if(!ents[i].spawned) continue;
if(OUTBORD(e.x, e.y)) continue;
vec v = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight };
vdist(dist, t, player1->o, v);
if(dist<2.5) pickup(i, player1);
};
};
void putitems(uchar *&p) // puts items in network stream and also spawns them locally
{
loopv(ents) if((ents[i].type>=I_AMMO && ents[i].type<=I_QUAD) || ents[i].type==CARROT)
{
putint(p, i);
ents[i].spawned = true;
};
};
void resetspawns() { loopv(ents) ents[i].spawned = false; };
void setspawn(int i, bool on) { if(i<ents.length()) ents[i].spawned = on; };
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;
}
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;
}
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;
}
*/
//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<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");
};
// entities.cpp: map entity related functions (pickup etc.)
#include "cube.h"
vector<entity> ents;
//fill in 2nd rrounds wth grenade, 3rd with plasma
char *entmdlnames[] =
{
"shells", "bullets", "rockets", "rrounds", "rrounds", "rrounds", "health", "armour", "quad",
};
int triggertime = 0;
void renderent(entity &e, char *mdlname, float z, float yaw, int frame = 0, int numf = 1, int basetime = 0, float speed = 10.0f)
{
rendermodel(mdlname, frame, numf, 0, 1.1f, e.x, z+S(e.x, e.y)->floor, e.y, yaw, 0, false, 1.0f, speed, 0, basetime);
};
void renderentities()
{
if(lastmillis>triggertime+1000) triggertime = 0;
loopv(ents)
{
entity &e = ents[i];
if(e.type==MAPMODEL)
{
mapmodelinfo &mmi = getmminfo(e.attr2);
if(!&mmi) continue;
rendermodel(mmi.name, 0, 1, e.attr4, (float)mmi.rad, e.x, (float)S(e.x, e.y)->floor+mmi.zoff+e.attr3, e.y, (float)((e.attr1+7)-(e.attr1+7)%15), 0, false, 1.0f, 10.0f, mmi.snap);
}
else
{
if(OUTBORD(e.x, e.y)) continue;
if(e.type!=CARROT)
{
if(!e.spawned) continue;
if(e.type<I_AMMO || e.type>I_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)
{
case 1:
case 3:
continue;
case 2:
case 0:
if(!e.spawned) continue;
renderent(e, "carrot", (float)(1+sin(lastmillis/100.0+e.x+e.y)/20), lastmillis/(e.attr2 ? 1.0f : 10.0f));
break;
case 4: renderent(e, "switch2", 3, (float)e.attr3*90, (!e.spawned && !triggertime) ? 1 : 0, (e.spawned || !triggertime) ? 1 : 2, triggertime, 1050.0f); break;
case 5: renderent(e, "switch1", -0.15f, (float)e.attr3*90, (!e.spawned && !triggertime) ? 30 : 0, (e.spawned || !triggertime) ? 1 : 30, triggertime, 35.0f); break;
};
};
};
};
struct itemstat { int add, max, sound; } itemstats[] =
{
7, 14, S_ITEMAMMO, //shotgun
30, 90, S_ITEMAMMO, //subgun
5, 15, S_ITEMAMMO, //sniper
20, 40, S_ITEMAMMO, //assult
5, 10, S_ITEMAMMO, //pistol
1, 2, S_ITEMAMMO, //grenade
25, 100, S_ITEMHEALTH, //health
100, 125, S_ITEMARMOUR, //armour
20000, 30000, S_ITEMPUP, //powerup
};
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_AMMO];
ents[i].spawned = false;
v += is.add;
if(v>is.max) v = is.max;
playsoundc(is.sound);
};
void realpickup(int n, dynent *d)
{
switch(ents[n].type)
{
/* 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_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->hasarmour = true;
break;
case I_QUAD:
radditem(n, d->quadmillis);
conoutf("you got the quad!");
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_AMMO].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
ents[i].spawned = false; // even if someone else gets it first
};
};
void pickup(int n, dynent *d)
{
int np = 1;
loopv(players) if(players[i]) np++;
np = np<3 ? 4 : (np>4 ? 2 : 3); // spawn times are dependent on number of players
int ammo = np*2;
switch(ents[n].type)
{
/*
case I_PISTOL: additem(n, d->ammo[1], 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_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:
additem(n, d->armour, 20);
break;
case I_QUAD:
additem(n, d->quadmillis, 60);
break;
case CARROT:
ents[n].spawned = false;
triggertime = lastmillis;
trigger(ents[n].attr1, ents[n].attr2, false); // needs to go over server for multiplayer
break;
};
};
void checkitems()
{
if(editmode) return;
loopv(ents)
{
entity &e = ents[i];
if(e.type==NOTUSED) continue;
if(!ents[i].spawned) continue;
if(OUTBORD(e.x, e.y)) continue;
vec v = { e.x, e.y, S(e.x, e.y)->floor+player1->eyeheight };
vdist(dist, t, player1->o, v);
if(dist<2.5) pickup(i, player1);
};
};
void putitems(uchar *&p) // puts items in network stream and also spawns them locally
{
loopv(ents) if((ents[i].type>=I_AMMO && ents[i].type<=I_QUAD) || ents[i].type==CARROT)
{
putint(p, i);
ents[i].spawned = true;
};
};
void resetspawns() { loopv(ents) ents[i].spawned = false; };
void setspawn(int i, bool on) { if(i<ents.length()) ents[i].spawned = on; };
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;
}
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;
}
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;
}
*/
//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<6) player1->nextprimary = num;
else
{
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);
+1 -1
View File
@@ -357,7 +357,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat
if (!player1->reloading && player1->gunselect!=GUN_KNIFE)
{
//draw_textf("%d", 690, 827, 2, player1->mag[player1->gunselect]);
char * gunstats;
char gunstats[64];
sprintf(gunstats,"%i/%i",player1->mag[player1->gunselect],player1->ammo[player1->gunselect]);
draw_text(gunstats, 690, 827, 2);
//clean up pointer?
+1 -1
View File
@@ -105,7 +105,7 @@ void loadgamerest()
{
if(demoplayback || !f) return;
if(gzgeti()!=ents.length()) return loadgameout();
if(gzgeti()!=ents.length()) { loadgameout(); return; }
loopv(ents)
{
ents[i].spawned = gzgetc(f)!=0;
+2 -2
View File
@@ -292,7 +292,7 @@ void load_world(char *mname) // still supports all map formats that have
free(world);
setupworld(hdr.sfactor);
char texuse[256];
loopi(256) texuse[i] = 0;
loopj(256) texuse[j] = 0;
sqr *t = NULL;
loopk(cubicsize)
{
@@ -358,7 +358,7 @@ void load_world(char *mname) // still supports all map formats that have
calclight();
settagareas();
int xs, ys;
loopi(256) if(texuse) lookuptexture(i, xs, ys);
loop(g, 256) if(texuse) lookuptexture(g, xs, ys);
conoutf("read map %s (%d milliseconds)", (int)cgzname, SDL_GetTicks()-lastmillis);
conoutf("%s", (int)hdr.maptitle);
startmap(mname);