aboutsummaryrefslogtreecommitdiff
path: root/src/GameLoop.cpp
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-09-15 17:05:53 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-09-16 00:12:44 +0700
commit6bfeb5cbc20e3336d8e2a2147b02b380e2d50378 (patch)
tree37149c46c84da45411b1b7f3322397c77980fa2e /src/GameLoop.cpp
parent662673fd3ceac4895769241c1b6836061738d46a (diff)
downloadblackshades-6bfeb5cbc20e3336d8e2a2147b02b380e2d50378.tar.gz
Tweak control system to mirror Overgrowth
Diffstat (limited to 'src/GameLoop.cpp')
-rw-r--r--src/GameLoop.cpp60
1 files changed, 47 insertions, 13 deletions
diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp
index a927f2f..77ec774 100644
--- a/src/GameLoop.cpp
+++ b/src/GameLoop.cpp
@@ -24,6 +24,7 @@
extern float multiplier;
extern int thirdperson;
extern int visions;
+extern float soundscalefactor;
extern unsigned int gSourceID[100];
extern unsigned int gSampleSet[100];
extern Camera camera;
@@ -76,23 +77,56 @@ void handleKey(Game* game, int key, int action, int mods)
player.aimamount = 0;
}
} else if (key == GLFW_KEY_R) {
- if (player.reloads[player.whichgun] > 0
+ if (player.whichgun != grenade
+ && player.reloads[player.whichgun] > 0
&& player.reloading <= 0)
player.ammo = -1;
} else if (key == aimkey) {
player.aiming ^= 1;
} else if (key == psychicaimkey) {
- game->flashamount = 0.5;
- game->flashr = 1;
- game->flashg = game->flashb = 0;
- alSourcePlay(gSourceID[souloutsound]);
+ // Picking up gun from rag doll
+ if (player.currentanimation == crouchanim
+ && (!player.aiming || player.whichgun == nogun
+ || player.whichgun == knife
+ || player.whichgun == grenade)) {
+ for (int i = 1; i < game->numpeople; ++i) {
+ auto& person = game->person[i];
+ if (!person.skeleton.free
+ || findDistancefast(player.playercoords,
+ person.averageloc) > 200)
+ continue;
+
+ auto soundsrc = (player.playercoords
+ - camera.position) / soundscalefactor;
+ float gLoc[] {soundsrc.x, soundsrc.y, soundsrc.z};
+ alSourcefv(gSourceID[clicksound], AL_POSITION, gLoc);
+ alSourcePlay(gSourceID[clicksound]);
+
+ auto tmp_gun = player.whichgun;
+ player.whichgun = person.whichgun;
+ person.whichgun = tmp_gun;
+
+ auto tmp_ammo = player.ammo;
+ player.ammo = person.ammo;
+ person.ammo = tmp_ammo;
+
+ player.aiming = 1;
+ player.aimamount = 0;
+ break;
+ }
+ } else {
+ game->flashamount = 0.5;
+ game->flashr = 1;
+ game->flashg = game->flashb = 0;
+ alSourcePlay(gSourceID[souloutsound]);
- slomo = 2;
- game->score -= 20;
+ slomo = 2;
+ game->score -= 20;
- alSourcef(gSourceID[knifesong], AL_PITCH, 0.5f);
- alSourcef(gSourceID[shootsong], AL_PITCH, 0.5f);
- alSourcef(gSourceID[zombiesong], AL_PITCH, 0.5f);
+ alSourcef(gSourceID[knifesong], AL_PITCH, 0.5f);
+ alSourcef(gSourceID[shootsong], AL_PITCH, 0.5f);
+ alSourcef(gSourceID[zombiesong], AL_PITCH, 0.5f);
+ }
} else if (key == psychickey) {
if (visions ^= 1) {
game->flashamount = game->flashr = 1;
@@ -186,14 +220,14 @@ void handleKey(Game* game, int key, int action, int mods)
}
break;
case GLFW_KEY_X:
- if (!shift || player.grenphase)
+ if (player.grenphase)
break;
+ player.grenphase = 0;
player.ammo = -1;
player.whichgun++;
- player.grenphase = 0;
- player.reloads[player.whichgun] = 3;
if (player.whichgun > 7)
player.whichgun = 0;
+ player.reloads[player.whichgun] = 3;
break;
}
}