removed old (nade) projectile code, menu sounds
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1812 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -201,7 +201,6 @@ void freebotent(botent *d)
|
||||
void zapplayer(playerent *&d)
|
||||
{
|
||||
removebounceents(d);
|
||||
removeprojectiles(d);
|
||||
DELETEP(d);
|
||||
}
|
||||
|
||||
@@ -289,7 +288,6 @@ void updateworld(int curtime, int lastmillis) // main game update loop
|
||||
physicsframe();
|
||||
checkweaponswitch();
|
||||
checkakimbo();
|
||||
moveprojectiles((float)curtime);
|
||||
if(getclientnum()>=0) shoot(player1, worldpos); // only shoot when connected to server
|
||||
gets2c(); // do this first, so we have most accurate information when our player moves
|
||||
movebounceents();
|
||||
@@ -375,8 +373,7 @@ void spawnplayer(playerent *d)
|
||||
|
||||
void respawnself()
|
||||
{
|
||||
/*if(player1->isspectating()) findplayerstart(player1, true);
|
||||
else*/ if(m_mp(gamemode)) addmsg(SV_TRYSPAWN, "r");
|
||||
if(m_mp(gamemode)) addmsg(SV_TRYSPAWN, "r");
|
||||
else
|
||||
{
|
||||
showscores(false);
|
||||
@@ -551,7 +548,6 @@ void startmap(const char *name) // called just after a map load
|
||||
if(m_botmode) BotManager.BeginMap(name);
|
||||
else kickallbots();
|
||||
// End add by Rick
|
||||
projreset();
|
||||
clearbounceents();
|
||||
resetspawns();
|
||||
if(m_ctf) preparectf();
|
||||
|
||||
@@ -45,7 +45,6 @@ void toggleedit()
|
||||
{
|
||||
player1->health = 100;
|
||||
//put call to clear/restart gamemode
|
||||
projreset();
|
||||
player1->attacking = false;
|
||||
}
|
||||
keyrepeat(editmode);
|
||||
|
||||
@@ -458,11 +458,19 @@ struct bounceent : physent // nades, gibs
|
||||
virtual void destroy() {}
|
||||
};
|
||||
|
||||
struct hitmsg
|
||||
{
|
||||
int target, lifesequence, info;
|
||||
ivec dir;
|
||||
};
|
||||
|
||||
struct grenadeent : bounceent
|
||||
{
|
||||
grenadeent (playerent *owner, int millis = 0);
|
||||
void activate(vec &from, vec &to);
|
||||
void _throw();
|
||||
void explode();
|
||||
void splash();
|
||||
virtual void destroy();
|
||||
};
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ void menuselect(void *menu, int sel)
|
||||
{
|
||||
m.items[oldsel]->focus(false);
|
||||
m.items[sel]->focus(true);
|
||||
playsound(S_MENUSELECT, SP_HIGH);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -601,6 +602,7 @@ bool menukey(int code, bool isdown, int unicode)
|
||||
if(code==SDLK_RETURN || code==SDLK_SPACE || code==-1 || code==-2)
|
||||
{
|
||||
m.select();
|
||||
playsound(S_MENUENTER, SP_HIGH);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
+2
-5
@@ -93,7 +93,7 @@ struct mitem
|
||||
virtual void render(int x, int y, int w);
|
||||
virtual int width() = 0;
|
||||
virtual void select() {}
|
||||
virtual void focus(bool on) {}
|
||||
virtual void focus(bool on) { }
|
||||
virtual void key(int code, bool isdown, int unicode) { }
|
||||
virtual void init() {}
|
||||
bool isselection();
|
||||
@@ -459,14 +459,11 @@ extern void renderclient(playerent *d, const char *mdlname, const char *vwepname
|
||||
// weapon
|
||||
extern void shoot(playerent *d, vec &to);
|
||||
extern void createrays(vec &from, vec &to);
|
||||
extern void moveprojectiles(float time);
|
||||
extern void removebounceents(playerent *owner);
|
||||
extern void movebounceents();
|
||||
extern void clearbounceents();
|
||||
extern void renderbounceents();
|
||||
extern void addgib(playerent *d);
|
||||
extern void projreset();
|
||||
extern void removeprojectiles(playerent *d);
|
||||
extern playerent *playerincrosshair();
|
||||
extern int magsize(int gun);
|
||||
extern void checkweaponswitch();
|
||||
@@ -477,7 +474,7 @@ extern bool intersect(entity *e, const vec &from, const vec &to, vec *end = NULL
|
||||
extern void damageeffect(int damage, playerent *d);
|
||||
extern void tryreload(playerent *p);
|
||||
extern void checkakimbo();
|
||||
extern void newprojectile(vec &from, vec &to, float speed, bool local, playerent *owner, int gun, int id = lastmillis);
|
||||
extern struct projectile *newprojectile(vec &from, vec &to, float speed, bool local, playerent *owner, int gun, int id = lastmillis);
|
||||
|
||||
// entities
|
||||
extern const char *entnames[];
|
||||
|
||||
@@ -22,6 +22,7 @@ enum
|
||||
S_RAKIMBO, S_GUNCHANGE, S_GIB, S_HEADSHOT,
|
||||
S_CALLVOTE, S_VOTEPASS, S_VOTEFAIL,
|
||||
S_FOOTSTEPS, S_FOOTSTEPSCROUCH,
|
||||
S_MENUSELECT, S_MENUENTER,
|
||||
S_AFFIRMATIVE,
|
||||
S_ALLRIGHTSIR,
|
||||
S_COMEONMOVE,
|
||||
|
||||
+71
-156
@@ -175,43 +175,14 @@ playerent *playerincrosshair()
|
||||
return intersectclosest(player1->o, worldpos, player1);
|
||||
}
|
||||
|
||||
struct projectile { vec o, to; float speed; playerent *owner; int gun; bool local; int id; };
|
||||
vector<projectile > projs;
|
||||
|
||||
void projreset() { projs.setsize(0); }
|
||||
|
||||
void newprojectile(vec &from, vec &to, float speed, bool local, playerent *owner, int gun, int id)
|
||||
{
|
||||
projectile &p = projs.add();
|
||||
p.o = from;
|
||||
p.to = to;
|
||||
p.speed = speed;
|
||||
p.local = local;
|
||||
p.owner = owner;
|
||||
p.gun = gun;
|
||||
p.id = id;
|
||||
}
|
||||
|
||||
void removeprojectiles(playerent *owner)
|
||||
{
|
||||
loopv(projs) if(projs[i].owner==owner) projs.remove(i--);
|
||||
}
|
||||
|
||||
void damageeffect(int damage, playerent *d)
|
||||
{
|
||||
particle_splash(3, damage/10, 1000, d->o);
|
||||
}
|
||||
|
||||
struct hitmsg
|
||||
{
|
||||
int target, lifesequence, info;
|
||||
ivec dir;
|
||||
};
|
||||
|
||||
vector<hitmsg> hits;
|
||||
|
||||
|
||||
|
||||
void hit(int damage, playerent *d, playerent *at, const vec &vel, int gun, bool gib, int info)
|
||||
{
|
||||
if(d==player1 || d->type==ENT_BOT || !m_mp(gamemode)) d->hitpush(damage, vel, at, gun);
|
||||
@@ -227,7 +198,6 @@ void hit(int damage, playerent *d, playerent *at, const vec &vel, int gun, bool
|
||||
{
|
||||
h.dir = ivec(0, 0, 0);
|
||||
d->damageroll(damage);
|
||||
//damageblend(damage);
|
||||
updatedmgindicator(at->o);
|
||||
playsound(S_PAIN6);
|
||||
}
|
||||
@@ -270,93 +240,6 @@ void radialeffect(playerent *o, vec &v, int qdam, playerent *at, int gun)
|
||||
}
|
||||
}
|
||||
|
||||
void splash(projectile &p, vec &v, vec &vold, playerent *notthis, int qdam)
|
||||
{
|
||||
particle_splash(0, 50, 300, v);
|
||||
if(p.gun!=GUN_GRENADE)
|
||||
{
|
||||
playsound(S_FEXPLODE, &v);
|
||||
// no push?
|
||||
}
|
||||
else
|
||||
{
|
||||
//playsound(S_RLHIT, &v);
|
||||
particle_fireball(5, v);
|
||||
addscorchmark(v);
|
||||
dodynlight(vold, v, 0, 0, p.owner);
|
||||
if(!p.local) return;
|
||||
radialeffect(player1, v, qdam, p.owner, p.gun);
|
||||
loopv(players)
|
||||
{
|
||||
playerent *o = players[i];
|
||||
if(!o || o==notthis) continue;
|
||||
radialeffect(o, v, qdam, p.owner, p.gun);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool projdamage(playerent *o, projectile &p, vec &v, int qdam)
|
||||
{
|
||||
if(o->state!=CS_ALIVE || !intersect(o, p.o, v)) return false;
|
||||
splash(p, v, p.o, o, qdam);
|
||||
vec dir;
|
||||
expdist(o, dir, v);
|
||||
hit(qdam, o, p.owner, dir, p.gun, true, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void moveprojectiles(float time)
|
||||
{
|
||||
loopv(projs)
|
||||
{
|
||||
projectile &p = projs[i];
|
||||
int qdam = guns[p.gun].damage;
|
||||
vec v;
|
||||
float dist = p.to.dist(p.o, v);
|
||||
float dtime = dist*1000/p.speed;
|
||||
if(time>dtime) dtime = time;
|
||||
v.mul(time/dtime).add(p.o);
|
||||
bool exploded = false;
|
||||
hits.setsizenodelete(0);
|
||||
if(p.local)
|
||||
{
|
||||
loopvj(players)
|
||||
{
|
||||
playerent *o = players[j];
|
||||
if(!o || p.owner==o || o->o.reject(v, 10.0f)) continue;
|
||||
if(projdamage(o, p, v, qdam)) exploded = true;
|
||||
}
|
||||
if(p.owner!=player1 && projdamage(player1, p, v, qdam)) exploded = true;
|
||||
}
|
||||
if(!exploded)
|
||||
{
|
||||
if(time==dtime)
|
||||
{
|
||||
splash(p, v, p.o, NULL, qdam);
|
||||
exploded = true;
|
||||
}
|
||||
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, NULL, qdam);
|
||||
// End add
|
||||
}
|
||||
}
|
||||
if(exploded)
|
||||
{
|
||||
if(p.local)
|
||||
addmsg(SV_EXPLODE, "ri3iv", lastmillis, p.gun, p.id,
|
||||
hits.length(), hits.length()*sizeof(hitmsg)/sizeof(int), hits.getbuf());
|
||||
projs.remove(i--);
|
||||
}
|
||||
else p.o = v;
|
||||
}
|
||||
}
|
||||
|
||||
vector<bounceent *> bounceents;
|
||||
|
||||
void removebounceents(playerent *owner)
|
||||
@@ -672,8 +555,44 @@ void grenadeent::explode()
|
||||
{
|
||||
static vec n(0,0,0);
|
||||
if(bouncestate != NADE_THROWED) owner->weapons[GUN_GRENADE]->attack(n);
|
||||
hits.setsizenodelete(0);
|
||||
splash();
|
||||
if(owner == player1)
|
||||
addmsg(SV_EXPLODE, "ri3iv", lastmillis, GUN_GRENADE, millis, // fixme
|
||||
hits.length(), hits.length()*sizeof(hitmsg)/sizeof(int), hits.getbuf());
|
||||
playsound(S_FEXPLODE, &o);
|
||||
newprojectile(o, o, 1, owner==player1, owner, GUN_GRENADE, millis);
|
||||
}
|
||||
|
||||
void grenadeent::splash()
|
||||
{
|
||||
particle_splash(0, 50, 300, o);
|
||||
particle_fireball(5, o);
|
||||
addscorchmark(o);
|
||||
dodynlight(o, o, 0, 0, owner);
|
||||
if(owner != player1) return;
|
||||
int damage = guns[GUN_GRENADE].damage;
|
||||
radialeffect(owner, o, damage, owner, GUN_GRENADE);
|
||||
loopv(players)
|
||||
{
|
||||
playerent *p = players[i];
|
||||
if(!p) continue;
|
||||
radialeffect(p, p->o, damage, owner, GUN_GRENADE);
|
||||
}
|
||||
}
|
||||
|
||||
void grenadeent::activate(vec &from, vec &to)
|
||||
{
|
||||
addmsg(SV_SHOOT, "ri2i6i", millis, owner->weaponsel->type,
|
||||
(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);
|
||||
playsound(S_GRENADEPULL, SP_HIGH);
|
||||
}
|
||||
|
||||
void grenadeent::_throw()
|
||||
{
|
||||
addmsg(SV_THROWNADE, "ri7", int(o.x*DMF), int(o.y*DMF), int(o.z*DMF), int(vel.x*DMF), int(vel.y*DMF), int(vel.z*DMF), lastmillis-millis);
|
||||
playsound(S_GRENADETHROW, SP_HIGH);
|
||||
}
|
||||
|
||||
void grenadeent::destroy()
|
||||
@@ -684,7 +603,7 @@ void grenadeent::destroy()
|
||||
|
||||
// grenades
|
||||
|
||||
grenades::grenades(playerent *owner) : weapon(owner, GUN_GRENADE), inhandnade(NULL), throwwait((13*1000)/40), throwmillis(0) {}
|
||||
grenades::grenades(playerent *owner) : weapon(owner, GUN_GRENADE), inhandnade(NULL), throwwait((13*1000)/40), throwmillis(0), state(GST_NONE) {}
|
||||
|
||||
bool grenades::attack(vec &targ)
|
||||
{
|
||||
@@ -692,10 +611,10 @@ bool grenades::attack(vec &targ)
|
||||
vec &from = owner->o;
|
||||
vec &to = targ;
|
||||
|
||||
if(throwmillis && attackmillis >= throwwait)
|
||||
if(GST_THROWING == state && attackmillis >= throwwait) // throw done
|
||||
{
|
||||
throwmillis = 0;
|
||||
if(!mag)
|
||||
reset();
|
||||
if(!mag) // switch to primary immediately
|
||||
{
|
||||
owner->weaponchanging = lastmillis-1-(weaponchangetime/2);
|
||||
owner->nextweaponsel = owner->weaponsel = owner->primweap;
|
||||
@@ -707,31 +626,12 @@ bool grenades::attack(vec &targ)
|
||||
|
||||
gunwait = reloading = 0;
|
||||
|
||||
if(owner->attacking && !inhandnade) // activate
|
||||
{
|
||||
if(!mag) return false;
|
||||
throwmillis = 0;
|
||||
inhandnade = new grenadeent(owner);
|
||||
bounceents.add(inhandnade);
|
||||
updatelastaction(owner);
|
||||
mag--;
|
||||
gunwait = info.attackdelay;
|
||||
owner->lastattackweapon = this;
|
||||
addmsg(SV_SHOOT, "ri2i6i", lastmillis, owner->weaponsel->type,
|
||||
(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);
|
||||
playsound(S_GRENADEPULL, SP_HIGH);
|
||||
}
|
||||
if(owner->attacking && !inhandnade) activatenade(from, to); // activate
|
||||
else if(inhandnade && attackmillis>info.attackdelay)
|
||||
{
|
||||
if(!owner->attacking) thrownade(); // throw
|
||||
else if(!inhandnade->isalive(lastmillis)) // drop & have fun
|
||||
{
|
||||
vec n(0,0,0);
|
||||
thrownade(owner->o, n, inhandnade);
|
||||
}
|
||||
}
|
||||
else if(!inhandnade->isalive(lastmillis)) dropnade(); // drop & have fun
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -749,23 +649,34 @@ void grenades::attackfx(vec &from, vec &to, int millis) // other player's grenad
|
||||
|
||||
int grenades::modelanim()
|
||||
{
|
||||
if(throwing()) return ANIM_GUN_THROW;
|
||||
if(state == GST_THROWING) return ANIM_GUN_THROW;
|
||||
else
|
||||
{
|
||||
int animtime = min(gunwait, (int)info.attackdelay);
|
||||
if(inhand() || lastmillis - owner->lastaction < animtime) return ANIM_GUN_SHOOT;
|
||||
if(state == GST_INHAND || lastmillis - owner->lastaction < animtime) return ANIM_GUN_SHOOT;
|
||||
}
|
||||
return ANIM_GUN_IDLE;
|
||||
}
|
||||
|
||||
bool grenades::throwing() { return throwmillis && !inhandnade; }
|
||||
bool grenades::inhand() { return throwmillis <= 0 && inhandnade; }
|
||||
void grenades::activatenade(vec &from, vec &to)
|
||||
{
|
||||
if(!mag) return;
|
||||
throwmillis = 0;
|
||||
inhandnade = new grenadeent(owner);
|
||||
bounceents.add(inhandnade);
|
||||
updatelastaction(owner);
|
||||
mag--;
|
||||
gunwait = info.attackdelay;
|
||||
owner->lastattackweapon = this;
|
||||
state = GST_INHAND;
|
||||
inhandnade->activate(from, to);
|
||||
}
|
||||
|
||||
void grenades::thrownade()
|
||||
{
|
||||
const float speed = cosf(RAD*owner->pitch);
|
||||
vec vel(sinf(RAD*owner->yaw)*speed, -cosf(RAD*owner->yaw)*speed, sinf(RAD*owner->pitch));
|
||||
vel.mul(1.5f);
|
||||
vel.mul(1.6f);
|
||||
|
||||
vec from(vel);
|
||||
from.normalize();
|
||||
@@ -777,27 +688,31 @@ void grenades::thrownade()
|
||||
owner->attacking = false;
|
||||
}
|
||||
|
||||
void grenades::thrownade(const vec &from, const vec &vel, bounceent *p)
|
||||
void grenades::thrownade(const vec &from, const vec &vel, grenadeent *p)
|
||||
{
|
||||
if(!p) return;
|
||||
p->vel = vel;
|
||||
p->o = from;
|
||||
p->bouncestate = NADE_THROWED;
|
||||
loopi(10) moveplayer(p, 10, true, 10);
|
||||
|
||||
p->bouncestate = NADE_THROWED;
|
||||
inhandnade = NULL;
|
||||
|
||||
if(owner==player1)
|
||||
{
|
||||
throwmillis = lastmillis;
|
||||
playsound(S_GRENADETHROW, SP_HIGH);
|
||||
updatelastaction(player1);
|
||||
addmsg(SV_THROWNADE, "ri7", int(p->o.x*DMF), int(p->o.y*DMF), int(p->o.z*DMF), int(p->vel.x*DMF), int(p->vel.y*DMF), int(p->vel.z*DMF), lastmillis-p->millis);
|
||||
state = GST_THROWING;
|
||||
p->_throw();
|
||||
}
|
||||
else playsound(S_GRENADETHROW, owner);
|
||||
}
|
||||
|
||||
void grenades::dropnade()
|
||||
{
|
||||
vec n(0,0,0);
|
||||
thrownade(owner->o, n, inhandnade);
|
||||
}
|
||||
|
||||
void grenades::renderstats()
|
||||
{
|
||||
char gunstats[64];
|
||||
@@ -805,8 +720,8 @@ void grenades::renderstats()
|
||||
draw_text(gunstats, 690, 827);
|
||||
}
|
||||
|
||||
bool grenades::selectable() { return weapon::selectable() && !inhand() && mag; }
|
||||
void grenades::reset() { throwmillis = 0; }
|
||||
bool grenades::selectable() { return weapon::selectable() && state != GST_INHAND && mag; }
|
||||
void grenades::reset() { throwmillis = 0; state = GST_NONE; }
|
||||
|
||||
void grenades::onselecting() { reset(); playsound(S_GUNCHANGE); }
|
||||
void grenades::onownerdies()
|
||||
|
||||
+6
-3
@@ -46,20 +46,23 @@ struct weapon
|
||||
struct grenadeent;
|
||||
struct bounceent;
|
||||
|
||||
enum { GST_NONE, GST_INHAND, GST_THROWING };
|
||||
|
||||
struct grenades : weapon
|
||||
{
|
||||
grenadeent *inhandnade;
|
||||
const int throwwait;
|
||||
int throwmillis;
|
||||
int state;
|
||||
|
||||
grenades(playerent *owner);
|
||||
bool attack(vec &targ);
|
||||
void attackfx(vec &from, vec &to, int millis);
|
||||
int modelanim();
|
||||
bool throwing();
|
||||
bool inhand();
|
||||
void activatenade(vec &from, vec &to);
|
||||
void thrownade();
|
||||
void thrownade(const vec &from, const vec &vel, bounceent *p);
|
||||
void thrownade(const vec &from, const vec &vel, grenadeent *p);
|
||||
void dropnade();
|
||||
void renderstats();
|
||||
bool selectable();
|
||||
void reset();
|
||||
|
||||
Reference in New Issue
Block a user