Compare commits

...

33 Commits

Author SHA1 Message Date
FatBoy 84446eb726 AI tweaking 2025-01-09 08:41:36 -06:00
FatBoy 99f5a9c606 use new AI system 2025-01-09 08:24:20 -06:00
FatBoy 235b5e7375 remove pet properly when no owner found 2025-01-09 08:23:30 -06:00
FatBoy 7289f9e006 Easy AI 2025-01-08 21:06:02 -06:00
FatBoy 9c1afd9441 Easy AI 2025-01-08 21:01:06 -06:00
FatBoy 56226c71eb Easy AI 2025-01-08 20:41:03 -06:00
FatBoy c1eb6796f5 Easy AI first draft 2025-01-08 20:29:42 -06:00
FatBoy 88e16448a8 gold and conc on promotion 2025-01-07 19:11:41 -06:00
FatBoy 4cb428e993 noob island progression changes 2025-01-07 19:05:11 -06:00
FatBoy af9945f9db added null check for endEffect 2025-01-06 21:28:54 -06:00
FatBoy f0594fb1b2 sitting only toggle when casting spells not skills 2025-01-06 12:45:20 -06:00
FatBoy a155bc0308 modified ht chance 2025-01-06 07:14:40 -06:00
FatBoy dce7444483 modified ht chance 2025-01-06 06:54:26 -06:00
FatBoy 76eed79b0a repair cost formula fixed 2025-01-05 20:05:41 -06:00
FatBoy f73ed17c05 repair cost formula 2025-01-05 19:24:05 -06:00
FatBoy b049d21aff corpse timer 2025-01-05 18:53:00 -06:00
FatBoy f6cce5ee1f corpse timer 2025-01-05 18:52:53 -06:00
FatBoy 8038c2ebe2 arena que messages 2025-01-05 18:52:10 -06:00
FatBoy 9f51b9af57 arena que messages 2025-01-05 18:42:06 -06:00
FatBoy cbc75bf9d7 irekei healer blood prophet 2025-01-05 17:40:55 -06:00
FatBoy 0ecfa546cd SDR bind loc for errants 2025-01-05 16:43:38 -06:00
FatBoy b89fb0803d SDR bind loc for errants 2025-01-05 15:41:10 -06:00
FatBoy 11005d58a7 SDR bind loc for errants 2025-01-05 15:39:41 -06:00
FatBoy b0c6239314 SDR bind loc for errants 2025-01-05 15:36:30 -06:00
FatBoy 67f66155e9 SDR bind loc for errants 2025-01-05 15:28:51 -06:00
FatBoy 7fbae12e99 mob update 2025-01-05 14:53:05 -06:00
FatBoy 65580c0a47 mob update 2025-01-05 14:51:43 -06:00
FatBoy 236afe4cc6 mob update 2025-01-05 14:48:51 -06:00
FatBoy c23a6af28f mob update 2025-01-05 14:45:45 -06:00
FatBoy 2535106d2c player update sync 2025-01-05 14:38:07 -06:00
FatBoy d8379ae5a9 shades dont break hide when moving 2025-01-05 11:18:39 -06:00
FatBoy 9f13f5fc5d add sprint to shade stealth 2025-01-05 10:56:14 -06:00
FatBoy 884cb30ebd trade bug 2025-01-05 09:26:42 -06:00
27 changed files with 502 additions and 92 deletions
+9 -17
View File
@@ -9,15 +9,13 @@
package engine; package engine;
import ch.claude_martin.enumbitset.EnumBitSetHelper; import ch.claude_martin.enumbitset.EnumBitSetHelper;
import engine.gameManager.BuildingManager;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.gameManager.PowersManager; import engine.gameManager.PowersManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Vector2f; import engine.math.Vector2f;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.objects.AbstractCharacter; import engine.objects.*;
import engine.objects.ItemBase;
import engine.objects.Shrine;
import engine.objects.Zone;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@@ -471,11 +469,14 @@ public class Enum {
// 14001 does not have a banestone to bind at // 14001 does not have a banestone to bind at
if (ruinZone.getLoadNum() == 14001) if (ruinZone.getLoadNum() == 14001) {
spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc(), 30); spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc(), 30);
else }else {
spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc() //spawnLocation = Vector3fImmutable.getRandomPointOnCircle(ruinZone.getLoc()
.add(new Vector3fImmutable(-196.016f, 2.812f, 203.621f)), 30); //.add(new Vector3fImmutable(-196.016f, 2.812f, 203.621f)), 30);
spawnLocation = Vector3fImmutable.getRandomPointOnCircle(BuildingManager.getBuilding(27977).loc,30f);
}
} }
@@ -1090,15 +1091,6 @@ public class Enum {
DamageShield, DamageShield,
DeathShroud, DeathShroud,
DefenseBuff, DefenseBuff,
DefenseBuffAss,
DefenseBuffChn,
DefenseBuffDsr,
DefenseBuffFur,
DefenseBuffNec,
DefenseBuffNsr,
DefenseBuffPrl,
DefenseBuffRng,
DefenseBuffWiz,
DefenseBuffGroup, DefenseBuffGroup,
DefenseDebuff, DefenseDebuff,
DetectInvis, DetectInvis,
+6 -2
View File
@@ -134,9 +134,13 @@ public class dbItemHandler extends dbHandlerBase {
ResultSet rs = preparedStatement.executeQuery(); ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) if (rs.next()) {
try {
worked = rs.getBoolean("result"); worked = rs.getBoolean("result");
}catch(Exception e){
worked = false;
}
}
} catch (SQLException e) { } catch (SQLException e) {
Logger.error(e); Logger.error(e);
} }
+8
View File
@@ -18,6 +18,7 @@ import engine.gameManager.BuildingManager;
import engine.gameManager.SessionManager; import engine.gameManager.SessionManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.objects.*; import engine.objects.*;
import engine.server.MBServerStatics;
import engine.util.StringUtils; import engine.util.StringUtils;
import java.text.DecimalFormat; import java.text.DecimalFormat;
@@ -530,6 +531,13 @@ public class InfoCmd extends AbstractDevCmd {
} }
break; break;
case Corpse:
Corpse corpse = (Corpse)target;
Long timeLeft = MBServerStatics.CORPSE_CLEANUP_TIMER_MS - (System.currentTimeMillis() - corpse.spawnedTime);
output += "Despawn in: " + timeLeft;
output += newline;
break;
} }
throwbackInfo(pc, output); throwbackInfo(pc, output);
+10
View File
@@ -49,10 +49,20 @@ public class ArenaManager {
if (!playerQueue.contains(player)) { if (!playerQueue.contains(player)) {
playerQueue.add(player); playerQueue.add(player);
} }
for(PlayerCharacter pc : playerQueue){
if(pc.equals(player))
continue;
ChatManager.chatSystemInfo(pc, player.getName() + " has joined the arena que. There are now " + playerQueue.size() + " players queued.");
}
} }
public static void leaveQueue(PlayerCharacter player) { public static void leaveQueue(PlayerCharacter player) {
playerQueue.remove(player); playerQueue.remove(player);
for(PlayerCharacter pc : playerQueue){
if(pc.equals(player))
continue;
ChatManager.chatSystemInfo(pc, player.getName() + " has left the arena que. There are now " + playerQueue.size() + " players queued.");
}
} }
private static void createArena() { private static void createArena() {
+8 -10
View File
@@ -1453,19 +1453,17 @@ public enum CombatManager {
((AbstractCharacter) awo).getCharItemManager().damageRandomArmor(1); ((AbstractCharacter) awo).getCharItemManager().damageRandomArmor(1);
} }
public static boolean LandHit(int atr, int defense){ public static boolean LandHit(int C5, int D5){
float chance = (C5-((C5+D5)*.315f)) / ((D5-((C5+D5)*.315f)) + (C5-((C5+D5)*.315f)));
int convertedChance = Math.round(chance * 100);
//convertedChance = Math.max(5, Math.min(95, convertedChance));
int roll = ThreadLocalRandom.current().nextInt(101); int roll = ThreadLocalRandom.current().nextInt(101);
float chance = (float)((atr-((atr+defense)*0.315))/((defense-((atr+defense)*0.315))+(atr-((atr+defense)*0.315))));
int connvertedChance = (int)(chance * 100); if(roll < 5)//always 5% chance ot miss
return false;
if(connvertedChance < 5) return roll <= convertedChance;
connvertedChance = 5;
if(connvertedChance > 95)
connvertedChance = 95;
return connvertedChance > roll;
} }
} }
+6
View File
@@ -75,6 +75,12 @@ public enum LootManager {
} }
public static void GenerateMobLoot(Mob mob) { public static void GenerateMobLoot(Mob mob) {
//no loot for safezones
if(mob == null || mob.getSafeZone()){
return;
}
//determine if mob is in hotzone //determine if mob is in hotzone
boolean inHotzone = false; boolean inHotzone = false;
+8 -5
View File
@@ -165,7 +165,7 @@ public enum PowersManager {
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
if(!pc.isFlying()) //cant be sitting if flying if(!pc.isFlying() && powersBaseByToken.get(msg.getPowerUsedID()) != null && powersBaseByToken.get(msg.getPowerUsedID()).isSpell) //cant be sitting if flying
CombatManager.toggleSit(false,origin); CombatManager.toggleSit(false,origin);
if(pc.isMoving()) if(pc.isMoving())
@@ -787,10 +787,13 @@ public enum PowersManager {
if (playerCharacter == null || msg == null) if (playerCharacter == null || msg == null)
return; return;
if((msg.getPowerUsedID() == 429495514 || msg.getPowerUsedID() == 429407306) && playerCharacter.getRace().getName().toLowerCase().contains("shade")){ //if((msg.getPowerUsedID() == 429495514 || msg.getPowerUsedID() == 429407306) && playerCharacter.getRace().getName().toLowerCase().contains("shade")){
//msg.setPowerUsedID(407015607); // //use sneak instead of hide
applyPower(playerCharacter,playerCharacter,playerCharacter.loc,429397210,msg.getNumTrains(),false); // PowersBase pb = PowersManager.getPowerByToken(429397210);
} // int offsetTrains = (40 - msg.getNumTrains()) ;
// applyPower(playerCharacter,playerCharacter,playerCharacter.loc,429397210,msg.getNumTrains(),false);
// applyPower(playerCharacter,playerCharacter,playerCharacter.loc,427857146,offsetTrains,false);
//}
if(msg.getPowerUsedID() == 429494441) {//wildkins chase if(msg.getPowerUsedID() == 429494441) {//wildkins chase
playerCharacter.removeEffectBySource(EffectSourceType.Root,40,true); playerCharacter.removeEffectBySource(EffectSourceType.Root,40,true);
playerCharacter.removeEffectBySource(EffectSourceType.Snare,40,true); playerCharacter.removeEffectBySource(EffectSourceType.Snare,40,true);
+1 -1
View File
@@ -117,7 +117,7 @@ public abstract class AbstractEffectJob extends AbstractScheduleJob {
} }
public void endEffect() { public void endEffect() {
if (this.eb == null) if (this.eb == null || this.power == null)
return; return;
this.eb.endEffect(this.source, this.target, this.trains, this.power, this); this.eb.endEffect(this.source, this.target, this.trains, this.power, this);
} }
@@ -0,0 +1,10 @@
package engine.mobileAI.BehaviourFiles;
import engine.objects.Mob;
public class PlayerGuard {
public static void process(Mob guard){
}
}
@@ -0,0 +1,86 @@
package engine.mobileAI.BehaviourFiles;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.PowersManager;
import engine.mobileAI.enumMobState;
import engine.mobileAI.utilities.CombatUtilities;
import engine.mobileAI.utilities.MovementUtilities;
import engine.objects.AbstractWorldObject;
import engine.objects.ItemBase;
import engine.objects.Mob;
import engine.objects.PlayerCharacter;
import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import java.util.Map;
public class PlayerPet {
public static void process(Mob pet){
if(pet.getOwner() == null && !pet.isNecroPet()){
pet.killCharacter("no owner");
return;
}
if(!WorldGrid.getObjectsInRangePartial(pet.loc, MBServerStatics.CHARACTER_LOAD_RANGE,1).contains(pet.getOwner())){
pet.teleport(pet.getOwner().loc);
return;
}
switch(enumMobState.getState(pet)){
case dead:
pet.despawn();
return;
case patrolling:
if(pet.loc.distanceSquared(pet.getOwner().loc) > 90 && !pet.isMoving()){
MovementUtilities.aiMove(pet,pet.getOwner().loc,false);
}
return;
case attacking:
attack(pet);
return;
}
}
public static void attack(Mob mob){
if (mob.combatTarget == null || !mob.combatTarget.isAlive()) {
mob.setCombatTarget(null);
aggro(mob);
return;
}
if(!CombatUtilities.inRangeToAttack(mob,mob.combatTarget)){
if (!MovementUtilities.canMove(mob))
return;
MovementUtilities.aiMove(mob,mob.combatTarget.loc,false);
return;
}
mob.updateLocation();
ItemBase weapon = mob.getWeaponItemBase(true);
boolean mainHand = true;
if(weapon == null) {
weapon = mob.getWeaponItemBase(false);
mainHand = false;
}
if (System.currentTimeMillis() > mob.getNextAttackTime()) {
CombatUtilities.combatCycle(mob, mob.combatTarget, mainHand, weapon);
mob.setNextAttackTime(System.currentTimeMillis() + 3000L);
}
}
public static void aggro(Mob mob){
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(mob.loc,30, MBServerStatics.MASK_MOB)) {
Mob potentialTarget = (Mob) awo;
if (!potentialTarget.isAlive())
continue;
if (MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
mob.setCombatTarget(potentialTarget);
return;
}
}
}
}
@@ -0,0 +1,47 @@
package engine.mobileAI.BehaviourFiles;
import engine.Enum;
import engine.mobileAI.utilities.CombatUtilities;
import engine.objects.Mob;
public class SiegeMob {
public static void process(Mob treb){
if(!treb.isAlive()){
if(!treb.despawned){
treb.despawn();
treb.deathTime = System.currentTimeMillis();
return;
}
if(treb.deathTime == 0) {
treb.deathTime = System.currentTimeMillis();
return;
}
if(treb.deathTime + 900000L > System.currentTimeMillis()) {
treb.respawn();
treb.setCombatTarget(null);
return;
}
}
if(treb.combatTarget == null)
return;
if(!treb.combatTarget.getObjectType().equals(Enum.GameObjectType.Building)) {
treb.setCombatTarget(null);
return;
}
if(!treb.combatTarget.isAlive()) {
treb.setCombatTarget(null);
return;
}
if(!CombatUtilities.inRangeToAttack(treb,treb.combatTarget))
treb.setCombatTarget(null);
if (System.currentTimeMillis() > treb.getNextAttackTime()) {
CombatUtilities.combatCycle(treb, treb.combatTarget, true, null);
treb.setNextAttackTime(System.currentTimeMillis() + 11000L);
}
}
}
@@ -0,0 +1,155 @@
package engine.mobileAI.BehaviourFiles;
import engine.InterestManagement.WorldGrid;
import engine.gameManager.PowersManager;
import engine.mobileAI.enumMobState;
import engine.mobileAI.utilities.CombatUtilities;
import engine.mobileAI.utilities.MovementUtilities;
import engine.objects.*;
import engine.powers.PowersBase;
import engine.server.MBServerStatics;
import java.util.Map;
public class StandardMob {
public static void process(Mob mob){
switch(enumMobState.getState(mob)){
case idle:
return;
case dead:
respawn(mob);
return;
case patrolling:
if(mob.combatTarget == null)
aggro(mob);
if(mob.combatTarget == null)
patrol(mob);
return;
case attacking:
attack(mob);
return;
}
}
public static void respawn(Mob mob){
if (mob.deathTime == 0) {
mob.setDeathTime(System.currentTimeMillis());
return;
}
if (!mob.despawned) {
if (mob.getCharItemManager() != null && mob.getCharItemManager().getInventoryCount() > 0) {
if (System.currentTimeMillis() > mob.deathTime + MBServerStatics.DESPAWN_TIMER_WITH_LOOT) {
mob.despawn();
mob.deathTime = System.currentTimeMillis();
return;
}
//No items in inventory.
} else if (mob.isHasLoot()) {
if (System.currentTimeMillis() > mob.deathTime + MBServerStatics.DESPAWN_TIMER_ONCE_LOOTED) {
mob.despawn();
mob.deathTime = System.currentTimeMillis();
return;
}
//Mob never had Loot.
} else {
if (System.currentTimeMillis() > mob.deathTime + MBServerStatics.DESPAWN_TIMER) {
mob.despawn();
mob.deathTime = System.currentTimeMillis();
return;
}
}
}
if(Mob.discDroppers.contains(mob))
return;
if (System.currentTimeMillis() > (mob.deathTime + (mob.spawnTime * 1000L))) {
if (!Zone.respawnQue.contains(mob)) {
Zone.respawnQue.add(mob);
}
}
}
public static void aggro(Mob mob){
if(enumMobState.Agressive(mob)){
for(int id : mob.playerAgroMap.keySet()){
PlayerCharacter potentialTarget = PlayerCharacter.getFromCache(id);
if(!potentialTarget.isAlive() || !mob.canSee(potentialTarget))
continue;
if (MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
mob.setCombatTarget(potentialTarget);
return;
}
}
for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(mob.loc,60, MBServerStatics.MASK_PET)){
Mob potentialTarget = (Mob)awo;
if(!potentialTarget.isAlive())
continue;
if (MovementUtilities.inRangeToAggro(mob, potentialTarget)) {
mob.setCombatTarget(potentialTarget);
return;
}
}
}
}
public static void patrol(Mob mob){
if (!MovementUtilities.canMove(mob))
return;
if (mob.stopPatrolTime + 5000L > System.currentTimeMillis())
return;
if(mob.isMoving())
return;
if (mob.lastPatrolPointIndex > mob.patrolPoints.size() - 1)
mob.lastPatrolPointIndex = 0;
mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex);
mob.lastPatrolPointIndex += 1;
MovementUtilities.aiMove(mob, mob.destination, true);
}
public static void attack(Mob mob){
if (!MovementUtilities.inRangeOfBindLocation(mob)) {
PowersBase recall = PowersManager.getPowerByToken(-1994153779);
PowersManager.useMobPower(mob, mob, recall, 40);
mob.setCombatTarget(null);
for (Map.Entry playerEntry : mob.playerAgroMap.entrySet())
PlayerCharacter.getFromCache((int) playerEntry.getKey()).setHateValue(0);
mob.setCombatTarget(null);
return;
}
if (mob.combatTarget == null || !mob.combatTarget.isAlive()) {
mob.setCombatTarget(null);
return;
}
if(!mob.isMoving() && !CombatUtilities.inRangeToAttack(mob,mob.combatTarget)){
if (!MovementUtilities.canMove(mob))
return;
MovementUtilities.aiMove(mob,mob.combatTarget.loc,false);
return;
}
mob.updateLocation();
ItemBase weapon = mob.getWeaponItemBase(true);
boolean mainHand = true;
if(weapon == null) {
weapon = mob.getWeaponItemBase(false);
mainHand = false;
}
if (System.currentTimeMillis() > mob.getNextAttackTime()) {
CombatUtilities.combatCycle(mob, mob.combatTarget, mainHand, weapon);
mob.setNextAttackTime(System.currentTimeMillis() + 3000L);
}
}
}
+32
View File
@@ -0,0 +1,32 @@
package engine.mobileAI;
import engine.mobileAI.BehaviourFiles.PlayerGuard;
import engine.mobileAI.BehaviourFiles.PlayerPet;
import engine.mobileAI.BehaviourFiles.SiegeMob;
import engine.mobileAI.BehaviourFiles.StandardMob;
import engine.objects.Mob;
public class EasyAI {
public static void aiRun(Mob mob) {
if (mob == null)
return;
if (mob.isPlayerGuard) {
PlayerGuard.process(mob);
return;
}
if(mob.isSiege()){
SiegeMob.process(mob);
return;
}
if (mob.isPet()) {
PlayerPet.process(mob);
return;
}
StandardMob.process(mob);
}
}
+11 -14
View File
@@ -9,7 +9,6 @@
package engine.mobileAI; package engine.mobileAI;
import engine.Enum; import engine.Enum;
import engine.Enum.DispatchChannel;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.gameManager.*; import engine.gameManager.*;
import engine.math.Vector3f; import engine.math.Vector3f;
@@ -17,9 +16,7 @@ import engine.math.Vector3fImmutable;
import engine.mobileAI.Threads.MobAIThread; import engine.mobileAI.Threads.MobAIThread;
import engine.mobileAI.utilities.CombatUtilities; import engine.mobileAI.utilities.CombatUtilities;
import engine.mobileAI.utilities.MovementUtilities; import engine.mobileAI.utilities.MovementUtilities;
import engine.net.DispatchMessage;
import engine.net.client.msg.PerformActionMsg; import engine.net.client.msg.PerformActionMsg;
import engine.net.client.msg.PowerProjectileMsg;
import engine.objects.*; import engine.objects.*;
import engine.powers.ActionsBase; import engine.powers.ActionsBase;
import engine.powers.PowersBase; import engine.powers.PowersBase;
@@ -118,7 +115,7 @@ public class MobAI {
//no weapons, default mob attack speed 3 seconds. //no weapons, default mob attack speed 3 seconds.
if (System.currentTimeMillis() < mob.getLastAttackTime()) if (System.currentTimeMillis() < mob.getNextAttackTime())
return; return;
// ranged mobs cant attack while running. skip until they finally stop. // ranged mobs cant attack while running. skip until they finally stop.
@@ -136,19 +133,19 @@ public class MobAI {
int delay = 3000; int delay = 3000;
if (mob.isSiege()) if (mob.isSiege())
delay = 11000; delay = 11000;
mob.setLastAttackTime(System.currentTimeMillis() + delay); mob.setNextAttackTime(System.currentTimeMillis() + delay);
} else if (mob.getWeaponItemBase(true) != null) { } else if (mob.getWeaponItemBase(true) != null) {
int delay = 3000; int delay = 3000;
if (mob.isSiege()) if (mob.isSiege())
delay = 11000; delay = 11000;
CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true)); CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true));
mob.setLastAttackTime(System.currentTimeMillis() + delay); mob.setNextAttackTime(System.currentTimeMillis() + delay);
} else if (mob.getWeaponItemBase(false) != null) { } else if (mob.getWeaponItemBase(false) != null) {
int attackDelay = 3000; int attackDelay = 3000;
if (mob.isSiege()) if (mob.isSiege())
attackDelay = 11000; attackDelay = 11000;
CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false)); CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false));
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); mob.setNextAttackTime(System.currentTimeMillis() + attackDelay);
} }
} }
@@ -193,19 +190,19 @@ public class MobAI {
int delay = 3000; int delay = 3000;
if (mob.isSiege()) if (mob.isSiege())
delay = 15000; delay = 15000;
mob.setLastAttackTime(System.currentTimeMillis() + delay); mob.setNextAttackTime(System.currentTimeMillis() + delay);
} else if (mob.getWeaponItemBase(true) != null) { } else if (mob.getWeaponItemBase(true) != null) {
int attackDelay = 3000; int attackDelay = 3000;
if (mob.isSiege()) if (mob.isSiege())
attackDelay = 15000; attackDelay = 15000;
CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true)); CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true));
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); mob.setNextAttackTime(System.currentTimeMillis() + attackDelay);
} else if (mob.getWeaponItemBase(false) != null) { } else if (mob.getWeaponItemBase(false) != null) {
int attackDelay = 3000; int attackDelay = 3000;
if (mob.isSiege()) if (mob.isSiege())
attackDelay = 15000; attackDelay = 15000;
CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false)); CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false));
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); mob.setNextAttackTime(System.currentTimeMillis() + attackDelay);
} }
//if (mob.isSiege()) { //if (mob.isSiege()) {
@@ -236,19 +233,19 @@ public class MobAI {
int delay = 3000; int delay = 3000;
if (mob.isSiege()) if (mob.isSiege())
delay = 11000; delay = 11000;
mob.setLastAttackTime(System.currentTimeMillis() + delay); mob.setNextAttackTime(System.currentTimeMillis() + delay);
} else if (mob.getWeaponItemBase(true) != null) { } else if (mob.getWeaponItemBase(true) != null) {
int attackDelay = 3000; int attackDelay = 3000;
if (mob.isSiege()) if (mob.isSiege())
attackDelay = 11000; attackDelay = 11000;
CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true)); CombatUtilities.combatCycle(mob, target, true, mob.getWeaponItemBase(true));
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); mob.setNextAttackTime(System.currentTimeMillis() + attackDelay);
} else if (mob.getWeaponItemBase(false) != null) { } else if (mob.getWeaponItemBase(false) != null) {
int attackDelay = 3000; int attackDelay = 3000;
if (mob.isSiege()) if (mob.isSiege())
attackDelay = 11000; attackDelay = 11000;
CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false)); CombatUtilities.combatCycle(mob, target, false, mob.getWeaponItemBase(false));
mob.setLastAttackTime(System.currentTimeMillis() + attackDelay); mob.setNextAttackTime(System.currentTimeMillis() + attackDelay);
if (target.getCombatTarget() == null) { if (target.getCombatTarget() == null) {
target.setCombatTarget(mob); target.setCombatTarget(mob);
} }
@@ -918,7 +915,7 @@ public class MobAI {
mob.setCombatTarget(null); mob.setCombatTarget(null);
return; return;
} }
if (System.currentTimeMillis() > mob.getLastAttackTime()) if (System.currentTimeMillis() > mob.getNextAttackTime())
AttackTarget(mob, mob.getCombatTarget()); AttackTarget(mob, mob.getCombatTarget());
} catch (Exception e) { } catch (Exception e) {
+2 -1
View File
@@ -1,6 +1,7 @@
package engine.mobileAI.Threads; package engine.mobileAI.Threads;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.mobileAI.EasyAI;
import engine.mobileAI.MobAI; import engine.mobileAI.MobAI;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.objects.Mob; import engine.objects.Mob;
@@ -33,7 +34,7 @@ public class MobAIThread implements Runnable{
try { try {
if (mob != null) if (mob != null)
MobAI.DetermineAction(mob); EasyAI.aiRun(mob);
} catch (Exception e) { } catch (Exception e) {
Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e); Logger.error("Mob: " + mob.getName() + " UUID: " + mob.getObjectUUID() + " ERROR: " + e);
e.printStackTrace(); e.printStackTrace();
+27
View File
@@ -0,0 +1,27 @@
package engine.mobileAI;
import engine.objects.Mob;
public enum enumMobState {
idle,
attacking,
patrolling,
dead;
public static enumMobState getState(Mob mob){
if(mob.playerAgroMap.isEmpty())
return enumMobState.idle;
if(!mob.isAlive())
return enumMobState.dead;
if(mob.combatTarget != null)
return enumMobState.attacking;
return enumMobState.patrolling;
}
public static boolean Agressive(Mob mob){
return mob.BehaviourType.name().contains("Aggro");
}
}
@@ -154,7 +154,7 @@ public class CombatUtilities {
case Building: case Building:
return false; return false;
} }
return CombatManager.LandHit(atr,defense); return !CombatManager.LandHit(atr,defense);
} }
public static boolean triggerBlock(Mob agent, AbstractWorldObject ac) { public static boolean triggerBlock(Mob agent, AbstractWorldObject ac) {
@@ -83,7 +83,7 @@ public class MovementUtilities {
} }
public static boolean inRangeToAggro(Mob agent, PlayerCharacter target) { public static boolean inRangeToAggro(Mob agent, AbstractCharacter target) {
Vector3fImmutable sl = agent.getLoc(); Vector3fImmutable sl = agent.getLoc();
Vector3fImmutable tl = target.getLoc(); Vector3fImmutable tl = target.getLoc();
@@ -169,6 +169,9 @@ public class MovementUtilities {
if (agent.getMobBase() != null && Enum.MobFlagType.SENTINEL.elementOf(agent.getMobBase().getFlags())) if (agent.getMobBase() != null && Enum.MobFlagType.SENTINEL.elementOf(agent.getMobBase().getFlags()))
return false; return false;
if(!agent.BehaviourType.canRoam)
return false;
return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.CannotMove, SourceType.None)); return (agent.isAlive() && !agent.getBonuses().getBool(ModType.Stunned, SourceType.None) && !agent.getBonuses().getBool(ModType.CannotMove, SourceType.None));
} }
+6 -9
View File
@@ -1681,15 +1681,12 @@ public class ClientMessagePump implements NetMsgHandler {
return; return;
} }
int cost = ((int)((toRepair.getMagicValue()/max*(max - dur)) + (npc.getSpecialPrice() * npc.buyPercent))) + (int)(npc.getSpecialPrice() * (max - dur)); int pointsToRepair = max - dur;
double damageRatio = (double)1.0d - (toRepair.getDurabilityMax() - toRepair.getDurabilityCurrent()) / toRepair.getDurabilityMax();
//int pointsToRepair = max - dur; int modifiedValue = (int)(damageRatio * toRepair.getMagicValue());
//int magicValue = toRepair.getMagicValue(); int costPerPoint = modifiedValue / toRepair.getDurabilityMax();
//if(magicValue == 0) int modifiedRepairCost = (int)(pointsToRepair * costPerPoint)+ npc.getSpecialPrice();
// magicValue = 1; int cost = (int)(modifiedRepairCost * 1 + npc.buyPercent) + npc.getSpecialPrice();
//int calculatedValue = toRepair.getDurabilityMax() * magicValue;
//float costPerPoint = (magicValue / max) * ( 1 + npc.buyPercent);
//cost = (int)(pointsToRepair * costPerPoint) + npc.getSpecialPrice();
Building b = (!npc.isStatic()) ? npc.getBuilding() : null; Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
if (b != null) if (b != null)
@@ -146,6 +146,8 @@ public class ApplyRuneMsg extends ClientNetMsg {
valid = true; valid = true;
if(runeID == 3035 && baseClassID == 2501) if(runeID == 3035 && baseClassID == 2501)
valid = true; valid = true;
if(runeID == 3028 && baseClassID == 2501 && playerCharacter.getRace().getName().contains("Irekei"))
valid = true;
if (!valid) { if (!valid) {
return false; return false;
} }
@@ -631,6 +631,11 @@ public class VendorDialogMsg extends ClientNetMsg {
.getObjectUUID(), true); .getObjectUUID(), true);
DispatchMessage.dispatchMsgToInterestArea(pc, arm, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); DispatchMessage.dispatchMsgToInterestArea(pc, arm, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
if(pc.getCharItemManager() != null && pc.getCharItemManager().getGoldInventory() != null && pc.getCharItemManager().getGoldInventory().getNumOfItems() < 1000) {
pc.getCharItemManager().addGoldToInventory(1000, false);
pc.getCharItemManager().addItemToInventory(new MobLoot(pc, ItemBase.getItemBase(980066), 1, false).promoteToItem(pc));
pc.getCharItemManager().updateInventory();
}
} }
+14 -5
View File
@@ -14,10 +14,7 @@ import engine.Enum.*;
import engine.InterestManagement.InterestManager; import engine.InterestManagement.InterestManager;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.exception.SerializationException; import engine.exception.SerializationException;
import engine.gameManager.CombatManager; import engine.gameManager.*;
import engine.gameManager.ConfigManager;
import engine.gameManager.MovementManager;
import engine.gameManager.PowersManager;
import engine.job.AbstractJob; import engine.job.AbstractJob;
import engine.job.JobContainer; import engine.job.JobContainer;
import engine.job.JobScheduler; import engine.job.JobScheduler;
@@ -764,8 +761,12 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
public abstract Vector3fImmutable getBindLoc(); public abstract Vector3fImmutable getBindLoc();
public final void setBindLoc(final Vector3fImmutable value) { public final void setBindLoc(final Vector3fImmutable value) {
if(this.getObjectType().equals(GameObjectType.PlayerCharacter) && this.guild.getNation().equals(Guild.getErrantGuild())){
this.bindLoc = Vector3fImmutable.getRandomPointOnCircle(BuildingManager.getBuilding(27977).loc,20f);
}else {
this.bindLoc = value; this.bindLoc = value;
} }
}
public final Vector3fImmutable getFaceDir() { public final Vector3fImmutable getFaceDir() {
return this.faceDir; return this.faceDir;
@@ -1558,7 +1559,15 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
Effect eff = this.effects.get(s); Effect eff = this.effects.get(s);
if (eff == null) if (eff == null)
continue; continue;
if (eff.cancelOnMove() && eff.cancel()) {
Boolean override = false;
if(this.getObjectType().equals(GameObjectType.PlayerCharacter)) {
PlayerCharacter pc = (PlayerCharacter) this;
if (eff.getEffectsBase().getIDString().equals("INVIS-B") && s.equals("Invisible") && pc.getRace().getName().contains("Shade"))
override = true;
}
if (!override && eff.cancelOnMove() && eff.cancel()) {
//System.out.println("canceling on Move"); //System.out.println("canceling on Move");
eff.cancelJob(); eff.cancelJob();
this.effects.remove(s); this.effects.remove(s);
+2
View File
@@ -43,6 +43,7 @@ public class Corpse extends AbstractWorldObject {
private int inBuildingID = 0; private int inBuildingID = 0;
private int inFloorID = -1; private int inFloorID = -1;
private int inBuilding = -1; private int inBuilding = -1;
public Long spawnedTime = 0L;
/** /**
* No Id Constructor * No Id Constructor
@@ -74,6 +75,7 @@ public class Corpse extends AbstractWorldObject {
} }
this.setObjectTypeMask(MBServerStatics.MASK_CORPSE); this.setObjectTypeMask(MBServerStatics.MASK_CORPSE);
this.spawnedTime = System.currentTimeMillis();
if (!safeZone) if (!safeZone)
transferInventory(belongsTo, enterWorld); transferInventory(belongsTo, enterWorld);
+4 -1
View File
@@ -1227,7 +1227,10 @@ public class Item extends AbstractWorldObject {
} }
public final int getMagicValue() { public final int getMagicValue() {
return this.magicValue; int val = this.calcMagicValue();
if(val == 0)
val = 1;
return val + this.getItemBase().getMagicValue();
} }
public int getBaseValue() { public int getBaseValue() {
+9 -7
View File
@@ -12,6 +12,7 @@ package engine.objects;
import ch.claude_martin.enumbitset.EnumBitSet; import ch.claude_martin.enumbitset.EnumBitSet;
import engine.Enum; import engine.Enum;
import engine.Enum.*; import engine.Enum.*;
import engine.InterestManagement.InterestManager;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.exception.SerializationException; import engine.exception.SerializationException;
import engine.gameManager.*; import engine.gameManager.*;
@@ -95,7 +96,7 @@ public class Mob extends AbstractIntelligenceAgent {
private AbstractWorldObject fearedObject = null; private AbstractWorldObject fearedObject = null;
private int buildingID; private int buildingID;
private boolean isSiege = false; private boolean isSiege = false;
private long lastAttackTime = 0; private long nextAttackTime = 0;
private int lastMobPowerToken = 0; private int lastMobPowerToken = 0;
private HashMap<Integer, MobEquipment> equip = null; private HashMap<Integer, MobEquipment> equip = null;
private DeferredPowerJob weaponPower; private DeferredPowerJob weaponPower;
@@ -1326,8 +1327,6 @@ public class Mob extends AbstractIntelligenceAgent {
Dispatch dispatch; Dispatch dispatch;
try { try {
//resync corpses
//this.setLoc(this.getMovementLoc());
if (this.isSiege) { if (this.isSiege) {
this.deathTime = System.currentTimeMillis(); this.deathTime = System.currentTimeMillis();
//this.state = STATE.Dead; //this.state = STATE.Dead;
@@ -1407,6 +1406,8 @@ public class Mob extends AbstractIntelligenceAgent {
Logger.error(e); Logger.error(e);
} }
this.updateLocation(); this.updateLocation();
//resync corpses
InterestManager.setObjectDirty(this);
} }
public void respawn() { public void respawn() {
@@ -2165,6 +2166,7 @@ public class Mob extends AbstractIntelligenceAgent {
} }
this.deathTime = 0; this.deathTime = 0;
InterestManager.setObjectDirty(this);
} catch (Exception e) { } catch (Exception e) {
Logger.error(e.getMessage()); Logger.error(e.getMessage());
} }
@@ -2235,12 +2237,12 @@ public class Mob extends AbstractIntelligenceAgent {
return this.upgradeDateTime != null; return this.upgradeDateTime != null;
} }
public long getLastAttackTime() { public long getNextAttackTime() {
return lastAttackTime; return nextAttackTime;
} }
public void setLastAttackTime(long lastAttackTime) { public void setNextAttackTime(long lastAttackTime) {
this.lastAttackTime = lastAttackTime; this.nextAttackTime = lastAttackTime;
} }
public void setDeathTime(long deathTime) { public void setDeathTime(long deathTime) {
+25 -14
View File
@@ -1300,7 +1300,7 @@ public class PlayerCharacter extends AbstractCharacter {
if (ConfigManager.serverType.equals(ServerType.WORLDSERVER)) if (ConfigManager.serverType.equals(ServerType.WORLDSERVER))
player.setLoc(player.bindLoc); player.setLoc(player.getBindLoc());
player.endLoc = Vector3fImmutable.ZERO; player.endLoc = Vector3fImmutable.ZERO;
//get level based on experience //get level based on experience
@@ -2925,6 +2925,9 @@ public class PlayerCharacter extends AbstractCharacter {
} }
public synchronized void grantXP(int xp) { public synchronized void grantXP(int xp) {
int groupSize = 1;
if(GroupManager.getGroup(this)!= null)
groupSize = GroupManager.getGroup(this).members.size();
if(this.promotionClass == null && this.level == 10){ if(this.promotionClass == null && this.level == 10){
this.setOverFlowEXP(0); this.setOverFlowEXP(0);
this.update(false); this.update(false);
@@ -3075,6 +3078,14 @@ public class PlayerCharacter extends AbstractCharacter {
SetObjectValueMsg upm = new SetObjectValueMsg(this, 9); SetObjectValueMsg upm = new SetObjectValueMsg(this, 9);
DispatchMessage.dispatchMsgToInterestArea(this, upm, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); DispatchMessage.dispatchMsgToInterestArea(this, upm, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
checkGuildStatus(); checkGuildStatus();
//give gold for level up if level is under or equal to 20 and over 10
if(this.level >= 10 && this.level < 20) {
int gold = (int) ((100000 * (this.level - 10) / 55.0) / groupSize);
this.charItemManager.addGoldToInventory(gold, false);
this.charItemManager.updateInventory();
}
} else { } else {
this.exp += remainingXP; this.exp += remainingXP;
@@ -4640,7 +4651,7 @@ public class PlayerCharacter extends AbstractCharacter {
tmpLevel = targetLevel; tmpLevel = targetLevel;
tmpLevel = (short) Math.min(tmpLevel, 75); tmpLevel = (short) Math.min(tmpLevel, MBServerStatics.LEVELCAP);
while (this.level < tmpLevel) { while (this.level < tmpLevel) {
grantXP(Experience.getBaseExperience(tmpLevel) - this.exp); grantXP(Experience.getBaseExperience(tmpLevel) - this.exp);
@@ -4845,8 +4856,8 @@ public class PlayerCharacter extends AbstractCharacter {
@Override @Override
public void update(Boolean newSystem) { public void update(Boolean newSystem) {
if(!newSystem) //if(!newSystem)
return; // return;
if (this.updateLock.writeLock().tryLock()) { if (this.updateLock.writeLock().tryLock()) {
try { try {
@@ -4858,19 +4869,19 @@ public class PlayerCharacter extends AbstractCharacter {
forceRespawn(this); forceRespawn(this);
return; return;
} }
updateLocation(); this.updateLocation();
updateMovementState(); this.updateMovementState();
updateRegen(); this.updateRegen();
if (this.getStamina() < 10) { if (this.getStamina() < 10) {
if (this.getAltitude() > 0 || this.getDesiredAltitude() > 0) { if (this.getAltitude() > 0 || this.getDesiredAltitude() > 0) {
PlayerCharacter.GroundPlayer(this); PlayerCharacter.GroundPlayer(this);
updateRegen(); this.updateRegen();
} }
} }
RealmMap.updateRealm(this); RealmMap.updateRealm(this);
updateBlessingMessage(); this.updateBlessingMessage();
this.safeZone = this.isInSafeZone(); this.safeZone = this.isInSafeZone();
if(!this.timestamps.containsKey("nextBoxCheck")) if(!this.timestamps.containsKey("nextBoxCheck"))
@@ -4886,11 +4897,11 @@ public class PlayerCharacter extends AbstractCharacter {
while (this.level < 10) { while (this.level < 10) {
grantXP(Experience.getBaseExperience(this.level + 1) - this.exp); grantXP(Experience.getBaseExperience(this.level + 1) - this.exp);
} }
if(this.charItemManager != null && this.charItemManager.getGoldInventory() != null && this.charItemManager.getGoldInventory().getNumOfItems() < 1000) { //if(this.charItemManager != null && this.charItemManager.getGoldInventory() != null && this.charItemManager.getGoldInventory().getNumOfItems() < 1000) {
this.getCharItemManager().addGoldToInventory(1000, false); // this.getCharItemManager().addGoldToInventory(1000, false);
this.getCharItemManager().addItemToInventory(new MobLoot(this, ItemBase.getItemBase(980066), 1, false).promoteToItem(this)); // this.getCharItemManager().addItemToInventory(new MobLoot(this, ItemBase.getItemBase(980066), 1, false).promoteToItem(this));
this.getCharItemManager().updateInventory(); // this.getCharItemManager().updateInventory();
} //}
} }
if(this.isBoxed && !this.containsEffect(1672601862)) { if(this.isBoxed && !this.containsEffect(1672601862)) {
+2 -2
View File
@@ -517,8 +517,8 @@ public class WorldServer {
Logger.info("Starting Bane Thread"); Logger.info("Starting Bane Thread");
BaneThread.startBaneThread(); BaneThread.startBaneThread();
Logger.info("Starting Player Update Thread"); //Logger.info("Starting Player Update Thread");
UpdateThread.startUpdateThread(); //UpdateThread.startUpdateThread();
printThreads(); printThreads();