Skip to content

Commit

Permalink
add colored_weapon_trails.patch
Browse files Browse the repository at this point in the history
closes #9
  • Loading branch information
sauerbraten committed Sep 21, 2021
1 parent cfbfb48 commit 3233f4b
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ apply-patches:
$(PATCH) < patches/paused_spec_movement.patch
$(PATCH) < patches/checkupdate.patch
$(PATCH) < patches/clientdemo.patch
$(PATCH) < patches/colored_weapon_trails.patch
unix2dos src/vcpp/sauerbraten.nsi
unix2dos src/vcpp/sauerbraten.vcxproj
cd src && make depend
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ This repository contains the source for my client mod, as well as the patches ap
- [paused_spec_movement.patch](#paused_spec_movementpatch)
- [checkupdate.patch](#checkupdatepatch)
- [clientdemo.patch](#clientdemopatch)
- [colored_weapon_trails.patch](#colored_weapon_trailspatch)
- [Server Patches](#server-patches)
- [authservers.patch](#authserverspatch)
- [serverlogging.patch](#serverloggingpatch)
Expand Down Expand Up @@ -229,6 +230,12 @@ For an overview of who uses p1xbraten, you can run `/showgui p1xbratenusage`.

Client-side demos record the game as you experience it, and work independently of server-side demo recording. They also work locally, without being connected to any server.

### [colored_weapon_trails.patch](./patches/colored_weapon_trails.patch)

- adds the `trailcolor[shotgun|chaingun|rocketlauncher|rifle|grenadelauncher|pistol]` vars that change the respective weapon's projectile/particle trail
- adds the `settrailcolor <SG|CG|RL|RI|GL|PI> <color>` command (for convenience: changing the variables directly also works)


## Server Patches

These are the patches that make p1x.pw different from other servers.
Expand Down
103 changes: 103 additions & 0 deletions patches/colored_weapon_trails.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
Index: src/fpsgame/weapon.cpp
===================================================================
--- src/fpsgame/weapon.cpp (revision 6519)
+++ src/fpsgame/weapon.cpp (working copy)
@@ -228,6 +228,8 @@
adddecal(DECAL_BLOOD, vec(b->o).sub(vec(surface).mul(b->radius)), surface, 2.96f/b->bounces, bvec(0x60, 0xFF, 0xFF), rnd(4));
}

+ MOD(HVARP, trailcolorgrenadelauncher, 0, 0x404040, 0xFFFFFF);
+
void updatebouncers(int time)
{
loopv(bouncers)
@@ -236,7 +238,7 @@
if(bnc.bouncetype==BNC_GRENADE && bnc.vel.magnitude() > 50.0f)
{
vec pos = bnc.offsetpos();
- regular_particle_splash(PART_SMOKE, 1, 150, pos, 0x404040, 2.4f, 50, -20);
+ regular_particle_splash(PART_SMOKE, 1, 150, pos, trailcolorgrenadelauncher, 2.4f, 50, -20);
}
vec old(bnc.o);
bool stopped = false;
@@ -520,6 +522,8 @@
return true;
}

+ MOD(HVARP, trailcolorrocketlauncher, 0, 0x404040, 0xFFFFFF);
+
void updateprojectiles(int time)
{
loopv(projs)
@@ -570,7 +574,7 @@
}
particle_splash(guns[p.gun].part, 1, 1, pos, color, 4.8f, 150, 20);
}
- else regular_particle_splash(PART_SMOKE, 2, 300, pos, 0x404040, 2.4f, 50, -20);
+ else regular_particle_splash(PART_SMOKE, 2, 300, pos, p.gun==GUN_RL ? trailcolorrocketlauncher : 0x404040, 2.4f, 50, -20);
}
}
if(exploded)
@@ -588,6 +592,10 @@

VARP(muzzleflash, 0, 1, 1);
VARP(muzzlelight, 0, 1, 1);
+ MOD(HVARP, trailcolorshotgun, 0, 0xFFC864, 0xFFFFFF);
+ MOD(HVARP, trailcolorchaingun, 0, 0xFFC864, 0xFFFFFF);
+ MOD(HVARP, trailcolorrifle, 0, 0x404040, 0xFFFFFF);
+ MOD(HVARP, trailcolorpistol, 0, 0xFFC864, 0xFFFFFF);

void shoteffects(int gun, const vec &from, const vec &to, fpsent *d, bool local, int id, int prevaction) // create visual effect from a shot
{
@@ -606,7 +614,7 @@
loopi(guns[gun].rays)
{
particle_splash(PART_SPARK, 20, 250, rays[i], 0xB49B4B, 0.24f);
- particle_flare(hudgunorigin(gun, from, rays[i], d), rays[i], 300, PART_STREAK, 0xFFC864, 0.28f);
+ particle_flare(hudgunorigin(gun, from, rays[i], d), rays[i], 300, PART_STREAK, trailcolorshotgun, 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);
@@ -617,7 +625,7 @@
case GUN_PISTOL:
{
particle_splash(PART_SPARK, 200, 250, to, 0xB49B4B, 0.24f);
- particle_flare(hudgunorigin(gun, from, to, d), to, 600, PART_STREAK, 0xFFC864, 0.28f);
+ particle_flare(hudgunorigin(gun, from, to, d), to, 600, PART_STREAK, gun==GUN_CG ? trailcolorchaingun : trailcolorpistol, 0.28f);
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);
@@ -650,7 +658,7 @@

case GUN_RIFLE:
particle_splash(PART_SPARK, 200, 250, to, 0xB49B4B, 0.24f);
- particle_trail(PART_SMOKE, 500, hudgunorigin(gun, from, to, d), to, 0x404040, 0.6f, 20);
+ particle_trail(PART_SMOKE, 500, hudgunorigin(gun, from, to, d), to, trailcolorrifle, 0.6f, 20);
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);
@@ -676,6 +684,19 @@
if(d->quadmillis && lastmillis-prevaction>200 && !looped) playsound(S_ITEMPUP, d==h ? NULL : &d->o);
}

+ ICOMMAND(settrailcolor, "sf", (char *name, float *color), {
+ if(!color) return;
+ switch (getweapon(name))
+ {
+ case GUN_SG: trailcolorshotgun = *color; break;
+ case GUN_CG: trailcolorchaingun = *color; break;
+ case GUN_RL: trailcolorrocketlauncher = *color; break;
+ case GUN_RIFLE: trailcolorrifle = *color; break;
+ case GUN_GL: trailcolorgrenadelauncher = *color; break;
+ case GUN_PISTOL: trailcolorpistol = *color; break;
+ }
+ });
+
void particletrack(physent *owner, vec &o, vec &d)
{
if(owner->type!=ENT_PLAYER && owner->type!=ENT_AI) return;
@@ -1000,4 +1021,3 @@
}
}
};
-
32 changes: 26 additions & 6 deletions src/fpsgame/weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ namespace game
adddecal(DECAL_BLOOD, vec(b->o).sub(vec(surface).mul(b->radius)), surface, 2.96f/b->bounces, bvec(0x60, 0xFF, 0xFF), rnd(4));
}

