*** empty log message ***

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@869 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2007-03-31 23:44:27 +00:00
parent cc1642e1a9
commit b296653ae4
39 changed files with 1473 additions and 1469 deletions
+75 -75
View File
@@ -40,8 +40,8 @@ void checkweaponswitch()
(player1->akimbo && !player1->akimbomillis && player1->gunselect==GUN_PISTOL))
player1->akimbo = !player1->akimbo;
player1->gunselect = player1->nextweapon;
};
};
}
}
void weaponswitch(int gun)
{
@@ -50,7 +50,7 @@ void weaponswitch(int gun)
player1->lastaction = player1->akimbolastaction[0] = player1->akimbolastaction[1] = lastmillis;
player1->nextweapon = gun;
playsound(S_GUNCHANGE);
};
}
void weapon(int gun)
{
@@ -65,7 +65,7 @@ void weapon(int gun)
setscope(false);
weaponswitch(gun);
};
}
void shiftweapon(int s)
{
@@ -74,12 +74,12 @@ void shiftweapon(int s)
int trygun = player1->gunselect + s + (s < 0 ? -i : i);
if((trygun %= NUMGUNS) < 0) trygun += NUMGUNS;
weapon(trygun);
};
};
}
}
int currentprimary() { return player1->primary; };
int curweapon() { return player1->gunselect; };
int magcontent(int gun) { if(gun > 0 && gun < NUMGUNS) return player1->mag[gun]; else return -1;};
int currentprimary() { return player1->primary; }
int curweapon() { return player1->gunselect; }
int magcontent(int gun) { if(gun > 0 && gun < NUMGUNS) return player1->mag[gun]; else return -1;}
COMMAND(weapon, ARG_1INT);
COMMAND(shiftweapon, ARG_1INT);
@@ -132,16 +132,16 @@ void reload(playerent *d)
if(has_akimbo(d)) playsoundc(S_RAKIMBO);
else if(d->type==ENT_BOT) playsound(guns[d->gunselect].reload, &d->o);
else playsoundc(guns[d->gunselect].reload);
};
}
void selfreload() { reload(player1); };
void selfreload() { reload(player1); }
COMMANDN(reload, selfreload, ARG_NONE);
int reloadtime(int gun) { return guns[gun].reloadtime; };
int attackdelay(int gun) { return guns[gun].attackdelay; };
int magsize(int gun) { return guns[gun].magsize; };
int kick_rot(int gun) { return guns[gun].mdl_kick_rot; };
int kick_back(int gun) { return guns[gun].mdl_kick_back; };
int reloadtime(int gun) { return guns[gun].reloadtime; }
int attackdelay(int gun) { return guns[gun].attackdelay; }
int magsize(int gun) { return guns[gun].magsize; }
int kick_rot(int gun) { return guns[gun].mdl_kick_rot; }
int kick_back(int gun) { return guns[gun].mdl_kick_back; }
void createrays(vec &from, vec &to) // create random spread of rays for the shotgun
{
@@ -153,8 +153,8 @@ void createrays(vec &from, vec &to) // create random spread of rays
sg[i] = to;
sg[i].add(r);
#undef RNDD
};
};
}
}
bool intersect(dynent *d, vec &from, vec &to, vec *end) // if lineseg hits entity bounding box
{
@@ -173,8 +173,8 @@ bool intersect(dynent *d, vec &from, vec &to, vec *end) // if lineseg hits ent
float f = c1/c2;
v.mul(f).add(from);
p = &v;
};
};
}
}
return p->x <= d->o.x+d->radius
&& p->x >= d->o.x-d->radius
@@ -182,7 +182,7 @@ bool intersect(dynent *d, vec &from, vec &to, vec *end) // if lineseg hits ent
&& p->y >= d->o.y-d->radius
&& p->z <= d->o.z+d->aboveeye
&& p->z >= d->o.z-d->eyeheight;
};
}
playerent *intersectclosest(vec &from, vec &to, int &n, playerent *at)
{
@@ -193,7 +193,7 @@ playerent *intersectclosest(vec &from, vec &to, int &n, playerent *at)
best = player1;
bestdist = at->o.dist(player1->o);
n = getclientnum();
};
}
loopv(players)
{
playerent *o = players[i];
@@ -205,23 +205,23 @@ playerent *intersectclosest(vec &from, vec &to, int &n, playerent *at)
best = o;
bestdist = dist;
n = i;
};
};
}
}
return best;
};
}
playerent *playerincrosshair()
{
if(demoplayback) return NULL;
int n;
return intersectclosest(player1->o, worldpos, n, player1);
};
}
const int MAXPROJ = 100;
struct projectile { vec o, to; float speed; playerent *owner; int gun; bool inuse, local; };
projectile projs[MAXPROJ];
void projreset() { loopi(MAXPROJ) projs[i].inuse = false; };
void projreset() { loopi(MAXPROJ) projs[i].inuse = false; }
void newprojectile(vec &from, vec &to, float speed, bool local, playerent *owner, int gun)
{
@@ -237,8 +237,8 @@ void newprojectile(vec &from, vec &to, float speed, bool local, playerent *owner
p->owner = owner;
p->gun = gun;
return;
};
};
}
}
void hit(int target, int damage, playerent *d, playerent *at, bool gib=false)
{
@@ -248,10 +248,10 @@ void hit(int target, int damage, playerent *d, playerent *at, bool gib=false)
{
addmsg(gib ? SV_GIBDAMAGE : SV_DAMAGE, "ri3", target, damage, d->lifesequence);
playsound(S_PAIN1+rnd(5), &d->o);
};
}
particle_splash(3, damage, 1000, d->o);
demodamage(damage, d->o);
};
}
const float RL_RADIUS = 7;
const float RL_DAMRAD = 10; // hack
@@ -268,8 +268,8 @@ void radialeffect(playerent *o, vec &v, int cn, int qdam, playerent *at)
int damage = (int)(qdam*(1-(dist/RL_DAMRAD)));
hit(cn, damage, o, at, true);
o->vel.add(temp.mul((RL_DAMRAD-dist)*damage/800));
};
};
}
}
void splash(projectile *p, vec &v, vec &vold, int notthisplayer, int qdam)
{
@@ -293,9 +293,9 @@ void splash(projectile *p, vec &v, vec &vold, int notthisplayer, int qdam)
playerent *o = players[i];
if(!o) continue;
radialeffect(o, v, i, qdam, p->owner);
};
};
};
}
}
}
inline void projdamage(playerent *o, projectile *p, vec &v, int i, int qdam)
{
@@ -304,8 +304,8 @@ inline void projdamage(playerent *o, projectile *p, vec &v, int i, int qdam)
{
splash(p, v, p->o, i, qdam);
hit(i, qdam, o, p->owner, true); //fixme
};
};
}
}
void moveprojectiles(float time)
{
@@ -327,26 +327,26 @@ void moveprojectiles(float time)
playerent *o = players[i];
if(!o) continue;
projdamage(o, p, v, i, qdam);
};
}
if(p->owner!=player1) projdamage(player1, p, v, -1, qdam);
};
}
if(p->inuse)
{
if(time==dtime) splash(p, v, p->o, -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); };
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, qdam);
// End add
};
};
}
}
p->o = v;
};
};
}
}
void throw_nade(playerent *d, const vec &vel, bounceent *p)
{
@@ -368,8 +368,8 @@ void throw_nade(playerent *d, const vec &vel, bounceent *p)
{
player1->lastaction = lastmillis;
addmsg(SV_SHOT, "ri8", d->gunselect, (int)(d->o.x*DMF), (int)(d->o.y*DMF), (int)(d->o.z*DMF), (int)(vel.x*DMF), (int)(vel.y*DMF), (int)(vel.z*DMF), lastmillis-p->millis);
};
};
}
}
void throw_nade(playerent *d, bounceent *p)
{
@@ -380,7 +380,7 @@ void throw_nade(playerent *d, bounceent *p)
vel.mul(1.5f);
throw_nade(d, vel, p);
};
}
// fixme
VAR(grenadespeed, 0, 27, 100);
@@ -400,7 +400,7 @@ bounceent *new_nade(playerent *d, int millis = 0)
d->thrownademillis = 0;
playsound(S_GRENADEPULL, (d==player1 ? NULL : &d->o));
return p;
};
}
void explode_nade(bounceent *i)
{
@@ -408,7 +408,7 @@ void explode_nade(bounceent *i)
if(i->bouncestate != NADE_THROWED) throw_nade(i->owner, vec(0,0,0), i);
playsound(S_FEXPLODE, &i->o);
newprojectile(i->o, i->o, 1, i->owner==player1, i->owner, GUN_GRENADE);
};
}
void shootv(int gun, vec &from, vec &to, playerent *d, bool local, int nademillis) // create visual effect from a shot
{
@@ -422,7 +422,7 @@ void shootv(int gun, vec &from, vec &to, playerent *d, bool local, int nademilli
{
loopi(SGRAYS) particle_splash(0, 5, 200, sg[i]);
break;
};
}
case GUN_PISTOL:
case GUN_SUBGUN:
@@ -431,7 +431,7 @@ void shootv(int gun, vec &from, vec &to, playerent *d, bool local, int nademilli
addshotline(d, from, to);
particle_splash(0, 5, 250, to);
break;
};
}
case GUN_GRENADE:
{
@@ -439,9 +439,9 @@ void shootv(int gun, vec &from, vec &to, playerent *d, bool local, int nademilli
{
bounceent *p = new_nade(d, nademillis);
throw_nade(d, to, p);
};
}
break;
};
}
case GUN_SNIPER:
{
@@ -449,9 +449,9 @@ void shootv(int gun, vec &from, vec &to, playerent *d, bool local, int nademilli
particle_splash(0, 50, 200, to);
particle_trail(1, 500, from, to);
break;
};
};
};
}
}
}
void hitpush(int target, int damage, playerent *d, playerent *at, vec &from, vec &to, bool gib = false)
{
@@ -460,12 +460,12 @@ void hitpush(int target, int damage, playerent *d, playerent *at, vec &from, vec
float dist = to.dist(from, v);
v.mul(damage/dist/50);
d->vel.add(v);
};
}
void shorten(vec &from, vec &to, vec &target)
{
target.sub(from).normalize().mul(from.dist(to)).add(from);
};
}
const float HEADSIZE = 0.8f;
vec hitpos;
@@ -495,10 +495,10 @@ void raydamage(vec &from, vec &to, playerent *d)
shorten(from, o->o, sg[r]);
}
else raysleft = true;
};
}
if(damage) hitpush(i, damage, o, d, from, to);
if(!raysleft) break;
};
}
}
else if((o = intersectclosest(from, to, i, d)))
{
@@ -510,12 +510,12 @@ void raydamage(vec &from, vec &to, playerent *d)
{
gdam *= 3;
gib = true;
};
}
hitpush(i, gdam, o, d, from, to, gib);
shorten(from, o->o, to);
};
};
}
}
void spreadandrecoil(vec &from, vec &to, playerent *d)
{
@@ -536,13 +536,13 @@ void spreadandrecoil(vec &from, vec &to, playerent *d)
if(d->shots > 3)
spd = 70;
rcl += (rnd(8)*-0.01f);
};
}
if((d->gunselect==GUN_SNIPER) /*&& (d->vel.x<.25f && d->vel.y<.25f)*/ && scoped)
{
spd = 1;
rcl = rcl / 3;
};
}
if(d->gunselect!=GUN_SHOTGUN) //no spread on shotgun
{
@@ -550,13 +550,13 @@ void spreadandrecoil(vec &from, vec &to, playerent *d)
vec r(RNDD, RNDD, RNDD);
to.add(r);
#undef RNDD
};
}
//increase pitch for recoil
d->vel.add(vec(unitv).mul(rcl/dist));
if(d->pitch<80.0f) d->pitch += guns[d->gunselect].recoil*0.05f;
};
}
bool hasammo(playerent *d) // bot mod
{
@@ -593,7 +593,7 @@ void shoot(playerent *d, vec &targ)
d->nextweapon = d->mag[GUN_GRENADE] ? GUN_GRENADE : d->primary;
d->thrownademillis = 0;
d->lastaction = lastmillis-1-WEAPONCHANGE_TIME/2;
};
}
if(d->weaponchanging || attacktime<d->gunwait) return;
d->gunwait = 0;
@@ -618,11 +618,11 @@ void shoot(playerent *d, vec &targ)
d->gunwait = 0;
d->reloading = false;
if(!d->attacking) { d->shots = 0; return; };
if(!d->attacking) { d->shots = 0; return; }
d->lastaction = lastmillis;
d->lastattackgun = d->gunselect;
if(d->gunselect!=GUN_KNIFE && !hasammo(d)) { d->shots = 0; return; };
if(d->gunselect!=GUN_KNIFE && !hasammo(d)) { d->shots = 0; return; }
if(guns[d->gunselect].isauto) d->shots++;
else d->attacking = false;
@@ -632,11 +632,11 @@ void shoot(playerent *d, vec &targ)
d->attacking = true; //make akimbo auto
d->akimbolastaction[akimboside?1:0] = lastmillis;
akimboside = !akimboside;
};
}
if(d->gunselect!=GUN_KNIFE) d->mag[d->gunselect]--;
from.z -= 0.2f; // below eye
};
}
spreadandrecoil(from,to,d);
vec unitv;
@@ -648,7 +648,7 @@ void shoot(playerent *d, vec &targ)
unitv.mul(3); // punch range
to = from;
to.add(unitv);
};
}
if(d->gunselect==GUN_SHOTGUN) createrays(from, to);
if(has_akimbo(d)) d->gunwait = guns[d->gunselect].attackdelay / 2; //make akimbo pistols shoot twice as fast as normal pistol
@@ -662,4 +662,4 @@ void shoot(playerent *d, vec &targ)
if(guns[d->gunselect].projspeed || d->gunselect==GUN_GRENADE) return;
raydamage(from, to, d);
};
}