1
0

Second round of fixes

* Implemented suggestions
This commit is contained in:
Tiger Wang 2013-10-09 21:02:59 +01:00
parent 7401fc000d
commit fe6fa23a97
17 changed files with 140 additions and 112 deletions

View File

@ -334,78 +334,13 @@ public:
// tolua_begin
// Metadata flags; descendants may override the defaults:
// COMMON metadata flags; descendants may override the defaults:
virtual bool IsOnFire (void) const {return (m_TicksLeftBurning > 0); }
virtual bool IsCrouched (void) const {return false; }
virtual bool IsRiding (void) const {return false; }
virtual bool IsSprinting(void) const {return false; }
virtual bool IsRclking (void) const {return false; }
virtual bool IsInvisible(void) const {return false; }
// Ageables + Tameables
virtual bool IsBaby (void) const {return false; }
virtual bool IsSitting (void) const {return false; }
virtual bool IsTame (void) const {return false; }
// Creepers
virtual bool IsCharged (void) const {return false; }
virtual bool IsBlowing (void) const {return false; }
// Furnace Minecarts & Minecarts
virtual int LastDamage (void) const {return 0; }
virtual bool IsFueled (void) const {return false; }
// Bat
virtual bool IsHanging (void) const {return false; }
// Pig
virtual bool IsSaddled (void) const {return false; }
// TESTIFICATE
virtual int GetVilType (void) const {return 0; }
// Zombie
virtual bool IsVillZomb (void) const {return false; }
virtual bool IsConvert (void) const {return false; }
// Ghast
virtual bool IsCharging (void) const {return false; }
// Arrow
virtual bool IsCritical (void) const {return false; }
// Wolf
virtual bool IsAngry (void) const {return false; }
virtual bool IsBegging (void) const {return false; }
virtual int GetCollar (void) const {return 0; }
// Sheep
virtual int GetFurColor (void) const {return 0; }
virtual bool IsSheared (void) const {return false; }
// Enderman
virtual BLOCKTYPE CarriedBlock (void) const {return E_BLOCK_AIR; }
virtual NIBBLETYPE CarriedMeta (void) const {return 0; }
virtual bool IsScream (void) const {return false; }
// Skeleton || Wither Skeleton
virtual bool IsWither (void) const {return false; }
// Witch
virtual bool IsNosey (void) const {return false; }
// Slimes and Magma cubes
virtual int GetSize (void) const {return 1; }
// Horsheys
virtual bool IsChested (void) const {return false; }
virtual bool IsEating (void) const {return false; }
virtual bool IsRearing (void) const {return false; }
virtual bool IsMthOpen (void) const {return false; }
virtual int GetHType (void) const {return 0; }
virtual int GetHColor (void) const {return 0; }
virtual int GetHStyle (void) const {return 0; }
virtual int GetHArmour (void) const {return 0; }
// tolua_end

View File

@ -374,12 +374,12 @@ void cMinecart::DoTakeDamage(TakeDamageInfo & TDI)
}
case mpTNT:
{
Drops.push_back(cItem(0, 1, 0));
Drops.push_back(cItem(E_ITEM_MINECART_WITH_TNT, 1, 0));
break;
}
case mpHopper:
{
Drops.push_back(cItem(0, 1, 0));
Drops.push_back(cItem(E_ITEM_MINECART_WITH_HOPPER, 1, 0));
break;
}
default:

View File

@ -51,8 +51,8 @@ public:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override;
virtual void DoTakeDamage(TakeDamageInfo & TDI) override;
int LastDamage(void) const { return m_LastDamage; }
int LastDamage(void) const { return m_LastDamage; }
void HandleRailPhysics(float a_Dt, cChunk & a_Chunk);
ePayload GetPayload(void) const { return m_Payload; }

View File

@ -20,6 +20,8 @@ public:
}
CLASS_PROTODEF(cBat);
bool IsHanging(void) const {return false; }
} ;

View File

@ -2,13 +2,16 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Creeper.h"
#include "../World.h"
cCreeper::cCreeper(void) :
super("Creeper", 50, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8)
super("Creeper", 50, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8),
m_bIsBlowing(false),
m_bIsCharged(false)
{
}
@ -26,3 +29,19 @@ void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI)
{
super::DoTakeDamage(a_TDI);
if (a_TDI.DamageType == dtLightning)
{
m_bIsCharged = true;
}
m_World->BroadcastEntityMetadata(*this);
}

View File

@ -18,6 +18,15 @@ public:
CLASS_PROTODEF(cCreeper);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
bool IsBlowing(void) const {return m_bIsBlowing; }
bool IsCharged(void) const {return m_bIsCharged; }
private:
bool m_bIsBlowing, m_bIsCharged;
} ;

View File

