Add hit fire sound (#41)

Convert sounds to mono
This commit is contained in:
Cong
2013-06-21 23:22:45 +10:00
parent 312dd0a4e6
commit b9d8cd0d77
9 changed files with 67 additions and 17 deletions

BIN
sounds/hit_fire.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -963,14 +963,31 @@ void ActorTakeSpecialDamage(TActor *actor, special_damage_e damage)
}
}
void ActorTakeHit(TActor *actor, int dx, int dy, int power, special_damage_e damage)
void ActorTakeHit(
TActor *actor,
Vector2i hitVector,
int power,
special_damage_e damage,
int isHitSoundEnabled,
Vector2i hitLocation)
{
assert(!ActorIsImmune(actor, damage));
ActorTakeSpecialDamage(actor, damage);
// Pushback
actor->dx += (power * dx) / 25;
actor->dy += (power * dy) / 25;
actor->dx += (power * hitVector.x) / 25;
actor->dy += (power * hitVector.y) / 25;
// Hit sound
if (isHitSoundEnabled)
{
sound_e hitSound = SND_HIT_FLESH;
if (damage == SPECIAL_FLAME)
{
hitSound = SND_HIT_FIRE;
}
SoundPlayAt(hitSound, hitLocation.x, hitLocation.y);
}
}
int ActorIsInvulnerable(TActor *actor, int flags, campaign_mode_e mode)

View File

@@ -208,7 +208,13 @@ void KillAllActors(void);
int ActorIsImmune(TActor *actor, special_damage_e damage);
// Taking a hit only gives the appearance (pushback, special effect) but deals no damage
void ActorTakeHit(TActor *actor, int dx, int dy, int power, special_damage_e damage);
void ActorTakeHit(
TActor *actor,
Vector2i hitVector,
int power,
special_damage_e damage,
int isHitSoundEnabled,
Vector2i hitLocation);
int ActorIsInvulnerable(TActor *actor, int flags, campaign_mode_e mode);
#endif

View File

@@ -267,9 +267,18 @@ static void TrackKills(TActor * victim, int flags)
// The damage function!
int DamageCharacter(
int dx, int dy, int power, int flags, TTileItem *target, special_damage_e damage)
Vector2i hitVector,
int power,
int flags,
TTileItem *target,
special_damage_e damage,
campaign_mode_e mode,
int isHitSoundEnabled)
{
TActor *actor = (TActor *)target->data;
Vector2i hitLocation;
hitLocation.x = target->x;
hitLocation.y = target->y;
if (!(flags & FLAGS_HURTALWAYS) &&
(flags & FLAGS_PLAYERS) &&
@@ -282,17 +291,12 @@ int DamageCharacter(
{
return 1;
}
ActorTakeHit(actor, dx, dy, power, damage);
if (gConfig.Sound.Hits)
{
SoundPlayAt(SND_HIT_FLESH, target->x, target->y);
}
ActorTakeHit(actor, hitVector, power, damage, isHitSoundEnabled, hitLocation);
if (ActorIsInvulnerable(actor, flags, gCampaign.mode))
if (ActorIsInvulnerable(actor, flags, mode))
{
return 1;
}
InjureActor(actor, power);
if (actor->health <= 0)
{
@@ -316,7 +320,12 @@ int DamageCharacter(
return 1;
}
void DamageObject(int power, int flags, TTileItem *target)
void DamageObject(
int power,
int flags,
TTileItem *target,
special_damage_e damage,
int isHitSoundEnabled)
{
TObject *object = (TObject *)target->data;
// Don't bother if object already destroyed
@@ -326,9 +335,14 @@ void DamageObject(int power, int flags, TTileItem *target)
}
object->structure -= power;
if (gConfig.Sound.Hits)
if (isHitSoundEnabled)
{
SoundPlayAt(SND_HIT_HARD, target->x, target->y);
sound_e hitSound = SND_HIT_HARD;
if (damage == SPECIAL_FLAME)
{
hitSound = SND_HIT_FIRE;
}
SoundPlayAt(hitSound, target->x, target->y);
}
// Destroying objects and all the wonderful things that happen
@@ -389,6 +403,10 @@ void DamageObject(int power, int flags, TTileItem *target)
int DamageSomething(
int dx, int dy, int power, int flags, TTileItem *target, special_damage_e damage)
{
Vector2i hitVector;
hitVector.x = dx;
hitVector.y = dy;
if (!target)
{
return 0;
@@ -397,10 +415,17 @@ int DamageSomething(
switch (target->kind)
{
case KIND_CHARACTER:
return DamageCharacter(dx, dy, power, flags, target, damage);
return DamageCharacter(
hitVector,
power,
flags,
target,
damage,
gCampaign.mode,
gConfig.Sound.Hits);
case KIND_OBJECT:
DamageObject(power, flags, target);
DamageObject(power, flags, target, damage, gConfig.Sound.Hits);
break;
case KIND_PIC:

View File

@@ -90,6 +90,7 @@ SoundDevice gSoundDevice =
{"sounds/shotgun_r.wav", 0, NULL},
{"sounds/powergun_r.wav", 0, NULL},
{"sounds/package_r.wav", 0, NULL},
{"sounds/hit_fire.wav", 0, NULL},
{"sounds/hit_flesh.wav", 0, NULL},
{"sounds/hit_hard.wav", 0, NULL}
}

View File

@@ -77,6 +77,7 @@ typedef enum
SND_SHOTGUN_R,
SND_LASER_R,
SND_PACKAGE_R,
SND_HIT_FIRE,
SND_HIT_FLESH,
SND_HIT_HARD,
SND_COUNT