1
0
Fork 0

Add ambient mob sounds (#4521)

This commit is contained in:
Mat 2020-03-22 17:50:34 +02:00 committed by GitHub
parent 076749bd36
commit 9ddf433ae7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 62 additions and 41 deletions

View File

@ -11,8 +11,8 @@
cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, const AString & a_SoundAmbient, double a_Width, double a_Height) :
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_SoundAmbient, a_Width, a_Height)
{
m_EMPersonality = AGGRESSIVE;
}

View File

@ -14,7 +14,7 @@ class cAggressiveMonster :
public:
cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, const AString & a_SoundAmbient, double a_Width, double a_Height);
virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void InStateChasing(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;

View File

@ -6,7 +6,7 @@
cBat::cBat(void) :
super("Bat", mtBat, "entity.bat.hurt", "entity.bat.death", 0.5, 0.9)
super("Bat", mtBat, "entity.bat.hurt", "entity.bat.death", "entity.bat.ambient", 0.5, 0.9)
{
SetGravity(-2.0f);
SetAirDrag(0.05f);

View File

@ -9,7 +9,7 @@
cBlaze::cBlaze(void) :
super("Blaze", mtBlaze, "entity.blaze.hurt", "entity.blaze.death", 0.6, 1.8)
super("Blaze", mtBlaze, "entity.blaze.hurt", "entity.blaze.death", "entity.blaze.ambient", 0.6, 1.8)
{
SetGravity(-8.0f);
SetAirDrag(0.05f);

View File

@ -8,7 +8,7 @@
cCaveSpider::cCaveSpider(void) :
super("CaveSpider", mtCaveSpider, "entity.spider.hurt", "entity.spider.death", 0.7, 0.5)
super("CaveSpider", mtCaveSpider, "entity.spider.hurt", "entity.spider.death", "entity.spider.ambient", 0.7, 0.5)
{
}

View File

@ -8,7 +8,7 @@
cChicken::cChicken(void) :
super("Chicken", mtChicken, "entity.chicken.hurt", "entity.chicken.death", 0.4, 0.7),
super("Chicken", mtChicken, "entity.chicken.hurt", "entity.chicken.death", "entity.chicken.ambient", 0.4, 0.7),
m_EggDropTimer(0)
{
SetGravity(-2.0f);

View File

@ -9,7 +9,7 @@
cCow::cCow(void) :
super("Cow", mtCow, "entity.cow.hurt", "entity.cow.death", 0.9, 1.3)
super("Cow", mtCow, "entity.cow.hurt", "entity.cow.death", "entity.cow.ambient", 0.9, 1.3)
{
}

View File

@ -11,7 +11,7 @@
cCreeper::cCreeper(void) :
super("Creeper", mtCreeper, "entity.creeper.hurt", "entity.creeper.death", 0.6, 1.8),
super("Creeper", mtCreeper, "entity.creeper.hurt", "entity.creeper.death", "entity.creeper.ambient", 0.6, 1.8),
m_bIsBlowing(false),
m_bIsCharged(false),
m_BurnedWithFlintAndSteel(false),

View File

@ -9,7 +9,7 @@
cEnderDragon::cEnderDragon(void) :
// TODO: Vanilla source says this, but is it right? Dragons fly, they don't stand
super("EnderDragon", mtEnderDragon, "entity.enderdragon.hurt", "entity.enderdragon.death", 16.0, 8.0)
super("EnderDragon", mtEnderDragon, "entity.enderdragon.hurt", "entity.enderdragon.death", "entity.enderdragon.ambient", 16.0, 8.0)
{
}

View File

@ -73,7 +73,7 @@ protected:
cEnderman::cEnderman(void) :
super("Enderman", mtEnderman, "entity.endermen.hurt", "entity.endermen.death", 0.5, 2.9),
super("Enderman", mtEnderman, "entity.endermen.hurt", "entity.endermen.death", "entity.endermen.ambient", 0.5, 2.9),
m_bIsScreaming(false),
m_CarriedBlock(E_BLOCK_AIR),
m_CarriedMeta(0)

View File

@ -9,7 +9,7 @@
cGhast::cGhast(void) :
super("Ghast", mtGhast, "entity.ghast.hurt", "entity.ghast.death", 4, 4)
super("Ghast", mtGhast, "entity.ghast.hurt", "entity.ghast.death", "entity.ghast.ambient", 4, 4)
{
}

View File

@ -8,7 +8,7 @@
cGiant::cGiant(void) :
super("Giant", mtGiant, "entity.zombie.hurt", "entity.zombie.death", 3.6, 10.8)
super("Giant", mtGiant, "entity.zombie.hurt", "entity.zombie.death", "entity.zombie.ambient", 3.6, 10.8)
{
}

View File

@ -9,7 +9,7 @@
cGuardian::cGuardian(void) :
super("Guardian", mtGuardian, "entity.guardian.hurt", "entity.guardian.death", 0.875, 0.8)
super("Guardian", mtGuardian, "entity.guardian.hurt", "entity.guardian.death", "entity.guardian.ambient", 0.875, 0.8)
{
}

View File

@ -11,7 +11,7 @@
cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
super("Horse", mtHorse, "entity.horse.hurt", "entity.horse.death", 1.4, 1.6),
super("Horse", mtHorse, "entity.horse.hurt", "entity.horse.death", "entity.horse.ambient", 1.4, 1.6),
cEntityWindowOwner(this),
m_bHasChest(false),
m_bIsEating(false),

View File

@ -8,7 +8,7 @@
cIronGolem::cIronGolem(void) :
super("IronGolem", mtIronGolem, "entity.irongolem.hurt", "entity.irongolem.death", 1.4, 2.9)
super("IronGolem", mtIronGolem, "entity.irongolem.hurt", "entity.irongolem.death", "entity.irongolem.ambient", 1.4, 2.9)
{
}

View File

@ -7,7 +7,7 @@
cMagmaCube::cMagmaCube(int a_Size) :
super("MagmaCube", mtMagmaCube, Printf("entity.%smagmacube.hurt", GetSizeName(a_Size).c_str()), Printf("entity.%smagmacube.death", GetSizeName(a_Size).c_str()), 0.6 * a_Size, 0.6 * a_Size),
super("MagmaCube", mtMagmaCube, Printf("entity.%smagmacube.hurt", GetSizeName(a_Size).c_str()), Printf("entity.%smagmacube.death", GetSizeName(a_Size).c_str()), "", 0.6 * a_Size, 0.6 * a_Size),
m_Size(a_Size)
{
}

View File

@ -76,7 +76,7 @@ static const struct
////////////////////////////////////////////////////////////////////////////////
// cMonster:
cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, const AString & a_SoundAmbient, double a_Width, double a_Height)
: super(etMonster, a_Width, a_Height)
, m_EMState(IDLE)
, m_EMPersonality(AGGRESSIVE)
@ -90,6 +90,7 @@ cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const A
, m_CustomNameAlwaysVisible(false)
, m_SoundHurt(a_SoundHurt)
, m_SoundDeath(a_SoundDeath)
, m_SoundAmbient(a_SoundAmbient)
, m_AttackRate(3)
, m_AttackDamage(1)
, m_AttackRange(1)
@ -117,6 +118,9 @@ cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const A
{
GetMonsterConfig(a_ConfigName);
}
// Prevent mobs spawning at the same time from making sounds simultaneously
m_AmbientSoundTimer = GetRandomProvider().RandInt(0, 100);
}
@ -384,6 +388,19 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
BroadcastMovementUpdate();
// Ambient mob sounds
if (!m_SoundAmbient.empty() && (--m_AmbientSoundTimer <= 0))
{
auto & Random = GetRandomProvider();
auto ShouldPlaySound = Random.RandBool();
if (ShouldPlaySound)
{
auto SoundPitchMultiplier = 1.0f + (Random.RandReal(1.0f) - Random.RandReal(1.0f)) * 0.2f;
m_World->BroadcastSoundEffect(m_SoundAmbient, GetPosition(), 1.0f, SoundPitchMultiplier * 1.0f);
}
m_AmbientSoundTimer = 100;
}
if (m_AgingTimer > 0)
{
m_AgingTimer--;

View File

@ -39,7 +39,7 @@ public:
a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs 2012_12_22))
a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively
*/
cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, const AString & a_SoundAmbient, double a_Width, double a_Height);
virtual ~cMonster() override;
@ -267,6 +267,7 @@ protected:
AString m_SoundHurt;
AString m_SoundDeath;
AString m_SoundAmbient;
float m_AttackRate;
int m_AttackDamage;
@ -287,6 +288,8 @@ protected:
bool m_BurnsInDaylight;
double m_RelativeWalkSpeed;
int m_AmbientSoundTimer;
int m_Age;
int m_AgingTimer;

