Fixed Formatting, Added DropChances and CanPickUpLoot attributes to Monsters
This commit is contained in:
parent
7a7b9e88b2
commit
2f59517023
@ -392,38 +392,6 @@ enum ENUM_ITEM_ID
|
||||
|
||||
|
||||
|
||||
// ENCHANTMENT IDS
|
||||
enum
|
||||
{
|
||||
E_ENCHANTMENT_PROTECTION = 0,
|
||||
E_ENCHANTMENT_FIRE_PROTECTION = 1,
|
||||
E_ENCHANTMENT_FEATHER_FALLING = 2,
|
||||
E_ENCHANTMENT_BLAST_PROTECTION = 3,
|
||||
E_ENCHANTMENT_PROJECTILE_PROTECTION= 4,
|
||||
E_ENCHANTMENT_RESPIRATION = 5,
|
||||
E_ENCHANTMENT_AQUA_AFFINITY = 6,
|
||||
E_ENCHANTMENT_THORNS = 7,
|
||||
E_ENCHANTMENT_SHARPNESS = 16,
|
||||
E_ENCHANTMENT_SMITE = 17,
|
||||
E_ENCHANTMENT_BANE_OF_ARTHROPODS = 18,
|
||||
E_ENCHANTMENT_KNOCKBACK = 19,
|
||||
E_ENCHANTMENT_FIREASPECT = 20,
|
||||
E_ENCHANTMENT_LOOTING = 21,
|
||||
E_ENCHANTMENT_EFFICIENCY = 32,
|
||||
E_ENCHANTMENT_SILKTOUCH = 33,
|
||||
E_ENCHANTMENT_UNBREAKING = 34,
|
||||
E_ENCHANTMENT_FORTUNE = 35,
|
||||
E_ENCHANTMENT_POWER = 48,
|
||||
E_ENCHANTMENT_PUNCH = 49,
|
||||
E_ENCHANTMENT_FLAME = 50,
|
||||
E_ENCHANTMENT_INFINITY = 51,
|
||||
E_ENCHANTMENT_LUCKOFTHESEA = 61,
|
||||
E_ENCHANTMENT_LURE = 62,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -21,7 +21,6 @@ class cParsedNBT;
|
||||
|
||||
|
||||
|
||||
|
||||
/** Class that stores item enchantments or stored-enchantments
|
||||
The enchantments may be serialized to a stringspec and read back from such stringspec.
|
||||
The format for the stringspec is "id=lvl;id=lvl;id=lvl...", with an optional semicolon at the end,
|
||||
|
@ -19,9 +19,9 @@ cBlaze::cBlaze(void) :
|
||||
|
||||
void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
if (a_Killer->IsA("cPlayer") || a_Killer->IsA("cWolf"))
|
||||
if ((a_Killer != NULL) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_BLAZE_ROD);
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,13 @@ void cCavespider::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
void cCavespider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STRING);
|
||||
if (a_Killer->IsA("cPlayer") || a_Killer->IsA("cWolf"))
|
||||
if ((a_Killer != NULL) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
|
||||
{
|
||||
AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_SPIDER_EYE);
|
||||
}
|
||||
|
@ -48,7 +48,11 @@ void cChicken::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
void cChicken::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_FEATHER);
|
||||
AddRandomDropItem(a_Drops, 1, 1, IsOnFire() ? E_ITEM_COOKED_CHICKEN : E_ITEM_RAW_CHICKEN);
|
||||
}
|
||||
|
@ -21,7 +21,11 @@ cCow::cCow(void) :
|
||||
|
||||
void cCow::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_LEATHER);
|
||||
AddRandomDropItem(a_Drops, 1, 3 + LootingLevel, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
|
||||
}
|
||||
|
@ -39,7 +39,11 @@ void cCreeper::Tick(float a_Dt, cChunk & a_Chunk)
|
||||
|
||||
void cCreeper::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER);
|
||||
|
||||
if ((a_Killer != NULL) && (a_Killer->IsProjectile()))
|
||||
|
@ -21,7 +21,11 @@ cEnderman::cEnderman(void) :
|
||||
|
||||
void cEnderman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_ENDER_PEARL);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,11 @@ cGhast::cGhast(void) :
|
||||
|
||||
void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER);
|
||||
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_GHAST_TEAR);
|
||||
}
|
||||
|
@ -140,7 +140,11 @@ void cHorse::OnRightClicked(cPlayer & a_Player)
|
||||
|
||||
void cHorse::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_LEATHER);
|
||||
if (m_bIsSaddled)
|
||||
{
|
||||
|
@ -81,6 +81,12 @@ cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString
|
||||
, m_AttackDamage(1)
|
||||
, m_AttackRange(2)
|
||||
, m_AttackInterval(0)
|
||||
, m_DropChanceWeapon(0.085)
|
||||
, m_DropChanceHelmet(0.085)
|
||||
, m_DropChanceChestplate(0.085)
|
||||
, m_DropChanceLeggings(0.085)
|
||||
, m_DropChanceBoots(0.085)
|
||||
, m_CanPickUpLoot(true)
|
||||
, m_SightDistance(25)
|
||||
, m_BurnsInDaylight(false)
|
||||
{
|
||||
@ -884,7 +890,7 @@ void cMonster::AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short
|
||||
{
|
||||
MTRand r1;
|
||||
int Count = r1.randInt() % 1000;
|
||||
if (Count < (a_Chance*10))
|
||||
if (Count < (a_Chance * 10))
|
||||
{
|
||||
a_Drops.push_back(cItem(a_Item, 1, a_ItemHealth));
|
||||
}
|
||||
@ -909,6 +915,47 @@ void cMonster::AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a
|
||||
|
||||
|
||||
|
||||
void cMonster::AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel)
|
||||
{
|
||||
MTRand r1;
|
||||
if (r1.randInt() % 200 < ((m_DropChanceHelmet * 200) + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedHelmet().IsEmpty()) a_Drops.push_back(GetEquippedHelmet());
|
||||
}
|
||||
|
||||
if (r1.randInt() % 200 < ((m_DropChanceChestplate * 200) + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedChestplate().IsEmpty()) a_Drops.push_back(GetEquippedChestplate());
|
||||
}
|
||||
|
||||
if (r1.randInt() % 200 < ((m_DropChanceLeggings * 200) + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedLeggings().IsEmpty()) a_Drops.push_back(GetEquippedLeggings());
|
||||
}
|
||||
|
||||
if (r1.randInt() % 200 < ((m_DropChanceBoots * 200) + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedBoots().IsEmpty()) a_Drops.push_back(GetEquippedBoots());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cMonster::AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel)
|
||||
{
|
||||
MTRand r1;
|
||||
if (r1.randInt() % 200 < ((m_DropChanceWeapon * 200) + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedWeapon().IsEmpty()) a_Drops.push_back(GetEquippedWeapon());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cMonster::HandleDaylightBurning(cChunk & a_Chunk)
|
||||
{
|
||||
if (!m_BurnsInDaylight)
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "../Defines.h"
|
||||
#include "../BlockID.h"
|
||||
#include "../Item.h"
|
||||
#include "../Enchantments.h"
|
||||
|
||||
|
||||
|
||||
@ -118,6 +119,19 @@ public:
|
||||
void SetAttackDamage(int a_AttackDamage) { m_AttackDamage = a_AttackDamage; }
|
||||
void SetSightDistance(int a_SightDistance) { m_SightDistance = a_SightDistance; }
|
||||
|
||||
float GetDropChanceWeapon() { return m_DropChanceWeapon; }
|
||||
float GetDropChanceHelmet() { return m_DropChanceHelmet; }
|
||||
float GetDropChanceChestplate() { return m_DropChanceChestplate; }
|
||||
float GetDropChanceLeggings() { return m_DropChanceLeggings; }
|
||||
float GetDropChanceBoots() { return m_DropChanceBoots; }
|
||||
bool CanPickUpLoot() { return m_CanPickUpLoot; }
|
||||
void SetDropChanceWeapon(float a_DropChanceWeapon) { m_DropChanceWeapon = a_DropChanceWeapon; }
|
||||
void SetDropChanceHelmet(float a_DropChanceHelmet) { m_DropChanceHelmet = a_DropChanceHelmet; }
|
||||
void SetDropChanceChestplate(float a_DropChanceChestplate) { m_DropChanceChestplate = a_DropChanceChestplate; }
|
||||
void SetDropChanceLeggings(float a_DropChanceLeggings) { m_DropChanceLeggings = a_DropChanceLeggings; }
|
||||
void SetDropChanceBoots(float a_DropChanceBoots) { m_DropChanceBoots = a_DropChanceBoots; }
|
||||
void SetCanPickUpLoot(bool a_CanPickUpLoot) { m_CanPickUpLoot = a_CanPickUpLoot; }
|
||||
|
||||
/// Sets whether the mob burns in daylight. Only evaluated at next burn-decision tick
|
||||
void SetBurnsInDaylight(bool a_BurnsInDaylight) { m_BurnsInDaylight = a_BurnsInDaylight; }
|
||||
|
||||
@ -220,13 +234,31 @@ protected:
|
||||
float m_AttackInterval;
|
||||
int m_SightDistance;
|
||||
|
||||
float m_DropChanceWeapon;
|
||||
float m_DropChanceHelmet;
|
||||
float m_DropChanceChestplate;
|
||||
float m_DropChanceLeggings;
|
||||
float m_DropChanceBoots;
|
||||
bool m_CanPickUpLoot;
|
||||
|
||||
void HandleDaylightBurning(cChunk & a_Chunk);
|
||||
bool m_BurnsInDaylight;
|
||||
|
||||
/** Adds a random number of a_Item between a_Min and a_Max to itemdrops a_Drops*/
|
||||
void AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth = 0);
|
||||
|
||||
/** Adds a item a_Item with the chance of a_Chance (in percent) to itemdrops a_Drops*/
|
||||
void AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth = 0);
|
||||
|
||||
/** Adds one rare item out of the list of rare items a_Items modified by the looting level a_LootingLevel(I-III or custom) to the itemdrop a_Drops*/
|
||||
void AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel);
|
||||
|
||||
/** Adds armor that is equipped with the chance of 8,5% (Looting 3: 11,5%) to the drop*/
|
||||
void AddRandomArmorDropItem(cItems & a_Drops, short a_LootingLevel);
|
||||
|
||||
/** Adds weapon that is equipped with the chance of 8,5% (Looting 3: 11,5%) to the drop*/
|
||||
void AddRandomWeaponDropItem(cItems & a_Drops, short a_LootingLevel);
|
||||
|
||||
|
||||
} ; // tolua_export
|
||||
|
||||
|
@ -2,11 +2,12 @@
|
||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||
|
||||
#include "Mooshroom.h"
|
||||
#include "../Entities/Player.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO: Milk Cow
|
||||
|
||||
|
||||
|
||||
@ -23,10 +24,50 @@ cMooshroom::cMooshroom(void) :
|
||||
|
||||
void cMooshroom::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_LEATHER);
|
||||
AddRandomDropItem(a_Drops, 1, 3 + LootingLevel, IsOnFire() ? E_ITEM_STEAK : E_ITEM_RAW_BEEF);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cMooshroom::OnRightClicked(cPlayer & a_Player)
|
||||
{
|
||||
switch (a_Player.GetEquippedItem().m_ItemType)
|
||||
{
|
||||
case E_ITEM_BUCKET:
|
||||
{
|
||||
if (!a_Player.IsGameModeCreative())
|
||||
{
|
||||
a_Player.GetInventory().RemoveOneEquippedItem();
|
||||
a_Player.GetInventory().AddItem(E_ITEM_MILK);
|
||||
}
|
||||
} break;
|
||||
case E_ITEM_BOWL:
|
||||
{
|
||||
if (!a_Player.IsGameModeCreative())
|
||||
{
|
||||
a_Player.GetInventory().RemoveOneEquippedItem();
|
||||
a_Player.GetInventory().AddItem(E_ITEM_MUSHROOM_SOUP);
|
||||
}
|
||||
} break;
|
||||
case E_ITEM_SHEARS:
|
||||
{
|
||||
if (!a_Player.IsGameModeCreative())
|
||||
{
|
||||
a_Player.UseEquippedItem();
|
||||
}
|
||||
|
||||
cItems Drops;
|
||||
Drops.push_back(cItem(E_BLOCK_RED_MUSHROOM, 5, 0));
|
||||
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ public:
|
||||
CLASS_PROTODEF(cMooshroom);
|
||||
|
||||
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
|
||||
virtual void OnRightClicked(cPlayer & a_Player) override;
|
||||
|
||||
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }
|
||||
} ;
|
||||
|
@ -21,7 +21,11 @@ cPig::cPig(void) :
|
||||
|
||||
void cPig::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 1, 3 + LootingLevel, IsOnFire() ? E_ITEM_COOKED_PORKCHOP : E_ITEM_RAW_PORKCHOP);
|
||||
if (m_bIsSaddled)
|
||||
{
|
||||
|
@ -20,28 +20,26 @@ cSkeleton::cSkeleton(bool IsWither) :
|
||||
|
||||
void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
if (IsWither())
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_BONE);
|
||||
AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_COAL);
|
||||
cItems RareDrops;
|
||||
RareDrops.Add(cItem(E_ITEM_HEAD, 1, 1));
|
||||
if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
|
||||
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_ARROW);
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_BONE);
|
||||
cItems RareDrops;
|
||||
if (!GetEquippedHelmet().IsEmpty()) RareDrops.Add(GetEquippedHelmet());
|
||||
if (!GetEquippedChestplate().IsEmpty()) RareDrops.Add(GetEquippedChestplate());
|
||||
if (!GetEquippedLeggings().IsEmpty()) RareDrops.Add(GetEquippedLeggings());
|
||||
if (!GetEquippedBoots().IsEmpty()) RareDrops.Add(GetEquippedBoots());
|
||||
if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
|
||||
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
|
||||
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_BONE);
|
||||
AddRandomArmorDropItem(a_Drops, LootingLevel);
|
||||
AddRandomWeaponDropItem(a_Drops, LootingLevel);
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,7 +20,11 @@ cSlime::cSlime(int a_Size) :
|
||||
|
||||
void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
if (GetSize() == 1)
|
||||
{
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SLIMEBALL);
|
||||
|
@ -18,9 +18,13 @@ cSpider::cSpider(void) :
|
||||
|
||||
void cSpider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STRING);
|
||||
if (a_Killer->IsA("cPlayer") || a_Killer->IsA("cWolf"))
|
||||
if ((a_Killer != NULL) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
|
||||
{
|
||||
AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_SPIDER_EYE);
|
||||
}
|
||||
|
@ -21,7 +21,11 @@ cSquid::cSquid(void) :
|
||||
void cSquid::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
// Drops 0-3 Ink Sacs
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 3 + LootingLevel, E_ITEM_DYE, E_META_DYE_BLACK);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,11 @@ cWitch::cWitch(void) :
|
||||
|
||||
void cWitch::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
MTRand r1;
|
||||
int DropTypeCount = (r1.randInt() % 3) + 1;
|
||||
for (int i = 0; i < DropTypeCount; i++)
|
||||
@ -26,18 +30,16 @@ void cWitch::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
int DropType = r1.randInt() % 7;
|
||||
switch (DropType)
|
||||
{
|
||||
case 0: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GLASS_BOTTLE);
|
||||
case 1: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GLOWSTONE_DUST);
|
||||
case 2: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER);
|
||||
case 3: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_REDSTONE_DUST);
|
||||
case 4: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SPIDER_EYE);
|
||||
case 5: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STICK);
|
||||
case 6: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SUGAR);
|
||||
case 0: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GLASS_BOTTLE); break;
|
||||
case 1: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GLOWSTONE_DUST); break;
|
||||
case 2: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_GUNPOWDER); break;
|
||||
case 3: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_REDSTONE_DUST); break;
|
||||
case 4: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SPIDER_EYE); break;
|
||||
case 5: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STICK); break;
|
||||
case 6: AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_SUGAR); break;
|
||||
}
|
||||
}
|
||||
cItems RareDrops;
|
||||
if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
|
||||
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
|
||||
AddRandomWeaponDropItem(a_Drops, LootingLevel);
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,18 +23,19 @@ cZombie::cZombie(bool a_IsVillagerZombie) :
|
||||
|
||||
void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_ROTTEN_FLESH);
|
||||
cItems RareDrops;
|
||||
RareDrops.Add(cItem(E_ITEM_IRON));
|
||||
RareDrops.Add(cItem(E_ITEM_CARROT));
|
||||
RareDrops.Add(cItem(E_ITEM_POTATO));
|
||||
if (!GetEquippedHelmet().IsEmpty()) RareDrops.Add(GetEquippedHelmet());
|
||||
if (!GetEquippedChestplate().IsEmpty()) RareDrops.Add(GetEquippedChestplate());
|
||||
if (!GetEquippedLeggings().IsEmpty()) RareDrops.Add(GetEquippedLeggings());
|
||||
if (!GetEquippedBoots().IsEmpty()) RareDrops.Add(GetEquippedBoots());
|
||||
if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
|
||||
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
|
||||
AddRandomArmorDropItem(a_Drops, LootingLevel);
|
||||
AddRandomWeaponDropItem(a_Drops, LootingLevel);
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,14 +19,19 @@ cZombiePigman::cZombiePigman(void) :
|
||||
|
||||
void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
int LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
int LootingLevel = 0;
|
||||
if (a_Killer != NULL)
|
||||
{
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchLooting);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_ROTTEN_FLESH);
|
||||
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_GOLD_NUGGET);
|
||||
|
||||
cItems RareDrops;
|
||||
RareDrops.Add(cItem(E_ITEM_GOLD));
|
||||
if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
|
||||
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
|
||||
AddRandomArmorDropItem(a_Drops, LootingLevel);
|
||||
AddRandomWeaponDropItem(a_Drops, LootingLevel);
|
||||
}
|
||||
|
||||
|
||||
|
@ -409,6 +409,14 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
|
||||
|
||||
m_Writer.BeginCompound("");
|
||||
AddBasicEntity(a_Monster, EntityClass);
|
||||
m_Writer.BeginList("DropChances", TAG_Float);
|
||||
m_Writer.AddFloat("", a_Monster->GetDropChanceWeapon());
|
||||
m_Writer.AddFloat("", a_Monster->GetDropChanceHelmet());
|
||||
m_Writer.AddFloat("", a_Monster->GetDropChanceChestplate());
|
||||
m_Writer.AddFloat("", a_Monster->GetDropChanceLeggings());
|
||||
m_Writer.AddFloat("", a_Monster->GetDropChanceBoots());
|
||||
m_Writer.EndList();
|
||||
m_Writer.AddByte("CanPickUpLoot", (char)a_Monster->CanPickUpLoot());
|
||||
switch (a_Monster->GetMobType())
|
||||
{
|
||||
case cMonster::mtBat:
|
||||
|
@ -1485,6 +1485,11 @@ void cWSSAnvil::LoadBatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1500,6 +1505,11 @@ void cWSSAnvil::LoadBlazeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1515,6 +1525,11 @@ void cWSSAnvil::LoadCaveSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1530,6 +1545,11 @@ void cWSSAnvil::LoadChickenFromNBT(cEntityList & a_Entities, const cParsedNBT &
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1545,6 +1565,11 @@ void cWSSAnvil::LoadCowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1560,6 +1585,11 @@ void cWSSAnvil::LoadCreeperFromNBT(cEntityList & a_Entities, const cParsedNBT &
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1575,6 +1605,11 @@ void cWSSAnvil::LoadEnderDragonFromNBT(cEntityList & a_Entities, const cParsedNB
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1591,6 +1626,11 @@ void cWSSAnvil::LoadEndermanFromNBT(cEntityList & a_Entities, const cParsedNBT &
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
|
||||
@ -1606,6 +1646,11 @@ void cWSSAnvil::LoadGhastFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
|
||||
@ -1620,6 +1665,11 @@ void cWSSAnvil::LoadGiantFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1646,6 +1696,11 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1661,6 +1716,11 @@ void cWSSAnvil::LoadIronGolemFromNBT(cEntityList & a_Entities, const cParsedNBT
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1682,6 +1742,11 @@ void cWSSAnvil::LoadMagmaCubeFromNBT(cEntityList & a_Entities, const cParsedNBT
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1697,6 +1762,11 @@ void cWSSAnvil::LoadMooshroomFromNBT(cEntityList & a_Entities, const cParsedNBT
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1712,6 +1782,11 @@ void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1727,6 +1802,11 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1748,6 +1828,11 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1763,6 +1848,11 @@ void cWSSAnvil::LoadSilverfishFromNBT(cEntityList & a_Entities, const cParsedNBT
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1784,6 +1874,11 @@ void cWSSAnvil::LoadSkeletonFromNBT(cEntityList & a_Entities, const cParsedNBT &
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1805,6 +1900,11 @@ void cWSSAnvil::LoadSlimeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1820,6 +1920,11 @@ void cWSSAnvil::LoadSnowGolemFromNBT(cEntityList & a_Entities, const cParsedNBT
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1835,6 +1940,11 @@ void cWSSAnvil::LoadSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT & a
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1850,6 +1960,11 @@ void cWSSAnvil::LoadSquidFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1871,6 +1986,11 @@ void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT &
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1886,6 +2006,11 @@ void cWSSAnvil::LoadWitchFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1901,6 +2026,11 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1916,6 +2046,10 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int OwnerIdx = a_NBT.FindChildByName(a_TagIdx, "Owner");
|
||||
if (OwnerIdx > 0)
|
||||
{
|
||||
@ -1964,6 +2098,11 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
@ -1980,6 +2119,11 @@ void cWSSAnvil::LoadPigZombieFromNBT(cEntityList & a_Entities, const cParsedNBT
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_Entities.push_back(Monster.release());
|
||||
}
|
||||
|
||||
@ -2023,6 +2167,27 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N
|
||||
|
||||
|
||||
|
||||
bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT & a_NBT, int a_TagIdx)
|
||||
{
|
||||
float DropChance[5];
|
||||
if (!LoadFloatsListFromNBT(DropChance, 5, a_NBT, a_NBT.FindChildByName(a_TagIdx, "DropChance")))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
a_Monster.SetDropChanceWeapon(DropChance[0]);
|
||||
a_Monster.SetDropChanceHelmet(DropChance[1]);
|
||||
a_Monster.SetDropChanceChestplate(DropChance[2]);
|
||||
a_Monster.SetDropChanceLeggings(DropChance[3]);
|
||||
a_Monster.SetDropChanceBoots(DropChance[4]);
|
||||
bool CanPickUpLoot = (a_NBT.GetByte(a_NBT.FindChildByName(a_TagIdx, "CanPickUpLoot")) == 1);
|
||||
a_Monster.SetCanPickUpLoot(CanPickUpLoot);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cWSSAnvil::LoadProjectileBaseFromNBT(cProjectileEntity & a_Entity, const cParsedNBT & a_NBT, int a_TagIdx)
|
||||
{
|
||||
if (!LoadEntityBaseFromNBT(a_Entity, a_NBT, a_TagIdx))
|
||||
@ -2065,6 +2230,24 @@ bool cWSSAnvil::LoadDoublesListFromNBT(double * a_Doubles, int a_NumDoubles, con
|
||||
|
||||
|
||||
|
||||
bool cWSSAnvil::LoadFloatsListFromNBT(float * a_Floats, int a_NumFloats, const cParsedNBT & a_NBT, int a_TagIdx)
|
||||
{
|
||||
if ((a_TagIdx < 0) || (a_NBT.GetType(a_TagIdx) != TAG_List) || (a_NBT.GetChildrenType(a_TagIdx) != TAG_Float))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int idx = 0;
|
||||
for (int Tag = a_NBT.GetFirstChild(a_TagIdx); (Tag > 0) && (idx < a_NumFloats); Tag = a_NBT.GetNextSibling(Tag), ++idx)
|
||||
{
|
||||
a_Floats[idx] = a_NBT.GetFloat(Tag);
|
||||
} // for Tag - PosTag[]
|
||||
return (idx == a_NumFloats); // Did we read enough doubles?
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cWSSAnvil::GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, int & a_X, int & a_Y, int & a_Z)
|
||||
{
|
||||
int x = a_NBT.FindChildByName(a_TagIdx, "x");
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "WorldStorage.h"
|
||||
#include "FastNBT.h"
|
||||
#include "../Mobs/Monster.h"
|
||||
|
||||
|
||||
|
||||
@ -194,12 +195,18 @@ protected:
|
||||
/// Loads entity common data from the NBT compound; returns true if successful
|
||||
bool LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||
|
||||
/// Loads monster common data from the NBT compound; returns true if successful
|
||||
bool LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||
|
||||
/// Loads projectile common data from the NBT compound; returns true if successful
|
||||
bool LoadProjectileBaseFromNBT(cProjectileEntity & a_Entity, const cParsedNBT & a_NBT, int a_TagIx);
|
||||
|
||||
/// Loads an array of doubles of the specified length from the specified NBT list tag a_TagIdx; returns true if successful
|
||||
bool LoadDoublesListFromNBT(double * a_Doubles, int a_NumDoubles, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||
|
||||
/// Loads an array of floats of the specified length from the specified NBT list tag a_TagIdx; returns true if successful
|
||||
bool LoadFloatsListFromNBT(float * a_Floats, int a_NumFloats, const cParsedNBT & a_NBT, int a_TagIdx);
|
||||
|
||||
/// Helper function for extracting the X, Y, and Z int subtags of a NBT compound; returns true if successful
|
||||
bool GetBlockEntityNBTPos(const cParsedNBT & a_NBT, int a_TagIdx, int & a_X, int & a_Y, int & a_Z);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user