diff --git a/source/src/entity.h b/source/src/entity.h index 372e8bab..cbf56a8d 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -342,13 +342,11 @@ struct playerent : dynent, playerstate weapon *weapons[NUMGUNS]; weapon *weaponsel, *nextweaponsel, *primweap, *nextprimweap, *lastattackweapon; - struct bounceent *inhandnade; - poshist history; // Previous stored locations of this player playerent() : clientnum(-1), plag(0), ping(0), lifesequence(0), frags(0), flagscore(0), lastpain(0), clientrole(CR_DEFAULT), skin(0), nextskin(0), spectating(SM_NONE), followplayercn(0), - weaponsel(NULL), nextweaponsel(NULL), primweap(NULL), nextprimweap(NULL), lastattackweapon(NULL), inhandnade(NULL) + weaponsel(NULL), nextweaponsel(NULL), primweap(NULL), nextprimweap(NULL), lastattackweapon(NULL) { type = ENT_PLAYER; name[0] = team[0] = 0; diff --git a/source/src/physics.cpp b/source/src/physics.cpp index dba925b2..77754e61 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -182,7 +182,7 @@ bool collide(physent *d, bool spawn, float drop, float rise) if(!plcollide(d, o, headspace, hi, lo)) return false; } - if(d!=player1 && !(d->type==ENT_BOUNCE && player1->inhandnade==((bounceent *)d))) if(!plcollide(d, player1, headspace, hi, lo)) return false; + if(d!=player1 && !(d->type==ENT_BOUNCE && ((bounceent *)d)->bouncestate==NADE_ACTIVATED || ((bounceent *)d)->bouncestate==NADE_THROWED)) if(!plcollide(d, player1, headspace, hi, lo)) return false; headspace -= 0.01f; mmcollide(d, hi, lo); // collide with map models diff --git a/source/src/renderparticles.cpp b/source/src/renderparticles.cpp index cd07dd02..0b84b248 100644 --- a/source/src/renderparticles.cpp +++ b/source/src/renderparticles.cpp @@ -542,11 +542,19 @@ void addshotline(dynent *pl, vec &from, vec &to) float dist = to.dist(from, unitv); unitv.div(dist); + // shotline visuals vec o = unitv; o.mul(dist/10+start).add(from); vec d = unitv; d.mul(dist/10*-(10-start-2)).add(to); newparticle(o, d, fx ? shotlinettl : 75, 6); - //playsound(S_BULLETAIR, NULL, NULL, NULL), + + // shotline sound fx + vec fromuv, touv, soundpos(unitv); + float fd = camera1->o.dist(from, fromuv); + float td = camera1->o.dist(to, touv); + soundpos.mul(fd/(fd+td)*dist); + soundpos.add(from); + playsound(S_BULLETAIR, NULL, NULL, &soundpos); } diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index d77efd6f..32b13334 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -670,10 +670,11 @@ struct grenadeent : bounceent struct grenades : weapon { + grenadeent *inhandnade; const int throwwait; int throwmillis; - grenades(playerent *owner) : weapon(owner, GUN_GRENADE), throwwait((13*1000)/40), throwmillis(0) {} + grenades(playerent *owner) : weapon(owner, GUN_GRENADE), inhandnade(NULL), throwwait((13*1000)/40), throwmillis(0) {} bool attack(vec &targ) { @@ -696,11 +697,12 @@ struct grenades : weapon gunwait = reloading = 0; - if(owner->attacking && !owner->inhandnade) // activate + if(owner->attacking && !inhandnade) // activate { if(!mag) return false; throwmillis = 0; - owner->inhandnade = bounceents.add(new grenadeent(owner)); + inhandnade = new grenadeent(owner); + bounceents.add(inhandnade); updatelastaction(owner); mag--; gunwait = info.attackdelay; @@ -711,7 +713,7 @@ struct grenades : weapon 0); playsound(S_GRENADEPULL); } - else if(!owner->attacking && owner->inhandnade && attackmillis>info.attackdelay) thrownade(); + else if(inhandnade && attackmillis>info.attackdelay && (!owner->attacking || !inhandnade->isalive(lastmillis))) thrownade(); return true; } @@ -721,8 +723,9 @@ struct grenades : weapon if(millis == 0) playsound(S_GRENADEPULL, owner); // activate else if(millis > 0) // throw { - owner->inhandnade = bounceents.add(new grenadeent(owner, millis)); - thrownade(from, to, owner->inhandnade); + inhandnade = new grenadeent(owner, millis); + bounceents.add(inhandnade); + thrownade(from, to, inhandnade); } } @@ -737,8 +740,8 @@ struct grenades : weapon return ANIM_GUN_IDLE; } - bool throwing() { return throwmillis && !owner->inhandnade; } - bool inhand() { return throwmillis <= 0 && owner->inhandnade; } + bool throwing() { return throwmillis && !inhandnade; } + bool inhand() { return throwmillis <= 0 && inhandnade; } void thrownade() { @@ -748,7 +751,7 @@ struct grenades : weapon vec from(vel); from.mul(1.1f*owner->radius); from.add(owner->o); - thrownade(from, vel, owner->inhandnade); + thrownade(from, vel, inhandnade); } void thrownade(const vec &from, const vec &vel, bounceent *p) @@ -760,7 +763,7 @@ struct grenades : weapon loopi(10) moveplayer(p, 10, true, 10); p->bouncestate = NADE_THROWED; - owner->inhandnade = NULL; + inhandnade = NULL; throwmillis = lastmillis; @@ -788,7 +791,7 @@ struct grenades : weapon void onownerdies() { reset(); - if(owner==player1 && owner->inhandnade) ((grenadeent *)owner->inhandnade)->explode(); + if(owner==player1 && inhandnade) inhandnade->explode(); } }; @@ -954,7 +957,7 @@ struct akimbo : gun akimbomillis = lastmillis + 30000; if(owner==player1) { - if(owner->weaponsel->type!=GUN_SNIPER && !owner->inhandnade) weaponswitch(this); + if(owner->weaponsel->type!=GUN_SNIPER && owner->weaponsel->type!=GUN_GRENADE) weaponswitch(this); addmsg(SV_AKIMBO, "ri", lastmillis); } }