View File

@ -9,7 +9,7 @@
cMooshroom::cMooshroom(void) :
super("Mooshroom", mtMooshroom, "entity.cow.hurt", "entity.cow.death", 0.9, 1.3)
super("Mooshroom", mtMooshroom, "entity.cow.hurt", "entity.cow.death", "entity.cow.ambient", 0.9, 1.3)
{
}

View File

@ -21,7 +21,7 @@
*/
cOcelot::cOcelot(void) :
super("Ocelot", mtOcelot, "entity.cat.hurt", "entity.cat.death", 0.6, 0.8),
super("Ocelot", mtOcelot, "entity.cat.hurt", "entity.cat.death", "entity.cat.ambient", 0.6, 0.8),
m_IsSitting(false),
m_IsTame(false),
m_IsBegging(false),

View File

@ -9,8 +9,8 @@
cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, const AString & a_SoundAmbient, double a_Width, double a_Height) :
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_SoundAmbient, a_Width, a_Height)
{
m_EMPersonality = PASSIVE;
}

View File

@ -13,7 +13,7 @@ class cPassiveAggressiveMonster :
typedef cAggressiveMonster super;
public:
cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, const AString & a_SoundAmbient, double a_Width, double a_Height);
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void EventSeePlayer(cPlayer *, cChunk & a_Chunk) override;

