forked from MagicBane/Server
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
6.0 KiB
140 lines
6.0 KiB
2 months ago
|
package engine;
|
||
|
|
||
|
import engine.InterestManagement.WorldGrid;
|
||
|
import engine.gameManager.BuildingManager;
|
||
|
import engine.gameManager.ChatManager;
|
||
|
import engine.math.Vector3fImmutable;
|
||
|
import engine.objects.*;
|
||
|
import engine.server.MBServerStatics;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Random;
|
||
|
import java.util.concurrent.ThreadLocalRandom;
|
||
|
|
||
|
public class PlayerAi {
|
||
|
public static ArrayList<PlayerCharacter> ai_players = new ArrayList<>();
|
||
|
|
||
|
public static void addPlayer(PlayerCharacter pc){
|
||
|
ai_players.add(pc);
|
||
|
int index = ai_players.indexOf(pc);
|
||
|
pc.setObjectUUID(MBServerStatics.NO_DB_ROW_ASSIGNED_YET - (1 + index));
|
||
|
}
|
||
|
|
||
|
public static void populate_world(){
|
||
|
for(Mine mine : Mine.getMines()){
|
||
|
Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID());
|
||
|
if(tower != null){
|
||
|
for(int i = 0; i < mine.capSize; i++){
|
||
|
addPlayer(createPlayer(tower));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static PlayerCharacter createPlayer(Building tower){
|
||
|
|
||
|
Vector3fImmutable loc = Vector3fImmutable.getRandomPointOnCircle(tower.loc,40f);
|
||
|
|
||
|
//get random race
|
||
|
Race race = null;
|
||
|
while(race == null) {
|
||
|
int raceId = ThreadLocalRandom.current().nextInt(1999, 2030);
|
||
|
while (raceId == 2021 || raceId == 2020 || raceId == 2019 || raceId == 2018) {
|
||
|
raceId = ThreadLocalRandom.current().nextInt(1999, 2030);
|
||
|
}
|
||
|
race = Race.getRace(raceId);
|
||
|
}
|
||
|
|
||
|
|
||
|
//get random baseClass
|
||
|
BaseClass baseClass = null;
|
||
|
while(baseClass == null) {
|
||
|
int baseId = ThreadLocalRandom.current().nextInt(2499, 2505);
|
||
|
BaseClass temp = BaseClass.getBaseClass(baseId);
|
||
|
if (temp == null || !race.getValidBaseClasses().contains(temp)) {
|
||
|
continue;
|
||
|
}
|
||
|
baseClass = BaseClass.getBaseClass(baseId);
|
||
|
}
|
||
|
|
||
|
PlayerCharacter newPLayer = new PlayerCharacter("", "AI POWERED", (short) 5, (short) 5, (short) 5, (short) 5,
|
||
|
(short) 5, Guild.getGuild(5), (byte) 0, (Account) null, race, baseClass
|
||
|
, (byte) 1, (byte) 1,
|
||
|
(byte) 1, (byte) 1, (byte) 1);
|
||
|
|
||
|
newPLayer.runAfterLoad();
|
||
|
|
||
|
if(newPLayer.isMale()) {
|
||
|
newPLayer.setFirstName(getMaleName());
|
||
|
}else {
|
||
|
newPLayer.setFirstName(getFemaleName());
|
||
|
}
|
||
|
|
||
|
newPLayer.setLevel((short)10);
|
||
|
|
||
|
PromotionClass promo = null;
|
||
|
while(promo == null){
|
||
|
int promoId = ThreadLocalRandom.current().nextInt(2508,2526);
|
||
|
PromotionClass temp = PromotionClass.GetPromtionClassFromCache(promoId);
|
||
|
if(temp == null)
|
||
|
continue;
|
||
|
if(!temp.isAllowedRune(race.getToken()))
|
||
|
continue;
|
||
|
if(!temp.isAllowedRune(baseClass.getToken()))
|
||
|
continue;
|
||
|
promo = PromotionClass.GetPromtionClassFromCache(promoId);
|
||
|
}
|
||
|
newPLayer.setPromotionClass(promo.getObjectUUID());
|
||
|
newPLayer.setLevel((short)75);
|
||
|
|
||
|
newPLayer.setLoc(loc);
|
||
|
|
||
|
newPLayer.setObjectTypeMask(MBServerStatics.MASK_PLAYER);
|
||
|
WorldGrid.addObject(newPLayer,loc.x,loc.z);
|
||
|
|
||
|
return newPLayer;
|
||
|
}
|
||
|
|
||
|
public static void run_ai_players() {
|
||
|
for (PlayerCharacter pc : ai_players) {
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static String getMaleName(){
|
||
|
String[] maleNames = {
|
||
|
"James", "John", "Robert", "Michael", "William", "David", "Richard", "Joseph", "Thomas", "Charles",
|
||
|
"Christopher", "Daniel", "Matthew", "Anthony", "Mark", "Donald", "Steven", "Paul", "Andrew", "Joshua",
|
||
|
"Kenneth", "Kevin", "Brian", "George", "Edward", "Ronald", "Timothy", "Jason", "Jeffrey", "Ryan",
|
||
|
"Jacob", "Gary", "Nicholas", "Eric", "Jonathan", "Stephen", "Larry", "Justin", "Scott", "Brandon",
|
||
|
"Benjamin", "Samuel", "Gregory", "Alexander", "Patrick", "Frank", "Raymond", "Jack", "Dennis", "Jerry",
|
||
|
"Tyler", "Aaron", "Jose", "Adam", "Nathan", "Henry", "Douglas", "Zachary", "Peter", "Kyle",
|
||
|
"Walter", "Ethan", "Jeremy", "Harold", "Keith", "Christian", "Roger", "Noah", "Gerald", "Carl",
|
||
|
"Terry", "Sean", "Austin", "Arthur", "Lawrence", "Jesse", "Dylan", "Bryan", "Joe", "Jordan",
|
||
|
"Billy", "Bruce", "Albert", "Willie", "Gabriel", "Logan", "Alan", "Juan", "Wayne", "Roy",
|
||
|
"Ralph", "Randy", "Eugene", "Vincent", "Russell", "Louis", "Philip", "Bobby", "Johnny", "Bradley"
|
||
|
};
|
||
|
|
||
|
Random random = new Random();
|
||
|
return maleNames[random.nextInt(maleNames.length)];
|
||
|
}
|
||
|
|
||
|
public static String getFemaleName(){
|
||
|
String[] femaleNames = {
|
||
|
"Mary", "Patricia", "Jennifer", "Linda", "Elizabeth", "Barbara", "Susan", "Jessica", "Sarah", "Karen",
|
||
|
"Nancy", "Lisa", "Betty", "Margaret", "Sandra", "Ashley", "Kimberly", "Emily", "Donna", "Michelle",
|
||
|
"Carol", "Amanda", "Melissa", "Deborah", "Stephanie", "Rebecca", "Laura", "Sharon", "Cynthia", "Kathleen",
|
||
|
"Amy", "Shirley", "Angela", "Helen", "Anna", "Brenda", "Pamela", "Nicole", "Samantha", "Katherine",
|
||
|
"Christine", "Debra", "Rachel", "Catherine", "Carolyn", "Janet", "Ruth", "Maria", "Heather", "Diane",
|
||
|
"Virginia", "Julie", "Joyce", "Victoria", "Kelly", "Christina", "Lauren", "Joan", "Evelyn", "Judith",
|
||
|
"Olivia", "Frances", "Martha", "Cheryl", "Megan", "Andrea", "Hannah", "Jacqueline", "Ann", "Gloria",
|
||
|
"Jean", "Kathryn", "Alice", "Teresa", "Sara", "Janice", "Doris", "Madison", "Julia", "Grace",
|
||
|
"Judy", "Abigail", "Marie", "Denise", "Beverly", "Amber", "Theresa", "Marilyn", "Danielle", "Diana",
|
||
|
"Brittany", "Natalie", "Sophia", "Rose", "Isabella", "Alexis", "Kayla", "Charlotte", "Faith", "Alyssa"
|
||
|
};
|
||
|
|
||
|
Random random = new Random();
|
||
|
return femaleNames[random.nextInt(femaleNames.length)];
|
||
|
}
|
||
|
}
|