forked from MagicBane/Server
added equip dropping on mobs to LootManager
This commit is contained in:
@@ -43,7 +43,7 @@ public class LootManager {
|
|||||||
DbManager.LootQueries.LOAD_ALL_MODGROUPS();
|
DbManager.LootQueries.LOAD_ALL_MODGROUPS();
|
||||||
DbManager.LootQueries.LOAD_ALL_MODTABLES();
|
DbManager.LootQueries.LOAD_ALL_MODTABLES();
|
||||||
}
|
}
|
||||||
public static void GenerateMobLoot(Mob mob){
|
public static void GenerateMobLoot(Mob mob, boolean fromDeath){
|
||||||
//determine if mob is in hotzone
|
//determine if mob is in hotzone
|
||||||
boolean inHotzone = ZoneManager.inHotZone(mob.getLoc());
|
boolean inHotzone = ZoneManager.inHotZone(mob.getLoc());
|
||||||
//get multiplier form config manager
|
//get multiplier form config manager
|
||||||
@@ -54,10 +54,10 @@ public class LootManager {
|
|||||||
}
|
}
|
||||||
//iterate the booty sets
|
//iterate the booty sets
|
||||||
if(mob.getMobBase().bootySet != 0 && NPCManager._bootySetMap.containsKey(mob.getMobBase().bootySet)) {
|
if(mob.getMobBase().bootySet != 0 && NPCManager._bootySetMap.containsKey(mob.getMobBase().bootySet)) {
|
||||||
RunBootySet(NPCManager._bootySetMap.get(mob.getMobBase().bootySet), mob, multiplier, inHotzone);
|
RunBootySet(NPCManager._bootySetMap.get(mob.getMobBase().bootySet), mob, multiplier, inHotzone, fromDeath);
|
||||||
}
|
}
|
||||||
if(mob.bootySet != 0) {
|
if(mob.bootySet != 0) {
|
||||||
RunBootySet(NPCManager._bootySetMap.get(mob.bootySet), mob, multiplier, inHotzone);
|
RunBootySet(NPCManager._bootySetMap.get(mob.bootySet), mob, multiplier, inHotzone, fromDeath);
|
||||||
}
|
}
|
||||||
//lastly, check mobs inventory for godly or disc runes to send a server announcement
|
//lastly, check mobs inventory for godly or disc runes to send a server announcement
|
||||||
for (Item it : mob.getInventory()) {
|
for (Item it : mob.getInventory()) {
|
||||||
@@ -70,14 +70,13 @@ public class LootManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob, float multiplier, boolean inHotzone) {
|
private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob, float multiplier, boolean inHotzone, boolean fromDeath) {
|
||||||
|
|
||||||
for (BootySetEntry bse : entries) {
|
for (BootySetEntry bse : entries) {
|
||||||
//check if chance roll is good
|
|
||||||
switch (bse.bootyType) {
|
switch (bse.bootyType) {
|
||||||
case "GOLD":
|
case "GOLD":
|
||||||
if (ThreadLocalRandom.current().nextInt(100) <= (bse.dropChance * multiplier)) {
|
if (ThreadLocalRandom.current().nextInt(100) <= (bse.dropChance * multiplier) || fromDeath) {
|
||||||
//early exit, failed to hit minimum chance roll
|
//early exit, failed to hit minimum chance roll OR booty was generated from mob's death
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//determine and add gold to mob inventory
|
//determine and add gold to mob inventory
|
||||||
@@ -88,8 +87,8 @@ public class LootManager {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "LOOT":
|
case "LOOT":
|
||||||
if (ThreadLocalRandom.current().nextInt(100) <= (bse.dropChance * multiplier)) {
|
if (ThreadLocalRandom.current().nextInt(100) <= (bse.dropChance * multiplier) || fromDeath) {
|
||||||
//early exit, failed to hit minimum chance roll
|
//early exit, failed to hit minimum chance roll OR booty was generated from mob's death
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//iterate the booty tables and add items to mob inventory
|
//iterate the booty tables and add items to mob inventory
|
||||||
@@ -107,10 +106,20 @@ public class LootManager {
|
|||||||
break;
|
break;
|
||||||
case "ITEM":
|
case "ITEM":
|
||||||
MobLoot disc = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true);
|
MobLoot disc = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true);
|
||||||
if (disc != null)
|
if (disc != null || fromDeath)
|
||||||
mob.getCharItemManager().addItemToInventory(disc);
|
mob.getCharItemManager().addItemToInventory(disc);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case "EQUIP":
|
||||||
|
if (ThreadLocalRandom.current().nextInt(100) <= (bse.dropChance * multiplier) || !fromDeath) {
|
||||||
|
//early exit, failed to hit minimum chance roll OR booty wasn't generated form mob's death
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
MobLoot equipToAdd = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true);
|
||||||
|
if (equipToAdd != null) {
|
||||||
|
mob.getCharItemManager().addItemToInventory(equipToAdd);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1253,23 +1253,8 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
|
|
||||||
playerAgroMap.clear();
|
playerAgroMap.clear();
|
||||||
|
|
||||||
if (!this.isPlayerGuard) {
|
if (!this.isPlayerGuard && this.equip != null) {
|
||||||
|
LootManager.GenerateMobLoot(this, true);
|
||||||
|
|
||||||
if (this.equip != null) {
|
|
||||||
|
|
||||||
for (MobEquipment me : equip.values()) {
|
|
||||||
if (me.getDropChance() == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
float chance = ThreadLocalRandom.current().nextFloat();
|
|
||||||
|
|
||||||
if (chance <= me.getDropChance()) {
|
|
||||||
MobLoot ml = new MobLoot(this, me.getItemBase(), false);
|
|
||||||
this.charItemManager.addItemToInventory(ml);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1378,7 +1363,7 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
if (isPlayerGuard)
|
if (isPlayerGuard)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LootManager.GenerateMobLoot(this);
|
LootManager.GenerateMobLoot(this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getLootTable() {
|
private int getLootTable() {
|
||||||
|
|||||||
Reference in New Issue
Block a user