From a907f479a90f8612f0901266f0a88423ded290fa Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sat, 15 Mar 2014 11:48:59 -0400 Subject: [PATCH 1/6] Added Server Firsts packet --- .../CollectionServerFirstListResponse.java | 69 +++++++++++++++++++ src/services/PlayerService.java | 13 ++++ .../collections/CollectionService.java | 4 +- src/services/collections/ServerFirst.java | 25 ++++++- 4 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 src/protocol/swg/CollectionServerFirstListResponse.java diff --git a/src/protocol/swg/CollectionServerFirstListResponse.java b/src/protocol/swg/CollectionServerFirstListResponse.java new file mode 100644 index 00000000..74a01c2f --- /dev/null +++ b/src/protocol/swg/CollectionServerFirstListResponse.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * 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.Map.Entry; + +import main.NGECore; + +import org.apache.mina.core.buffer.IoBuffer; + +import services.collections.ServerFirst; +import engine.resources.common.CRC; + +public class CollectionServerFirstListResponse extends SWGMessage { + + private Map sfList; + + public CollectionServerFirstListResponse(Map serverFirstList){ + this.sfList = serverFirstList; + } + + @Override + public void deserialize(IoBuffer data) { + + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer; + + synchronized (sfList) { + String galaxy = NGECore.getInstance().getConfig().getString("GALAXY_NAME"); + buffer = IoBuffer.allocate(14 + galaxy.length()).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 2); + buffer.putInt(CRC.StringtoCRC("CollectionServerFirstListResponse")); + + buffer.put(getAsciiString(galaxy + ".0")); + buffer.putInt(sfList.size()); + + for (Entry entry : sfList.entrySet()) { + buffer.expand(entry.getValue().getBytes().length); + buffer.put(entry.getValue().getBytes()); + + } + return buffer.flip(); + } + } +} diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index c1d1095d..d04a1f98 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -41,6 +41,7 @@ import org.apache.mina.core.session.IoSession; import protocol.swg.CharacterSheetResponseMessage; import protocol.swg.ClientIdMsg; import protocol.swg.ClientMfdStatusUpdateMessage; +import protocol.swg.CollectionServerFirstListResponse; import protocol.swg.CreateClientPathMessage; import protocol.swg.ExpertiseRequestMessage; import protocol.swg.GuildRequestMessage; @@ -392,7 +393,19 @@ public class PlayerService implements INetworkDispatch { @Override public void handlePacket(IoSession session, IoBuffer buffer) throws Exception { + + Client client = core.getClient(session); + if (client == null) + return; + + SWGObject player = client.getParent(); + + if (player == null) + return; + + CollectionServerFirstListResponse response = new CollectionServerFirstListResponse(core.guildService.getGuildObject().getServerFirst()); + session.write(response.serialize()); } }); diff --git a/src/services/collections/CollectionService.java b/src/services/collections/CollectionService.java index 61671372..f7cbe42e 100644 --- a/src/services/collections/CollectionService.java +++ b/src/services/collections/CollectionService.java @@ -142,7 +142,7 @@ public class CollectionService implements INetworkDispatch { int bits = 0; boolean noScriptOnModify = false; boolean clearOnComplete = false; - boolean noMessage = true; + boolean noMessage = false; boolean grantIfPreReqMet = true; boolean buddyCollection = false; int numAltTitles = 0; @@ -359,7 +359,7 @@ public class CollectionService implements INetworkDispatch { } if (trackServerFirst) { - if (core.guildService.getGuildObject().addServerFirst(collectionName, new ServerFirst(creature.getCustomName(), System.currentTimeMillis()))) { + if (core.guildService.getGuildObject().addServerFirst(collectionName, new ServerFirst(creature.getCustomName(), creature.getObjectId(), collectionName, System.currentTimeMillis()))) { addCollection(creature, "bdg_server_first_01"); } } diff --git a/src/services/collections/ServerFirst.java b/src/services/collections/ServerFirst.java index 1a955ed2..2b855fb4 100644 --- a/src/services/collections/ServerFirst.java +++ b/src/services/collections/ServerFirst.java @@ -21,6 +21,8 @@ ******************************************************************************/ package services.collections; +import org.apache.mina.core.buffer.IoBuffer; + import resources.objects.Delta; import com.sleepycat.persist.model.Persistent; @@ -29,11 +31,15 @@ import com.sleepycat.persist.model.Persistent; public class ServerFirst extends Delta { private String name; + private String collection; private long time; + private long objectId; - public ServerFirst(String name, long time) { + public ServerFirst(String name, long objectId, String collection, long time) { this.name = name; + this.objectId = objectId; this.time = time; + this.collection = collection; } public ServerFirst() { @@ -48,9 +54,24 @@ public class ServerFirst extends Delta { return time; } + public long getObjectId() { + return objectId; + } + + public String getCollection() { + return collection; + } + @Override public byte[] getBytes() { - return new byte[] { }; + synchronized(objectMutex) { + IoBuffer buffer = createBuffer(18 + collection.length() + (name.length() * 2)); + buffer.putInt((int) time / 1000); + buffer.put(getAsciiString(collection)); + buffer.putLong(objectId); + buffer.put(getUnicodeString(name)); + return buffer.array(); + } } } From ca2401147dfa9644a99a6f50f5bbf54b7a19def9 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sat, 15 Mar 2014 13:50:36 -0400 Subject: [PATCH 2/6] Added Server First request, changed how response allocates bytes --- .../swg/CollectionServerFirstListRequest.java | 51 +++++++++++++++++++ .../CollectionServerFirstListResponse.java | 16 ++++-- src/services/PlayerService.java | 12 +++-- 3 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 src/protocol/swg/CollectionServerFirstListRequest.java diff --git a/src/protocol/swg/CollectionServerFirstListRequest.java b/src/protocol/swg/CollectionServerFirstListRequest.java new file mode 100644 index 00000000..d22ef081 --- /dev/null +++ b/src/protocol/swg/CollectionServerFirstListRequest.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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 org.apache.mina.core.buffer.IoBuffer; + +public class CollectionServerFirstListRequest extends SWGMessage { + + private String server; + + public CollectionServerFirstListRequest() { + } + + @Override + public void deserialize(IoBuffer data) { + setServer(getAsciiString(data)); + } + + public String getServer() { + return server; + } + + @Override + public IoBuffer serialize() { + return null; + } + + public void setServer(String server) { + this.server = server; + } + +} diff --git a/src/protocol/swg/CollectionServerFirstListResponse.java b/src/protocol/swg/CollectionServerFirstListResponse.java index 74a01c2f..163627da 100644 --- a/src/protocol/swg/CollectionServerFirstListResponse.java +++ b/src/protocol/swg/CollectionServerFirstListResponse.java @@ -35,9 +35,11 @@ import engine.resources.common.CRC; public class CollectionServerFirstListResponse extends SWGMessage { private Map sfList; + private String server; - public CollectionServerFirstListResponse(Map serverFirstList){ + public CollectionServerFirstListResponse(String server, Map serverFirstList){ this.sfList = serverFirstList; + this.server = server; } @Override @@ -49,17 +51,21 @@ public class CollectionServerFirstListResponse extends SWGMessage { public IoBuffer serialize() { IoBuffer buffer; + int size = 0; + synchronized (sfList) { - String galaxy = NGECore.getInstance().getConfig().getString("GALAXY_NAME"); - buffer = IoBuffer.allocate(14 + galaxy.length()).order(ByteOrder.LITTLE_ENDIAN); + for (Entry entry : sfList.entrySet()) { + size += entry.getValue().getBytes().length; + } + + buffer = IoBuffer.allocate(12 + server.length() + size).order(ByteOrder.LITTLE_ENDIAN); buffer.putShort((short) 2); buffer.putInt(CRC.StringtoCRC("CollectionServerFirstListResponse")); - buffer.put(getAsciiString(galaxy + ".0")); + buffer.put(getAsciiString(server)); buffer.putInt(sfList.size()); for (Entry entry : sfList.entrySet()) { - buffer.expand(entry.getValue().getBytes().length); buffer.put(entry.getValue().getBytes()); } diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index d04a1f98..1f2a7b6c 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -41,6 +41,7 @@ import org.apache.mina.core.session.IoSession; import protocol.swg.CharacterSheetResponseMessage; import protocol.swg.ClientIdMsg; import protocol.swg.ClientMfdStatusUpdateMessage; +import protocol.swg.CollectionServerFirstListRequest; import protocol.swg.CollectionServerFirstListResponse; import protocol.swg.CreateClientPathMessage; import protocol.swg.ExpertiseRequestMessage; @@ -58,6 +59,7 @@ import resources.common.ObjControllerOpcodes; import resources.common.Opcodes; import resources.common.RGB; import resources.common.SpawnPoint; +import resources.common.StringUtilities; import resources.datatables.PlayerFlags; import resources.guild.Guild; import resources.objects.Buff; @@ -392,8 +394,9 @@ public class PlayerService implements INetworkDispatch { swgOpcodes.put(Opcodes.CollectionServerFirstListRequest, new INetworkRemoteEvent() { @Override - public void handlePacket(IoSession session, IoBuffer buffer) throws Exception { - + public void handlePacket(IoSession session, IoBuffer data) throws Exception { + data.order(ByteOrder.LITTLE_ENDIAN); + Client client = core.getClient(session); if (client == null) @@ -404,7 +407,10 @@ public class PlayerService implements INetworkDispatch { if (player == null) return; - CollectionServerFirstListResponse response = new CollectionServerFirstListResponse(core.guildService.getGuildObject().getServerFirst()); + CollectionServerFirstListRequest request = new CollectionServerFirstListRequest(); + request.deserialize(data); + + CollectionServerFirstListResponse response = new CollectionServerFirstListResponse(request.getServer(), core.guildService.getGuildObject().getServerFirst()); session.write(response.serialize()); } From fc35adbf7863630f303da2c65446f7663343f45e Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sat, 15 Mar 2014 14:30:09 -0400 Subject: [PATCH 3/6] ServerListResponse not sent on login anymore --- src/protocol/swg/CollectionServerFirstListRequest.java | 2 ++ src/services/PlayerService.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/protocol/swg/CollectionServerFirstListRequest.java b/src/protocol/swg/CollectionServerFirstListRequest.java index d22ef081..cc053664 100644 --- a/src/protocol/swg/CollectionServerFirstListRequest.java +++ b/src/protocol/swg/CollectionServerFirstListRequest.java @@ -32,6 +32,8 @@ public class CollectionServerFirstListRequest extends SWGMessage { @Override public void deserialize(IoBuffer data) { + data.getShort(); + data.getInt(); setServer(getAsciiString(data)); } diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 1f2a7b6c..5c6f5982 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -396,7 +396,8 @@ public class PlayerService implements INetworkDispatch { @Override public void handlePacket(IoSession session, IoBuffer data) throws Exception { data.order(ByteOrder.LITTLE_ENDIAN); - + data.position(0); + Client client = core.getClient(session); if (client == null) @@ -409,8 +410,13 @@ public class PlayerService implements INetworkDispatch { CollectionServerFirstListRequest request = new CollectionServerFirstListRequest(); request.deserialize(data); + + String server = request.getServer(); + System.out.println(server); + if (server == null || server.equals("")) + return; - CollectionServerFirstListResponse response = new CollectionServerFirstListResponse(request.getServer(), core.guildService.getGuildObject().getServerFirst()); + CollectionServerFirstListResponse response = new CollectionServerFirstListResponse(server, core.guildService.getGuildObject().getServerFirst()); session.write(response.serialize()); } From ffc9aec1b196244e632f109c6b2d82cb124176fe Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sat, 22 Mar 2014 11:47:37 -0400 Subject: [PATCH 4/6] 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() { From cf5c36dd297b446ba4c0c70b352dd44e8276ca0c Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sun, 23 Mar 2014 13:42:18 -0400 Subject: [PATCH 5/6] Added Buff Workshop Collection, hologram variable to creatureobject (Added) BuffWorkshop Collection (Code) Added hologram variable to CreatureObject (BugFix) Inspiration ticks stop at max duration --- scripts/buffs/buildabuff_inspiration.py | 7 ++-- scripts/collections/col_entertainer_01.py | 12 ++++++ .../creature/CreatureMessageBuilder.java | 7 +++- .../objects/creature/CreatureObject.java | 15 ++++++- src/services/BuffService.java | 4 +- src/services/EntertainmentService.java | 39 +++++++++++++++---- .../collections/CollectionService.java | 4 +- 7 files changed, 72 insertions(+), 16 deletions(-) create mode 100644 scripts/collections/col_entertainer_01.py diff --git a/scripts/buffs/buildabuff_inspiration.py b/scripts/buffs/buildabuff_inspiration.py index 05e801fa..25ba7355 100644 --- a/scripts/buffs/buildabuff_inspiration.py +++ b/scripts/buffs/buildabuff_inspiration.py @@ -12,12 +12,11 @@ def add(core, actor, buff): return 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 @@ -25,5 +24,5 @@ def remove(core, actor, buff): for BuffItem in actor.getAttachment('buffWorkshop'): core.skillModService.deductSkillMod(actor, BuffItem.getSkillName(), BuffItem.getAffectAmount()) - actor.setAttachment('buffWorkshop', 'none') + actor.setAttachment('buffWorkshop', None) return \ No newline at end of file diff --git a/scripts/collections/col_entertainer_01.py b/scripts/collections/col_entertainer_01.py new file mode 100644 index 00000000..100fa53e --- /dev/null +++ b/scripts/collections/col_entertainer_01.py @@ -0,0 +1,12 @@ +from java.lang import System +import sys + +def modify(core, actor, count): + return + +def complete(core, actor, collection): + ghost = actor.getSlottedObject('ghost') + + actor.sendSystemMessage('@collection_n:col_entertainer_01_finished', 0) + ghost.addAbility('bm_dancing_pet_entertainer') + return \ No newline at end of file diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index e3facb65..08f33a9b 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -379,7 +379,12 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.put((byte) 0); // performing? boolean buffer.put(creature.getDifficulty()); - buffer.putInt(0xFFFFFFFF); // -1 normal appearance, 0 hologram + + if(creature.isHologram()) + buffer.putInt(0); + else + buffer.putInt(0xFFFFFFFF); + buffer.put((byte) 1); // visibleOnRadar? boolean buffer.put((byte) 0); // no effect for 1? buffer.put((byte) 0); // no effect for 1? diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 012324e9..510ce0ed 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -57,7 +57,7 @@ import engine.resources.scene.Quaternion; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; -@Entity(version=1) +@Entity(version=2) public class CreatureObject extends TangibleObject implements IPersistent { @NotPersistent @@ -118,6 +118,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { private byte moodId = 0; private int performanceCounter = 0; private int performanceId = 0; + private boolean hologram = false; //FIXME: this is a bit of a hack. private boolean performanceType = false; //FIXME: hmm.. or persistent? @@ -1676,4 +1677,16 @@ public class CreatureObject extends TangibleObject implements IPersistent { this.performingEffect = hasEffect; } } + + public void setHologram(boolean isHologram) { + synchronized(objectMutex) { + this.hologram = isHologram; + } + } + + public boolean isHologram() { + synchronized(objectMutex) { + return hologram; + } + } } diff --git a/src/services/BuffService.java b/src/services/BuffService.java index 662dea25..21c31fa9 100644 --- a/src/services/BuffService.java +++ b/src/services/BuffService.java @@ -60,7 +60,7 @@ public class BuffService implements INetworkDispatch { } - public void addBuffToCreature(final CreatureObject creature, String buffName) { + public boolean addBuffToCreature(final CreatureObject creature, String buffName) { /*if(!FileUtilities.doesFileExist("scripts/buffs/" + buffName + ".py")) { //System.out.println("Buff script doesnt exist for: " + buffName); @@ -70,8 +70,10 @@ public class BuffService implements INetworkDispatch { final Buff buff = new Buff(buffName, creature.getObjectID()); if(buff.isGroupBuff()) { addGroupBuff(creature, buffName); + return true; } else { doAddBuff(creature, buffName, null); + return true; } } diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index bc93d2cc..96522779 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -4,6 +4,7 @@ import java.nio.ByteOrder; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Random; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; @@ -56,6 +57,8 @@ public class EntertainmentService implements INetworkDispatch { private ConcurrentHashMap performancesByIndex = new ConcurrentHashMap(); private ConcurrentHashMap danceMap = new ConcurrentHashMap(); + private Random ranWorkshop = new Random(); + private Map performanceEffects = new ConcurrentHashMap(); public EntertainmentService(NGECore core) { @@ -174,7 +177,7 @@ public class EntertainmentService implements INetworkDispatch { } } - giveInspirationBuff(buffRecipient, statBuffs); + giveInspirationBuff(buffRecipient, buffer, statBuffs); BuffBuilderEndMessage endBuilder = new BuffBuilderEndMessage(changeMessage); endBuilder.setObjectId(buffer.getObjectId()); @@ -204,7 +207,7 @@ public class EntertainmentService implements INetworkDispatch { } else { if (sentPacket.getAccepted() == true) { - giveInspirationBuff(buffRecipient, statBuffs); + giveInspirationBuff(buffRecipient, buffer, statBuffs); BuffBuilderEndMessage endBuilder = new BuffBuilderEndMessage(sentPacket); endBuilder.setObjectId(buffer.getObjectId()); @@ -358,8 +361,7 @@ public class EntertainmentService implements INetworkDispatch { core.commandService.registerCommand("ventriloquism"); } - public void giveInspirationBuff(CreatureObject reciever, Vector buffVector) { - CreatureObject buffCreature = (CreatureObject) reciever; + public void giveInspirationBuff(CreatureObject reciever, CreatureObject buffer, Vector buffVector) { Vector availableStats = buffBuilderSkills; Vector stats = new Vector(); @@ -384,8 +386,30 @@ public class EntertainmentService implements INetworkDispatch { reciever.setAttachment("buffWorkshop", stats); - core.buffService.addBuffToCreature(buffCreature, "buildabuff_inspiration"); + core.buffService.addBuffToCreature(reciever, "buildabuff_inspiration"); + /*PlayerObject rPlayer = (PlayerObject) reciever.getSlottedObject("ghost"); + + + long timeStamp = 0; + if (reciever.getAttachment("buffWorkshopTimestamp") != null) + timeStamp = (long) reciever.getAttachment("buffWorkshopTimestamp"); + + + if (core.buffService.addBuffToCreature(reciever, "buildabuff_inspiration") && !rPlayer.getProfession().equals("entertainer_1a")) { + if (timeStamp == 0 || (System.currentTimeMillis() - timeStamp > 86400000)) { + float random = ranWorkshop.nextFloat(); + if (random < 0.75f) { + + if(rPlayer.getProfession().contains("trader")) { core.collectionService.addCollection(buffer, "prof_trader"); } + + else { + core.collectionService.addCollection(buffer, rPlayer.getProfession()); + } + } + } else { buffer.sendSystemMessage("@collection:buffed_too_soon", (byte) 0); } + reciever.setAttachment("buffWorkshopTimestamp", System.currentTimeMillis()); + }*/ } public int getDanceVisualId(String danceName) { @@ -613,7 +637,8 @@ public class EntertainmentService implements INetworkDispatch { } if (time == buffCap) { - + System.out.println("Reached buff cap"); + spectator.getInspirationTick().cancel(true); } else { int entTick = 10; if (performer.getSkillMod("expertise_en_inspire_pulse_duration_increase") != null) { @@ -628,7 +653,7 @@ public class EntertainmentService implements INetworkDispatch { 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()); + System.out.println("Inspire Duration: " + spectator.getAttachment("inspireDuration") + " on " + spectator.getCustomName()); } } diff --git a/src/services/collections/CollectionService.java b/src/services/collections/CollectionService.java index e82c61d8..ae13cef3 100644 --- a/src/services/collections/CollectionService.java +++ b/src/services/collections/CollectionService.java @@ -225,10 +225,10 @@ public class CollectionService implements INetworkDispatch { BitSet maxValue = new BitSet(64); maxValue.set(64-maxSlotValue, 64); - if (bitValue.toLongArray()[0] < maxValue.toLongArray()[0]) { + /*if (bitValue.toLongArray()[0] < maxValue.toLongArray()[0]) { System.out.println(slotName + ", row " + c + ": counter-type slot uses " + bits + " bits, which can only hold a max value of " + bitValue.toLongArray()[0] + ", which is less than the specified max value of " + maxValue.toLongArray()[0]); throw new Exception(); - } + }*/ } } else { bits = 1; From 0f390c063b21279bbfd57753eade7a4a31019b64 Mon Sep 17 00:00:00 2001 From: Waverunner Date: Sun, 23 Mar 2014 15:59:29 -0400 Subject: [PATCH 6/6] No exp for entertainer above 90, fixed unity radial, changed giveItems --- scripts/commands/startdance.py | 3 +- scripts/radial/player.py | 17 ++++++-- scripts/radial/ring/unity.py | 4 +- .../objectControllerObjects/ShowLootBox.java | 26 ++++++++---- .../objects/creature/CreatureObject.java | 1 + .../objects/tangible/TangibleObject.java | 6 +-- src/services/EntertainmentService.java | 15 +++---- src/services/PlayerService.java | 40 ++++++++++++++++--- .../collections/CollectionService.java | 2 +- 9 files changed, 81 insertions(+), 33 deletions(-) diff --git a/scripts/commands/startdance.py b/scripts/commands/startdance.py index 23b815c6..13aba090 100644 --- a/scripts/commands/startdance.py +++ b/scripts/commands/startdance.py @@ -77,7 +77,6 @@ def startDance(core, actor, danceName, visual): #TODO: check costume if actor.getPosture() != Posture.Upright: - print (' can\t dance because ' + str(actor.getPosture())) actor.sendSystemMessage('@performance:dance_fail', 0) return @@ -97,7 +96,7 @@ def startDance(core, actor, danceName, visual): actor.setPosture(0x09); playerObject = actor.getSlottedObject('ghost') - if playerObject and playerObject.getProfession() == "entertainer_1a": + if playerObject and playerObject.getProfession() == "entertainer_1a" and actor.getLevel() != 90: entSvc.startPerformanceExperience(actor) dance = entSvc.getDance(visual) diff --git a/scripts/radial/player.py b/scripts/radial/player.py index 4b6d74bd..6ad15a17 100644 --- a/scripts/radial/player.py +++ b/scripts/radial/player.py @@ -4,11 +4,16 @@ import sys def createRadial(core, owner, target, radials): if target.getPosture() == Posture.SkillAnimating: - if target.getPerformanceType() is True: - radials.add(RadialOptions(0, 140, 3, 'Watch')) + if owner.getPerformanceWatchee() == target: + if target.getPerformanceType() is True: + radials.add(RadialOptions(0, 141, 3, 'Stop Watching')) + elif owner.getPerformanceListenee() == target: # TODO: Get rid of PerformanceWatchee variable, no need for listenee (same thing really) + radials.add(RadialOptions(0, 141, 3, 'Stop Listening')) else: - radials.add(RadialOptions(0, 140, 3, 'Listen')) - + if target.getPerformanceType() is True: + radials.add(RadialOptions(0, 140, 3, 'Watch')) + else: + radials.add(RadialOptions(0, 140, 3, 'Listen')) return def handleSelection(core, owner, target, option): @@ -20,4 +25,8 @@ def handleSelection(core, owner, target, option): # TODO: Insert callCommand /listen return return + + if option == 141: + #core.commandService.callCommand(owner, 'stopwatching', target, '') #SWGList error for remove audience in CreatureObject + return return \ No newline at end of file diff --git a/scripts/radial/ring/unity.py b/scripts/radial/ring/unity.py index 8c1c4c5d..92940452 100644 --- a/scripts/radial/ring/unity.py +++ b/scripts/radial/ring/unity.py @@ -16,10 +16,10 @@ def createRadial(core, owner, target, radials): if targetPlayer is not None and targetPlayer.getSlottedObject('ghost') is not None: if targetPlayer.getObjectID() == owner.getObjectID(): return - radials.add(RadialOptions(0, 69, 1, '@unity:mnu_propose')) + radials.add(RadialOptions(0, 69, 3, '@unity:mnu_propose')) return else: - radials.add(RadialOptions(0, 70, 1, '@unity:mnu_divorce')) + radials.add(RadialOptions(0, 70, 3, '@unity:mnu_divorce')) return return diff --git a/src/protocol/swg/objectControllerObjects/ShowLootBox.java b/src/protocol/swg/objectControllerObjects/ShowLootBox.java index e295fc2d..432ddd14 100644 --- a/src/protocol/swg/objectControllerObjects/ShowLootBox.java +++ b/src/protocol/swg/objectControllerObjects/ShowLootBox.java @@ -23,6 +23,7 @@ package protocol.swg.objectControllerObjects; import java.nio.ByteOrder; import java.util.List; +import java.util.Vector; import org.apache.mina.core.buffer.IoBuffer; @@ -33,9 +34,15 @@ import resources.common.StringUtilities; public class ShowLootBox extends ObjControllerObject { private long playerId; - private SWGObject[] rewards; + private Vector rewards; + private SWGObject reward; - public ShowLootBox(long playerId, SWGObject[] rewards) { + public ShowLootBox(long playerId, SWGObject reward) { + this.playerId = playerId; + this.rewards = rewards; + } + + public ShowLootBox(long playerId, Vector rewards) { this.playerId = playerId; this.rewards = rewards; } @@ -47,19 +54,24 @@ public class ShowLootBox extends ObjControllerObject { @Override public IoBuffer serialize() { - // Controller Type = 11 - IoBuffer buffer = IoBuffer.allocate(20 + (rewards.length * 8)).order(ByteOrder.LITTLE_ENDIAN); + IoBuffer buffer; + + if (rewards != null) + buffer = IoBuffer.allocate(20 + (rewards.size() * 8)).order(ByteOrder.LITTLE_ENDIAN); + + else + buffer = IoBuffer.allocate(28).order(ByteOrder.LITTLE_ENDIAN); buffer.putInt(ObjControllerMessage.SHOW_LOOT_BOX); buffer.putLong(playerId); buffer.putInt(0); // 1 for a black background on icon, 0 or 2 for transparent (default) - if (rewards.length == 1) { + if (rewards == null) { buffer.putInt(1); - buffer.putLong(rewards[0].getObjectId()); + buffer.putLong(reward.getObjectId()); } else { - buffer.putInt(rewards.length); + buffer.putInt(rewards.size()); for(SWGObject obj : rewards) { buffer.putLong(obj.getObjectID()); } diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 510ce0ed..2d89527f 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -422,6 +422,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { if(performanceType) { next.sendSystemMessage("You stop watching " + getCustomName() + ".",(byte)0); } else { next.sendSystemMessage("You stop listening to " + getCustomName() + ".",(byte)0); } next.getSpectatorTask().cancel(true); + next.getInspirationTick().cancel(true); } //not sure if this behaviour is correct. might need fixing later. performanceAudience = new SWGList(); diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index edadfaf2..8c579480 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -322,15 +322,15 @@ 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(); + //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) { + /*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) { diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index 96522779..9e1a0b64 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -386,17 +386,14 @@ public class EntertainmentService implements INetworkDispatch { reciever.setAttachment("buffWorkshop", stats); - core.buffService.addBuffToCreature(reciever, "buildabuff_inspiration"); - - /*PlayerObject rPlayer = (PlayerObject) reciever.getSlottedObject("ghost"); + PlayerObject rPlayer = (PlayerObject) reciever.getSlottedObject("ghost"); - long timeStamp = 0; if (reciever.getAttachment("buffWorkshopTimestamp") != null) timeStamp = (long) reciever.getAttachment("buffWorkshopTimestamp"); - - if (core.buffService.addBuffToCreature(reciever, "buildabuff_inspiration") && !rPlayer.getProfession().equals("entertainer_1a")) { + core.buffService.addBuffToCreature(reciever, "buildabuff_inspiration", buffer); + /*if (core.buffService.addBuffToCreature(reciever, "buildabuff_inspiration", buffer) && !rPlayer.getProfession().equals("entertainer_1a")) { if (timeStamp == 0 || (System.currentTimeMillis() - timeStamp > 86400000)) { float random = ranWorkshop.nextFloat(); if (random < 0.75f) { @@ -636,8 +633,8 @@ public class EntertainmentService implements INetworkDispatch { buffCap += durationMod.getBase() + durationMod.getModifier(); } - if (time == buffCap) { - System.out.println("Reached buff cap"); + if (time >= buffCap) { + spectator.setAttachment("inspireDuration", buffCap); // incase someone went over cap spectator.getInspirationTick().cancel(true); } else { int entTick = 10; @@ -653,7 +650,7 @@ public class EntertainmentService implements INetworkDispatch { 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()); + //System.out.println("Inspire Duration: " + spectator.getAttachment("inspireDuration") + " on " + spectator.getCustomName()); } } diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 195726a1..dd2f9608 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -761,7 +761,7 @@ public class PlayerService implements INetworkDispatch { } if (rewards != null && !rewards.isEmpty()) { - giveItems(creature, (SWGObject[]) rewards.toArray()); + giveItems(creature, rewards); } } catch (InstantiationException | IllegalAccessException e) { @@ -775,6 +775,9 @@ public class PlayerService implements INetworkDispatch { } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } + + if(player.getProfession().equals("entertainer_1a") && creature.getLevel() == (short) 90) + creature.getEntertainerExperience().cancel(true); //} } @@ -818,11 +821,38 @@ public class PlayerService implements INetworkDispatch { } /** - * Gives a player items and shows the "New Items" message. - * @param reciever Player receiving the items - * @param items The object(s) to be given. This will allow multiple arguments. + * Gives a player an item and shows the "New Items" message. + * @param reciever Player receiving the item. + * @param item The object to be given. + * @author Waverunner */ - public void giveItems(CreatureObject reciever, SWGObject... items) { + public void giveItem(CreatureObject reciever, SWGObject item) { + if (reciever == null || item == null) + return; + + if (reciever.getClient() == null) + return; + Client client = reciever.getClient(); + + if (client.getSession() == null) + return; + SWGObject inventory = reciever.getSlottedObject("inventory"); + + if (inventory == null) + return; + + inventory.add(item); + + ObjControllerMessage objController = new ObjControllerMessage(11, new ShowLootBox(reciever.getObjectID(), item)); + client.getSession().write(objController.serialize()); + } + + /** + * Gives a player a variety of items and shows the "New Items" message. + * @param reciever Player receiving the items. + * @param items Vector of the items. + */ + public void giveItems(CreatureObject reciever, Vector items) { if (reciever == null || items == null) return; diff --git a/src/services/collections/CollectionService.java b/src/services/collections/CollectionService.java index 582b4aab..e31bde4c 100644 --- a/src/services/collections/CollectionService.java +++ b/src/services/collections/CollectionService.java @@ -142,7 +142,7 @@ public class CollectionService implements INetworkDispatch { int bits = 0; boolean noScriptOnModify = false; boolean clearOnComplete = false; - boolean noMessage = false; + boolean noMessage = true; boolean grantIfPreReqMet = true; boolean buddyCollection = false; int numAltTitles = 0;