Browse Source

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

lakebane-master
FatBoy-DOTC 8 months ago
parent
commit
5023d6bb73
  1. 24
      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. 5
      src/engine/net/client/ClientMessagePump.java
  7. 48
      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

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

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

11
src/engine/gameManager/CombatManager.java

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

45
src/engine/gameManager/LootManager.java

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

4
src/engine/gameManager/PowersManager.java

@ -2487,11 +2487,11 @@ public enum PowersManager {
ChatManager.chatSystemInfo(pc, outmsg); ChatManager.chatSystemInfo(pc, outmsg);
return false; // can't target player, stop here return false; // can't target player, stop here
} // target is mob } // 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(); return pb.targetMob();
// target is pet // 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(); return pb.targetPet();
// target is Building // target is Building

24
src/engine/mobileAI/MobAI.java

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

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

@ -1408,7 +1408,7 @@ public class ClientMessagePump implements NetMsgHandler {
} }
int cost = me.getMagicValue(); int cost = me.getMagicValue();
int resourceCost = Warehouse.getCostForResource(me.getItemBase().getUUID()); int resourceCost = Warehouse.getCostForResource(me.getItemBase().getUUID());
if(resourceCost != 0) if (resourceCost != 0)
cost = resourceCost; cost = resourceCost;
float bargain = sourcePlayer.getBargain(); float bargain = sourcePlayer.getBargain();
@ -1440,10 +1440,9 @@ public class ClientMessagePump implements NetMsgHandler {
if (!itemMan.buyFromNPC(b, cost, buildingDeposit)) { if (!itemMan.buyFromNPC(b, cost, buildingDeposit)) {
// chatMan.chatSystemInfo(pc, "" + "You Failed to buy the item."); // chatMan.chatSystemInfo(pc, "" + "You Failed to buy the item.");
ChatManager.chatSystemError(sourcePlayer,"Failed To Buy Item"); ChatManager.chatSystemError(sourcePlayer, "Failed To Buy Item");
return; return;
} }
buy = Item.createItemForPlayer(sourcePlayer, ib); buy = Item.createItemForPlayer(sourcePlayer, ib);
if (buy != null) { if (buy != null) {
me.transferEnchants(buy); me.transferEnchants(buy);

48
src/engine/objects/CharacterItemManager.java

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

8
src/engine/objects/Mob.java

@ -1736,6 +1736,14 @@ public class Mob extends AbstractIntelligenceAgent {
if(this.behaviourType.equals(MobBehaviourType.HamletGuard) && this.getMobBaseID() == 14104) {//guards if(this.behaviourType.equals(MobBehaviourType.HamletGuard) && this.getMobBaseID() == 14104) {//guards
this.behaviourType = MobBehaviourType.Aggro; 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 @Override

15
src/engine/objects/PlayerCharacter.java

@ -3325,7 +3325,9 @@ public class PlayerCharacter extends AbstractCharacter {
if (this.equals(tar)) if (this.equals(tar))
return true; return true;
if(this.getSeeInvis() >= 20){
return !tar.safemodeInvis();
}
return this.getSeeInvis() >= tar.hidden && !tar.safemodeInvis(); return this.getSeeInvis() >= tar.hidden && !tar.safemodeInvis();
} }
@ -4802,17 +4804,6 @@ public class PlayerCharacter extends AbstractCharacter {
//} //}
if(this.isEnteredWorld() && this.isActive() && this.getLevel() < 10){ if(this.isEnteredWorld() && this.isActive() && this.getLevel() < 10){
this.setLevel((short) 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) { } catch (Exception e) {

4
src/engine/objects/Resists.java

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

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

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

Loading…
Cancel
Save