mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-10-13 03:13:26 -04:00
FIXED Incorrect music playing for each instrument
ADDED Player Ability check to playing music ADDED Player notification messages for failed music performance checks ADDED 'canPerform' method to EntertainmentService ADDED 'getAvailableSongs' method to EntertainmentService
This commit is contained in:
@@ -1,72 +1,102 @@
|
||||
import sys
|
||||
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
|
||||
from resources.datatables import Posture
|
||||
|
||||
def setup():
|
||||
return
|
||||
|
||||
def run(core, actor, target, commandString):
|
||||
#print("Up the Irons!")
|
||||
global suiWindow
|
||||
global actorObject
|
||||
global entSvc
|
||||
actorObject = actor
|
||||
entSvc = core.entertainmentService
|
||||
|
||||
instrumentObj = entSvc.getInstrument(actor)
|
||||
|
||||
#TODO: Determine if player has an instrument
|
||||
if instrumentObj is not None:
|
||||
#TODO: If player does have an instrument then determine what type of instrument the player has
|
||||
#If player does have an instrument then determine what type of instrument the player has
|
||||
instrumentStfName = instrumentObj.getStfName()
|
||||
instrumentCode = -1
|
||||
#TODO: If type is traz then audioID is 1
|
||||
#If type is traz then audioID is 1
|
||||
if instrumentStfName == "obj_traz_classic":
|
||||
instrumentCode = 1
|
||||
#TODO: Else if type is slitherhorn then audioID is 2
|
||||
#if type is slitherhorn then audioID is 2
|
||||
elif instrumentStfName == "obj_slitherhorn_classic":
|
||||
instrumentCode = 2
|
||||
#TODO: Else if type is fanfar then audioID is 3
|
||||
#if type is fanfar then audioID is 3
|
||||
elif instrumentStfName == "obj_fanfar_classic":
|
||||
instrumentCode = 3
|
||||
#TODO: Else if type is flutedroopy then audioID is 4
|
||||
#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"
|
||||
|
||||
#TODO: Else if type is kloohorn then audioID is 5
|
||||
#if type is kloohorn then audioID is 5
|
||||
elif instrumentStfName == "obj_kloo_horn_classic":
|
||||
instrumentCode = 5
|
||||
#TODO: Else if type is fizz then audioID is 6
|
||||
#if type is fizz then audioID is 6
|
||||
elif instrumentStfName == "obj_fizzz_classic":
|
||||
instrumentCode = 6
|
||||
#TODO: Else if type is bandfill then audioID is 7
|
||||
#if type is bandfill then audioID is 7
|
||||
elif instrumentStfName == "obj_bandfill_classic":
|
||||
instrumentCode = 7
|
||||
|
||||
#TODO: Else if type is omnibox then audioID is 8
|
||||
#if type is omnibox then audioID is 8
|
||||
#FIXME: This instrument isn't equipped when played
|
||||
|
||||
#TODO: Else if type is nalargon then audioID is 9
|
||||
#if type is nalargon then audioID is 9
|
||||
#FIXME: This instrument isn't equipped when played
|
||||
|
||||
#TODO: Else if type is mandoviol then audioID is 10
|
||||
#if type is mandoviol then audioID is 10
|
||||
elif instrumentStfName == "obj_mandoviol_classic":
|
||||
instrumentCode = 10
|
||||
#TODO: Else if type is xantha then audioID is 11
|
||||
#if type is xantha then audioID is 11
|
||||
elif instrumentStfName == "xantha_n":
|
||||
instrumentCode = 11
|
||||
#TODO: Else if type is flangedjessoon then audioID is 12
|
||||
#if type is flangedjessoon then audioID is 12
|
||||
elif instrumentStfName == "obj_jessoon":
|
||||
instrumentCode = 12
|
||||
#TODO: Else if type is valahorn then audioID is 13
|
||||
#if type is valahorn then audioID is 13
|
||||
elif instrumentStfName == "obj_valahorn":
|
||||
instrumentCode = 13
|
||||
#TODO: Else if type is downeybox then audioID is 14
|
||||
#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:
|
||||
#TODO: Parse command string
|
||||
#Parse command string
|
||||
if len(commandString) > 0:
|
||||
params = commandString.split(" ")
|
||||
performance = entSvc.getPerformance(params[0], instrumentCode)
|
||||
print('line number: ', performance.getLineNumber())
|
||||
#print(performance.getPerformanceName(), performance.getInstrumentAudioId())
|
||||
startMusic(core, actor, performance, entSvc)
|
||||
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)
|
||||
else:
|
||||
#Equipped item is not an instrument
|
||||
actor.sendSystemMessage('@performance:music_no_instrument', 0)
|
||||
@@ -81,17 +111,15 @@ def run(core, actor, target, commandString):
|
||||
This information doesn't seem to be needed...
|
||||
'''
|
||||
pass
|
||||
def startMusic(core, actor, performance, entSvc):
|
||||
|
||||
if performance is None:
|
||||
#Not a proper song
|
||||
actor.sendSystemMessage('@performance:music_invalid_song', 0)
|
||||
return
|
||||
|
||||
#TODO: Handle lack of skill
|
||||
|
||||
def handleStartMusic(core, owner, eventType, returnList):
|
||||
item = suiWindow.getMenuItems().get(int(returnList.get(0)))
|
||||
print(item.getObjectId())
|
||||
startMusic(core, actorObject, item.getObjectId())
|
||||
pass
|
||||
def startMusic(core, actor, performanceLineNumber):
|
||||
if actor.getPosture == 0x09:
|
||||
actor.sendSystemMessage('@performance:music_fail', 0)
|
||||
actor.sendSystemMessage('@performance:already_performing_self', 0)
|
||||
pass
|
||||
|
||||
if not actor.getPerformanceWatchee():
|
||||
@@ -108,19 +136,16 @@ def startMusic(core, actor, performance, entSvc):
|
||||
|
||||
#FIXME: player plays wrong song
|
||||
|
||||
anim = 'music_'+ str(performance.getLineNumber())
|
||||
actor.sendSystemMessage('@performance:music_start_self',0)
|
||||
#entSvc.startPerformance(actor, performance.getLineNumber(), -842249156, "dance_0", 0)#TODO: Figure out what exactly goes in parameter slots 2 and 3
|
||||
#entSvc.startPerformance(actor, performance.getLineNumber(), -842249156, anim, 0)#TODO: Figure out what exactly goes in parameter slots 2 and 3
|
||||
entSvc.startPerformance(actor, performance.getLineNumber(), -842249156, 'music_8', 0)#TODO: Figure out what exactly goes in parameter slots 2 and 3
|
||||
entSvc.startPerformance(actor, performanceLineNumber+1, -842249156, 'music_2', 0)#TODO: Figure out what exactly goes in parameter slots 2 and 3
|
||||
'''
|
||||
Bandfill = music_1
|
||||
Nargalon = music_2
|
||||
(Some flute-ish)[perhaps traz] = music_3
|
||||
Omnibox = music_4
|
||||
Mandoviol = music_5
|
||||
Nil = music_6
|
||||
Nargalon = music_8
|
||||
|
||||
'''
|
||||
|
||||
pass
|
||||
|
||||
@@ -51,6 +51,9 @@ public class EntertainmentService implements INetworkDispatch {
|
||||
|
||||
private NGECore core;
|
||||
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
|
||||
private static final int SONG = 866729052;
|
||||
private static final int DANCE = -1788534963;
|
||||
|
||||
private Vector<BuffBuilder> buffBuilderSkills = new Vector<BuffBuilder>();
|
||||
//FIXME: create a wrapper class for double key lookup maps
|
||||
@@ -642,6 +645,22 @@ public class EntertainmentService implements INetworkDispatch {
|
||||
|
||||
}
|
||||
|
||||
public Map<Long, String> getAvailableSongs(CreatureObject actor, int instrumentCode)
|
||||
{
|
||||
Map<Long, String> songs = new HashMap<Long, String>();
|
||||
for(Performance performance : performances.values())
|
||||
{
|
||||
if(performance.getInstrumentAudioId() == instrumentCode)
|
||||
{
|
||||
if(canPerform(actor, performance))
|
||||
{
|
||||
songs.put(new Long(performance.getLineNumber()), performance.getPerformanceName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return songs;
|
||||
}
|
||||
|
||||
//FIXME: if visualId > 0 then it is a dance...
|
||||
public boolean isDance(int visualId) {
|
||||
return ( danceMap.get(visualId) != null ) ;
|
||||
@@ -654,17 +673,29 @@ public class EntertainmentService implements INetworkDispatch {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean canDance(CreatureObject actor, int visualId) {
|
||||
if (!isDance(visualId)) { return false; }
|
||||
return canDance(actor, danceMap.get(visualId));
|
||||
}
|
||||
|
||||
public boolean canPerform(CreatureObject actor, Performance performance)
|
||||
{
|
||||
if(performance.getRequiredInstrument() != null)
|
||||
{
|
||||
boolean hasInstrument = actor.hasAbility(performance.getRequiredInstrument());
|
||||
boolean hasSong = actor.hasAbility(performance.getRequiredSong());
|
||||
return hasInstrument && hasSong;
|
||||
}
|
||||
else return actor.hasAbility(performance.getRequiredDance());
|
||||
}
|
||||
|
||||
public Performance getDance(int visualId) {
|
||||
return danceMap.get(visualId);
|
||||
}
|
||||
|
||||
//FIXME: Refactor using new map -COMPLETE-
|
||||
//FIXME: Returning null for known combination...
|
||||
//FIXME: Returning null for known combination... - fixed?
|
||||
public Performance getPerformance(String name, int instrumentAudioId) {
|
||||
return performances.get(new PerformanceUID(name, instrumentAudioId));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user