MOD(HVARP, trailcolorgrenadelauncher, 0, 0x404040, 0xFFFFFF);

void updatebouncers(int time)
{
loopv(bouncers)
Expand All @@ -238,7 +240,7 @@ namespace game
if(bnc.bouncetype==BNC_GRENADE && bnc.vel.magnitude() > 50.0f)
{
vec pos = bnc.offsetpos();
regular_particle_splash(PART_SMOKE, 1, 150, pos, 0x404040, 2.4f, 50, -20);
regular_particle_splash(PART_SMOKE, 1, 150, pos, trailcolorgrenadelauncher, 2.4f, 50, -20);
}
vec old(bnc.o);
bool stopped = false;
Expand Down Expand Up @@ -522,6 +524,8 @@ namespace game
return true;
}

MOD(HVARP, trailcolorrocketlauncher, 0, 0x404040, 0xFFFFFF);

void updateprojectiles(int time)
{
loopv(projs)
Expand Down Expand Up @@ -572,7 +576,7 @@ namespace game
}
particle_splash(guns[p.gun].part, 1, 1, pos, color, 4.8f, 150, 20);
}
else regular_particle_splash(PART_SMOKE, 2, 300, pos, 0x404040, 2.4f, 50, -20);
else regular_particle_splash(PART_SMOKE, 2, 300, pos, p.gun==GUN_RL ? trailcolorrocketlauncher : 0x404040, 2.4f, 50, -20);
}
}
if(exploded)
Expand All @@ -590,6 +594,10 @@ namespace game

