From ffc9aec1b196244e632f109c6b2d82cb124176fe Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sat, 22 Mar 2014 11:47:37 -0400 Subject: [PATCH] Added Inspiration ticks, effects for Multi-Tier Performance Abilities (BugFix) Build-A-Buff applies correct stats now -- NOTE: Stats that the player does not have yet may not show in character sheet but the server will recognize still recognize their new stats (Added) Inspiration Ticks (BugFix) Inspiration Buffs time corresponds to the players inspiration ticks. (BugFix) "Watch" on radial menu working again (Added) Put in the effects for the multi-tiered performance abilities (Feature) You can now type /[performance effect] [tier number] to use that specific effect (BugFix) showFlyText boolean for showing to observers or not (fixes other players exp gain shown to other players) (Code) Few minor additions/fixes --- scripts/buffs/buildabuff_inspiration.py | 7 +- scripts/commands/colorlights.py | 17 ++++- scripts/commands/dazzle.py | 17 ++++- scripts/commands/distract.py | 17 ++++- scripts/commands/firejet.py | 19 +++-- scripts/commands/inspire.py | 2 +- scripts/commands/smokebomb.py | 17 ++++- scripts/commands/spotlight.py | 23 +++--- scripts/commands/ventriloquism.py | 17 ++++- .../expertise_en_intense_performer_1.py | 5 +- .../expertise_en_intense_performer_2.py | 3 +- .../expertise_en_intense_performer_3.py | 3 +- .../expertise_en_intense_performer_4.py | 3 +- .../expertise_en_lasting_impression_1.py | 3 +- .../expertise_en_lasting_impression_2.py | 3 +- .../expertise_en_lasting_impression_3.py | 3 +- .../expertise_en_lasting_impression_4.py | 3 +- scripts/radial/player.py | 4 +- .../objectControllerObjects/ShowFlyText.java | 11 ++- src/resources/common/MathUtilities.java | 24 ++++++ .../objects/creature/CreatureObject.java | 9 ++- .../objects/tangible/TangibleObject.java | 12 +++ src/services/ConnectionService.java | 14 ++++ src/services/EntertainmentService.java | 75 +++++++++++++++---- 24 files changed, 242 insertions(+), 69 deletions(-) diff --git a/scripts/buffs/buildabuff_inspiration.py b/scripts/buffs/buildabuff_inspiration.py index c6bf7407..801733ca 100644 --- a/scripts/buffs/buildabuff_inspiration.py +++ b/scripts/buffs/buildabuff_inspiration.py @@ -8,10 +8,13 @@ def setup(core, actor, buff): if buffWorkshop is None: return - buff.setDuration(3600) #1 hour - + attached = actor.getAttachment('inspireDuration') + print (attached) + buff.setDuration(float(actor.getAttachment('inspireDuration') * 60)) + print ('Buff Duration: ' + str(actor.getAttachment('inspireDuration'))) for BuffItem in buffWorkshop: core.skillModService.addSkillMod(actor, BuffItem.getSkillName(), BuffItem.getAffectAmount()) + print ('Gave skill mod ' + BuffItem.getSkillName() + ' with affect of ' + str(BuffItem.getAffectAmount())) return diff --git a/scripts/commands/colorlights.py b/scripts/commands/colorlights.py index abaa8dd2..b92c9c34 100644 --- a/scripts/commands/colorlights.py +++ b/scripts/commands/colorlights.py @@ -6,14 +6,23 @@ def setup(): def run(core, actor, target, commandString): command = 'ColorLights1' - effect = 'entertainer_color_lights_level_1.cef' + effect = 'clienteffect/entertainer_color_lights_level_1.cef' + rLevel = 4 # minimum level to perform this effect - if actor.getLevel() < 4: + if commandString == '2': + command = 'ColorLights2' + effect = 'clienteffect/entertainer_color_lights_level_2.cef' + rLevel = 20 + + elif commandString == '3': + command = 'ColorLights3' + effect = 'clienteffect/entertainer_color_lights_level_3.cef' + rLevel = 50 + + if actor.getLevel() < rLevel: actor.sendSystemMessage('@performance:effect_lack_skill_self') return - # TODO: Find out levels for other colored light 2 and 3 - if core.entertainmentService.performEffect(actor, command, effect, target) is True: actor.sendSystemMessage('@performance:effect_perform_color_lights', 0) return \ No newline at end of file diff --git a/scripts/commands/dazzle.py b/scripts/commands/dazzle.py index 718c6c5d..25ac5068 100644 --- a/scripts/commands/dazzle.py +++ b/scripts/commands/dazzle.py @@ -6,14 +6,23 @@ def setup(): def run(core, actor, target, commandString): command = 'Dazzle1' - effect = 'entertainer_dazzle_level_1.cef' + effect = 'clienteffect/entertainer_dazzle_level_1.cef' + rLevel = 10 # minimum level to perform this effect - if actor.getLevel() < 10: + if commandString == '2': + command = 'Dazzle2' + effect = 'clienteffect/entertainer_dazzle_level_2.cef' + rLevel = 20 + + elif commandString == '3': + command = 'Dazzle3' + effect = 'clienteffect/entertainer_dazzle_level_3.cef' + rLevel = 30 + + if actor.getLevel() < rLevel: actor.sendSystemMessage('@performance:effect_lack_skill_self') return - # TODO: Find out levels for other dazzle 2 and 3 - if core.entertainmentService.performEffect(actor, command, effect, target) is True: actor.sendSystemMessage('@performance:effect_perform_dazzle', 0) return \ No newline at end of file diff --git a/scripts/commands/distract.py b/scripts/commands/distract.py index 6c1eb887..d92cb55e 100644 --- a/scripts/commands/distract.py +++ b/scripts/commands/distract.py @@ -6,14 +6,23 @@ def setup(): def run(core, actor, target, commandString): command = 'Distract1' - effect = 'entertainer_distract_level_1.cef' + effect = 'clienteffect/entertainer_distract_level_1.cef' + rLevel = 18 # minimum level to perform this effect - if actor.getLevel() < 18: + if commandString == '2': + command = 'Distract2' + effect = 'clienteffect/entertainer_distract_level_2.cef' + rLevel = 50 + + elif commandString == '3': + command = 'Distract3' + effect = 'clienteffect/entertainer_distract_level_3.cef' + rLevel = 75 + + if actor.getLevel() < rLevel: actor.sendSystemMessage('@performance:effect_lack_skill_self') return - # TODO: Find out levels for other distract 2 and 3 - if core.entertainmentService.performEffect(actor, command, effect, target) is True: actor.sendSystemMessage('@performance:effect_perform_distract', 0) return \ No newline at end of file diff --git a/scripts/commands/firejet.py b/scripts/commands/firejet.py index 42179337..63a5ba54 100644 --- a/scripts/commands/firejet.py +++ b/scripts/commands/firejet.py @@ -6,14 +6,23 @@ def setup(): def run(core, actor, target, commandString): command = 'FireJets1' - effect = 'entertainer_fire_jets_level_1.cef' + effect = 'clienteffect/entertainer_fire_jets_level_1.cef' + rLevel = 26 # minimum level to perform this effect - if actor.getLevel() < 26: + if commandString == '2': + command = 'FireJets2' + effect = 'clienteffect/entertainer_fire_jets_level_2.cef' + rLevel = 50 + + elif commandString == '3': + command = 'FireJets3' + effect = 'clienteffect/entertainer_fire_jets_level_3.cef' + rLevel = 75 + + if actor.getLevel() < rLevel: actor.sendSystemMessage('@performance:effect_lack_skill_self') return - - # TODO: Find out levels for other firejets 2 and 3 - + if core.entertainmentService.performEffect(actor, command, effect, target) is True: actor.sendSystemMessage('@performance:effect_perform_fire_jets', 0) return \ No newline at end of file diff --git a/scripts/commands/inspire.py b/scripts/commands/inspire.py index 531aa1e2..dea0e544 100644 --- a/scripts/commands/inspire.py +++ b/scripts/commands/inspire.py @@ -7,7 +7,7 @@ def setup(): def run(core, actor, target, commandString): playerObject = actor.getSlottedObject('ghost') - print playerObject.getProfession() + if not playerObject or playerObject.getProfession() != "entertainer_1a": return diff --git a/scripts/commands/smokebomb.py b/scripts/commands/smokebomb.py index 01b2bf52..ace39704 100644 --- a/scripts/commands/smokebomb.py +++ b/scripts/commands/smokebomb.py @@ -6,14 +6,23 @@ def setup(): def run(core, actor, target, commandString): command = 'SmokeBomb1' - effect = 'entertainer_smoke_bomb_level_1.cef' + effect = 'clienteffect/entertainer_smoke_bomb_level_1.cef' + rLevel = 50 # minimum level to perform this effect - if actor.getLevel() < 50: + if commandString == '2': + command = 'SmokeBomb2' + effect = 'clienteffect/entertainer_smoke_bomb_level_2.cef' + rLevel = 75 + + elif commandString == '3': + command = 'SmokeBomb3' + effect = 'clienteffect/entertainer_smoke_bomb_level_3.cef' + rLevel = 90 + + if actor.getLevel() < rLevel: actor.sendSystemMessage('@performance:effect_lack_skill_self') return - # TODO: Find out levels for other smoke bomb 2 and 3 - if core.entertainmentService.performEffect(actor, command, effect, target) is True: actor.sendSystemMessage('@performance:effect_perform_smoke_bomb', 0) return \ No newline at end of file diff --git a/scripts/commands/spotlight.py b/scripts/commands/spotlight.py index 25341536..1f94394a 100644 --- a/scripts/commands/spotlight.py +++ b/scripts/commands/spotlight.py @@ -8,17 +8,22 @@ def run(core, actor, target, commandString): command = 'SpotLight1' effect = 'clienteffect/entertainer_spot_light_level_1.cef' + rLevel = 1 # minimum level to perform this effect - # TODO: Figure out what levels the spotlight effects upgraded at. - - if actor.getLevel() >= 80: - command == 'SpotLight3' - effect = 'clienteffect/entertainer_spot_light_level_3.cef' - - elif actor.getLevel() >= 40: - command == 'SpotLight2' + if commandString == '2': + command = 'SpotLight2' effect = 'clienteffect/entertainer_spot_light_level_2.cef' - + rLevel = 20 + + elif commandString == '3': + command = 'SpotLight3' + effect = 'clienteffect/entertainer_spot_light_level_3.cef' + rLevel = 30 + + if actor.getLevel() < rLevel: + actor.sendSystemMessage('@performance:effect_lack_skill_self') + return + if core.entertainmentService.performEffect(actor, command, effect, None) is True: actor.sendSystemMessage('@performance:effect_perform_spot_light', 0) return diff --git a/scripts/commands/ventriloquism.py b/scripts/commands/ventriloquism.py index 198516f4..34d941e9 100644 --- a/scripts/commands/ventriloquism.py +++ b/scripts/commands/ventriloquism.py @@ -6,14 +6,23 @@ def setup(): def run(core, actor, target, commandString): command = 'Ventriloquism1' - effect = 'entertainer_ventriloquism_level_1.cef' + effect = 'clienteffect/entertainer_ventriloquism_level_1.cef' + rLevel = 58 # minimum level to perform this effect - if actor.getLevel() < 58: + if commandString == '2': + command = 'Ventriloquism2' + effect = 'clienteffect/entertainer_ventriloquism_level_2.cef' + rLevel = 75 + + elif commandString == '3': + command = 'Ventriloquism3' + effect = 'clienteffect/entertainer_ventriloquism_level_3.cef' + rLevel = 90 + + if actor.getLevel() < rLevel: actor.sendSystemMessage('@performance:effect_lack_skill_self') return - # TODO: Find out levels for other ventriloquism 2 and 3 - if core.entertainmentService.performEffect(actor, command, effect, target) is True: actor.sendSystemMessage('@performance:effect_perform_ventriloquism', 0) return \ No newline at end of file diff --git a/scripts/expertise/expertise_en_intense_performer_1.py b/scripts/expertise/expertise_en_intense_performer_1.py index cf9f9699..8925253a 100644 --- a/scripts/expertise/expertise_en_intense_performer_1.py +++ b/scripts/expertise/expertise_en_intense_performer_1.py @@ -11,8 +11,8 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_intense_performer_1') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) addAbilities(core, actor, player) - return def removeExpertisePoint(core, actor): @@ -26,9 +26,8 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_intense_performer_1') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) removeAbilities(core, actor, player) - return # this checks what abilities the player gets by level, need to also call this on level-up diff --git a/scripts/expertise/expertise_en_intense_performer_2.py b/scripts/expertise/expertise_en_intense_performer_2.py index 0582a021..f0327c0c 100644 --- a/scripts/expertise/expertise_en_intense_performer_2.py +++ b/scripts/expertise/expertise_en_intense_performer_2.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_intense_performer_2') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_intense_performer_2') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) removeAbilities(core, actor, player) return diff --git a/scripts/expertise/expertise_en_intense_performer_3.py b/scripts/expertise/expertise_en_intense_performer_3.py index 5ee49acf..ac3eb24a 100644 --- a/scripts/expertise/expertise_en_intense_performer_3.py +++ b/scripts/expertise/expertise_en_intense_performer_3.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_intense_performer_3') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_intense_performer_3') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) removeAbilities(core, actor, player) return diff --git a/scripts/expertise/expertise_en_intense_performer_4.py b/scripts/expertise/expertise_en_intense_performer_4.py index 29b5eb73..5e316992 100644 --- a/scripts/expertise/expertise_en_intense_performer_4.py +++ b/scripts/expertise/expertise_en_intense_performer_4.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_intense_performer_4') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_intense_performer_4') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) removeAbilities(core, actor, player) return diff --git a/scripts/expertise/expertise_en_lasting_impression_1.py b/scripts/expertise/expertise_en_lasting_impression_1.py index 960c9b75..1ce042fc 100644 --- a/scripts/expertise/expertise_en_lasting_impression_1.py +++ b/scripts/expertise/expertise_en_lasting_impression_1.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_lasting_impression_1') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_lasting_impression_1') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) removeAbilities(core, actor, player) return diff --git a/scripts/expertise/expertise_en_lasting_impression_2.py b/scripts/expertise/expertise_en_lasting_impression_2.py index 0ef56c25..5daf6031 100644 --- a/scripts/expertise/expertise_en_lasting_impression_2.py +++ b/scripts/expertise/expertise_en_lasting_impression_2.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_lasting_impression_2') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_lasting_impression_2') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) removeAbilities(core, actor, player) return diff --git a/scripts/expertise/expertise_en_lasting_impression_3.py b/scripts/expertise/expertise_en_lasting_impression_3.py index 74107ef2..8a4642bd 100644 --- a/scripts/expertise/expertise_en_lasting_impression_3.py +++ b/scripts/expertise/expertise_en_lasting_impression_3.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_lasting_impression_3') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_lasting_impression_3') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) removeAbilities(core, actor, player) return diff --git a/scripts/expertise/expertise_en_lasting_impression_4.py b/scripts/expertise/expertise_en_lasting_impression_4.py index b71d1b91..086a38c9 100644 --- a/scripts/expertise/expertise_en_lasting_impression_4.py +++ b/scripts/expertise/expertise_en_lasting_impression_4.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_lasting_impression_4') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_lasting_impression_4') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) removeAbilities(core, actor, player) return diff --git a/scripts/radial/player.py b/scripts/radial/player.py index 3ca2cc75..4b6d74bd 100644 --- a/scripts/radial/player.py +++ b/scripts/radial/player.py @@ -5,9 +5,9 @@ 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')) + radials.add(RadialOptions(0, 140, 3, 'Watch')) else: - radials.add(RadialOptions(0, 140, 1, 'Listen')) + radials.add(RadialOptions(0, 140, 3, 'Listen')) return diff --git a/src/protocol/swg/objectControllerObjects/ShowFlyText.java b/src/protocol/swg/objectControllerObjects/ShowFlyText.java index 41325368..f47bbbb2 100644 --- a/src/protocol/swg/objectControllerObjects/ShowFlyText.java +++ b/src/protocol/swg/objectControllerObjects/ShowFlyText.java @@ -27,6 +27,7 @@ import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.ObjControllerMessage; import resources.common.RGB; +import resources.common.StringUtilities; public class ShowFlyText extends ObjControllerObject { @@ -70,6 +71,7 @@ public class ShowFlyText extends ObjControllerObject { this.scale = scale; this.color = color; this.alternativeStructure = true; + this.displayType = displayType; } @Override @@ -117,13 +119,16 @@ public class ShowFlyText extends ObjControllerObject { result.putLong(0); result.putLong(0); result.putLong(0); - result.put(getUnicodeString(customText)); - result.putShort(xp); + result.put(getUnicodeString(customText)); // %TO? + result.putShort(xp); // %DI ? result.putLong(0); result.putFloat(scale); result.put(color.getBytes()); result.putInt(displayType); - return result.flip(); + + result.flip(); + //StringUtilities.printBytes(result.array()); + return result; } } diff --git a/src/resources/common/MathUtilities.java b/src/resources/common/MathUtilities.java index 8cf73cc0..8decf30b 100644 --- a/src/resources/common/MathUtilities.java +++ b/src/resources/common/MathUtilities.java @@ -21,6 +21,8 @@ ******************************************************************************/ package resources.common; +import java.math.BigDecimal; + import engine.resources.scene.*; public class MathUtilities { @@ -43,5 +45,27 @@ public class MathUtilities { q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x); } + + /** + * Converts seconds to a whole hour. + * @author Waverunner + * @param seconds + * @return hour(s) + */ + public static int secondsToWholeHours(int seconds) { + BigDecimal dec = new BigDecimal(seconds); + return dec.divide(new BigDecimal(3600), BigDecimal.ROUND_FLOOR).intValue(); + } + + /** + * Converts seconds to minutes of the hour. + * @author Waverunner + * @param seconds + * @return hour(s) + */ + public static int secondsToHourMinutes(int seconds) { + BigDecimal dec = new BigDecimal(seconds); + return dec.remainder(new BigDecimal(3600)).divide(new BigDecimal(60), BigDecimal.ROUND_FLOOR).intValue(); + } } diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 46d13369..012324e9 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -435,11 +435,15 @@ public class CreatureObject extends TangibleObject implements IPersistent { } public ScheduledFuture getInspirationTick() { - return inspirationTick; + synchronized(objectMutex) { + return inspirationTick; + } } public void setInspirationTick(ScheduledFuture inspirationTick) { - this.inspirationTick = inspirationTick; + synchronized(objectMutex) { + this.inspirationTick = inspirationTick; + } } @Override @@ -570,6 +574,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { public void addSkillMod(String name, int base) { if(getSkillMod(name) == null) { + // TODO: This will need to be fixed as it doesn't update in the character sheet properly (wrong delta) SkillMod skillMod = new SkillMod(); skillMod.setBase(base); skillMod.setSkillModString(name); diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 587daa91..edadfaf2 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -321,6 +321,18 @@ public class TangibleObject extends SWGObject { } } + public void showFlyText(String stfFile, String stfString, String customText, int xp, float scale, RGB color, int displayType, int unkInt) { + Set observers = getObservers(); + + if (getClient() != null) { + getClient().getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(getObjectID(), getObjectID(), unkInt, 1, 1, -1, stfFile, stfString, customText, xp, scale, color, displayType))).serialize()); + } + + for (Client client : observers) { + client.getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(client.getParent().getObjectID(), getObjectID(), unkInt, 1, 1, -1, stfFile, stfString, customText, xp, scale, color, displayType))).serialize()); + } + } + public void playEffectObject(String effectFile, String commandString) { notifyObservers(new PlayClientEffectObjectMessage(effectFile, getObjectID(), commandString), true); } diff --git a/src/services/ConnectionService.java b/src/services/ConnectionService.java index c0d5405e..9791848a 100644 --- a/src/services/ConnectionService.java +++ b/src/services/ConnectionService.java @@ -195,6 +195,20 @@ public class ConnectionService implements INetworkDispatch { object.setInviteCounter(0); object.setInviteSenderId(0); object.setInviteSenderName(""); + + if(object.getAttachment("inspireDuration") != null) + object.setAttachment("inspireDuration", null); + + if(object.getInspirationTick() != null) { + object.getInspirationTick().cancel(true); + object.setInspirationTick(null); + } + + if(object.getSpectatorTask() != null) { + object.getSpectatorTask().cancel(true); + object.setSpectatorTask(null); + } + core.groupService.handleGroupDisband(object); for (CreatureObject opponent : object.getDuelList()) { diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index b45b0c8d..bc93d2cc 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -24,13 +24,16 @@ import protocol.swg.objectControllerObjects.BuffBuilderEndMessage; import protocol.swg.objectControllerObjects.BuffBuilderStartMessage; import resources.common.BuffBuilder; import resources.common.Console; +import resources.common.MathUtilities; import resources.common.ObjControllerOpcodes; import resources.common.Performance; import resources.common.PerformanceEffect; +import resources.common.RGB; import resources.common.StringUtilities; import resources.datatables.Posture; import resources.objects.Buff; import resources.objects.BuffItem; +import resources.objects.SWGList; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; @@ -38,6 +41,7 @@ import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; import engine.clients.Client; import engine.resources.objects.SWGObject; +import engine.resources.objects.SkillMod; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -70,7 +74,7 @@ public class EntertainmentService implements INetworkDispatch { public void handlePacket(IoSession session, IoBuffer data) throws Exception { data.order(ByteOrder.LITTLE_ENDIAN); - StringUtilities.printBytes(data.array()); + Client client = core.getClient(session); if(client == null) @@ -145,8 +149,8 @@ public class EntertainmentService implements INetworkDispatch { Vector statBuffs = sentPacket.getStatBuffs(); - SWGObject buffer = core.objectService.getObject(sentPacket.getBufferId()); - SWGObject buffRecipient = core.objectService.getObject(sentPacket.getBuffRecipientId()); + CreatureObject buffer = (CreatureObject) core.objectService.getObject(sentPacket.getBufferId()); + CreatureObject buffRecipient = (CreatureObject) core.objectService.getObject(sentPacket.getBuffRecipientId()); if (buffer != buffRecipient) { @@ -354,7 +358,7 @@ public class EntertainmentService implements INetworkDispatch { core.commandService.registerCommand("ventriloquism"); } - public void giveInspirationBuff(SWGObject reciever, Vector buffVector) { + public void giveInspirationBuff(CreatureObject reciever, Vector buffVector) { CreatureObject buffCreature = (CreatureObject) reciever; Vector availableStats = buffBuilderSkills; @@ -372,19 +376,13 @@ public class EntertainmentService implements INetworkDispatch { BuffItem stat = new BuffItem(builder.getStatAffects(), item.getInvested(), item.getEntertainerBonus()); stat.setAffectAmount(affectTotal); - - /*System.out.println("Invested Points: " + item.getInvested()); - System.out.println("Entertainer Bonus: " + item.getEntertainerBonus()); - System.out.println("Affect Total: " + affectTotal);*/ stats.add(stat); - - break; } } } - reciever.setAttachment("buffWorkshop", buffVector); + reciever.setAttachment("buffWorkshop", stats); core.buffService.addBuffToCreature(buffCreature, "buildabuff_inspiration"); @@ -481,6 +479,7 @@ public class EntertainmentService implements INetworkDispatch { } public void startSpectating(final CreatureObject spectator, final CreatureObject performer) { + final ScheduledFuture spectatorTask = scheduler.scheduleAtFixedRate(new Runnable() { @Override @@ -499,14 +498,20 @@ public class EntertainmentService implements INetworkDispatch { } spectator.setMoodAnimation("neutral"); performer.removeAudience(spectator); - - spectator.getSpectatorTask().cancel(true); + + if (spectator.getInspirationTick().cancel(true)) + spectator.getSpectatorTask().cancel(true); } } }, 2, 2, TimeUnit.SECONDS); spectator.setSpectatorTask(spectatorTask); + + if(((PlayerObject)performer.getSlottedObject("ghost")).getProfession().equals("entertainer_1a")) { + handleInspirationTicks(spectator, performer); + } + } public void performFlourish(final CreatureObject performer, int flourish) { @@ -547,8 +552,6 @@ public class EntertainmentService implements INetworkDispatch { String performance = (performer.getPerformanceType()) ? "dance" : "music"; - // TODO: Skill Level check - if(performer.isPerformingEffect()) { performer.sendSystemMessage("@performance:effect_wait_self", (byte) 0); return false; @@ -591,6 +594,48 @@ public class EntertainmentService implements INetworkDispatch { return true; } + public void handleInspirationTicks(final CreatureObject spectator, final CreatureObject performer) { + // http://youtu.be/WqyAde-oC7o?t=11m14s << Player watching entertainer (Has ring only, no pet, + 15 min ticks) + // TODO: Camp/Cantina checks for expertise and duration bonus %. Right now only using basic values. + final ScheduledFuture inspirationTick = scheduler.scheduleAtFixedRate(new Runnable() { + + @Override + public void run() { + int time = 0; // current buff duration time (minutes) + int buffCap = 215; // 5 hours 35 minutes - 2 hours (buff duration increase bonus) << Taken from video, doesn't account for performance bonuses etc. + + if (spectator.getAttachment("inspireDuration") != null) + time+= (int) spectator.getAttachment("inspireDuration"); + + if (performer.getSkillMod("expertise_en_inspire_buff_duration_increase") != null) { + SkillMod durationMod = performer.getSkillMod("expertise_en_inspire_buff_duration_increase"); + buffCap += durationMod.getBase() + durationMod.getModifier(); + } + + if (time == buffCap) { + + } else { + int entTick = 10; + if (performer.getSkillMod("expertise_en_inspire_pulse_duration_increase") != null) { + SkillMod pulseMod = performer.getSkillMod("expertise_en_inspire_pulse_duration_increase"); + entTick += pulseMod.getBase() + pulseMod.getModifier(); + } + + int duration = (time + entTick); // minutes + int hMinutes = MathUtilities.secondsToHourMinutes(duration * 60); + int hours = MathUtilities.secondsToWholeHours(duration * 60); + + spectator.showFlyText("spam", "buff_duration_tick_observer", String.valueOf(hours) + " hours , " + hMinutes + " minutes ", 0, (float) 0.66, new RGB(255, 182, 193), 3, 78); + + spectator.setAttachment("inspireDuration", duration); + //System.out.println("Inspire Duration: " + spectator.getAttachment("inspireDuration") + " on " + spectator.getCustomName()); + } + } + + }, 10, 10, TimeUnit.SECONDS); + spectator.setInspirationTick(inspirationTick); + } + @Override public void shutdown() {