1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-13 16:44:50 +02:00

fix ricochet sound when all the bullets hit

This commit is contained in:
XProger
2018-12-04 08:34:44 +03:00
parent df8478e254
commit 361483dd05
4 changed files with 14 additions and 7 deletions

View File

@@ -1841,11 +1841,11 @@ namespace TR {
}
static bool isPuzzleItem(Type type) {
return type >= PUZZLE_1 && type <= PUZZLE_4;
return (type >= PUZZLE_1 && type <= PUZZLE_4) || (type >= INV_PUZZLE_1 && type <= INV_PUZZLE_4);
}
static bool isKeyItem(Type type) {
return type >= KEY_ITEM_1 && type <= KEY_ITEM_4;
return (type >= KEY_ITEM_1 && type <= KEY_ITEM_4) || (type >= INV_KEY_ITEM_1 && type <= INV_KEY_ITEM_4);
}
static bool isWeapon(Type type) {

View File

@@ -1460,6 +1460,9 @@ struct Inventory {
StringID getItemName(StringID def, TR::LevelID id, TR::Entity::Type type) {
if (!TR::Entity::isPuzzleItem(type) && !TR::Entity::isKeyItem(type))
return def;
#define LVLCHECK(L, T, S) if (id == TR::L && type == TR::Entity::INV_##T) return S;
LVLCHECK(LVL_TR1_2, KEY_ITEM_1, STR_KEY_SILVER);

View File

@@ -62,6 +62,8 @@
#define UNITS_PER_METER 445.0f
#define LARA_VIBRATE_HIT_TIME 0.2f
struct Lara : Character {
// http://www.tombraiderforums.com/showthread.php?t=148859
@@ -1023,7 +1025,7 @@ struct Lara : Character {
int count = wpnCurrent == TR::Entity::SHOTGUN ? 6 : 2;
float nearDist = 32.0f * 1024.0f;
vec3 nearPos;
int shots = 0;
int shots = 0, hits = 0;
for (int i = 0; i < count; i++) {
int armIndex;
@@ -1057,6 +1059,7 @@ struct Lara : Character {
int room;
vec3 hit = trace(getRoomIndex(), p, t, room, false);
if (arm->target && checkHit(arm->target, p, hit, hit)) {
hits++;
TR::Entity::Type type = arm->target->getEntity().type;
((Character*)arm->target)->hit(wpnGetDamage(), this);
hit -= d * 64.0f;
@@ -1078,7 +1081,8 @@ struct Lara : Character {
saveStats.ammoUsed += ((wpnCurrent == TR::Entity::SHOTGUN) ? 1 : 2);
game->playSound(wpnGetSound(), pos, Sound::PAN);
game->playSound(TR::SND_RICOCHET, nearPos, Sound::PAN);
if (shots != hits)
game->playSound(TR::SND_RICOCHET, nearPos, Sound::PAN);
if (wpnAmmo && *wpnAmmo != UNLIMITED_AMMO && wpnCurrent == TR::Entity::SHOTGUN)
*wpnAmmo -= 1;
@@ -1577,7 +1581,7 @@ struct Lara : Character {
Character::hit(damage, enemy, hitType);
hitTimer = 0.2f;
hitTimer = LARA_VIBRATE_HIT_TIME;
switch (hitType) {
case TR::HIT_DART : addBlood(enemy->pos, vec3(0));

View File

@@ -169,8 +169,8 @@ bool osJoyReady(int index) {
}
void osJoyVibrate(int index, float L, float R) {
joyDevice[index].vL = L;
joyDevice[index].vR = R;
joyDevice[index].vL = L;
joyDevice[index].vR = R;
}
void joyRumble(int index) {