View File

@ -10,8 +10,8 @@
cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height),
cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, const AString & a_SoundAmbient, double a_Width, double a_Height) :
super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_SoundAmbient, a_Width, a_Height),
m_LovePartner(nullptr),
m_LoveTimer(0),
m_LoveCooldown(0),

View File

@ -13,7 +13,7 @@ class cPassiveMonster :
typedef cMonster super;
public:
cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, const AString & a_SoundAmbient, double a_Width, double a_Height);
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void OnRightClicked(cPlayer & a_Player) override;

View File

@ -10,7 +10,7 @@
cPig::cPig(void) :
super("Pig", mtPig, "entity.pig.hurt", "entity.pig.death", 0.9, 0.9),
super("Pig", mtPig, "entity.pig.hurt", "entity.pig.death", "entity.pig.ambient", 0.9, 0.9),
m_bIsSaddled(false)
{
}

View File

@ -21,7 +21,7 @@ cRabbit::cRabbit(void) :
cRabbit::cRabbit(eRabbitType Type, int MoreCarrotTicks) :
super("Rabbit", mtRabbit, "entity.rabbit.hurt", "entity.rabbit.death", 0.82, 0.68),
super("Rabbit", mtRabbit, "entity.rabbit.hurt", "entity.rabbit.death", "entity.rabbit.ambient", 0.82, 0.68),
m_Type(Type),
m_MoreCarrotTicks(MoreCarrotTicks)
{

View File

@ -12,7 +12,7 @@
cSheep::cSheep(int a_Color) :
super("Sheep", mtSheep, "entity.sheep.hurt", "entity.sheep.death", 0.6, 1.3),
super("Sheep", mtSheep, "entity.sheep.hurt", "entity.sheep.death", "entity.sheep.ambient", 0.6, 1.3),
m_IsSheared(false),
m_WoolColor(a_Color),
m_TimeToStopEating(-1)

View File

@ -14,7 +14,7 @@ class cSilverfish :
public:
cSilverfish(void) :
super("Silverfish", mtSilverfish, "entity.silverfish.hurt", "entity.silverfish.death", 0.3, 0.4)
super("Silverfish", mtSilverfish, "entity.silverfish.hurt", "entity.silverfish.death", "entity.silverfish.ambient", 0.3, 0.4)
{
}

View File

@ -10,7 +10,7 @@
cSkeleton::cSkeleton(bool IsWither) :
super("Skeleton", mtSkeleton, "entity.skeleton.hurt", "entity.skeleton.death", 0.6, 1.8),
super("Skeleton", mtSkeleton, "entity.skeleton.hurt", "entity.skeleton.death", "entity.skeleton.ambient", 0.6, 1.8),
m_bIsWither(IsWither)
{
}

View File

@ -14,6 +14,7 @@ cSlime::cSlime(int a_Size) :
mtSlime,
Printf("entity.%sslime.hurt", GetSizeName(a_Size).c_str()),
Printf("entity.%sslime.death", GetSizeName(a_Size).c_str()),
"",
0.6 * a_Size,
0.6 * a_Size
),

