diff --git a/scripts/mobiles/generic/faction/imperial/elite_imperial_stormtrooper_90.py b/scripts/mobiles/generic/faction/imperial/elite_imperial_stormtrooper_90.py new file mode 100644 index 00000000..e1fa305b --- /dev/null +++ b/scripts/mobiles/generic/faction/imperial/elite_imperial_stormtrooper_90.py @@ -0,0 +1,43 @@ +import sys +from services.spawn import MobileTemplate +from services.spawn import WeaponTemplate +from resources.datatables import WeaponType +from resources.datatables import Difficulty +from resources.datatables import Options +from resources.datatables import FactionStatus +from java.util import Vector + + +def addTemplate(core): + mobileTemplate = MobileTemplate() + + mobileTemplate.setCreatureName('crackdown_stormtrooper_hard') + mobileTemplate.setLevel(90) + mobileTemplate.setDifficulty(Difficulty.ELITE) + + mobileTemplate.setMinSpawnDistance(4) + mobileTemplate.setMaxSpawnDistance(8) + mobileTemplate.setDeathblow(True) + mobileTemplate.setSocialGroup("imperial") + mobileTemplate.setAssistRange(0) + mobileTemplate.setStalker(False) + mobileTemplate.setFaction("imperial") + mobileTemplate.setFactionStatus(FactionStatus.Combatant) + + templates = Vector() + templates.add('object/mobile/shared_dressed_stormtrooper_black_white.iff') + templates.add('object/mobile/shared_dressed_stormtrooper_white_black.iff') + templates.add('object/mobile/shared_dressed_stormtrooper_white_white.iff') + mobileTemplate.setTemplates(templates) + + weaponTemplates = Vector() + weapontemplate = WeaponTemplate('object/weapon/ranged/carbine/shared_carbine_e11.iff', WeaponType.CARBINE, 1.0, 15, 'energy') + weaponTemplates.add(weapontemplate) + mobileTemplate.setWeaponTemplateVector(weaponTemplates) + + attacks = Vector() + mobileTemplate.setDefaultAttack('rangedShot') + mobileTemplate.setAttacks(attacks) + + core.spawnService.addMobileTemplate('elite_imperial_stormtrooper_90', mobileTemplate) + return \ No newline at end of file diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 91f182ae..5ecef37a 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -92,6 +92,7 @@ import services.command.CommandService; import services.equipment.EquipmentService; import services.gcw.FactionService; import services.gcw.GCWService; +import services.gcw.InvasionService; import services.GuildService; import services.LoginService; import services.map.MapService; @@ -211,6 +212,7 @@ public class NGECore { public PetService petService; public BrowserService browserService; //public BattlefieldService battlefieldService; + public InvasionService invasionService; // Login Server public NetworkDispatch loginDispatch; @@ -370,6 +372,7 @@ public class NGECore { spawnService = new SpawnService(this); aiService = new AIService(this); missionService = new MissionService(this); + invasionService = new InvasionService(this); if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") == 1) { surveyService = new SurveyService(this); @@ -430,6 +433,7 @@ public class NGECore { zoneDispatch.addService(staticService); zoneDispatch.addService(reverseEngineeringService); zoneDispatch.addService(petService); + zoneDispatch.addService(invasionService); if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") == 1) { zoneDispatch.addService(surveyService); diff --git a/src/services/DevService.java b/src/services/DevService.java index e43ceb89..09025e2a 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -82,6 +82,8 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 3, "Locations"); if (System.getProperty("user.name").equals("Charon")) suiOptions.put((long) 4, "Treasure chest test"); + if (System.getProperty("user.name").equals("Charon")) + suiOptions.put((long) 6, "Dearic attack camp"); break; case 1: // Character suiOptions.put((long) 10, "Set combat level to 90"); @@ -214,6 +216,11 @@ public class DevService implements INetworkDispatch { //treasureContainer.add(droppedItem); return; + + case 6: // Locations + core.simulationService.transferToPlanet(player, core.terrainService.getPlanetByName("talus"), new Point3D(-124,6,-2958), player.getOrientation(), null); + core.invasionService.testPylons(); + return; // Character case 10: // Set combat level to 90 diff --git a/src/services/ai/AIActor.java b/src/services/ai/AIActor.java index 477dcd67..56eaa44d 100644 --- a/src/services/ai/AIActor.java +++ b/src/services/ai/AIActor.java @@ -86,6 +86,7 @@ public class AIActor { private ScheduledFuture movementFuture; private ScheduledFuture recoveryFuture; private ScheduledFuture despawnFuture; + private boolean patrolLoop = true; // default public AIActor(CreatureObject creature, Point3D spawnPosition, ScheduledExecutorService scheduler) { this.creature = creature; @@ -627,5 +628,13 @@ public class AIActor { Point3D lastPositionBeforeStateChange) { this.lastPositionBeforeStateChange = lastPositionBeforeStateChange; } + + public boolean isPatrolLoop() { + return patrolLoop; + } + + public void setPatrolLoop(boolean patrolLoop) { + this.patrolLoop = patrolLoop; + } } diff --git a/src/services/ai/AIService.java b/src/services/ai/AIService.java index b492da20..c1e24c7b 100644 --- a/src/services/ai/AIService.java +++ b/src/services/ai/AIService.java @@ -169,6 +169,13 @@ public class AIService { } } + public void setPatrolLoop(CreatureObject creature, boolean value){ + AIActor actor = (AIActor) creature.getAttachment("AI"); + if (actor==null) + return; + actor.setPatrolLoop(value); + } + public void setPatrol(CreatureObject creature, Vector patrolpoints){ AIActor actor = (AIActor) creature.getAttachment("AI"); if (actor==null) diff --git a/src/services/ai/states/AIState.java b/src/services/ai/states/AIState.java index 15d68dd5..f376517e 100644 --- a/src/services/ai/states/AIState.java +++ b/src/services/ai/states/AIState.java @@ -492,7 +492,10 @@ public abstract class AIState { if (actor.getPatrolPointIndex() + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.gcw; + +import java.util.Map; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; + +import resources.datatables.Factions; +import main.NGECore; +import engine.resources.common.CRC; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; + +public class InvasionService implements INetworkDispatch { + + private NGECore core; + private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + protected final Object objectMutex = new Object(); + + private long kerenInvasionStartTime = 1; + private long bestineInvasionStartTime = 2; + private long dearicInvasionStartTime = 3; + + private int invasionLocation=InvasionLocation.Dearic; + private int invasionPhase=2; // Test phase 2 + + public InvasionService(final NGECore core) { + this.core = core; + + + + } + + public void testPylons(){ + Quaternion quaternion = new Quaternion(0.28F,0F,0.95F,0F); + SoldierPatrolPylon pylon1 = (SoldierPatrolPylon) core.objectService.createObject("object/tangible/destructible/shared_gcw_city_construction_beacon.iff", 0, core.terrainService.getPlanetByName("talus"), new Point3D(-48, 4, -2798), quaternion); + pylon1.setPylonFaction(Factions.Imperial); + pylon1.setSpawnLevel(3); + } + + public void spawnGeneral(){ + Quaternion quaternion = new Quaternion(0.28F,0F,0.95F,0F); + SoldierPatrolPylon pylon1 = (SoldierPatrolPylon) core.objectService.createObject("object/tangible/destructible/shared_gcw_city_construction_beacon.iff", 0, core.terrainService.getPlanetByName("talus"), new Point3D(-48, 4, -2798), quaternion); + } + + public void spawnDefensiveQuestOfficer(){ + Quaternion quaternion = new Quaternion(0.28F,0F,0.95F,0F); + SoldierPatrolPylon pylon1 = (SoldierPatrolPylon) core.objectService.createObject("object/tangible/destructible/shared_gcw_city_construction_beacon.iff", 0, core.terrainService.getPlanetByName("talus"), new Point3D(-48, 4, -2798), quaternion); + } + + public void spawnOffensiveCamps(){ + Quaternion quaternion = new Quaternion(0.28F,0F,0.95F,0F); + SoldierPatrolPylon pylon1 = (SoldierPatrolPylon) core.objectService.createObject("object/tangible/destructible/shared_gcw_city_construction_beacon.iff", 0, core.terrainService.getPlanetByName("talus"), new Point3D(-48, 4, -2798), quaternion); + } + + @Override + public void shutdown() { + + } + @Override + public void insertOpcodes(Map arg0, + Map arg1) { + // TODO Auto-generated method stub + + } + + + // Test methods + public void buildPylon1(){ + + } + + public int getInvasionPhase() { + return invasionPhase; + } + + public void setInvasionPhase(int invasionPhase) { + this.invasionPhase = invasionPhase; + } + + public class InvasionLocation { + + public static final int Keren = 0; + public static final int Bestine = 1; + public static final int Dearic = 2; + + } + +} diff --git a/src/services/gcw/SoldierPatrolPylon.java b/src/services/gcw/SoldierPatrolPylon.java new file mode 100644 index 00000000..41003473 --- /dev/null +++ b/src/services/gcw/SoldierPatrolPylon.java @@ -0,0 +1,177 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.gcw; + +import java.util.Random; +import java.util.Vector; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; +import main.NGECore; +import resources.datatables.Factions; +import resources.objects.creature.CreatureObject; +import resources.objects.tangible.TangibleObject; + +/** + * @author Charon + */ + +public class SoldierPatrolPylon extends TangibleObject{ + + private static final long serialVersionUID = 1L; + private int pylonFaction = 0; + private int spawnLevel = 0; + private int totalSpawnedSoldiers = 0; + private String[] soldierTemplates = new String[]{""}; + private String[] rebelTemplates1 = new String[]{""}; + private String[] rebelTemplates2 = new String[]{""}; + private String[] rebelTemplates3 = new String[]{""}; + private String[] imperialTemplates1 = new String[]{""}; + private String[] imperialTemplates2 = new String[]{""}; + private String[] imperialTemplates3 = new String[]{"elite_imperial_stormtrooper_90"}; + private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + + public SoldierPatrolPylon() { + super(); + } + + public SoldierPatrolPylon(long objectID, Planet planet, Point3D position, Quaternion orientation, String template){ + super(objectID, planet, position, orientation, template); + + scheduler.scheduleAtFixedRate(new Runnable() { + @Override public void run() { + try { + spawnSoldier(); + } catch (Exception e) { + System.err.println("Exception in SoldierPatrolPylon->scheduleAtFixedRate->spawnSoldier() " + e.getMessage()); + } + } + }, 5, 20, TimeUnit.SECONDS); + + } + + public int getPylonFaction() { + return pylonFaction; + } + + public void setPylonFaction(int pylonFaction) { + this.pylonFaction = pylonFaction; + } + + public int getSpawnLevel() { + return spawnLevel; + } + + public void setSpawnLevel(int spawnLevel) { + this.spawnLevel = spawnLevel; + } + + public void spawnSoldier(){ + + if (NGECore.getInstance().invasionService.getInvasionPhase()==2){ + if (pylonFaction==Factions.Rebel){ + switch (spawnLevel) { + case 1: soldierTemplates = rebelTemplates1; + case 2: soldierTemplates = rebelTemplates2; + case 3: soldierTemplates = rebelTemplates3; + } + } + if (pylonFaction==Factions.Imperial){ + switch (spawnLevel) { + case 1: soldierTemplates = imperialTemplates1; + case 2: soldierTemplates = imperialTemplates2; + case 3: soldierTemplates = imperialTemplates3; + } + } + String soldierTemplate = soldierTemplates[new Random().nextInt(soldierTemplates.length)]; + CreatureObject soldier = (CreatureObject)NGECore.getInstance().spawnService.spawnCreature(soldierTemplate, this.getPlanet().getName(), 0L, this.getPosition().x, this.getPosition().y, this.getPosition().z, this.getOrientation().w, this.getOrientation().x, this.getOrientation().y,this.getOrientation().z,-1); + + NGECore.getInstance().aiService.setPatrol(soldier, get_Dearic_Route_1()); + NGECore.getInstance().aiService.setPatrolLoop(soldier,false); + totalSpawnedSoldiers++; + } + } + + public Vector get_Dearic_Route_1(){ + Vector patrolpoints = new Vector(); + patrolpoints.add(new Point3D(68.0F, 6.00F, -2959F)); + patrolpoints.add(new Point3D(151.93F,6.00F, -2961.66F)); + patrolpoints.add(new Point3D(170.18F, 6.00F, -2992.99F)); + patrolpoints.add(new Point3D(262.76F, 6.00F, -2999.76F)); + patrolpoints.add(new Point3D(275.87F, 6.00F, -3008.44F)); + patrolpoints.add(new Point3D(303.41F, 6.00F, -3005.19F)); + patrolpoints.add(new Point3D(343.31F, 6.00F, -2961.06F)); + patrolpoints.add(new Point3D(379.98F, 6.00F, -2963.31F)); + patrolpoints.add(new Point3D(404.70F, 6.00F, -2980.57F)); + patrolpoints.add(new Point3D(412.54F, 6.00F, -3039.39F)); + patrolpoints.add(new Point3D(423.06F, 6.00F, -3050.75F)); + patrolpoints.add(new Point3D(446.92F, 6.00F, -3046.32F)); + patrolpoints.add(new Point3D(470.48F, 6.00F, -3023.43F)); + return patrolpoints; + } + + public Vector get_Dearic_Route_2(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_3(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_4(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_5(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_6(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_7(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_8(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_9(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + + +} diff --git a/src/services/gcw/VehiclePatrolPylon.java b/src/services/gcw/VehiclePatrolPylon.java new file mode 100644 index 00000000..35da108d --- /dev/null +++ b/src/services/gcw/VehiclePatrolPylon.java @@ -0,0 +1,177 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.gcw; + +import java.util.Random; +import java.util.Vector; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; +import main.NGECore; +import resources.datatables.Factions; +import resources.objects.creature.CreatureObject; +import resources.objects.tangible.TangibleObject; + +/** + * @author Charon + */ + +public class VehiclePatrolPylon extends TangibleObject{ + + private static final long serialVersionUID = 1L; + private int pylonFaction = 0; + private int spawnLevel = 0; + private int totalSpawnedVehicles = 0; + private String[] vehicleTemplates = new String[]{""}; + private String[] rebelTemplates1 = new String[]{""}; + private String[] rebelTemplates2 = new String[]{""}; + private String[] rebelTemplates3 = new String[]{""}; + private String[] imperialTemplates1 = new String[]{""}; + private String[] imperialTemplates2 = new String[]{""}; + private String[] imperialTemplates3 = new String[]{"elite_imperial_stormtrooper_90"}; + private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + + public VehiclePatrolPylon() { + super(); + } + + public VehiclePatrolPylon(long objectID, Planet planet, Point3D position, Quaternion orientation, String template){ + super(objectID, planet, position, orientation, template); + + scheduler.scheduleAtFixedRate(new Runnable() { + @Override public void run() { + try { + spawnVehicle(); + } catch (Exception e) { + System.err.println("Exception in VehiclePatrolPylon->scheduleAtFixedRate->spawnVehicle() " + e.getMessage()); + } + } + }, 5, 20, TimeUnit.SECONDS); + + } + + public int getPylonFaction() { + return pylonFaction; + } + + public void setPylonFaction(int pylonFaction) { + this.pylonFaction = pylonFaction; + } + + public int getSpawnLevel() { + return spawnLevel; + } + + public void setSpawnLevel(int spawnLevel) { + this.spawnLevel = spawnLevel; + } + + public void spawnVehicle(){ + + if (NGECore.getInstance().invasionService.getInvasionPhase()==2){ + if (pylonFaction==Factions.Rebel){ + switch (spawnLevel) { + case 1: vehicleTemplates = rebelTemplates1; + case 2: vehicleTemplates = rebelTemplates2; + case 3: vehicleTemplates = rebelTemplates3; + } + } + if (pylonFaction==Factions.Imperial){ + switch (spawnLevel) { + case 1: vehicleTemplates = imperialTemplates1; + case 2: vehicleTemplates = imperialTemplates2; + case 3: vehicleTemplates = imperialTemplates3; + } + } + String vehicleTemplate = vehicleTemplates[new Random().nextInt(vehicleTemplates.length)]; + CreatureObject vehicle = (CreatureObject)NGECore.getInstance().spawnService.spawnCreature(vehicleTemplate, this.getPlanet().getName(), 0L, this.getPosition().x, this.getPosition().y, this.getPosition().z, this.getOrientation().w, this.getOrientation().x, this.getOrientation().y,this.getOrientation().z,-1); + + NGECore.getInstance().aiService.setPatrol(vehicle, get_Dearic_Route_1()); + NGECore.getInstance().aiService.setPatrolLoop(vehicle,false); + totalSpawnedVehicles++; + } + } + + public Vector get_Dearic_Route_1(){ + Vector patrolpoints = new Vector(); + patrolpoints.add(new Point3D(68.0F, 6.00F, -2959F)); + patrolpoints.add(new Point3D(151.93F,6.00F, -2961.66F)); + patrolpoints.add(new Point3D(170.18F, 6.00F, -2992.99F)); + patrolpoints.add(new Point3D(262.76F, 6.00F, -2999.76F)); + patrolpoints.add(new Point3D(275.87F, 6.00F, -3008.44F)); + patrolpoints.add(new Point3D(303.41F, 6.00F, -3005.19F)); + patrolpoints.add(new Point3D(343.31F, 6.00F, -2961.06F)); + patrolpoints.add(new Point3D(379.98F, 6.00F, -2963.31F)); + patrolpoints.add(new Point3D(404.70F, 6.00F, -2980.57F)); + patrolpoints.add(new Point3D(412.54F, 6.00F, -3039.39F)); + patrolpoints.add(new Point3D(423.06F, 6.00F, -3050.75F)); + patrolpoints.add(new Point3D(446.92F, 6.00F, -3046.32F)); + patrolpoints.add(new Point3D(470.48F, 6.00F, -3023.43F)); + return patrolpoints; + } + + public Vector get_Dearic_Route_2(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_3(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_4(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_5(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_6(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_7(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_8(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + public Vector get_Dearic_Route_9(){ + Vector patrolpoints = new Vector(); + return patrolpoints; + } + + + +} diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index a823a1ca..643160b8 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -130,6 +130,7 @@ import services.command.CombatCommand; import services.bazaar.AuctionItem; import services.chat.ChatRoom; import services.equipment.EquipmentService; +import services.gcw.SoldierPatrolPylon; import services.sui.SUIWindow; import services.sui.SUIWindow.SUICallback; import services.sui.SUIWindow.Trigger; @@ -278,6 +279,12 @@ public class ObjectService implements INetworkDispatch { object = new SurveyTool(objectID, planet, position, orientation, Template); + } else if(Template.startsWith("object/tangible/destructible/shared_gcw_city_construction_beacon")) { + + float positionY = core.terrainService.getHeight(planet.getID(), position.x, position.z)-1f; + Point3D newpoint = new Point3D(position.x,positionY,position.z); + object = new SoldierPatrolPylon(objectID, planet, position, orientation, Template); + } else if(Template.startsWith("object/tangible")) { object = new TangibleObject(objectID, planet, position, orientation, Template);