random double nade spawn for lss, this opens the possibility to have other double items, like double armor... idk

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5021 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Rafael Barreto
2010-05-23 20:58:42 +00:00
parent 717827f4b6
commit 2282336244
4 changed files with 28 additions and 12 deletions
+14 -7
View File
@@ -6,15 +6,16 @@ vector<entity> ents;
const char *entmdlnames[] =
{
"pickups/pistolclips", "pickups/ammobox", "pickups/nades", "pickups/health", "pickups/helmet", "pickups/kevlar", "pickups/akimbo",
"pickups/pistolclips", "pickups/ammobox", "pickups/nade", "pickups/health", "pickups/helmet", "pickups/kevlar", "pickups/akimbo", "pickups/nades", //FIXME
};
void renderent(entity &e)
{
const char *mdlname = entmdlnames[e.type-I_CLIPS];
/* FIXME: if the item list change, this "e.twice?5:0" will be messed, but it is useless to provide a general fix for now */
const char *mdlname = entmdlnames[e.type-I_CLIPS+(e.twice&&e.type==I_GRENADE?5:0)];
float z = (float)(1+sinf(lastmillis/100.0f+e.x+e.y)/20),
yaw = lastmillis/10.0f;
rendermodel(mdlname, ANIM_MAPMODEL|ANIM_LOOP|ANIM_DYNALLOC, 0, 0, vec(e.x, e.y, z+S(e.x, e.y)->floor+e.attr1), yaw, 0);
rendermodel(mdlname, ANIM_MAPMODEL|ANIM_LOOP|ANIM_DYNALLOC, 0, 0, vec(e.x, e.y, z+S(e.x, e.y)->floor+e.attr1), yaw, 0);
}
void renderclip(entity &e)
@@ -287,19 +288,25 @@ void spawnallitems() // spawns items locally
loopv(ents) if(ents[i].fitsmode(gamemode) || (multiplayer(false) && gamespeed!=100 && (i=-1)))
{
ents[i].spawned = true;
ents[i].twice = false;
}
}
void resetspawns(int type)
{
loopv(ents) if(type < 0 || type == ents[i].type) ents[i].spawned = false;
if(m_noitemsnade || m_pistol)
loopv(ents) if(type < 0 || type == ents[i].type) ents[i].twice = ents[i].spawned = false;
if(m_noitemsnade || m_pistol)
{
loopv(ents) ents[i].transformtype(gamemode);
loopv(ents) ents[i].transformtype(gamemode);
}
}
void setspawn(int i, bool on) { if(ents.inrange(i)) ents[i].spawned = on; }
void setspawn(int i, bool on) {
if(ents.inrange(i)) {
ents[i].twice = (ents[i].type == I_GRENADE && ents[i].spawned && on ? true : false);
ents[i].spawned = on;
}
}
bool selectnextprimary(int num)
{
+2 -2
View File
@@ -31,8 +31,8 @@ struct persistent_entity // map entity
struct entity : persistent_entity
{
bool spawned; //the only dynamic state of a map entity
entity(short x, short y, short z, uchar type, short attr1, uchar attr2, uchar attr3, uchar attr4) : persistent_entity(x, y, z, type, attr1, attr2, attr3, attr4), spawned(false) {}
bool spawned, twice; //the dynamic states of a map entity
entity(short x, short y, short z, uchar type, short attr1, uchar attr2, uchar attr3, uchar attr4) : persistent_entity(x, y, z, type, attr1, attr2, attr3, attr4), spawned(false), twice(false) {}
entity() {}
bool fitsmode(int gamemode) { return !m_noitems && isitem(type) && !(m_noitemsnade && type!=I_GRENADE) && !(m_pistol && type==I_AMMO); }
void transformtype(int gamemode)
+11 -2
View File
@@ -1272,8 +1272,12 @@ bool serverpickup(int i, int sender) // server side item pickup, acknowl
}
sendf(-1, 1, "ri3", SV_ITEMACC, i, sender);
cl->state.pickup(sents[i].type);
if (e.twice) {
sendf(-1, 1, "ri3", SV_ITEMACC, i, sender);
cl->state.pickup(sents[i].type);
}
}
e.spawned = false;
e.spawned = e.twice = false;
if(!m_lms) e.spawntime = spawntime(e.type);
return true;
}
@@ -1289,6 +1293,10 @@ void checkitemspawns(int diff)
sents[i].spawntime = 0;
sents[i].spawned = true;
sendf(-1, 1, "ri2", SV_ITEMSPAWN, i);
if (m_lss && sents[i].type == I_GRENADE && rnd(101) > 70 ) {
sents[i].twice = true;
sendf(-1, 1, "ri2", SV_ITEMSPAWN, i);
}
}
}
}
@@ -1678,9 +1686,10 @@ void startgame(const char *newname, int newmode, int newtime, bool notify)
{
e.type = smapstats.enttypes[i];
e.transformtype(smode);
server_entity se = { e.type, false, false, 0, smapstats.entposs[i * 3], smapstats.entposs[i * 3 + 1]};
server_entity se = { e.type, false, false, false, 0, smapstats.entposs[i * 3], smapstats.entposs[i * 3 + 1]};
sents.add(se);
if(e.fitsmode(smode)) sents[i].spawned = sents[i].legalpickup = true;
sents[i].twice = false;
}
mapbuffer.setrevision();
logline(ACLOG_INFO, "Map height density information for %s: H = %.2f V = %d, A = %d and MA = %d", smapname, Mheight, Mvolume, Marea, Mopen);
+1 -1
View File
@@ -298,7 +298,7 @@ struct worldstate
struct server_entity // server side version of "entity" type
{
int type;
bool spawned, legalpickup;
bool spawned, legalpickup, twice;
int spawntime;
short x, y;
};