Browse Source

added equip dropping on mobs to LootManager

master
FatBoy-DOTC 2 years ago
parent
commit
c8c275bcd5
  1. 29
      src/engine/loot/LootManager.java
  2. 21
      src/engine/objects/Mob.java

29
src/engine/loot/LootManager.java

@ -43,7 +43,7 @@ public class LootManager { @@ -43,7 +43,7 @@ public class LootManager {
DbManager.LootQueries.LOAD_ALL_MODGROUPS();
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
boolean inHotzone = ZoneManager.inHotZone(mob.getLoc());
//get multiplier form config manager
@ -54,10 +54,10 @@ public class LootManager { @@ -54,10 +54,10 @@ public class LootManager {
}
//iterate the booty sets
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) {
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
for (Item it : mob.getInventory()) {
@ -70,14 +70,13 @@ public class LootManager { @@ -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) {
//check if chance roll is good
switch (bse.bootyType) {
case "GOLD":
if (ThreadLocalRandom.current().nextInt(100) <= (bse.dropChance * multiplier)) {
//early exit, failed to hit minimum chance roll
if (ThreadLocalRandom.current().nextInt(100) <= (bse.dropChance * multiplier) || fromDeath) {
//early exit, failed to hit minimum chance roll OR booty was generated from mob's death
break;
}
//determine and add gold to mob inventory
@ -88,8 +87,8 @@ public class LootManager { @@ -88,8 +87,8 @@ public class LootManager {
}
break;
case "LOOT":
if (ThreadLocalRandom.current().nextInt(100) <= (bse.dropChance * multiplier)) {
//early exit, failed to hit minimum chance roll
if (ThreadLocalRandom.current().nextInt(100) <= (bse.dropChance * multiplier) || fromDeath) {
//early exit, failed to hit minimum chance roll OR booty was generated from mob's death
break;
}
//iterate the booty tables and add items to mob inventory
@ -107,10 +106,20 @@ public class LootManager { @@ -107,10 +106,20 @@ public class LootManager {
break;
case "ITEM":
MobLoot disc = new MobLoot(mob, ItemBase.getItemBase(bse.itemBase), true);
if (disc != null)
if (disc != null || fromDeath)
mob.getCharItemManager().addItemToInventory(disc);
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;
}
}
}

21
src/engine/objects/Mob.java

@ -1253,23 +1253,8 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1253,23 +1253,8 @@ public class Mob extends AbstractIntelligenceAgent {
playerAgroMap.clear();
if (!this.isPlayerGuard) {
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);
}
}
}
if (!this.isPlayerGuard && this.equip != null) {
LootManager.GenerateMobLoot(this, true);
}
}
@ -1378,7 +1363,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1378,7 +1363,7 @@ public class Mob extends AbstractIntelligenceAgent {
if (isPlayerGuard)
return;
LootManager.GenerateMobLoot(this);
LootManager.GenerateMobLoot(this, false);
}
private int getLootTable() {

Loading…
Cancel
Save