diff --git a/scripts/commands/startmusic.py b/scripts/commands/startmusic.py index ff1a94e3..a290a0bc 100644 --- a/scripts/commands/startmusic.py +++ b/scripts/commands/startmusic.py @@ -17,92 +17,38 @@ def run(core, actor, target, commandString): actorObject = actor entSvc = core.entertainmentService - instrumentObj = entSvc.getInstrument(actor) - - #TODO: Determine if player has an instrument - if instrumentObj is not None: - #If player does have an instrument then determine what type of instrument the player has - instrumentStfName = instrumentObj.getStfName() - instrumentCode = -1 - #If type is traz then audioID is 1 - if instrumentStfName == "obj_traz_classic": - instrumentCode = 1 - #if type is slitherhorn then audioID is 2 - elif instrumentStfName == "obj_slitherhorn_classic": - instrumentCode = 2 - #if type is fanfar then audioID is 3 - elif instrumentStfName == "obj_fanfar_classic": - instrumentCode = 3 - #if type is flutedroopy then audioID is 4 - #FIXME: I don't know what this is yet, but I suspect it's "obj_chidinkalu_horn_classic" + instrumentCode = entSvc.getInstrumentAudioId(actor) + + #print('instrumentCode: ' , instrumentCode) + if instrumentCode > 0: + #Parse command string + if len(commandString) > 0: + params = commandString.split(" ") + performance = entSvc.getPerformance(params[0], instrumentCode) + #print('line number: ', performance.getLineNumber()) + if performance is None: + #Not a proper song + actor.sendSystemMessage('@performance:music_invalid_song', 0) + return - #if type is kloohorn then audioID is 5 - elif instrumentStfName == "obj_kloo_horn_classic": - instrumentCode = 5 - #if type is fizz then audioID is 6 - elif instrumentStfName == "obj_fizzz_classic": - instrumentCode = 6 - #if type is bandfill then audioID is 7 - elif instrumentStfName == "obj_bandfill_classic": - instrumentCode = 7 - - #if type is omnibox then audioID is 8 - #FIXME: This instrument isn't equipped when played - - #if type is nalargon then audioID is 9 - #FIXME: This instrument isn't equipped when played - - #if type is mandoviol then audioID is 10 - elif instrumentStfName == "obj_mandoviol_classic": - instrumentCode = 10 - #if type is xantha then audioID is 11 - elif instrumentStfName == "xantha_n": - instrumentCode = 11 - #if type is flangedjessoon then audioID is 12 - elif instrumentStfName == "obj_jessoon": - instrumentCode = 12 - #if type is valahorn then audioID is 13 - elif instrumentStfName == "obj_valahorn": - instrumentCode = 13 - #if type is downeybox then audioID is 14 - #FIXME: This instrument isn't equipped when played - - #TODO: Handle instruments that are placed on the ground - - print('instrumentCode: ' , instrumentCode) - if instrumentCode > 0: - #Parse command string - if len(commandString) > 0: - params = commandString.split(" ") - performance = entSvc.getPerformance(params[0], instrumentCode) - print('line number: ', performance.getLineNumber()) - if performance is None: - #Not a proper song - actor.sendSystemMessage('@performance:music_invalid_song', 0) - return - - #Handle lack of skill - if not entSvc.canPerform(actor, performance): - actor.sendSystemMessage('@performance:music_lack_skill_self',0) - return - startMusic(core, actor, performance.getLineNumber()) - else: - availableSongs = entSvc.getAvailableSongs(actor, instrumentCode) - - suiSvc = core.suiService - suiWindow = suiSvc.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "@performance:select_song", "@performance:available_songs", availableSongs, actor, None, 10) - - returnList = Vector() - returnList.add("List.lstList:SelectedRow") - suiWindow.addHandler(0, '', Trigger.TRIGGER_OK, returnList, handleStartMusic) - - suiSvc.openSUIWindow(suiWindow) + #Handle lack of skill + if not entSvc.canPerform(actor, performance): + actor.sendSystemMessage('@performance:music_lack_skill_self',0) + return + startMusic(core, actor, performance.getLineNumber()) else: - #Equipped item is not an instrument - actor.sendSystemMessage('@performance:music_no_instrument', 0) - pass + availableSongs = entSvc.getAvailableSongs(actor, instrumentCode) + + suiSvc = core.suiService + suiWindow = suiSvc.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "@performance:select_song", "@performance:available_songs", availableSongs, actor, None, 10) + + returnList = Vector() + returnList.add("List.lstList:SelectedRow") + suiWindow.addHandler(0, '', Trigger.TRIGGER_OK, returnList, handleStartMusic) + + suiSvc.openSUIWindow(suiWindow) else: - #No instrument equipped + #Equipped item is not an instrument actor.sendSystemMessage('@performance:music_no_instrument', 0) pass ''' @@ -119,7 +65,7 @@ def handleStartMusic(core, owner, eventType, returnList): pass def startMusic(core, actor, performanceLineNumber): - if actor.getPosture == 0x09: + if actor.getPosture() == 0x09: actor.sendSystemMessage('@performance:already_performing_self', 0) pass @@ -154,7 +100,7 @@ def startMusic(core, actor, performanceLineNumber): elif audioId < 15: songAnim = "music_4" #downeybox (Don't think this was ever added) - print(songAnim) + #print(songAnim) actor.sendSystemMessage('@performance:music_start_self',0) diff --git a/scripts/object/tangible/instrument/bandfill.py b/scripts/object/tangible/instrument/bandfill.py index ccad8904..3d5558f7 100644 --- a/scripts/object/tangible/instrument/bandfill.py +++ b/scripts/object/tangible/instrument/bandfill.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "50") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/scripts/object/tangible/instrument/downey_box.py b/scripts/object/tangible/instrument/downey_box.py index ccad8904..c08009de 100644 --- a/scripts/object/tangible/instrument/downey_box.py +++ b/scripts/object/tangible/instrument/downey_box.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "74") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/scripts/object/tangible/instrument/fanfar.py b/scripts/object/tangible/instrument/fanfar.py index ccad8904..c3a06763 100644 --- a/scripts/object/tangible/instrument/fanfar.py +++ b/scripts/object/tangible/instrument/fanfar.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "7") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/scripts/object/tangible/instrument/fizz.py b/scripts/object/tangible/instrument/fizz.py index ccad8904..c83ab460 100644 --- a/scripts/object/tangible/instrument/fizz.py +++ b/scripts/object/tangible/instrument/fizz.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "1") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/scripts/object/tangible/instrument/flanged_jessoon.py b/scripts/object/tangible/instrument/flanged_jessoon.py index ccad8904..3d5558f7 100644 --- a/scripts/object/tangible/instrument/flanged_jessoon.py +++ b/scripts/object/tangible/instrument/flanged_jessoon.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "50") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/scripts/object/tangible/instrument/flute_droopy.py b/scripts/object/tangible/instrument/flute_droopy.py index ccad8904..01907cbb 100644 --- a/scripts/object/tangible/instrument/flute_droopy.py +++ b/scripts/object/tangible/instrument/flute_droopy.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "62") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/scripts/object/tangible/instrument/kloo_horn.py b/scripts/object/tangible/instrument/kloo_horn.py index ccad8904..58058b9a 100644 --- a/scripts/object/tangible/instrument/kloo_horn.py +++ b/scripts/object/tangible/instrument/kloo_horn.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "14") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/scripts/object/tangible/instrument/mandoviol.py b/scripts/object/tangible/instrument/mandoviol.py index ccad8904..9624c6f4 100644 --- a/scripts/object/tangible/instrument/mandoviol.py +++ b/scripts/object/tangible/instrument/mandoviol.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "38") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/scripts/object/tangible/instrument/nalargon.py b/scripts/object/tangible/instrument/nalargon.py index ccad8904..261e4b7a 100644 --- a/scripts/object/tangible/instrument/nalargon.py +++ b/scripts/object/tangible/instrument/nalargon.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "86") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/scripts/object/tangible/instrument/ommni_box.py b/scripts/object/tangible/instrument/ommni_box.py index ccad8904..c08009de 100644 --- a/scripts/object/tangible/instrument/ommni_box.py +++ b/scripts/object/tangible/instrument/ommni_box.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "74") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/scripts/object/tangible/instrument/traz.py b/scripts/object/tangible/instrument/traz.py index ccad8904..e39d8c2f 100644 --- a/scripts/object/tangible/instrument/traz.py +++ b/scripts/object/tangible/instrument/traz.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "26") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/scripts/object/tangible/instrument/valahorn.py b/scripts/object/tangible/instrument/valahorn.py index ccad8904..8591f484 100644 --- a/scripts/object/tangible/instrument/valahorn.py +++ b/scripts/object/tangible/instrument/valahorn.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "90") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/scripts/object/tangible/instrument/xantha.py b/scripts/object/tangible/instrument/xantha.py index ccad8904..8591f484 100644 --- a/scripts/object/tangible/instrument/xantha.py +++ b/scripts/object/tangible/instrument/xantha.py @@ -1,4 +1,6 @@ import sys def setup(core, object): + object.setStringAttribute("required_combat_level", "90") + object.setStringAttribute("class_required", "Entertainer") return \ No newline at end of file diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index 5a012745..a9488dac 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -76,7 +76,7 @@ public class EntertainmentService implements INetworkDispatch { populateSkillCaps(); populatePerformanceTable(); - System.out.printf("[DEBUG] number_of_performances: %d\n", performances.size()); + //System.out.printf("[DEBUG] number_of_performances: %d\n", performances.size()); populatePerformanceEffects(); registerCommands(); @@ -456,11 +456,13 @@ public class EntertainmentService implements INetworkDispatch { } //TODO: Remove + /* Set debugSet = performances.keySet(); for(PerformanceUID uid : debugSet) { System.out.println(uid.toString()); } + */ } @@ -872,7 +874,7 @@ public class EntertainmentService implements INetworkDispatch { performer.sendSystemMessage("@performance:flourish_wait_self", (byte) 0); return; } - //FIXME: I don't think this will work. + Performance performance = getPerformanceByIndex(performer.getPerformanceId()); if(performance == null) @@ -887,6 +889,7 @@ public class EntertainmentService implements INetworkDispatch { performer.setPerformingFlourish(true); performer.sendSystemMessage("@performance:flourish_perform", (byte) 0); performer.doSkillAnimation(anmFlo); + performer.playMusic(performance.getFlourish1()); scheduler.schedule(() -> { try { @@ -1112,6 +1115,50 @@ public class EntertainmentService implements INetworkDispatch { return actor.getSlottedObject("hold_r"); } + /** + * @param actor + * @return The InstrumentAudioId of the instrument being played or zero if there is no instrument being played + */ + public int getInstrumentAudioId(CreatureObject actor) + { + SWGObject instrument = getInstrument(actor); + if(instrument != null) + { + switch(instrument.getStfName()) + { + case "obj_traz_classic": + return 1; + case "obj_slitherhorn_classic": + return 2; + case "obj_fanfar_classic": + return 3; + case "obj_chidinkalu_horn_classic"://FIXME: Not 100% certain on this one, but I think it's flootdroopy + return 4; + case "obj_kloo_horn_classic": + return 5; + case "obj_fizzz_classic": + return 6; + case "obj_bandfill_classic": + return 7; + case "obj_modoviol_classic": + return 10; + case "obj_xanta_n": + return 11; + case "obj_jessoon": + return 12; + case "obj_valahorn": + return 13; + default: + break; + } + } + //TODO: The following instruments are placed and then played instead of being held. + //TODO: omnibox audioID is 8. + //TODO: nargalon audioID is 9. + //TODO: downeybox audioID is 14. + return 0; + } + @Override public void shutdown() {