private void applyLootList(List<String> allowedItems, List<String> allowedWeapons, Ai ai) { ai.setWeapon( Weapon.stringToWeapon(allowedWeapons.get(new Random().nextInt(allowedWeapons.size())))); int randomItemCount = new Random().nextInt(5); if (allowedItems.size() > 0) { boolean hasArmour = false; for (int i = 0; i < randomItemCount; i++) { String item = allowedItems.get(new Random().nextInt(allowedItems.size())); if (item != null && (!(item.equals(ArmourPlates1.NAME) || item.equals(ArmourPlates2.NAME)) || !hasArmour) && (!ai.getInventory().hasItem(Item.stringToItem(item)))) { ai.addItem(Item.stringToItem(item)); if (item.equals(ArmourPlates1.NAME) || item.equals(ArmourPlates2.NAME)) hasArmour = true; } } } }
private void generatePlayerTeam(ArrayList<Squaddie> squad, LevelBlock levelBlock) { double[] randomLocation = levelManager.randomInPosition(levelBlock); for (int i = 0; i < squad.size(); i++) { Ai ai = null; AiImage aiImg = null; if (squad.get(i).isVehicle()) { aiImg = new VehicleImage( aiCrowd, combatMembersManager, combatUiManager, combatVisualManager, panningManager, 100, 100, mouseAbilityHandler, floatingIcons); switch (squad.get(i).getVehicleType()) { case MuleAi.MULE: ai = new MuleAi( panningManager, floatingIcons, mouseAbilityHandler, squad.get(i).getName(), randomLocation[0], randomLocation[1], combatInorganicManager, levelManager, lootbox, combatMembersManager, combatUiManager, combatVisualManager, aiCrowd, turnProcess); break; } ai.setImage(squad.get(i).getImage()); ai.setTeam("1Player"); } else { aiImg = new AiImage( aiCrowd, combatMembersManager, combatUiManager, combatVisualManager, panningManager, 100, 100, mouseAbilityHandler, floatingIcons); ai = new Ai( floatingIcons, mouseAbilityHandler, squad.get(i).getName(), randomLocation[0], randomLocation[1], combatInorganicManager, levelManager, lootbox, combatMembersManager, combatUiManager, combatVisualManager, aiCrowd, panningManager, turnProcess); ai.setImage(squad.get(i).getImage()); ai.setTeam("1Player"); } Iterator<String> skillIt = squad.get(i).getSkills(); while (skillIt.hasNext()) { String next = skillIt.next(); ai.setSkill(next, squad.get(i).getSkillLevel(next)); } ai.setWeapon(Weapon.stringToWeapon(squad.get(i).getWeapon())); Iterator<String> itemIt = squad.get(i).getItems(); while (itemIt.hasNext()) { ai.addItem(Item.stringToItem(itemIt.next())); } ai.assignAbilities(); aiImg.setAi(ai); aiCrowd.addDisplayItem(aiImg); aiCrowd.addMouseActionItem(aiImg); aiCrowd.addActor(ai, new DirectorClassification(DirectorArchetype.PLAYER)); aiCrowd.addMask(aiImg); randomLocation = levelManager.randomInPosition(levelBlock); combatMembersManager.addAi(ai); } }
private void generateSoloAi(SoloGenerateCommand command, int team) { double[] location = null; if (command.x == null && !command.getFaction().equals(AiGenerator.LONER)) location = levelManager.randomInPosition( combatMembersManager.getCommander(command.getFaction()).getSpawnRoom()); else if (command.x == null && command.getFaction().equals(AiGenerator.LONER)) location = levelManager.randomPosition(); else location = new double[] {command.x, command.y}; AiImage aiImg = new AiImage( aiCrowd, combatMembersManager, combatUiManager, combatVisualManager, panningManager, 0, 0, mouseAbilityHandler, floatingIcons); ThinkingAi ai = null; DialoguePool dialoguePool = new DialoguePool(command.getFaction(), missionManager, cartographer, messageBox); switch (command.getFaction()) { case AiGenerator.LONER: if (command.isDaemon()) { ai = new DaemonAi( panningManager, combatVisualManager, turnProcess, floatingIcons, mouseAbilityHandler, aiCrowd, combatMembersManager, command.getName(), location[0], location[1], levelManager, combatInorganicManager, combatUiManager, lootbox, dialoguePool); ai.setBaseAggression(ThinkingAiEmotion.MINDLESS_TERROR); aiImg = new DaemonImage( aiCrowd, combatMembersManager, combatUiManager, combatVisualManager, panningManager, location[0], location[1], mouseAbilityHandler, floatingIcons); } else { ai = new LonerAi( panningManager, aiCrowd, combatVisualManager, turnProcess, floatingIcons, mouseAbilityHandler, combatMembersManager, command.getName(), location[0], location[1], levelManager, combatInorganicManager, combatUiManager, lootbox, dialoguePool); ai.setBaseAggression(ThinkingAiEmotion.PASSIVE_RESPOND); ai.setImage(randomImage()); } ai.setTeam(team + LONER); break; case AiGenerator.WHITE_VISTA: ai = new ThinkingAi( dialoguePool, panningManager, combatVisualManager, turnProcess, floatingIcons, mouseAbilityHandler, aiCrowd, combatMembersManager, command.getName(), location[0], location[1], levelManager, combatInorganicManager, combatUiManager, lootbox); ai.setBaseAggression(ThinkingAiEmotion.PASSIVE_RESPOND); ai.setImage("Armour"); ai.setTeam(team + WHITE_VISTA); break; case AiGenerator.BANDITS: ai = new ThinkingAi( dialoguePool, panningManager, combatVisualManager, turnProcess, floatingIcons, mouseAbilityHandler, aiCrowd, combatMembersManager, command.getName(), location[0], location[1], levelManager, combatInorganicManager, combatUiManager, lootbox); ai.setBaseAggression(ThinkingAiEmotion.AGGRESSIVE_FIGHTER); ai.setImage("Bandit"); ai.setTeam(team + BANDITS); break; } if (command.isDaemon()) { ai.setWeapon(new DaemonWeapon()); } else { ai.setWeapon(Weapon.stringToWeapon(command.getWeapon())); if (command.getItems() != null) for (int i = 0; i < command.getItems().length; i++) { ai.addItem(Item.stringToItem(command.getItems()[i])); } } ai.assignAbilities(); aiImg.setAi(ai); aiCrowd.addDisplayItem(aiImg); aiCrowd.addMouseActionItem(aiImg); aiCrowd.addActor(ai, new DirectorClassification(command.directorClass)); aiCrowd.addMask(aiImg); if (command.getAiNode() != null) { List<String> priority = new ArrayList<String>(1); priority.add(ai.getName()); command.getAiNode().addPriorities(priority); ai.setAiNode(command.getAiNode()); } combatMembersManager.addAi(ai); String[] alliances = command.getAlliances(); if (alliances != null) for (int i = 0; i < alliances.length; i++) { ai.getCommander().addAlliance(alliances[i]); } }