From 2e3879321bf6173a14a2cdba613e5001c46ce598 Mon Sep 17 00:00:00 2001 From: darkk1138 Date: Fri, 29 Nov 2013 23:14:18 +0100 Subject: [PATCH 01/23] temp commit for ent stuff --- scripts/commands/startdance.py | 52 ++++ .../CommandEnqueue.java | 9 + src/resources/common/Performance.java | 245 ++++++++++++++++++ src/services/EntertainmentService.java | 95 +++++++ src/services/object/ObjectService.java | 5 +- 5 files changed, 405 insertions(+), 1 deletion(-) create mode 100644 scripts/commands/startdance.py create mode 100644 src/resources/common/Performance.java diff --git a/scripts/commands/startdance.py b/scripts/commands/startdance.py new file mode 100644 index 00000000..6a08bf7a --- /dev/null +++ b/scripts/commands/startdance.py @@ -0,0 +1,52 @@ +from services.sui import SUIWindow +from services.sui import SUIService +from services.sui.SUIWindow import Trigger +from services.sui.SUIService import ListBoxType +from java.util import Vector +from java.util import HashMap +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + + entSvc = core.entertainmentService + + if len(commandString) > 0: + params = commandString.split(" ") + startDance(core, actor, params[0]) + return + else: + + available_dances = entSvc.getAvailableDances(actor) + + suiSvc = core.suiService + suiWindow = suiSvc.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "@performance:select_dance", "@performance:available_dances", available_dances, actor, actor, 10) + + returnParams = Vector() + returnParams.add('btnOk:Text') + returnParams.add('btnCancel:Text') + suiWindow.addHandler(0, '', Trigger.TRIGGER_OK, returnParams, handleStartdance) + suiWindow.addHandler(1, '', Trigger.TRIGGER_CANCEL, returnParams, handleStartdance) + + suiSvc.openSUIWindow(suiWindow) + return + return + + +def handleStartdance(core, owner, eventType, returnList): + return + +def startDance(core, actor, danceName): + + entSvc = core.entertainmentService + + if not entSvc.isDance(danceName): + actor.sendSystemMessage('@performance:dance_unknown_self',0) + return + + if not entSvc.canDance(actor, danceName): + actor.sendSystemMessage('@performance:dance_lack_skill_self',0) + return + return diff --git a/src/protocol/swg/objectControllerObjects/CommandEnqueue.java b/src/protocol/swg/objectControllerObjects/CommandEnqueue.java index 40b228a6..bb1705a4 100644 --- a/src/protocol/swg/objectControllerObjects/CommandEnqueue.java +++ b/src/protocol/swg/objectControllerObjects/CommandEnqueue.java @@ -39,6 +39,15 @@ public class CommandEnqueue extends ObjControllerObject { public static final int STAND = 0xA8A25C79; public static final int ATTACK = 0xA8FEF90A; public static final int TRANSFERITEM = 0x3CFB449D; + + //ent + // this really needed? + public static final int STARTDANCE = 0x7B1DCBE0; + public static final int STOPDANCE = 0xECC171CC; + public static final int FLOURISH = 0xC8998CE9; + public static final int FLO = 0x3B159B76; + public static final int BANDFLOURISH = 0xF4C60EC3; + public static final int BANDFLO = 0xDD3FB008; private int actionCounter; private int commandCRC; diff --git a/src/resources/common/Performance.java b/src/resources/common/Performance.java new file mode 100644 index 00000000..42e40469 --- /dev/null +++ b/src/resources/common/Performance.java @@ -0,0 +1,245 @@ +package resources.common; + +public class Performance { + + + private String performanceName; + private int instrumentAudioId; + private String requiredSong; + private String requiredInstrument; + private String requiredDance; + private int danceVisualId; + private int actionPointsPerLoop; + private float loopDuration; + private int type; + private int baseXp; + private int flourishXpMod; + private int healMindWound; + private int healShockWound; + private String requiredSkillMod; + private int requiredSkillModValue; + private String mainloop; + private String flourish1; + private String flourish2; + private String flourish3; + private String flourish4; + private String flourish5; + private String flourish6; + private String flourish7; + private String flourish8; + private String intro; + private String outro; + + public Performance() { + + } + + public int getBaseXp() { + return baseXp; + } + + public void setBaseXp(int baseXp) { + this.baseXp = baseXp; + } + + public String getPerformanceName() { + return performanceName; + } + + public void setPerformanceName(String performanceName) { + this.performanceName = performanceName; + } + + public int getInstrumentAudioId() { + return instrumentAudioId; + } + + public void setInstrumentAudioId(int instrumentAudioId) { + this.instrumentAudioId = instrumentAudioId; + } + + public int getRequiredSkillModValue() { + return requiredSkillModValue; + } + + public void setRequiredSkillModValue(int requiredSkillModValue) { + this.requiredSkillModValue = requiredSkillModValue; + } + + public String getRequiredSong() { + return requiredSong; + } + + public void setRequiredSong(String requiredSong) { + this.requiredSong = requiredSong; + } + + public String getRequiredInstrument() { + return requiredInstrument; + } + + public void setRequiredInstrument(String requiredInstrument) { + this.requiredInstrument = requiredInstrument; + } + + public String getRequiredDance() { + return requiredDance; + } + + public void setRequiredDance(String requiredDance) { + this.requiredDance = requiredDance; + } + + public int getDanceVisualId() { + return danceVisualId; + } + + public void setDanceVisualId(int danceVisualId) { + this.danceVisualId = danceVisualId; + } + + public int getActionPointsPerLoop() { + return actionPointsPerLoop; + } + + public void setActionPointsPerLoop(int actionPointsPerLoop) { + this.actionPointsPerLoop = actionPointsPerLoop; + } + + public float getLoopDuration() { + return loopDuration; + } + + public void setLoopDuration(float loopDuration) { + this.loopDuration = loopDuration; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public int getFlourishXpMod() { + return flourishXpMod; + } + + public void setFlourishXpMod(int flourishXpMod) { + this.flourishXpMod = flourishXpMod; + } + + public int getHealMindWound() { + return healMindWound; + } + + public void setHealMindWound(int healMindWound) { + this.healMindWound = healMindWound; + } + + public int getHealShockWound() { + return healShockWound; + } + + public void setHealShockWound(int healShockWound) { + this.healShockWound = healShockWound; + } + + public String getRequiredSkillMod() { + return requiredSkillMod; + } + + public void setRequiredSkillMod(String requiredSkillMod) { + this.requiredSkillMod = requiredSkillMod; + } + + public String getMainloop() { + return mainloop; + } + + public void setMainloop(String mainloop) { + this.mainloop = mainloop; + } + + public String getFlourish1() { + return flourish1; + } + + public void setFlourish1(String flourish1) { + this.flourish1 = flourish1; + } + + public String getFlourish2() { + return flourish2; + } + + public void setFlourish2(String flourish2) { + this.flourish2 = flourish2; + } + + public String getFlourish3() { + return flourish3; + } + + public void setFlourish3(String flourish3) { + this.flourish3 = flourish3; + } + + public String getFlourish4() { + return flourish4; + } + + public void setFlourish4(String flourish4) { + this.flourish4 = flourish4; + } + + public String getFlourish5() { + return flourish5; + } + + public void setFlourish5(String flourish5) { + this.flourish5 = flourish5; + } + + public String getFlourish6() { + return flourish6; + } + + public void setFlourish6(String flourish6) { + this.flourish6 = flourish6; + } + + public String getFlourish7() { + return flourish7; + } + + public void setFlourish7(String flourish7) { + this.flourish7 = flourish7; + } + + public String getFlourish8() { + return flourish8; + } + + public void setFlourish8(String flourish8) { + this.flourish8 = flourish8; + } + + public String getIntro() { + return intro; + } + + public void setIntro(String intro) { + this.intro = intro; + } + + public String getOutro() { + return outro; + } + + public void setOutro(String outro) { + this.outro = outro; + } + +} diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index 896f2525..8d253fde 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -1,6 +1,8 @@ package services; import java.nio.ByteOrder; +import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; @@ -17,6 +19,7 @@ import protocol.swg.objectControllerObjects.BuffBuilderStartMessage; import resources.common.BuffBuilder; import resources.common.Console; import resources.common.ObjControllerOpcodes; +import resources.common.Performance; import resources.objects.Buff; import resources.objects.BuffItem; import resources.objects.creature.CreatureObject; @@ -33,10 +36,15 @@ public class EntertainmentService implements INetworkDispatch { private NGECore core; private Vector buffBuilderSkills = new Vector(); + //FIXME: create a wrapper class for double key lookup maps + private HashMap performances = new HashMap(); + private HashMap danceMap = new HashMap(); public EntertainmentService(NGECore core) { this.core = core; populateSkillCaps(); + populatePerformanceTable(); + registerCommands(); } @Override @@ -128,6 +136,58 @@ public class EntertainmentService implements INetworkDispatch { }); } + private void populatePerformanceTable() { + + try { + DatatableVisitor PerformanceVisitor = ClientFileManager.loadFile("datatables/performance/performance.iff", DatatableVisitor.class); + + //rformanceVisitor. + + for (int r = 0; r < PerformanceVisitor.getRowCount(); r++) { + Performance p = new Performance(); + + /* for (int j=0; j < PerformanceVisitor.getColumnCount(); j++) { + System.out.println(j + ": " + PerformanceVisitor.getObject(r, j)); + }*/ + + p.setPerformanceName( ( (String) PerformanceVisitor.getObject(r, 0) ).toLowerCase()); + p.setInstrumentAudioId((int) PerformanceVisitor.getObject(r, 1)); + p.setRequiredSong((String) PerformanceVisitor.getObject(r, 2)); + p.setRequiredInstrument((String) PerformanceVisitor.getObject(r, 3)); + p.setRequiredDance((String) PerformanceVisitor.getObject(r, 4)); + p.setDanceVisualId((int) PerformanceVisitor.getObject(r, 5)); + p.setActionPointsPerLoop((int) PerformanceVisitor.getObject(r, 6)); + p.setLoopDuration((float) PerformanceVisitor.getObject(r, 7)); + p.setType((int) PerformanceVisitor.getObject(r, 8)); + p.setBaseXp((int) PerformanceVisitor.getObject(r, 9)); + p.setFlourishXpMod((int) PerformanceVisitor.getObject(r, 10)); + p.setHealMindWound((int) PerformanceVisitor.getObject(r, 11)); + p.setHealShockWound((int) PerformanceVisitor.getObject(r, 12)); + p.setRequiredSkillMod((String) PerformanceVisitor.getObject(r, 13)); + p.setRequiredSkillModValue((int) PerformanceVisitor.getObject(r, 14)); + p.setMainloop((String) PerformanceVisitor.getObject(r, 15)); + p.setFlourish1((String) PerformanceVisitor.getObject(r, 16)); + p.setFlourish2((String) PerformanceVisitor.getObject(r, 17)); + p.setFlourish3((String) PerformanceVisitor.getObject(r, 18)); + p.setFlourish4((String) PerformanceVisitor.getObject(r, 19)); + p.setFlourish5((String) PerformanceVisitor.getObject(r, 20)); + p.setFlourish6((String) PerformanceVisitor.getObject(r, 21)); + p.setFlourish7((String) PerformanceVisitor.getObject(r, 22)); + p.setFlourish8((String) PerformanceVisitor.getObject(r, 23)); + p.setIntro((String) PerformanceVisitor.getObject(r, 24)); + p.setOutro((String) PerformanceVisitor.getObject(r, 25)); + + if (p.getType() == -1788534963) { + danceMap.put(new Integer(p.getDanceVisualId()), p); + } + performances.put(p.getPerformanceName(), p); + } + + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + } + private void populateSkillCaps() { try { DatatableVisitor buffBuilder = ClientFileManager.loadFile("datatables/buff/buff_builder.iff", DatatableVisitor.class); @@ -152,6 +212,10 @@ public class EntertainmentService implements INetworkDispatch { e.printStackTrace(); } } + + private void registerCommands() { + core.commandService.registerCommand("startdance"); + } public void giveInspirationBuff(SWGObject reciever, Vector buffVector) { CreatureObject buffCreature = (CreatureObject) reciever; @@ -177,6 +241,37 @@ public class EntertainmentService implements INetworkDispatch { } + public Map getAvailableDances(CreatureObject actor) { + + Map dances = new HashMap(); + for (int index : danceMap.keySet()) { + if (!canDance(actor, danceMap.get(index) )) { continue; } + dances.put( new Long(index), danceMap.get(index).getPerformanceName() ); + } + + return dances; + + } + + public boolean isDance(String danceName) { + return ( performances.get(danceName) != null && performances.get(danceName).getType() == -1788534963); + } + + public boolean canDance(CreatureObject actor, Performance dance) { + for (String x : actor.getAbilities() ) { + System.out.println(x); + } + if (actor.hasAbility(dance.getRequiredDance())) { + return true; + } + return false; + } + + public boolean canDance(CreatureObject actor, String danceName) { + if (!isDance(danceName)) { return false; } + return canDance(actor, performances.get(danceName)); + } + @Override public void shutdown() { diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 014c66b3..87f7ed73 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -21,6 +21,7 @@ ******************************************************************************/ package services.object; +import java.io.FileNotFoundException; import java.io.IOException; import java.nio.ByteOrder; import java.sql.PreparedStatement; @@ -237,10 +238,12 @@ public class ObjectService implements INetworkDispatch { } } + } catch (FileNotFoundException e) { + System.out.println("!File Not Found:" + template.toString()); } catch (IOException e) { + System.out.println("!IO error " + template.toString()); e.printStackTrace(); } - } public SWGObject createObject(String Template, Planet planet) { From cde8e11be5e81dd3e0962441c645f0dd22ae9ef1 Mon Sep 17 00:00:00 2001 From: darkk1138 Date: Sat, 30 Nov 2013 16:54:25 +0100 Subject: [PATCH 02/23] grant species_* skills --- src/services/CharacterService.java | 2 ++ src/services/EntertainmentService.java | 3 --- src/services/SkillService.java | 7 +++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/services/CharacterService.java b/src/services/CharacterService.java index 4d60f425..7717b4bd 100644 --- a/src/services/CharacterService.java +++ b/src/services/CharacterService.java @@ -232,10 +232,12 @@ public class CharacterService implements INetworkDispatch { if (constitution >= 1) core.skillModService.addSkillMod(object, "constitution", (int) constitution); if (stamina >= 1) core.skillModService.addSkillMod(object, "stamina", (int) stamina); if (agility >= 1) core.skillModService.addSkillMod(object, "agility", (int) agility); + object.createTransaction(core.getCreatureODB().getEnvironment()); PlayerObject player = (PlayerObject) core.objectService.createObject("object/player/shared_player.iff", object.getPlanet()); object._add(player); + core.skillService.addSkill(object, "species_" + object.getStfName()); player.setProfession(clientCreateCharacter.getProfession()); player.setProfessionWheelPosition(clientCreateCharacter.getProfessionWheelPosition()); if(clientCreateCharacter.getHairObject().length() > 0) { diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index 8d253fde..ee88e386 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -258,9 +258,6 @@ public class EntertainmentService implements INetworkDispatch { } public boolean canDance(CreatureObject actor, Performance dance) { - for (String x : actor.getAbilities() ) { - System.out.println(x); - } if (actor.hasAbility(dance.getRequiredDance())) { return true; } diff --git a/src/services/SkillService.java b/src/services/SkillService.java index a6cd92c4..e4f970e3 100644 --- a/src/services/SkillService.java +++ b/src/services/SkillService.java @@ -87,6 +87,8 @@ public class SkillService implements INetworkDispatch { String[] schematicsGranted = ((String) skillTable.getObject(s, 23)).split(","); String[] schematicsRevoked = ((String) skillTable.getObject(s, 24)).split(","); + boolean speciesSkill = skill.matches("^species.+$"); + if (isTitle == true) { core.playerService.addPlayerTitle(player, skill); Console.println("Gave skill title: " + skill); @@ -95,8 +97,9 @@ public class SkillService implements INetworkDispatch { if (isProfession) { return; } - - if (godOnly || isHidden) { + + //exempt species skills from being returned -- they're marked godOnly but really meant to be granted + if ((!speciesSkill) && ( godOnly || isHidden)) { return; } From 6bd1c7b02ca9ba5202a5b17e3dcd443cdf5bd4ad Mon Sep 17 00:00:00 2001 From: darkk1138 Date: Wed, 4 Dec 2013 20:42:03 +0100 Subject: [PATCH 03/23] temp commit before merge --- scripts/commands/startdance.py | 23 ++++++++ src/resources/common/Performance.java | 9 +++ .../creature/CreatureMessageBuilder.java | 55 ++++++++++++++++++- .../objects/creature/CreatureObject.java | 49 ++++++++++++++++- src/services/EntertainmentService.java | 5 ++ 5 files changed, 138 insertions(+), 3 deletions(-) diff --git a/scripts/commands/startdance.py b/scripts/commands/startdance.py index 6a08bf7a..a8d78ed7 100644 --- a/scripts/commands/startdance.py +++ b/scripts/commands/startdance.py @@ -50,3 +50,26 @@ def startDance(core, actor, danceName): actor.sendSystemMessage('@performance:dance_lack_skill_self',0) return return + + if actor.getPerformanceId() > 0: + actor.sendSystemMessage('@performance:already_performing_self',0) + return + + performance = entSvc.getPerformance(danceName) + #TODO: check costume, posture, etc + + actor.sendSystemMessage('@performance:dance_start_self'); + actor.notifyAudience('@performance:dance_start_other'); + + if not actor.getPerformanceWatchee(): + #this also needs to notify the client with a delta4 + actor.setPerformanceWatchee(actor) + + #this should send a CREO3 + actor.setPosture(0x09); + # send CREO6 here + # second param is some sort of counter or start tick + actor.startPerformance(performance.getLineNumber(), 0xCDCC4C3C, 'dance_' . performance.getVisualId true) + + + diff --git a/src/resources/common/Performance.java b/src/resources/common/Performance.java index 42e40469..9100e2f2 100644 --- a/src/resources/common/Performance.java +++ b/src/resources/common/Performance.java @@ -29,6 +29,7 @@ public class Performance { private String flourish8; private String intro; private String outro; + private int lineNumber; public Performance() { @@ -141,6 +142,10 @@ public class Performance { public int getHealShockWound() { return healShockWound; } + + public int getLineNumber() { + return lineNumber; + } public void setHealShockWound(int healShockWound) { this.healShockWound = healShockWound; @@ -241,5 +246,9 @@ public class Performance { public void setOutro(String outro) { this.outro = outro; } + + public void setLineNumber(int lineNumber) { + this.lineNumber = lineNumber; + } } diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index 0a09f314..ca4c6090 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -173,7 +173,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { } buffer.putFloat(creature.getSpeedMultiplierBase()); buffer.putFloat(creature.getSpeedMultiplierMod()); - buffer.putLong(0); // unk + buffer.putLong(creature.getListenToId()); buffer.putFloat(creature.getRunSpeed()); @@ -234,10 +234,12 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { //buffer.putShort((short) 90); buffer.putInt(creature.getGrantedHealth()); // From player_level.iff. Ranges from 0-2000 as you level, consistent with that table. + //0A if(creature.getCurrentAnimation() == null || creature.getCurrentAnimation().length() == 0) buffer.putShort((short) 0); else buffer.put(getAsciiString(creature.getCurrentAnimation())); + if(creature.getMoodAnimation() == null || creature.getMoodAnimation().length() == 0) buffer.put(getAsciiString("neutral")); else @@ -251,10 +253,11 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putShort((short) 0); else buffer.put(getAsciiString(creature.getInviteSenderName())); - + buffer.putLong(creature.getInviteCounter()); buffer.putInt(creature.getGuildId()); + //10 buffer.putLong(creature.getTargetId()); buffer.put(creature.getMoodId()); buffer.putInt(creature.getPerformanceCounter()); @@ -267,6 +270,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putInt(creature.getHamListCounter()); buffer.putInt(creature.getHealth()); + //1A buffer.putInt(0); buffer.putInt(creature.getAction()); buffer.putInt(0); @@ -975,6 +979,51 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { } + public IoBuffer buildListenToId(long creatureObjectId) { + IoBuffer buffer = bufferPool.allocate(8, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putLong(creatureObjectId); + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("CREO", (byte) 4, (short) 1, (short) 2, buffer, size + 4); + return buffer; + } + + public IoBuffer buildPerformanceId(int performanceId) { + IoBuffer buffer = bufferPool.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putInt(performanceId); + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 2, buffer, size + 4); + return buffer; + } + + public IoBuffer buildPerformanceCounter(int performanceCounter) { + IoBuffer buffer = bufferPool.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putInt(performanceCounter); + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 2, buffer, size + 4); + return buffer; + } + + public IoBuffer buildSkillName(String skillName) { + IoBuffer buffer = bufferPool.allocate(getUnicodeString(skillName).length, false).order(ByteOrder.LITTLE_ENDIAN); + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 2, buffer, size + 4); + return buffer; + } + + public IoBuffer buildStartPerformance(boolean doStart) { + IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.put((byte) ((doStart) ? 1 : 0)); + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 2, buffer, size + 4); + return buffer; + } + + @Override public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { // TODO Auto-generated method stub @@ -985,5 +1034,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { public void sendBaselines() { } + + } diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index cff18a9b..a17ac2b6 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -56,7 +56,8 @@ import engine.resources.scene.Quaternion; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; -@Entity(version=2) + +@Entity(version=4) public class CreatureObject extends TangibleObject implements IPersistent { @NotPersistent @@ -116,6 +117,8 @@ public class CreatureObject extends TangibleObject implements IPersistent { private byte moodId = 0; private int performanceCounter = 0; private int performanceId = 0; + private CreatureObject performanceWatchee; + private CreatureObject performanceListenee; private int health = 1000; private int action = 300; @NotPersistent @@ -1261,5 +1264,49 @@ public class CreatureObject extends TangibleObject implements IPersistent { public boolean setStaticNPC(boolean staticNPC) { return this.staticNPC = staticNPC; } + public CreatureObject getPerformanceWatchee() { + synchronized(objectMutex) { + return performanceWatchee; + } + } + + public void setPerformanceWatchee(CreatureObject performanceWatchee) { + synchronized(objectMutex) { + this.performanceWatchee = performanceWatchee; + } + getClient().getSession().write(messageBuilder.buildListenToId(performanceWatchee.getObjectId())); + } + + public CreatureObject getPerformanceListenee() { + synchronized(objectMutex) { + return performanceListenee; + } + } + + public void setPerformanceListenee(CreatureObject performanceListenee) { + synchronized(objectMutex) { + this.performanceListenee = performanceListenee; + } + } + + public void startPerformance(int performanceId, int performanceCounter, String skillName, boolean doStart) { + synchronized(objectMutex) { + this.performanceId = performanceId; + this.performanceCounter = performanceCounter; + } + + if (doStart) { getClient().getSession().write(messageBuilder.buildPerformanceId(performanceId)); } + if (doStart) { getClient().getSession().write(messageBuilder.buildPerformanceCounter(performanceCounter)); } + if (doStart) { getClient().getSession().write(messageBuilder.buildSkillName(skillName)); } + getClient().getSession().write(messageBuilder.buildStartPerformance(doStart)); + + } + + public void notifyAudience() { + //TODO: stub + } + + + } diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index ee88e386..2d262da6 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -176,6 +176,7 @@ public class EntertainmentService implements INetworkDispatch { p.setFlourish8((String) PerformanceVisitor.getObject(r, 23)); p.setIntro((String) PerformanceVisitor.getObject(r, 24)); p.setOutro((String) PerformanceVisitor.getObject(r, 25)); + p.setLineNumber(r); if (p.getType() == -1788534963) { danceMap.put(new Integer(p.getDanceVisualId()), p); @@ -269,6 +270,10 @@ public class EntertainmentService implements INetworkDispatch { return canDance(actor, performances.get(danceName)); } + public Performance getPerformance(String name) { + return performances.get(name); + } + @Override public void shutdown() { From ff772a1f79758ee860f53f90618929b5dca1c4bd Mon Sep 17 00:00:00 2001 From: Waverunner Date: Thu, 5 Dec 2013 18:48:58 -0500 Subject: [PATCH 04/23] MissionObject Delta's added, Debug print to try and fix Travel Points showing on other planets --- src/resources/common/TerminalType.java | 30 +++ .../mission/MissionMessageBuilder.java | 193 +++++++++++++++++- .../objects/mission/MissionObject.java | 65 +----- src/services/travel/TravelService.java | 5 +- 4 files changed, 231 insertions(+), 62 deletions(-) create mode 100644 src/resources/common/TerminalType.java diff --git a/src/resources/common/TerminalType.java b/src/resources/common/TerminalType.java new file mode 100644 index 00000000..375d1e61 --- /dev/null +++ b/src/resources/common/TerminalType.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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 resources.common; + +public class TerminalType { + public static int MISSION_GENERIC = 1; + public static int MISSION_BOUNTYHUNTER = 2; + public static int MISSION_ENTERTAINER = 3; + public static int MISSION_ARTISAN = 4; + public static int MISSION_EXPLORER = 5; +} diff --git a/src/resources/objects/mission/MissionMessageBuilder.java b/src/resources/objects/mission/MissionMessageBuilder.java index 8e206c01..dff9bc55 100644 --- a/src/resources/objects/mission/MissionMessageBuilder.java +++ b/src/resources/objects/mission/MissionMessageBuilder.java @@ -42,8 +42,8 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { buffer.putShort((short) 11); - buffer.putFloat(mission.getMissionComplexity()); - buffer.put(getAsciiString("mission/mission_object")); + buffer.putFloat(1); // mission complexity ?? + buffer.put(getAsciiString(mission.getStfFilename())); buffer.putInt(0); buffer.put(getAsciiString(mission.getStfName())); @@ -122,17 +122,202 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { public IoBuffer buildBaseline6() { IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putInt(121); // unk int size = buffer.position(); - buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); - buffer.flip(); buffer = createBaseline("MISO", (byte) 6, buffer, size); return buffer; } + public IoBuffer buildStfDelta() { + MissionObject mission = (MissionObject) object; + + IoBuffer buffer = IoBuffer.allocate(4 + mission.getStfFilename().length() + mission.getStfName().length(), false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.put(getAsciiString(mission.getStfFilename())); + buffer.putInt(0); + buffer.put(getAsciiString(mission.getStfName())); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x01, buffer, size + 4); + + return buffer; + } + + public IoBuffer buildDifficultyLevelDelta() { + MissionObject mission = (MissionObject) object; + + IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putInt(mission.getMissionLevel()); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x05, buffer, size + 4); + + return buffer; + } + + public IoBuffer buildStartLocationDelta() { + MissionObject mission = (MissionObject) object; + + IoBuffer buffer = IoBuffer.allocate(24, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putFloat(mission.getMissionStartX()); + buffer.putFloat(mission.getMissionStartZ()); + buffer.putFloat(mission.getMissionStartY()); + + buffer.putLong(0); + + buffer.putInt(CRC.StringtoCRC(mission.getMissionStartPlanet())); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x06, buffer, size + 4); + + return buffer; + } + + public IoBuffer buildCreatorNameDelta() { + MissionObject mission = (MissionObject) object; + + IoBuffer buffer = IoBuffer.allocate(4 + mission.getMissionCreator().length(), false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.put(getAsciiString(mission.getMissionCreator())); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x07, buffer, size + 4); + + return buffer; + } + + public IoBuffer buildCreditsRewardDelta() { + MissionObject mission = (MissionObject) object; + + IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putInt(mission.getMissionCredits()); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x08, buffer, size + 4); + + return buffer; + } + + public IoBuffer buildDestinationDelta() { + MissionObject mission = (MissionObject) object; + + IoBuffer buffer = IoBuffer.allocate(24, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putFloat(mission.getMissionDestinationX()); + buffer.putFloat(mission.getMissionDestinationZ()); + buffer.putFloat(mission.getMissionDestinationY()); + + buffer.putLong(0); // Destination Object ID + + buffer.putInt(CRC.StringtoCRC(mission.getMissionDestinationPlanet())); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x09, buffer, size + 4); + + return buffer; + } + + public IoBuffer buildTargetObjectIffDelta() { + MissionObject mission = (MissionObject) object; + + IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putInt(CRC.StringtoCRC(mission.getMissionTemplateObject())); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x0A, buffer, size + 4); + + return buffer; + } + + public IoBuffer buildMissionDescriptionDelta() { + MissionObject mission = (MissionObject) object; + + IoBuffer buffer = IoBuffer.allocate(4 + mission.getMissionDescription().length() + mission.getMissionDescId().length(), false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.put(getAsciiString(mission.getMissionDescription())); + buffer.putInt(0); + buffer.put(getAsciiString(mission.getMissionDescId())); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x0B, buffer, size + 4); + + return buffer; + } + + public IoBuffer buildMissionTitleDelta() { + MissionObject mission = (MissionObject) object; + + IoBuffer buffer = IoBuffer.allocate(4 + mission.getMissionTitle().length() + mission.getMissionTitleId().length(), false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.put(getAsciiString(mission.getMissionTitle())); + buffer.putInt(0); + buffer.put(getAsciiString(mission.getMissionTitleId())); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x0C, buffer, size + 4); + + return buffer; + } + + public IoBuffer buildRepeatCounterDelta() { + MissionObject mission = (MissionObject) object; + + IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putInt(mission.getMissionRepeatCounter()); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x0D, buffer, size + 4); + + return buffer; + } + + public IoBuffer buildMissionTypeDelta() { + MissionObject mission = (MissionObject) object; + + IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putInt(CRC.StringtoCRC(mission.getMissionType())); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x0E, buffer, size + 4); + + return buffer; + } + + public IoBuffer buildTargetNameDelta() { + MissionObject mission = (MissionObject) object; + + IoBuffer buffer = IoBuffer.allocate(4 + mission.getMissionTargetName().length(), false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.put(getAsciiString(mission.getMissionTargetName())); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("MISO", (byte) 3, (short) 1, (short) 0x0F, buffer, size + 4); + + return buffer; + } + @Override public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { diff --git a/src/resources/objects/mission/MissionObject.java b/src/resources/objects/mission/MissionObject.java index 3cbde103..c98ab0c7 100644 --- a/src/resources/objects/mission/MissionObject.java +++ b/src/resources/objects/mission/MissionObject.java @@ -36,11 +36,6 @@ import engine.resources.scene.Quaternion; public class MissionObject extends SWGObject implements IPersistent { - private String stfName; - private String customName; - private int volume; - - private float missionComplexity; private float missionDestinationX; private float missionDestinationY; private float missionDestinationZ; @@ -73,85 +68,41 @@ public class MissionObject extends SWGObject implements IPersistent { public MissionObject(long objectID, Planet planet, String template) { super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), template); } - - public String getStfName() { - return stfName; - } - - public void setStfName(String stfName) { - this.stfName = stfName; - } - - public String getCustomName() { - return customName; - } - - public void setCustomName(String customName) { - this.customName = customName; - } - - public int getVolume() { - return volume; - } - - public void setVolume(int volume) { - this.volume = volume; - } - - public float getMissionComplexity() { - return missionComplexity; - } - - public void setMissionComplexity(float missionComplexity) { - this.missionComplexity = missionComplexity; - } public float getMissionStartX() { return missionStartX; } - public void setMissionStartX(float missionStartX) { - this.missionStartX = missionStartX; - } - public float getMissionStartY() { return missionStartY; } - public void setMissionStartY(float missionStartY) { - this.missionStartY = missionStartY; - } - public float getMissionStartZ() { return missionStartZ; } - public void setMissionStartZ(float missionStartZ) { - this.missionStartZ = missionStartZ; + public void setMissionStart(float x, float y, float z) { + this.missionStartZ = z; + this.missionStartX = x; + this.missionStartY = y; } public float getMissionDestinationX() { return missionDestinationX; } - public void setMissionDestinationX(float missionDestinationX) { - this.missionDestinationX = missionDestinationX; - } - public float getMissionDestinationY() { return missionDestinationY; } - public void setMissionDestinationY(float missionDestinationY) { - this.missionDestinationY = missionDestinationY; - } - public float getMissionDestinationZ() { return missionDestinationZ; } - public void setMissionDestinationZ(float missionDestinationZ) { - this.missionDestinationZ = missionDestinationZ; + public void setMissionDestination(float x, float y, float z) { + this.missionDestinationZ = z; + this.missionDestinationY = y; + this.missionDestinationZ = z; } public String getMissionDestinationPlanet() { diff --git a/src/services/travel/TravelService.java b/src/services/travel/TravelService.java index 956c34ca..541615a3 100644 --- a/src/services/travel/TravelService.java +++ b/src/services/travel/TravelService.java @@ -114,11 +114,14 @@ public class TravelService implements INetworkDispatch { Vector correctTravelPoints = new Vector(); for(TravelPoint tp : travelMap.get(planet)) { - if(tp.isStarport() || tp.getPlanetName().equalsIgnoreCase(object.getPlanet().getName())) + if(tp.isStarport() || tp.getPlanetName().equalsIgnoreCase(object.getPlanet().getName())) { correctTravelPoints.add(tp); + Console.println(tp.getName()); + } } PlanetTravelPointListResponse response = new PlanetTravelPointListResponse(planetString, correctTravelPoints); client.getSession().write(response.serialize()); + break; } From e94fc930cecf8c3884686b4b889ae49b0685c1b0 Mon Sep 17 00:00:00 2001 From: Treeku Date: Fri, 6 Dec 2013 12:14:13 +0000 Subject: [PATCH 05/23] FactionService, helper funcs, factionResponseMsg --- scripts/faction/aakuans.py | 9 ++ scripts/faction/afarathu.py | 9 ++ scripts/faction/alkhara.py | 9 ++ scripts/faction/bandit.py | 9 ++ scripts/faction/beldonnas_league.py | 11 ++ scripts/faction/binayre.py | 9 ++ scripts/faction/bloodrazor.py | 9 ++ scripts/faction/borvo.py | 9 ++ scripts/faction/canyon_corsair.py | 9 ++ scripts/faction/cobral.py | 9 ++ scripts/faction/cor_swoop.py | 9 ++ scripts/faction/corsec.py | 9 ++ scripts/faction/dantari_raiders.py | 9 ++ scripts/faction/desert_demon.py | 9 ++ scripts/faction/donkuwah_tribe.py | 9 ++ scripts/faction/drall.py | 9 ++ scripts/faction/endor_marauder.py | 9 ++ scripts/faction/fed_dub.py | 9 ++ scripts/faction/flail.py | 9 ++ scripts/faction/followers_of_lord_nyax.py | 9 ++ scripts/faction/forest_kerritamba.py | 9 ++ scripts/faction/forest_outcast.py | 9 ++ scripts/faction/fs_villager.py | 9 ++ scripts/faction/garyn.py | 9 ++ scripts/faction/gondula_tribe.py | 9 ++ scripts/faction/gungan.py | 9 ++ scripts/faction/hidden_daggers.py | 11 ++ scripts/faction/hutt.py | 11 ++ scripts/faction/imperial.py | 9 ++ scripts/faction/jabba.py | 11 ++ scripts/faction/janta_tribe.py | 9 ++ scripts/faction/jawa.py | 9 ++ scripts/faction/kobola.py | 9 ++ scripts/faction/korga_tribe.py | 9 ++ scripts/faction/kunga_tribe.py | 9 ++ scripts/faction/liberation_party.py | 9 ++ scripts/faction/lok_mercenaries.py | 9 ++ scripts/faction/lost_aqualish.py | 9 ++ scripts/faction/meatlump.py | 9 ++ scripts/faction/mokk_tribe.py | 9 ++ scripts/faction/monumenter.py | 9 ++ scripts/faction/mtn_clan.py | 9 ++ scripts/faction/naboo.py | 9 ++ scripts/faction/naboo_pirate.py | 9 ++ scripts/faction/naboo_security_force.py | 9 ++ scripts/faction/narmle.py | 11 ++ scripts/faction/nightsister.py | 9 ++ scripts/faction/nym.py | 9 ++ scripts/faction/olag_greck.py | 9 ++ scripts/faction/panshee_tribe.py | 9 ++ scripts/faction/pirate.py | 9 ++ scripts/faction/plasma_thief.py | 9 ++ scripts/faction/pubam.py | 9 ++ scripts/faction/rebel.py | 9 ++ scripts/faction/restuss.py | 11 ++ scripts/faction/rogue_corsec.py | 11 ++ scripts/faction/rorgungan.py | 9 ++ scripts/faction/sif.py | 11 ++ scripts/faction/sith_shadow.py | 11 ++ scripts/faction/smashball.py | 9 ++ scripts/faction/spice_collective.py | 9 ++ scripts/faction/spider_nightsister.py | 9 ++ scripts/faction/swamp_rat.py | 9 ++ scripts/faction/swoop.py | 9 ++ scripts/faction/thug.py | 9 ++ scripts/faction/townsperson.py | 11 ++ scripts/faction/trade_federation.py | 9 ++ scripts/faction/tusken_raider.py | 9 ++ scripts/faction/valarian.py | 9 ++ scripts/faction/yavin_scavenger.py | 9 ++ src/protocol/swg/FactionResponseMessage.java | 77 ++++++++++++ src/resources/common/Opcodes.java | 1 + src/resources/common/StateStatus.java | 21 ++++ .../objects/creature/CreatureObject.java | 2 +- src/services/gcw/FactionService.java | 114 +++++++++++++----- src/services/object/ObjectService.java | 26 ++-- 76 files changed, 846 insertions(+), 45 deletions(-) create mode 100644 scripts/faction/aakuans.py create mode 100644 scripts/faction/afarathu.py create mode 100644 scripts/faction/alkhara.py create mode 100644 scripts/faction/bandit.py create mode 100644 scripts/faction/beldonnas_league.py create mode 100644 scripts/faction/binayre.py create mode 100644 scripts/faction/bloodrazor.py create mode 100644 scripts/faction/borvo.py create mode 100644 scripts/faction/canyon_corsair.py create mode 100644 scripts/faction/cobral.py create mode 100644 scripts/faction/cor_swoop.py create mode 100644 scripts/faction/corsec.py create mode 100644 scripts/faction/dantari_raiders.py create mode 100644 scripts/faction/desert_demon.py create mode 100644 scripts/faction/donkuwah_tribe.py create mode 100644 scripts/faction/drall.py create mode 100644 scripts/faction/endor_marauder.py create mode 100644 scripts/faction/fed_dub.py create mode 100644 scripts/faction/flail.py create mode 100644 scripts/faction/followers_of_lord_nyax.py create mode 100644 scripts/faction/forest_kerritamba.py create mode 100644 scripts/faction/forest_outcast.py create mode 100644 scripts/faction/fs_villager.py create mode 100644 scripts/faction/garyn.py create mode 100644 scripts/faction/gondula_tribe.py create mode 100644 scripts/faction/gungan.py create mode 100644 scripts/faction/hidden_daggers.py create mode 100644 scripts/faction/hutt.py create mode 100644 scripts/faction/imperial.py create mode 100644 scripts/faction/jabba.py create mode 100644 scripts/faction/janta_tribe.py create mode 100644 scripts/faction/jawa.py create mode 100644 scripts/faction/kobola.py create mode 100644 scripts/faction/korga_tribe.py create mode 100644 scripts/faction/kunga_tribe.py create mode 100644 scripts/faction/liberation_party.py create mode 100644 scripts/faction/lok_mercenaries.py create mode 100644 scripts/faction/lost_aqualish.py create mode 100644 scripts/faction/meatlump.py create mode 100644 scripts/faction/mokk_tribe.py create mode 100644 scripts/faction/monumenter.py create mode 100644 scripts/faction/mtn_clan.py create mode 100644 scripts/faction/naboo.py create mode 100644 scripts/faction/naboo_pirate.py create mode 100644 scripts/faction/naboo_security_force.py create mode 100644 scripts/faction/narmle.py create mode 100644 scripts/faction/nightsister.py create mode 100644 scripts/faction/nym.py create mode 100644 scripts/faction/olag_greck.py create mode 100644 scripts/faction/panshee_tribe.py create mode 100644 scripts/faction/pirate.py create mode 100644 scripts/faction/plasma_thief.py create mode 100644 scripts/faction/pubam.py create mode 100644 scripts/faction/rebel.py create mode 100644 scripts/faction/restuss.py create mode 100644 scripts/faction/rogue_corsec.py create mode 100644 scripts/faction/rorgungan.py create mode 100644 scripts/faction/sif.py create mode 100644 scripts/faction/sith_shadow.py create mode 100644 scripts/faction/smashball.py create mode 100644 scripts/faction/spice_collective.py create mode 100644 scripts/faction/spider_nightsister.py create mode 100644 scripts/faction/swamp_rat.py create mode 100644 scripts/faction/swoop.py create mode 100644 scripts/faction/thug.py create mode 100644 scripts/faction/townsperson.py create mode 100644 scripts/faction/trade_federation.py create mode 100644 scripts/faction/tusken_raider.py create mode 100644 scripts/faction/valarian.py create mode 100644 scripts/faction/yavin_scavenger.py create mode 100644 src/protocol/swg/FactionResponseMessage.java diff --git a/scripts/faction/aakuans.py b/scripts/faction/aakuans.py new file mode 100644 index 00000000..a8fc0c39 --- /dev/null +++ b/scripts/faction/aakuans.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'fed_dub' or enemy == 'binayre' or enemy == 'liberation_party': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/afarathu.py b/scripts/faction/afarathu.py new file mode 100644 index 00000000..80a24805 --- /dev/null +++ b/scripts/faction/afarathu.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'corsec': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/alkhara.py b/scripts/faction/alkhara.py new file mode 100644 index 00000000..3553adcd --- /dev/null +++ b/scripts/faction/alkhara.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'tusken_raider': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/bandit.py b/scripts/faction/bandit.py new file mode 100644 index 00000000..bd97f757 --- /dev/null +++ b/scripts/faction/bandit.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'townsperson': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/beldonnas_league.py b/scripts/faction/beldonnas_league.py new file mode 100644 index 00000000..c15dab6d --- /dev/null +++ b/scripts/faction/beldonnas_league.py @@ -0,0 +1,11 @@ +import sys + +def isAlly(ally): + if ally == 'corsec': + return 1 + return 0 + +def isEnemy(enemy): + if enemy == 'followers_of_lord_nyax' or enemy == 'lost_aqualish': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/binayre.py b/scripts/faction/binayre.py new file mode 100644 index 00000000..5eb7703b --- /dev/null +++ b/scripts/faction/binayre.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'fed_dub' or enemy == 'aakuans' or enemy == 'corsec': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/bloodrazor.py b/scripts/faction/bloodrazor.py new file mode 100644 index 00000000..78220da0 --- /dev/null +++ b/scripts/faction/bloodrazor.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'canyon_corsair' or enemy == 'nym': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/borvo.py b/scripts/faction/borvo.py new file mode 100644 index 00000000..1dfa01f8 --- /dev/null +++ b/scripts/faction/borvo.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'gungan' or enemy == 'trade_federation' or enemy == 'jabba': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/canyon_corsair.py b/scripts/faction/canyon_corsair.py new file mode 100644 index 00000000..f978debe --- /dev/null +++ b/scripts/faction/canyon_corsair.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'bloodrazor' or enemy == 'nym': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/cobral.py b/scripts/faction/cobral.py new file mode 100644 index 00000000..139fe6a1 --- /dev/null +++ b/scripts/faction/cobral.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'restuss': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/cor_swoop.py b/scripts/faction/cor_swoop.py new file mode 100644 index 00000000..7d2ffab5 --- /dev/null +++ b/scripts/faction/cor_swoop.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'smashball': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/corsec.py b/scripts/faction/corsec.py new file mode 100644 index 00000000..30ca26bf --- /dev/null +++ b/scripts/faction/corsec.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'afarathu' or enemy == 'followers_of_lord_nyax' or enemy == 'beldonnas_league' or enemy == 'monumenter' or enemy == 'rogue_corsec' or enemy == 'lost_aqualish': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/dantari_raiders.py b/scripts/faction/dantari_raiders.py new file mode 100644 index 00000000..f1dd456b --- /dev/null +++ b/scripts/faction/dantari_raiders.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'kunga_tribe' or enemy == 'mokk_tribe' or enemy == 'janta_tribe': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/desert_demon.py b/scripts/faction/desert_demon.py new file mode 100644 index 00000000..9dd1a4d4 --- /dev/null +++ b/scripts/faction/desert_demon.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'swoop': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/donkuwah_tribe.py b/scripts/faction/donkuwah_tribe.py new file mode 100644 index 00000000..6db0ca51 --- /dev/null +++ b/scripts/faction/donkuwah_tribe.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'gondula_tribe' or enemy == 'panshee_tribe': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/drall.py b/scripts/faction/drall.py new file mode 100644 index 00000000..5059caaf --- /dev/null +++ b/scripts/faction/drall.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'corsec' or enemy == 'fed_dub': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/endor_marauder.py b/scripts/faction/endor_marauder.py new file mode 100644 index 00000000..6db0ca51 --- /dev/null +++ b/scripts/faction/endor_marauder.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'gondula_tribe' or enemy == 'panshee_tribe': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/fed_dub.py b/scripts/faction/fed_dub.py new file mode 100644 index 00000000..20a018fb --- /dev/null +++ b/scripts/faction/fed_dub.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'liberation_party' or enemy == 'binayre' or enemy == 'lost_aqualish' or enemy == 'drall': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/flail.py b/scripts/faction/flail.py new file mode 100644 index 00000000..37a3ff1d --- /dev/null +++ b/scripts/faction/flail.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'hidden_daggers': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/followers_of_lord_nyax.py b/scripts/faction/followers_of_lord_nyax.py new file mode 100644 index 00000000..35c07b91 --- /dev/null +++ b/scripts/faction/followers_of_lord_nyax.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'corsec' or enemy == 'beldonnas_league': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/forest_kerritamba.py b/scripts/faction/forest_kerritamba.py new file mode 100644 index 00000000..1213cf20 --- /dev/null +++ b/scripts/faction/forest_kerritamba.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'forest_outcast': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/forest_outcast.py b/scripts/faction/forest_outcast.py new file mode 100644 index 00000000..05faa8d3 --- /dev/null +++ b/scripts/faction/forest_outcast.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'forest_kerritamba': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/fs_villager.py b/scripts/faction/fs_villager.py new file mode 100644 index 00000000..0fd5d988 --- /dev/null +++ b/scripts/faction/fs_villager.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'sith_shadow': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/garyn.py b/scripts/faction/garyn.py new file mode 100644 index 00000000..139fe6a1 --- /dev/null +++ b/scripts/faction/garyn.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'restuss': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/gondula_tribe.py b/scripts/faction/gondula_tribe.py new file mode 100644 index 00000000..c0078e6a --- /dev/null +++ b/scripts/faction/gondula_tribe.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'donkuwah_tribe' or enemy == 'korga_tribe' or enemy == 'panshee_tribe' or enemy == 'pubam' or enemy == 'endor_marauder': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/gungan.py b/scripts/faction/gungan.py new file mode 100644 index 00000000..1f9355e5 --- /dev/null +++ b/scripts/faction/gungan.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'plasma_thief' or enemy == 'swamp_rat' or enemy == 'borvo': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/hidden_daggers.py b/scripts/faction/hidden_daggers.py new file mode 100644 index 00000000..34c20129 --- /dev/null +++ b/scripts/faction/hidden_daggers.py @@ -0,0 +1,11 @@ +import sys + +def isAlly(ally): + if ally == 'rogue_corsec': + return 1 + return 0 + +def isEnemy(enemy): + if enemy == 'corsec' or enemy == 'beldonnas_league' or enemy == 'flail': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/hutt.py b/scripts/faction/hutt.py new file mode 100644 index 00000000..0d468932 --- /dev/null +++ b/scripts/faction/hutt.py @@ -0,0 +1,11 @@ +import sys + +def isAlly(ally): + if ally == 'panshee_tribe': + return 1 + return 0 + +def isEnemy(enemy): + if enemy == 'naboo_security_force' or enemy == 'nym' or enemy == 'imperial' or enemy == 'jabba' or enemy == 'borvo' or enemy == 'corsec' or enemy == 'narmle': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/imperial.py b/scripts/faction/imperial.py new file mode 100644 index 00000000..b5bc8cc0 --- /dev/null +++ b/scripts/faction/imperial.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'rebel': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/jabba.py b/scripts/faction/jabba.py new file mode 100644 index 00000000..5840595b --- /dev/null +++ b/scripts/faction/jabba.py @@ -0,0 +1,11 @@ +import sys + +def isAlly(ally): + if ally == 'hutt': + return 1 + return 0 + +def isEnemy(enemy): + if enemy == 'valarian' or enemy == 'borvo': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/janta_tribe.py b/scripts/faction/janta_tribe.py new file mode 100644 index 00000000..b446a0a0 --- /dev/null +++ b/scripts/faction/janta_tribe.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'kunga_tribe' or enemy == 'dantari_raiders': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/jawa.py b/scripts/faction/jawa.py new file mode 100644 index 00000000..3553adcd --- /dev/null +++ b/scripts/faction/jawa.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'tusken_raider': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/kobola.py b/scripts/faction/kobola.py new file mode 100644 index 00000000..8befaec5 --- /dev/null +++ b/scripts/faction/kobola.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'narmle' or enemy == 'spice_collective': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/korga_tribe.py b/scripts/faction/korga_tribe.py new file mode 100644 index 00000000..6db0ca51 --- /dev/null +++ b/scripts/faction/korga_tribe.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'gondula_tribe' or enemy == 'panshee_tribe': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/kunga_tribe.py b/scripts/faction/kunga_tribe.py new file mode 100644 index 00000000..52e241cb --- /dev/null +++ b/scripts/faction/kunga_tribe.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'mokk_tribe' or enemy == 'dantari_raiders': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/liberation_party.py b/scripts/faction/liberation_party.py new file mode 100644 index 00000000..2fff2b6f --- /dev/null +++ b/scripts/faction/liberation_party.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'fed_dub' or enemy == 'corsec': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/lok_mercenaries.py b/scripts/faction/lok_mercenaries.py new file mode 100644 index 00000000..ebf10bf9 --- /dev/null +++ b/scripts/faction/lok_mercenaries.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'bloodrazor' or enemy == 'canyon_corsair': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/lost_aqualish.py b/scripts/faction/lost_aqualish.py new file mode 100644 index 00000000..9aef6e55 --- /dev/null +++ b/scripts/faction/lost_aqualish.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'beldonnas_league' or enemy == 'fed_dub' or enemy == 'corsec': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/meatlump.py b/scripts/faction/meatlump.py new file mode 100644 index 00000000..3e432825 --- /dev/null +++ b/scripts/faction/meatlump.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'corsec' or enemy == 'rogue_corsec' or enemy == 'beldonnas_league': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/mokk_tribe.py b/scripts/faction/mokk_tribe.py new file mode 100644 index 00000000..93e05b64 --- /dev/null +++ b/scripts/faction/mokk_tribe.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'janta_tribe' or enemy == 'dantari_raiders': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/monumenter.py b/scripts/faction/monumenter.py new file mode 100644 index 00000000..35c07b91 --- /dev/null +++ b/scripts/faction/monumenter.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'corsec' or enemy == 'beldonnas_league': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/mtn_clan.py b/scripts/faction/mtn_clan.py new file mode 100644 index 00000000..e2b7c145 --- /dev/null +++ b/scripts/faction/mtn_clan.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'nightsister': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/naboo.py b/scripts/faction/naboo.py new file mode 100644 index 00000000..22519151 --- /dev/null +++ b/scripts/faction/naboo.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'borvo': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/naboo_pirate.py b/scripts/faction/naboo_pirate.py new file mode 100644 index 00000000..d409c4ff --- /dev/null +++ b/scripts/faction/naboo_pirate.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'naboo_security_force': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/naboo_security_force.py b/scripts/faction/naboo_security_force.py new file mode 100644 index 00000000..ec32a708 --- /dev/null +++ b/scripts/faction/naboo_security_force.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'borvo' or enemy == 'naboo_pirate' or enemy == 'plasma_thief' or enemy == 'swamp_rat' or enemy == 'trade_federation': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/narmle.py b/scripts/faction/narmle.py new file mode 100644 index 00000000..3188e87c --- /dev/null +++ b/scripts/faction/narmle.py @@ -0,0 +1,11 @@ +import sys + +def isAlly(ally): + if ally == 'restuss': + return 1 + return 0 + +def isEnemy(enemy): + if enemy == 'narmle' or enemy == 'spice_collective' or enemy == 'kobola': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/nightsister.py b/scripts/faction/nightsister.py new file mode 100644 index 00000000..cf1f8c4e --- /dev/null +++ b/scripts/faction/nightsister.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'mtn_clan' or enemy == 'imperial': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/nym.py b/scripts/faction/nym.py new file mode 100644 index 00000000..ebf10bf9 --- /dev/null +++ b/scripts/faction/nym.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'bloodrazor' or enemy == 'canyon_corsair': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/olag_greck.py b/scripts/faction/olag_greck.py new file mode 100644 index 00000000..35c07b91 --- /dev/null +++ b/scripts/faction/olag_greck.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'corsec' or enemy == 'beldonnas_league': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/panshee_tribe.py b/scripts/faction/panshee_tribe.py new file mode 100644 index 00000000..6ea96a0d --- /dev/null +++ b/scripts/faction/panshee_tribe.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'donkuwah_tribe' or enemy == 'korga_tribe' or enemy == 'gondula_tribe' or enemy == 'pubam' or enemy == 'endor_marauder': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/pirate.py b/scripts/faction/pirate.py new file mode 100644 index 00000000..a8fc0c39 --- /dev/null +++ b/scripts/faction/pirate.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'fed_dub' or enemy == 'binayre' or enemy == 'liberation_party': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/plasma_thief.py b/scripts/faction/plasma_thief.py new file mode 100644 index 00000000..89a851e9 --- /dev/null +++ b/scripts/faction/plasma_thief.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'gungan': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/pubam.py b/scripts/faction/pubam.py new file mode 100644 index 00000000..6db0ca51 --- /dev/null +++ b/scripts/faction/pubam.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'gondula_tribe' or enemy == 'panshee_tribe': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/rebel.py b/scripts/faction/rebel.py new file mode 100644 index 00000000..0d685a6a --- /dev/null +++ b/scripts/faction/rebel.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'imperial': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/restuss.py b/scripts/faction/restuss.py new file mode 100644 index 00000000..9ce8318a --- /dev/null +++ b/scripts/faction/restuss.py @@ -0,0 +1,11 @@ +import sys + +def isAlly(ally): + if ally == 'narmle': + return 1 + return 0 + +def isEnemy(enemy): + if enemy == 'garyn' or enemy == 'cobral': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/rogue_corsec.py b/scripts/faction/rogue_corsec.py new file mode 100644 index 00000000..38fd4f3a --- /dev/null +++ b/scripts/faction/rogue_corsec.py @@ -0,0 +1,11 @@ +import sys + +def isAlly(ally): + if ally == 'hidden_daggers': + return 1 + return 0 + +def isEnemy(enemy): + if enemy == 'corsec': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/rorgungan.py b/scripts/faction/rorgungan.py new file mode 100644 index 00000000..f39573c6 --- /dev/null +++ b/scripts/faction/rorgungan.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'spice_collective': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/sif.py b/scripts/faction/sif.py new file mode 100644 index 00000000..04d90a0e --- /dev/null +++ b/scripts/faction/sif.py @@ -0,0 +1,11 @@ +import sys + +def isAlly(ally): + if ally == 'hutt': + return 1 + return 0 + +def isEnemy(enemy): + if enemy == 'rebel' or enemy == 'imperial': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/sith_shadow.py b/scripts/faction/sith_shadow.py new file mode 100644 index 00000000..e89c90da --- /dev/null +++ b/scripts/faction/sith_shadow.py @@ -0,0 +1,11 @@ +import sys + +def isAlly(ally): + if ally == 'rebel' or ally == 'imperial': + return 1 + return 0 + +def isEnemy(enemy): + if enemy == 'fs_villager': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/smashball.py b/scripts/faction/smashball.py new file mode 100644 index 00000000..89e21659 --- /dev/null +++ b/scripts/faction/smashball.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'corsec' or enemy == 'cor_swoop': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/spice_collective.py b/scripts/faction/spice_collective.py new file mode 100644 index 00000000..a95f585e --- /dev/null +++ b/scripts/faction/spice_collective.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'narmle' or enemy == 'rorgungan' or enemy == 'kobola': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/spider_nightsister.py b/scripts/faction/spider_nightsister.py new file mode 100644 index 00000000..90a4f892 --- /dev/null +++ b/scripts/faction/spider_nightsister.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'mtn_clan': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/swamp_rat.py b/scripts/faction/swamp_rat.py new file mode 100644 index 00000000..89a851e9 --- /dev/null +++ b/scripts/faction/swamp_rat.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'gungan': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/swoop.py b/scripts/faction/swoop.py new file mode 100644 index 00000000..24e9984a --- /dev/null +++ b/scripts/faction/swoop.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'desert_demon': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/thug.py b/scripts/faction/thug.py new file mode 100644 index 00000000..bd97f757 --- /dev/null +++ b/scripts/faction/thug.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'townsperson': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/townsperson.py b/scripts/faction/townsperson.py new file mode 100644 index 00000000..e747a256 --- /dev/null +++ b/scripts/faction/townsperson.py @@ -0,0 +1,11 @@ +import sys + +def isAlly(ally): + if ally == 'rebel' or ally == 'imperial': + return 1 + return 0 + +def isEnemy(enemy): + if enemy == 'thug' or enemy == 'bandit': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/trade_federation.py b/scripts/faction/trade_federation.py new file mode 100644 index 00000000..74674464 --- /dev/null +++ b/scripts/faction/trade_federation.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'borvo' or enemy == 'naboo_security_force': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/tusken_raider.py b/scripts/faction/tusken_raider.py new file mode 100644 index 00000000..4a81e25b --- /dev/null +++ b/scripts/faction/tusken_raider.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'jawa' or enemy == 'alkhara': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/valarian.py b/scripts/faction/valarian.py new file mode 100644 index 00000000..9d5ef701 --- /dev/null +++ b/scripts/faction/valarian.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'jabba': + return 1 + return 0 \ No newline at end of file diff --git a/scripts/faction/yavin_scavenger.py b/scripts/faction/yavin_scavenger.py new file mode 100644 index 00000000..0c95933c --- /dev/null +++ b/scripts/faction/yavin_scavenger.py @@ -0,0 +1,9 @@ +import sys + +def isAlly(ally): + return 0 + +def isEnemy(enemy): + if enemy == 'hutt' or enemy == 'jabba': + return 1 + return 0 \ No newline at end of file diff --git a/src/protocol/swg/FactionResponseMessage.java b/src/protocol/swg/FactionResponseMessage.java new file mode 100644 index 00000000..ad9f85e9 --- /dev/null +++ b/src/protocol/swg/FactionResponseMessage.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * 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 protocol.swg; + +import java.nio.ByteOrder; +import java.util.Map; +import java.util.TreeMap; + +import org.apache.mina.core.buffer.IoBuffer; + +import resources.common.Opcodes; + +public class FactionResponseMessage extends SWGMessage { + + private Map factionStandingMap; + private int factionRank = 0; + private int rebelPoints = 0; + private int imperialPoints = 0; + + public FactionResponseMessage(Map factionStandingMap, int factionRank) { + this.factionStandingMap = new TreeMap(); + this.factionStandingMap.putAll(factionStandingMap); + this.factionRank = factionRank; + + if (this.factionStandingMap.containsKey("rebel")) { + this.rebelPoints = this.factionStandingMap.get("rebel"); + } + + if (this.factionStandingMap.containsKey("imperial")) { + this.imperialPoints = this.factionStandingMap.get("imperial"); + } + } + + public void deserialize(IoBuffer data) { + + } + + public IoBuffer serialize() { + IoBuffer result = IoBuffer.allocate(26).order(ByteOrder.LITTLE_ENDIAN); + result.setAutoExpand(true); + result.putShort((short) 2); + result.putInt(Opcodes.FactionResponseMessage); + result.putInt(factionRank); + result.putInt(rebelPoints); + result.putInt(imperialPoints); + result.putInt(factionStandingMap.size()); + for (String faction : factionStandingMap.keySet()) { + result.put(getAsciiString(faction)); + } + result.putInt(factionStandingMap.size()); + for (Integer points : factionStandingMap.values()) { + result.putInt(points); + } + + return result.flip(); + } + +} diff --git a/src/resources/common/Opcodes.java b/src/resources/common/Opcodes.java index 7b9b948f..5d03db30 100644 --- a/src/resources/common/Opcodes.java +++ b/src/resources/common/Opcodes.java @@ -56,5 +56,6 @@ public class Opcodes { public static int PlayMusicMessage = CRC.StringtoCRC("PlayMusicMessage"); public static int PlanetTravelPointListRequest = 0x96405D4D; public static int FactionRequestMessage = CRC.StringtoCRC("FactionRequestMessage"); + public static int FactionResponseMessage = CRC.StringtoCRC("FactionResponseMessage"); } diff --git a/src/resources/common/StateStatus.java b/src/resources/common/StateStatus.java index e4039a46..e97026c7 100644 --- a/src/resources/common/StateStatus.java +++ b/src/resources/common/StateStatus.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * 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 resources.common; public class StateStatus { diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index ea367d8f..45b76ada 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -143,7 +143,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { private SWGList dotList = new SWGList(); @NotPersistent private ScheduledFuture incapTask; - + private boolean staticNPC = false; // temp public CreatureObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) { diff --git a/src/services/gcw/FactionService.java b/src/services/gcw/FactionService.java index 5792f2cd..ee1122c6 100644 --- a/src/services/gcw/FactionService.java +++ b/src/services/gcw/FactionService.java @@ -32,16 +32,17 @@ import org.apache.mina.core.session.IoSession; import org.python.core.Py; import org.python.core.PyObject; +import protocol.swg.FactionResponseMessage; + import resources.common.FileUtilities; import resources.common.Opcodes; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; -import resources.objects.tangible.TangibleObject; import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; +import engine.clients.Client; import engine.resources.common.CRC; -import engine.resources.objects.SWGObject; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -85,6 +86,10 @@ public class FactionService implements INetworkDispatch { } public void addFactionStanding(CreatureObject creature, String faction, int factionStanding) { + if (!isFaction(faction)) { + return; + } + if (creature == null) { return; } @@ -99,6 +104,10 @@ public class FactionService implements INetworkDispatch { } public void removeFactionStanding(CreatureObject creature, String faction, int factionStanding) { + if (!isFaction(faction)) { + return; + } + if (creature == null) { return; } @@ -109,32 +118,7 @@ public class FactionService implements INetworkDispatch { return; } - player.modifyFactionStanding(faction, factionStanding); - } - - public void updateFactionStanding(SWGObject killedObject) { - if (!(killedObject instanceof TangibleObject) || killedObject == null) { - return; - } - - TangibleObject target = (TangibleObject) killedObject; - - if (!(((TangibleObject) killedObject).getKiller() instanceof TangibleObject) || ((TangibleObject) killedObject).getKiller() == null) { - return; - } - - TangibleObject killer = ((TangibleObject) killedObject).getKiller(); - - if (killer != null && target != null && isFaction(target.getFaction())) { - if (FileUtilities.doesFileExist("scripts/faction/standing/" + target.getFaction() + ".py")) { - - PyObject method = core.scriptService.getMethod("scripts/faction/standing/", target.getFaction(), "update"); - - if (method != null && method.isCallable()) { - method.__call__(Py.java2py(core), Py.java2py(killer), Py.java2py(target)); - } - } - } + player.modifyFactionStanding(faction, -factionStanding); } public boolean isFaction(String faction) { @@ -145,6 +129,62 @@ public class FactionService implements INetworkDispatch { return false; } + /* + * Returns true if creature2 is an ally of creature1 + * + * Will be useful for NPC AI, so they know who to help and who to be indifferent to. + */ + public boolean isFactionAlly(CreatureObject creature1, CreatureObject creature2) { + if (creature1 == null || creature2 == null) { + return false; + } + + String faction1 = creature1.getFaction(); + String faction2 = creature2.getFaction(); + + if (!isFaction(faction1) || !isFaction(faction2)) { + return false; + } + + if (FileUtilities.doesFileExist("scripts/faction/" + faction1 + ".py")) { + PyObject method = core.scriptService.getMethod("scripts/faction/", faction1, "isAlly"); + + if (method != null && method.isCallable()) { + return ((method.__call__(Py.java2py(faction2)).asInt() == 1) ? true : false); + } + } + + return false; + } + + /* + * Returns true if creature2 is an enemy of creature1 + * + * Will be useful for NPC AI, so they know who to attack and who to be indifferent to. + */ + public boolean isFactionEnemy(CreatureObject creature1, CreatureObject creature2) { + if (creature1 == null || creature2 == null) { + return false; + } + + String faction1 = creature1.getFaction(); + String faction2 = creature2.getFaction(); + + if (!isFaction(faction1) || !isFaction(faction2)) { + return false; + } + + if (FileUtilities.doesFileExist("scripts/faction/" + faction1 + ".py")) { + PyObject method = core.scriptService.getMethod("scripts/faction/", faction1, "isEnemy"); + + if (method != null && method.isCallable()) { + return ((method.__call__(Py.java2py(faction2)).asInt() == 1) ? true : false); + } + } + + return false; + } + public Map getFactionMap() { return factionMap; } @@ -156,7 +196,25 @@ public class FactionService implements INetworkDispatch { @Override public void handlePacket(IoSession session, IoBuffer buffer) throws Exception { + Client client = core.getClient((int) session.getAttribute("connectionId")); + if (client == null) { + return; + } + + CreatureObject creature = (CreatureObject) client.getParent(); + + if (creature == null) { + return; + } + + PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); + + if (player == null) { + return; + } + + session.write((new FactionResponseMessage(player.getFactionStandingMap(), 0)).serialize()); } }); diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index b08ad2f9..6ae5c535 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -219,7 +219,7 @@ public class ObjectService implements INetworkDispatch { object.setAttachment("serverTemplate", ((customServerTemplate != null) ? customServerTemplate : object.getTemplate())); object.setisInSnapshot(isSnapshot); - loadServerTemplate(object); + //loadServerTemplate(object); objectList.put(objectID, object); @@ -351,18 +351,6 @@ public class ObjectService implements INetworkDispatch { } } - if (object instanceof CreatureObject) { - if (core.factionService.getFactionMap().containsKey(((CreatureObject) object).getFaction())) { - if (FileUtilities.doesFileExist(filePath)) { - PyObject method = core.scriptService.getMethod("scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", ""), object.getTemplate().split("shared_" , 2)[1].replace(".iff", ""), "destroy"); - - if (method != null && method.isCallable()) { - method.__call__(Py.java2py(core), Py.java2py(((TangibleObject) object).getKiller()), Py.java2py(object)); - } - } - } - } - if (object == null) { return; } @@ -456,10 +444,16 @@ public class ObjectService implements INetworkDispatch { String filePath = "scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", "") + object.getTemplate().split("shared_" , 2)[1].replace(".iff", "") + ".py"; if (FileUtilities.doesFileExist(filePath)) { - PyObject method = core.scriptService.getMethod("scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", ""), object.getTemplate().split("shared_" , 2)[1].replace(".iff", ""), "useObject"); + filePath = "scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", ""); + String fileName = object.getTemplate().split("shared_" , 2)[1].replace(".iff", ""); - if (method != null && method.isCallable()) { - method.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(object)); + PyObject method1 = core.scriptService.getMethod("scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", ""), object.getTemplate().split("shared_" , 2)[1].replace(".iff", ""), "use"); + PyObject method2 = core.scriptService.getMethod("scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", ""), object.getTemplate().split("shared_" , 2)[1].replace(".iff", ""), "useObject"); + + if (method1 != null && method1.isCallable()) { + method1.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(object)); + } else if (method2 != null && method2.isCallable()) { + method2.__call__(Py.java2py(core), Py.java2py(creature), Py.java2py(object)); } } } From aa0fe46fbacb18c17d6ae531ca7df2133ea17df1 Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Fri, 6 Dec 2013 23:21:31 +0100 Subject: [PATCH 06/23] Fixed Supply Drop command for officers. The Tactical Supply Drop command was removed from the game and was merged with the Medical Supply Drop and then became Supply Drop. The script can properly check if the actor has the tactical serum expertise box or not. --- scripts/commands/of_medical_sup_1.py | 52 ++++++++++++++ scripts/commands/of_tactical_sup_2.py | 13 ---- scripts/commands/of_tactical_sup_3.py | 13 ---- scripts/commands/of_tactical_sup_4.py | 13 ---- scripts/commands/of_tactical_sup_5.py | 13 ---- scripts/commands/of_tactical_sup_6.py | 70 ------------------- .../expertise/expertise_of_tactical_sup_1.py | 4 -- src/services/combat/CombatCommands.java | 7 +- 8 files changed, 53 insertions(+), 132 deletions(-) create mode 100644 scripts/commands/of_medical_sup_1.py delete mode 100644 scripts/commands/of_tactical_sup_2.py delete mode 100644 scripts/commands/of_tactical_sup_3.py delete mode 100644 scripts/commands/of_tactical_sup_4.py delete mode 100644 scripts/commands/of_tactical_sup_5.py delete mode 100644 scripts/commands/of_tactical_sup_6.py diff --git a/scripts/commands/of_medical_sup_1.py b/scripts/commands/of_medical_sup_1.py new file mode 100644 index 00000000..bc8c4935 --- /dev/null +++ b/scripts/commands/of_medical_sup_1.py @@ -0,0 +1,52 @@ +from engine.resources.container import StaticContainerPermissions +import time +import sys + +def setup(core, actor, target, command): + return + +def run(core, actor, target, commandString): + doStimDrop(core, actor) + return + +def doStimDrop(core, actor): + actor.sendSystemMessage('Stims incoming Mr. Bossman!', 0) + stcSvc = core.staticService + shuttle = stcSvc.spawnObject('object/creature/npc/theme_park/shared_lambda_shuttle.iff', actor.getPlanet().getName(), long(0), actor.getPosition().x, actor.getPosition().y, actor.getPosition().z, actor.getOrientation().y, actor.getOrientation().w) + shuttle.setPosture(0) + time.sleep(10) # Wait time before shuttle arrives after command is called + shuttle.setPosture(2) + time.sleep(20) # wait time for the crate to show (length of landing animation for shuttle) + spawnCrate(core, actor, shuttle) + time.sleep(5) # Wait time for the shuttle to leave after crate is spawned + shuttle.setPosture(0) + time.sleep(20) # How long the take-off sequence is, until the Shuttle is destroyed + core.objectService.destroyObject(shuttle) + return + +def spawnCrate(core, actor, shuttle): + crate = core.staticService.spawnObject('object/tangible/container/loot/shared_npe_loot_crate_low.iff', shuttle.getPlanet().getName(), long(0), shuttle.getPosition().x, shuttle.getPosition().y, shuttle.getPosition().z, shuttle.getOrientation().y, shuttle.getOrientation().w) + crate.setCustomName('Supply Crate') + + group = core.objectService.getObject(actor.getGroupId()) + + permissions = StaticContainerPermissions() + permissions.canRemove(group, crate) + permissions.canView(group, crate) + crate.setContainerPermissions(permissions) + + if actor.hasSkill('expertise_of_tactical_sup_1'): + for i in range(0, 8): + tactical = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) #FIXME: Use the correct template + tactical.setCustomName('Tactical Serum A') + crate.add(tactical) + + for i in range(0, 8): + stimpack = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_e.iff', actor.getPlanet()) #FIXME: Use the correct template + stimpack.setCustomName('Field Stimpack A') + crate.add(stimpack) + + time.sleep(60) + core.objectService.destroyObject(crate) + + return \ No newline at end of file diff --git a/scripts/commands/of_tactical_sup_2.py b/scripts/commands/of_tactical_sup_2.py deleted file mode 100644 index 76c7b5aa..00000000 --- a/scripts/commands/of_tactical_sup_2.py +++ /dev/null @@ -1,13 +0,0 @@ -import sys - -def setup(core, actor, buff): - return - -def run(core, actor, target, commandString): - print (' shuttle called!') - lambdaShuttle = stcSvc.spawnObject('object/creature/npc/theme_park/shared_event_lambda_shuttle.iff', actor.getPlanet().getName(), - long(0), actor.getPosition().x, actor.getPosition().y, actor.getPosition().z, actor.getOrientation().y, actor.getOrientation().w) - - lambdaShuttle.setPosture(0) # 0 or 2? - print ('posture set!') - return \ No newline at end of file diff --git a/scripts/commands/of_tactical_sup_3.py b/scripts/commands/of_tactical_sup_3.py deleted file mode 100644 index 76c7b5aa..00000000 --- a/scripts/commands/of_tactical_sup_3.py +++ /dev/null @@ -1,13 +0,0 @@ -import sys - -def setup(core, actor, buff): - return - -def run(core, actor, target, commandString): - print (' shuttle called!') - lambdaShuttle = stcSvc.spawnObject('object/creature/npc/theme_park/shared_event_lambda_shuttle.iff', actor.getPlanet().getName(), - long(0), actor.getPosition().x, actor.getPosition().y, actor.getPosition().z, actor.getOrientation().y, actor.getOrientation().w) - - lambdaShuttle.setPosture(0) # 0 or 2? - print ('posture set!') - return \ No newline at end of file diff --git a/scripts/commands/of_tactical_sup_4.py b/scripts/commands/of_tactical_sup_4.py deleted file mode 100644 index 76c7b5aa..00000000 --- a/scripts/commands/of_tactical_sup_4.py +++ /dev/null @@ -1,13 +0,0 @@ -import sys - -def setup(core, actor, buff): - return - -def run(core, actor, target, commandString): - print (' shuttle called!') - lambdaShuttle = stcSvc.spawnObject('object/creature/npc/theme_park/shared_event_lambda_shuttle.iff', actor.getPlanet().getName(), - long(0), actor.getPosition().x, actor.getPosition().y, actor.getPosition().z, actor.getOrientation().y, actor.getOrientation().w) - - lambdaShuttle.setPosture(0) # 0 or 2? - print ('posture set!') - return \ No newline at end of file diff --git a/scripts/commands/of_tactical_sup_5.py b/scripts/commands/of_tactical_sup_5.py deleted file mode 100644 index 76c7b5aa..00000000 --- a/scripts/commands/of_tactical_sup_5.py +++ /dev/null @@ -1,13 +0,0 @@ -import sys - -def setup(core, actor, buff): - return - -def run(core, actor, target, commandString): - print (' shuttle called!') - lambdaShuttle = stcSvc.spawnObject('object/creature/npc/theme_park/shared_event_lambda_shuttle.iff', actor.getPlanet().getName(), - long(0), actor.getPosition().x, actor.getPosition().y, actor.getPosition().z, actor.getOrientation().y, actor.getOrientation().w) - - lambdaShuttle.setPosture(0) # 0 or 2? - print ('posture set!') - return \ No newline at end of file diff --git a/scripts/commands/of_tactical_sup_6.py b/scripts/commands/of_tactical_sup_6.py deleted file mode 100644 index ec8f96db..00000000 --- a/scripts/commands/of_tactical_sup_6.py +++ /dev/null @@ -1,70 +0,0 @@ -from engine.resources.container import StaticContainerPermissions -import time -import sys - -def setup(core, actor, buff): - return - -def run(core, actor, target, commandString): - doStimDrop(core, actor) - return - -def doStimDrop(core, actor): - stcSvc = core.staticService - time.sleep(10) # Wait time before shuttle arrives after command is called - shuttle = stcSvc.spawnObject('object/creature/npc/theme_park/shared_lambda_shuttle.iff', actor.getPlanet().getName(), long(0), actor.getPosition().x, actor.getPosition().y, actor.getPosition().z, actor.getOrientation().y, actor.getOrientation().w) - shuttle.setPosture(0) - time.sleep(1) - shuttle.setPosture(2) - time.sleep(20) # wait time for the crate to show (length of landing animation for shuttle) - spawnCrate(core, actor, shuttle) - time.sleep(5) # Wait time for the shuttle to leave after crate is spawned - shuttle.setPosture(0) - time.sleep(20) # How long the take-off sequence is, until the Shuttle is destroyed - core.objectService.destroyObject(shuttle) - return - -def spawnCrate(core, actor, shuttle): - crate = core.staticService.spawnObject('object/tangible/container/loot/shared_npe_loot_crate_low.iff', shuttle.getPlanet().getName(), long(0), shuttle.getPosition().x, shuttle.getPosition().y, shuttle.getPosition().z, shuttle.getOrientation().y, shuttle.getOrientation().w) - crate.setCustomName('Supply Crate') - - permissions = StaticContainerPermissions() - permissions.canRemove(actor, crate) - permissions.canView(actor, crate) - crate.setContainerPermissions(permissions) - - tac1 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac1) - tac2 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac2) - tac3 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac3) - tac4 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac4) - tac5 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac5) - tac6 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac6) - tac7 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac7) - tac8 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac8) - - stim1 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim1) - stim2 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim2) - stim3 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim3) - stim4 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim4) - stim5 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim5) - stim6 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim6) - stim7 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim7) - stim8 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim8) - - return \ No newline at end of file diff --git a/scripts/expertise/expertise_of_tactical_sup_1.py b/scripts/expertise/expertise_of_tactical_sup_1.py index d95ef2a5..451c6fbe 100644 --- a/scripts/expertise/expertise_of_tactical_sup_1.py +++ b/scripts/expertise/expertise_of_tactical_sup_1.py @@ -37,12 +37,8 @@ def removeExpertisePoint(core, actor): # this checks what abilities the player gets by level, need to also call this on level-up def addAbilities(core, actor, player): - actor.addAbility('of_tactical_sup_1') - return def removeAbilities(core, actor, player): - actor.removeAbility('of_tactical_sup_1') - return diff --git a/src/services/combat/CombatCommands.java b/src/services/combat/CombatCommands.java index 7ba5c596..1544a0ce 100644 --- a/src/services/combat/CombatCommands.java +++ b/src/services/combat/CombatCommands.java @@ -516,15 +516,10 @@ public class CombatCommands { core.commandService.registerCommand("of_buff_def_9"); core.commandService.registerCommand("of_emergency_shield"); core.commandService.registerCommand("of_firepower_1"); + core.commandService.registerCommand("of_medical_sup_1"); core.commandService.registerCommand("of_purge_1"); core.commandService.registerCommand("of_scatter_1"); core.commandService.registerCommand("of_stimulator_1"); - core.commandService.registerCommand("of_tactical_sup_1"); - core.commandService.registerCommand("of_tactical_sup_2"); - core.commandService.registerCommand("of_tactical_sup_3"); - core.commandService.registerCommand("of_tactical_sup_4"); - core.commandService.registerCommand("of_tactical_sup_5"); - core.commandService.registerCommand("of_tactical_sup_6"); // Smuggler From abf7e90329ee1f874a9211548f35e0c78c2ec50d Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Sat, 7 Dec 2013 02:17:20 +0100 Subject: [PATCH 07/23] Deleted another unused command script --- scripts/commands/of_tactical_sup_1.py | 72 --------------------------- 1 file changed, 72 deletions(-) delete mode 100644 scripts/commands/of_tactical_sup_1.py diff --git a/scripts/commands/of_tactical_sup_1.py b/scripts/commands/of_tactical_sup_1.py deleted file mode 100644 index 7ec7b103..00000000 --- a/scripts/commands/of_tactical_sup_1.py +++ /dev/null @@ -1,72 +0,0 @@ -from engine.resources.container import StaticContainerPermissions -import time -import sys - -def setup(core, actor, target, command): - return - -def run(core, actor, target, commandString): - doStimDrop(core, actor) - return - -def doStimDrop(core, actor): - stcSvc = core.staticService - shuttle = stcSvc.spawnObject('object/creature/npc/theme_park/shared_lambda_shuttle.iff', actor.getPlanet().getName(), long(0), actor.getPosition().x, actor.getPosition().y, actor.getPosition().z, actor.getOrientation().y, actor.getOrientation().w) - shuttle.setPosture(0) - time.sleep(10) # Wait time before shuttle arrives after command is called - shuttle.setPosture(2) - time.sleep(20) # wait time for the crate to show (length of landing animation for shuttle) - spawnCrate(core, actor, shuttle) - time.sleep(5) # Wait time for the shuttle to leave after crate is spawned - shuttle.setPosture(0) - time.sleep(20) # How long the take-off sequence is, until the Shuttle is destroyed - core.objectService.destroyObject(shuttle) - return - -def spawnCrate(core, actor, shuttle): - crate = core.staticService.spawnObject('object/tangible/container/loot/shared_npe_loot_crate_low.iff', shuttle.getPlanet().getName(), long(0), shuttle.getPosition().x, shuttle.getPosition().y, shuttle.getPosition().z, shuttle.getOrientation().y, shuttle.getOrientation().w) - crate.setCustomName('Supply Crate') - - permissions = StaticContainerPermissions() - permissions.canRemove(actor, crate) - permissions.canView(actor, crate) - crate.setContainerPermissions(permissions) - - tac1 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac1) - tac2 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac2) - tac3 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac3) - tac4 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac4) - tac5 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac5) - tac6 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac6) - tac7 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac7) - tac8 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) - crate.add(tac8) - - stim1 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim1) - stim2 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim2) - stim3 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim3) - stim4 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim4) - stim5 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim5) - stim6 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim6) - stim7 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim7) - stim8 = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_generic_a.iff', actor.getPlanet()) - crate.add(stim8) - - time.sleep(60) - core.objectService.destroyObject(crate) - - return \ No newline at end of file From 64f332bea26d10afd4b25f6feebd49d0c6c43d0f Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Sat, 7 Dec 2013 02:19:31 +0100 Subject: [PATCH 08/23] Supply Drop now uses the correct crate --- scripts/commands/of_medical_sup_1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/commands/of_medical_sup_1.py b/scripts/commands/of_medical_sup_1.py index bc8c4935..b7186ab6 100644 --- a/scripts/commands/of_medical_sup_1.py +++ b/scripts/commands/of_medical_sup_1.py @@ -25,7 +25,7 @@ def doStimDrop(core, actor): return def spawnCrate(core, actor, shuttle): - crate = core.staticService.spawnObject('object/tangible/container/loot/shared_npe_loot_crate_low.iff', shuttle.getPlanet().getName(), long(0), shuttle.getPosition().x, shuttle.getPosition().y, shuttle.getPosition().z, shuttle.getOrientation().y, shuttle.getOrientation().w) + crate = core.staticService.spawnObject('object/tangible/container/drum/shared_supply_drop_crate.iff', shuttle.getPlanet().getName(), long(0), shuttle.getPosition().x, shuttle.getPosition().y, shuttle.getPosition().z, shuttle.getOrientation().y, shuttle.getOrientation().w) crate.setCustomName('Supply Crate') group = core.objectService.getObject(actor.getGroupId()) @@ -37,7 +37,7 @@ def spawnCrate(core, actor, shuttle): if actor.hasSkill('expertise_of_tactical_sup_1'): for i in range(0, 8): - tactical = core.objectService.createObject('object/tangible/medicine/instant_stimpack/shared_stimpack_syren.iff', actor.getPlanet()) #FIXME: Use the correct template + tactical = core.objectService.createObject('object/tangible/loot/generic_usable/shared_stim_syringe_generic.iff', actor.getPlanet()) #FIXME: Use the correct template tactical.setCustomName('Tactical Serum A') crate.add(tactical) From 14fece35b65ae0dac22a82a56fdaf413d9a24a77 Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Sat, 7 Dec 2013 04:28:11 +0100 Subject: [PATCH 09/23] Fixed incorrect math (Healing Potency) Healing Potency now functions properly. --- src/services/combat/CombatService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 06a84ce2..dfa1d7ec 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -888,7 +888,7 @@ public class CombatService implements INetworkDispatch { if(healer.getSkillMod("expertise_healing_line_sp_heal") != null) healPotency += healer.getSkillMod("expertise_healing_line_sp_heal").getBase(); if(healPotency > 0) - healAmount += (healAmount * (healPotency / 100)); + healAmount += ((healAmount * healPotency) / 100); if(target.getSkillMod("expertise_healing_reduction") != null) healAmount *= (1 - target.getSkillMod("expertise_healing_reduction").getBase() / 100); From 4f1142a8d1b7e2af4e3bc58f382460595f382dde Mon Sep 17 00:00:00 2001 From: Levarrishawk Date: Fri, 6 Dec 2013 22:46:07 -0500 Subject: [PATCH 10/23] Corrected "Doaba Guerfel Starport" travel point. --- scripts/static_travel_points.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/static_travel_points.py b/scripts/static_travel_points.py index 54b19a77..26ac3f85 100644 --- a/scripts/static_travel_points.py +++ b/scripts/static_travel_points.py @@ -40,11 +40,10 @@ def corelliaPoints(core, planet): trvSvc.addTravelPoint(planet, "Kor Vella Shuttleport", -3775, 86, 3234) trvSvc.addTravelPoint(planet, "Bela Vistal Shuttleport A", 6644, 330, -5922) trvSvc.addTravelPoint(planet, "Bela Vistal Shuttleport B", 6930, 330, -5534) - trvSvc.addTravelPoint(planet, "Coronet Starport", -51, 28, -4735) trvSvc.addTravelPoint(planet, "Tyrena Starport", -4975, 21, -2230) trvSvc.addTravelPoint(planet, "Kor Vella Starport", -3136, 31, 2894) - trvSvc.addTravelPoint(planet, "Doaba Guerful Starport", 3377, 308, 5605) + trvSvc.addTravelPoint(planet, "Doaba Guerfel Starport", 3377, 308, 5605) return def dantooinePoints(core, planet): From 805ef52f73c6ff3370d0bc849aa0a0184b126275 Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Sat, 7 Dec 2013 05:11:52 +0100 Subject: [PATCH 11/23] Soothing Aura for LSJ This expertise now functions as intended. --- src/services/combat/CombatService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index dfa1d7ec..52f0a5d3 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -887,6 +887,8 @@ public class CombatService implements INetworkDispatch { healPotency += healer.getSkillMod("expertise_healing_line_sm_heal").getBase(); if(healer.getSkillMod("expertise_healing_line_sp_heal") != null) healPotency += healer.getSkillMod("expertise_healing_line_sp_heal").getBase(); + if(healer.getSkillMod("expertise_stance_healing_line_fs_heal") != null) + healPotency += healer.getSkillMod("expertise_stance_healing_line_fs_heal").getBase(); if(healPotency > 0) healAmount += ((healAmount * healPotency) / 100); if(target.getSkillMod("expertise_healing_reduction") != null) From 2a8760a47447ed98defbc3d842a4c6697965e93d Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Sat, 7 Dec 2013 16:22:42 +0100 Subject: [PATCH 12/23] Fixed heal cooldown expertise for Officer --- src/services/combat/CombatService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 52f0a5d3..1ee06890 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -405,11 +405,18 @@ public class CombatService implements INetworkDispatch { private void sendHealPackets(CreatureObject attacker, CreatureObject target, WeaponObject weapon, CombatCommand command, int actionCounter) { + float cooldown = 0; + CombatAction combatAction = new CombatAction(CRC.StringtoCRC(command.getDefaultAnimations()[0]), attacker.getObjectID(), weapon.getObjectID(), target.getObjectID(), command.getCommandCRC()); ObjControllerMessage objController = new ObjControllerMessage(0x1B, combatAction); attacker.notifyObserversInRange(objController, true, 125); - StartTask startTask = new StartTask(actionCounter, attacker.getObjectID(), command.getCommandCRC(), CRC.StringtoCRC(command.getCooldownGroup()), command.getCooldown()); + cooldown = command.getCooldown(); + + if(attacker.getSkillMod("expertise_cooldown_line_of_heal") != null) + cooldown -= 2*(attacker.getSkillMod("expertise_cooldown_line_of_heal").getBase()); + + StartTask startTask = new StartTask(actionCounter, attacker.getObjectID(), command.getCommandCRC(), CRC.StringtoCRC(command.getCooldownGroup()), cooldown); ObjControllerMessage objController2 = new ObjControllerMessage(0x0B, startTask); attacker.getClient().getSession().write(objController2.serialize()); From 9683f4c16438b621f7d07791ce131e6de7533a2e Mon Sep 17 00:00:00 2001 From: darkk1138 Date: Sat, 7 Dec 2013 16:34:19 +0100 Subject: [PATCH 13/23] add startdance, stopdance, flourish and bandflourish commands --- scripts/commands/bandflourish.py | 57 ++++++++++++++++ scripts/commands/flourish.py | 31 +++++++++ scripts/commands/startdance.py | 61 +++++++++++------ scripts/commands/stopdance.py | 19 ++++++ .../creature/CreatureMessageBuilder.java | 14 +--- .../objects/creature/CreatureObject.java | 66 ++++++++++++++++--- src/services/EntertainmentService.java | 26 ++++++-- 7 files changed, 227 insertions(+), 47 deletions(-) create mode 100644 scripts/commands/bandflourish.py create mode 100644 scripts/commands/flourish.py create mode 100644 scripts/commands/stopdance.py diff --git a/scripts/commands/bandflourish.py b/scripts/commands/bandflourish.py new file mode 100644 index 00000000..75c17b32 --- /dev/null +++ b/scripts/commands/bandflourish.py @@ -0,0 +1,57 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + + if len(commandString) <= 0: + actor.sendSystemMessage('@performance:flourish_not_valid', 0) + return + + if commandString == 'on': + actor.setAcceptBandflourishes(1) + actor.sendSystemMessage('@performance:band_flourish_status_on', 0) + return + if commandString == 'off': + actor.setAcceptBandflourishes(0) + actor.sendSystemMessage('@performance:band_flourish_status_off', 0) + return + + try: + flourish = int(commandString) + except ValueError: + actor.sendSystemMessage('@performance:flourish_not_valid', 0) + return + + if flourish < 1 or flourish > 9: + actor.sendSystemMessage('@performance:flourish_not_valid', 0) + return + + if actor.getPerformanceId() <= 0: + actor.sendSystemMessage('@performance:flourish_not_performing', 0) + return + + animation = 'skill_action_' + str(flourish) + if flourish == 9: + animation = 'mistake' + + group = core.objectService.getObject(actor.getGroupId()) + if not group: + if actor.getAcceptBandflourishes(): + actor.sendSystemMessage('@performance:flourish_perform_band_self', 0) + actor.sendSystemMessage('@performance:flourish_perform', 0) + actor.doSkillAnimation(animation) + return + + for creature in group.getMemberList(): + if creature.getAcceptBandflourishes(): + if actor == creature: + creature.sendSystemMessage('@performance:flourish_perform_band_self', 0) + else: + creature.sendSystemMessage('@performance:flourish_perform_band_member', 0) + creature.sendSystemMessage('@performance:flourish_perform', 0) + creature.doSkillAnimation(animation) + return + + diff --git a/scripts/commands/flourish.py b/scripts/commands/flourish.py new file mode 100644 index 00000000..0bb6cb93 --- /dev/null +++ b/scripts/commands/flourish.py @@ -0,0 +1,31 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + + if len(commandString) <= 0: + actor.sendSystemMessage('@performance:flourish_not_valid', 0) + return + + try: + flourish = int(commandString) + except ValueError: + actor.sendSystemMessage('@performance:flourish_not_valid', 0) + return + + if flourish < 1 or flourish > 9: + actor.sendSystemMessage('@performance:flourish_not_valid', 0) + return + + if actor.getPerformanceId() <= 0: + actor.sendSystemMessage('@performance:flourish_not_performing', 0) + return + + actor.sendSystemMessage('@performance:flourish_perform', 0) + animation = 'skill_action_' + str(flourish) + if flourish == 9: + animation = 'mistake' + + actor.doSkillAnimation(animation) diff --git a/scripts/commands/startdance.py b/scripts/commands/startdance.py index a8d78ed7..18aa211c 100644 --- a/scripts/commands/startdance.py +++ b/scripts/commands/startdance.py @@ -12,23 +12,28 @@ def setup(): def run(core, actor, target, commandString): entSvc = core.entertainmentService + global actorObject + global coreObject + global availableDances + global suiWindow + actorObject = actor + coreObject = core if len(commandString) > 0: params = commandString.split(" ") - startDance(core, actor, params[0]) + startDance(core, actor, params[0], 0) return else: - available_dances = entSvc.getAvailableDances(actor) + availableDances = entSvc.getAvailableDances(actor) + print availableDances suiSvc = core.suiService - suiWindow = suiSvc.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "@performance:select_dance", "@performance:available_dances", available_dances, actor, actor, 10) + suiWindow = suiSvc.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "@performance:select_dance", "@performance:available_dances", availableDances, actor, None, 10) - returnParams = Vector() - returnParams.add('btnOk:Text') - returnParams.add('btnCancel:Text') - suiWindow.addHandler(0, '', Trigger.TRIGGER_OK, returnParams, handleStartdance) - suiWindow.addHandler(1, '', Trigger.TRIGGER_CANCEL, returnParams, handleStartdance) + returnList = Vector() + returnList.add("List.lstList:SelectedRow") + suiWindow.addHandler(0, '', Trigger.TRIGGER_OK, returnList, handleStartdance) suiSvc.openSUIWindow(suiWindow) return @@ -36,40 +41,56 @@ def run(core, actor, target, commandString): def handleStartdance(core, owner, eventType, returnList): + + item = suiWindow.getMenuItems().get(int(returnList.get(0))) + + if not item: + return + + #if eventType == 0: + startDance(coreObject, actorObject, '', int(item.getObjectId())) return -def startDance(core, actor, danceName): +def startDance(core, actor, danceName, visual): entSvc = core.entertainmentService - if not entSvc.isDance(danceName): + if visual <= 0: + visual = entSvc.getDanceVisualId(danceName) + + if visual <= 0: + return + + if not entSvc.isDance(visual): actor.sendSystemMessage('@performance:dance_unknown_self',0) return - if not entSvc.canDance(actor, danceName): + if not entSvc.canDance(actor, visual): actor.sendSystemMessage('@performance:dance_lack_skill_self',0) return - return if actor.getPerformanceId() > 0: actor.sendSystemMessage('@performance:already_performing_self',0) return - performance = entSvc.getPerformance(danceName) - #TODO: check costume, posture, etc + #TODO: check costume, posture, etc? - actor.sendSystemMessage('@performance:dance_start_self'); + actor.sendSystemMessage('@performance:dance_start_self',0); actor.notifyAudience('@performance:dance_start_other'); + danceVisual = 'dance_' + str(visual) + if not actor.getPerformanceWatchee(): - #this also needs to notify the client with a delta4 + #this also notifies the client with a delta4 actor.setPerformanceWatchee(actor) - + #this should send a CREO3 actor.setPosture(0x09); + + dance = entSvc.getDance(visual) + # send CREO6 here # second param is some sort of counter or start tick - actor.startPerformance(performance.getLineNumber(), 0xCDCC4C3C, 'dance_' . performance.getVisualId true) - - + actor.startPerformance(dance.getLineNumber(), -842249156 , danceVisual, 1) + return diff --git a/scripts/commands/stopdance.py b/scripts/commands/stopdance.py new file mode 100644 index 00000000..0f2d4763 --- /dev/null +++ b/scripts/commands/stopdance.py @@ -0,0 +1,19 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + entSvc = core.entertainmentService + + if (actor.getPerformanceId() <= 0): + actor.sendSystemMessage('@performance:dance_not_performing', 0) + return + + #since we need to stop performance for any posture change, + # all packets are triggered in setPosture. + # this may not be very consistent, but it prevents + # duplicate code. + actor.setPosture(0x00) + + return diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index 042f12eb..39f35820 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -1000,7 +1000,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putInt(performanceId); int size = buffer.position(); buffer.flip(); - buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 2, buffer, size + 4); + buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x14, buffer, size + 4); return buffer; } @@ -1009,15 +1009,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putInt(performanceCounter); int size = buffer.position(); buffer.flip(); - buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 2, buffer, size + 4); - return buffer; - } - - public IoBuffer buildSkillName(String skillName) { - IoBuffer buffer = bufferPool.allocate(getUnicodeString(skillName).length, false).order(ByteOrder.LITTLE_ENDIAN); - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 2, buffer, size + 4); + buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x13, buffer, size + 4); return buffer; } @@ -1026,7 +1018,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.put((byte) ((doStart) ? 1 : 0)); int size = buffer.position(); buffer.flip(); - buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 2, buffer, size + 4); + buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x1B, buffer, size + 4); return buffer; } diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index b1787033..c2ce6fff 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -57,7 +57,7 @@ import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; -@Entity(version=4) +@Entity(version=5) public class CreatureObject extends TangibleObject implements IPersistent { @NotPersistent @@ -117,6 +117,11 @@ public class CreatureObject extends TangibleObject implements IPersistent { private byte moodId = 0; private int performanceCounter = 0; private int performanceId = 0; + //FIXME: this is a bit of a hack. + private boolean performanceType = false; + //FIXME: hmm.. or persistent? + @NotPersistent + private boolean acceptBandflourishes = true; private CreatureObject performanceWatchee; private CreatureObject performanceListenee; private int health = 1000; @@ -296,15 +301,25 @@ public class CreatureObject extends TangibleObject implements IPersistent { } public void setPosture(byte posture) { + boolean needsStopPerformance = false; synchronized(objectMutex) { + if (this.posture == 0x09) { + needsStopPerformance = true; + } this.posture = posture; } + IoBuffer postureDelta = messageBuilder.buildPostureDelta(posture); Posture postureUpdate = new Posture(getObjectID(), posture); ObjControllerMessage objController = new ObjControllerMessage(0x1B, postureUpdate); notifyObservers(postureDelta, true); notifyObservers(objController, true); + + if (needsStopPerformance) { + stopPerformance(); + } + } @Override @@ -738,6 +753,14 @@ public class CreatureObject extends TangibleObject implements IPersistent { notifyObservers(messageBuilder.buildCurrentAnimationDelta(currentAnimation), true); } + + public void doSkillAnimation(String skillAnimation) { + Animation animation = new Animation(getObjectId(), skillAnimation); + ObjControllerMessage objController = new ObjControllerMessage(0x1B, animation); + + notifyObservers(objController, true); + + } public String getMoodAnimation() { synchronized(objectMutex) { @@ -885,6 +908,14 @@ public class CreatureObject extends TangibleObject implements IPersistent { } } + public boolean getAcceptBandflourishes() { + return acceptBandflourishes; + } + + public void setAcceptBandflourishes(boolean acceptBandflourishes) { + this.acceptBandflourishes = acceptBandflourishes; + } + public SWGList getEquipmentList() { return equipmentList; } @@ -1324,26 +1355,41 @@ public class CreatureObject extends TangibleObject implements IPersistent { } } - public void startPerformance(int performanceId, int performanceCounter, String skillName, boolean doStart) { + public void startPerformance(int performanceId, int performanceCounter, String skillName, boolean isDance) { synchronized(objectMutex) { this.performanceId = performanceId; this.performanceCounter = performanceCounter; + this.currentAnimation = skillName; + this.performanceType = isDance; } - if (doStart) { getClient().getSession().write(messageBuilder.buildPerformanceId(performanceId)); } - if (doStart) { getClient().getSession().write(messageBuilder.buildPerformanceCounter(performanceCounter)); } - if (doStart) { getClient().getSession().write(messageBuilder.buildSkillName(skillName)); } - getClient().getSession().write(messageBuilder.buildStartPerformance(doStart)); + getClient().getSession().write(messageBuilder.buildPerformanceId(performanceId)); + getClient().getSession().write(messageBuilder.buildPerformanceCounter(performanceCounter)); + getClient().getSession().write(messageBuilder.buildCurrentAnimationDelta(skillName)); + getClient().getSession().write(messageBuilder.buildStartPerformance(true)); } - public void notifyAudience() { + public void stopPerformance() { + String type = ""; + synchronized(objectMutex) { + this.performanceId = 0; + this.performanceCounter = 0; + this.currentAnimation = null; + type = (performanceType) ? "dance" : "music"; + } + + sendSystemMessage("@performance:" + type + "_stop_self",(byte)0); + notifyAudience("@performance:" + type + "_stop_other"); + + getClient().getSession().write(messageBuilder.buildStartPerformance(false)); + } + + public void notifyAudience(String message) { //TODO: stub } - - - + @Override public void setPvPBitmask(int pvpBitmask) { super.setPvPBitmask(pvpBitmask); diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index 2d262da6..6882c8a8 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -216,6 +216,9 @@ public class EntertainmentService implements INetworkDispatch { private void registerCommands() { core.commandService.registerCommand("startdance"); + core.commandService.registerCommand("stopdance"); + core.commandService.registerCommand("flourish"); + core.commandService.registerCommand("bandflourish"); } public void giveInspirationBuff(SWGObject reciever, Vector buffVector) { @@ -242,20 +245,27 @@ public class EntertainmentService implements INetworkDispatch { } + public int getDanceVisualId(String danceName) { + Performance p = performances.get(danceName); + + //if 0 , then it's no dance. need to handle that in the script. + return p.getDanceVisualId(); + } + public Map getAvailableDances(CreatureObject actor) { Map dances = new HashMap(); for (int index : danceMap.keySet()) { if (!canDance(actor, danceMap.get(index) )) { continue; } - dances.put( new Long(index), danceMap.get(index).getPerformanceName() ); + dances.put( new Long( danceMap.get(index).getDanceVisualId() ), danceMap.get(index).getPerformanceName() ); } return dances; } - public boolean isDance(String danceName) { - return ( performances.get(danceName) != null && performances.get(danceName).getType() == -1788534963); + public boolean isDance(int visualId) { + return ( danceMap.get(visualId) != null ) ; } public boolean canDance(CreatureObject actor, Performance dance) { @@ -265,9 +275,13 @@ public class EntertainmentService implements INetworkDispatch { return false; } - public boolean canDance(CreatureObject actor, String danceName) { - if (!isDance(danceName)) { return false; } - return canDance(actor, performances.get(danceName)); + public boolean canDance(CreatureObject actor, int visualId) { + if (!isDance(visualId)) { return false; } + return canDance(actor, danceMap.get(visualId)); + } + + public Performance getDance(int visualId) { + return danceMap.get(visualId); } public Performance getPerformance(String name) { From 9cefd424ce555613e9ddd0e0dfb18eb05f88c1eb Mon Sep 17 00:00:00 2001 From: darkk1138 Date: Sat, 7 Dec 2013 16:42:56 +0100 Subject: [PATCH 14/23] need object version change --- odb/creature/je.info.0.1 | 0 src/resources/objects/creature/CreatureObject.java | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 odb/creature/je.info.0.1 diff --git a/odb/creature/je.info.0.1 b/odb/creature/je.info.0.1 new file mode 100644 index 00000000..e69de29b diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index c3620945..f0b160b5 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -55,7 +55,7 @@ import engine.resources.scene.Quaternion; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; -@Entity(version=5) +@Entity(version=6) public class CreatureObject extends TangibleObject implements IPersistent { @NotPersistent From 55411e0f23f4ecf757fe81ad3ea1ce59efa6eeb6 Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Sat, 7 Dec 2013 17:34:37 +0100 Subject: [PATCH 15/23] Fixed incorrect calculation for heal CD and added BH heal --- src/services/combat/CombatService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 1ee06890..b943779c 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -412,10 +412,13 @@ public class CombatService implements INetworkDispatch { attacker.notifyObserversInRange(objController, true, 125); cooldown = command.getCooldown(); + System.out.println(cooldown); if(attacker.getSkillMod("expertise_cooldown_line_of_heal") != null) - cooldown -= 2*(attacker.getSkillMod("expertise_cooldown_line_of_heal").getBase()); - + cooldown -= attacker.getSkillMod("expertise_cooldown_line_of_heal").getBase(); + if(attacker.getSkillMod("expertise_cooldown_line_sh") != null) + cooldown -= ((attacker.getSkillMod("expertise_cooldown_line_sh").getBase())/10); + StartTask startTask = new StartTask(actionCounter, attacker.getObjectID(), command.getCommandCRC(), CRC.StringtoCRC(command.getCooldownGroup()), cooldown); ObjControllerMessage objController2 = new ObjControllerMessage(0x0B, startTask); attacker.getClient().getSession().write(objController2.serialize()); From 1f4d72fa160dc8ee84829b372805bfb58b3c78f0 Mon Sep 17 00:00:00 2001 From: darkk1138 Date: Sat, 7 Dec 2013 21:25:44 +0100 Subject: [PATCH 16/23] add aliases to command service --- src/services/command/CommandService.java | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index f6483fab..367f9134 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -22,8 +22,11 @@ package services.command; import java.nio.ByteOrder; +import java.util.HashMap; import java.util.Map; import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; + import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; @@ -50,6 +53,8 @@ import resources.objects.weapon.WeaponObject; public class CommandService implements INetworkDispatch { private Vector commandLookup = new Vector(); + private ConcurrentHashMap aliases = new ConcurrentHashMap(); + private ConcurrentHashMap aliasesByCRC = new ConcurrentHashMap(); private NGECore core; public CommandService(NGECore core) { @@ -125,9 +130,29 @@ public class CommandService implements INetworkDispatch { return command; } + + //FIXME: CRC could just be generated as well. + public void registerAlias(String name, String target) { + Vector commands = new Vector(commandLookup); // copy for thread safety + BaseSWGCommand targetCommand = null; + for(BaseSWGCommand command : commands) { + if(command.getCommandName().equalsIgnoreCase(target)) { + targetCommand = command; + } + } + if (targetCommand == null) { return; } + + aliases.put(name, targetCommand); + aliasesByCRC.put(CRC.StringtoCRC(name), targetCommand); + + } public BaseSWGCommand getCommandByCRC(int CRC) { + if (aliasesByCRC.containsKey(CRC)) { + return aliasesByCRC.get(CRC); + } + Vector commands = new Vector(commandLookup); // copy for thread safety for(BaseSWGCommand command : commands) { @@ -140,6 +165,10 @@ public class CommandService implements INetworkDispatch { public BaseSWGCommand getCommandByName(String name) { + if (aliases.containsKey(name)) { + return aliases.get(name); + } + Vector commands = new Vector(commandLookup); // copy for thread safety for(BaseSWGCommand command : commands) { From 5bea91f1cf9f8d2e73c304b0a5156f12f221f7dd Mon Sep 17 00:00:00 2001 From: darkk1138 Date: Sat, 7 Dec 2013 21:30:52 +0100 Subject: [PATCH 17/23] allow /flo ;) --- src/services/EntertainmentService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index 6882c8a8..5bcfa7b6 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -218,6 +218,7 @@ public class EntertainmentService implements INetworkDispatch { core.commandService.registerCommand("startdance"); core.commandService.registerCommand("stopdance"); core.commandService.registerCommand("flourish"); + core.commandService.registerAlias("flo","flourish"); core.commandService.registerCommand("bandflourish"); } From a2c94acaf86deea18c42f889fb77052c1b8bab5a Mon Sep 17 00:00:00 2001 From: darkk1138 Date: Sat, 7 Dec 2013 21:31:20 +0100 Subject: [PATCH 18/23] optimise /bandflo script, it just didn't look right to me. :p --- scripts/commands/bandflourish.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/commands/bandflourish.py b/scripts/commands/bandflourish.py index 75c17b32..e30daa8f 100644 --- a/scripts/commands/bandflourish.py +++ b/scripts/commands/bandflourish.py @@ -36,20 +36,20 @@ def run(core, actor, target, commandString): if flourish == 9: animation = 'mistake' + if actor.getAcceptBandflourishes(): + actor.sendSystemMessage('@performance:flourish_perform_band_self', 0) + actor.sendSystemMessage('@performance:flourish_perform', 0) + actor.doSkillAnimation(animation) + group = core.objectService.getObject(actor.getGroupId()) if not group: - if actor.getAcceptBandflourishes(): - actor.sendSystemMessage('@performance:flourish_perform_band_self', 0) - actor.sendSystemMessage('@performance:flourish_perform', 0) - actor.doSkillAnimation(animation) return for creature in group.getMemberList(): + if creature == actor: + continue if creature.getAcceptBandflourishes(): - if actor == creature: - creature.sendSystemMessage('@performance:flourish_perform_band_self', 0) - else: - creature.sendSystemMessage('@performance:flourish_perform_band_member', 0) + creature.sendSystemMessage('@performance:flourish_perform_band_member', 0) creature.sendSystemMessage('@performance:flourish_perform', 0) creature.doSkillAnimation(animation) return From 4039379583951ab319212ffc10bb66bb804fcbba Mon Sep 17 00:00:00 2001 From: Ziggeh Date: Sat, 7 Dec 2013 23:12:41 +0100 Subject: [PATCH 19/23] Fixed creating waypoints through planetary map --- scripts/commands/requestwaypointatposition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/commands/requestwaypointatposition.py b/scripts/commands/requestwaypointatposition.py index 98c3fd2d..60b932ce 100644 --- a/scripts/commands/requestwaypointatposition.py +++ b/scripts/commands/requestwaypointatposition.py @@ -7,7 +7,7 @@ def run(core, actor, target, commandString): commandArgs = commandString.split("(^-,=+_)color_13548(,+-=_^)=1") - newString = commandArgs[1] + newString = commandArgs[0] print (newString) cmdService = core.commandService cmdService.callCommand(actor, 'waypoint', None, newString) # No need to re-create a script From ae0b06f9171d716f025a0ffe005b660ac0665b7f Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sat, 7 Dec 2013 17:58:49 -0500 Subject: [PATCH 20/23] Fixed MissionObject Delta's, Synchronized MissionObject, Fixed MissionListRequest Opcode --- .../tangible/terminal/terminal_mission.py | 2 + src/main/NGECore.java | 5 +- .../MissionListRequest.java | 1 + .../common/ObjControllerOpcodes.java | 2 +- .../mission/MissionMessageBuilder.java | 141 +++++++------ .../objects/mission/MissionObject.java | 197 ++++++++++++------ src/services/CharacterService.java | 12 +- src/services/MissionService.java | 163 +++++++++++++++ src/services/object/ObjectService.java | 22 +- src/services/travel/TravelService.java | 4 +- 10 files changed, 411 insertions(+), 138 deletions(-) diff --git a/scripts/object/tangible/terminal/terminal_mission.py b/scripts/object/tangible/terminal/terminal_mission.py index 4884aa67..ccf684c0 100644 --- a/scripts/object/tangible/terminal/terminal_mission.py +++ b/scripts/object/tangible/terminal/terminal_mission.py @@ -1,7 +1,9 @@ +from resources.common import TerminalType import sys def setup(core, object): core.mapService.addLocation(object.getPlanet(), 'Mission Terminal', object.getPosition().x, object.getPosition().z, 41, 44, 0) + object.setAttachment("terminalType", TerminalType.MISSION_GENERIC) return \ No newline at end of file diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 77bac93b..9ac42a8c 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -35,7 +35,6 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import net.engio.mbassy.bus.config.BusConfiguration; - import resources.common.RadialOptions; import resources.common.ThreadMonitor; import resources.objects.creature.CreatureObject; @@ -47,6 +46,7 @@ import services.EntertainmentService; import services.EquipmentService; import services.GroupService; import services.LoginService; +import services.MissionService; import services.PlayerService; import services.ScriptService; import services.SimulationService; @@ -144,6 +144,7 @@ public class NGECore { public WeatherService weatherService; public SpawnService spawnService; public AIService aiService; + //public MissionService missionService; // Login Server public NetworkDispatch loginDispatch; @@ -220,6 +221,7 @@ public class NGECore { entertainmentService = new EntertainmentService(this); spawnService = new SpawnService(this); aiService = new AIService(this); + //missionService = new MissionService(this); // Ping Server try { @@ -250,6 +252,7 @@ public class NGECore { zoneDispatch.addService(playerService); zoneDispatch.addService(buffService); zoneDispatch.addService(entertainmentService); + //zoneDispatch.addService(missionService); zoneServer = new MINAServer(zoneDispatch, config.getInt("ZONE.PORT")); zoneServer.start(); diff --git a/src/protocol/swg/objectControllerObjects/MissionListRequest.java b/src/protocol/swg/objectControllerObjects/MissionListRequest.java index 1cafd618..7fbe2d02 100644 --- a/src/protocol/swg/objectControllerObjects/MissionListRequest.java +++ b/src/protocol/swg/objectControllerObjects/MissionListRequest.java @@ -39,6 +39,7 @@ public class MissionListRequest extends ObjControllerObject { public void deserialize(IoBuffer data) { Console.println("MissionListRequest: " + StringUtilities.bytesToHex(data.array())); setObjectId(data.getLong()); + data.getInt(); // unk data.get(); // unk byte setTickCount(data.get()); setTerminalId(data.getLong()); diff --git a/src/resources/common/ObjControllerOpcodes.java b/src/resources/common/ObjControllerOpcodes.java index 17c9784c..551857d9 100644 --- a/src/resources/common/ObjControllerOpcodes.java +++ b/src/resources/common/ObjControllerOpcodes.java @@ -31,6 +31,6 @@ public class ObjControllerOpcodes { public static final int OBJECT_MENU_REQUEST = 0x46010000; public static final int SECURE_TRADE = 0x15010000; public static final int BUFF_BUILDER_CHANGE = 0x5A020000; - public static final int MISSION_LIST_REQUEST = 0x5F000000; + public static final int MISSION_LIST_REQUEST = 0xF5000000; } diff --git a/src/resources/objects/mission/MissionMessageBuilder.java b/src/resources/objects/mission/MissionMessageBuilder.java index dff9bc55..190773ad 100644 --- a/src/resources/objects/mission/MissionMessageBuilder.java +++ b/src/resources/objects/mission/MissionMessageBuilder.java @@ -26,6 +26,8 @@ import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; import engine.resources.common.CRC; +import resources.common.Console; +import resources.common.StringUtilities; import resources.objects.ObjectMessageBuilder; import resources.objects.waypoint.WaypointObject; @@ -40,7 +42,7 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { IoBuffer buffer = IoBuffer.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); buffer.setAutoExpand(true); - buffer.putShort((short) 11); + buffer.putShort((short) 17); buffer.putFloat(1); // mission complexity ?? buffer.put(getAsciiString(mission.getStfFilename())); @@ -50,7 +52,7 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { if (mission.getCustomName() == null) { buffer.put(getUnicodeString("")); } else { buffer.put(getUnicodeString(mission.getCustomName())); } - buffer.putInt(mission.getVolume()); + buffer.putInt(0); // volume buffer.putInt(0); // unused buffer.putInt(mission.getMissionLevel()); @@ -60,8 +62,12 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { buffer.putLong(0); // ?? - buffer.putInt(CRC.StringtoCRC(mission.getMissionStartPlanet())); - + if (mission.getMissionStartPlanet() == null) { + buffer.putInt(0); + } else { + buffer.putInt(CRC.StringtoCRC(mission.getMissionStartPlanet())); + } + buffer.put(getUnicodeString(mission.getMissionCreator())); buffer.putInt(mission.getMissionCredits()); @@ -71,10 +77,18 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { buffer.putLong(0); // ?? - buffer.putInt(CRC.StringtoCRC(mission.getMissionDestinationPlanet())); - - buffer.putInt(CRC.StringtoCRC(mission.getMissionTemplateObject())); + if (mission.getMissionDestinationPlanet() == null) { + buffer.putInt(0); + } else { + buffer.putInt(CRC.StringtoCRC(mission.getMissionDestinationPlanet())); + } + if (mission.getTargetTemplateObject() == null) { + buffer.putInt(0); + } else { + buffer.putInt(CRC.StringtoCRC(mission.getTargetTemplateObject())); + } + buffer.put(getAsciiString(mission.getMissionDescription())); buffer.putInt(0); buffer.put(getAsciiString(mission.getMissionDescId())); @@ -85,8 +99,12 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { buffer.putInt(0); // refresh counter - buffer.putInt(CRC.StringtoCRC(mission.getMissionType())); - + if(mission.getMissionType() == null) { + buffer.putInt(0); + } else { + buffer.putInt(CRC.StringtoCRC(mission.getMissionType())); + } + buffer.put(getAsciiString(mission.getMissionTargetName())); WaypointObject wp = mission.getMissionAttachedWaypoint(); @@ -109,6 +127,8 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { buffer.putFloat(wp.getPosition().y); buffer.putLong(0); buffer.putInt(CRC.StringtoCRC(wp.getPlanet().name)); + buffer.put((byte) 0); + buffer.put((byte) 0x01); } int size = buffer.position(); buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); @@ -116,6 +136,7 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { buffer.flip(); buffer = createBaseline("MISO", (byte) 3, buffer, size); + Console.println("Bytes: " + StringUtilities.bytesToHex(buffer.array())); return buffer; } @@ -132,14 +153,13 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildStfDelta() { - MissionObject mission = (MissionObject) object; + public IoBuffer buildStfDelta(String stfFile, String stfName) { - IoBuffer buffer = IoBuffer.allocate(4 + mission.getStfFilename().length() + mission.getStfName().length(), false).order(ByteOrder.LITTLE_ENDIAN); + IoBuffer buffer = IoBuffer.allocate(4 + stfFile.length() + stfName.length(), false).order(ByteOrder.LITTLE_ENDIAN); - buffer.put(getAsciiString(mission.getStfFilename())); + buffer.put(getAsciiString(stfFile)); buffer.putInt(0); - buffer.put(getAsciiString(mission.getStfName())); + buffer.put(getAsciiString(stfName)); int size = buffer.position(); buffer.flip(); @@ -148,12 +168,11 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildDifficultyLevelDelta() { - MissionObject mission = (MissionObject) object; + public IoBuffer buildDifficultyLevelDelta(int difficulty) { IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(mission.getMissionLevel()); + buffer.putInt(difficulty); int size = buffer.position(); buffer.flip(); @@ -162,18 +181,17 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildStartLocationDelta() { - MissionObject mission = (MissionObject) object; - + public IoBuffer buildStartLocationDelta(float x, float z, float y, String planet) { + IoBuffer buffer = IoBuffer.allocate(24, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putFloat(mission.getMissionStartX()); - buffer.putFloat(mission.getMissionStartZ()); - buffer.putFloat(mission.getMissionStartY()); + buffer.putFloat(x); + buffer.putFloat(z); + buffer.putFloat(y); buffer.putLong(0); - buffer.putInt(CRC.StringtoCRC(mission.getMissionStartPlanet())); + buffer.putInt(CRC.StringtoCRC(planet)); int size = buffer.position(); buffer.flip(); @@ -182,12 +200,11 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildCreatorNameDelta() { - MissionObject mission = (MissionObject) object; + public IoBuffer buildCreatorNameDelta(String creator) { + + IoBuffer buffer = IoBuffer.allocate(4 + creator.length(), false).order(ByteOrder.LITTLE_ENDIAN); - IoBuffer buffer = IoBuffer.allocate(4 + mission.getMissionCreator().length(), false).order(ByteOrder.LITTLE_ENDIAN); - - buffer.put(getAsciiString(mission.getMissionCreator())); + buffer.put(getAsciiString(creator)); int size = buffer.position(); buffer.flip(); @@ -196,12 +213,11 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildCreditsRewardDelta() { - MissionObject mission = (MissionObject) object; - + public IoBuffer buildCreditsRewardDelta(int creds) { + IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(mission.getMissionCredits()); + buffer.putInt(creds); int size = buffer.position(); buffer.flip(); @@ -210,18 +226,17 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildDestinationDelta() { - MissionObject mission = (MissionObject) object; - + public IoBuffer buildDestinationDelta(float x, float z, float y, String planet) { + IoBuffer buffer = IoBuffer.allocate(24, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putFloat(mission.getMissionDestinationX()); - buffer.putFloat(mission.getMissionDestinationZ()); - buffer.putFloat(mission.getMissionDestinationY()); + buffer.putFloat(x); + buffer.putFloat(z); + buffer.putFloat(y); buffer.putLong(0); // Destination Object ID - buffer.putInt(CRC.StringtoCRC(mission.getMissionDestinationPlanet())); + buffer.putInt(CRC.StringtoCRC(planet)); int size = buffer.position(); buffer.flip(); @@ -230,12 +245,11 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildTargetObjectIffDelta() { - MissionObject mission = (MissionObject) object; - + public IoBuffer buildTargetObjectIffDelta(String template) { + IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(CRC.StringtoCRC(mission.getMissionTemplateObject())); + buffer.putInt(CRC.StringtoCRC(template)); int size = buffer.position(); buffer.flip(); @@ -244,14 +258,13 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildMissionDescriptionDelta() { - MissionObject mission = (MissionObject) object; + public IoBuffer buildMissionDescriptionDelta(String desc, String id) { - IoBuffer buffer = IoBuffer.allocate(4 + mission.getMissionDescription().length() + mission.getMissionDescId().length(), false).order(ByteOrder.LITTLE_ENDIAN); + IoBuffer buffer = IoBuffer.allocate(8 + desc.length() + id.length(), false).order(ByteOrder.LITTLE_ENDIAN); - buffer.put(getAsciiString(mission.getMissionDescription())); + buffer.put(getAsciiString(desc)); buffer.putInt(0); - buffer.put(getAsciiString(mission.getMissionDescId())); + buffer.put(getAsciiString(id)); int size = buffer.position(); buffer.flip(); @@ -260,14 +273,13 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildMissionTitleDelta() { - MissionObject mission = (MissionObject) object; + public IoBuffer buildMissionTitleDelta(String title, String id) { + + IoBuffer buffer = IoBuffer.allocate(8 + title.length() + id.length(), false).order(ByteOrder.LITTLE_ENDIAN); - IoBuffer buffer = IoBuffer.allocate(4 + mission.getMissionTitle().length() + mission.getMissionTitleId().length(), false).order(ByteOrder.LITTLE_ENDIAN); - - buffer.put(getAsciiString(mission.getMissionTitle())); + buffer.put(getAsciiString(title)); buffer.putInt(0); - buffer.put(getAsciiString(mission.getMissionTitleId())); + buffer.put(getAsciiString(id)); int size = buffer.position(); buffer.flip(); @@ -276,12 +288,11 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildRepeatCounterDelta() { - MissionObject mission = (MissionObject) object; + public IoBuffer buildRepeatCounterDelta(int counter) { IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(mission.getMissionRepeatCounter()); + buffer.putInt(counter); int size = buffer.position(); buffer.flip(); @@ -290,12 +301,11 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildMissionTypeDelta() { - MissionObject mission = (MissionObject) object; - + public IoBuffer buildMissionTypeDelta(String type) { + IoBuffer buffer = IoBuffer.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(CRC.StringtoCRC(mission.getMissionType())); + buffer.putInt(CRC.StringtoCRC(type)); int size = buffer.position(); buffer.flip(); @@ -304,12 +314,11 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - public IoBuffer buildTargetNameDelta() { - MissionObject mission = (MissionObject) object; + public IoBuffer buildTargetNameDelta(String targetName) { - IoBuffer buffer = IoBuffer.allocate(4 + mission.getMissionTargetName().length(), false).order(ByteOrder.LITTLE_ENDIAN); + IoBuffer buffer = IoBuffer.allocate(4 + targetName.length(), false).order(ByteOrder.LITTLE_ENDIAN); - buffer.put(getAsciiString(mission.getMissionTargetName())); + buffer.put(getAsciiString(targetName)); int size = buffer.position(); buffer.flip(); diff --git a/src/resources/objects/mission/MissionObject.java b/src/resources/objects/mission/MissionObject.java index c98ab0c7..635da311 100644 --- a/src/resources/objects/mission/MissionObject.java +++ b/src/resources/objects/mission/MissionObject.java @@ -23,7 +23,9 @@ package resources.objects.mission; import com.sleepycat.je.Environment; import com.sleepycat.je.Transaction; +import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.NotPersistent; +import com.sleepycat.persist.model.Persistent; import resources.objects.tangible.TangibleObject; import resources.objects.waypoint.WaypointObject; @@ -34,6 +36,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; +@Persistent(version=1) public class MissionObject extends SWGObject implements IPersistent { private float missionDestinationX; @@ -47,12 +50,12 @@ public class MissionObject extends SWGObject implements IPersistent { private String missionDestinationPlanet; private int missionRepeatCounter; // increases for each player using the mission; used for redisplaying on mission term too private int missionCredits; - private String missionCreator; - private String missionDescription; - private String missionTitle; - private String missionTargetName; // target/destination - private String missionDescId; - private String missionTitleId; + private String missionCreator = ""; + private String missionDescription = ""; + private String missionTitle = ""; + private String missionTargetName = ""; // Target object I guess? + private String missionDescId = ""; + private String missionTitleId = ""; private String missionType; private WaypointObject missionAttachedWaypoint; @@ -63,158 +66,222 @@ public class MissionObject extends SWGObject implements IPersistent { @NotPersistent private Transaction txn; - + + public MissionObject() { + super(); + } public MissionObject(long objectID, Planet planet, String template) { super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), template); } public float getMissionStartX() { - return missionStartX; + synchronized(objectMutex) { + return missionStartX; + } } public float getMissionStartY() { - return missionStartY; + synchronized(objectMutex) { + return missionStartY; + } } public float getMissionStartZ() { - return missionStartZ; + synchronized(objectMutex) { + return missionStartZ; + } } - public void setMissionStart(float x, float y, float z) { - this.missionStartZ = z; - this.missionStartX = x; - this.missionStartY = y; + public void setMissionStart(float x, float y, float z, String planet) { + synchronized(objectMutex) { + this.missionStartZ = z; + this.missionStartX = x; + this.missionStartY = y; + this.missionStartPlanet = planet; + } + + notifyObservers(messageBuilder.buildStartLocationDelta(x, z, y, planet), false); } public float getMissionDestinationX() { - return missionDestinationX; + synchronized(objectMutex) { + return missionDestinationX; + } } public float getMissionDestinationY() { - return missionDestinationY; + synchronized(objectMutex) { + return missionDestinationY; + } } public float getMissionDestinationZ() { - return missionDestinationZ; + synchronized(objectMutex) { + return missionDestinationZ; + } } - public void setMissionDestination(float x, float y, float z) { - this.missionDestinationZ = z; - this.missionDestinationY = y; - this.missionDestinationZ = z; + public void setMissionDestination(float x, float y, float z, String planet) { + synchronized(objectMutex) { + this.missionDestinationZ = z; + this.missionDestinationY = y; + this.missionDestinationZ = z; + this.missionDestinationPlanet = planet; + } } public String getMissionDestinationPlanet() { - return missionDestinationPlanet; - } - - public void setMissionDestinationPlanet(String missionDestinationPlanet) { - this.missionDestinationPlanet = missionDestinationPlanet; + synchronized(objectMutex) { + return missionDestinationPlanet; + } } public int getMissionLevel() { - return missionLevel; + synchronized(objectMutex) { + return missionLevel; + } } public void setMissionLevel(int missionLevel) { - this.missionLevel = missionLevel; + synchronized(objectMutex) { + this.missionLevel = missionLevel; + } } public String getMissionStartPlanet() { - return missionStartPlanet; - } - - public void setMissionStartPlanet(String missionStartPlanetCRC) { - this.missionStartPlanet = missionStartPlanetCRC; + synchronized(objectMutex) { + return missionStartPlanet; + } } public int getMissionRepeatCounter() { - return missionRepeatCounter; + synchronized(objectMutex) { + return missionRepeatCounter; + } } public void setMissionRepeatCounter(int missionRepeatCounter) { - this.missionRepeatCounter = missionRepeatCounter; + synchronized(objectMutex) { + this.missionRepeatCounter = missionRepeatCounter; + } } public int getMissionCredits() { - return missionCredits; + synchronized(objectMutex) { + return missionCredits; + } } public void setMissionCredits(int missionCredits) { - this.missionCredits = missionCredits; + synchronized(objectMutex) { + this.missionCredits = missionCredits; + } + notifyObservers(messageBuilder.buildCreditsRewardDelta(missionCredits), false); } public String getMissionCreator() { - return missionCreator; + synchronized(objectMutex) { + return missionCreator; + } } public void setMissionCreator(String missionCreator) { - this.missionCreator = missionCreator; + synchronized(objectMutex) { + this.missionCreator = missionCreator; + } + notifyObservers(messageBuilder.buildCreatorNameDelta(missionCreator), false); } public String getMissionDescription() { - return missionDescription; + synchronized(objectMutex) { + return missionDescription; + } } - public void setMissionDescription(String missionDescription) { - this.missionDescription = missionDescription; + public void setMissionDescription(String missionDescription, String id) { + synchronized(objectMutex) { + this.missionDescription = missionDescription; + this.missionDescId = id; + } + notifyObservers(messageBuilder.buildMissionDescriptionDelta(missionDescription, id), false); } public String getMissionTitle() { - return missionTitle; + synchronized(objectMutex) { + return missionTitle; + } } - public void setMissionTitle(String missionTitle) { - this.missionTitle = missionTitle; + public void setMissionTitle(String missionTitle, String id) { + synchronized(objectMutex) { + this.missionTitle = missionTitle; + this.missionTitleId = id; + } + notifyObservers(messageBuilder.buildMissionTitleDelta(missionTitle, id), false); } public String getMissionTargetName() { - return missionTargetName; + synchronized(objectMutex) { + return missionTargetName; + } } public void setMissionTargetName(String missionTargetName) { - this.missionTargetName = missionTargetName; + synchronized(objectMutex) { + this.missionTargetName = missionTargetName; + } + notifyObservers(messageBuilder.buildTargetNameDelta(missionTargetName), false); } public WaypointObject getMissionAttachedWaypoint() { - return missionAttachedWaypoint; + synchronized(objectMutex) { + return missionAttachedWaypoint; + } } public void setMissionAttachedWaypoint(WaypointObject missionAttachedWaypoint) { - this.missionAttachedWaypoint = missionAttachedWaypoint; + synchronized(objectMutex) { + this.missionAttachedWaypoint = missionAttachedWaypoint; + } } - public String getMissionTemplateObject() { - return missionTemplateObject; + public String getTargetTemplateObject() { + synchronized(objectMutex) { + return missionTemplateObject; + } } - public void setMissionTemplateObject(String missionTemplateObject) { - this.missionTemplateObject = missionTemplateObject; + public void setTargetTemplateObject(String missionTemplateObject) { + synchronized(objectMutex) { + this.missionTemplateObject = missionTemplateObject; + } + notifyObservers(messageBuilder.buildTargetObjectIffDelta(missionTemplateObject), false); } public String getMissionDescId() { - return missionDescId; - } - - public void setMissionDescId(String missionDescId) { - this.missionDescId = missionDescId; + synchronized(objectMutex) { + return missionDescId; + } } public String getMissionTitleId() { - return missionTitleId; - } - - public void setMissionTitleId(String missionTitleId) { - this.missionTitleId = missionTitleId; + synchronized(objectMutex) { + return missionTitleId; + } } public String getMissionType() { - return missionType; + synchronized(objectMutex) { + return missionType; + } } public void setMissionType(String missionType) { - this.missionType = missionType; + synchronized(objectMutex) { + this.missionType = missionType; + } + notifyObservers(messageBuilder.buildMissionTypeDelta(missionType), false); } public Transaction getTransaction() { diff --git a/src/services/CharacterService.java b/src/services/CharacterService.java index 5298d0da..99d3f926 100644 --- a/src/services/CharacterService.java +++ b/src/services/CharacterService.java @@ -37,6 +37,7 @@ import engine.clients.Client; import engine.resources.common.CRC; import engine.resources.container.CreatureContainerPermissions; import engine.resources.container.CreaturePermissions; +import engine.resources.container.Traverser; import engine.resources.database.DatabaseConnection; import engine.resources.objects.SWGObject; import engine.resources.scene.Point3D; @@ -44,7 +45,6 @@ import engine.resources.scene.Quaternion; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import resources.common.*; - import protocol.swg.ClientCreateCharacter; import protocol.swg.ClientMfdStatusUpdateMessage; import protocol.swg.ClientRandomNameRequest; @@ -53,8 +53,8 @@ import protocol.swg.ClientVerifyAndLockNameRequest; import protocol.swg.ClientVerifyAndLockNameResponse; import protocol.swg.CreateCharacterSuccess; import protocol.swg.HeartBeatMessage; - import resources.objects.creature.CreatureObject; +import resources.objects.mission.MissionObject; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; @@ -264,6 +264,14 @@ public class CharacterService implements INetworkDispatch { object._add(datapad); object._add(bank); object._add(missionBag); + + /*for(int missionsAdded = 0; missionsAdded < 12; missionsAdded++) { + MissionObject mission = (MissionObject) core.objectService.createObject("object/mission/shared_mission_object.iff", object.getPlanet()); + + missionBag._add(mission); + Console.println("Added empty mission " + missionsAdded); + }*/ + TangibleObject backpack = (TangibleObject) core.objectService.createObject("object/tangible/wearables/backpack/shared_backpack_galactic_marine.iff", object.getPlanet()); inventory._add(backpack); //object.addObjectToEquipList(datapad); diff --git a/src/services/MissionService.java b/src/services/MissionService.java index d376f698..4eaca9bb 100644 --- a/src/services/MissionService.java +++ b/src/services/MissionService.java @@ -21,29 +21,192 @@ ******************************************************************************/ package services; +import java.nio.ByteOrder; import java.util.Map; +import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; + +import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.session.IoSession; +import protocol.swg.objectControllerObjects.MissionListRequest; +import resources.common.Console; +import resources.common.TerminalType; import resources.common.ObjControllerOpcodes; +import resources.objects.creature.CreatureObject; +import resources.objects.mission.MissionObject; +import resources.objects.tangible.TangibleObject; +import engine.clientdata.ClientFileManager; +import engine.clientdata.visitors.DatatableVisitor; +import engine.clients.Client; +import engine.resources.container.Traverser; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Planet; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; public class MissionService implements INetworkDispatch { + private NGECore core; + + public MissionService(NGECore core) { + this.core = core; + } + @Override public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { objControllerOpcodes.put(ObjControllerOpcodes.MISSION_LIST_REQUEST, new INetworkRemoteEvent() { @Override public void handlePacket(IoSession session, IoBuffer data) throws Exception { + data.order(ByteOrder.LITTLE_ENDIAN); + + MissionListRequest request = new MissionListRequest(); + request.deserialize(data); + + Client client = core.getClient((Integer) session.getAttribute("connectionId")); + if(client == null || client.getSession() == null) + return; + + SWGObject object = client.getParent(); + + if(object == null) + return; + + SWGObject terminal = core.objectService.getObject(request.getTerminalId()); + + int terminalType = (int) terminal.getAttachment("terminalType"); + + if (terminalType == TerminalType.MISSION_GENERIC) { + populateMissions(core.objectService.getObject(request.getObjectId()), TerminalType.MISSION_GENERIC); + } else if (terminalType == TerminalType.MISSION_BOUNTYHUNTER) { + + } else if (terminalType == TerminalType.MISSION_ENTERTAINER) { + + } else if (terminalType == TerminalType.MISSION_ARTISAN) { + + } else { + Console.println("ERROR: Unsupported terminal " + terminal.getObjectId()); + } } }); } + + private void populateMissions(final SWGObject player, int type) { + CreatureObject creature = (CreatureObject) player; + TangibleObject missionBag = (TangibleObject) creature.getSlottedObject("mission_bag"); + + final AtomicInteger deliveryCount = new AtomicInteger(); + final AtomicInteger destroyCount = new AtomicInteger(); + final int deliveryEntries = 30; + + final Random ran = new Random(); + + final int bagSize = core.objectService.objsInContainer(creature, missionBag); + Console.println("Delivery Entries: " + deliveryEntries); + if (bagSize != 12) { + for(int missionsAdded = 0; missionsAdded < 12; missionsAdded++) { + MissionObject mission = (MissionObject) core.objectService.createObject("object/mission/shared_mission_object.iff", creature.getPlanet()); + + int textId = ran.nextInt(deliveryEntries); + + Console.println("Random Int Value: " + textId); + Console.println("Now the value is: " + textId); + + mission.setMissionLevel(5); + + mission.setMissionStart(0, 0, 0, player.getPlanet().name); + + mission.setMissionCreator("Waverunner"); + mission.setMissionCredits(9000); + + // TODO: Base this off of textId + f + mission.setTargetTemplateObject("object/tangible/mission/shared_mission_datadisk.iff"); + // TODO: Base this off of textId + l + mission.setMissionTargetName("Osskscosco"); + + mission.setMissionDescription("mission/mission_deliver_neutral_easy", "m" + textId + "d"); + mission.setMissionTitle("mission/mission_deliver_neutral_easy", "m" + textId + "t"); + + mission.setMissionType("deliver"); + + mission.setMissionDestination(-5962, 0, -6259, player.getPlanet().name); + deliveryCount.getAndIncrement(); + + + missionBag._add(mission); + Console.println("Added mission " + missionsAdded); + } + return; + } + + missionBag.viewChildren(player, false, false, new Traverser() { + + @Override + public void process(SWGObject child) { + if (deliveryCount.get() == 6) + return; + + MissionObject mission = (MissionObject) child; + int textId = ran.nextInt(deliveryEntries); + + Console.println("Random Int Value: " + textId); + Console.println("Now the value is: " + textId); + + mission.setMissionLevel(5); + + mission.setMissionStart(0, 0, 0, player.getPlanet().name); + + mission.setMissionCreator("Waverunner"); + mission.setMissionCredits(9000); + + // TODO: Base this off of textId + f + mission.setTargetTemplateObject("object/tangible/mission/shared_mission_datadisk.iff"); + // TODO: Base this off of textId + l + mission.setMissionTargetName("Osskscosco"); + + mission.setMissionDescription("mission/mission_deliver_neutral_easy", "m" + textId + "d"); + mission.setMissionTitle("mission/mission_deliver_neutral_easy", "m" + textId + "t"); + + mission.setMissionType("deliver"); + + mission.setMissionDestination(-5962, 0, -6259, player.getPlanet().name); + deliveryCount.getAndIncrement(); + } + + }); + + Console.println("Outside of the traverser now!"); + } + + // May want to create a map for the server with needed info + public int getNumberOfEntries(String stf) { + try { + DatatableVisitor stfFile = ClientFileManager.loadFile(stf, DatatableVisitor.class); + + for (int s = 0; s < stfFile.getRowCount(); s++) { + String name = ((String) stfFile.getObject(s, 3)); + Console.println("Name: " + name); + if (name.equals("number_of_entries")) { + int entryCount = ((int) stfFile.getObject(s, 4)); + Console.println("Entry Count: " + entryCount); + return entryCount; + } + } + } + catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + + return 0; + } + @Override public void shutdown() { diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index b08ad2f9..8da5bc20 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -36,6 +36,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import resources.common.*; @@ -740,5 +741,24 @@ public class ObjectService implements INetworkDispatch { } - + public int objsInContainer(SWGObject owner, TangibleObject container) { + if (owner == null) { + Console.println("Owner null!"); + } + if (container == null) { + Console.println("Container is null!"); + } + final AtomicInteger count = new AtomicInteger(); + + container.viewChildren(owner, false, false, new Traverser() { + + @Override + public void process(SWGObject child) { + count.getAndIncrement(); + } + + }); + + return count.get(); + } } diff --git a/src/services/travel/TravelService.java b/src/services/travel/TravelService.java index 541615a3..bd3ba0b7 100644 --- a/src/services/travel/TravelService.java +++ b/src/services/travel/TravelService.java @@ -116,7 +116,7 @@ public class TravelService implements INetworkDispatch { for(TravelPoint tp : travelMap.get(planet)) { if(tp.isStarport() || tp.getPlanetName().equalsIgnoreCase(object.getPlanet().getName())) { correctTravelPoints.add(tp); - Console.println(tp.getName()); + //Console.println(tp.getName()); } } PlanetTravelPointListResponse response = new PlanetTravelPointListResponse(planetString, correctTravelPoints); @@ -367,7 +367,7 @@ public class TravelService implements INetworkDispatch { for (int f = 0; f < travelFares.getRowCount(); f++) { Planet planet = core.terrainService.getPlanetByName((String) travelFares.getObject(f, 0)); if (travelMap.containsKey(planet)) { - int corellia = ((Integer) travelFares.getObject(f, 1)); + int corellia = ((int) travelFares.getObject(f, 1)); int dantooine = ((int) travelFares.getObject(f, 2)); int dathomir = ((int) travelFares.getObject(f, 3)); int endor = ((int) travelFares.getObject(f, 4)); From ba858e2c28f13461d5f01b651f9dd11f8c82921b Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sat, 7 Dec 2013 22:37:51 -0500 Subject: [PATCH 21/23] Friend Notification only on login/logout now, Chat messages for ignored players no longer display Use Travel Ticket for travel tickets added --- .../travel_ticket/base/base_travel_ticket.py | 1 + scripts/radial/travel_terminal.py | 5 +-- scripts/radial/travel_ticket.py | 40 +++++++++++++++++++ src/services/SimulationService.java | 31 +------------- src/services/chat/ChatService.java | 4 ++ src/services/command/CommandService.java | 2 +- src/services/object/ObjectService.java | 31 ++++++++++++++ src/services/travel/TravelService.java | 4 +- 8 files changed, 81 insertions(+), 37 deletions(-) create mode 100644 scripts/radial/travel_ticket.py diff --git a/scripts/object/tangible/travel/travel_ticket/base/base_travel_ticket.py b/scripts/object/tangible/travel/travel_ticket/base/base_travel_ticket.py index ccad8904..77e1b16d 100644 --- a/scripts/object/tangible/travel/travel_ticket/base/base_travel_ticket.py +++ b/scripts/object/tangible/travel/travel_ticket/base/base_travel_ticket.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'travel_ticket') return \ No newline at end of file diff --git a/scripts/radial/travel_terminal.py b/scripts/radial/travel_terminal.py index f8b984fb..eae686ca 100644 --- a/scripts/radial/travel_terminal.py +++ b/scripts/radial/travel_terminal.py @@ -8,13 +8,10 @@ def createRadial(core, owner, target, radials): def handleSelection(core, owner, target, option): if option == 21 and target: - print ('Owner: ' + str(owner.getObjectId())) - + if owner is not None: tpm = EnterTicketPurchaseModeMessage(owner.getPlanet().getName(), core.mapService.getClosestCityName(owner), owner) owner.getClient().getSession().write(tpm.serialize()) - print ('Planet name: ' + owner.getPlanet().getName()) - print ('City name: ' + core.mapService.getClosestCityName(owner)) return return diff --git a/scripts/radial/travel_ticket.py b/scripts/radial/travel_ticket.py new file mode 100644 index 00000000..9812f7ff --- /dev/null +++ b/scripts/radial/travel_ticket.py @@ -0,0 +1,40 @@ +from resources.common import RadialOptions +from protocol.swg import EnterTicketPurchaseModeMessage +import sys + +def createRadial(core, owner, target, radials): + radials.clear + + radials.add(RadialOptions(0, 21, 1, 'Use Travel Ticket')) + #radials.add(RadialOptions(0, 7, 1, '')) + #radials.add(RadialOptions(0, 15, 1, '')) + return + +def handleSelection(core, owner, target, option): + + if option == 21 and target: + + tp = core.travelService.getNearestTravelPoint(owner) + + if owner is not None and tp is not None: + if tp.getLocation().getDistance2D(owner.getWorldPosition()) <= 25: + if tp.isShuttleAvailable() is True: + core.travelService.doTransport(owner, core.travelService.getTravelPointByName(target.getStringAttribute('@obj_attr_n:travel_arrival_planet'), + target.getStringAttribute('@obj_attr_n:travel_arrival_point'))) + core.objectService.destroyObject(target) + return + return + else: + owner.sendSystemMessage('@travel:boarding_too_far', 0) + return + return + return + + if option == 15 and target: + core.commandService.callCommand(owner, 'serverdestroyobject', target, None) + return + return + +def handleSUI(owner, window, eventType, returnList): + + return \ No newline at end of file diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 31ee4181..3d9af0fb 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -563,37 +563,8 @@ public class SimulationService implements INetworkDispatch { if(object.getParentId() == 0) add(object, pos.x, pos.z); - - + PlayerObject ghost = (PlayerObject) object.getSlottedObject("ghost"); - if (ghost != null) { - - String objectShortName = object.getCustomName().toLowerCase(); - - if (object.getCustomName().contains(" ")) { - String[] splitName = object.getCustomName().toLowerCase().split(" "); - objectShortName = splitName[0].toLowerCase(); - } - - core.chatService.playerStatusChange(objectShortName, (byte) 1); - - if (ghost.getFriendList().isEmpty() == false) { - // Find out what friends are online/offline - for (String friend : ghost.getFriendList()) { - SWGObject friendObject = (SWGObject) core.chatService.getObjectByFirstName(friend); - if (friendObject == null) - continue; - if(friendObject.isInQuadtree() == true) { - ChatFriendsListUpdate onlineNotifyStatus = new ChatFriendsListUpdate(friend, (byte) 1); - client.getSession().write(onlineNotifyStatus.serialize()); - - } else { - ChatOnChangeFriendStatus changeStatus = new ChatOnChangeFriendStatus(object.getObjectID(), friend, 0); - client.getSession().write(changeStatus.serialize()); - } - } - } - } core.weatherService.sendWeather(object); diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index 2d0c26c4..a3587d08 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -110,6 +110,10 @@ public class ChatService implements INetworkDispatch { for(Client client : observers) { float distance = client.getParent().getPosition().getDistance2D(position); if(client != null && client.getSession() != null && distance <= 80) { + + if(((PlayerObject)client.getParent().getSlottedObject("ghost")).getIgnoreList().contains(speaker.getCustomName().toLowerCase().split(" ")[0])) + continue; + spatialChat.setDestinationId(client.getParent().getObjectID()); ObjControllerMessage objControllerMessage2 = new ObjControllerMessage(0x0B, spatialChat); client.getSession().write(objControllerMessage2.serialize()); diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 367f9134..293645f3 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -285,7 +285,7 @@ public class CommandService implements INetworkDispatch { } - public void callCommand(CreatureObject actor, String commandName, SWGObject target, String commandArgs) { + public void callCommand(SWGObject actor, String commandName, SWGObject target, String commandArgs) { if (actor == null) return; diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 6888b40b..d819ef25 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -49,6 +49,8 @@ import org.python.core.PyObject; import com.sleepycat.persist.EntityCursor; +import protocol.swg.ChatFriendsListUpdate; +import protocol.swg.ChatOnChangeFriendStatus; import protocol.swg.ChatOnGetFriendsList; import protocol.swg.CmdSceneReady; import protocol.swg.CmdStartScene; @@ -564,6 +566,35 @@ public class ObjectService implements INetworkDispatch { ChatOnGetFriendsList friendsListMessage = new ChatOnGetFriendsList(ghost); client.getSession().write(friendsListMessage.serialize()); + if (ghost != null) { + + String objectShortName = creature.getCustomName().toLowerCase(); + + if (creature.getCustomName().contains(" ")) { + String[] splitName = creature.getCustomName().toLowerCase().split(" "); + objectShortName = splitName[0].toLowerCase(); + } + + core.chatService.playerStatusChange(objectShortName, (byte) 1); + + if (ghost.getFriendList().isEmpty() == false) { + // Find out what friends are online/offline + for (String friend : ghost.getFriendList()) { + SWGObject friendObject = (SWGObject) core.chatService.getObjectByFirstName(friend); + if (friendObject == null) + continue; + if(friendObject.isInQuadtree() == true) { + ChatFriendsListUpdate onlineNotifyStatus = new ChatFriendsListUpdate(friend, (byte) 1); + client.getSession().write(onlineNotifyStatus.serialize()); + + } else { + ChatOnChangeFriendStatus changeStatus = new ChatOnChangeFriendStatus(creature.getObjectID(), friend, 0); + client.getSession().write(changeStatus.serialize()); + } + } + } + } + core.playerService.postZoneIn(creature); } diff --git a/src/services/travel/TravelService.java b/src/services/travel/TravelService.java index bd3ba0b7..8ab347ca 100644 --- a/src/services/travel/TravelService.java +++ b/src/services/travel/TravelService.java @@ -230,7 +230,7 @@ public class TravelService implements INetworkDispatch { Planet planet = core.terrainService.getPlanetByName(departurePlanet.toLowerCase()); SWGObject travelTicket = core.objectService.createObject("object/tangible/travel/travel_ticket/base/shared_base_travel_ticket.iff", planet); - + travelTicket.setStringAttribute("@obj_attr_n:travel_departure_planet", WordUtils.capitalize(departurePlanet)); travelTicket.setStringAttribute("@obj_attr_n:travel_departure_point", departureLoc); @@ -274,7 +274,7 @@ public class TravelService implements INetworkDispatch { creatureObj.getSlottedObject("inventory").add(travelTicket); //Console.println("Total cost: " + fare); - SUIWindow window = core.suiService.createMessageBox(MessageBoxType.MESSAGE_BOX_OK, "STAR WARS GALAXIES", "Ticket purchase complete.", player, null, 0); + SUIWindow window = core.suiService.createMessageBox(MessageBoxType.MESSAGE_BOX_OK, "STAR WARS GALAXIES", "@travel:ticket_purchase_complete", player, null, 0); core.suiService.openSUIWindow(window); creatureObj.sendSystemMessage("You successfully make a payment of " + fare + " credits to the Galactic Travel Commission.", (byte) 0); From 9d7892188c89dc52238f5500e0fab6a61eac0796 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sun, 8 Dec 2013 11:08:24 -0500 Subject: [PATCH 22/23] FindFriend added, Bank tips no longer produces an error --- scripts/commands/findfriend.py | 18 ++++++++++++++++++ scripts/commands/tip.py | 8 ++++---- scripts/radial/travel_ticket.py | 6 +++--- src/services/chat/ChatService.java | 1 + 4 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 scripts/commands/findfriend.py diff --git a/scripts/commands/findfriend.py b/scripts/commands/findfriend.py new file mode 100644 index 00000000..992efa35 --- /dev/null +++ b/scripts/commands/findfriend.py @@ -0,0 +1,18 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + ghost = actor.getSlottedObject('ghost') + friend = commandString.split(' ')[0] + + if ghost.getFriendList().contains(friend): + friendObj = core.chatService.getObjectByFirstName(friend) + if friendObj is not None: + if friendObj.getSlottedObject('ghost').getFriendList().contains(actor.getCustomName().lower().split(' ')[0]): + fPos = friendObj.getPosition() + core.commandService.callCommand(actor, 'waypoint', None, friendObj.getPlanet().name + ' ' + str(fPos.x) + ' ' + str(fPos.z) + ' ' + str(fPos.y) + ' blue ' + friendObj.getCustomName()) + return + return + return \ No newline at end of file diff --git a/scripts/commands/tip.py b/scripts/commands/tip.py index b0b4331c..b34992f2 100644 --- a/scripts/commands/tip.py +++ b/scripts/commands/tip.py @@ -1,6 +1,4 @@ -from resources.objects.creature import CreatureObject from java.util import Date -from engine.resources.objects import SWGObject from services.chat import ChatService from services.chat import Mail from services.sui import SUIWindow @@ -8,6 +6,7 @@ from services.sui import SUIService from services.sui.SUIWindow import Trigger from services.sui.SUIService import MessageBoxType from java.util import Vector +from main import NGECore import sys # initialize global vars (happens at compile time) @@ -81,7 +80,8 @@ def run(core, actor, target, commandString): return return -def handleBankTip(core, owner, eventType, returnList): +def handleBankTip(owner, window, eventType, returnList): + core = NGECore.getInstance() chatSvc = core.chatService actorGlobal = core.objectService.getObject(actorID) targetGlobal = core.objectService.getObject(targetID) @@ -115,7 +115,7 @@ def handleBankTip(core, owner, eventType, returnList): actorMail.setSubject('@base_player:wire_mail_subject') actorMail.setSenderName('bank') - targetGlobal.setBankCredits(int(tipAmount)) + targetGlobal.setBankCredits(int(tipAmount) + int(targetGlobal.getBankCredits())) actorGlobal.setBankCredits(int(actorFunds) - int(totalLost)) actorGlobal.sendSystemMessage('You have successfully sent ' + tipAmount + ' bank credits to ' + targetGlobal.getCustomName(), 0) targetGlobal.sendSystemMessage('You have successfully received ' + tipAmount + ' bank credits from ' + actorGlobal.getCustomName(), 0) diff --git a/scripts/radial/travel_ticket.py b/scripts/radial/travel_ticket.py index 9812f7ff..a42df278 100644 --- a/scripts/radial/travel_ticket.py +++ b/scripts/radial/travel_ticket.py @@ -1,5 +1,4 @@ from resources.common import RadialOptions -from protocol.swg import EnterTicketPurchaseModeMessage import sys def createRadial(core, owner, target, radials): @@ -17,9 +16,10 @@ def handleSelection(core, owner, target, option): tp = core.travelService.getNearestTravelPoint(owner) if owner is not None and tp is not None: - if tp.getLocation().getDistance2D(owner.getWorldPosition()) <= 25: + print (str(tp.getLocation().getDistance2D(owner.getWorldPosition()))) + if tp.getLocation().getDistance2D(owner.getWorldPosition()) <= float(25): if tp.isShuttleAvailable() is True: - core.travelService.doTransport(owner, core.travelService.getTravelPointByName(target.getStringAttribute('@obj_attr_n:travel_arrival_planet'), + core.travelService.doTransport(owner, core.travelService.getTravelPointByName(target.getStringAttribute('@obj_attr_n:travel_arrival_planet'), target.getStringAttribute('@obj_attr_n:travel_arrival_point'))) core.objectService.destroyObject(target) return diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index a3587d08..e9aa0576 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -74,6 +74,7 @@ public class ChatService implements INetworkDispatch { core.commandService.registerCommand("socialinternal"); core.commandService.registerCommand("addignore"); core.commandService.registerCommand("removeignore"); + core.commandService.registerCommand("findfriend"); mailODB = core.getMailODB(); } From 6471d7e118eb322b7e49056b6eb93521f75aa656 Mon Sep 17 00:00:00 2001 From: darkk1138 Date: Sun, 8 Dec 2013 17:25:04 +0100 Subject: [PATCH 23/23] add /groupdance command --- scripts/commands/groupdance.py | 11 +++++++ .../creature/CreatureMessageBuilder.java | 2 +- .../objects/creature/CreatureObject.java | 29 +++++++++++++++++-- src/services/EntertainmentService.java | 7 +++-- src/services/command/CommandService.java | 1 - 5 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 scripts/commands/groupdance.py diff --git a/scripts/commands/groupdance.py b/scripts/commands/groupdance.py new file mode 100644 index 00000000..ed38ed89 --- /dev/null +++ b/scripts/commands/groupdance.py @@ -0,0 +1,11 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + + newState = actor.toggleGroupDance() + msg = '@performance:dance_group_on' if newState else '@performance:dance_group_off' + actor.sendSystemMessage(msg, 0) + return diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index ef2a2ad4..2491e829 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -992,7 +992,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putLong(creatureObjectId); int size = buffer.position(); buffer.flip(); - buffer = createDelta("CREO", (byte) 4, (short) 1, (short) 2, buffer, size + 4); + buffer = createDelta("CREO", (byte) 4, (short) 1, (short) 0x09, buffer, size + 4); return buffer; } diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index f0b160b5..4f24298c 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -55,7 +55,7 @@ import engine.resources.scene.Quaternion; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; -@Entity(version=6) +@Entity(version=7) public class CreatureObject extends TangibleObject implements IPersistent { @NotPersistent @@ -120,6 +120,8 @@ public class CreatureObject extends TangibleObject implements IPersistent { //FIXME: hmm.. or persistent? @NotPersistent private boolean acceptBandflourishes = true; + @NotPersistent + private boolean groupDance = true; private CreatureObject performanceWatchee; private CreatureObject performanceListenee; private int health = 1000; @@ -1341,6 +1343,26 @@ public class CreatureObject extends TangibleObject implements IPersistent { public boolean setStaticNPC(boolean staticNPC) { return this.staticNPC = staticNPC; } + + public boolean getGroupDance() { + synchronized(objectMutex) { + return groupDance; + } + } + + public void setGroupDance(boolean groupDance) { + synchronized(objectMutex) { + this.groupDance = groupDance; + } + } + + public boolean toggleGroupDance() { + synchronized(objectMutex) { + groupDance = !groupDance; + return groupDance; + } + } + public CreatureObject getPerformanceWatchee() { synchronized(objectMutex) { return performanceWatchee; @@ -1351,7 +1373,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { synchronized(objectMutex) { this.performanceWatchee = performanceWatchee; } - getClient().getSession().write(messageBuilder.buildListenToId(performanceWatchee.getObjectId())); + //getClient().getSession().write(messageBuilder.buildListenToId(0)); } public CreatureObject getPerformanceListenee() { @@ -1363,7 +1385,10 @@ public class CreatureObject extends TangibleObject implements IPersistent { public void setPerformanceListenee(CreatureObject performanceListenee) { synchronized(objectMutex) { this.performanceListenee = performanceListenee; + //possibly redundant, need to research this further. + this.listenToId = performanceListenee.getObjectId(); } + getClient().getSession().write(messageBuilder.buildListenToId(this.listenToId)); } public void startPerformance(int performanceId, int performanceCounter, String skillName, boolean isDance) { diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index 5bcfa7b6..60a6d7a0 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -215,11 +215,12 @@ public class EntertainmentService implements INetworkDispatch { } private void registerCommands() { - core.commandService.registerCommand("startdance"); - core.commandService.registerCommand("stopdance"); + core.commandService.registerCommand("bandflourish"); core.commandService.registerCommand("flourish"); core.commandService.registerAlias("flo","flourish"); - core.commandService.registerCommand("bandflourish"); + core.commandService.registerCommand("groupdance"); + core.commandService.registerCommand("startdance"); + core.commandService.registerCommand("stopdance"); } public void giveInspirationBuff(SWGObject reciever, Vector buffVector) { diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 293645f3..d02d5521 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -131,7 +131,6 @@ public class CommandService implements INetworkDispatch { } - //FIXME: CRC could just be generated as well. public void registerAlias(String name, String target) { Vector commands = new Vector(commandLookup); // copy for thread safety BaseSWGCommand targetCommand = null;