void Damage( const Vec2i hitVector, const int power, const int flags, const int playerUID, const int uid, const TileItemKind targetKind, const int targetUID, const special_damage_e special) { switch (targetKind) { case KIND_CHARACTER: DoDamageCharacter( hitVector, power, flags, playerUID, uid, ActorGetByUID(targetUID), special); break; case KIND_OBJECT: { GameEvent e = GameEventNew(GAME_EVENT_MAP_OBJECT_DAMAGE); e.u.MapObjectDamage.UID = targetUID; e.u.MapObjectDamage.Power = power; e.u.MapObjectDamage.ActorUID = uid; e.u.MapObjectDamage.PlayerUID = playerUID; e.u.MapObjectDamage.Flags = flags; GameEventsEnqueue(&gGameEvents, e); } break; default: CASSERT(false, "cannot damage tile item kind"); break; } }
bool DamageSomething( const Vec2i hitVector, const int power, const int flags, const int player, const int uid, TTileItem *target, const special_damage_e special, const HitSounds *hitSounds, const bool allowFriendlyHitSound) { if (!target) { return 0; } const Vec2i pos = Vec2iNew(target->x, target->y); switch (target->kind) { case KIND_CHARACTER: return DoDamageCharacter( pos, hitVector, power, flags, player, uid, target, special, hitSounds, allowFriendlyHitSound); case KIND_OBJECT: DamageObject(power, flags, player, uid, target); if (gConfig.Sound.Hits && hitSounds != NULL && power > 0) { GameEvent es; es.Type = GAME_EVENT_SOUND_AT; es.u.SoundAt.Sound = hitSounds->Object; es.u.SoundAt.Pos = pos; GameEventsEnqueue(&gGameEvents, es); } break; case KIND_PARTICLE: case KIND_MOBILEOBJECT: break; } return 1; }