diff options
author | Samuel Barney <samjbarney@gmail.com> | 2014-08-21 02:56:31 +0200 |
---|---|---|
committer | Samuel Barney <samjbarney@gmail.com> | 2014-08-21 02:56:31 +0200 |
commit | 34e0bc759326803ead6e752533b402ff32db9dd2 (patch) | |
tree | f535df9df31aaac33f5f8461733503a842adea66 /src/Mobs/NewMonster.cpp | |
parent | Temporarily instantiating components here. (diff) | |
download | cuberite-34e0bc759326803ead6e752533b402ff32db9dd2.tar cuberite-34e0bc759326803ead6e752533b402ff32db9dd2.tar.gz cuberite-34e0bc759326803ead6e752533b402ff32db9dd2.tar.bz2 cuberite-34e0bc759326803ead6e752533b402ff32db9dd2.tar.lz cuberite-34e0bc759326803ead6e752533b402ff32db9dd2.tar.xz cuberite-34e0bc759326803ead6e752533b402ff32db9dd2.tar.zst cuberite-34e0bc759326803ead6e752533b402ff32db9dd2.zip |
Diffstat (limited to 'src/Mobs/NewMonster.cpp')
-rw-r--r-- | src/Mobs/NewMonster.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/Mobs/NewMonster.cpp b/src/Mobs/NewMonster.cpp index 3245bd83d..feeac2489 100644 --- a/src/Mobs/NewMonster.cpp +++ b/src/Mobs/NewMonster.cpp @@ -1,6 +1,7 @@ #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "NewMonster.h" #include "../ClientHandle.h" +#include "../MersenneTwister.h" cNewMonster::cNewMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) : super(etMonster, a_Width, a_Height) @@ -14,8 +15,95 @@ cNewMonster::cNewMonster(const AString & a_ConfigName, eType a_MobType, const AS m_Movement = new cMovementComponent(this); } + + + + void cNewMonster::SpawnOn(cClientHandle & a_Client) { a_Client.SendSpawnMob(*this); } + + + + +void cNewMonster::AddRandomDropItem(cItems & a_Drops, unsigned int a_Min, unsigned int a_Max, short a_Item, short a_ItemHealth) +{ + MTRand r1; + int Count = r1.randInt() % (a_Max + 1 - a_Min) + a_Min; + if (Count > 0) + { + a_Drops.push_back(cItem(a_Item, Count, a_ItemHealth)); + } +} + + + + + +void cNewMonster::AddRandomUncommonDropItem(cItems & a_Drops, float a_Chance, short a_Item, short a_ItemHealth) +{ + MTRand r1; + int Count = r1.randInt() % 1000; + if (Count < (a_Chance * 10)) + { + a_Drops.push_back(cItem(a_Item, 1, a_ItemHealth)); + } +} + + + + + +void cNewMonster::AddRandomRareDropItem(cItems & a_Drops, cItems & a_Items, short a_LootingLevel) +{ + MTRand r1; + int Count = r1.randInt() % 200; + if (Count < (5 + a_LootingLevel)) + { + int Rare = r1.randInt() % a_Items.Size(); + a_Drops.push_back(a_Items.at(Rare)); + } +} + + + + + +void cNewMonster::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 cNewMonster::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()); + } +} |