forked from MagicBane/Server
				
			
				 5 changed files with 1 additions and 162 deletions
			
			
		| @ -1,74 +0,0 @@@@ -1,74 +0,0 @@ | ||||
| package engine.AiPlayers; | ||||
| 
 | ||||
| import engine.Enum; | ||||
| import engine.InterestManagement.InterestManager; | ||||
| import engine.InterestManagement.WorldGrid; | ||||
| import engine.gameManager.LootManager; | ||||
| import engine.math.Vector3fImmutable; | ||||
| import engine.net.client.msg.VendorDialogMsg; | ||||
| import engine.objects.*; | ||||
| 
 | ||||
| import java.sql.ResultSet; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Random; | ||||
| import java.util.concurrent.ThreadLocalRandom; | ||||
| 
 | ||||
| public class AiPlayer { | ||||
|     public Mob emulated; | ||||
| 
 | ||||
|     //randomized constructor
 | ||||
|     //creates a random AI player to start at level 10 and progress throughout the game world
 | ||||
|     public AiPlayer(){ | ||||
|         Mob emu = generateRandomPlayer(); | ||||
|         if(emu != null) | ||||
|             this.emulated = emu; | ||||
|     } | ||||
| 
 | ||||
|     public static Mob generateRandomPlayer(){ | ||||
|         Race race = AiPlayerManager.getRandomRace(); | ||||
|         if(race == null) | ||||
|             return null; | ||||
| 
 | ||||
|         BaseClass baseClass = null; | ||||
| 
 | ||||
|         List<BaseClass> validClasses = race.getValidBaseClasses(); | ||||
|         if (!validClasses.isEmpty()) { | ||||
|             Random random = new Random(); | ||||
|             baseClass = validClasses.get(random.nextInt(validClasses.size())); | ||||
|             // Use randomClass here
 | ||||
|         } | ||||
| 
 | ||||
|         if(baseClass == null) | ||||
|             return null; | ||||
| 
 | ||||
|         City hamlet = AiPlayerManager.getRandomHamlet(); | ||||
|         Vector3fImmutable loc = Vector3fImmutable.getRandomPointOnCircle(hamlet.getTOL().loc,30); | ||||
| 
 | ||||
|         Mob guard = Mob.createStrongholdMob(race.getRaceRuneID(), loc, Guild.getErrantGuild(),true,hamlet.getParent(),null,0, AiPlayerManager.generateFirstName(),10); | ||||
| 
 | ||||
|         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(); | ||||
|         } | ||||
| 
 | ||||
|         return guard; | ||||
|     } | ||||
| 
 | ||||
|     public void update(){ | ||||
|         this.emulated.update(true); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| @ -1,71 +0,0 @@@@ -1,71 +0,0 @@ | ||||
| package engine.AiPlayers; | ||||
| 
 | ||||
| import engine.objects.City; | ||||
| import engine.objects.Mob; | ||||
| import engine.objects.Race; | ||||
| import org.pmw.tinylog.Logger; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import java.util.Random; | ||||
| import java.util.concurrent.ThreadLocalRandom; | ||||
| 
 | ||||
| public class AiPlayerManager { | ||||
| 
 | ||||
|     public static ArrayList<AiPlayer> AiPlayers = new ArrayList<>(); | ||||
|     public static int totalPlayers = 100; | ||||
| 
 | ||||
|     private static final List<String> GENDER_NEUTRAL_NAMES = Arrays.asList( | ||||
|             "Alex", "Andy", "Avery", "Bailey", "Blake", "Cameron", "Casey", "Charlie", "Dakota", "Dallas", | ||||
|             "Devin", "Drew", "Elliot", "Emerson", "Finley", "Frankie", "Gray", "Harley", "Hayden", "Hunter", | ||||
|             "Jackie", "Jamie", "Jay", "Jessie", "Jordan", "Jules", "Kai", "Keegan", "Kendall", "Lane", | ||||
|             "Leighton", "Lennon", "Lennox", "Logan", "Mackenzie", "Marley", "Mason", "Micah", "Morgan", "Nico", | ||||
|             "Noel", "Oakley", "Parker", "Payton", "Phoenix", "Quinn", "Reagan", "Reese", "Remy", "Riley", | ||||
|             "River", "Robin", "Rowan", "Rory", "Ryan", "Sage", "Sam", "Sawyer", "Shay", "Shiloh", | ||||
|             "Sky", "Skyler", "Spencer", "Stevie", "Sydney", "Tatum", "Taylor", "Toby", "Toni", "Tyler", | ||||
|             "Val", "Wesley", "Winter", "Zephyr", "Arden", "Aspen", "Blaine", "Briar", "Brook", "Camdyn", | ||||
|             "Chandler", "Corey", "Denver", "Devon", "Eden", "Ellis", "Emory", "Ever", "Everest", "Fallon", | ||||
|             "Flynn", "Indigo", "Justice", "Karter", "Kyrie", "Lex", "Lyric", "Monroe", "Peyton", "Sterling" | ||||
|     ); | ||||
| 
 | ||||
|     private static final int[] hamletIds = {36105, 36245, 36423, 36562, 36661, 39049}; | ||||
| 
 | ||||
|     private static final Random RANDOM = new Random(); | ||||
| 
 | ||||
|     public static void init(){ | ||||
|         while(AiPlayers.size() < totalPlayers){ | ||||
|             try { | ||||
|                 AiPlayer aiPlayer = new AiPlayer(); | ||||
|                 if (aiPlayer != null) { | ||||
|                     if (aiPlayer.emulated != null) { | ||||
|                         AiPlayers.add(aiPlayer); | ||||
|                     } | ||||
|                 } | ||||
|             }catch(Exception e){ | ||||
|                 Logger.error(e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     public static String generateFirstName(){ | ||||
|         return GENDER_NEUTRAL_NAMES.get(RANDOM.nextInt(GENDER_NEUTRAL_NAMES.size())); | ||||
|     } | ||||
| 
 | ||||
|     public static Race getRandomRace(){ | ||||
|         int RaceId = ThreadLocalRandom.current().nextInt(1999,2029); | ||||
|         while (RaceId == 2020 || RaceId == 2021 || RaceId == 2018 || RaceId == 2019){ | ||||
|             RaceId = ThreadLocalRandom.current().nextInt(1999,2029); | ||||
|         } | ||||
|         Race race = Race.getRace(RaceId); | ||||
|         return race; | ||||
|     } | ||||
| 
 | ||||
|     public static City getRandomHamlet() { | ||||
|         return City.getCity(hamletIds[RANDOM.nextInt(hamletIds.length)]); | ||||
|     } | ||||
| 
 | ||||
|     public static void runAi(Mob mob){ | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
					Loading…
					
					
				
		Reference in new issue