From 5c99f3fadafa03664da4a179af28ed4db4980048 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 17 Dec 2014 17:28:24 +0100 Subject: Fixed eMonsterType lua bugs. --- src/Mobs/MonsterTypes.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Mobs') diff --git a/src/Mobs/MonsterTypes.h b/src/Mobs/MonsterTypes.h index dc6dd3992..3175f0606 100644 --- a/src/Mobs/MonsterTypes.h +++ b/src/Mobs/MonsterTypes.h @@ -37,6 +37,7 @@ enum eMonsterType mtWolf = E_META_SPAWN_EGG_WOLF, mtZombie = E_META_SPAWN_EGG_ZOMBIE, mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN, + mtMax = 120, } ; // tolua_end -- cgit v1.2.3 From fff108f20a8962f6690a9dff45176c7f31c8cf01 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 17 Dec 2014 19:16:35 +0100 Subject: Added comment. --- src/Mobs/MonsterTypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Mobs') diff --git a/src/Mobs/MonsterTypes.h b/src/Mobs/MonsterTypes.h index 3175f0606..6886bd51a 100644 --- a/src/Mobs/MonsterTypes.h +++ b/src/Mobs/MonsterTypes.h @@ -37,7 +37,7 @@ enum eMonsterType mtWolf = E_META_SPAWN_EGG_WOLF, mtZombie = E_META_SPAWN_EGG_ZOMBIE, mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN, - mtMax = 120, + mtMax = 120, // This is just a hotfix for #http://forum.mc-server.org/showthread.php?tid=1616. Tolua is too bad to find the highest value, so this is needed. } ; // tolua_end -- cgit v1.2.3 From c2926f8de1709d660cdca130f95a24623e2007c2 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 17 Dec 2014 20:08:55 +0100 Subject: derp --- src/Mobs/MonsterTypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Mobs') diff --git a/src/Mobs/MonsterTypes.h b/src/Mobs/MonsterTypes.h index 6886bd51a..bbe9e0471 100644 --- a/src/Mobs/MonsterTypes.h +++ b/src/Mobs/MonsterTypes.h @@ -37,7 +37,7 @@ enum eMonsterType mtWolf = E_META_SPAWN_EGG_WOLF, mtZombie = E_META_SPAWN_EGG_ZOMBIE, mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN, - mtMax = 120, // This is just a hotfix for #http://forum.mc-server.org/showthread.php?tid=1616. Tolua is too bad to find the highest value, so this is needed. + mtMax = 120, // This is just a hotfix for http://forum.mc-server.org/showthread.php?tid=1616. Tolua is too bad to find the highest value, so this is needed. } ; // tolua_end -- cgit v1.2.3 From c836b52dd1b8d6a2999721f235e6c2b6079b266c Mon Sep 17 00:00:00 2001 From: Masy98 Date: Thu, 18 Dec 2014 19:30:32 +0100 Subject: Added Entity Guardian --- src/Mobs/CMakeLists.txt | 2 ++ src/Mobs/Guardian.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++ src/Mobs/Guardian.h | 31 +++++++++++++++++++++ src/Mobs/IncludeAllMonsters.h | 1 + src/Mobs/Monster.cpp | 4 +++ src/Mobs/Monster.h | 2 +- src/Mobs/MonsterTypes.h | 1 + 7 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/Mobs/Guardian.cpp create mode 100644 src/Mobs/Guardian.h (limited to 'src/Mobs') diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt index bbbb9287a..c1ac2de32 100644 --- a/src/Mobs/CMakeLists.txt +++ b/src/Mobs/CMakeLists.txt @@ -16,6 +16,7 @@ SET (SRCS Enderman.cpp Ghast.cpp Giant.cpp + Guardian.cpp Horse.cpp IronGolem.cpp MagmaCube.cpp @@ -49,6 +50,7 @@ SET (HDRS Enderman.h Ghast.h Giant.h + Guardian.h Horse.h IncludeAllMonsters.h IronGolem.h diff --git a/src/Mobs/Guardian.cpp b/src/Mobs/Guardian.cpp new file mode 100644 index 000000000..166057865 --- /dev/null +++ b/src/Mobs/Guardian.cpp @@ -0,0 +1,65 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "Guardian.h" +#include "../Vector3.h" +#include "../Chunk.h" + + + + + +cGuardian::cGuardian(void) : + super("Guardian", mtGuardian, "mob.guardian.idle", "mob.guardian.death", 0.95, 0.95) +{ +} + + + + + +void cGuardian::GetDrops(cItems & a_Drops, cEntity * a_Killer) +{ + // Drops 0-3 Ink Sacs + int LootingLevel = 0; + if (a_Killer != nullptr) + { + LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); + } + AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_PRISMARINE_SHARD); + AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_RAW_FISH); + AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_PRISMARINE_CRYSTALS); // ToDo: Prismarine Crystals only drop if the raw fish drop is 0 +} + + + + + +void cGuardian::Tick(float a_Dt, cChunk & a_Chunk) +{ + // We must first process current location, and only then tick, otherwise we risk processing a location in a chunk + // that is not where the entity currently resides (FS #411) + + Vector3d Pos = GetPosition(); + + // TODO: Not a real behavior, but cool :D + int RelY = (int)floor(Pos.y); + if ((RelY < 0) || (RelY >= cChunkDef::Height)) + { + return; + } + int RelX = (int)floor(Pos.x) - a_Chunk.GetPosX() * cChunkDef::Width; + int RelZ = (int)floor(Pos.z) - a_Chunk.GetPosZ() * cChunkDef::Width; + BLOCKTYPE BlockType; + if (a_Chunk.UnboundedRelGetBlockType(RelX, RelY, RelZ, BlockType) && !IsBlockWater(BlockType) && !IsOnFire()) + { + // Burn for 10 ticks, then decide again + StartBurning(10); + } + + super::Tick(a_Dt, a_Chunk); +} + + + + diff --git a/src/Mobs/Guardian.h b/src/Mobs/Guardian.h new file mode 100644 index 000000000..50c034036 --- /dev/null +++ b/src/Mobs/Guardian.h @@ -0,0 +1,31 @@ + +#pragma once + +#include "AggressiveMonster.h" + + + + + +class cGuardian : + public cAggressiveMonster +{ + typedef cAggressiveMonster super; + +public: + cGuardian(); + + virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + + CLASS_PROTODEF(cGuardian) + + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; + + // Guardians do not drown (or float) + virtual void HandleAir(void) override {} + virtual void SetSwimState(cChunk & a_Chunk) override {} +} ; + + + + diff --git a/src/Mobs/IncludeAllMonsters.h b/src/Mobs/IncludeAllMonsters.h index 3460db993..f5eb9dcc3 100644 --- a/src/Mobs/IncludeAllMonsters.h +++ b/src/Mobs/IncludeAllMonsters.h @@ -8,6 +8,7 @@ #include "EnderDragon.h" #include "Ghast.h" #include "Giant.h" +#include "Guardian.h" #include "Horse.h" #include "IronGolem.h" #include "MagmaCube.h" diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 7b8f763af..963ca628c 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -38,6 +38,7 @@ static const struct {mtEnderman, "enderman", "Enderman"}, {mtEnderDragon, "enderdragon", "EnderDragon"}, {mtGhast, "ghast", "Ghast"}, + {mtGuardian, "guardian", "Guardian"}, {mtHorse, "horse", "EntityHorse"}, {mtIronGolem, "irongolem", "VillagerGolem"}, {mtMagmaCube, "magmacube", "LavaSlime"}, @@ -513,6 +514,7 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI) case mtCreeper: case mtEnderman: case mtGhast: + case mtGuardian: case mtSilverfish: case mtSkeleton: case mtSpider: @@ -842,6 +844,7 @@ cMonster::eFamily cMonster::FamilyFromType(eMonsterType a_Type) case mtEnderman: return mfHostile; case mtGhast: return mfHostile; case mtGiant: return mfNoSpawn; + case mtGuardian: return mfNoSpawn; // Just because they have special spawning conditions. If Watertemples have been added, this needs to be edited! case mtHorse: return mfPassive; case mtIronGolem: return mfPassive; case mtMagmaCube: return mfHostile; @@ -955,6 +958,7 @@ cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType) case mtEnderman: toReturn = new cEnderman(); break; case mtGhast: toReturn = new cGhast(); break; case mtGiant: toReturn = new cGiant(); break; + case mtGuardian: toReturn = new cGuardian(); break; case mtIronGolem: toReturn = new cIronGolem(); break; case mtMooshroom: toReturn = new cMooshroom(); break; case mtOcelot: toReturn = new cOcelot(); break; diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index f04e45ac6..fb1bc550d 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -30,7 +30,7 @@ public: mfHostile = 0, // Spider, Zombies ... mfPassive = 1, // Cows, Pigs mfAmbient = 2, // Bats - mfWater = 3, // Squid + mfWater = 3, // Squid, Guardian mfNoSpawn, mfUnhandled, // Nothing. Be sure this is the last and the others are in order diff --git a/src/Mobs/MonsterTypes.h b/src/Mobs/MonsterTypes.h index dc6dd3992..50fcf971a 100644 --- a/src/Mobs/MonsterTypes.h +++ b/src/Mobs/MonsterTypes.h @@ -18,6 +18,7 @@ enum eMonsterType mtEnderman = E_META_SPAWN_EGG_ENDERMAN, mtGhast = E_META_SPAWN_EGG_GHAST, mtGiant = E_META_SPAWN_EGG_GIANT, + mtGuardian = E_META_SPAWN_EGG_GUARDIAN, mtHorse = E_META_SPAWN_EGG_HORSE, mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM, mtMagmaCube = E_META_SPAWN_EGG_MAGMA_CUBE, -- cgit v1.2.3 From f09c6701eb9126b627503bc301084ffb4039fabd Mon Sep 17 00:00:00 2001 From: Masy98 Date: Thu, 18 Dec 2014 20:44:39 +0100 Subject: Guardian can now spawn if wanted!? --- src/Mobs/Monster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 963ca628c..3d174677c 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -844,7 +844,7 @@ cMonster::eFamily cMonster::FamilyFromType(eMonsterType a_Type) case mtEnderman: return mfHostile; case mtGhast: return mfHostile; case mtGiant: return mfNoSpawn; - case mtGuardian: return mfNoSpawn; // Just because they have special spawning conditions. If Watertemples have been added, this needs to be edited! + case mtGuardian: return mfWater; // Just because they have special spawning conditions. If Watertemples have been added, this needs to be edited! case mtHorse: return mfPassive; case mtIronGolem: return mfPassive; case mtMagmaCube: return mfHostile; -- cgit v1.2.3 From 5cfb6063c37243477ea79319706dae7cdde27ab2 Mon Sep 17 00:00:00 2001 From: Masy98 Date: Fri, 19 Dec 2014 16:06:43 +0100 Subject: Fixed Guardians size and health --- src/Mobs/Guardian.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Guardian.cpp b/src/Mobs/Guardian.cpp index 166057865..d69ee1683 100644 --- a/src/Mobs/Guardian.cpp +++ b/src/Mobs/Guardian.cpp @@ -10,7 +10,7 @@ cGuardian::cGuardian(void) : - super("Guardian", mtGuardian, "mob.guardian.idle", "mob.guardian.death", 0.95, 0.95) + super("Guardian", mtGuardian, "mob.guardian.idle", "mob.guardian.death", 0.875, 0.8) { } -- cgit v1.2.3 From 6e8e1c6d8da3d5a0f5ca39f6f18d88c2ca6c1e71 Mon Sep 17 00:00:00 2001 From: Masy98 Date: Sat, 20 Dec 2014 10:31:34 +0100 Subject: Added Rabbits --- src/Mobs/IncludeAllMonsters.h | 1 + src/Mobs/Monster.cpp | 4 ++++ src/Mobs/MonsterTypes.h | 1 + src/Mobs/Rabbit.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/Mobs/Rabbit.h | 24 ++++++++++++++++++++++++ 5 files changed, 68 insertions(+) create mode 100644 src/Mobs/Rabbit.cpp create mode 100644 src/Mobs/Rabbit.h (limited to 'src/Mobs') diff --git a/src/Mobs/IncludeAllMonsters.h b/src/Mobs/IncludeAllMonsters.h index f5eb9dcc3..53c709c2b 100644 --- a/src/Mobs/IncludeAllMonsters.h +++ b/src/Mobs/IncludeAllMonsters.h @@ -15,6 +15,7 @@ #include "Mooshroom.h" #include "Ocelot.h" #include "Pig.h" +#include "Rabbit.h" #include "Sheep.h" #include "Silverfish.h" #include "Skeleton.h" diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 3d174677c..a02ea357e 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -45,6 +45,7 @@ static const struct {mtMooshroom, "mooshroom", "MushroomCow"}, {mtOcelot, "ocelot", "Ozelot"}, {mtPig, "pig", "Pig"}, + {mtRabbit, "rabbit", "Rabbit"}, {mtSheep, "sheep", "Sheep"}, {mtSilverfish, "silverfish", "Silverfish"}, {mtSkeleton, "skeleton", "Skeleton"}, @@ -499,6 +500,7 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI) case mtCow: case mtHorse: case mtPig: + case mtRabbit: case mtSheep: case mtSquid: case mtMooshroom: @@ -851,6 +853,7 @@ cMonster::eFamily cMonster::FamilyFromType(eMonsterType a_Type) case mtMooshroom: return mfHostile; case mtOcelot: return mfPassive; case mtPig: return mfPassive; + case mtRabbit: return mfPassive; case mtSheep: return mfPassive; case mtSilverfish: return mfHostile; case mtSkeleton: return mfHostile; @@ -963,6 +966,7 @@ cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType) case mtMooshroom: toReturn = new cMooshroom(); break; case mtOcelot: toReturn = new cOcelot(); break; case mtPig: toReturn = new cPig(); break; + case mtRabbit: toReturn = new cRabbit(); break; case mtSheep: toReturn = new cSheep(); break; case mtSilverfish: toReturn = new cSilverfish(); break; case mtSnowGolem: toReturn = new cSnowGolem(); break; diff --git a/src/Mobs/MonsterTypes.h b/src/Mobs/MonsterTypes.h index 0d716cca3..02bec267b 100644 --- a/src/Mobs/MonsterTypes.h +++ b/src/Mobs/MonsterTypes.h @@ -25,6 +25,7 @@ enum eMonsterType mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM, mtOcelot = E_META_SPAWN_EGG_OCELOT, mtPig = E_META_SPAWN_EGG_PIG, + mtRabbit = E_META_SPAWN_EGG_RABBIT, mtSheep = E_META_SPAWN_EGG_SHEEP, mtSilverfish = E_META_SPAWN_EGG_SILVERFISH, mtSkeleton = E_META_SPAWN_EGG_SKELETON, diff --git a/src/Mobs/Rabbit.cpp b/src/Mobs/Rabbit.cpp new file mode 100644 index 000000000..1c7d810b7 --- /dev/null +++ b/src/Mobs/Rabbit.cpp @@ -0,0 +1,38 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "Rabbit.h" +#include "../Entities/Player.h" +#include "../World.h" + + + + + +cRabbit::cRabbit(void) : + super("Rabbit", mtRabbit, "mob.rabbit.idle", "mob.rabbit.death", 0.9, 0.9) +{ +} + + + + + +void cRabbit::GetDrops(cItems & a_Drops, cEntity * a_Killer) +{ + int LootingLevel = 0; + if (a_Killer != nullptr) + { + LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting); + } + AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, IsOnFire() ? E_ITEM_COOKED_RABBIT : E_ITEM_RAW_RABBIT); + AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_RABBIT_HIDE); + cItems RareDrops; + RareDrops.Add(cItem(E_ITEM_RABBITS_FOOT)); + AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel); +} + + + + + diff --git a/src/Mobs/Rabbit.h b/src/Mobs/Rabbit.h new file mode 100644 index 000000000..5ea03d09b --- /dev/null +++ b/src/Mobs/Rabbit.h @@ -0,0 +1,24 @@ + +#pragma once + +#include "PassiveMonster.h" + + + + + +class cRabbit : + public cPassiveMonster +{ + typedef cPassiveMonster super; + +public: + cRabbit(); + + CLASS_PROTODEF(cRabbit) + + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; + + virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); } + +} ; \ No newline at end of file -- cgit v1.2.3 From 3d2b1875a196a6aa39414381d580bdf5b2135bff Mon Sep 17 00:00:00 2001 From: Masy98 Date: Sat, 20 Dec 2014 10:38:56 +0100 Subject: Fixed Rabbit size --- src/Mobs/Rabbit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Rabbit.cpp b/src/Mobs/Rabbit.cpp index 1c7d810b7..7b873da33 100644 --- a/src/Mobs/Rabbit.cpp +++ b/src/Mobs/Rabbit.cpp @@ -10,7 +10,7 @@ cRabbit::cRabbit(void) : - super("Rabbit", mtRabbit, "mob.rabbit.idle", "mob.rabbit.death", 0.9, 0.9) + super("Rabbit", mtRabbit, "mob.rabbit.idle", "mob.rabbit.death", 0.82, 0.68) { } -- cgit v1.2.3 From 7903ee485ee58b67c6bc4a6b7a182c5d855d5418 Mon Sep 17 00:00:00 2001 From: Masy98 Date: Sat, 20 Dec 2014 11:41:23 +0100 Subject: Added Rabbit.h and Rabbit.cpp to the CMakeList --- src/Mobs/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Mobs') diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt index c1ac2de32..7a291dcf2 100644 --- a/src/Mobs/CMakeLists.txt +++ b/src/Mobs/CMakeLists.txt @@ -25,6 +25,7 @@ SET (SRCS PassiveAggressiveMonster.cpp PassiveMonster.cpp Pig.cpp + Rabbit.cpp Sheep.cpp Skeleton.cpp Slime.cpp @@ -62,6 +63,7 @@ SET (HDRS PassiveAggressiveMonster.h PassiveMonster.h Pig.h + Rabbit.h Sheep.h Silverfish.h Skeleton.h -- cgit v1.2.3 From 5695649bb94276a7465c6c1df5a271889650abc0 Mon Sep 17 00:00:00 2001 From: Masy98 Date: Sat, 20 Dec 2014 13:04:42 +0100 Subject: Fixed damn empty line with no use --- src/Mobs/Rabbit.cpp | 4 ---- src/Mobs/Rabbit.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Rabbit.cpp b/src/Mobs/Rabbit.cpp index 7b873da33..cf49d2744 100644 --- a/src/Mobs/Rabbit.cpp +++ b/src/Mobs/Rabbit.cpp @@ -32,7 +32,3 @@ void cRabbit::GetDrops(cItems & a_Drops, cEntity * a_Killer) AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel); } - - - - diff --git a/src/Mobs/Rabbit.h b/src/Mobs/Rabbit.h index 5ea03d09b..e86c85579 100644 --- a/src/Mobs/Rabbit.h +++ b/src/Mobs/Rabbit.h @@ -21,4 +21,4 @@ public: virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); } -} ; \ No newline at end of file +} ; -- cgit v1.2.3 From 3da6e4374e72e86930a24441c2b26f8eb582c723 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 25 Dec 2014 00:44:09 +0100 Subject: Fixed basic style. --- src/Mobs/Guardian.cpp | 2 +- src/Mobs/Monster.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/Guardian.cpp b/src/Mobs/Guardian.cpp index d69ee1683..15908d801 100644 --- a/src/Mobs/Guardian.cpp +++ b/src/Mobs/Guardian.cpp @@ -28,7 +28,7 @@ void cGuardian::GetDrops(cItems & a_Drops, cEntity * a_Killer) } AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_PRISMARINE_SHARD); AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_RAW_FISH); - AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_PRISMARINE_CRYSTALS); // ToDo: Prismarine Crystals only drop if the raw fish drop is 0 + AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_PRISMARINE_CRYSTALS); // TODO: Prismarine Crystals only drop if the raw fish drop is 0 } diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index a02ea357e..425c80bf4 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -846,7 +846,7 @@ cMonster::eFamily cMonster::FamilyFromType(eMonsterType a_Type) case mtEnderman: return mfHostile; case mtGhast: return mfHostile; case mtGiant: return mfNoSpawn; - case mtGuardian: return mfWater; // Just because they have special spawning conditions. If Watertemples have been added, this needs to be edited! + case mtGuardian: return mfWater; // Just because they have special spawning conditions. If Watertemples have been added, this needs to be edited! case mtHorse: return mfPassive; case mtIronGolem: return mfPassive; case mtMagmaCube: return mfHostile; -- cgit v1.2.3 From 2a9664d6ca8aa9eb4f554301e4d9b0ec33b465ce Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 11 Jan 2015 21:12:26 +0000 Subject: Initial convertion of a_Dt to std::chrono also refactored cWorld::m_WorldAge and cWorld::m_TimeOfDay --- src/Mobs/AggressiveMonster.cpp | 6 +++--- src/Mobs/AggressiveMonster.h | 4 ++-- src/Mobs/Blaze.cpp | 4 ++-- src/Mobs/Blaze.h | 2 +- src/Mobs/CaveSpider.cpp | 4 ++-- src/Mobs/CaveSpider.h | 4 ++-- src/Mobs/Chicken.cpp | 2 +- src/Mobs/Chicken.h | 2 +- src/Mobs/Creeper.cpp | 4 ++-- src/Mobs/Creeper.h | 4 ++-- src/Mobs/Enderman.cpp | 2 +- src/Mobs/Enderman.h | 2 +- src/Mobs/Ghast.cpp | 4 ++-- src/Mobs/Ghast.h | 2 +- src/Mobs/Guardian.cpp | 2 +- src/Mobs/Guardian.h | 2 +- src/Mobs/Horse.cpp | 2 +- src/Mobs/Horse.h | 2 +- src/Mobs/Monster.cpp | 12 +++++------- src/Mobs/Monster.h | 2 +- src/Mobs/PassiveMonster.cpp | 2 +- src/Mobs/PassiveMonster.h | 2 +- src/Mobs/Pig.cpp | 2 +- src/Mobs/Pig.h | 2 +- src/Mobs/Sheep.cpp | 2 +- src/Mobs/Sheep.h | 2 +- src/Mobs/Skeleton.cpp | 4 ++-- src/Mobs/Skeleton.h | 2 +- src/Mobs/Slime.cpp | 2 +- src/Mobs/Slime.h | 2 +- src/Mobs/SnowGolem.cpp | 2 +- src/Mobs/SnowGolem.h | 2 +- src/Mobs/Squid.cpp | 2 +- src/Mobs/Squid.h | 2 +- src/Mobs/Villager.cpp | 2 +- src/Mobs/Villager.h | 2 +- src/Mobs/Wither.cpp | 2 +- src/Mobs/Wither.h | 2 +- src/Mobs/Wolf.cpp | 4 ++-- src/Mobs/Wolf.h | 4 ++-- 40 files changed, 56 insertions(+), 58 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index 7ca7a9d66..b9e80c01d 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -61,7 +61,7 @@ void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity) -void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk) +void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); @@ -93,9 +93,9 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk) -void cAggressiveMonster::Attack(float a_Dt) +void cAggressiveMonster::Attack(std::chrono::milliseconds a_Dt) { - m_AttackInterval += a_Dt * m_AttackRate; + m_AttackInterval += a_Dt.count() * m_AttackRate; if ((m_Target == nullptr) || (m_AttackInterval < 3.0)) { diff --git a/src/Mobs/AggressiveMonster.h b/src/Mobs/AggressiveMonster.h index 2549ba2d3..932915055 100644 --- a/src/Mobs/AggressiveMonster.h +++ b/src/Mobs/AggressiveMonster.h @@ -16,11 +16,11 @@ public: cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); - virtual void Tick (float a_Dt, cChunk & a_Chunk) override; + virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual void InStateChasing(float a_Dt) override; virtual void EventSeePlayer(cEntity *) override; - virtual void Attack(float a_Dt); + virtual void Attack(std::chrono::milliseconds a_Dt); protected: /** Whether this mob's destination is the same as its target's position. */ diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp index 1fa9d2c37..172ccd071 100644 --- a/src/Mobs/Blaze.cpp +++ b/src/Mobs/Blaze.cpp @@ -30,9 +30,9 @@ void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cBlaze::Attack(float a_Dt) +void cBlaze::Attack(std::chrono::milliseconds a_Dt) { - m_AttackInterval += a_Dt * m_AttackRate; + m_AttackInterval += a_Dt.count() * m_AttackRate; if ((m_Target != nullptr) && (m_AttackInterval > 3.0)) { diff --git a/src/Mobs/Blaze.h b/src/Mobs/Blaze.h index e2a4ad9f1..493953a14 100644 --- a/src/Mobs/Blaze.h +++ b/src/Mobs/Blaze.h @@ -18,5 +18,5 @@ public: CLASS_PROTODEF(cBlaze) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; - virtual void Attack(float a_Dt) override; + virtual void Attack(std::chrono::milliseconds a_Dt) override; } ; diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp index 045b47e73..fa530db82 100644 --- a/src/Mobs/CaveSpider.cpp +++ b/src/Mobs/CaveSpider.cpp @@ -16,7 +16,7 @@ cCaveSpider::cCaveSpider(void) : -void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk) +void cCaveSpider::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); @@ -27,7 +27,7 @@ void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk) -void cCaveSpider::Attack(float a_Dt) +void cCaveSpider::Attack(std::chrono::milliseconds a_Dt) { super::Attack(a_Dt); diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h index 494ba1360..d3e56fd2b 100644 --- a/src/Mobs/CaveSpider.h +++ b/src/Mobs/CaveSpider.h @@ -16,8 +16,8 @@ public: CLASS_PROTODEF(cCaveSpider) - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - virtual void Attack(float a_Dt) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; + virtual void Attack(std::chrono::milliseconds a_Dt) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; } ; diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp index 634867cfa..b2b21d4ae 100644 --- a/src/Mobs/Chicken.cpp +++ b/src/Mobs/Chicken.cpp @@ -18,7 +18,7 @@ cChicken::cChicken(void) : -void cChicken::Tick(float a_Dt, cChunk & a_Chunk) +void cChicken::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); diff --git a/src/Mobs/Chicken.h b/src/Mobs/Chicken.h index 07b921884..9349187c6 100644 --- a/src/Mobs/Chicken.h +++ b/src/Mobs/Chicken.h @@ -17,7 +17,7 @@ public: CLASS_PROTODEF(cChicken) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_SEEDS); } diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp index a073224cf..c4ae47f2f 100644 --- a/src/Mobs/Creeper.cpp +++ b/src/Mobs/Creeper.cpp @@ -23,7 +23,7 @@ cCreeper::cCreeper(void) : -void cCreeper::Tick(float a_Dt, cChunk & a_Chunk) +void cCreeper::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); @@ -119,7 +119,7 @@ bool cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI) -void cCreeper::Attack(float a_Dt) +void cCreeper::Attack(std::chrono::milliseconds a_Dt) { UNUSED(a_Dt); diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h index bf3272e22..1827c416e 100644 --- a/src/Mobs/Creeper.h +++ b/src/Mobs/Creeper.h @@ -19,8 +19,8 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; - virtual void Attack(float a_Dt) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Attack(std::chrono::milliseconds a_Dt) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual void OnRightClicked(cPlayer & a_Player) override; bool IsBlowing(void) const {return m_bIsBlowing; } diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp index 56ea10245..42c33884a 100644 --- a/src/Mobs/Enderman.cpp +++ b/src/Mobs/Enderman.cpp @@ -186,7 +186,7 @@ bool cEnderman::CheckLight() -void cEnderman::Tick(float a_Dt, cChunk & a_Chunk) +void cEnderman::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); diff --git a/src/Mobs/Enderman.h b/src/Mobs/Enderman.h index 28bbceb84..8ccbf2ce7 100644 --- a/src/Mobs/Enderman.h +++ b/src/Mobs/Enderman.h @@ -21,7 +21,7 @@ public: virtual void CheckEventSeePlayer(void) override; virtual void CheckEventLostPlayer(void) override; virtual void EventLosePlayer(void) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; bool IsScreaming(void) const {return m_bIsScreaming; } BLOCKTYPE GetCarriedBlock(void) const {return CarriedBlock; } diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp index fc8de8362..ea0295102 100644 --- a/src/Mobs/Ghast.cpp +++ b/src/Mobs/Ghast.cpp @@ -32,9 +32,9 @@ void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cGhast::Attack(float a_Dt) +void cGhast::Attack(std::chrono::milliseconds a_Dt) { - m_AttackInterval += a_Dt * m_AttackRate; + m_AttackInterval += a_Dt.count() * m_AttackRate; if ((m_Target != nullptr) && (m_AttackInterval > 3.0)) { diff --git a/src/Mobs/Ghast.h b/src/Mobs/Ghast.h index a28940a01..431edaf6d 100644 --- a/src/Mobs/Ghast.h +++ b/src/Mobs/Ghast.h @@ -18,7 +18,7 @@ public: CLASS_PROTODEF(cGhast) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; - virtual void Attack(float a_Dt) override; + virtual void Attack(std::chrono::milliseconds a_Dt) override; bool IsCharging(void) const {return false; } } ; diff --git a/src/Mobs/Guardian.cpp b/src/Mobs/Guardian.cpp index 15908d801..5eb30785b 100644 --- a/src/Mobs/Guardian.cpp +++ b/src/Mobs/Guardian.cpp @@ -35,7 +35,7 @@ void cGuardian::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cGuardian::Tick(float a_Dt, cChunk & a_Chunk) +void cGuardian::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { // We must first process current location, and only then tick, otherwise we risk processing a location in a chunk // that is not where the entity currently resides (FS #411) diff --git a/src/Mobs/Guardian.h b/src/Mobs/Guardian.h index 50c034036..6bc17947c 100644 --- a/src/Mobs/Guardian.h +++ b/src/Mobs/Guardian.h @@ -15,7 +15,7 @@ class cGuardian : public: cGuardian(); - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; CLASS_PROTODEF(cGuardian) diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp index d92f0d023..5b4c78bfc 100644 --- a/src/Mobs/Horse.cpp +++ b/src/Mobs/Horse.cpp @@ -30,7 +30,7 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) : -void cHorse::Tick(float a_Dt, cChunk & a_Chunk) +void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); diff --git a/src/Mobs/Horse.h b/src/Mobs/Horse.h index 4c644e512..be283705e 100644 --- a/src/Mobs/Horse.h +++ b/src/Mobs/Horse.h @@ -18,7 +18,7 @@ public: CLASS_PROTODEF(cHorse) virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual void OnRightClicked(cPlayer & a_Player) override; bool IsSaddled (void) const {return m_bIsSaddled; } diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 425c80bf4..30bbd0ff2 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -252,14 +252,14 @@ bool cMonster::ReachedFinalDestination() -void cMonster::Tick(float a_Dt, cChunk & a_Chunk) +void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); if (m_Health <= 0) { // The mob is dead, but we're still animating the "puff" they leave when they die - m_DestroyTimer += a_Dt / 1000; + m_DestroyTimer += a_Dt.count() / 1000; if (m_DestroyTimer > 1) { Destroy(true); @@ -275,8 +275,6 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) // Burning in daylight HandleDaylightBurning(a_Chunk); - a_Dt /= 1000; - if (m_bMovingToDestination) { if (m_bOnGround) @@ -347,18 +345,18 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk) case IDLE: { // If enemy passive we ignore checks for player visibility - InStateIdle(a_Dt); + InStateIdle(std::chrono::duration_cast(a_Dt).count()); break; } case CHASING: { // If we do not see a player anymore skip chasing action - InStateChasing(a_Dt); + InStateChasing(std::chrono::duration_cast(a_Dt).count()); break; } case ESCAPING: { - InStateEscaping(a_Dt); + InStateEscaping(std::chrono::duration_cast(a_Dt).count()); break; } diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index fb1bc550d..5752a2040 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -52,7 +52,7 @@ public: virtual void SpawnOn(cClientHandle & a_ClientHandle) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp index 1048616d0..012ca9949 100644 --- a/src/Mobs/PassiveMonster.cpp +++ b/src/Mobs/PassiveMonster.cpp @@ -35,7 +35,7 @@ bool cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI) -void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk) +void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); diff --git a/src/Mobs/PassiveMonster.h b/src/Mobs/PassiveMonster.h index 9221d9a6e..2ed2cd21d 100644 --- a/src/Mobs/PassiveMonster.h +++ b/src/Mobs/PassiveMonster.h @@ -15,7 +15,7 @@ class cPassiveMonster : public: cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; /// When hit by someone, run away virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp index 1e4c35acd..edd4d9de4 100644 --- a/src/Mobs/Pig.cpp +++ b/src/Mobs/Pig.cpp @@ -80,7 +80,7 @@ void cPig::OnRightClicked(cPlayer & a_Player) -void cPig::Tick(float a_Dt, cChunk & a_Chunk) +void cPig::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h index 0e026933a..0fe4b4fed 100644 --- a/src/Mobs/Pig.h +++ b/src/Mobs/Pig.h @@ -22,7 +22,7 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; virtual void OnRightClicked(cPlayer & a_Player) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); } diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index c46404391..e4d1760e0 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -84,7 +84,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player) -void cSheep::Tick(float a_Dt, cChunk & a_Chunk) +void cSheep::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); int PosX = POSX_TOINT; diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h index 16d5fddd3..b6c99ac2a 100644 --- a/src/Mobs/Sheep.h +++ b/src/Mobs/Sheep.h @@ -24,7 +24,7 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; virtual void OnRightClicked(cPlayer & a_Player) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); } diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp index da5ddc670..dd59d6454 100644 --- a/src/Mobs/Skeleton.cpp +++ b/src/Mobs/Skeleton.cpp @@ -67,9 +67,9 @@ void cSkeleton::MoveToPosition(const Vector3d & a_Position) -void cSkeleton::Attack(float a_Dt) +void cSkeleton::Attack(std::chrono::milliseconds a_Dt) { - m_AttackInterval += a_Dt * m_AttackRate; + m_AttackInterval += a_Dt.count() * m_AttackRate; if ((m_Target != nullptr) && (m_AttackInterval > 3.0)) { diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h index cd1c6c3f0..9c49c52fb 100644 --- a/src/Mobs/Skeleton.h +++ b/src/Mobs/Skeleton.h @@ -19,7 +19,7 @@ public: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; virtual void MoveToPosition(const Vector3d & a_Position) override; - virtual void Attack(float a_Dt) override; + virtual void Attack(std::chrono::milliseconds a_Dt) override; virtual void SpawnOn(cClientHandle & a_ClientHandle) override; virtual bool IsUndead(void) override { return true; } diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp index 1c68c5189..e42501e47 100644 --- a/src/Mobs/Slime.cpp +++ b/src/Mobs/Slime.cpp @@ -46,7 +46,7 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cSlime::Attack(float a_Dt) +void cSlime::Attack(std::chrono::milliseconds a_Dt) { if (m_Size > 1) { diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h index a177a279c..29605992d 100644 --- a/src/Mobs/Slime.h +++ b/src/Mobs/Slime.h @@ -20,7 +20,7 @@ public: // cAggressiveMonster overrides: virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; - virtual void Attack(float a_Dt) override; + virtual void Attack(std::chrono::milliseconds a_Dt) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override; int GetSize(void) const { return m_Size; } diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp index 8c4178beb..e1510b203 100644 --- a/src/Mobs/SnowGolem.cpp +++ b/src/Mobs/SnowGolem.cpp @@ -27,7 +27,7 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk) +void cSnowGolem::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ())))) diff --git a/src/Mobs/SnowGolem.h b/src/Mobs/SnowGolem.h index f036b1867..9c95e21c5 100644 --- a/src/Mobs/SnowGolem.h +++ b/src/Mobs/SnowGolem.h @@ -17,7 +17,7 @@ public: CLASS_PROTODEF(cSnowGolem) - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; } ; diff --git a/src/Mobs/Squid.cpp b/src/Mobs/Squid.cpp index 59ee963ae..3c508b65f 100644 --- a/src/Mobs/Squid.cpp +++ b/src/Mobs/Squid.cpp @@ -33,7 +33,7 @@ void cSquid::GetDrops(cItems & a_Drops, cEntity * a_Killer) -void cSquid::Tick(float a_Dt, cChunk & a_Chunk) +void cSquid::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { // We must first process current location, and only then tick, otherwise we risk processing a location in a chunk // that is not where the entity currently resides (FS #411) diff --git a/src/Mobs/Squid.h b/src/Mobs/Squid.h index a46d738c6..7e944a17e 100644 --- a/src/Mobs/Squid.h +++ b/src/Mobs/Squid.h @@ -15,7 +15,7 @@ class cSquid : public: cSquid(); - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; CLASS_PROTODEF(cSquid) diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index 963595347..6f647ac18 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -51,7 +51,7 @@ bool cVillager::DoTakeDamage(TakeDamageInfo & a_TDI) -void cVillager::Tick(float a_Dt, cChunk & a_Chunk) +void cVillager::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h index d3a38dbf0..2de79295c 100644 --- a/src/Mobs/Villager.h +++ b/src/Mobs/Villager.h @@ -31,7 +31,7 @@ public: // cEntity overrides virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; - virtual void Tick (float a_Dt, cChunk & a_Chunk) override; + virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; // cVillager functions /** return true if the given blocktype are: crops, potatoes or carrots.*/ diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp index 578b47995..6ef81ce1b 100644 --- a/src/Mobs/Wither.cpp +++ b/src/Mobs/Wither.cpp @@ -66,7 +66,7 @@ bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI) -void cWither::Tick(float a_Dt, cChunk & a_Chunk) +void cWither::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h index a20fed3d3..9e333c7fa 100644 --- a/src/Mobs/Wither.h +++ b/src/Mobs/Wither.h @@ -28,7 +28,7 @@ public: virtual bool Initialize(cWorld & a_World) override; virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override; virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual void KilledBy(TakeDamageInfo & a_TDI) override; virtual bool IsUndead(void) override { return true; } diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp index 4711d5a7a..b3eefdf79 100644 --- a/src/Mobs/Wolf.cpp +++ b/src/Mobs/Wolf.cpp @@ -43,7 +43,7 @@ bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI) -void cWolf::Attack(float a_Dt) +void cWolf::Attack(std::chrono::milliseconds a_Dt) { UNUSED(a_Dt); @@ -145,7 +145,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player) -void cWolf::Tick(float a_Dt, cChunk & a_Chunk) +void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { if (!IsAngry()) { diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h index 7500854f8..73ffb55c2 100644 --- a/src/Mobs/Wolf.h +++ b/src/Mobs/Wolf.h @@ -20,9 +20,9 @@ public: virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override; virtual void OnRightClicked(cPlayer & a_Player) override; - virtual void Tick(float a_Dt, cChunk & a_Chunk) override; + virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; virtual void TickFollowPlayer(); - virtual void Attack(float a_Dt) override; + virtual void Attack(std::chrono::milliseconds a_Dt) override; // Get functions bool IsSitting (void) const { return m_IsSitting; } -- cgit v1.2.3 From bfe1960191e902013b5ac75e8a3a487496d63bb9 Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 16 Jan 2015 14:38:21 +0000 Subject: Converted Monster to std::chrono --- src/Mobs/AggressiveMonster.cpp | 2 +- src/Mobs/AggressiveMonster.h | 2 +- src/Mobs/Monster.cpp | 22 +++++++++++----------- src/Mobs/Monster.h | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/Mobs') diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp index b9e80c01d..72317d66b 100644 --- a/src/Mobs/AggressiveMonster.cpp +++ b/src/Mobs/AggressiveMonster.cpp @@ -22,7 +22,7 @@ cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eMonsterTyp // What to do if in Chasing State -void cAggressiveMonster::InStateChasing(float a_Dt) +void cAggressiveMonster::InStateChasing(std::chrono::milliseconds a_Dt) { super::InStateChasing(a_Dt); diff --git a/src/Mobs/AggressiveMonster.h b/src/Mobs/AggressiveMonster.h index 932915055..f64c1103f 100644 --- a/src/Mobs/AggressiveMonster.h +++ b/src/Mobs/AggressiveMonster.h @@ -17,7 +17,7 @@ public: cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height); virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override; - virtual void InStateChasing(float a_Dt) override; + virtual void InStateChasing(std::chrono::milliseconds a_Dt) override; virtual void EventSeePlayer(cEntity *) override; virtual void Attack(std::chrono::milliseconds a_Dt); diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 30bbd0ff2..6e07bfbb6 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -259,8 +259,8 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) if (m_Health <= 0) { // The mob is dead, but we're still animating the "puff" they leave when they die - m_DestroyTimer += a_Dt.count() / 1000; - if (m_DestroyTimer > 1) + m_DestroyTimer += a_Dt; + if (m_DestroyTimer > std::chrono::seconds(1)) { Destroy(true); } @@ -345,18 +345,18 @@ void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) case IDLE: { // If enemy passive we ignore checks for player visibility - InStateIdle(std::chrono::duration_cast(a_Dt).count()); + InStateIdle(a_Dt); break; } case CHASING: { // If we do not see a player anymore skip chasing action - InStateChasing(std::chrono::duration_cast(a_Dt).count()); + InStateChasing(a_Dt); break; } case ESCAPING: { - InStateEscaping(std::chrono::duration_cast(a_Dt).count()); + InStateEscaping(a_Dt); break; } @@ -555,7 +555,7 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI) { m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Reward); } - m_DestroyTimer = 0; + m_DestroyTimer = std::chrono::milliseconds(0); } @@ -638,7 +638,7 @@ void cMonster::EventLosePlayer(void) -void cMonster::InStateIdle(float a_Dt) +void cMonster::InStateIdle(std::chrono::milliseconds a_Dt) { if (m_bMovingToDestination) { @@ -647,11 +647,11 @@ void cMonster::InStateIdle(float a_Dt) m_IdleInterval += a_Dt; - if (m_IdleInterval > 1) + if (m_IdleInterval > std::chrono::seconds(1)) { // At this interval the results are predictable int rem = m_World->GetTickRandomNumber(6) + 1; - m_IdleInterval -= 1; // So nothing gets dropped when the server hangs for a few seconds + m_IdleInterval -= std::chrono::seconds(1); // So nothing gets dropped when the server hangs for a few seconds Vector3d Dist; Dist.x = (double)m_World->GetTickRandomNumber(10) - 5; @@ -678,7 +678,7 @@ void cMonster::InStateIdle(float a_Dt) // What to do if in Chasing State // This state should always be defined in each child class -void cMonster::InStateChasing(float a_Dt) +void cMonster::InStateChasing(std::chrono::milliseconds a_Dt) { UNUSED(a_Dt); } @@ -688,7 +688,7 @@ void cMonster::InStateChasing(float a_Dt) // What to do if in Escaping State -void cMonster::InStateEscaping(float a_Dt) +void cMonster::InStateEscaping(std::chrono::milliseconds a_Dt) { UNUSED(a_Dt); diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h index 5752a2040..21ed0c25a 100644 --- a/src/Mobs/Monster.h +++ b/src/Mobs/Monster.h @@ -80,9 +80,9 @@ public: virtual void EventLosePlayer(void); virtual void CheckEventLostPlayer(void); - virtual void InStateIdle (float a_Dt); - virtual void InStateChasing (float a_Dt); - virtual void InStateEscaping(float a_Dt); + virtual void InStateIdle (std::chrono::milliseconds a_Dt); + virtual void InStateChasing (std::chrono::milliseconds a_Dt); + virtual void InStateEscaping(std::chrono::milliseconds a_Dt); int GetAttackRate() { return static_cast(m_AttackRate); } void SetAttackRate(float a_AttackRate) { m_AttackRate = a_AttackRate; } @@ -217,8 +217,8 @@ protected: /* =========================== */ - float m_IdleInterval; - float m_DestroyTimer; + std::chrono::milliseconds m_IdleInterval; + std::chrono::milliseconds m_DestroyTimer; eMonsterType m_MobType; AString m_CustomName; -- cgit v1.2.3