AI Players as mobs
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
package engine.AiPlayers;
|
package engine.AiPlayers;
|
||||||
|
|
||||||
import engine.Enum;
|
import engine.Enum;
|
||||||
|
import engine.InterestManagement.InterestManager;
|
||||||
import engine.InterestManagement.WorldGrid;
|
import engine.InterestManagement.WorldGrid;
|
||||||
|
import engine.gameManager.LootManager;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.net.client.msg.VendorDialogMsg;
|
import engine.net.client.msg.VendorDialogMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
@@ -13,17 +15,17 @@ import java.util.Random;
|
|||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public class AiPlayer {
|
public class AiPlayer {
|
||||||
public PlayerCharacter emulated;
|
public Mob emulated;
|
||||||
|
|
||||||
//randomized constructor
|
//randomized constructor
|
||||||
//creates a random AI player to start at level 10 and progress throughout the game world
|
//creates a random AI player to start at level 10 and progress throughout the game world
|
||||||
public AiPlayer(){
|
public AiPlayer(){
|
||||||
PlayerCharacter emu = generateRandomPlayer();
|
Mob emu = generateRandomPlayer();
|
||||||
if(emu != null)
|
if(emu != null)
|
||||||
this.emulated = emu;
|
this.emulated = emu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerCharacter generateRandomPlayer(){
|
public static Mob generateRandomPlayer(){
|
||||||
Race race = AiPlayerManager.getRandomRace();
|
Race race = AiPlayerManager.getRandomRace();
|
||||||
if(race == null)
|
if(race == null)
|
||||||
return null;
|
return null;
|
||||||
@@ -40,34 +42,28 @@ public class AiPlayer {
|
|||||||
if(baseClass == null)
|
if(baseClass == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
PromotionClass promo = null;
|
City hamlet = AiPlayerManager.getRandomHamlet();
|
||||||
while (promo == null){
|
Vector3fImmutable loc = Vector3fImmutable.getRandomPointOnCircle(hamlet.getTOL().loc,30);
|
||||||
int promoId = ThreadLocalRandom.current().nextInt(2504,2526);
|
|
||||||
PromotionClass tempPromo = PromotionClass.GetPromtionClassFromCache(promoId);
|
Mob guard = Mob.createStrongholdMob(race.getRaceRuneID(), loc, Guild.getErrantGuild(),true,hamlet.getParent(),null,0, AiPlayerManager.generateFirstName(),10);
|
||||||
if(tempPromo.isAllowedRune(baseClass.getToken())){
|
|
||||||
promo = tempPromo;
|
if(guard != null){
|
||||||
}
|
guard.parentZone = hamlet.getParent();
|
||||||
|
guard.bindLoc = loc;
|
||||||
|
guard.setLoc(loc);
|
||||||
|
guard.StrongholdGuardian = true;
|
||||||
|
guard.runAfterLoad();
|
||||||
|
guard.setLevel((short)10);
|
||||||
|
guard.spawnTime = 1000000000;
|
||||||
|
guard.setFirstName(AiPlayerManager.generateFirstName());
|
||||||
|
guard.setLastName("Ai Player");
|
||||||
|
InterestManager.setObjectDirty(guard);
|
||||||
|
WorldGrid.addObject(guard,loc.x,loc.z);
|
||||||
|
WorldGrid.updateObject(guard);
|
||||||
|
guard.mobPowers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Account a = new Account();
|
return guard;
|
||||||
PlayerCharacter emulated = new PlayerCharacter(AiPlayerManager.generateFirstName(), "AI Player", (short) 0, (short) 0, (short) 0,
|
|
||||||
(short) 0, (short) 0, Guild.getErrantGuild(), (byte) 0, a, race, baseClass, (byte) 1, (byte) 1,
|
|
||||||
(byte) 1, (byte) 1, (byte) 1);
|
|
||||||
|
|
||||||
emulated.setPromotionClass(promo.getObjectUUID());
|
|
||||||
|
|
||||||
return emulated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void runAfterLoad(){
|
|
||||||
City hamlet = AiPlayerManager.getRandomHamlet();
|
|
||||||
Vector3fImmutable binder = Vector3fImmutable.getRandomPointOnCircle(hamlet.getTOL().loc,30);
|
|
||||||
this.emulated.bindLoc = binder;
|
|
||||||
WorldGrid.addObject(this.emulated,binder.x,binder.z);
|
|
||||||
this.emulated.setLoc(binder);
|
|
||||||
WorldGrid.updateObject(this.emulated);
|
|
||||||
this.emulated.removeEffectBySource(Enum.EffectSourceType.Invisibility,40,true);
|
|
||||||
this.emulated.removeEffectBySource(Enum.EffectSourceType.Invulnerability,40,true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package engine.AiPlayers;
|
package engine.AiPlayers;
|
||||||
|
|
||||||
import engine.objects.City;
|
import engine.objects.City;
|
||||||
|
import engine.objects.Mob;
|
||||||
import engine.objects.Race;
|
import engine.objects.Race;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -39,7 +40,6 @@ public class AiPlayerManager {
|
|||||||
if (aiPlayer != null) {
|
if (aiPlayer != null) {
|
||||||
if (aiPlayer.emulated != null) {
|
if (aiPlayer.emulated != null) {
|
||||||
AiPlayers.add(aiPlayer);
|
AiPlayers.add(aiPlayer);
|
||||||
aiPlayer.runAfterLoad();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
@@ -64,4 +64,8 @@ public class AiPlayerManager {
|
|||||||
return City.getCity(hamletIds[RANDOM.nextInt(hamletIds.length)]);
|
return City.getCity(hamletIds[RANDOM.nextInt(hamletIds.length)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void runAi(Mob mob){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package engine.mobileAI.Threads;
|
package engine.mobileAI.Threads;
|
||||||
|
|
||||||
|
import engine.AiPlayers.AiPlayerManager;
|
||||||
import engine.gameManager.ConfigManager;
|
import engine.gameManager.ConfigManager;
|
||||||
import engine.mobileAI.MobAI;
|
import engine.mobileAI.MobAI;
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
@@ -33,7 +34,11 @@ public class MobAIThread implements Runnable{
|
|||||||
for (Mob mob : zone.zoneMobSet) {
|
for (Mob mob : zone.zoneMobSet) {
|
||||||
try {
|
try {
|
||||||
if (mob != null) {
|
if (mob != null) {
|
||||||
MobAI.DetermineAction(mob);
|
if(mob.StrongholdGuardian){
|
||||||
|
AiPlayerManager.runAi(mob);
|
||||||
|
}else {
|
||||||
|
MobAI.DetermineAction(mob);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error("Error processing Mob [Name: {}, UUID: {}]", mob.getName(), mob.getObjectUUID(), e);
|
Logger.error("Error processing Mob [Name: {}, UUID: {}]", mob.getName(), mob.getObjectUUID(), e);
|
||||||
|
|||||||
@@ -515,8 +515,8 @@ public class WorldServer {
|
|||||||
Logger.info("Running garbage collection...");
|
Logger.info("Running garbage collection...");
|
||||||
System.gc();
|
System.gc();
|
||||||
|
|
||||||
//Logger.info("Spawning AI Players...");
|
Logger.info("Spawning AI Players...");
|
||||||
//AiPlayerManager.init();
|
AiPlayerManager.init();
|
||||||
|
|
||||||
Logger.info("Starting Bane Thread");
|
Logger.info("Starting Bane Thread");
|
||||||
BaneThread.startBaneThread();
|
BaneThread.startBaneThread();
|
||||||
|
|||||||
Reference in New Issue
Block a user