summaryrefslogtreecommitdiff
path: root/src/fpsgame
diff options
context:
space:
mode:
authorxolatile2025-08-10 00:19:46 +0200
committerxolatile2025-08-10 00:19:46 +0200
commit757096e7df15c14b9b10352fa91663483f9e34f8 (patch)
treedcad789d0abd8be76463277dc01bf32c4e6a527b /src/fpsgame
parentb2c89d7060e99a36c8c7ac897b7386686c74deac (diff)
downloadxolatile-badassbug-757096e7df15c14b9b10352fa91663483f9e34f8.tar.xz
xolatile-badassbug-757096e7df15c14b9b10352fa91663483f9e34f8.tar.zst
all
Diffstat (limited to 'src/fpsgame')
-rw-r--r--src/fpsgame/ai.cpp86
-rw-r--r--src/fpsgame/ai.h5
-rw-r--r--src/fpsgame/client.cpp16
-rw-r--r--src/fpsgame/entities.cpp31
-rw-r--r--src/fpsgame/fps.cpp5
-rw-r--r--src/fpsgame/game.h1
-rw-r--r--src/fpsgame/render.cpp7
-rw-r--r--src/fpsgame/server.cpp4
-rw-r--r--src/fpsgame/weapon.cpp37
9 files changed, 49 insertions, 143 deletions
diff --git a/src/fpsgame/ai.cpp b/src/fpsgame/ai.cpp
index b4e631b..b59dbd3 100644
--- a/src/fpsgame/ai.cpp
+++ b/src/fpsgame/ai.cpp
@@ -29,7 +29,7 @@ namespace ai {
float weapmaxdist(int weap) {
return guns[weap].range + 4;
}
- bool weaprange(fpsent *d, int weap, float dist) {
+ bool weaprange(int weap, float dist) {
float mindist = weapmindist(weap), maxdist = weapmaxdist(weap);
return dist >= mindist*mindist && dist <= maxdist*maxdist;
}
@@ -53,16 +53,16 @@ namespace ai {
return false;
}
bool canshoot(fpsent *d, fpsent *e) {
- if(weaprange(d, d->gunselect, e->o.squaredist(d->o)) && targetable(d, e))
+ if(weaprange(d->gunselect, e->o.squaredist(d->o)) && targetable(d, e))
return d->ammo[d->gunselect] > 0 && lastmillis - d->lastaction >= d->gunwait;
return false;
}
bool canshoot(fpsent *d) {
return !d->ai->becareful && d->ammo[d->gunselect] > 0 && lastmillis - d->lastaction >= d->gunwait;
}
- bool hastarget(fpsent *d, aistate &b, fpsent *e, float yaw, float pitch, float dist) {
+ bool hastarget(fpsent *d, float yaw, float pitch, float dist) {
// add margins of error
- if(weaprange(d, d->gunselect, dist) || (d->skill <= 100 && !rnd(d->skill))) {
+ if(weaprange(d->gunselect, dist) || (d->skill <= 100 && !rnd(d->skill))) {
if(d->gunselect == GUN_FIST) return true;
float skew = clamp(float(lastmillis-d->ai->enemymillis)/float((d->skill*guns[d->gunselect].attackdelay/200.f)), 0.f, guns[d->gunselect].projspeed ? 0.25f : 1e16f),
offy = yaw-d->yaw, offp = pitch-d->pitch;
@@ -95,6 +95,7 @@ namespace ai {
if(d->ai) DELETEP(d->ai);
}
void init(fpsent *d, int at, int ocn, int sk, int bn, int pm, const char *name, const char *team) {
+ (void) bn; (void) pm;
loadwaypoints();
fpsent *o = newclient(ocn);
d->aitype = at;
@@ -194,7 +195,7 @@ namespace ai {
if(d->skill <= 100) return d->health <= (111-d->skill)/4;
return false;
}
- bool enemy(fpsent *d, aistate &b, const vec &pos, float guard = SIGHTMIN, int pursue = 0) {
+ bool enemy(fpsent *d, aistate &b, float guard = SIGHTMIN, int pursue = 0) {
fpsent *t = NULL;
vec dp = d->headpos();
float mindist = guard*guard, bestdist = 1e16f;
@@ -232,7 +233,7 @@ namespace ai {
return true;
}
bool defend(fpsent *d, aistate &b, const vec &pos, float guard, float wander, int walk) {
- bool hasenemy = enemy(d, b, pos, wander, d->gunselect == GUN_FIST ? 1 : 0);
+ bool hasenemy = enemy(d, b, wander, d->gunselect == GUN_FIST ? 1 : 0);
if(!walk) {
if(d->feetpos().squaredist(pos) <= guard*guard) {
b.idle = hasenemy ? 2 : 1;
@@ -288,19 +289,7 @@ namespace ai {
if(d->ammo[GUN_GL] > 5) return true;
return false;
}
- void assist(fpsent *d, aistate &b, vector<interest> &interests, bool all, bool force) {
- loopv(players) {
- fpsent *e = players[i];
- if(e == d || (!all && e->aitype != AI_NONE) || !isteam(d->team, e->team)) continue;
- interest &n = interests.add();
- n.state = AI_S_DEFEND;
- n.node = e->lastnode;
- n.target = e->clientnum;
- n.targtype = AI_T_PLAYER;
- n.score = e->o.squaredist(d->o)/(hasgoodammo(d) ? 1e8f : (force ? 1e4f : 1e2f));
- }
- }
- static void tryitem(fpsent *d, extentity &e, int id, aistate &b, vector<interest> &interests, bool force = false) {
+ static void tryitem(fpsent *d, extentity &e, int id, vector<interest> &interests) {
float score = 0;
switch(e.type) {
case I_HEALTH:
@@ -330,18 +319,18 @@ namespace ai {
n.node = closestwaypoint(e.o, SIGHTMIN, true);
n.target = id;
n.targtype = AI_T_ENTITY;
- n.score = d->feetpos().squaredist(e.o)/(force ? -1 : score);
+ n.score = d->feetpos().squaredist(e.o)/score;
}
}
- void items(fpsent *d, aistate &b, vector<interest> &interests, bool force = false) {
+ void items(fpsent *d, vector<interest> &interests) {
loopv(entities::ents) {
extentity &e = *(extentity *)entities::ents[i];
if(!e.spawned() || e.nopickup() || !d->canpickup(e.type)) continue;
- tryitem(d, e, i, b, interests, force);
+ tryitem(d, e, i, interests);
}
}
static vector<int> targets;
- bool parseinterests(fpsent *d, aistate &b, vector<interest> &interests, bool override, bool ignore) {
+ bool parseinterests(fpsent *d, aistate &b, vector<interest> &interests, bool ignore) {
while(!interests.empty()) {
int q = interests.length()-1;
loopi(interests.length()-1) if(interests[i].score < interests[q].score) q = i;
@@ -362,12 +351,12 @@ namespace ai {
}
return false;
}
- bool find(fpsent *d, aistate &b, bool override = false) {
+ bool find(fpsent *d, aistate &b) {
static vector<interest> interests;
interests.setsize(0);
if(!m_noitems) {
if((!m_noammo && !hasgoodammo(d)) || d->health < min(d->skill - 15, 75))
- items(d, b, interests);
+ items(d, interests);
else {
static vector<int> nearby;
nearby.setsize(0);
@@ -375,36 +364,11 @@ namespace ai {
loopv(nearby) {
int id = nearby[i];
extentity &e = *(extentity *)entities::ents[id];
- if(d->canpickup(e.type)) tryitem(d, e, id, b, interests);
- }
- }
- }
- if(m_teammode) assist(d, b, interests);
- return parseinterests(d, b, interests, override);
- }
- bool findassist(fpsent *d, aistate &b, bool override = false) {
- static vector<interest> interests;
- interests.setsize(0);
- assist(d, b, interests);
- while(!interests.empty()) {
- int q = interests.length()-1;
- loopi(interests.length()-1) if(interests[i].score < interests[q].score) q = i;
- interest n = interests.removeunordered(q);
- bool proceed = true;
- switch(n.state) {
- case AI_S_DEFEND: { // don't get into herds {
- int members = 0;
- proceed = !checkothers(targets, d, n.state, n.targtype, n.target, true, &members) && members > 1;
- break;
+ if(d->canpickup(e.type)) tryitem(d, e, id, interests);
}
- default: break;
- }
- if(proceed && makeroute(d, b, n.node)) {
- d->ai->switchstate(b, n.state, n.targtype, n.target);
- return true;
}
}
- return false;
+ return parseinterests(d, b, interests);
}
void damaged(fpsent *d, fpsent *e) {
if(d->ai && canmove(d) && targetable(d, e)) { // see if this ai is interested in a grudge {
@@ -442,7 +406,7 @@ namespace ai {
void spawned(fpsent *d) {
if(d->ai) setup(d);
}
- void killed(fpsent *d, fpsent *e) {
+ void killed(fpsent *d) {
if(d->ai) d->ai->reset();
}
void itemspawned(int ent) {
@@ -595,7 +559,7 @@ namespace ai {
}
return -1;
}
- bool anynode(fpsent *d, aistate &b, int len = NUMPREVNODES) {
+ bool anynode(fpsent *d, int len = NUMPREVNODES) {
if(iswaypoint(d->lastnode)) loopk(2) {
d->ai->clear(k ? true : false);
int n = randomlink(d, d->lastnode);
@@ -662,7 +626,7 @@ namespace ai {
}
}
b.override = false;
- return anynode(d, b);
+ return anynode(d);
}
void jumpto(fpsent *d, aistate &b, const vec &pos) {
vec off = vec(pos).sub(d->feetpos()), dir(off.x, off.y, 0);
@@ -797,7 +761,7 @@ namespace ai {
}
scaleyawpitch(d->yaw, d->pitch, yaw, pitch, frame, sskew);
if(insight || quick) {
- if(canshoot(d, e) && hastarget(d, b, e, yaw, pitch, dp.squaredist(ep))) {
+ if(canshoot(d, e) && hastarget(d, yaw, pitch, dp.squaredist(ep))) {
d->attacking = true;
d->ai->lastaction = lastmillis;
result = 3;
@@ -862,7 +826,7 @@ namespace ai {
if(targetable(d, e)) {
vec ep = getaimpos(d, e);
float dist = ep.squaredist(d->headpos());
- if(weaprange(d, weap, dist)) return true;
+ if(weaprange(weap, dist)) return true;
}
return false;
}
@@ -882,7 +846,7 @@ namespace ai {
}
return process(d, b) >= 2;
}
- void timeouts(fpsent *d, aistate &b) {
+ void timeouts(fpsent *d) {
if(d->blocked) {
d->ai->blocktime += lastmillis-d->ai->lastrun;
if(d->ai->blocktime > (d->ai->blockseq+1)*1000) {
@@ -931,7 +895,7 @@ namespace ai {
}
}
}
- void logic(fpsent *d, aistate &b, bool run) {
+ void logic(fpsent *d, aistate &b) {
bool allowmove = canmove(d) && b.type != AI_S_WAIT;
if(d->state != CS_ALIVE || !allowmove) d->stopmoving();
if(d->state == CS_ALIVE) {
@@ -942,7 +906,7 @@ namespace ai {
if(!intermission) {
if(d->ragdoll) cleanragdoll(d);
moveplayer(d, 10, true);
- if(allowmove && !b.idle) timeouts(d, b);
+ if(allowmove && !b.idle) timeouts(d);
if(d->quadmillis) entities::checkquad(curtime, d);
entities::checkitems(d);
}
@@ -1006,7 +970,7 @@ namespace ai {
}
}
}
- logic(d, c, run);
+ logic(d, c);
break;
}
if(d->ai->trywipe) d->ai->wipe();
diff --git a/src/fpsgame/ai.h b/src/fpsgame/ai.h
index 40c8513..81b1e26 100644
--- a/src/fpsgame/ai.h
+++ b/src/fpsgame/ai.h
@@ -227,11 +227,10 @@ namespace ai {
extern bool violence(fpsent *d, aistate &b, fpsent *e, int pursue = 0);
extern bool patrol(fpsent *d, aistate &b, const vec &pos, float guard = SIGHTMIN, float wander = SIGHTMAX, int walk = 1, bool retry = false);
extern bool defend(fpsent *d, aistate &b, const vec &pos, float guard = SIGHTMIN, float wander = SIGHTMAX, int walk = 1);
- extern void assist(fpsent *d, aistate &b, vector<interest> &interests, bool all = false, bool force = false);
- extern bool parseinterests(fpsent *d, aistate &b, vector<interest> &interests, bool override = false, bool ignore = false);
+ extern bool parseinterests(fpsent *d, aistate &b, vector<interest> &interests, bool ignore = false);
extern void spawned(fpsent *d);
extern void damaged(fpsent *d, fpsent *e);
- extern void killed(fpsent *d, fpsent *e);
+ extern void killed(fpsent *d);
extern void itemspawned(int ent);
extern void render();
}
diff --git a/src/fpsgame/client.cpp b/src/fpsgame/client.cpp
index bd98625..83aa385 100644
--- a/src/fpsgame/client.cpp
+++ b/src/fpsgame/client.cpp
@@ -562,12 +562,6 @@ namespace game {
messages.put(buf, p.length());
return true;
}
- void connectattempt(const char *name, const char *password, const ENetAddress &address) {
- copystring(connectpass, password);
- }
- void connectfail() {
- memset(connectpass, 0, sizeof(connectpass));
- }
void gameconnect(bool _remote) {
remote = _remote;
if(editmode) toggleedit();
@@ -1149,11 +1143,7 @@ namespace game {
if(!entities::ents.inrange(i)) break;
entities::setspawn(i, true);
ai::itemspawned(i);
- playsound(S_ITEMSPAWN, &entities::ents[i]->o, NULL, 0, 0, 0, -1, 0, 1500);
- #if 0
- const char *name = entities::itemname(i);
- if(name) particle_text(entities::ents[i]->o, name, PART_TEXT, 2000, 0x32FF64, 4.0f, -8);
- #endif
+ playsound(S_ITEMSPAWN, &entities::ents[i]->o, NULL, 0, 0, -1, 0, 1500);
int icon = entities::itemicon(i);
if(icon >= 0) particle_icon(vec(0.0f, 0.0f, 4.0f).add(entities::ents[i]->o), icon%4, icon/4, PART_HUD_ICON, 2000, 0xFFFFFF, 2.0f, -8);
break;
@@ -1378,8 +1368,8 @@ namespace game {
}
case N_ANNOUNCE: {
int t = getint(p);
- if (t==I_QUAD) { playsound(S_V_QUAD10, NULL, NULL, 0, 0, 0, -1, 0, 3000); conoutf(CON_GAMEINFO, "\f2quad damage will spawn in 10 seconds!"); }
- else if(t==I_BOOST) { playsound(S_V_BOOST10, NULL, NULL, 0, 0, 0, -1, 0, 3000); conoutf(CON_GAMEINFO, "\f2health boost will spawn in 10 seconds!"); }
+ if (t==I_QUAD) { playsound(S_V_QUAD10, NULL, NULL, 0, 0, -1, 0, 3000); conoutf(CON_GAMEINFO, "\f2quad damage will spawn in 10 seconds!"); }
+ else if(t==I_BOOST) { playsound(S_V_BOOST10, NULL, NULL, 0, 0, -1, 0, 3000); conoutf(CON_GAMEINFO, "\f2health boost will spawn in 10 seconds!"); }
break;
}
case N_NEWMAP: {
diff --git a/src/fpsgame/entities.cpp b/src/fpsgame/entities.cpp
index 21d44a6..656a9b0 100644
--- a/src/fpsgame/entities.cpp
+++ b/src/fpsgame/entities.cpp
@@ -77,17 +77,6 @@ namespace entities {
if(!mdl) continue;
preloadmodel(mdl);
}
- loopv(ents) {
- extentity &e = *ents[i];
- switch(e.type) {
- case TELEPORT:
- if(e.attr2 > 0) preloadmodel(mapmodelname(e.attr2));
- [[fallthrough]];
- case JUMPPAD:
- if(e.attr4 > 0) preloadmapsound(e.attr4);
- break;
- }
- }
}
void renderentities() {
loopv(ents) {
@@ -133,7 +122,7 @@ namespace entities {
//particle_text(d->abovehead(), is.name, PART_TEXT, 2000, 0xFFC864, 4.0f, -8);
particle_icon(d->abovehead(), is.icon%4, is.icon/4, PART_HUD_ICON_GREY, 2000, 0xFFFFFF, 2.0f, -8);
}
- playsound(itemstats[type-I_SHELLS].sound, d!=h ? &d->o : NULL, NULL, 0, 0, 0, -1, 0, 1500);
+ playsound(itemstats[type-I_SHELLS].sound, d!=h ? &d->o : NULL, NULL, 0, 0, -1, 0, 1500);
d->pickup(type);
switch(type) {
case I_TINYARMOUR: pwitemspicked[0]++; break;
@@ -147,11 +136,11 @@ namespace entities {
if(d==h) switch(type) {
case I_BOOST:
conoutf(CON_GAMEINFO, "\f2you got the health boost!");
- playsound(S_V_BOOST, NULL, NULL, 0, 0, 0, -1, 0, 3000);
+ playsound(S_V_BOOST, NULL, NULL, 0, 0, -1, 0, 3000);
break;
case I_QUAD:
conoutf(CON_GAMEINFO, "\f2you got the quad!");
- playsound(S_V_QUAD, NULL, NULL, 0, 0, 0, -1, 0, 3000);
+ playsound(S_V_QUAD, NULL, NULL, 0, 0, -1, 0, 3000);
break;
}
}
@@ -160,11 +149,11 @@ namespace entities {
if(ents.inrange(tp) && ents[tp]->type == TELEPORT) {
extentity &e = *ents[tp];
if(e.attr4 >= 0) {
- int snd = S_TELEPORT, flags = 0;
- if(e.attr4 > 0) { snd = e.attr4; flags = SND_MAP; }
+ int snd = S_TELEPORT;
+ if(e.attr4 > 0) snd = e.attr4;
fpsent *h = followingplayer(player1);
- playsound(snd, d==h ? NULL : &e.o, NULL, flags);
- if(d!=h && ents.inrange(td) && ents[td]->type == TELEDEST) playsound(snd, &ents[td]->o, NULL, flags);
+ playsound(snd, d==h ? NULL : &e.o, NULL);
+ if(d!=h && ents.inrange(td) && ents[td]->type == TELEDEST) playsound(snd, &ents[td]->o, NULL);
}
}
if(local && d->clientnum >= 0) {
@@ -182,9 +171,9 @@ namespace entities {
if(ents.inrange(jp) && ents[jp]->type == JUMPPAD) {
extentity &e = *ents[jp];
if(e.attr4 >= 0) {
- int snd = S_JUMPPAD, flags = 0;
- if(e.attr4 > 0) { snd = e.attr4; flags = SND_MAP; }
- playsound(snd, d == followingplayer(player1) ? NULL : &e.o, NULL, flags);
+ int snd = S_JUMPPAD;
+ if(e.attr4 > 0) snd = e.attr4;
+ playsound(snd, d == followingplayer(player1) ? NULL : &e.o, NULL);
}
}
if(local && d->clientnum >= 0) {
diff --git a/src/fpsgame/fps.cpp b/src/fpsgame/fps.cpp
index eadb2c8..d167582 100644
--- a/src/fpsgame/fps.cpp
+++ b/src/fpsgame/fps.cpp
@@ -353,7 +353,7 @@ namespace game {
}
}
deathstate(d);
- ai::killed(d, actor);
+ ai::killed(d);
}
void timeupdate(int secs) {
server::timeupdate(secs);
@@ -411,7 +411,6 @@ namespace game {
if(notify && d->name[0]) conoutf("\f4leave:\f7 %s", colorname(d));
removeweapons(d);
removetrackedparticles(d);
- removetrackeddynlights(d);
players.removeobj(d);
DELETEP(clients[cn]);
cleardynentcache();
@@ -527,7 +526,7 @@ namespace game {
}
VARP(teamsounds, 0, 1, 1);
void teamsound(bool sameteam, int n, const vec *loc) {
- playsound(n, loc, NULL, teamsounds ? (m_teammode && sameteam ? SND_USE_ALT : SND_NO_ALT) : 0);
+ playsound(n, loc, NULL);
}
void teamsound(fpsent *d, int n, const vec *loc) {
teamsound(isteam(d->team, player1->team), n, loc);
diff --git a/src/fpsgame/game.h b/src/fpsgame/game.h
index 5b95c5a..c76498a 100644
--- a/src/fpsgame/game.h
+++ b/src/fpsgame/game.h
@@ -538,6 +538,7 @@ namespace game {
// client
extern bool connected, remote, demoplayback;
extern string servinfo;
+ extern string connectpass;
extern vector<uchar> messages;
extern int parseplayer(const char *arg);
extern void ignore(int cn);
diff --git a/src/fpsgame/render.cpp b/src/fpsgame/render.cpp
index dacdcd9..fff917e 100644
--- a/src/fpsgame/render.cpp
+++ b/src/fpsgame/render.cpp
@@ -253,13 +253,6 @@ namespace game {
sway.z = swayup*(fabs(sinf(steps)) - 1);
sway.add(swaydir).add(d->o);
if(!hudgunsway) sway = d->o;
-
-#if 0
- if(player1->state!=CS_DEAD && player1->quadmillis) {
- float t = 0.5f + 0.5f*sinf(2*M_PI*lastmillis/1000.0f);
- color.y = color.y*(1-t) + t;
- }
-#endif
const playermodelinfo &mdl = getplayermodelinfo(d);
defformatstring(gunname, "%s/%s", hudgunsdir[0] ? hudgunsdir : mdl.hudguns, guns[d->gunselect].file);
if((m_teammode || teamskins) && teamhudguns)
diff --git a/src/fpsgame/server.cpp b/src/fpsgame/server.cpp
index 2856e53..341b050 100644
--- a/src/fpsgame/server.cpp
+++ b/src/fpsgame/server.cpp
@@ -774,7 +774,7 @@ namespace server {
void sendwelcome(clientinfo *ci);
void setupdemorecord() {
if(!m_mp(gamemode) || m_edit) return;
- demotmp = opentempfile("demorecord", "w+b");
+ demotmp = opentempfile();
if(!demotmp) return;
stream *f = opengzfile(NULL, "wb", demotmp);
if(!f) { DELETEP(demotmp); return; }
@@ -2155,7 +2155,7 @@ namespace server {
clientinfo *ci = getinfo(sender);
if(ci->state.state==CS_SPECTATOR && !ci->privilege && !ci->local) return;
if(mapdata) DELETEP(mapdata);
- mapdata = opentempfile("mapdata", "w+b");
+ mapdata = opentempfile();
if(!mapdata) { sendf(sender, 1, "ris", N_SERVMSG, "failed to open temporary file for map"); return; }
mapdata->write(data, len);
sendservmsgf("[%s sent a map to server, \"/getmap\" to receive it]", colorname(ci));
diff --git a/src/fpsgame/weapon.cpp b/src/fpsgame/weapon.cpp
index c486110..30d2da8 100644
--- a/src/fpsgame/weapon.cpp
+++ b/src/fpsgame/weapon.cpp
@@ -305,9 +305,6 @@ namespace game {
if((gun==GUN_RL || gun==GUN_GL) && explodebright < 1) color = vec::hexcolor(color).mul(explodebright).tohexcolor();
/// REPLACE THIS SHIT WITH SMOKE AND FIRE EFFECT LIKE IN XONOTIC
//~particle_fireball(v, guns[gun].exprad, gun!=GUN_GL ? PART_EXPLOSION : PART_EXPLOSION_BLUE, gun!=GUN_GL ? -1 : int((guns[gun].exprad-4.0f)*15), color, 4.0f);
- if(gun==GUN_RL) adddynlight(v, 1.15f*guns[gun].exprad, vec(2, 1.5f, 1), 700, 100, 0, guns[gun].exprad/2, vec(1, 0.75f, 0.5f));
- else if(gun==GUN_GL) adddynlight(v, 1.15f*guns[gun].exprad, vec(0.5f, 1.5f, 2), 600, 100, 0, 8, vec(0.25f, 1, 1));
- else adddynlight(v, 1.15f*guns[gun].exprad, vec(2, 1.5f, 1), 700, 100);
if(!local) return;
int numdyn = numdynents();
loopi(numdyn) {
@@ -431,7 +428,6 @@ namespace game {
particle_flare(hudgunorigin(gun, from, rays[i], d), rays[i], 300, PART_STREAK, 0xFFC864, 0.28f);
if(!local) adddecal(DECAL_BULLET, rays[i], vec(from).sub(rays[i]).safenormalize(), 2.0f);
}
- if(muzzlelight) adddynlight(hudgunorigin(gun, d->o, to, d), 30, vec(0.5f, 0.375f, 0.25f), 100, 100, DL_FLASH, 0, vec(0, 0, 0), d);
break;
}
case GUN_CG:
@@ -443,7 +439,6 @@ namespace game {
if(muzzleflash && d->muzzle.x >= 0)
particle_flare(d->muzzle, d->muzzle, gun==GUN_CG ? 100 : 200, PART_MUZZLE_FLASH1, 0xFFFFFF, gun==GUN_CG ? 2.25f : 1.25f, d);
if(!local) adddecal(DECAL_BULLET, to, vec(from).sub(to).safenormalize(), 2.0f);
- if(muzzlelight) adddynlight(hudgunorigin(gun, d->o, to, d), gun==GUN_CG ? 30 : 15, vec(0.5f, 0.375f, 0.25f), gun==GUN_CG ? 50 : 100, gun==GUN_CG ? 50 : 100, DL_FLASH, 0, vec(0, 0, 0), d);
break;
}
case GUN_RL:
@@ -460,7 +455,6 @@ namespace game {
up.z += dist/8;
if(muzzleflash && d->muzzle.x >= 0)
particle_flare(d->muzzle, d->muzzle, 200, PART_MUZZLE_FLASH2, 0xFFFFFF, 1.5f, d);
- if(muzzlelight) adddynlight(hudgunorigin(gun, d->o, to, d), 20, vec(0.5f, 0.375f, 0.25f), 100, 100, DL_FLASH, 0, vec(0, 0, 0), d);
newbouncer(from, up, local, id, d, BNC_GRENADE, guns[gun].ttl, guns[gun].projspeed);
break;
}
@@ -472,7 +466,6 @@ namespace game {
if(muzzleflash && d->muzzle.x >= 0)
particle_flare(d->muzzle, d->muzzle, 150, PART_MUZZLE_FLASH3, 0xFFFFFF, 1.25f, d);
if(!local) adddecal(DECAL_BULLET, to, vec(from).sub(to).safenormalize(), 3.0f);
- if(muzzlelight) adddynlight(hudgunorigin(gun, d->o, to, d), 25, vec(0.5f, 0.375f, 0.25f), 75, 75, DL_FLASH, 0, vec(0, 0, 0), d);
break;
}
bool looped = false;
@@ -483,7 +476,7 @@ namespace game {
case S_CHAINSAW_ATTACK:
if(d->attacksound >= 0) looped = true;
d->attacksound = sound;
- d->attackchan = playsound(sound, d==h ? NULL : &d->o, NULL, 0, -1, 100, d->attackchan);
+ d->attackchan = playsound(sound, d==h ? NULL : &d->o, NULL, -1, 100, d->attackchan);
break;
default:
playsound(sound, d==h ? NULL : &d->o);
@@ -504,13 +497,6 @@ namespace game {
d.mul(min(newdist, dist)).add(owner->o);
}
}
- void dynlighttrack(physent *owner, vec &o, vec &hud) {
- if(owner->type!=ENT_PLAYER && owner->type!=ENT_AI) return;
- fpsent *pl = (fpsent *)owner;
- if(pl->muzzle.x < 0 || pl->lastattackgun != pl->gunselect) return;
- o = pl->muzzle;
- hud = owner == followingplayer(player1) ? vec(pl->o).add(vec(0, 0, 2)) : pl->muzzle;
- }
float intersectdist = 1e16f;
bool intersect(dynent *d, const vec &from, const vec &to, float &dist) { // if lineseg hits entity bounding box {
vec bottom(d->o), top(d->o);
@@ -609,21 +595,6 @@ namespace game {
if(d->gunselect == GUN_PISTOL && d->ai) d->gunwait += int(d->gunwait*(((101-d->skill)+rnd(111-d->skill))/100.f));
d->totalshots += guns[d->gunselect].damage*(d->quadmillis ? 4 : 1)*guns[d->gunselect].rays;
}
- void adddynlights() {
- loopv(projs) {
- projectile &p = projs[i];
- if(p.gun!=GUN_RL) continue;
- vec pos(p.o);
- pos.add(vec(p.offset).mul(p.offsetmillis/float(OFFSETMILLIS)));
- adddynlight(pos, 20, vec(1, 0.75f, 0.5f));
- }
- loopv(bouncers) {
- bouncer &bnc = *bouncers[i];
- if(bnc.bouncetype!=BNC_GRENADE) continue;
- vec pos = bnc.offsetpos();
- adddynlight(pos, 8, vec(0.25f, 1, 1));
- }
- }
static const char * const projnames[2] = { "projectiles/grenade", "projectiles/rocket" };
void preloadbouncers() {
loopi(sizeof(projnames)/sizeof(projnames[0])) preloadmodel(projnames[i]);
@@ -680,7 +651,7 @@ namespace game {
if(gun >= 0 && gun < NUMGUNS &&
d->clientnum >= 0 && d->state == CS_ALIVE &&
d->lastattackgun == gun && lastmillis - d->lastaction < guns[gun].attackdelay + 50) {
- d->attackchan = playsound(d->attacksound, local ? NULL : &d->o, NULL, 0, -1, -1, d->attackchan);
+ d->attackchan = playsound(d->attacksound, local ? NULL : &d->o, NULL, -1, -1, d->attackchan);
if(d->attackchan < 0) d->attacksound = -1;
}
else d->stopattacksound();
@@ -698,12 +669,12 @@ namespace game {
if(d->idlesound != sound) {
if(d->idlesound >= 0) d->stopidlesound();
if(sound >= 0) {
- d->idlechan = playsound(sound, local ? NULL : &d->o, NULL, 0, -1, 100, d->idlechan, radius);
+ d->idlechan = playsound(sound, local ? NULL : &d->o, NULL, -1, 100, d->idlechan, radius);
if(d->idlechan >= 0) d->idlesound = sound;
}
}
else if(sound >= 0) {
- d->idlechan = playsound(sound, local ? NULL : &d->o, NULL, 0, -1, -1, d->idlechan, radius);
+ d->idlechan = playsound(sound, local ? NULL : &d->o, NULL, -1, -1, d->idlechan, radius);
if(d->idlechan < 0) d->idlesound = -1;
}
}