mirror of
https://github.com/cxong/cdogs-sdl.git
synced 2025-07-23 07:23:01 +02:00
BIN
sounds/hit_fire.wav
Normal file
BIN
sounds/hit_fire.wav
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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:
|
||||
|
@@ -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}
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user