git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@300 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2006-06-01 22:01:32 +00:00
parent c40015be6c
commit e9159704ba
27 changed files with 2957 additions and 2086 deletions
+216 -96
View File
@@ -11,92 +11,95 @@ vec sg[SGRAYS];
//change the particales
guninfo guns[NUMGUNS] =
{
{ S_KNIFE, S_NULL, 0, 500, 50, 0, 0, 1, 1, 1, 0, 0, "knife" },
{ S_KNIFE, S_NULL, 0, 500, 50, 0, 0, 1, 1, 1, 0, 0, "knife" },
{ S_PISTOL, S_RPISTOL, 1400, 170, 20, 0, 0, 80, 10, 8, 6, 5, "pistol" }, // *SGRAYS
{ S_SHOTGUN, S_RSHOTGUN, 2400, 1000, 6, 0, 0, 1, 35, 7, 9, 9, "shotgun" }, //reload time is for 1 shell from 7 too powerful to 6
{ S_SUBGUN, S_RSUBGUN, 1650, 80, 17, 0, 0, 70, 15, 30, 1, 2, "subgun" },
{ S_SNIPER, S_RSNIPER, 1950, 1500, 72, 0, 0, 60, 50, 5, 4, 4, "sniper" },
{ S_ASSULT, S_RASSULT, 2000, 130, 20, 0, 0, 20, 40, 20, 0, 2, "assult" }, //recoil was 44
{ S_GRENADE, S_NULL, 1000, 2500, 150, 20, 6, 1, 1, 1, 3, 1, "grenade" },
{ S_GRENADE, S_NULL, 1000, 2500, 150, 20, 6, 1, 1, 1, 3, 1, "grenade" },
};
bool gun_changed = false;
void weapon(int gun)
{
if(gun>=0) gun %= G_NUM;
else gun = G_NUM-(gun % G_NUM);
gun_changed = true;
switch(gun)
{
case G_PRIMARY: player1->gunselect=player1->primary; break;
case G_SECONDARY: player1->gunselect=GUN_PISTOL; break;
case G_MELEE: player1->gunselect=GUN_KNIFE; break;
case G_GRENADE: player1->gunselect=GUN_GRENADE; break;
};
};
void shiftweapon(int i)
{
int gun;
switch(player1->gunselect)
{
case GUN_KNIFE: gun=G_MELEE; break;
case GUN_PISTOL: gun=G_SECONDARY; break;
case GUN_GRENADE: gun=G_GRENADE; break;
default: gun=G_PRIMARY; break;
};
gun += i;
weapon(gun);
bool gun_changed = false;
void weapon(int gun)
{
if(gun>=0) gun %= G_NUM;
else gun = G_NUM-(gun % G_NUM);
gun_changed = true;
switch(gun)
{
case G_PRIMARY: player1->gunselect=player1->primary; break;
case G_SECONDARY: player1->gunselect=GUN_PISTOL; break;
case G_MELEE: player1->gunselect=GUN_KNIFE; break;
case G_GRENADE: player1->gunselect=GUN_GRENADE; break;
};
};
void shiftweapon(int i)
{
int gun;
switch(player1->gunselect)
{
case GUN_KNIFE: gun=G_MELEE; break;
case GUN_PISTOL: gun=G_SECONDARY; break;
case GUN_GRENADE: gun=G_GRENADE; break;
default: gun=G_PRIMARY; break;
};
gun += i;
weapon(gun);
}
COMMAND(weapon, ARG_1INT);
COMMAND(weapon, ARG_1INT);
COMMAND(shiftweapon, ARG_1INT);
void reload()
void reload(dynent *d)
{
bool akimbo = player1->gunselect==GUN_PISTOL && player1->akimbo!=0;
if(!d) return;
if(player1->gunselect==GUN_KNIFE || player1->gunselect==GUN_GRENADE) return;
if(akimbo && player1->mag[player1->gunselect]>=(guns[player1->gunselect].magsize * 2)) return;
else if(player1->mag[player1->gunselect]>=guns[player1->gunselect].magsize && player1->akimbo==0) return;
if(player1->ammo[player1->gunselect]<=0) return;
if(player1->reloading) return;
bool akimbo = d->gunselect==GUN_PISTOL && d->akimbo!=0;
if(d->gunselect==GUN_KNIFE || d->gunselect==GUN_GRENADE) return;
if(akimbo && d->mag[d->gunselect]>=(guns[d->gunselect].magsize * 2)) return;
else if(d->mag[d->gunselect]>=guns[d->gunselect].magsize && d->akimbo==0) return;
if(d->ammo[d->gunselect]<=0) return;
if(d->reloading) return;
player1->reloading = true;
player1->lastaction = lastmillis;
if(akimbo)
{
akimbolastaction[akimboside?1:0] = lastmillis;
akimbolastaction[akimboside?0:1] = lastmillis;// + (reloadtime(GUN_PISTOL)/2);
d->reloading = true;
d->lastaction = lastmillis;
if(akimbo)
{
akimbolastaction[akimboside?1:0] = lastmillis;
akimbolastaction[akimboside?0:1] = lastmillis;// + (reloadtime(GUN_PISTOL)/2);
};
player1->gunwait = guns[player1->gunselect].reloadtime;
d->gunwait = guns[d->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(player1->gunselect==GUN_PISTOL && player1->akimbo!=0)
a = guns[player1->gunselect].magsize * 2 - player1->mag[player1->gunselect];
int a = guns[d->gunselect].magsize - d->mag[d->gunselect];
if(d->gunselect==GUN_PISTOL && d->akimbo!=0)
a = guns[d->gunselect].magsize * 2 - d->mag[d->gunselect];
if (a >= player1->ammo[player1->gunselect])
if (a >= d->ammo[d->gunselect])
{
player1->mag[player1->gunselect] += player1->ammo[player1->gunselect];
player1->ammo[player1->gunselect] = 0;
d->mag[d->gunselect] += d->ammo[d->gunselect];
d->ammo[d->gunselect] = 0;
}
else
{
player1->mag[player1->gunselect] += a;
player1->ammo[player1->gunselect] -= a;
d->mag[d->gunselect] += a;
d->ammo[d->gunselect] -= a;
}
if(akimbo) playsoundc(S_RAKIMBO);
else playsoundc(guns[player1->gunselect].reload);
if(akimbo) playsoundc(S_RAKIMBO);
else playsoundc(guns[d->gunselect].reload);
};
COMMAND(reload,ARG_NONE);
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; };
@@ -118,7 +121,8 @@ 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) // if lineseg hits entity bounding box
bool intersect(dynent *d, vec &from, vec &to, vec *end) // if lineseg hits entity bounding box
{
vec v = to, w = d->o, *p;
vsub(v, from);
@@ -158,6 +162,19 @@ dynent *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; };
@@ -185,7 +202,58 @@ 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 { addmsg(1, 4, SV_DAMAGE, target, damage, d->lifesequence); playsound(S_PAIN1+rnd(5), &d->o); };
//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;
}
}
}
if(at->bIsBot) addmsg(1, 5, SV_BOT2CLIENTDMG, target, damage, d->lifesequence, PlayerIndex);
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);
};
@@ -208,7 +276,8 @@ void radialeffect(dynent *o, vec &v, int cn, int qdam, dynent *at)
};
};
void splash(projectile *p, vec &v, vec &vold, int notthisplayer, int notthismonster, int qdam)
// Modified by Rick: Added notthisbot
void splash(projectile *p, vec &v, vec &vold, int notthisplayer, int notthismonster, int notthisbot, int qdam)
{
particle_splash(0, 50, 300, v);
p->inuse = false;
@@ -231,15 +300,29 @@ 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);
};
};
inline void projdamage(dynent *o, projectile *p, vec &v, int i, int im, int qdam)
// 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)
{
if(o->state!=CS_ALIVE) return;
if(intersect(o, p->o, v))
{
splash(p, v, p->o, i, im, qdam);
// splash(p, v, p->o, i, im, qdam); Modified by Rick
splash(p, v, p->o, i, im, ib, qdam);
hit(i, qdam, o, p->owner);
};
};
@@ -263,17 +346,36 @@ void moveprojectiles(float time)
{
dynent *o = players[i];
if(!o) continue;
projdamage(o, p, v, i, -1, qdam);
// projdamage(o, p, v, i, -1, qdam); Modified by Rick
projdamage(o, p, v, i, -1, -1, qdam);
};
if(p->owner!=player1) projdamage(player1, p, v, -1, -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->inuse)
{
if(time==dtime) splash(p, v, p->o, -1, -1, qdam);
// 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);
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;
@@ -288,7 +390,7 @@ void throw_nade(dynent *d, vec &to, physent *p)
{
if(!p || !d) return;
printf("thrownade\n");
playsound(S_GRENADETHROW, &d->o);
playsound(S_GRENADETHROW, &d->o);
p->isphysent = true;
p->gravity = 20;
@@ -378,7 +480,7 @@ physent *new_nade(dynent *d, int millis = 0)
{
curnade = p;
d->thrownademillis = 0;
};
};
playsound(S_GRENADEPULL, &d->o);
return p;
};
@@ -394,7 +496,7 @@ void explode_nade(physent *i)
vec dist = { 0.1f, 0.1f, 0.1f };
vadd(o, dist);
throw_nade(i->owner, o, i);
};
};
playsound(S_FEXPLODE, &i->o);
newprojectile(i->o, i->o, 1, i->owner==player1, i->owner, GUN_GRENADE);
};
@@ -422,7 +524,7 @@ void shootv(int gun, vec &from, vec &to, dynent *d, bool local, int nademillis)
//particle_trail(1, 10, from, to);
break;
case GUN_GRENADE:
case GUN_GRENADE:
{
if(d!=player1)
{
@@ -460,7 +562,7 @@ void raydamage(dynent *o, vec &from, vec &to, dynent *d, int i)
if(damage) hitpush(i, damage, o, d, from, to);
}
else if(intersect(o, from, to)) hitpush(i, qdam, o, d, from, to);
};
};
void spreadandrecoil(vec & from, vec & to, dynent * d)
{
@@ -503,13 +605,13 @@ void spreadandrecoil(vec & from, vec & to, dynent * d)
if(d->pitch<80.0f) d->pitch += guns[d->gunselect].recoil*0.05f;
};
//VAR(grenadepulltime, 0, 100, 10000);
const int grenadepulltime = 650;
bool akimboside = false;
int akimbolastaction[2] = {0,0};
//VAR(grenadepulltime, 0, 100, 10000);
const int grenadepulltime = 650;
bool akimboside = false;
int akimbolastaction[2] = {0,0};
void shoot(dynent *d, vec &targ)
{
@@ -517,10 +619,10 @@ void shoot(dynent *d, vec &targ)
if(!d->attacking && d->gunselect==GUN_GRENADE && curnade) // throw
{
if(attacktime>grenadepulltime)
{
d->thrownademillis = lastmillis;
throw_nade(d, targ, curnade);
if(attacktime>grenadepulltime)
{
d->thrownademillis = lastmillis;
throw_nade(d, targ, curnade);
}
return;
};
@@ -538,17 +640,26 @@ void shoot(dynent *d, vec &targ)
if(d->gunselect!=GUN_SUBGUN && d->gunselect!=GUN_ASSULT && d->gunselect!=GUN_GRENADE) d->attacking = false; //makes sub/assult autos
else d->shots++;
if(d->gunselect==GUN_PISTOL && d->akimbo!=0)
{
d->attacking = true; //make akimbo auto
akimbolastaction[akimboside?1:0] = lastmillis;
akimboside = !akimboside;
}
if(d->gunselect==GUN_PISTOL && d->akimbo)
{
d->attacking = true; //make akimbo auto
akimbolastaction[akimboside?1:0] = lastmillis;
akimboside = !akimboside;
}
d->lastaction = lastmillis;
d->lastattackgun = d->gunselect;
if(!d->mag[d->gunselect]) { playsoundc(S_NOAMMO); d->gunwait = 250; d->lastattackgun = -1; return; };
//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) d->mag[d->gunselect]--;
vec from = d->o;
@@ -567,18 +678,17 @@ void shoot(dynent *d, vec &targ)
vadd(to, unitv);
};
if(d->gunselect==GUN_SHOTGUN) createrays(from, to);
//if(d->quadmillis && attacktime>200) playsoundc(S_ITEMPUP);
if(d->gunselect==GUN_PISTOL && d->akimbo) d->gunwait = guns[d->gunselect].attackdelay / 2; //make akimbo pistols shoot twice as fast as normal pistol
else d->gunwait = guns[d->gunselect].attackdelay;
if(d->gunselect==GUN_GRENADE) // activate
{
if(!curnade) new_nade(player1);
if(!curnade) new_nade(d);
return;
}
//fixmebot
shootv(d->gunselect, from, to, d, 0);
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), 0 );
@@ -589,6 +699,16 @@ void shoot(dynent *d, vec &targ)
dynent *o = players[i];
if(!o) continue;
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
if(d->bIsBot) raydamage(player1, from, to, d, -1);
};