footstep sound bug, nosway
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1415 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -375,7 +375,7 @@ void showteamkill() { player1->lastteamkill = lastmillis; }
|
||||
|
||||
void dodamage(int damage, playerent *pl, playerent *actor, bool gib, bool local)
|
||||
{
|
||||
if(pl->state!=CS_ALIVE || intermission) return;
|
||||
if(pl->state != CS_ALIVE || pl->state == CS_EDITING || intermission) return;
|
||||
|
||||
pl->lastpain = lastmillis;
|
||||
if(local) damage = pl->dodamage(damage);
|
||||
|
||||
+13
-9
@@ -23,15 +23,19 @@ struct weaponmove
|
||||
pos = player1->o;
|
||||
anim = ANIM_GUN_IDLE;
|
||||
|
||||
float k = pow(0.7f, (lastmillis-lastsway)/10.0f);
|
||||
swaydir.mul(k);
|
||||
vec dv(player1->vel);
|
||||
dv.mul((1-k)/max(player1->vel.magnitude(), player1->maxspeed));
|
||||
dv.x *= 1.5f;
|
||||
dv.y *= 1.5f;
|
||||
dv.z *= 0.4f;
|
||||
swaydir.add(dv);
|
||||
pos.add(swaydir);
|
||||
if(!nosway)
|
||||
{
|
||||
float k = pow(0.7f, (lastmillis-lastsway)/10.0f);
|
||||
swaydir.mul(k);
|
||||
vec dv(player1->vel);
|
||||
dv.mul((1-k)/max(player1->vel.magnitude(), player1->maxspeed));
|
||||
dv.x *= 1.5f;
|
||||
dv.y *= 1.5f;
|
||||
dv.z *= 0.4f;
|
||||
swaydir.add(dv);
|
||||
pos.add(swaydir);
|
||||
}
|
||||
|
||||
if(player1->onfloor || player1->onladder || player1->inwater) swaymillis += lastmillis-lastsway;
|
||||
lastsway = lastmillis;
|
||||
|
||||
|
||||
@@ -2114,7 +2114,7 @@ void serverslice(uint timeout) // main server update, called from cube main lo
|
||||
int nonlocalclients = numnonlocalclients();
|
||||
|
||||
if((smode>1 || (gamemode==0 && nonlocalclients)) && gamemillis-diff>0 && gamemillis/60000!=(gamemillis-diff)/60000)
|
||||
checkintermission();
|
||||
checkintermission();
|
||||
if(interm && gamemillis>interm)
|
||||
{
|
||||
if(demorecord) enddemorecord();
|
||||
|
||||
+19
-37
@@ -40,6 +40,7 @@ struct soundslot
|
||||
sample *s;
|
||||
int vol;
|
||||
int uses, maxuses;
|
||||
bool loop;
|
||||
};
|
||||
|
||||
struct soundloc
|
||||
@@ -198,7 +199,7 @@ int findsound(char *name, int vol, vector<soundslot> &sounds)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int addsound(char *name, int vol, int maxuses, vector<soundslot> &sounds)
|
||||
int addsound(char *name, int vol, int maxuses, bool loop, vector<soundslot> &sounds)
|
||||
{
|
||||
sample *s = samples.access(name);
|
||||
if(!s)
|
||||
@@ -213,14 +214,15 @@ int addsound(char *name, int vol, int maxuses, vector<soundslot> &sounds)
|
||||
slot.vol = vol ? vol : 100;
|
||||
slot.uses = 0;
|
||||
slot.maxuses = maxuses;
|
||||
slot.loop = loop;
|
||||
return sounds.length()-1;
|
||||
}
|
||||
|
||||
void registersound(char *name, char *vol) { addsound(name, atoi(vol), 0, gamesounds); }
|
||||
COMMAND(registersound, ARG_2STR);
|
||||
void registersound(char *name, char *vol, char *loop) { addsound(name, atoi(vol), 0, atoi(loop) != 0, gamesounds); }
|
||||
COMMAND(registersound, ARG_3STR);
|
||||
|
||||
void mapsound(char *name, char *vol, char *maxuses) { addsound(name, atoi(vol), atoi(maxuses) < 0 ? 0 : max(1, *maxuses), mapsounds); }
|
||||
COMMAND(mapsound, ARG_3STR);
|
||||
void mapsound(char *name, char *vol, char *maxuses, char *loop) { addsound(name, atoi(vol), atoi(maxuses) < 0 ? 0 : max(1, *maxuses), atoi(loop) != 0, mapsounds); }
|
||||
COMMAND(mapsound, ARG_4STR);
|
||||
|
||||
void cleansound()
|
||||
{
|
||||
@@ -262,7 +264,6 @@ void checkmapsounds()
|
||||
}
|
||||
|
||||
VAR(footsteps, 0, 1, 1);
|
||||
VAR(footstepalign, 5, 15, 4000);
|
||||
|
||||
int findsoundloc(int sound, physent *p)
|
||||
{
|
||||
@@ -272,33 +273,15 @@ int findsoundloc(int sound, physent *p)
|
||||
|
||||
void checkplayerloopsounds()
|
||||
{
|
||||
loopv(players)
|
||||
if(footsteps)
|
||||
{
|
||||
playerent *p = players[i];
|
||||
if(!p) continue;
|
||||
|
||||
if(footsteps && camera1->o.dist(p->o) < 16)
|
||||
{
|
||||
int idx = findsoundloc(S_FOOTSTEPS, p);
|
||||
if(idx == -1 || !soundlocs[idx].inuse)
|
||||
{
|
||||
// sync to model animation
|
||||
int basetime = -((int)(size_t)p&0xFFF);
|
||||
int time = lastmillis-basetime;
|
||||
int speed = int(1860/p->maxspeed);
|
||||
// TODO: share with model code
|
||||
|
||||
if(time%speed < footstepalign) playsound(S_FOOTSTEPS, p);
|
||||
}
|
||||
if(findsoundloc(S_FOOTSTEPS, player1) == -1) playsound(S_FOOTSTEPS, player1);
|
||||
loopv(players)
|
||||
{
|
||||
playerent *p = players[i];
|
||||
if(!p) continue;
|
||||
if(findsoundloc(S_FOOTSTEPS, p) == -1) playsound(S_FOOTSTEPS, p);
|
||||
}
|
||||
|
||||
// add other sounds here
|
||||
}
|
||||
|
||||
if(footsteps && (player1->move || player1->strafe))
|
||||
{
|
||||
int idx = findsoundloc(S_FOOTSTEPS, player1);
|
||||
if(idx == -1 || !soundlocs[idx].inuse) playsound(S_FOOTSTEPS, player1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,8 +319,8 @@ void updatechanvol(int chan, int svol, soundloc *sl)
|
||||
{
|
||||
playerent *p = (playerent *)sl->pse;
|
||||
ASSERT(p);
|
||||
bool nofootsteps = p->state != CS_ALIVE || lastmillis-p->lastpain < 300 || (!p->onfloor && p->timeinair>50) || (!p->move && !p->strafe);
|
||||
if(nofootsteps) vol = 0; // TODO: fade out?
|
||||
bool nofootsteps = !footsteps || p->state != CS_ALIVE || lastmillis-p->lastpain < 300 || (!p->onfloor && p->timeinair>50) || (!p->move && !p->strafe);
|
||||
if(nofootsteps) vol = 0; // fade out instead?
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,7 +357,6 @@ soundloc *newsoundloc(int sound, int chan, soundslot *slot, physent *p = NULL, e
|
||||
if(!p && !ent && !loc) return NULL;
|
||||
while(chan >= soundlocs.length()) soundlocs.add().inuse = false;
|
||||
soundloc *sl = &soundlocs[chan];
|
||||
sl->inuse = true;
|
||||
sl->slot = slot;
|
||||
sl->pse = p;
|
||||
sl->ent = ent && !p ? ent : NULL;
|
||||
@@ -439,7 +421,7 @@ void playsound(int n, physent *p, entity *ent, const vec *loc)
|
||||
#ifdef USE_MIXER
|
||||
slot.s->sound = Mix_LoadWAV(file);
|
||||
#else
|
||||
slot.s->sound = FSOUND_Sample_Load(ent ? n+gamesounds.length() : n, file, FSOUND_LOOP_OFF, 0, 0);
|
||||
slot.s->sound = FSOUND_Sample_Load(ent ? n+gamesounds.length() : n, file, slot.loop ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF, 0, 0);
|
||||
#endif
|
||||
if(slot.s->sound) break;
|
||||
}
|
||||
@@ -448,7 +430,7 @@ void playsound(int n, physent *p, entity *ent, const vec *loc)
|
||||
}
|
||||
|
||||
#ifdef USE_MIXER
|
||||
int chan = Mix_PlayChannel(-1, slot.s->sound, 0);
|
||||
int chan = Mix_PlayChannel(-1, slot.s->sound, slot.loop ? -1 : 0);
|
||||
#else
|
||||
int chan = FSOUND_PlaySoundEx(FSOUND_FREE, slot.s->sound, NULL, true);
|
||||
#endif
|
||||
@@ -465,7 +447,7 @@ void playsoundname(char *s, const vec *loc, int vol)
|
||||
{
|
||||
if(!vol) vol = 100;
|
||||
int id = findsound(s, vol, gamesounds);
|
||||
if(id < 0) id = addsound(s, vol, 0, gamesounds);
|
||||
if(id < 0) id = addsound(s, vol, 0, false, gamesounds);
|
||||
playsound(id, NULL, NULL, loc);
|
||||
}
|
||||
|
||||
|
||||
@@ -389,7 +389,7 @@ void moveprojectiles(float time)
|
||||
{
|
||||
if(p.local)
|
||||
addmsg(SV_EXPLODE, "ri3iv", lastmillis, p.gun, p.id,
|
||||
hits.length(), hits.length()*sizeof(hitmsg)/sizeof(int), hits.getbuf());
|
||||
hits.length(), hits.length()*sizeof(hitmsg)/sizeof(int), hits.getbuf());
|
||||
projs.remove(i--);
|
||||
}
|
||||
else p.o = v;
|
||||
@@ -535,7 +535,7 @@ void thrownade(playerent *d, bounceent *p)
|
||||
thrownade(d, vel, p);
|
||||
}
|
||||
|
||||
bounceent *new_nade(playerent *d, int millis = 0)
|
||||
bounceent *newnade(playerent *d, int millis = 0)
|
||||
{
|
||||
bounceent *p = newbounceent();
|
||||
p->owner = d;
|
||||
@@ -592,7 +592,7 @@ void shootv(int gun, vec &from, vec &to, playerent *d, bool local, int nademilli
|
||||
{
|
||||
if(d!=player1)
|
||||
{
|
||||
bounceent *p = new_nade(d, nademillis);
|
||||
bounceent *p = newnade(d, nademillis);
|
||||
thrownade(d, to, p);
|
||||
}
|
||||
break;
|
||||
@@ -746,7 +746,7 @@ void shoot(playerent *d, vec &targ)
|
||||
{
|
||||
if(!hasammo(d)) return;
|
||||
d->mag[d->gunselect]--;
|
||||
new_nade(d);
|
||||
newnade(d);
|
||||
updatelastaction(d);
|
||||
d->gunwait[d->gunselect] = attackdelay(d->gunselect);
|
||||
d->lastattackgun = d->gunselect;
|
||||
|
||||
Reference in New Issue
Block a user