Changed formatting, encapsuled armor drop, introduced better static Enchantment IDs
This commit is contained in:
parent
b15ca0055b
commit
90574d083d
@ -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,6 +21,38 @@ class cParsedNBT;
|
||||
|
||||
|
||||
|
||||
// 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,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Class that stores item enchantments or stored-enchantments
|
||||
The enchantments may be serialized to a stringspec and read back from such stringspec.
|
||||
|
@ -19,7 +19,7 @@ cBlaze::cBlaze(void) :
|
||||
|
||||
void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
{
|
||||
if (a_Killer != NULL && (a_Killer->IsPlayer() || 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);
|
||||
AddRandomDropItem(a_Drops, 0, 1 + LootingLevel, E_ITEM_BLAZE_ROD);
|
||||
|
@ -37,7 +37,7 @@ void cCavespider::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
LootingLevel = a_Killer->GetEquippedWeapon().m_Enchantments.GetLevel(E_ENCHANTMENT_LOOTING);
|
||||
}
|
||||
AddRandomDropItem(a_Drops, 0, 2 + LootingLevel, E_ITEM_STRING);
|
||||
if (a_Killer != NULL && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
|
||||
if ((a_Killer != NULL) && (a_Killer->IsPlayer() || a_Killer->IsA("cWolf")))
|
||||
{
|
||||
AddRandomUncommonDropItem(a_Drops, 33.0f, E_ITEM_SPIDER_EYE);
|
||||
}
|
||||
|
@ -909,6 +909,34 @@ 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 < (17 + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedHelmet().IsEmpty()) a_Drops.push_back(GetEquippedHelmet());
|
||||
}
|
||||
|
||||
if (r1.randInt() % 200 < (17 + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedChestplate().IsEmpty()) a_Drops.push_back(GetEquippedChestplate());
|
||||
}
|
||||
|
||||
if (r1.randInt() % 200 < (17 + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedLeggings().IsEmpty()) a_Drops.push_back(GetEquippedLeggings());
|
||||
}
|
||||
|
||||
if (r1.randInt() % 200 < (17 + (a_LootingLevel * 2)))
|
||||
{
|
||||
if (!GetEquippedBoots().IsEmpty()) a_Drops.push_back(GetEquippedBoots());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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"
|
||||
|
||||
|
||||
|
||||
@ -225,11 +226,16 @@ protected:
|
||||
|
||||
/** 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 to itemdrops a_Drops*/
|
||||
|
||||
/** 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);
|
||||
|
||||
|
||||
} ; // tolua_export
|
||||
|
||||
|
@ -31,20 +31,14 @@ void cSkeleton::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
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);
|
||||
AddRandomArmorDropItem(a_Drops, 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);
|
||||
AddRandomArmorDropItem(a_Drops, LootingLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,13 +30,13 @@ 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;
|
||||
|
@ -33,12 +33,8 @@ void cZombie::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,8 +29,8 @@ void cZombiePigman::GetDrops(cItems & a_Drops, cEntity * a_Killer)
|
||||
|
||||
cItems RareDrops;
|
||||
RareDrops.Add(cItem(E_ITEM_GOLD));
|
||||
if (!GetEquippedWeapon().IsEmpty()) RareDrops.Add(GetEquippedWeapon());
|
||||
AddRandomRareDropItem(a_Drops, RareDrops, LootingLevel);
|
||||
AddRandomArmorDropItem(a_Drops, LootingLevel);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user