git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@28 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2005-08-14 17:49:15 +00:00
parent a1bba487b4
commit f31e26c5d3
19 changed files with 1200 additions and 2361 deletions
+22 -325
View File
@@ -13,15 +13,14 @@ 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, 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_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, 40, 20, "assult" }, //recoil was 44
{ S_ASSULT, S_RASSULT, 2000, 130, 33, 0, 0, 90, 44, 20, "assult" },
{ S_GRENADE, S_NULL, 0, 2000, 40, 30, 6, 1, 1, 1, "grenade" },
};
//weapon selection
void next()
{
@@ -51,25 +50,6 @@ void previous()
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);
void reload()
{
if(player1->gunselect==GUN_KNIFE) return;
@@ -80,14 +60,11 @@ void reload()
player1->reloading = true;
player1->lastaction = lastmillis;
int a = guns[player1->gunselect].magsize - player1->mag[player1->gunselect];
player1->gunwait = guns[player1->gunselect].reloadtime;
//temp hack in drawhudgun() so no guns drawn while reloading, needs fixed
int a = guns[player1->gunselect].magsize - player1->mag[player1->gunselect];
if (a >= player1->ammo[player1->gunselect])
{
player1->mag[player1->gunselect] += player1->ammo[player1->gunselect];
@@ -105,7 +82,7 @@ void reload()
COMMAND(reload,ARG_NONE);
int reloadtime(int gun) { return guns[gun].attackdelay; };
int delaytime(int gun) { return guns[gun].attackdelay; };
void createrays(vec &from, vec &to) // create random spread of rays for the shotgun
{
@@ -120,8 +97,7 @@ void createrays(vec &from, vec &to) // create random spread of rays
};
};
//bool intersect(dynent *d, vec &from, vec &to) // if lineseg hits entity bounding box
bool intersect(dynent *d, vec &from, vec &to, vec *end) // if lineseg hits entity bounding box
bool intersect(dynent *d, vec &from, vec &to) // if lineseg hits entity bounding box
{
vec v = to, w = d->o, *p;
vsub(v, from);
@@ -142,25 +118,12 @@ bool intersect(dynent *d, vec &from, vec &to, vec *end) // if lineseg hits ent
};
};
/* Modified by Rick
return p->x <= d->o.x+d->radius
&& p->x >= d->o.x-d->radius
&& p->y <= d->o.y+d->radius
&& p->y >= d->o.y-d->radius
&& p->z <= d->o.z+d->aboveeye
&& p->z >= d->o.z-d->eyeheight;
*/
if( p->x <= d->o.x+d->radius
&& p->x >= d->o.x-d->radius
&& p->y <= d->o.y+d->radius
&& p->y >= d->o.y-d->radius
&& p->z <= d->o.z+d->aboveeye
&& p->z >= d->o.z-d->eyeheight)
{
if (end) *end = *p;
return true;
}
return false;
};
char *playerincrosshair()
@@ -175,20 +138,6 @@ char *playerincrosshair()
return NULL;
};
// Added by Rick
char *botincrosshair()
{
if(demoplayback) return NULL;
loopv(bots)
{
dynent *o = bots[i];
if(!o) continue;
if(intersect(o, player1->o, worldpos)) return o->name;
};
return NULL;
};
// End add by Rick
const int MAXPROJ = 100;
struct projectile { vec o, to; float speed; dynent *owner; int gun; bool inuse, local; };
projectile projs[MAXPROJ];
@@ -215,59 +164,9 @@ void newprojectile(vec &from, vec &to, float speed, bool local, dynent *owner, i
void hit(int target, int damage, dynent *d, dynent *at)
{
if(d==player1) selfdamage(damage, at==player1 ? -1 : -2, at);
//else if(d->monsterstate) monsterpain(d, damage, at);
// Added by Rick: Let bots take damage
else if (d->pBot) d->pBot->BotPain(damage, at);
else if (d->bIsBot)
{
int PlayerIndex = -1;
if (at->bIsBot) PlayerIndex = BotManager.GetBotIndex(at);
else
{
loopv(players)
{
if (!players[i]) continue;
if (players[i] == at)
{
PlayerIndex = i;
break;
}
}
}
int msgtype = (at->bIsBot) ? SV_BOT2BOTDMG : SV_CLIENT2BOTDMG;
addmsg(1, 4, msgtype, BotManager.GetBotIndex(d), damage, PlayerIndex);
playsound(S_PAIN1+rnd(5), &d->o);
}
// End add by Rick
//else { addmsg(1, 4, SV_DAMAGE, target, damage, d->lifesequence); playsound(S_PAIN1+rnd(5), &d->o); }; Modified by Rick: Added IsBot and PlayerIndex to message
else
{
// Modified by Rick: Added IsBot and PlayerIndex to message
int PlayerIndex = -1;
if (at->bIsBot)
PlayerIndex = BotManager.GetBotIndex(at);
else
{
loopv(players)
{
if (!players[i])
continue;
if (players[i] == at)
{
PlayerIndex = i;
break;
}
}
}
addmsg(1, 6, SV_DAMAGE, target, damage, d->lifesequence, at->bIsBot, PlayerIndex);
playsound(S_PAIN1+rnd(5), &d->o);
};
else { addmsg(1, 4, SV_DAMAGE, target, damage, d->lifesequence); playsound(S_PAIN1+rnd(5), &d->o); };
particle_splash(3, damage, 1000, d->o);
demodamage(damage, d->o);
demodamage(damage, d->o);
};
const float RL_RADIUS = 5;
@@ -288,13 +187,11 @@ void radialeffect(dynent *o, vec &v, int cn, int qdam, dynent *at)
};
};
// Modified by Rick: Added notthisbot
void splash(projectile *p, vec &v, vec &vold, int notthisplayer, int notthismonster, int notthisbot, int qdam)
void splash(projectile *p, vec &v, vec &vold, int notthisplayer, int notthismonster, int qdam)
{
particle_splash(0, 50, 300, v);
p->inuse = false;
if(p->gun!=GUN_GRENADE)
if(p->gun!=GUN_GRENADE) //changed
{
playsound(S_FEXPLODE, &v);
// no push?
@@ -313,29 +210,15 @@ void splash(projectile *p, vec &v, vec &vold, int notthisplayer, int notthismons
if(!o) continue;
radialeffect(o, v, i, qdam, p->owner);
};
// Added by Rick
loopv(bots)
{
if(i==notthisbot) continue;
dynent *o = bots[i];
if(!o) continue;
radialeffect(o, v, i, qdam, p->owner);
}
// End add by Rick
//dvector &mv = getmonsters();
//loopv(mv) if(i!=notthismonster) radialeffect(mv[i], v, i, qdam, p->owner);
};
};
};
// Modified by Rick
// inline void projdamage(dynent *o, projectile *p, vec &v, int i, int im, int qdam)
inline void projdamage(dynent *o, projectile *p, vec &v, int i, int im, int ib, int qdam)
inline void projdamage(dynent *o, projectile *p, vec &v, int i, int im, int qdam)
{
if(o->state!=CS_ALIVE) return;
if(intersect(o, p->o, v))
{
// splash(p, v, p->o, i, im, qdam); Modified by Rick
splash(p, v, p->o, i, im, ib, qdam);
splash(p, v, p->o, i, im, qdam);
hit(i, qdam, o, p->owner);
};
};
@@ -358,36 +241,17 @@ void moveprojectiles(float time)
{
dynent *o = players[i];
if(!o) continue;
// projdamage(o, p, v, i, -1, qdam); Modified by Rick
projdamage(o, p, v, i, -1, -1, qdam);
projdamage(o, p, v, i, -1, qdam);
};
// Added by Rick: Damage bots aswell
loopv(bots)
{
dynent *o = bots[i];
if(!o || (o == p->owner)) continue;
projdamage(o, p, v, -1, -1, i, qdam);
};
// End add by Rick
// if(p->owner!=player1) projdamage(player1, p, v, -1, -1, qdam); Modified by Rick
if(p->owner!=player1) projdamage(player1, p, v, -1, -1, -1, qdam);
//dvector &mv = getmonsters();
//loopv(mv) if(!vreject(mv[i]->o, v, 10.0f) && mv[i]!=p->owner) projdamage(mv[i], p, v, -1, i, qdam); Modified by Rick
//loopv(mv) if(!vreject(mv[i]->o, v, 10.0f) && mv[i]!=p->owner) projdamage(mv[i], p, v, -1, i, -1, qdam);
if(p->owner!=player1) projdamage(player1, p, v, -1, -1, qdam);
};
if(p->inuse)
{
// if(time==dtime) splash(p, v, p->o, -1, -1, qdam); Modified by Rick
if(time==dtime) splash(p, v, p->o, -1, -1, -1, qdam);
if(time==dtime) splash(p, v, p->o, -1, -1, qdam);
else
{
if(p->gun==GUN_GRENADE) { dodynlight(p->o, v, 0, 255, p->owner); particle_splash(5, 2, 200, v); }
else { particle_splash(1, 1, 200, v); particle_splash(guns[p->gun].part, 1, 1, v); };
// Added by Rick
traceresult_s tr;
TraceLine(p->o, v, p->owner, true, &tr);
if (tr.collided) splash(p, v, p->o, -1, -1, -1, qdam);
// End add
};
};
p->o = v;
@@ -423,7 +287,7 @@ void shootv(int gun, vec &from, vec &to, dynent *d, bool local) // create vi
case GUN_SNIPER:
particle_splash(0, 50, 200, to);
//particle_trail(1, 500, from, to);
particle_trail(1, 500, from, to);
break;
};
};
@@ -462,12 +326,9 @@ void spreadandrecoil(vec & from, vec & to, dynent * d)
//recoil
int rcl = guns[d->gunselect].recoil*-0.01f;
if (d->gunselect==GUN_ASSULT)
if ((d->gunselect==GUN_ASSULT) && (d->shots<=3))
{
if (d->shots<=3)
spd = spd / 5;
rcl += (rnd(8)*-0.01f);
spd = spd / 5;
};
if ((d->gunselect==GUN_SNIPER) && (d->vel.x<.25f && d->vel.y<.25f))
@@ -478,11 +339,10 @@ void spreadandrecoil(vec & from, vec & to, dynent * d)
if (d->gunselect!=GUN_SHOTGUN) //no spread on shotgun
{
#define RNDD (rnd(spd)-spd/2)*f
vec r = { RNDD, RNDD, RNDD };
vadd(to, r);
};
//increase pitch for recoil
vdiv(unitv, dist);
@@ -508,24 +368,6 @@ void shoot(dynent *d, vec &targ)
};
d->lastaction = lastmillis;
d->lastattackgun = d->gunselect;
// Modified by Rick
// if(!d->mag[d->gunselect]) { playsoundc(S_NOAMMO); d->gunwait = 250; d->lastattackgun = -1; return; };
if(!d->mag[d->gunselect])
{
if (d->bIsBot) botplaysound(S_NOAMMO, d);
else playsoundc(S_NOAMMO);
d->gunwait = 250;
d->lastattackgun = -1;
return;
};
// End mod
if (d->gunselect!=0) //if knife skip
{
if(d->gunselect) d->mag[d->gunselect]--;
}
if(!d->mag[d->gunselect]) { playsoundc(S_NOAMMO); d->gunwait = 250; d->lastattackgun = -1; return; };
if(d->gunselect) d->mag[d->gunselect]--;
vec from = d->o;
@@ -545,25 +387,10 @@ void shoot(dynent *d, vec &targ)
};
if(d->gunselect==GUN_SHOTGUN) createrays(from, to);
//if(d->quadmillis && attacktime>200) playsoundc(S_ITEMPUP); Modified by Rick
if(d->quadmillis && attacktime>200)
{
if (d->bIsBot) botplaysound(S_ITEMPUP, d);
else playsoundc(S_ITEMPUP);
}
// End mod
if(d->quadmillis && attacktime>200) playsoundc(S_ITEMPUP);
shootv(d->gunselect, from, to, d, true);
// Modified by Rick
// if(!d->monsterstate) addmsg(1, 8, SV_SHOT, d->gunselect, (int)(from.x*DMF), (int)(from.y*DMF), (int)(from.z*DMF), (int)(to.x*DMF), (int)(to.y*DMF), (int)(to.z*DMF));
if(!d->monsterstate)
{
int index = -1;
if (d->bIsBot)
index = BotManager.GetBotIndex(d);
addmsg(1, 9, SV_SHOT, d->gunselect, (int)(from.x*DMF), (int)(from.y*DMF), (int)(from.z*DMF), (int)(to.x*DMF), (int)(to.y*DMF), (int)(to.z*DMF), index);
}
// End mod
d->gunwait = delaytime(d->gunselect);// hack guns[d->gunselect].attackdelay;
addmsg(1, 8, SV_SHOT, d->gunselect, (int)(from.x*DMF), (int)(from.y*DMF), (int)(from.z*DMF), (int)(to.x*DMF), (int)(to.y*DMF), (int)(to.z*DMF));
d->gunwait = guns[d->gunselect].attackdelay;
if(guns[d->gunselect].projspeed) return;
@@ -574,134 +401,4 @@ void shoot(dynent *d, vec &targ)
raydamage(o, from, to, d, i);
};
// Added by Rick: raydamage on bots too
loopv(bots)
{
dynent *o = bots[i];
if(!o || (o == d)) continue;
raydamage(o, from, to, d, i);
};
// End add by Rick
//dvector &v = getmonsters();
//loopv(v) if(v[i]!=d) raydamage(v[i], from, to, d, -2);
//if(d->monsterstate) raydamage(player1, from, to, d, -1); Modified by Rick
if(d->monsterstate || d->bIsBot) raydamage(player1, from, to, d, -1);
};
//currently client side only, need to make serv
void additem(int gun)
{
if (gun>0 && gun<10)
{
// player1->mag[gun] = guns[gun].magazine;
// player1->ammo[gun] = guns[gun].magazine * 3;
};
if (gun==10) //helmet
{
conoutf("NO HELMET FOR YOU!");
// player1->armour = 20
// break;
};
if (gun==11) //armour
{
conoutf("you can't add armor yet!");
// additem(I_ARMOUR, player1->armour, 20);
// break;
};
};
COMMAND(additem,ARG_1INT);
//gotta find a neater way of doing this -argh
void altattack(bool on)
{
/*
if (on)
{
switch(player1->gunselect)
{
case(GUN_KNIFE):
break;
case(GUN_SEMIPISTOL):
break;
case(GUN_SHOTGUN):
break;
case(GUN_SNIPER):
setvar("fov",getvar("fov")-55);
break;
case(GUN_SUBGUN):
break;
case(GUN_AUTORIFLE):
break;
case(GUN_GRENADE):
break;
};
}
else
{
switch(player1->gunselect)
{
case(GUN_KNIFE):
break;
case(GUN_SEMIPISTOL):
break;
case(GUN_SHOTGUN):
break;
case(GUN_SNIPER):
setvar("fov",getvar("fov")+55);
break;
case(GUN_SUBGUN):
break;
case(GUN_AUTORIFLE):
break;
case(GUN_GRENADE):
break;
};
};
*/
};
void altattack(void)
{
player1->altattack = !player1->altattack;
switch(player1->gunselect)
{
case(GUN_SHOTGUN):
if(player1->mag[player1->gunselect]>=guns[player1->gunselect].magsize) return;
if(player1->ammo[player1->gunselect]<=0) return;
if(player1->reloading) return;
player1->reloading = true;
player1->lastaction = lastmillis;
player1->gunwait = guns[player1->gunselect].reloadtime / 2;
if(player1->ammo[GUN_SHOTGUN]>1)
player1->mag[GUN_SHOTGUN]++;
player1->ammo[GUN_SHOTGUN]--;
playsoundc(guns[player1->gunselect].reload);
break;
case(GUN_SNIPER):
if(player1->altattack)
setvar("fov",getvar("fov")-55);
else
setvar("fov",getvar("fov")+55);
break;
}
};
COMMAND(altattack, ARG_NONE);