Browse Source

Merge branch 'lakebane-mines' into lakebane-custom-races

lakebane-master
FatBoy-DOTC 8 months ago
parent
commit
5023d6bb73
  1. 22
      src/engine/devcmd/cmds/SimulateBootyCmd.java
  2. 11
      src/engine/gameManager/CombatManager.java
  3. 45
      src/engine/gameManager/LootManager.java
  4. 4
      src/engine/gameManager/PowersManager.java
  5. 24
      src/engine/mobileAI/MobAI.java
  6. 1
      src/engine/net/client/ClientMessagePump.java
  7. 46
      src/engine/objects/CharacterItemManager.java
  8. 8
      src/engine/objects/Mob.java
  9. 15
      src/engine/objects/PlayerCharacter.java
  10. 4
      src/engine/objects/Resists.java
  11. 8
      src/engine/server/world/WorldServer.java

22
src/engine/devcmd/cmds/SimulateBootyCmd.java

@ -1,10 +1,12 @@ @@ -1,10 +1,12 @@
package engine.devcmd.cmds;
import engine.Enum;
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.LootManager;
import engine.gameManager.ZoneManager;
import engine.loot.BootySetEntry;
import engine.objects.*;
import org.pmw.tinylog.Logger;
import java.util.ArrayList;
import java.util.concurrent.ThreadLocalRandom;
@ -26,7 +28,9 @@ public class SimulateBootyCmd extends AbstractDevCmd { @@ -26,7 +28,9 @@ public class SimulateBootyCmd extends AbstractDevCmd {
String output;
output = "Booty Simulation:" + newline;
if(target.getObjectType().equals(Enum.GameObjectType.Mob) == false){
return;//ugh what?
}
Mob mob = (Mob) target;
output += "Name: " + mob.getName() + newline;
output += "Special Loot:" + newline;
@ -79,12 +83,19 @@ public class SimulateBootyCmd extends AbstractDevCmd { @@ -79,12 +83,19 @@ public class SimulateBootyCmd extends AbstractDevCmd {
goldAmount += lootItem.getNumOfItems();
break;
default:
if(Warehouse.maxResources.containsKey(lootItem.getItemBaseID())){
Resources.add(lootItem);
} else {
OtherDrops.add(lootItem);
}
break;
}
}
} catch (Exception ex) {
failures++;
//throwbackError(playerCharacter,ex.getLocalizedMessage());
//Logger.error(ex.fillInStackTrace());
//return;
}
if (mob.getEquip() != null) {
for (MobEquipment me : mob.getEquip().values()) {
@ -131,8 +142,17 @@ public class SimulateBootyCmd extends AbstractDevCmd { @@ -131,8 +142,17 @@ public class SimulateBootyCmd extends AbstractDevCmd {
}
output += "GLASS DROPS: " + GlassItems.size() + newline;
for(Item glass : GlassItems){
output += " " + glass.getName() + newline;
}
output += "RUNE DROPS: " + Runes.size() + newline;
for(Item rune : Runes){
output += " " + rune.getName() + newline;
}
output += "CONTRACTS DROPS: " + Contracts.size() + newline;
for(Item contract : Contracts){
output += " " + contract.getName() + newline;
}
output += "RESOURCE DROPS: " + Resources.size() + newline;
output += "OFFERINGS DROPPED: " + Offerings.size() + newline;
output += "ENCHANTED ITEMS DROPPED: " + OtherDrops.size() + newline;

11
src/engine/gameManager/CombatManager.java

@ -645,16 +645,7 @@ public enum CombatManager { @@ -645,16 +645,7 @@ public enum CombatManager {
errorTrack = 4;
//Get hit chance
int chance;
float dif = atr - defense;
if (dif > 100)
chance = 94;
else if (dif < -100)
chance = 4;
else
chance = (int) ((0.45 * dif) + 49);
int chance = (int)((atr-((atr+defense)*0.33f))/((defense-((atr+defense)*0.33f))+(atr-((atr+defense)*0.33f)))) * 100;
errorTrack = 5;

45
src/engine/gameManager/LootManager.java

@ -116,10 +116,18 @@ public enum LootManager { @@ -116,10 +116,18 @@ public enum LootManager {
private static void RunBootySet(ArrayList<BootySetEntry> entries, Mob mob) {
float dropRate = NORMAL_DROP_RATE;
//roll the geenric world drop table
GenerateLootDrop(mob, 1300);
if(ThreadLocalRandom.current().nextInt(1, 10000) == 5000) {
MobLoot extraLoot = rollForGlass(mob);
if (extraLoot != null) {
mob.getCharItemManager().addItemToInventory(extraLoot);
}
}
// Iterate all entries in this bootySet and process accordingly
boolean hasExtraRolled = false;
for (BootySetEntry bse : entries) {
switch (bse.bootyType) {
case "GOLD":
GenerateGoldDrop(mob, bse);
@ -127,9 +135,8 @@ public enum LootManager { @@ -127,9 +135,8 @@ public enum LootManager {
case "LOOT":
if (ThreadLocalRandom.current().nextInt(1, 100 + 1) < (bse.dropChance * dropRate))
GenerateLootDrop(mob, bse.genTable); //generate normal loot drop
if(ThreadLocalRandom.current().nextInt(1,101) < mob.level && mob.parentZone.getSafeZone() == 0) {
if (ThreadLocalRandom.current().nextInt(1, 10000) < mob.level) {
if (_genTables.containsKey(bse.genTable + 1)) {
if(mob.parentZone.getSafeZone() == 0) {
if (hasExtraRolled == false && ThreadLocalRandom.current().nextInt(1, 10000) < 5 * dropRate) {
int roll = ThreadLocalRandom.current().nextInt(1, 101);
MobLoot extraLoot = null;
if (roll >= 1 && roll <= 50) {
@ -138,13 +145,13 @@ public enum LootManager { @@ -138,13 +145,13 @@ public enum LootManager {
if (roll >= 51 && roll <= 94) {
extraLoot = rollForRune(bse.genTable, mob);
}
if (roll >= 95) {
extraLoot = rollForGlass(mob);
}
//if (roll >= 95) {
// extraLoot = rollForGlass(mob);
//}
if (extraLoot != null) {
mob.getCharItemManager().addItemToInventory(extraLoot);
}
}
hasExtraRolled = true;
}
}
break;
@ -193,9 +200,9 @@ public enum LootManager { @@ -193,9 +200,9 @@ public enum LootManager {
if (ItemBase.getItemBase(itemUUID).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) {
int chance = ThreadLocalRandom.current().nextInt(1,101);
if(chance > 5)
if(chance > 10)
return null;
int amount = ThreadLocalRandom.current().nextInt(tableRow.minSpawn, tableRow.maxSpawn + 1);
int amount = ThreadLocalRandom.current().nextInt((int)(tableRow.minSpawn * 0.5f), (int)((tableRow.maxSpawn + 1) * 0.5f));
return new MobLoot(mob, ItemBase.getItemBase(itemUUID), amount, false);
}
@ -333,6 +340,8 @@ public enum LootManager { @@ -333,6 +340,8 @@ public enum LootManager {
try {
MobLoot toAdd = getGenTableItem(tableID, mob);
if(toAdd.getItemBase().getType().equals(Enum.ItemType.CONTRACT) || toAdd.getItemBase().getType().equals(Enum.ItemType.RUNE))
return;//block all contracts and runes that drop outside the confines of the new system
if (toAdd != null) {
toAdd.setIsID(true);
@ -340,7 +349,6 @@ public enum LootManager { @@ -340,7 +349,6 @@ public enum LootManager {
}
} catch (Exception e) {
//TODO chase down loot generation error, affects roughly 2% of drops
int i = 0;
}
}
@ -385,7 +393,7 @@ public enum LootManager { @@ -385,7 +393,7 @@ public enum LootManager {
dropCount = 1;
//break; // Exit on first successful roll.
}
if(ml != null && genericIB.isVorg()){
if(ml != null && genericIB.isVorg() && mob.getMobBaseID() != 14062){
ml.setIsID(true);
ml.setDurabilityCurrent(ml.getDurabilityMax());
mob.getCharItemManager().addItemToInventory(ml);
@ -493,7 +501,10 @@ public enum LootManager { @@ -493,7 +501,10 @@ public enum LootManager {
}
public static MobLoot rollForContract(int table, Mob mob){
GenTableEntry selectedRow = GenTableEntry.rollTable(table, 99, 1.0f);
int roll = 99;
if (table == 1900 || table == 1500)
roll = 73;
GenTableEntry selectedRow = GenTableEntry.rollTable(table, roll, 1.0f);
if (selectedRow == null)
return null;
@ -516,7 +527,11 @@ public enum LootManager { @@ -516,7 +527,11 @@ public enum LootManager {
return null;
}
public static MobLoot rollForRune(int table, Mob mob){
GenTableEntry selectedRow = GenTableEntry.rollTable(table, 97, 1.0f);
int roll = 97;
if(table == 1900 || table == 1500){
roll = 77;
}
GenTableEntry selectedRow = GenTableEntry.rollTable(table, roll, 1.0f);
if (selectedRow == null)
return null;

4
src/engine/gameManager/PowersManager.java

@ -2487,11 +2487,11 @@ public enum PowersManager { @@ -2487,11 +2487,11 @@ public enum PowersManager {
ChatManager.chatSystemInfo(pc, outmsg);
return false; // can't target player, stop here
} // target is mob
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_MOB) != 0)
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_MOB) != 0 && ((Mob)target).isPet() == false)
return pb.targetMob();
// target is pet
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_PET) != 0)
else if ((target.getObjectTypeMask() & MBServerStatics.MASK_MOB) != 0 && ((Mob)target).isPet() == true)
return pb.targetPet();
// target is Building

24
src/engine/mobileAI/MobAI.java

@ -48,7 +48,12 @@ public class MobAI { @@ -48,7 +48,12 @@ public class MobAI {
mob.setCombatTarget(null);
return;
}
if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter){
if(((PlayerCharacter)target).getHidden() > 0){
mob.setCombatTarget(null);
return;
}
}
if (target.getObjectType() == Enum.GameObjectType.PlayerCharacter && canCast(mob)) {
if (mob.isPlayerGuard() == false && MobCast(mob)) {
@ -249,6 +254,9 @@ public class MobAI { @@ -249,6 +254,9 @@ public class MobAI {
if(target.isPet() && target.isAlive() == false && target.guardCaptain.isAlive() == true){
mob.setCombatTarget(target.guardCaptain);
}
if(mob.isPet()){
AttackMob(target,mob);
}
} catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: AttackMob" + " " + e.getMessage());
}
@ -733,7 +741,7 @@ public class MobAI { @@ -733,7 +741,7 @@ public class MobAI {
//Player is Dead, Mob no longer needs to attempt to aggro. Remove them from aggro map.
if (!loadedPlayer.isAlive()) {
if (!loadedPlayer.isAlive() || loadedPlayer.getHidden() > 0) {
loadedPlayers.remove(playerID);
continue;
}
@ -852,9 +860,6 @@ public class MobAI { @@ -852,9 +860,6 @@ public class MobAI {
private static void CheckForRespawn(Mob aiAgent) {
try {
if(Mob.disciplineDroppers.contains(aiAgent) == true){
return; // disc dropper respawns handled elsewhere
}
if (aiAgent.deathTime == 0) {
aiAgent.setDeathTime(System.currentTimeMillis());
return;
@ -891,7 +896,7 @@ public class MobAI { @@ -891,7 +896,7 @@ public class MobAI {
}
} else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) {
if (Zone.respawnQue.contains(aiAgent) == false) {
if (Zone.respawnQue.contains(aiAgent) == false && Mob.disciplineDroppers.contains(aiAgent) == false){
Zone.respawnQue.add(aiAgent);
}
}
@ -978,7 +983,12 @@ public class MobAI { @@ -978,7 +983,12 @@ public class MobAI {
private static void chaseTarget(Mob mob) {
try {
if (mob.combatTarget.getObjectType() == Enum.GameObjectType.PlayerCharacter){
if(((PlayerCharacter)mob.combatTarget).getHidden() > 0){
mob.setCombatTarget(null);
return;
}
}
float rangeSquared = mob.getRange() * mob.getRange();
float distanceSquared = mob.getLoc().distanceSquared2D(mob.getCombatTarget().getLoc());

1
src/engine/net/client/ClientMessagePump.java

@ -1443,7 +1443,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -1443,7 +1443,6 @@ public class ClientMessagePump implements NetMsgHandler {
ChatManager.chatSystemError(sourcePlayer, "Failed To Buy Item");
return;
}
buy = Item.createItemForPlayer(sourcePlayer, ib);
if (buy != null) {
me.transferEnchants(buy);

46
src/engine/objects/CharacterItemManager.java

@ -1254,31 +1254,35 @@ public class CharacterItemManager { @@ -1254,31 +1254,35 @@ public class CharacterItemManager {
}
return false;
}
} //else if (i.getItemBase().getType().equals(ItemType.RESOURCE)) {
// if(this.inventoryContainsResource(i)){
// Item resource = getResource(i);
// if(resource != null){
// resource.setNumOfItems(resource.getNumOfItems() + i.getNumOfItems());
// return true;
// }
//}
// }
this.inventory.add(i);
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
return true;
}
if(ItemBase.getItemBase(i.getItemBaseID()).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) {
int count = i.getNumOfItems();
ArrayList<Item> purge = new ArrayList<>();
for(Item item : this.inventory){
if(item.getItemBaseID() == i.getItemBaseID()){
if(item.getNumOfItems() + count <= Warehouse.getMaxResources().get(i.getItemBaseID())){
purge.add(item);
}
}
private boolean inventoryContainsResource(Item resource) {
for(Item i : this.inventory){
if(i.getItemBaseID() == resource.getItemBaseID())
return true;
}
for(Item item : purge){
count += item.getNumOfItems();
this.removeItemFromInventory(item);
item.junk();
return false;
}
Item resource = new MobLoot(this.getOwner(),i.getItemBase(),count,false).promoteToItem((PlayerCharacter)this.getOwner());
this.inventory.add(resource);
this.itemIDtoType.put(resource.getObjectUUID(), resource.getObjectType().ordinal());
this.updateInventory(purge,false);
return true;
private Item getResource(Item resource) {
for(Item i : this.inventory){
if(i.getItemBaseID() == resource.getItemBaseID())
return i;
}
this.inventory.add(i);
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
return true;
return null;
}
//called for adding gold of a specified amount

8
src/engine/objects/Mob.java

@ -1736,6 +1736,14 @@ public class Mob extends AbstractIntelligenceAgent { @@ -1736,6 +1736,14 @@ public class Mob extends AbstractIntelligenceAgent {
if(this.behaviourType.equals(MobBehaviourType.HamletGuard) && this.getMobBaseID() == 14104) {//guards
this.behaviourType = MobBehaviourType.Aggro;
}
for(MobEquipment equipped: this.equip.values()){
if(equipped.getItemBase().isVorg() && this.getMobBaseID() != 14062){
this.healthMax = 7500;
this.setHealth(this.healthMax);
this.level = 65;
}
}
}
@Override

15
src/engine/objects/PlayerCharacter.java

@ -3325,7 +3325,9 @@ public class PlayerCharacter extends AbstractCharacter { @@ -3325,7 +3325,9 @@ public class PlayerCharacter extends AbstractCharacter {
if (this.equals(tar))
return true;
if(this.getSeeInvis() >= 20){
return !tar.safemodeInvis();
}
return this.getSeeInvis() >= tar.hidden && !tar.safemodeInvis();
}
@ -4802,17 +4804,6 @@ public class PlayerCharacter extends AbstractCharacter { @@ -4802,17 +4804,6 @@ public class PlayerCharacter extends AbstractCharacter {
//}
if(this.isEnteredWorld() && this.isActive() && this.getLevel() < 10){
this.setLevel((short) 10);
boolean hasConc = false;
for(Item i : this.getCharItemManager().getInventory()){
if(i.getItemBaseID() == 980066){
hasConc = true;
}
}
if(hasConc == false) {
MobLoot conc = new MobLoot(this, ItemBase.getItemBase(980066), false);
this.getCharItemManager().addItemToInventory(conc.promoteToItem(this), 1);
this.getCharItemManager().updateInventory();
}
}
} catch (Exception e) {

4
src/engine/objects/Resists.java

@ -393,8 +393,6 @@ public class Resists { @@ -393,8 +393,6 @@ public class Resists {
* Expects heals as negative damage and damage as positive damage for fortitudes.
*/
public float getResistedDamage(AbstractCharacter source, AbstractCharacter target, DamageType type, float damage, int trains) {
//handle fortitudes
damage = handleFortitude(target, type, damage);
//calculate armor piercing
float ap = source.getBonuses().getFloatPercentAll(ModType.ArmorPiercing, SourceType.None);
float damageAfterResists = damage * (1 - (this.getResist(type, trains) * 0.01f) + ap);
@ -417,6 +415,8 @@ public class Resists { @@ -417,6 +415,8 @@ public class Resists {
}
target.cancelOnTakeDamage(type, (damageAfterResists));
}
//handle fortitudes last
damageAfterResists = handleFortitude(target, type, damageAfterResists);
return damageAfterResists;
}

8
src/engine/server/world/WorldServer.java

@ -196,12 +196,12 @@ public class WorldServer { @@ -196,12 +196,12 @@ public class WorldServer {
}
}
private int exec() {
private int exec() throws IOException {
LocalDateTime nextHeartbeatTime = LocalDateTime.now();
LocalDateTime nextPopulationFileTime = LocalDateTime.now();
LocalDateTime nextFlashTrashCheckTime = LocalDateTime.now();
LocalDateTime nextHourlyJobTime = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(1);
LocalDateTime nextHourlyJobTime = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(0);
LocalDateTime nextWareHousePushTime = LocalDateTime.now();
LocalDateTime nextDiscSpawn = LocalDateTime.now().withMinute(0).withSecond(0).plusHours(1);
@ -236,7 +236,7 @@ public class WorldServer { @@ -236,7 +236,7 @@ public class WorldServer {
//}else{
// nextHourlyJobTime = LocalDateTime.now().withMinute(30).withSecond(0);
//}
nextHourlyJobTime = LocalDateTime.now().plusMinutes(1);
nextHourlyJobTime = nextHourlyJobTime.plusMinutes(30);
}
if (LocalDateTime.now().isAfter(nextWareHousePushTime)) {
@ -252,7 +252,7 @@ public class WorldServer { @@ -252,7 +252,7 @@ public class WorldServer {
dropper.respawn();
}
}
nextDiscSpawn = LocalDateTime.now().plusHours(3).withMinute(0).withSecond(0);
nextDiscSpawn = LocalDateTime.now().plusHours(6).withMinute(0).withSecond(0);
}
ThreadUtils.sleep(50);
}

Loading…
Cancel
Save