From d210dc7ad7c425ccae16543e0dd517a65affb4a9 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Wed, 19 Mar 2014 15:56:52 -0400 Subject: [PATCH] Added posture checks, radial script for player objects, bug fixes (Bug Fix) Must now wait before performing multiple flourishes (Bug Fix) Can no longer propose to yourself (aka your hand) (Bug Fix) Fixed some strings that didn't have variables (Added) Posture checks before Skill Animating (Added) Additional radial options show on players --- scripts/commands/flourish.py | 8 +---- scripts/commands/startdance.py | 11 +++++-- .../object/creature/player/bothan_female.py | 1 + scripts/object/creature/player/bothan_male.py | 1 + .../object/creature/player/human_female.py | 1 + scripts/object/creature/player/human_male.py | 1 + .../object/creature/player/ithorian_female.py | 1 + .../object/creature/player/ithorian_male.py | 1 + .../object/creature/player/moncal_female.py | 1 + scripts/object/creature/player/moncal_male.py | 1 + .../object/creature/player/rodian_female.py | 1 + scripts/object/creature/player/rodian_male.py | 1 + .../creature/player/sullustan_female.py | 1 + .../object/creature/player/sullustan_male.py | 1 + .../creature/player/trandoshan_female.py | 1 + .../object/creature/player/trandoshan_male.py | 1 + .../object/creature/player/twilek_female.py | 1 + scripts/object/creature/player/twilek_male.py | 1 + .../object/creature/player/wookiee_female.py | 1 + .../object/creature/player/wookiee_male.py | 1 + .../object/creature/player/zabrak_female.py | 1 + scripts/object/creature/player/zabrak_male.py | 1 + scripts/radial/player.py | 23 +++++++++++++ scripts/radial/ring/unity.py | 2 ++ src/resources/datatables/Posture.java | 21 ++++++++++++ .../objects/creature/CreatureObject.java | 7 ++-- src/services/EntertainmentService.java | 33 +++++++++++++++++-- 27 files changed, 110 insertions(+), 15 deletions(-) create mode 100644 scripts/radial/player.py create mode 100644 src/resources/datatables/Posture.java diff --git a/scripts/commands/flourish.py b/scripts/commands/flourish.py index 37c26077..0ec20d6b 100644 --- a/scripts/commands/flourish.py +++ b/scripts/commands/flourish.py @@ -22,11 +22,5 @@ def run(core, actor, target, commandString): if actor.getPerformanceId() <= 0: actor.sendSystemMessage('@performance:flourish_not_performing', 0) return - - actor.incFlourishCount() - actor.sendSystemMessage('@performance:flourish_perform', 0) - animation = 'skill_action_' + str(flourish) - if flourish == 9: - animation = 'mistake' - actor.doSkillAnimation(animation) + core.entertainmentService.performFlourish(actor, flourish) \ No newline at end of file diff --git a/scripts/commands/startdance.py b/scripts/commands/startdance.py index bae424d8..23b815c6 100644 --- a/scripts/commands/startdance.py +++ b/scripts/commands/startdance.py @@ -4,6 +4,7 @@ from services.sui.SUIWindow import Trigger from services.sui.SUIService import ListBoxType from java.util import Vector from java.util import HashMap +from resources.datatables import Posture import sys def setup(): @@ -26,7 +27,6 @@ def run(core, actor, target, commandString): else: availableDances = entSvc.getAvailableDances(actor) - print availableDances suiSvc = core.suiService suiWindow = suiSvc.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "@performance:select_dance", "@performance:available_dances", availableDances, actor, None, 10) @@ -74,8 +74,13 @@ def startDance(core, actor, danceName, visual): actor.sendSystemMessage('@performance:already_performing_self',0) return - #TODO: check costume, posture, etc? - + #TODO: check costume + + if actor.getPosture() != Posture.Upright: + print (' can\t dance because ' + str(actor.getPosture())) + actor.sendSystemMessage('@performance:dance_fail', 0) + return + actor.sendSystemMessage('@performance:dance_start_self',0); # i'm not sure about this. i think stopping just stopped any watchers anyways # method doesn't exist now. diff --git a/scripts/object/creature/player/bothan_female.py b/scripts/object/creature/player/bothan_female.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/bothan_female.py +++ b/scripts/object/creature/player/bothan_female.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/bothan_male.py b/scripts/object/creature/player/bothan_male.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/bothan_male.py +++ b/scripts/object/creature/player/bothan_male.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/human_female.py b/scripts/object/creature/player/human_female.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/human_female.py +++ b/scripts/object/creature/player/human_female.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/human_male.py b/scripts/object/creature/player/human_male.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/human_male.py +++ b/scripts/object/creature/player/human_male.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/ithorian_female.py b/scripts/object/creature/player/ithorian_female.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/ithorian_female.py +++ b/scripts/object/creature/player/ithorian_female.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/ithorian_male.py b/scripts/object/creature/player/ithorian_male.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/ithorian_male.py +++ b/scripts/object/creature/player/ithorian_male.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/moncal_female.py b/scripts/object/creature/player/moncal_female.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/moncal_female.py +++ b/scripts/object/creature/player/moncal_female.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/moncal_male.py b/scripts/object/creature/player/moncal_male.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/moncal_male.py +++ b/scripts/object/creature/player/moncal_male.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/rodian_female.py b/scripts/object/creature/player/rodian_female.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/rodian_female.py +++ b/scripts/object/creature/player/rodian_female.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/rodian_male.py b/scripts/object/creature/player/rodian_male.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/rodian_male.py +++ b/scripts/object/creature/player/rodian_male.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/sullustan_female.py b/scripts/object/creature/player/sullustan_female.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/sullustan_female.py +++ b/scripts/object/creature/player/sullustan_female.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/sullustan_male.py b/scripts/object/creature/player/sullustan_male.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/sullustan_male.py +++ b/scripts/object/creature/player/sullustan_male.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/trandoshan_female.py b/scripts/object/creature/player/trandoshan_female.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/trandoshan_female.py +++ b/scripts/object/creature/player/trandoshan_female.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/trandoshan_male.py b/scripts/object/creature/player/trandoshan_male.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/trandoshan_male.py +++ b/scripts/object/creature/player/trandoshan_male.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/twilek_female.py b/scripts/object/creature/player/twilek_female.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/twilek_female.py +++ b/scripts/object/creature/player/twilek_female.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/twilek_male.py b/scripts/object/creature/player/twilek_male.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/twilek_male.py +++ b/scripts/object/creature/player/twilek_male.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/wookiee_female.py b/scripts/object/creature/player/wookiee_female.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/wookiee_female.py +++ b/scripts/object/creature/player/wookiee_female.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/wookiee_male.py b/scripts/object/creature/player/wookiee_male.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/wookiee_male.py +++ b/scripts/object/creature/player/wookiee_male.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/zabrak_female.py b/scripts/object/creature/player/zabrak_female.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/zabrak_female.py +++ b/scripts/object/creature/player/zabrak_female.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/object/creature/player/zabrak_male.py b/scripts/object/creature/player/zabrak_male.py index ccad8904..b80d569c 100644 --- a/scripts/object/creature/player/zabrak_male.py +++ b/scripts/object/creature/player/zabrak_male.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'player') return \ No newline at end of file diff --git a/scripts/radial/player.py b/scripts/radial/player.py new file mode 100644 index 00000000..3ca2cc75 --- /dev/null +++ b/scripts/radial/player.py @@ -0,0 +1,23 @@ +from resources.common import RadialOptions +from resources.datatables import Posture +import sys + +def createRadial(core, owner, target, radials): + if target.getPosture() == Posture.SkillAnimating: + if target.getPerformanceType() is True: + radials.add(RadialOptions(0, 140, 1, 'Watch')) + else: + radials.add(RadialOptions(0, 140, 1, 'Listen')) + + return + +def handleSelection(core, owner, target, option): + if option == 140: + if target.getPerformanceType() is True: + core.commandService.callCommand(owner, 'watch', target, '') + return + else: + # TODO: Insert callCommand /listen + return + return + return \ No newline at end of file diff --git a/scripts/radial/ring/unity.py b/scripts/radial/ring/unity.py index f57f3034..5065a8f4 100644 --- a/scripts/radial/ring/unity.py +++ b/scripts/radial/ring/unity.py @@ -14,6 +14,8 @@ def createRadial(core, owner, target, radials): if ghost.getSpouseName() is None or ghost.getSpouseName() is "": targetPlayer = core.objectService.getObject(owner.getTargetId()) if targetPlayer is not None and targetPlayer.getSlottedObject('ghost') is not None: + if targetPlayer.getObjectID() is owner.getObjectID(): + return radials.add(RadialOptions(0, 69, 1, '@unity:mnu_propose')) return else: diff --git a/src/resources/datatables/Posture.java b/src/resources/datatables/Posture.java new file mode 100644 index 00000000..312337f1 --- /dev/null +++ b/src/resources/datatables/Posture.java @@ -0,0 +1,21 @@ +package resources.datatables; + +public class Posture { + // Posture.iff + public static final int Invalid = -1; + public static final int Upright = 0; + public static final int Crouched = 1; + public static final int Prone = 2; + public static final int Sneaking = 3; + public static final int Blocking = 4; + public static final int Climbing = 5; + public static final int Flying = 6; + public static final int LyingDown = 7; + public static final int Sitting = 8; + public static final int SkillAnimating = 9; + public static final int DrivingVehicle = 10; + public static final int RidingCreature = 11; + public static final int KnockedDown = 12; + public static final int Incapacitated = 13; + public static final int Dead = 14; +} diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 19d60409..a3166959 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -355,11 +355,10 @@ public class CreatureObject extends TangibleObject implements IPersistent { this.posture = posture; } - IoBuffer postureDelta = messageBuilder.buildPostureDelta(posture); Posture postureUpdate = new Posture(getObjectID(), posture); ObjControllerMessage objController = new ObjControllerMessage(0x1B, postureUpdate); - notifyObservers(postureDelta, true); + notifyObservers(messageBuilder.buildPostureDelta(posture), true); notifyObservers(objController, true); if (needsStopPerformance) { @@ -377,6 +376,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { public void stopPerformance() { String type = ""; synchronized(objectMutex) { + // TODO: Minimum check to wait for song to finish before stopping... ? setPerformanceId(0,true); setPerformanceCounter(0); setCurrentAnimation(""); @@ -413,7 +413,8 @@ public class CreatureObject extends TangibleObject implements IPersistent { next.setMoodAnimation(""); } if (next == this) { continue; } - next.sendSystemMessage("@performance:" + type + "_stop_other",(byte)0); + if(performanceType) { next.sendSystemMessage("You stop watching " + getCustomName() + ".",(byte)0); } + else { next.sendSystemMessage("You stop listening to " + getCustomName() + ".",(byte)0); } next.getSpectatorTask().cancel(true); } //not sure if this behaviour is correct. might need fixing later. diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index a57d486d..ad35f3f8 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -429,8 +429,7 @@ public class EntertainmentService implements INetworkDispatch { public void run() { if (spectator.getPosition().getDistance2D(performer.getWorldPosition()) > (float) 70) { - String pType = (performer.getPerformanceType()) ? "dance" : "music"; - if(pType.equals("dance")) { + if(((performer.getPerformanceType()) ? "dance" : "music").equals("dance")) { spectator.setPerformanceWatchee(null); spectator.sendSystemMessage("You stop watching " + performer.getCustomName() + " because " + performer.getCustomName() + " is out of range.", (byte) 0); @@ -452,6 +451,36 @@ public class EntertainmentService implements INetworkDispatch { spectator.setSpectatorTask(spectatorTask); } + public void performFlourish(final CreatureObject performer, int flourish) { + + if (performer.getFlourishCount() > 0) { + performer.sendSystemMessage("@performance:wait_flourish_self", (byte) 0); + return; + } + Performance performance = getPerformanceByIndex(performer.getPerformanceId()); + + if(performance == null) + return; + + String anmFlo = "skill_action_" + flourish; + + if (flourish == 9) + anmFlo = "mistake"; + + performer.setFlourishCount(1); + performer.sendSystemMessage("@performance:flourish_perform", (byte) 0); + performer.doSkillAnimation(anmFlo); + + scheduler.schedule(new Runnable() { + + @Override + public void run() { + performer.setFlourishCount(0); + } + + }, (long) performance.getLoopDuration(), TimeUnit.SECONDS); + } + @Override public void shutdown() {