VARP(muzzleflash, 0, 1, 1);
VARP(muzzlelight, 0, 1, 1);
MOD(HVARP, trailcolorshotgun, 0, 0xFFC864, 0xFFFFFF);
MOD(HVARP, trailcolorchaingun, 0, 0xFFC864, 0xFFFFFF);
MOD(HVARP, trailcolorrifle, 0, 0x404040, 0xFFFFFF);
MOD(HVARP, trailcolorpistol, 0, 0xFFC864, 0xFFFFFF);

void shoteffects(int gun, const vec &from, const vec &to, fpsent *d, bool local, int id, int prevaction) // create visual effect from a shot
{
Expand All @@ -608,7 +616,7 @@ namespace game
loopi(guns[gun].rays)
{
particle_splash(PART_SPARK, 20, 250, rays[i], 0xB49B4B, 0.24f);
particle_flare(hudgunorigin(gun, from, rays[i], d), rays[i], 300, PART_STREAK, 0xFFC864, 0.28f);
particle_flare(hudgunorigin(gun, from, rays[i], d), rays[i], 300, PART_STREAK, trailcolorshotgun, 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);
Expand All @@ -619,7 +627,7 @@ namespace game
case GUN_PISTOL:
{
particle_splash(PART_SPARK, 200, 250, to, 0xB49B4B, 0.24f);
particle_flare(hudgunorigin(gun, from, to, d), to, 600, PART_STREAK, 0xFFC864, 0.28f);
particle_flare(hudgunorigin(gun, from, to, d), to, 600, PART_STREAK, gun==GUN_CG ? trailcolorchaingun : trailcolorpistol, 0.28f);
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);
Expand Down Expand Up @@ -652,7 +660,7 @@ namespace game

case GUN_RIFLE:
particle_splash(PART_SPARK, 200, 250, to, 0xB49B4B, 0.24f);
particle_trail(PART_SMOKE, 500, hudgunorigin(gun, from, to, d), to, 0x404040, 0.6f, 20);
particle_trail(PART_SMOKE, 500, hudgunorigin(gun, from, to, d), to, trailcolorrifle, 0.6f, 20);
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);
Expand All @@ -678,6 +686,19 @@ namespace game
if(d->quadmillis && lastmillis-prevaction>200 && !looped) playsound(S_ITEMPUP, d==h ? NULL : &d->o);
}

ICOMMAND(settrailcolor, "sf", (char *name, float *color), {
if(!color) return;
switch (getweapon(name))
{
case GUN_SG: trailcolorshotgun = *color; break;
case GUN_CG: trailcolorchaingun = *color; break;
case GUN_RL: trailcolorrocketlauncher = *color; break;
case GUN_RIFLE: trailcolorrifle = *color; break;
case GUN_GL: trailcolorgrenadelauncher = *color; break;
case GUN_PISTOL: trailcolorpistol = *color; break;
}
});

void particletrack(physent *owner, vec &o, vec &d)
{
if(owner->type!=ENT_PLAYER && owner->type!=ENT_AI) return;
Expand Down Expand Up @@ -1007,4 +1028,3 @@ namespace game
}
}
};

0 comments on commit 3233f4b

Please sign in to comment.