@ -9,7 +9,10 @@
cEnderman::cEnderman(void) :
// TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
super("Enderman", 58, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.5)
super("Enderman", 58, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.5),
m_bIsScreaming(false),
CarriedBlock(E_BLOCK_AIR),
CarriedMeta(0)
{
}

View File

@ -18,6 +18,17 @@ public:
CLASS_PROTODEF(cEnderman);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
bool IsScreaming(void) const {return m_bIsScreaming; }
BLOCKTYPE GetCarriedBlock(void) const {return CarriedBlock; }
NIBBLETYPE GetCarriedMeta(void) const {return CarriedMeta; }
private:
bool m_bIsScreaming;
BLOCKTYPE CarriedBlock;
NIBBLETYPE CarriedMeta;
} ;

View File

@ -18,6 +18,8 @@ public:
CLASS_PROTODEF(cGhast);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
bool IsCharging(void) const {return false; }
} ;

View File

@ -16,6 +16,7 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
m_bIsRearing(false),
m_bIsMouthOpen(false),
m_bIsTame(false),
m_bIsSaddled(false),
m_Type(Type),
m_Color(Color),
m_Style(Style),

View File

@ -20,6 +20,8 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
bool IsSaddled (void) const {return m_bIsSaddled; }
bool IsChested (void) const {return m_bHasChest; }
bool IsEating (void) const {return m_bIsEating; }
bool IsRearing (void) const {return m_bIsRearing; }
@ -32,7 +34,7 @@ public:
private:
bool m_bHasChest, m_bIsEating, m_bIsRearing, m_bIsMouthOpen, m_bIsTame;
bool m_bHasChest, m_bIsEating, m_bIsRearing, m_bIsMouthOpen, m_bIsTame, m_bIsSaddled;
int m_Type, m_Color, m_Style, m_Armour, m_TimesToTame, m_TameAttemptTimes;
} ;

View File

@ -113,6 +113,11 @@ public:
/// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick
void SetBurnsInDaylight(bool a_BurnsInDaylight) { m_BurnsInDaylight = a_BurnsInDaylight; }
// Overridables to handle ageable mobs
virtual bool IsBaby (void) const { return false; }
virtual bool IsTame (void) const { return false; }
virtual bool IsSitting (void) const { return false; }
enum MState{ATTACKING, IDLE, CHASING, ESCAPING} m_EMState;
enum MPersonality{PASSIVE,AGGRESSIVE,COWARDLY} m_EMPersonality;
@ -147,6 +152,7 @@ protected:
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
void HandleDaylightBurning(cChunk & a_Chunk);
} ; // tolua_export

View File

@ -18,6 +18,8 @@ public:
CLASS_PROTODEF(cWitch);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
bool IsAngry(void) const {return ((m_EMState == ATTACKING) || (m_EMState == CHASING)); }
} ;

View File

@ -8,8 +8,10 @@
cZombie::cZombie(void) :
super("Zombie", 54, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8)
cZombie::cZombie(bool IsVillagerZombie) :
super("Zombie", 54, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8),
m_bIsConverting(false),
m_bIsVillagerZombie(IsVillagerZombie)
{
SetBurnsInDaylight(true);
}

View File

@ -12,11 +12,19 @@ class cZombie :
typedef cAggressiveMonster super;
public:
cZombie(void);
cZombie(bool IsVillagerZombie);
CLASS_PROTODEF(cZombie);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
bool IsVillagerZombie(void) const {return m_bIsVillagerZombie; }
bool IsConverting(void) const {return m_bIsConverting; }
private:
bool m_bIsVillagerZombie, m_bIsConverting;
} ;

View File

