git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@102 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2006-01-08 13:38:30 +00:00
parent 679ba2ef64
commit a2346e9584
19 changed files with 1975 additions and 1917 deletions
+190 -190
View File
@@ -23,8 +23,8 @@ guninfo guns[NUMGUNS] =
{ S_ASSULT, S_RASSULT, 2000, 130, 20, 0, 0, 20, 40, 20, 0, 2, "assult" }, //recoil was 44
{ S_GRENADE, S_NULL, 1000, 2000, 130, 30, 6, 1, 1, 1, 3, 1, "grenade" },
};
{ S_GRENADE, S_NULL, 1000, 2000, 150, 20, 6, 1, 1, 1, 3, 1, "grenade" },
};
//weapon selection
@@ -121,10 +121,10 @@ void reload()
COMMAND(reload,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 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; };
@@ -213,7 +213,7 @@ void hit(int target, int damage, dynent *d, dynent *at)
demodamage(damage, d->o);
};
const float RL_RADIUS = 10;
const float RL_RADIUS = 7;
const float RL_DAMRAD = 10; // hack
void radialeffect(dynent *o, vec &v, int cn, int qdam, dynent *at)
@@ -302,107 +302,107 @@ void moveprojectiles(float time)
p->o = v;
};
};
extern float rad(float x);
bool nade_activated = false;
physent *curnade;
void thrownade(dynent *d, vec &to, physent *nade = NULL, int nadesec = 0)
{
physent *p;
if(nade) p = nade;
else p = (physent *)gp()->alloc(sizeof(physent)); // allocate new nade
p->owner = d;
p->yaw = 270;
p->pitch = 0;
p->roll = 0;
p->maxspeed = 35; //16 max speed, 14 max with armour
p->outsidemap = false;
p->inwater = false;
p->radius = 0.2f;
p->eyeheight = 0.3f;
p->aboveeye = 0.0f;
p->frags = 0;
p->plag = 0;
p->ping = 0;
p->lastupdate = lastmillis;
p->enemy = NULL;
p->monsterstate = 0;
p->name[0] = p->team[0] = 0;
p->blocked = false;
p->lifesequence = 0;
p->state = CS_ALIVE;
p->shots = 0;
p->reloading = false;
p->nextprimary = 1;
p->hasarmour = false;
p->k_left = false;
p->k_right = false;
p->k_up = false;
p->k_down = false;
p->jumpnext = false;
p->strafe = 0;
p->move = 0;
p->bounce = true;
p->gravity = 20;
p->timeinair = 0;
p->throwed = true;
p->onfloor = false;
p->lifetime = 3000;
p->o = d->o;
// float speed = sin(rad((d->pitch+90)/2.0f));
p->vel.z = sin(rad(d->pitch));
float speed = cos(rad(d->pitch));
p->vel.x = sin(rad(d->yaw))*speed;
p->vel.y = -cos(rad(d->yaw))*speed;
vmul(p->vel, 1.5f);
vec throwdir = p->vel;
vmul(throwdir, d->radius);
vadd(p->o, throwdir);
vadd(p->o, throwdir);
if(!nade) // add new one
{
p->millis = lastmillis;
physents.add(p);
};
};
void activate_nade()
{
physent *p = (physent *)gp()->alloc(sizeof(physent));
p->owner = player1;
p->millis = lastmillis;
p->lifetime = 3000;
p->throwed = false;
p->enabled = true;
curnade = p;
physents.add(p);
nade_activated = true;
};
extern void explode_nade(physent *i)
{
if(!i) return;
if(!i->throwed)
{
vec o = i->owner->o;
vec dist = { 0.1f, 0.1f, 0.1f };
vadd(o, dist);
thrownade(i->owner, o, i);
};
newprojectile(i->o, i->o, 1, true, i->owner, GUN_GRENADE);
};
extern float rad(float x);
bool nade_activated = false;
physent *curnade;
void thrownade(dynent *d, vec &to, physent *nade = NULL, int nadesec = 0)
{
physent *p;
if(nade) p = nade;
else p = (physent *)gp()->alloc(sizeof(physent)); // allocate new nade
p->owner = d;
p->yaw = 270;
p->pitch = 0;
p->roll = 0;
p->maxspeed = 40; //16 max speed, 14 max with armour
p->outsidemap = false;
p->inwater = false;
p->radius = 0.2f;
p->eyeheight = 0.3f;
p->aboveeye = 0.0f;
p->frags = 0;
p->plag = 0;
p->ping = 0;
p->lastupdate = lastmillis;
p->enemy = NULL;
p->monsterstate = 0;
p->name[0] = p->team[0] = 0;
p->blocked = false;
p->lifesequence = 0;
p->state = CS_ALIVE;
p->shots = 0;
p->reloading = false;
p->nextprimary = 1;
p->hasarmour = false;
p->k_left = false;
p->k_right = false;
p->k_up = false;
p->k_down = false;
p->jumpnext = false;
p->strafe = 0;
p->move = 0;
p->bounce = true;
p->gravity = 20;
p->timeinair = 0;
p->throwed = true;
p->onfloor = false;
p->lifetime = 3000;
p->o = d->o;
// float speed = sin(rad((d->pitch+90)/2.0f));
p->vel.z = sin(rad(d->pitch));
float speed = cos(rad(d->pitch));
p->vel.x = sin(rad(d->yaw))*speed;
p->vel.y = -cos(rad(d->yaw))*speed;
vmul(p->vel, 1.7f);
vec throwdir = p->vel;
vmul(throwdir, d->radius);
vadd(p->o, throwdir);
vadd(p->o, throwdir);
if(!nade) // add new one
{
p->millis = lastmillis;
physents.add(p);
};
};
void activate_nade()
{
physent *p = (physent *)gp()->alloc(sizeof(physent));
p->owner = player1;
p->millis = lastmillis;
p->lifetime = 3000;
p->throwed = false;
p->enabled = true;
curnade = p;
physents.add(p);
nade_activated = true;
};
extern void explode_nade(physent *i)
{
if(!i) return;
if(!i->throwed)
{
vec o = i->owner->o;
vec dist = { 0.1f, 0.1f, 0.1f };
vadd(o, dist);
thrownade(i->owner, o, i);
};
newprojectile(i->o, i->o, 1, true, i->owner, GUN_GRENADE);
};
void shootv(int gun, vec &from, vec &to, dynent *d, bool local, int nadesec) // create visual effect from a shot
{
@@ -421,22 +421,22 @@ void shootv(int gun, vec &from, vec &to, dynent *d, bool local, int nadesec)
case GUN_PISTOL:
case GUN_SUBGUN:
case GUN_ASSULT:
case GUN_ASSULT:
addshotline(d, from, to);
particle_splash(0, 100, 250, to);
particle_splash(9, 5, 250, to);
//particle_trail(1, 10, from, to);
break;
case GUN_GRENADE:
pspeed = guns[gun].projspeed;
//newprojectile(from, to, (float)pspeed, local, d, gun);
if(d==player1 && curnade)
thrownade(d, to, curnade);
else
//newprojectile(from, to, (float)pspeed, local, d, gun);
if(d==player1 && curnade)
thrownade(d, to, curnade);
else
thrownade(d, to, NULL, nadesec);
break;
case GUN_SNIPER:
case GUN_SNIPER:
addshotline(d, from, to);
particle_splash(0, 50, 200, to);
particle_trail(1, 500, from, to);
@@ -477,8 +477,8 @@ void spreadandrecoil(vec & from, vec & to, dynent * d)
//recoil
int rcl = guns[d->gunselect].recoil*-0.01f;␍
if (d->gunselect==GUN_ASSULT)
{
if(d->shots > 3)
{
if(d->shots > 3)
spd = 70;
rcl += (rnd(8)*-0.01f);
};␍
@@ -488,7 +488,7 @@ void spreadandrecoil(vec & from, vec & to, dynent * d)
rcl = rcl / 3;
};␍
if (d->gunselect!=GUN_SHOTGUN) //no spread on shotgun
{
{
#define RNDD (rnd(spd)-spd/2)*f
vec r = { RNDD, RNDD, RNDD };
vadd(to, r);
@@ -537,76 +537,76 @@ void spreadandrecoil(vec & from, vec & to, dynent * d)
vadd(d->vel, recoil);
if(d->pitch<80.0f) d->pitch += guns[d->gunselect].recoil*0.05f;
*/
};
void shoot(dynent *d, vec &targ)
{
bool grenade_throw = d->gunselect==GUN_GRENADE && !d->attacking && nade_activated;
int attacktime = lastmillis-d->lastaction;
if(d->reloading && (attacktime<d->gunwait) && !grenade_throw) return;
else if(attacktime<d->gunwait) return;
d->gunwait = 0;
d->reloading = false;
if(grenade_throw)
{
d->attacking = true;
nade_activated = false;
d->gunwait = guns[d->gunselect].attackdelay;
}
else if(d->gunselect==GUN_GRENADE && d->attacking && nade_activated) return;
if(!d->attacking)
{
d->shots = 0;
return;
};
if(!(d->gunselect==GUN_SUBGUN || d->gunselect==GUN_ASSULT)) d->attacking = false; //makes sub/assult autos
else
{
d->shots++;
};
d->lastaction = lastmillis;
d->lastattackgun = d->gunselect;
if(!d->mag[d->gunselect]) { playsoundc(S_NOAMMO); d->gunwait = 250; d->lastattackgun = -1; return; };
if(d->gunselect==GUN_GRENADE && !grenade_throw)
{
activate_nade();
d->attacking = true;
return;
}
if(d->gunselect) d->mag[d->gunselect]--;
vec from = d->o;
vec to = targ;
from.z -= 0.2f; // below eye
spreadandrecoil(from,to,d);
vdist(dist, unitv, from, to);
vdiv(unitv, dist);
if(d->gunselect==GUN_KNIFE)
{
vmul(unitv, 3); // punch range
to = from;
vadd(to, unitv);
};
if(d->gunselect==GUN_SHOTGUN) createrays(from, to);
//if(d->quadmillis && attacktime>200) playsoundc(S_ITEMPUP);
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), (int) grenade_throw ? lastmillis-curnade->millis : 0 );
d->gunwait = guns[d->gunselect].attackdelay;
if(guns[d->gunselect].projspeed) return;
loopv(players)
{
dynent *o = players[i];
if(!o) continue;
raydamage(o, from, to, d, i);
};
};
void shoot(dynent *d, vec &targ)
{
bool grenade_throw = d->gunselect==GUN_GRENADE && !d->attacking && nade_activated;
int attacktime = lastmillis-d->lastaction;
if(d->reloading && (attacktime<d->gunwait) && !grenade_throw) return;
else if(attacktime<d->gunwait) return;
d->gunwait = 0;
d->reloading = false;
if(grenade_throw)
{
d->attacking = true;
nade_activated = false;
d->gunwait = guns[d->gunselect].attackdelay;
}
else if(d->gunselect==GUN_GRENADE && d->attacking && nade_activated) return;
if(!d->attacking)
{
d->shots = 0;
return;
};
if(!(d->gunselect==GUN_SUBGUN || d->gunselect==GUN_ASSULT)) d->attacking = false; //makes sub/assult autos
else
{
d->shots++;
};
d->lastaction = lastmillis;
d->lastattackgun = d->gunselect;
if(!d->mag[d->gunselect]) { playsoundc(S_NOAMMO); d->gunwait = 250; d->lastattackgun = -1; return; };
if(d->gunselect==GUN_GRENADE && !grenade_throw)
{
activate_nade();
d->attacking = true;
return;
}
if(d->gunselect) d->mag[d->gunselect]--;
vec from = d->o;
vec to = targ;
from.z -= 0.2f; // below eye
spreadandrecoil(from,to,d);
vdist(dist, unitv, from, to);
vdiv(unitv, dist);
if(d->gunselect==GUN_KNIFE)
{
vmul(unitv, 3); // punch range
to = from;
vadd(to, unitv);
};
if(d->gunselect==GUN_SHOTGUN) createrays(from, to);
//if(d->quadmillis && attacktime>200) playsoundc(S_ITEMPUP);
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), (int) grenade_throw ? lastmillis-curnade->millis : 0 );
d->gunwait = guns[d->gunselect].attackdelay;
if(guns[d->gunselect].projspeed) return;
loopv(players)
{
dynent *o = players[i];
if(!o) continue;
raydamage(o, from, to, d, i);
};
};