View File

@ -9,7 +9,7 @@
cSnowGolem::cSnowGolem(void) :
super("SnowGolem", mtSnowGolem, "entity.snowman.hurt", "entity.snowman.death", 0.4, 1.8)
super("SnowGolem", mtSnowGolem, "entity.snowman.hurt", "entity.snowman.death", "entity.snowman.ambient", 0.4, 1.8)
{
}

View File

@ -9,7 +9,7 @@
cSpider::cSpider(void) :
super("Spider", mtSpider, "entity.spider.hurt", "entity.spider.death", 1.4, 0.9)
super("Spider", mtSpider, "entity.spider.hurt", "entity.spider.death", "entity.spider.ambient", 1.4, 0.9)
{
}

View File

@ -9,7 +9,7 @@
cSquid::cSquid(void) :
super("Squid", mtSquid, "entity.squid.hurt", "entity.squid.death", 0.95, 0.95)
super("Squid", mtSquid, "entity.squid.hurt", "entity.squid.death", "entity.squid.ambient", 0.95, 0.95)
{
}

View File

@ -12,7 +12,7 @@
cVillager::cVillager(eVillagerType VillagerType) :
super("Villager", mtVillager, "entity.villager.hurt", "entity.villager.death", 0.6, 1.8),
super("Villager", mtVillager, "entity.villager.hurt", "entity.villager.death", "entity.villager.ambient", 0.6, 1.8),
m_ActionCountDown(-1),
m_Type(VillagerType),
m_VillagerAction(false)

View File

@ -9,7 +9,7 @@
cWitch::cWitch(void) :
super("Witch", mtWitch, "entity.witch.hurt", "entity.witch.death", 0.6, 1.8)
super("Witch", mtWitch, "entity.witch.hurt", "entity.witch.death", "entity.witch.ambient", 0.6, 1.8)
{
}

View File

@ -11,7 +11,7 @@
cWither::cWither(void) :
super("Wither", mtWither, "entity.wither.hurt", "entity.wither.death", 0.9, 4.0),
super("Wither", mtWither, "entity.wither.hurt", "entity.wither.death", "entity.wither.ambient", 0.9, 4.0),
m_WitherInvulnerableTicks(220)
{
SetMaxHealth(300);

View File

@ -11,7 +11,7 @@
cWolf::cWolf(void) :
super("Wolf", mtWolf, "entity.wolf.hurt", "entity.wolf.death", 0.6, 0.8),
super("Wolf", mtWolf, "entity.wolf.hurt", "entity.wolf.death", "entity.wolf.ambient", 0.6, 0.8),
m_IsSitting(false),
m_IsTame(false),
m_IsBegging(false),

View File

@ -10,7 +10,7 @@
cZombie::cZombie(bool a_IsVillagerZombie) :
super("Zombie", mtZombie, "entity.zombie.hurt", "entity.zombie.death", 0.6, 1.8),
super("Zombie", mtZombie, "entity.zombie.hurt", "entity.zombie.death", "entity.zombie.ambient", 0.6, 1.8),
m_IsVillagerZombie(a_IsVillagerZombie),
m_IsConverting(false)
{

View File

@ -9,7 +9,7 @@
cZombiePigman::cZombiePigman(void) :
super("ZombiePigman", mtZombiePigman, "entity.zombie_pig.hurt", "entity.zombie_pig.death", 0.6, 1.8)
super("ZombiePigman", mtZombiePigman, "entity.zombie_pig.hurt", "entity.zombie_pig.death", "entity.zombie_pig.ambient", 0.6, 1.8)
{
}