@ -24,8 +24,27 @@ Documentation:
#include "../UI/Window.h"
#include "../Root.h"
#include "../Server.h"
#include "../Entities/ProjectileEntity.h"
#include "../Entities/Minecart.h"
#include "../Entities/FallingBlock.h"
#include "../Mobs/Monster.h"
#include "../Mobs/Creeper.h"
#include "../Mobs/Bat.h"
#include "../Mobs/Pig.h"
#include "../Mobs/Villager.h"
#include "../Mobs/Zombie.h"
#include "../Mobs/Ghast.h"
#include "../Mobs/Wolf.h"
#include "../Mobs/Sheep.h"
#include "../Mobs/Enderman.h"
#include "../Mobs/Skeleton.h"
#include "../Mobs/Witch.h"
#include "../Mobs/Slime.h"
#include "../Mobs/Magmacube.h"
#include "../Mobs/Horse.h"
@ -1655,70 +1674,70 @@ void cProtocol125::WriteMetadata(const cEntity & a_Entity)
{
WriteByte(0x51);
// No idea how Mojang makes their carts shakey shakey, so here is a complicated one-liner expression that does something similar
WriteInt( (((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * a_Entity.LastDamage()) * 4 );
WriteInt( (((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((cMinecart &)a_Entity).LastDamage()) * 4 );
WriteByte(0x52);
WriteInt(1); // Shaking direction, doesn't seem to affect anything
WriteByte(0x73);
WriteFloat((float)(a_Entity.LastDamage() + 10)); // Damage taken / shake effect multiplyer
WriteFloat((float)(((cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer
}
else if (a_Entity.IsA("cCreeper"))
{
WriteByte(0x10);
WriteByte(a_Entity.IsBlowing() ? 1 : -1); // Blowing up?
WriteByte(((cCreeper &)a_Entity).IsBlowing() ? 1 : -1); // Blowing up?
WriteByte(0x11);
WriteByte(a_Entity.IsCharged() ? 1 : 0); // Lightning-charged?
WriteByte(((cCreeper &)a_Entity).IsCharged() ? 1 : 0); // Lightning-charged?
}
else if (a_Entity.IsA("cMinecartWithFurnace"))
{
WriteByte(0x10);
WriteByte(a_Entity.IsFueled() ? 1 : 0); // Fueled?
WriteByte(((const cMinecartWithFurnace &)a_Entity).IsFueled() ? 1 : 0); // Fueled?
}
else if (a_Entity.IsA("cBat"))
{
WriteByte(0x10);
WriteByte(a_Entity.IsHanging() ? 1 : 0); // Upside down?
WriteByte(((const cBat &)a_Entity).IsHanging() ? 1 : 0); // Upside down?
}
else if (a_Entity.IsA("cPig"))
{
WriteByte(0x10);
WriteByte(a_Entity.IsSaddled() ? 1 : 0); // Saddled?
WriteByte(((const cPig &)a_Entity).IsSaddled() ? 1 : 0); // Saddled?
}
else if (a_Entity.IsA("cVillager"))
{
WriteByte(0x50);
WriteInt(a_Entity.GetVilType()); // What sort of TESTIFICATE?
WriteInt(((const cVillager &)a_Entity).GetVilType()); // What sort of TESTIFICATE?
}
else if (a_Entity.IsA("cZombie"))
{
WriteByte(0xC);
WriteByte(a_Entity.IsBaby() ? 1 : 0); // Babby zombie?
WriteByte(((const cZombie &)a_Entity).IsBaby() ? 1 : 0); // Babby zombie?
WriteByte(0xD);
WriteByte(a_Entity.IsVillZomb() ? 1 : 0); // Converted zombie?
WriteByte(((const cZombie &)a_Entity).IsVillagerZombie() ? 1 : 0); // Converted zombie?
WriteByte(0xE);
WriteByte(a_Entity.IsConvert() ? 1 : 0); // Converted-but-converting-back zombllager?
WriteByte(((const cZombie &)a_Entity).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager?
}
else if (a_Entity.IsA("cGhast"))
{
WriteByte(0x10);
WriteByte(a_Entity.IsCharging()); // About to eject un flamé-bol? :P
WriteByte(((const cGhast &)a_Entity).IsCharging()); // About to eject un flamé-bol? :P
}
else if (a_Entity.IsA("cArrowEntity"))
{
WriteByte(0x10);
WriteByte(a_Entity.IsCritical() ? 1 : 0); // Critical hitting arrow?
WriteByte(((const cArrowEntity &)a_Entity).IsCritical() ? 1 : 0); // Critical hitting arrow?
}
else if (a_Entity.IsA("cWolf"))
{
Byte WolfStatus = 0;
if (a_Entity.IsSitting())
if (((const cWolf &)a_Entity).IsSitting())
{
WolfStatus |= 0x1;
}
if (a_Entity.IsAngry())
if (((const cWolf &)a_Entity).IsAngry())
{
WolfStatus |= 0x2;
}
if (a_Entity.IsTame())
if (((const cWolf &)a_Entity).IsTame())
{
WolfStatus |= 0x4;
}
@ -1728,7 +1747,7 @@ void cProtocol125::WriteMetadata(const cEntity & a_Entity)
WriteByte(0x72);
WriteFloat((float)(a_Entity.GetHealth())); // Tail health-o-meter (only shown when tamed, by the way)
WriteByte(0x13);
WriteByte(a_Entity.IsBegging() ? 1 : 0); // Ultra cute mode?
WriteByte(((const cWolf &)a_Entity).IsBegging() ? 1 : 0); // Ultra cute mode?
}
else if (a_Entity.IsA("cSheep"))
{
@ -1737,9 +1756,9 @@ void cProtocol125::WriteMetadata(const cEntity & a_Entity)
WriteByte(0x10);
Byte SheepMetadata = 0;
SheepMetadata = a_Entity.GetFurColor(); // Fur colour
SheepMetadata = ((const cSheep &)a_Entity).GetFurColor(); // Fur colour
if (a_Entity.IsSheared()) // Is sheared?
if (((const cSheep &)a_Entity).IsSheared()) // Is sheared?
{
SheepMetadata |= 0x16;
}
@ -1748,55 +1767,62 @@ void cProtocol125::WriteMetadata(const cEntity & a_Entity)
else if (a_Entity.IsA("cEnderman"))
{
WriteByte(0x10);
WriteByte(a_Entity.CarriedBlock()); // Stolen block
WriteByte((Byte)(((cEnderman &)a_Entity).GetCarriedBlock())); // Block that he stole from your house
WriteByte(0x11);
WriteByte(a_Entity.CarriedMeta()); // Stolen metea
WriteByte((Byte)(((cEnderman &)a_Entity).GetCarriedMeta())); // Meta of block that he stole from your house
WriteByte(0x12);
WriteByte(a_Entity.IsScream() ? 1 : 0); // I HATE YER FACE, I SCWEAM AT YER FACE
WriteByte(((cEnderman &)a_Entity).IsScreaming() ? 1 : 0); // Screaming at your face?
}
else if (a_Entity.IsA("cSkeleton"))
{
WriteByte(0xD);
WriteByte(a_Entity.IsWither() ? 1 : 0); // It's a skeleton, but it's not
WriteByte(((const cSkeleton &)a_Entity).IsWither() ? 1 : 0); // It's a skeleton, but it's not
}
else if (a_Entity.IsA("cWitch"))
{
WriteByte(0x15);
WriteByte(a_Entity.IsNosey() ? 1 : 0); // Drinking-nose: like Squidward
WriteByte(((cWitch &)a_Entity).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything
}
else if ((a_Entity.IsA("cSlime")) || (a_Entity.IsA("cMagmaCube")))
{
WriteByte(0x10);
WriteByte(a_Entity.GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
if (a_Entity.IsA("cSlime"))
{
WriteByte(((const cSlime &)a_Entity).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
}
else
{
WriteByte(((const cMagmaCube &)a_Entity).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
}
}
else if (a_Entity.IsA("cHorse"))
{
int Flags = 0;
if (a_Entity.IsTame())
if (((const cHorse &)a_Entity).IsTame())
{
Flags |= 0x2;
}
if (a_Entity.IsSaddled())
if (((const cHorse &)a_Entity).IsSaddled())
{
Flags |= 0x4;
}
if (a_Entity.IsChested())
if (((const cHorse &)a_Entity).IsChested())
{
Flags |= 0x8;
}
if (a_Entity.IsBaby())
if (((const cHorse &)a_Entity).IsBaby())
{
Flags |= 0x10; // IsBred flag, according to wiki.vg - don't think it does anything in multiplayer
}
if (a_Entity.IsEating())
if (((const cHorse &)a_Entity).IsEating())
{
Flags |= 0x20;
}
if (a_Entity.IsRearing())
if (((const cHorse &)a_Entity).IsRearing())
{
Flags |= 0x40;
}
if (a_Entity.IsMthOpen())
if (((const cHorse &)a_Entity).IsMthOpen())
{
Flags |= 0x80;
}
@ -1804,16 +1830,16 @@ void cProtocol125::WriteMetadata(const cEntity & a_Entity)
WriteInt(Flags);
WriteByte(0x13);
WriteByte(a_Entity.GetHType()); // Type of horse (donkey, chestnut, etc.)
WriteByte(((const cHorse &)a_Entity).GetHType()); // Type of horse (donkey, chestnut, etc.)
WriteByte(0x54);
int Appearance = 0;
Appearance = a_Entity.GetHColor(); // Mask FF
Appearance |= a_Entity.GetHStyle() * 256; // Mask FF00, so multiply by 256
Appearance = ((const cHorse &)a_Entity).GetHColor(); // Mask FF
Appearance |= ((const cHorse &)a_Entity).GetHStyle() * 256; // Mask FF00, so multiply by 256
WriteInt(Appearance);
WriteByte(0x56);
WriteInt(a_Entity.GetHArmour()); // Horshey armour
WriteInt(((const cHorse &)a_Entity).GetHArmour()); // Horshey armour
}
// End Specific Metadata

View File

@ -2616,7 +2616,7 @@ int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eTyp
case cMonster::mtWitch: Monster = new cWitch(); break;
case cMonster::mtWither: Monster = new cWither(); break;
case cMonster::mtWolf: Monster = new cWolf(); break;
case cMonster::mtZombie: Monster = new cZombie(); break;
case cMonster::mtZombie: Monster = new cZombie(false); break; // TODO: Villager infection
case cMonster::mtZombiePigman: Monster = new cZombiePigman(); break;
default: