diff --git a/ngengine_public.jar b/ngengine_public.jar index 901385d6..96682c15 100644 Binary files a/ngengine_public.jar and b/ngengine_public.jar differ diff --git a/scripts/buffs/fs_force_run.py b/scripts/buffs/fs_force_run.py index 714e8198..52fa68f4 100644 --- a/scripts/buffs/fs_force_run.py +++ b/scripts/buffs/fs_force_run.py @@ -5,8 +5,7 @@ def setup(core, actor, buff): return def add(core, actor, buff): - actor.playEffectObject('clienteffect/pl_force_run.cef', 'fs_force_run') - actor.playEffectObject('appearance/pt_force_speed.prt', 'fs_force_run') + actor.playEffectObject('clienteffect/pl_force_run.cef', '') actor.setSpeedMultiplierBase(actor.getSpeedMultiplierBase() + 2.5 + (2.5 * (actor.getSkillModBase('expertise_movement_buff_fs_force_run')) / 100)) core.skillModService.addSkillMod(actor, 'slope_move', 5) core.skillModService.addSkillMod(actor, 'movement_resist_snare', 100) diff --git a/scripts/buffs/invis_sp_buff_invis_1.py b/scripts/buffs/invis_sp_buff_invis_1.py new file mode 100644 index 00000000..9192dba7 --- /dev/null +++ b/scripts/buffs/invis_sp_buff_invis_1.py @@ -0,0 +1,26 @@ +import sys + +def setup(core, actor, buff): + return + +def add(core, actor, buff): + actor.playEffectObject('clienteffect/npe_smoke_bomb.cef', '') + actor.setInStealth(True) + actor.setRadarVisible(False) + + core.combatService.endCombat(actor) + + if actor.getSkillMod('expertise_sp_without_a_trace_1'): + core.buffService.addBuffToCreature(actor, 'invis_sp_buff_invis_notrace_1') + + return + +def remove(core, actor, buff): + actor.setInStealth(False) + actor.setRadarVisible(True) + + if actor.getSkillMod('expertise_sp_without_a_trace_1'): + core.buffService.removeBuffFromCreature(actor, 'invis_sp_buff_invis_notrace_1') + + return + diff --git a/scripts/buffs/invis_sp_buff_stealth_1.py b/scripts/buffs/invis_sp_buff_stealth_1.py new file mode 100644 index 00000000..1b30ee83 --- /dev/null +++ b/scripts/buffs/invis_sp_buff_stealth_1.py @@ -0,0 +1,14 @@ +import sys + +def setup(core, actor, buff): + return + +def add(core, actor, buff): + actor.setInStealth(True) + actor.setRadarVisible(False) + return + +def remove(core, actor, buff): + actor.setInStealth(False) + actor.setRadarVisible(True) + return diff --git a/scripts/buffs/of_stimulator_1.py b/scripts/buffs/of_stimulator_1.py index 4e120b7f..492e64d7 100644 --- a/scripts/buffs/of_stimulator_1.py +++ b/scripts/buffs/of_stimulator_1.py @@ -9,4 +9,5 @@ def add(core, actor, buff): def remove(core, actor, buff): core.skillModService.deductSkillMod(actor, 'debuff_purge', 2) + return \ No newline at end of file diff --git a/scripts/commands/combat/forcethrow.py b/scripts/commands/combat/forcethrow.py index 276deb65..0e529b99 100644 --- a/scripts/commands/combat/forcethrow.py +++ b/scripts/commands/combat/forcethrow.py @@ -1,7 +1,7 @@ import sys def setup(core, actor, target, command): - core.buffService.addBuffToCreature(target, 'fs_force_throw') + core.buffService.addBuffToCreature(target, 'fs_force_throw', actor) return def preRun(core, actor, target, command): diff --git a/scripts/commands/createvendor.py b/scripts/commands/createvendor.py new file mode 100644 index 00000000..d2e4a1cc --- /dev/null +++ b/scripts/commands/createvendor.py @@ -0,0 +1,169 @@ +import sys +from java.util import HashMap +from java.util import Vector +from services.sui.SUIService import ListBoxType +from services.sui.SUIService import InputBoxType +from main import NGECore +from java.lang import Long +from services.sui.SUIWindow import Trigger + +def setup(): + return + +def run(core, actor, target, commandString): + + if actor.getCombatFlag() > 0: + return + + cell = actor.getContainer() + building = actor.getGrandparent() + ghost = actor.getSlottedObject('ghost') + + if not ghost or not cell or not building or not core.housingService.getPermissions(actor, cell): + return + + if ghost.getAmountOfVendors() >= actor.getSkillModBase('manage_vendor'): + actor.sendSystemMessage('@player_structure:full_vendors', 0) + return + + suiOptions = HashMap() + suiOptions.put(Long(1), '@player_structure:terminal') + suiOptions.put(Long(2), '@player_structure:droid') + # TODO add creatures + window = core.suiService.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, '@player_structure:vendor_type_t', '@player_structure:vendor_type_d', suiOptions, actor, None, 5) + returnList = Vector() + returnList.add('List.lstList:SelectedRow') + window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, handleFirstWindow) + core.suiService.openSUIWindow(window) + return + +def handleFirstWindow(actor, window, eventType, returnList): + + core = NGECore.getInstance() + index = int(returnList.get(0)) + selected = window.getObjectIdByIndex(index) + hiring = actor.getSkillModBase('hiring') + if selected == 1: + suiOptions = HashMap() + if hiring >= 10: + suiOptions.put(Long(1), '@player_structure:terminal_bulky') + if hiring >= 30: + suiOptions.put(Long(2), '@player_structure:terminal_standard') + if hiring >= 50: + suiOptions.put(Long(3), '@player_structure:terminal_small') + if hiring >= 75: + suiOptions.put(Long(4), '@player_structure:terminal_fancy') + if hiring >= 90: + suiOptions.put(Long(5), '@player_structure:terminal_slim') + window = core.suiService.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, '@player_structure:terminal_type_t', '@player_structure:terminal_type_d', suiOptions, actor, None, 5) + returnList = Vector() + returnList.add('List.lstList:SelectedRow') + window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, handleTerminalWindow) + core.suiService.openSUIWindow(window) + + if selected == 2: + suiOptions = HashMap() + if hiring >= 20: + suiOptions.put(Long(1), '@player_structure:droid_bartender') + if hiring >= 50: + suiOptions.put(Long(2), '@player_structure:droid_power') + if hiring >= 60: + suiOptions.put(Long(3), '@player_structure:droid_wed') + if hiring >= 90: + suiOptions.put(Long(4), '@player_structure:droid_surgical') + if hiring >= 100: + suiOptions.put(Long(5), '@player_structure:droid_protocol') + window = core.suiService.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, '@player_structure:droid_type_t', '@player_structure:droid_type_d', suiOptions, actor, None, 5) + returnList = Vector() + returnList.add('List.lstList:SelectedRow') + window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, handleDroidWindow) + core.suiService.openSUIWindow(window) + + return + +def handleTerminalWindow(actor, window, eventType, returnList): + + core = NGECore.getInstance() + index = int(returnList.get(0)) + selected = window.getObjectIdByIndex(index) + + if selected == 1: + actor.setAttachment('selectedVendorTemplate', 'object/tangible/vendor/shared_vendor_terminal_bulky.iff') + elif selected == 2: + actor.setAttachment('selectedVendorTemplate', 'object/tangible/vendor/shared_vendor_terminal_standard.iff') + elif selected == 3: + actor.setAttachment('selectedVendorTemplate', 'object/tangible/vendor/shared_vendor_terminal_small.iff') + elif selected == 4: + actor.setAttachment('selectedVendorTemplate', 'object/tangible/vendor/shared_vendor_terminal_fancy.iff') + elif selected == 5: + actor.setAttachment('selectedVendorTemplate', 'object/tangible/vendor/shared_vendor_terminal_slim.iff') + + createNameVendorWindow(core, actor) + + return + +def handleDroidWindow(actor, window, eventType, returnList): + + core = NGECore.getInstance() + index = int(returnList.get(0)) + selected = window.getObjectIdByIndex(index) + + if selected == 1: + actor.setAttachment('selectedVendorTemplate', 'object/tangible/vendor/shared_vendor_droid_bartender.iff') + elif selected == 2: + actor.setAttachment('selectedVendorTemplate', 'object/tangible/vendor/shared_vendor_droid_power.iff') + elif selected == 3: + actor.setAttachment('selectedVendorTemplate', 'object/tangible/vendor/shared_vendor_droid_wed.iff') + elif selected == 4: + actor.setAttachment('selectedVendorTemplate', 'object/tangible/vendor/shared_vendor_droid_surgical.iff') + elif selected == 5: + actor.setAttachment('selectedVendorTemplate', 'object/tangible/vendor/shared_vendor_droid_protocol.iff') + + createNameVendorWindow(core, actor) + + return + +def createNameVendorWindow(core, actor): + + window = core.suiService.createInputBox(InputBoxType.INPUT_BOX_OK_CANCEL, '@player_structure:name_t', '@player_structure:name_d', actor, None, 5, handleVendorName) + core.suiService.openSUIWindow(window) + return + +def handleVendorName(actor, window, eventType, returnList): + + core = NGECore.getInstance() + name = returnList.get(0) + print name + inventory = actor.getSlottedObject('inventory') + ghost = actor.getSlottedObject('ghost') + + if not core.characterService.checkName(name, actor.getClient()): + actor.sendSystemMessage('@player_structure:obscene', 0) + createNameVendorWindow(core, actor) + return + + if not actor.getAttachment('selectedVendorTemplate') or not inventory or not ghost: + actor.sendSystemMessage('@player_structure:create_failed', 0) + return + + if actor.getInventoryItemCount() >= 80: + actor.sendSystemMessage('@player_structure:inventory_full_generic', 0) + return + + vendor = core.objectService.createObject(actor.getAttachment('selectedVendorTemplate'), actor.getPlanet()) + + if not vendor: + actor.sendSystemMessage('@player_structure:create_failed', 0) + return + + actor.setAttachment('selectedVendorTemplate', None) + vendor.setAttachment('isVendor', True) + vendor.setAttachment('vendorOwner', actor.getObjectID()) + vendor.setAttachment('initialized', False) + vendor.setAttachment('vendorSearchEnabled', False) + vendor.setCustomName('Vendor: ' + name) + ghost.addVendor(vendor.getObjectID()) + inventory.add(vendor) + actor.sendSystemMessage('@player_structure:create_success', 0) + return + \ No newline at end of file diff --git a/scripts/commands/en_sprint_1.py b/scripts/commands/en_sprint_1.py index 1393d38e..a24ef49d 100644 --- a/scripts/commands/en_sprint_1.py +++ b/scripts/commands/en_sprint_1.py @@ -4,5 +4,5 @@ def setup(): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'en_sprint') + core.buffService.addBuffToCreature(actor, 'en_sprint', actor) return \ No newline at end of file diff --git a/scripts/commands/forcerun.py b/scripts/commands/forcerun.py index df72153b..c4dabf79 100644 --- a/scripts/commands/forcerun.py +++ b/scripts/commands/forcerun.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'fs_force_run') + core.buffService.addBuffToCreature(actor, 'fs_force_run', actor) return \ No newline at end of file diff --git a/scripts/commands/fs_buff_ca_1.py b/scripts/commands/fs_buff_ca_1.py index 141b3158..2d12673e 100644 --- a/scripts/commands/fs_buff_ca_1.py +++ b/scripts/commands/fs_buff_ca_1.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'fs_buff_ca_1') + core.buffService.addBuffToCreature(actor, 'fs_buff_ca_1', actor) return \ No newline at end of file diff --git a/scripts/commands/fs_buff_def_1_1.py b/scripts/commands/fs_buff_def_1_1.py index cd9637f1..0125c187 100644 --- a/scripts/commands/fs_buff_def_1_1.py +++ b/scripts/commands/fs_buff_def_1_1.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'fs_buff_def_1_1') + core.buffService.addBuffToCreature(actor, 'fs_buff_def_1_1', actor) return \ No newline at end of file diff --git a/scripts/commands/fs_buff_invis_1.py b/scripts/commands/fs_buff_invis_1.py index 57ed4a59..965d034c 100644 --- a/scripts/commands/fs_buff_invis_1.py +++ b/scripts/commands/fs_buff_invis_1.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'invis_fs_buff_invis_1') + core.buffService.addBuffToCreature(actor, 'invis_fs_buff_invis_1', actor) return \ No newline at end of file diff --git a/scripts/commands/fs_saber_reflect_buff.py b/scripts/commands/fs_saber_reflect_buff.py index 898e2530..29f49243 100644 --- a/scripts/commands/fs_saber_reflect_buff.py +++ b/scripts/commands/fs_saber_reflect_buff.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'fs_saber_reflect') + core.buffService.addBuffToCreature(actor, 'fs_saber_reflect', actor) return \ No newline at end of file diff --git a/scripts/commands/me_cure_affliction_1.py b/scripts/commands/me_cure_affliction_1.py index 1e9189f1..c03b5879 100644 --- a/scripts/commands/me_cure_affliction_1.py +++ b/scripts/commands/me_cure_affliction_1.py @@ -4,5 +4,5 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'me_cure_affliction_1') + core.buffService.addBuffToCreature(actor, 'me_cure_affliction_1', target) return \ No newline at end of file diff --git a/scripts/commands/me_evasion_1.py b/scripts/commands/me_evasion_1.py index 52391238..6fb5001a 100644 --- a/scripts/commands/me_evasion_1.py +++ b/scripts/commands/me_evasion_1.py @@ -4,5 +4,5 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'me_evasion_1') + core.buffService.addBuffToCreature(actor, 'me_evasion_1', actor) return \ No newline at end of file diff --git a/scripts/commands/me_stasis_self_1.py b/scripts/commands/me_stasis_self_1.py index fc808c70..192637a1 100644 --- a/scripts/commands/me_stasis_self_1.py +++ b/scripts/commands/me_stasis_self_1.py @@ -18,7 +18,7 @@ def run(core, actor, target, commandString): if not combatSvc.applySpecialCost(actor, weapon, CombatCommand('me_stasis_self_1')): return - core.buffService.addBuffToCreature(actor, 'me_stasis_self_1') + core.buffService.addBuffToCreature(actor, 'me_stasis_self_1', actor) return \ No newline at end of file diff --git a/scripts/commands/movefurniture.py b/scripts/commands/movefurniture.py index d07ea1da..46295121 100644 --- a/scripts/commands/movefurniture.py +++ b/scripts/commands/movefurniture.py @@ -9,6 +9,9 @@ def run(core, actor, target, commandString): container = actor.getContainer() parsedMsg = commandString.split(' ', 2) + if tarObj.getAttachment('initialized') is not None and target.getAttachment('initialized') == True: + return + if core.housingService.getPermissions(actor, container): # i should probably relook into my permissions system... it kinda sucks if parsedMsg[0] == "up": core.simulationService.transform(tarObj, Point3D(0, float(parsedMsg[1]) * 0.01, 0)) diff --git a/scripts/commands/of_emergency_shield.py b/scripts/commands/of_emergency_shield.py index 0a9cb543..73586f60 100644 --- a/scripts/commands/of_emergency_shield.py +++ b/scripts/commands/of_emergency_shield.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'of_emergency_shield') + core.buffService.addBuffToCreature(actor, 'of_emergency_shield', actor) return \ No newline at end of file diff --git a/scripts/commands/of_firepower_1.py b/scripts/commands/of_firepower_1.py index 50eba86a..442a5d45 100644 --- a/scripts/commands/of_firepower_1.py +++ b/scripts/commands/of_firepower_1.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'of_firepower') + core.buffService.addBuffToCreature(actor, 'of_firepower', actor) return \ No newline at end of file diff --git a/scripts/commands/of_inspiration_1.py b/scripts/commands/of_inspiration_1.py index 9f0c3a20..fc017af7 100644 --- a/scripts/commands/of_inspiration_1.py +++ b/scripts/commands/of_inspiration_1.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addGroupBuff(actor, 'of_inspiration_1') + core.buffService.addGroupBuff(actor, 'of_inspiration_1', actor) return \ No newline at end of file diff --git a/scripts/commands/of_inspiration_2.py b/scripts/commands/of_inspiration_2.py index c7ffcb5e..44ae030d 100644 --- a/scripts/commands/of_inspiration_2.py +++ b/scripts/commands/of_inspiration_2.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addGroupBuff(actor, 'of_inspiration_2') + core.buffService.addGroupBuff(actor, 'of_inspiration_2', actor) return \ No newline at end of file diff --git a/scripts/commands/of_inspiration_3.py b/scripts/commands/of_inspiration_3.py index fd2e8b80..52711f2a 100644 --- a/scripts/commands/of_inspiration_3.py +++ b/scripts/commands/of_inspiration_3.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addGroupBuff(actor, 'of_inspiration_3') + core.buffService.addGroupBuff(actor, 'of_inspiration_3', actor) return \ No newline at end of file diff --git a/scripts/commands/of_inspiration_4.py b/scripts/commands/of_inspiration_4.py index 35bae1ab..853d793d 100644 --- a/scripts/commands/of_inspiration_4.py +++ b/scripts/commands/of_inspiration_4.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addGroupBuff(actor, 'of_inspiration_4') + core.buffService.addGroupBuff(actor, 'of_inspiration_4', actor) return \ No newline at end of file diff --git a/scripts/commands/of_inspiration_5.py b/scripts/commands/of_inspiration_5.py index f9c9ba48..8723fc61 100644 --- a/scripts/commands/of_inspiration_5.py +++ b/scripts/commands/of_inspiration_5.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addGroupBuff(actor, 'of_inspiration_5') + core.buffService.addGroupBuff(actor, 'of_inspiration_5', actor) return \ No newline at end of file diff --git a/scripts/commands/of_inspiration_6.py b/scripts/commands/of_inspiration_6.py index ca05422d..5459e9ec 100644 --- a/scripts/commands/of_inspiration_6.py +++ b/scripts/commands/of_inspiration_6.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addGroupBuff(actor, 'of_inspiration_6') + core.buffService.addGroupBuff(actor, 'of_inspiration_6', actor) return \ No newline at end of file diff --git a/scripts/commands/of_purge_1.py b/scripts/commands/of_purge_1.py index 7a6edae9..1d1f6bae 100644 --- a/scripts/commands/of_purge_1.py +++ b/scripts/commands/of_purge_1.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'of_purge_1') + core.buffService.addBuffToCreature(actor, 'of_purge_1', actor) return \ No newline at end of file diff --git a/scripts/commands/of_scatter_1.py b/scripts/commands/of_scatter_1.py index 3984ca10..855c1841 100644 --- a/scripts/commands/of_scatter_1.py +++ b/scripts/commands/of_scatter_1.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'of_scatter_1', actor) + core.buffService.addGroupBuff(actor, 'of_scatter_1', actor) return \ No newline at end of file diff --git a/scripts/commands/of_stimulator_1.py b/scripts/commands/of_stimulator_1.py index c9b5a1c1..25efda68 100644 --- a/scripts/commands/of_stimulator_1.py +++ b/scripts/commands/of_stimulator_1.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'of_stimulator_1') + core.buffService.addBuffToCreature(actor, 'of_stimulator_1', actor) return \ No newline at end of file diff --git a/scripts/commands/rotatefurniture.py b/scripts/commands/rotatefurniture.py index 18fbfe35..66b1dc27 100644 --- a/scripts/commands/rotatefurniture.py +++ b/scripts/commands/rotatefurniture.py @@ -10,6 +10,9 @@ def run(core, actor, target, commandString): container = actor.getContainer() parsedMsg = commandString.split(' ', 2) + if tarObj.getAttachment('initialized') is not None and target.getAttachment('initialized') == True: + return + if core.housingService.getPermissions(actor, container): # i should probably relook into my permissions system... it kinda sucks if parsedMsg[0] == "pitch": core.simulationService.transform(tarObj, float(parsedMsg[1]), Point3D(1, 0, 0)) # this is messed up ??? diff --git a/scripts/commands/saberblock.py b/scripts/commands/saberblock.py index 55e12c59..4a69c0ff 100644 --- a/scripts/commands/saberblock.py +++ b/scripts/commands/saberblock.py @@ -4,6 +4,6 @@ def setup(core, actor, buff): return def run(core, actor, target, commandString): - core.buffService.addBuffToCreature(actor, 'saberblock') + core.buffService.addBuffToCreature(actor, 'saberblock', actor) return \ No newline at end of file diff --git a/scripts/commands/setgodmode.py b/scripts/commands/setgodmode.py index b0e78d52..680ba082 100644 --- a/scripts/commands/setgodmode.py +++ b/scripts/commands/setgodmode.py @@ -116,5 +116,13 @@ def run(core, actor, target, commandString): elif command == 'setBounty': core.playerService.sendSetBountyWindow(actor, actor) return + + elif command == 'genloot': + object = core.lootService.generateLootItem(actor, arg1) + + inventory = actor.getSlottedObject('inventory') + + if inventory: + inventory.add(object) return diff --git a/scripts/commands/setwaypointactivestatus.py b/scripts/commands/setwaypointactivestatus.py index 70d5b50c..24199d36 100644 --- a/scripts/commands/setwaypointactivestatus.py +++ b/scripts/commands/setwaypointactivestatus.py @@ -9,6 +9,10 @@ def run(core, actor, target, commandString): return waypointTarget = core.objectService.getObject(target.getObjectID()) wp = playerObject.getWaypointFromList(target) + + if wp is None: + return + if wp.isActive() == True: wp.setActive(False) playerObject.waypointUpdate(wp) diff --git a/scripts/commands/transferitemarmor.py b/scripts/commands/transferitemarmor.py index 2edbec74..8e166cbc 100644 --- a/scripts/commands/transferitemarmor.py +++ b/scripts/commands/transferitemarmor.py @@ -4,15 +4,18 @@ def setup(): return def run(core, actor, target, commandString): - if core.equipmentService.canEquip(actor, target) is False: - actor.sendSystemMessage('@error_message:insufficient_skill', 0) - return - parsedMsg = commandString.split(' ', 3) objService = core.objectService containerID = long(parsedMsg[1]) container = objService.getObject(containerID) + + canEquip = core.equipmentService.canEquip(actor, target) + + if canEquip[0] is False and container == actor: + actor.sendSystemMessage(canEquip[1], 0) + return + if target and container and target.getContainer(): oldContainer = target.getContainer() if container == oldContainer: diff --git a/scripts/commands/transferitemmisc.py b/scripts/commands/transferitemmisc.py index e30072ba..2bc32e5e 100644 --- a/scripts/commands/transferitemmisc.py +++ b/scripts/commands/transferitemmisc.py @@ -12,6 +12,14 @@ def run(core, actor, target, commandString): actorContainer = actor.getContainer() if container == None: return + + if(container.isFull()): + actor.sendSystemMessage('@container_error_message:container03', 0) + return + + if container.getTemplate().startswith("object/tangible/inventory/shared_lightsaber_inventory") or target.getContainer().getTemplate().startswith("object/tangible/inventory/shared_lightsaber_inventory"): + core.equipmentService.calculateLightsaberAttributes(actor, target, container) + return; if target.getTemplate() == 'object/tangible/item/shared_loot_cash.iff': core.lootService.handleCreditPickUp(actor,target) @@ -20,11 +28,7 @@ def run(core, actor, target, commandString): if target.isLootItem(): target.setLootItem(0) - name=target.getCustomName() - if target.getCustomName() == None: - name='@' + target.getStfFilename() + ':' + target.getStfName() - - actor.sendSystemMessage('You looted ' + name + ' from corpse.', 0) + actor.sendSystemMessage('You looted ' + target.getTrueName() + ' from corpse.', 0) if actorContainer != None and (container.getTemplate() == "object/cell/shared_cell.iff") & core.housingService.getPermissions(actor, actorContainer): target.getContainer().transferTo(actor, container, target) @@ -39,8 +43,10 @@ def run(core, actor, target, commandString): actor.sendSystemMessage("You do not have permission to access that container!", 0) return - if core.equipmentService.canEquip(actor, target) is False: - actor.sendSystemMessage('@error_message:insufficient_skill', 0) + canEquip = core.equipmentService.canEquip(actor, target) + + if canEquip[0] is False and container == actor: + actor.sendSystemMessage(canEquip[1], 0) return @@ -64,11 +70,13 @@ def run(core, actor, target, commandString): oldContainer.transferTo(actor, container, target) + for object in replacedObjects: + core.equipmentService.unequip(actor, object) + if actor == container: if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'): core.equipmentService.equip(actor, target) - for object in replacedObjects: - core.equipmentService.unequip(actor, object) + #path = 'scripts/' + target.getTemplate().rpartition('/')[0] + '/' #module = target.getTemplate().rpartition('/')[2].replace('shared_', '').replace('.iff', '') #core.scriptService.callScript(path, 'equip', module, core, actor, target) diff --git a/scripts/commands/transferitemweapon.py b/scripts/commands/transferitemweapon.py index 6e356571..b07c4e03 100644 --- a/scripts/commands/transferitemweapon.py +++ b/scripts/commands/transferitemweapon.py @@ -4,9 +4,7 @@ def setup(): return def run(core, actor, target, commandString): - if core.equipmentService.canEquip(actor, target) is False: - actor.sendSystemMessage('@error_message:insufficient_skill', 0) - return + parsedMsg = commandString.split(' ', 3) @@ -19,6 +17,12 @@ def run(core, actor, target, commandString): print 'Error: New container is same as old container.' return; + canEquip = core.equipmentService.canEquip(actor, target) + + if canEquip[0] is False and container == actor: + actor.sendSystemMessage(canEquip[1], 0) + return + replacedObject = None slotName = None replacedObjects = [] diff --git a/scripts/conversation/junk_dealer.py b/scripts/conversation/junk_dealer.py index 7c146b0f..5e5c435b 100644 --- a/scripts/conversation/junk_dealer.py +++ b/scripts/conversation/junk_dealer.py @@ -279,7 +279,7 @@ def noSellWindowCallBack(owner, window, eventType, returnList): #cancel if eventType == 1: - owner.sendSystemMessage('Cancle', 0) + owner.sendSystemMessage('Cancel', 0) sellItem = returnList.get(0) startConversation(coreRef,owner,junkDealerRef) return diff --git a/scripts/conversation/medical_cloning_droid.py b/scripts/conversation/medical_cloning_droid.py index 78bac164..8089c5f5 100644 --- a/scripts/conversation/medical_cloning_droid.py +++ b/scripts/conversation/medical_cloning_droid.py @@ -20,16 +20,23 @@ def startConversation(core, actor, npc): if actor.getBuffByName('cloning_sickness'): - prose = ProsePackage('conversation/clone_droid', 's_6') - outOfBand = OutOfBand() - outOfBand.addProsePackage(prose) - convSvc.sendConversationMessage(actor, npc, outOfBand) - prose2 = ProsePackage('conversation/clone_droid', 's_8') + + level = int(actor.getLevel()) + + if level <= 10: + cloningFee = 100 + elif level >= 11: + cloningFee = (((actor.getLevel() + 17) * actor.getLevel())/2) + elif level == 90: + cloningFee = 5000 + + convSvc.sendConversationMessage(actor, npc, OutOfBand.ProsePackage("@conversation/clone_droid:s_6", int(cloningFee))) + prose1 = ProsePackage('conversation/clone_droid', 's_8') outOfBand2 = OutOfBand() - outOfBand2.addProsePackage(prose2) - prose3 = ProsePackage('conversation/clone_droid', 's_12') + outOfBand2.addProsePackage(prose1) + prose2 = ProsePackage('conversation/clone_droid', 's_12') outOfBand3 = OutOfBand() - outOfBand3.addProsePackage(prose3) + outOfBand3.addProsePackage(prose2) option1 = ConversationOption(outOfBand2, 0) option2 = ConversationOption(outOfBand3, 1) @@ -41,7 +48,7 @@ def startConversation(core, actor, npc): convSvc.sendConversationOptions(actor, npc, options, handleFirstScreen) return else: - core.conversationService.sendStopConversation(actor, npc, 'conversation/clone_droid', 's_4') + core.conversationService.sendStopConversation(actor, npc, 'conversation/clone_droid', 's_14') return return @@ -68,24 +75,48 @@ def handleFirstScreen(core, actor, npc, selection): if selection == 1: - core.buffService.removeBuffFromCreature(actor, actor.getBuffByName("cloning_sickness")); - core.conversationService.sendStopConversation(actor, npc, 'conversation/clone_droid', 's_14') - return - return + if actor.getLevel() <= 10: + cloningFee = 100 + elif actor.getLevel() >= 11: + cloningFee = (((actor.getLevel() + 17) * actor.getLevel())/2) + elif actor.getLevel() == 90: + cloningFee = 5000 + + + if actor.getCashCredits() >= cloningFee: + core.buffService.removeBuffFromCreature(actor, actor.getBuffByName("cloning_sickness")); + core.conversationService.sendStopConversation(actor, npc, 'conversation/clone_droid', 's_14') + actor.setCashCredits(actor.getCashCredits() - int(cloningFee)) + return + elif actor.getCashCredits() <= cloningFee: + core.conversationService.sendStopConversation(actor, npc, 'conversation/clone_droid', 's_16') + return + return def handleSecondScreen(core, actor, npc, selection): convSvc = core.conversationService - + if actor.getLevel() <= 10: + cloningFee = 100 + elif actor.getLevel() >= 11: + cloningFee = (((actor.getLevel() + 17) * actor.getLevel())/2) + elif actor.getLevel() == 90: + cloningFee = 5000 if selection == 0: - core.buffService.removeBuffFromCreature(actor, actor.getBuffByName("cloning_sickness")); - core.conversationService.sendStopConversation(actor, npc, 'conversation/clone_droid', 's_14') + if actor.getCashCredits() >= cloningFee: + core.buffService.removeBuffFromCreature(actor, actor.getBuffByName("cloning_sickness")); + core.conversationService.sendStopConversation(actor, npc, 'conversation/clone_droid', 's_14') + actor.setCashCredits(actor.getCashCredits() - int(cloningFee)) + return + elif actor.getCashCredits() <= cloningFee: + core.conversationService.sendStopConversation(actor, npc, 'conversation/clone_droid', 's_16') + return return - return def endConversation(core, actor, npc): core.conversationService.sendStopConversation(actor, npc, 'conversation/clone_droid', 's_4') return - + + \ No newline at end of file diff --git a/scripts/loot/lootItems/armor/bone/bone_armor_bicep_left.py b/scripts/loot/lootItems/armor/bone/bone_armor_bicep_left.py index c6582c41..fe66e1ab 100644 --- a/scripts/loot/lootItems/armor/bone/bone_armor_bicep_left.py +++ b/scripts/loot/lootItems/armor/bone/bone_armor_bicep_left.py @@ -3,9 +3,9 @@ def itemTemplate(): return ['object/tangible/wearables/armor/bone/shared_armor_bone_s01_bicep_l.iff'] -def customItemName(): +#def customItemName(): - return 'Bone Armor Bicep Left' +# return 'Bone Armor Bicep Left' def customItemStackCount(): diff --git a/scripts/loot/lootItems/veryrareloot/rare_ankarres_sapphire.py b/scripts/loot/lootItems/veryrareloot/rare_ankarres_sapphire.py index 5559fc50..cee3f5ae 100644 --- a/scripts/loot/lootItems/veryrareloot/rare_ankarres_sapphire.py +++ b/scripts/loot/lootItems/veryrareloot/rare_ankarres_sapphire.py @@ -15,3 +15,5 @@ def requiredCL(): return 80 +def customSetup(object): + object.setCustomName2("Success!") \ No newline at end of file diff --git a/scripts/mobiles/dynamicgroups/mos_eisley_carrion_kreetle_01.py b/scripts/mobiles/dynamicgroups/mos_eisley_carrion_kreetle_01.py deleted file mode 100644 index db1bc7c3..00000000 --- a/scripts/mobiles/dynamicgroups/mos_eisley_carrion_kreetle_01.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -from services.spawn import DynamicSpawnGroup -from services.spawn import MobileTemplate -from java.util import Vector - -def addDynamicGroup(core): - dynamicGroup = DynamicSpawnGroup() - mobileTemplates = Vector() - mobileTemplates.add('carrion_kreetle') - dynamicGroup.setMobiles(mobileTemplates) - dynamicGroup.setGroupMembersNumber(1) - dynamicGroup.setName('mos_eisley_carrion_kreetle_01') - dynamicGroup.setMaxSpawns(-1) - dynamicGroup.setMinSpawnDistance(5) - core.spawnService.addDynamicGroup('mos_eisley_carrion_kreetle_01', dynamicGroup) - return \ No newline at end of file diff --git a/scripts/mobiles/dynamicgroups/mos_eisley_city_sewer_rats_01.py b/scripts/mobiles/dynamicgroups/mos_eisley_city_sewer_rats_01.py deleted file mode 100644 index 37c76c65..00000000 --- a/scripts/mobiles/dynamicgroups/mos_eisley_city_sewer_rats_01.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -from services.spawn import DynamicSpawnGroup -from services.spawn import MobileTemplate -from java.util import Vector - -def addDynamicGroup(core): - dynamicGroup = DynamicSpawnGroup() - mobileTemplates = Vector() - mobileTemplates.add('city_sewer_swamprat') - dynamicGroup.setMobiles(mobileTemplates) - dynamicGroup.setGroupMembersNumber(1) - dynamicGroup.setName('mos_eisley_city_sewer_rats_01') - dynamicGroup.setMaxSpawns(-1) - dynamicGroup.setMinSpawnDistance(5) - core.spawnService.addDynamicGroup('mos_eisley_city_sewer_rats_01', dynamicGroup) - return \ No newline at end of file diff --git a/scripts/mobiles/dynamicgroups/mos_eisley_mound_mites_01.py b/scripts/mobiles/dynamicgroups/mos_eisley_mound_mites_01.py deleted file mode 100644 index 46f2eddb..00000000 --- a/scripts/mobiles/dynamicgroups/mos_eisley_mound_mites_01.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -from services.spawn import DynamicSpawnGroup -from services.spawn import MobileTemplate -from java.util import Vector - -def addDynamicGroup(core): - dynamicGroup = DynamicSpawnGroup() - mobileTemplates = Vector() - mobileTemplates.add('mound_mite') - dynamicGroup.setMobiles(mobileTemplates) - dynamicGroup.setGroupMembersNumber(1) - dynamicGroup.setName('mos_eisley_mound_mites_01') - dynamicGroup.setMaxSpawns(-1) - dynamicGroup.setMinSpawnDistance(5) - core.spawnService.addDynamicGroup('mos_eisley_mound_mites_01', dynamicGroup) - return \ No newline at end of file diff --git a/scripts/mobiles/dynamicgroups/mos_eisley_rock_mites_01.py b/scripts/mobiles/dynamicgroups/mos_eisley_rock_mites_01.py deleted file mode 100644 index ead62ff3..00000000 --- a/scripts/mobiles/dynamicgroups/mos_eisley_rock_mites_01.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -from services.spawn import DynamicSpawnGroup -from services.spawn import MobileTemplate -from java.util import Vector - -def addDynamicGroup(core): - dynamicGroup = DynamicSpawnGroup() - mobileTemplates = Vector() - mobileTemplates.add('rockmite') - dynamicGroup.setMobiles(mobileTemplates) - dynamicGroup.setGroupMembersNumber(1) - dynamicGroup.setName('mos_eisley_rock_mites_01') - dynamicGroup.setMaxSpawns(-1) - dynamicGroup.setMinSpawnDistance(5) - core.spawnService.addDynamicGroup('mos_eisley_rock_mites_01', dynamicGroup) - return \ No newline at end of file diff --git a/scripts/mobiles/dynamicgroups/mos_eisley_sickly_womp_rats_01.py b/scripts/mobiles/dynamicgroups/mos_eisley_sickly_womp_rats_01.py deleted file mode 100644 index 73f1a14d..00000000 --- a/scripts/mobiles/dynamicgroups/mos_eisley_sickly_womp_rats_01.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -from services.spawn import DynamicSpawnGroup -from services.spawn import MobileTemplate -from java.util import Vector - -def addDynamicGroup(core): - dynamicGroup = DynamicSpawnGroup() - mobileTemplates = Vector() - mobileTemplates.add('sickly_womprat') - dynamicGroup.setMobiles(mobileTemplates) - dynamicGroup.setGroupMembersNumber(1) - dynamicGroup.setName('mos_eisley_sickly_womp_rats_01') - dynamicGroup.setMaxSpawns(-1) - dynamicGroup.setMinSpawnDistance(5) - core.spawnService.addDynamicGroup('mos_eisley_sickly_womp_rats_01', dynamicGroup) - return \ No newline at end of file diff --git a/scripts/mobiles/dynamicgroups/mos_eisley_tame_worrts_01.py b/scripts/mobiles/dynamicgroups/mos_eisley_tame_worrts_01.py deleted file mode 100644 index 148f876b..00000000 --- a/scripts/mobiles/dynamicgroups/mos_eisley_tame_worrts_01.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -from services.spawn import DynamicSpawnGroup -from services.spawn import MobileTemplate -from java.util import Vector - -def addDynamicGroup(core): - dynamicGroup = DynamicSpawnGroup() - mobileTemplates = Vector() - mobileTemplates.add('tame_worrt') - dynamicGroup.setMobiles(mobileTemplates) - dynamicGroup.setGroupMembersNumber(1) - dynamicGroup.setName('mos_eisley_tame_worrts_01') - dynamicGroup.setMaxSpawns(-1) - dynamicGroup.setMinSpawnDistance(5) - core.spawnService.addDynamicGroup('mos_eisley_tame_worrts_01', dynamicGroup) - return \ No newline at end of file diff --git a/scripts/mobiles/dynamicgroups/mos_eisley_tempest_rills_01.py b/scripts/mobiles/dynamicgroups/mos_eisley_tempest_rills_01.py deleted file mode 100644 index cb230f4f..00000000 --- a/scripts/mobiles/dynamicgroups/mos_eisley_tempest_rills_01.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -from services.spawn import DynamicSpawnGroup -from services.spawn import MobileTemplate -from java.util import Vector - -def addDynamicGroup(core): - dynamicGroup = DynamicSpawnGroup() - mobileTemplates = Vector() - mobileTemplates.add('tempest_rill') - dynamicGroup.setMobiles(mobileTemplates) - dynamicGroup.setGroupMembersNumber(1) - dynamicGroup.setName('mos_eisley_tempest_rills_01') - dynamicGroup.setMaxSpawns(-1) - dynamicGroup.setMinSpawnDistance(5) - core.spawnService.addDynamicGroup('mos_eisley_tempest_rills_01', dynamicGroup) - return \ No newline at end of file diff --git a/scripts/mobiles/dynamicgroups/mos_eisley_womp_rats_01.py b/scripts/mobiles/dynamicgroups/mos_eisley_womp_rats_01.py deleted file mode 100644 index 00637d0f..00000000 --- a/scripts/mobiles/dynamicgroups/mos_eisley_womp_rats_01.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys -from services.spawn import DynamicSpawnGroup -from services.spawn import MobileTemplate -from java.util import Vector - -def addDynamicGroup(core): - dynamicGroup = DynamicSpawnGroup() - mobileTemplates = Vector() - mobileTemplates.add('womprat') - dynamicGroup.setMobiles(mobileTemplates) - dynamicGroup.setGroupMembersNumber(1) - dynamicGroup.setName('mos_eisley_womprats_01') - dynamicGroup.setMaxSpawns(-1) - dynamicGroup.setMinSpawnDistance(5) - core.spawnService.addDynamicGroup('mos_eisley_womprats_01', dynamicGroup) - return \ No newline at end of file diff --git a/scripts/mobiles/spawnareas/legacy_starter_tatooine_1.py b/scripts/mobiles/spawnareas/legacy_starter_tatooine_1.py deleted file mode 100644 index e397088d..00000000 --- a/scripts/mobiles/spawnareas/legacy_starter_tatooine_1.py +++ /dev/null @@ -1,9 +0,0 @@ -import sys -from java.util import Vector - -def addSpawnArea(core): - dynamicGroups = Vector() - dynamicGroups.add('mos_eisley_carrion_kreetle_01') - dynamicGroups.add('mos_eisley_city_sewer_rats_01') - core.spawnService.addDynamicSpawnArea(dynamicGroups, 3216, -4465, 100, 'tatooine') - return \ No newline at end of file diff --git a/scripts/mobiles/spawnareas/legacy_starter_tatooine_2.py b/scripts/mobiles/spawnareas/legacy_starter_tatooine_2.py deleted file mode 100644 index 60c6b356..00000000 --- a/scripts/mobiles/spawnareas/legacy_starter_tatooine_2.py +++ /dev/null @@ -1,9 +0,0 @@ -import sys -from java.util import Vector - -def addSpawnArea(core): - dynamicGroups = Vector() - dynamicGroups.add('mos_eisley_tame_worrts_01') - dynamicGroups.add('mos_eisley_sickly_womp_rats_01') - core.spawnService.addDynamicSpawnArea(dynamicGroups, 3115, -4758, 100, 'tatooine') - return \ No newline at end of file diff --git a/scripts/mobiles/spawnareas/legacy_starter_tatooine_3.py b/scripts/mobiles/spawnareas/legacy_starter_tatooine_3.py deleted file mode 100644 index 140d9432..00000000 --- a/scripts/mobiles/spawnareas/legacy_starter_tatooine_3.py +++ /dev/null @@ -1,9 +0,0 @@ -import sys -from java.util import Vector - -def addSpawnArea(core): - dynamicGroups = Vector() - dynamicGroups.add('mos_eisley_tame_worrts_01') - dynamicGroups.add('mos_eisley_rock_mites_01') - core.spawnService.addDynamicSpawnArea(dynamicGroups, 3153, -4945, 100, 'tatooine') - return \ No newline at end of file diff --git a/scripts/mobiles/spawnareas/legacy_starter_tatooine_4.py b/scripts/mobiles/spawnareas/legacy_starter_tatooine_4.py deleted file mode 100644 index 8edcc45b..00000000 --- a/scripts/mobiles/spawnareas/legacy_starter_tatooine_4.py +++ /dev/null @@ -1,9 +0,0 @@ -import sys -from java.util import Vector - -def addSpawnArea(core): - dynamicGroups = Vector() - dynamicGroups.add('mos_eisley_tempest_rills_01') - dynamicGroups.add('mos_eisley_mound_mites_01') - core.spawnService.addDynamicSpawnArea(dynamicGroups, 3841, -4345, 100, 'tatooine') - return \ No newline at end of file diff --git a/scripts/mobiles/spawnareas/legacy_starter_tatooine_5.py b/scripts/mobiles/spawnareas/legacy_starter_tatooine_5.py deleted file mode 100644 index 44fcbc17..00000000 --- a/scripts/mobiles/spawnareas/legacy_starter_tatooine_5.py +++ /dev/null @@ -1,9 +0,0 @@ -import sys -from java.util import Vector - -def addSpawnArea(core): - dynamicGroups = Vector() - dynamicGroups.add('mos_eisley_womprats_01') - dynamicGroups.add('mos_eisley_mound_mites_01') - core.spawnService.addDynamicSpawnArea(dynamicGroups, 3587, -4354, 100, 'tatooine') - return \ No newline at end of file diff --git a/scripts/object/intangible/vehicle/landspeeder_av21_pcd.py b/scripts/object/intangible/vehicle/landspeeder_av21_pcd.py index ccad8904..d7c3f4a1 100644 --- a/scripts/object/intangible/vehicle/landspeeder_av21_pcd.py +++ b/scripts/object/intangible/vehicle/landspeeder_av21_pcd.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'datapad/vehicle_pcd') return \ No newline at end of file diff --git a/scripts/object/mobile/21b_surgical_droid.py b/scripts/object/mobile/21b_surgical_droid.py index ccad8904..bdc8a620 100644 --- a/scripts/object/mobile/21b_surgical_droid.py +++ b/scripts/object/mobile/21b_surgical_droid.py @@ -1,4 +1,11 @@ import sys +from resources.datatables import Options def setup(core, object): - return \ No newline at end of file + object.setAttachment('radial_filename', 'object/conversation'); + object.setAttachment('conversationFile','medical_cloning_droid') + object.setOptionsBitmask(Options.CONVERSABLE | Options.INVULNERABLE) + object.setStfFilename('mob/creature_names') + object.setStfName('surgical_droid') + return + diff --git a/scripts/object/tangible/terminal/terminal_mission_artisan.py b/scripts/object/tangible/terminal/terminal_mission_artisan.py index 6bface4e..7bbd42dd 100644 --- a/scripts/object/tangible/terminal/terminal_mission_artisan.py +++ b/scripts/object/tangible/terminal/terminal_mission_artisan.py @@ -1,7 +1,7 @@ import sys def setup(core, object): - + object.setAttachment("terminalType", 4) core.mapService.addLocation(object.getPlanet(), '@map_loc_cat_n:terminal_mission_artisan', object.getPosition().x, object.getPosition().z, 41, 76, 0) return \ No newline at end of file diff --git a/scripts/object/tangible/wearables/armor/zam/item_roadmap_belt_trader_01_02.py b/scripts/object/tangible/wearables/armor/zam/item_roadmap_belt_trader_01_02.py new file mode 100644 index 00000000..353407c0 --- /dev/null +++ b/scripts/object/tangible/wearables/armor/zam/item_roadmap_belt_trader_01_02.py @@ -0,0 +1,13 @@ +import sys + +def setup(core, object): + object.setStfFilename('static_item_n') + object.setStfName('item_roadmap_belt_trader_01_02') + object.setDetailFilename('static_item_d') + object.setDetailName('item_roadmap_belt_trader_01_02') + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:agility_modified', 15) + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:constitution_modified', 20) + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:precision_modified', 15) + object.setStringAttribute('class_required', 'Trader') + object.setIntAttribute('required_combat_level', 90) + return \ No newline at end of file diff --git a/scripts/object/tangible/wearables/backpack/item_trader_backpack_01_02.py b/scripts/object/tangible/wearables/backpack/item_trader_backpack_01_02.py new file mode 100644 index 00000000..9eb23a37 --- /dev/null +++ b/scripts/object/tangible/wearables/backpack/item_trader_backpack_01_02.py @@ -0,0 +1,11 @@ +import sys + +def setup(core, object): + object.setStfFilename('static_item_n') + object.setStfName('item_trader_backpack_01_02') + object.setDetailFilename('static_item_d') + object.setDetailName('item_trader_backpack_01_02') + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:expertise_assembly_increase_artisan', 5) + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:hiring', 3) + object.setStringAttribute('class_required', 'Trader') + return diff --git a/scripts/object/tangible/wearables/bodysuit/item_trader_roadmap_jumpsuit_02_01.py b/scripts/object/tangible/wearables/bodysuit/item_trader_roadmap_jumpsuit_02_01.py new file mode 100644 index 00000000..7218be6d --- /dev/null +++ b/scripts/object/tangible/wearables/bodysuit/item_trader_roadmap_jumpsuit_02_01.py @@ -0,0 +1,12 @@ +import sys + +def setup(core, object): + object.setStfFilename('static_item_n') + object.setStfName('item_trader_roadmap_jumpsuit_02_01') + object.setDetailFilename('static_item_d') + object.setDetailName('item_trader_roadmap_jumpsuit_02_01') + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:agility_modified', 2) + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:constitution_modified', 1) + object.setStringAttribute('class_required', 'Trader') + object.setIntAttribute('required_combat_level', 30) + return \ No newline at end of file diff --git a/scripts/object/tangible/wearables/bodysuit/item_trader_roadmap_jumpsuit_02_02.py b/scripts/object/tangible/wearables/bodysuit/item_trader_roadmap_jumpsuit_02_02.py new file mode 100644 index 00000000..f10fbe79 --- /dev/null +++ b/scripts/object/tangible/wearables/bodysuit/item_trader_roadmap_jumpsuit_02_02.py @@ -0,0 +1,12 @@ +import sys + +def setup(core, object): + object.setStfFilename('static_item_n') + object.setStfName('item_trader_roadmap_jumpsuit_02_02') + object.setDetailFilename('static_item_d') + object.setDetailName('item_trader_roadmap_jumpsuit_02_02') + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:agility_modified', 2) + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:constitution_modified', 1) + object.setStringAttribute('class_required', 'Trader') + object.setIntAttribute('required_combat_level', 30) + return \ No newline at end of file diff --git a/scripts/object/tangible/wearables/bracelet/item_bracelet_l_set_spy_utility_a_01_01.py b/scripts/object/tangible/wearables/bracelet/item_bracelet_l_set_spy_utility_a_01_01.py index cf9b8380..024129b8 100644 --- a/scripts/object/tangible/wearables/bracelet/item_bracelet_l_set_spy_utility_a_01_01.py +++ b/scripts/object/tangible/wearables/bracelet/item_bracelet_l_set_spy_utility_a_01_01.py @@ -7,11 +7,12 @@ def setup(core, object): object.setDetailName('item_bracelet_l_set_spy_utility_a_01_01') object.setIntAttribute('required_combat_level', 85) object.setStringAttribute('class_required', 'Spy') - object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_strikethrough_chance', 2) - object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_action_all', 1) - object.setIntAttribute('cat_stat_mod_bonus.@stat_n:luck_modified', 50) + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:strength_modified', 25) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:fast_attack_line_sp_smoke', 1) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_duration_line_sp_preparation', 1) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_cooldown_line_sp_preparation', 6) object.setStringAttribute('@set_bonus:piece_bonus_count_3', '@set_bonus:set_bonus_spy_utility_a_1') object.setStringAttribute('@set_bonus:piece_bonus_count_4', '@set_bonus:set_bonus_spy_utility_a_2') object.setStringAttribute('@set_bonus:piece_bonus_count_5', '@set_bonus:set_bonus_spy_utility_a_3') object.setAttachment('setBonus', 'set_bonus_spy_utility_a') - return \ No newline at end of file + return diff --git a/scripts/object/tangible/wearables/bracelet/item_bracelet_r_set_spy_utility_a_01_01.py b/scripts/object/tangible/wearables/bracelet/item_bracelet_r_set_spy_utility_a_01_01.py index 490bfeab..6d18e3d8 100644 --- a/scripts/object/tangible/wearables/bracelet/item_bracelet_r_set_spy_utility_a_01_01.py +++ b/scripts/object/tangible/wearables/bracelet/item_bracelet_r_set_spy_utility_a_01_01.py @@ -7,11 +7,12 @@ def setup(core, object): object.setDetailName('item_bracelet_r_set_spy_utility_a_01_01') object.setIntAttribute('required_combat_level', 85) object.setStringAttribute('class_required', 'Spy') - object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_strikethrough_chance', 2) - object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_action_all', 1) - object.setIntAttribute('cat_stat_mod_bonus.@stat_n:luck_modified', 50) + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:strength_modified', 25) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:fast_attack_line_sp_smoke', 1) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_duration_line_sp_preparation', 1) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_cooldown_line_sp_preparation', 6) object.setStringAttribute('@set_bonus:piece_bonus_count_3', '@set_bonus:set_bonus_spy_utility_a_1') object.setStringAttribute('@set_bonus:piece_bonus_count_4', '@set_bonus:set_bonus_spy_utility_a_2') object.setStringAttribute('@set_bonus:piece_bonus_count_5', '@set_bonus:set_bonus_spy_utility_a_3') object.setAttachment('setBonus', 'set_bonus_spy_utility_a') - return \ No newline at end of file + return diff --git a/scripts/object/tangible/wearables/necklace/item_necklace_set_spy_utility_a_01_01.py b/scripts/object/tangible/wearables/necklace/item_necklace_set_spy_utility_a_01_01.py index af9be68a..405ed693 100644 --- a/scripts/object/tangible/wearables/necklace/item_necklace_set_spy_utility_a_01_01.py +++ b/scripts/object/tangible/wearables/necklace/item_necklace_set_spy_utility_a_01_01.py @@ -7,11 +7,12 @@ def setup(core, object): object.setDetailName('item_necklace_set_spy_utility_a_01_01') object.setIntAttribute('required_combat_level', 85) object.setStringAttribute('class_required', 'Spy') - object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_strikethrough_chance', 2) - object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_action_all', 1) - object.setIntAttribute('cat_stat_mod_bonus.@stat_n:luck_modified', 50) + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:strength_modified', 25) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:fast_attack_line_sp_smoke', 1) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_duration_sp_preparation', 1) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_cooldown_line_sp_preparation', 6) object.setStringAttribute('@set_bonus:piece_bonus_count_3', '@set_bonus:set_bonus_spy_utility_a_1') object.setStringAttribute('@set_bonus:piece_bonus_count_4', '@set_bonus:set_bonus_spy_utility_a_2') object.setStringAttribute('@set_bonus:piece_bonus_count_5', '@set_bonus:set_bonus_spy_utility_a_3') object.setAttachment('setBonus', 'set_bonus_spy_utility_a') - return \ No newline at end of file + return diff --git a/scripts/object/tangible/wearables/necklace/item_trader_pendant_01_02.py b/scripts/object/tangible/wearables/necklace/item_trader_pendant_01_02.py new file mode 100644 index 00000000..48f0b1b9 --- /dev/null +++ b/scripts/object/tangible/wearables/necklace/item_trader_pendant_01_02.py @@ -0,0 +1,11 @@ +import sys + +def setup(core, object): + object.setStfFilename('static_item_n') + object.setStfName('item_trader_pendant_01_02') + object.setDetailFilename('static_item_d') + object.setDetailName('item_trader_pendant_01_02') + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:general_assembly', 5) + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:hiring', 3) + object.setStringAttribute('class_required', 'Trader') + return diff --git a/scripts/object/tangible/wearables/ring/item_band_set_spy_utility_a_01_01.py b/scripts/object/tangible/wearables/ring/item_band_set_spy_utility_a_01_01.py index aa7306d4..3483cb23 100644 --- a/scripts/object/tangible/wearables/ring/item_band_set_spy_utility_a_01_01.py +++ b/scripts/object/tangible/wearables/ring/item_band_set_spy_utility_a_01_01.py @@ -9,11 +9,12 @@ def setup(core, object): object.setDetailName('item_band_set_spy_utility_a_01_01') object.setIntAttribute('required_combat_level', 85) object.setStringAttribute('class_required', 'Spy') - object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_strikethrough_chance', 2) - object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_action_all', 1) - object.setIntAttribute('cat_stat_mod_bonus.@stat_n:luck_modified', 50) + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:strength_modified', 25) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:fast_attack_line_sp_smoke', 1) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_duration_line_sp_preparation', 1) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_cooldown_line_sp_preparation', 6) object.setStringAttribute('@set_bonus:piece_bonus_count_3', '@set_bonus:set_bonus_spy_utility_a_1') object.setStringAttribute('@set_bonus:piece_bonus_count_4', '@set_bonus:set_bonus_spy_utility_a_2') object.setStringAttribute('@set_bonus:piece_bonus_count_5', '@set_bonus:set_bonus_spy_utility_a_3') object.setAttachment('setBonus', 'set_bonus_spy_utility_a') - return \ No newline at end of file + return diff --git a/scripts/object/tangible/wearables/ring/item_content_trader_ring_03_01.py b/scripts/object/tangible/wearables/ring/item_content_trader_ring_03_01.py new file mode 100644 index 00000000..70713a96 --- /dev/null +++ b/scripts/object/tangible/wearables/ring/item_content_trader_ring_03_01.py @@ -0,0 +1,13 @@ +import sys + +def setup(core, object): + object.setAttachment('objType', 'ring') + object.setStfFilename('static_item_n') + object.setStfName('item_content_trader_ring_03_01') + object.setDetailFilename('static_item_d') + object.setDetailName('item_content_trader_ring_03_01') + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:constitution_modified', 6) + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:general_assembly', 6) + object.setStringAttribute('class_required', 'Trader') + object.setAttachment('radial_filename', 'ring/unity') + return \ No newline at end of file diff --git a/scripts/object/tangible/wearables/ring/item_ring_set_spy_utility_a_01_01.py b/scripts/object/tangible/wearables/ring/item_ring_set_spy_utility_a_01_01.py index e57da3f8..500ea4ff 100644 --- a/scripts/object/tangible/wearables/ring/item_ring_set_spy_utility_a_01_01.py +++ b/scripts/object/tangible/wearables/ring/item_ring_set_spy_utility_a_01_01.py @@ -9,11 +9,12 @@ def setup(core, object): object.setDetailName('item_ring_set_spy_utility_a_01_01') object.setIntAttribute('required_combat_level', 85) object.setStringAttribute('class_required', 'Spy') - object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_strikethrough_chance', 2) - object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_action_all', 1) - object.setIntAttribute('cat_stat_mod_bonus.@stat_n:luck_modified', 50) + object.setIntAttribute('cat_stat_mod_bonus.@stat_n:strength_modified', 25) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:fast_attack_line_sp_smoke', 1) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_duration_line_sp_preparation', 1) + object.setIntAttribute('cat_skill_mod_bonus.@stat_n:expertise_cooldown_line_sp_preparation', 6) object.setStringAttribute('@set_bonus:piece_bonus_count_3', '@set_bonus:set_bonus_spy_utility_a_1') object.setStringAttribute('@set_bonus:piece_bonus_count_4', '@set_bonus:set_bonus_spy_utility_a_2') object.setStringAttribute('@set_bonus:piece_bonus_count_5', '@set_bonus:set_bonus_spy_utility_a_3') object.setAttachment('setBonus', 'set_bonus_spy_utility_a') - return \ No newline at end of file + return diff --git a/scripts/object/weapon/melee/2h_sword/crafted_saber/sword_lightsaber_two_handed_gen5.py b/scripts/object/weapon/melee/2h_sword/crafted_saber/sword_lightsaber_two_handed_gen5.py index ccad8904..7f41b9a6 100644 --- a/scripts/object/weapon/melee/2h_sword/crafted_saber/sword_lightsaber_two_handed_gen5.py +++ b/scripts/object/weapon/melee/2h_sword/crafted_saber/sword_lightsaber_two_handed_gen5.py @@ -1,4 +1,13 @@ import sys +from engine.resources.container import CreaturePermissions def setup(core, object): + + inventory = core.objectService.createObject("object/tangible/inventory/shared_lightsaber_inventory_5.iff", object.getPlanet()) + inventory.setContainerPermissions(CreaturePermissions.CREATURE_PERMISSIONS); + + object.add(inventory) + + object.setAttachment('radial_filename', 'item/lightsaber') + return \ No newline at end of file diff --git a/scripts/object/weapon/melee/knife/weapon_knife_trader_roadmap_01_02.py b/scripts/object/weapon/melee/knife/weapon_knife_trader_roadmap_01_02.py new file mode 100644 index 00000000..a8e53801 --- /dev/null +++ b/scripts/object/weapon/melee/knife/weapon_knife_trader_roadmap_01_02.py @@ -0,0 +1,15 @@ +import sys + +def setup(core, object): + object.setStfFilename('static_item_n') + object.setStfName('weapon_knife_trader_roadmap_01_02') + object.setDetailFilename('static_item_d') + object.setDetailName('weapon_knife_trader_roadmap_01_02') + object.setStringAttribute('class_required', 'Trader') + object.setIntAttribute('required_combat_level', 42) + object.setFloatAttribute('cat_wpn_damage.wpn_attack_speed', 0) + object.setStringAttribute('cat_wpn_damage.damage', '80 - 160') + object.setStringAttribute('cat_wpn_damage.wpn_range', '0-5m') + object.setStringAttribute('cat_wpn_damage.wpn_category', 'One-Handed Melee') + object.setIntAttribute('cat_wpn_damage.dps', object.getDamagePerSecond()) + return \ No newline at end of file diff --git a/scripts/object/weapon/melee/polearm/crafted_saber/sword_lightsaber_polearm_gen5.py b/scripts/object/weapon/melee/polearm/crafted_saber/sword_lightsaber_polearm_gen5.py index ccad8904..7f41b9a6 100644 --- a/scripts/object/weapon/melee/polearm/crafted_saber/sword_lightsaber_polearm_gen5.py +++ b/scripts/object/weapon/melee/polearm/crafted_saber/sword_lightsaber_polearm_gen5.py @@ -1,4 +1,13 @@ import sys +from engine.resources.container import CreaturePermissions def setup(core, object): + + inventory = core.objectService.createObject("object/tangible/inventory/shared_lightsaber_inventory_5.iff", object.getPlanet()) + inventory.setContainerPermissions(CreaturePermissions.CREATURE_PERMISSIONS); + + object.add(inventory) + + object.setAttachment('radial_filename', 'item/lightsaber') + return \ No newline at end of file diff --git a/scripts/object/weapon/melee/sword/crafted_saber/sword_lightsaber_one_handed_gen5.py b/scripts/object/weapon/melee/sword/crafted_saber/sword_lightsaber_one_handed_gen5.py index ccad8904..7f41b9a6 100644 --- a/scripts/object/weapon/melee/sword/crafted_saber/sword_lightsaber_one_handed_gen5.py +++ b/scripts/object/weapon/melee/sword/crafted_saber/sword_lightsaber_one_handed_gen5.py @@ -1,4 +1,13 @@ import sys +from engine.resources.container import CreaturePermissions def setup(core, object): + + inventory = core.objectService.createObject("object/tangible/inventory/shared_lightsaber_inventory_5.iff", object.getPlanet()) + inventory.setContainerPermissions(CreaturePermissions.CREATURE_PERMISSIONS); + + object.add(inventory) + + object.setAttachment('radial_filename', 'item/lightsaber') + return \ No newline at end of file diff --git a/scripts/object/weapon/ranged/pistol/weapon_pistol_trader_roadmap_01_02.py b/scripts/object/weapon/ranged/pistol/weapon_pistol_trader_roadmap_01_02.py new file mode 100644 index 00000000..9feea0cd --- /dev/null +++ b/scripts/object/weapon/ranged/pistol/weapon_pistol_trader_roadmap_01_02.py @@ -0,0 +1,16 @@ +import sys + +def setup(core, object): + object.setStfFilename('static_item_n') + object.setStfName('weapon_pistol_trader_roadmap_01_02') + object.setDetailFilename('static_item_d') + object.setDetailName('weapon_pistol_trader_roadmap_01_02') + object.setStringAttribute('class_required', 'Trader') + object.setIntAttribute('required_combat_level', 62) + object.setFloatAttribute('cat_wpn_damage.wpn_attack_speed', 0.4) + object.setStringAttribute('cat_wpn_damage.wpn_damage_type', 'Energy') + object.setStringAttribute('cat_wpn_damage.damage', '250-500') + object.setStringAttribute('cat_wpn_damage.wpn_range', '0-35m') + object.setStringAttribute('cat_wpn_damage.wpn_category', 'Pistol') + object.setIntAttribute('cat_wpn_damage.dps', object.getDamagePerSecond()) + return \ No newline at end of file diff --git a/scripts/radial/deeds/vehicleDeed.py b/scripts/radial/deeds/vehicleDeed.py index 033462ad..ad08a40f 100644 --- a/scripts/radial/deeds/vehicleDeed.py +++ b/scripts/radial/deeds/vehicleDeed.py @@ -4,7 +4,7 @@ import sys def createRadial(core, owner, target, radials): radials.add(RadialOptions(0, 7, 1, '')) radials.add(RadialOptions(0, 15, 1, '')) - radials.add(RadialOptions(0, 61, 3, '@pet_menu:menu_generate')) + radials.add(RadialOptions(0, 61, 3, '@pet/pet_menu:menu_generate')) return def handleSelection(core, owner, target, option): diff --git a/scripts/radial/item/lightsaber.py b/scripts/radial/item/lightsaber.py new file mode 100644 index 00000000..c02dc502 --- /dev/null +++ b/scripts/radial/item/lightsaber.py @@ -0,0 +1,12 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + radials.add(RadialOptions(0, 21, 1, 'Open Lightsaber')) + return + +def handleSelection(core, owner, target, option): + if option == 21 and target: + core.simulationService.openContainer(owner, target.getSlottedObject("saber_inv")) + return + \ No newline at end of file diff --git a/scripts/radial/item/tunable.py b/scripts/radial/item/tunable.py index f226f86b..cda19b74 100644 --- a/scripts/radial/item/tunable.py +++ b/scripts/radial/item/tunable.py @@ -1,15 +1,60 @@ from resources.common import RadialOptions +from services.sui.SUIService import MessageBoxType +import time +from services.sui.SUIWindow import Trigger +from java.util import Vector +import main.NGECore import sys -def createRadial(core, owner, target, radials): +def createRadial(core, owner, target, radials): radials.clear() radials.add(RadialOptions(0, 7, 0, 'Examine')) radials.add(RadialOptions(0, 15, 0, 'Destroy')) - radials.add(RadialOptions(0, 19, 0, 'Tune')) + if target.getAttachment("tunerId") == None or target.getAttachment("tunerId") == 0: + if owner.getPlayerObject().getProfession()=='force_sensitive_1a': + radials.add(RadialOptions(0, 19, 0, '@jedi_spam:tune_crystal')) return def handleSelection(core, owner, target, option): if option == 19 and target: if owner is not None: - owner.sendSystemMessage('You are not attuned enough with the force yet.',1) + #owner.sendSystemMessage('You are not attuned enough with the force yet.',1) + + if target.getAttachment("tunerId") == None or target.getAttachment("tunerId") == 0: + + owner.setAttachment("TunableObject", target.getObjectID()) + handleSUIWindow(core, owner, target, option) + + else: + owner.sendSystemMessage("You cannot tune this crystal.",1) return + +def handleSUIWindow(core, owner, target, option): + suiSvc = core.suiService + suiWindow = suiSvc.createMessageBox(MessageBoxType.MESSAGE_BOX_OK_CANCEL, '@jedi_spam:confirm_tune_title', '@jedi_spam:confirm_tune_prompt', owner, target, 15) + returnParams = Vector() + returnParams.add('btnOk:Text') + returnParams.add('btnCancel:Text') + suiWindow.addHandler(0, '', Trigger.TRIGGER_OK, returnParams, handleSUI) + suiWindow.addHandler(1, '', Trigger.TRIGGER_CANCEL, returnParams, handleSUI) + suiSvc.openSUIWindow(suiWindow) + +def handleSUI(owner, window, eventType, returnList): + + if eventType == 0: + time.sleep(1) + objectID = long(owner.getAttachment("TunableObject")) + tunableObject = main.NGECore.getInstance().objectService.getObject(objectID) + + if tunableObject: + tunableObject.getAttributes().put("@obj_attr_n:crystal_owner", owner.getCustomName()) + tunableObject.setAttachment("tunerId", int(owner.getObjectId())) + + if tunableObject.getAttributes().get("@obj_attr_n:color") is None: + main.NGECore.getInstance().lootService.tuneProcess(tunableObject) + time.sleep(0.5) + + tunableObject.setCustomName( "\\#00FF00" + tunableObject.getObjectName().getStfValue() + " (tuned)") + owner.sendSystemMessage('@jedi_spam:crystal_tune_success',1) + return + \ No newline at end of file diff --git a/scripts/radial/structure/structure_management_terminal.py b/scripts/radial/structure/structure_management_terminal.py index b6e7ae3a..8bdc5878 100644 --- a/scripts/radial/structure/structure_management_terminal.py +++ b/scripts/radial/structure/structure_management_terminal.py @@ -24,6 +24,8 @@ def createRadial(core, owner, target, radials): radials.add(RadialOptions(2, 172, 0, 'Pack Up This Building')) radials.add(RadialOptions(3, 121, 0, '@player_structure:permission_enter')) radials.add(RadialOptions(3, 123, 0, '@player_structure:permission_banned')) + if owner.getSkillModBase('manage_vendor') >= 1: + radials.add(RadialOptions(2, 130, 0, '@player_structure:create_vendor')) return @@ -73,5 +75,7 @@ def handleSelection(core, owner, target, option): if owner is not None: core.housingService.handlePermissionBan(owner,target) return - - + if option == 130: + if owner is not None and owner.getSkillModBase('manage_vendor') >= 1: + core.commandService.callCommand(owner, 'createvendor', None, '') + return diff --git a/scripts/radial/terminal/cloning_terminal.py b/scripts/radial/terminal/cloning_terminal.py index 4809d1d6..1cf0e065 100644 --- a/scripts/radial/terminal/cloning_terminal.py +++ b/scripts/radial/terminal/cloning_terminal.py @@ -10,8 +10,19 @@ def createRadial(core, owner, target, radials): def handleSelection(core, owner, target, option): if option == 21 and target: + # REALLY Dirty hack until this can be resolved SWG way !! + stra = "Will you pay the %DI credits to clone yourself here?" + level = int(owner.getLevel()) + + if level <= 10: + cloningFee = 100 + elif level >= 11: + cloningFee = (((owner.getLevel() + 17) * owner.getLevel())/2) + elif level == 90: + cloningFee = 5000 + suiSvc = core.suiService - suiWindow = suiSvc.createMessageBox(MessageBoxType.MESSAGE_BOX_OK_CANCEL, '@base_player:clone_confirm_title', '@base_player:clone_confirm_prompt', owner, target, 15) + suiWindow = suiSvc.createMessageBox(MessageBoxType.MESSAGE_BOX_OK_CANCEL, '@base_player:clone_confirm_title', stra.replace ("%DI" , str(cloningFee)), owner, target, 15) returnParams = Vector() returnParams.add('btnOk:Text') returnParams.add('btnCancel:Text') @@ -24,17 +35,26 @@ def handleSelection(core, owner, target, option): def handleSUI(owner, window, eventType, returnList): if eventType == 0: + level = int(owner.getLevel()) + if level <= 10: + cloningFee = 100 + elif level >= 11: + cloningFee = (((owner.getLevel() + 17) * owner.getLevel())/2) + elif level == 90: + cloningFee = 5000 + cash = owner.getCashCredits() bank = owner.getBankCredits() - if bank < 1000 and cash < 1000: + + if bank < cloningFee and cash < cloningFee: owner.sendSystemMessage('You lack the credits required to cover the cost of cloning.', 0) return - elif bank > 1000: - owner.setBankCredits(bank - 1000) - elif cash > 1000 and bank < 1000: - owner.setCashCredits(cash - 1000) + elif bank >= cloningFee: + owner.setBankCredits(bank - cloningFee) + elif cash >= cloningFee and bank < cloningFee: + owner.setCashCredits(cash - cloningFee) - owner.setAttachment('preDesignatedCloner', window.getRangeObject().getGrandparent().getObjectID()) + owner.getPlayerObject().setBindLocation(window.getRangeObject().getGrandparent().getObjectID()) owner.sendSystemMessage('@base_player:clone_success', 0) diff --git a/scripts/radial/terminal/vendor.py b/scripts/radial/terminal/vendor.py new file mode 100644 index 00000000..39b25d8b --- /dev/null +++ b/scripts/radial/terminal/vendor.py @@ -0,0 +1,39 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + radials.clear() + radials.add(RadialOptions(0, 11, 1, '')) + radials.add(RadialOptions(0, 55, 0, '')) + radials.add(RadialOptions(2, 56, 1, '')) + radials.add(RadialOptions(2, 57, 1, '')) + radials.add(RadialOptions(2, 58, 1, '')) + radials.add(RadialOptions(2, 59, 1, '')) + radials.add(RadialOptions(0, 52, 0, '')) + radials.add(RadialOptions(3, 53, 1, '')) + radials.add(RadialOptions(3, 54, 1, '')) + + if not owner.getPlayerObject().getOwnedVendors().contains(target.getObjectID()) + return + radials.add(RadialOptions(0, 112, 3, '@player_structure:vendor_control')) + if target.getAttachment('initialized') == False: + radials.add(RadialOptions(1, 118, 3, '@player_structure:vendor_init')) + else: + # soe reuses option 118 + radials.add(RadialOptions(4, 118, 3, '@player_structure:vendor_status')) + radials.add(RadialOptions(4, 217, 3, '@player_structure:give_maintenance')) + radials.add(RadialOptions(4, 115, 3, '@player_structure:take_maintenance')) + if owner.getSkillModBase('private_register_vendor') >= 1: + radials.add(RadialOptions(4, 116, 3, '@player_structure:register_vendor')) + radials.add(RadialOptions(4, 205, 3, '@player_structure:enable_vendor_search')) + radials.add(RadialOptions(4, 206, 3, '@player_structure:disable_vendor_search')) + radials.add(RadialOptions(4, 121, 3, '@player_structure:customize_vendor')) + + radials.add(RadialOptions(4, 114, 3, '@player_structure:vendor_pack')) + radials.add(RadialOptions(4, 117, 3, '@player_structure:remove_vendor')) + + return + +def handleSelection(core, owner, target, option): + return + \ No newline at end of file diff --git a/scripts/roadmap/trader_0a.py b/scripts/roadmap/trader_0a.py index 203b6ad9..c0ae1ee4 100644 --- a/scripts/roadmap/trader_0a.py +++ b/scripts/roadmap/trader_0a.py @@ -25,4 +25,30 @@ def getAction(): return 75 def getRewards(name): - return \ No newline at end of file + if name == 'item_npe_gen_craft_tool_trader_03_01': + return "object/tangible/crafting/base/shared_generic_base_tool.iff" + + if name == 'item_trader_backpack_01_02': + return "object/tangible/wearables/backpack/shared_backpack_s04.iff" + + if name == 'weapon_knife_trader_roadmap_01_02': + return "object/weapon/melee/knife/shared_knife_dagger.iff" + + if name == 'item_trader_ring_01_02': + return "object/tangible/wearables/ring/shared_ring_s02.iff" + + if name == 'item_trader_roadmap_jumpsuit_02_02': + return "object/tangible/wearables/bodysuit/shared_bodysuit_s01.iff" + + if name == 'weapon_pistol_trader_roadmap_01_02': + return "object/weapon/ranged/pistol/shared_pistol_scout_blaster.iff" + + if name == 'item_trader_pendant_01_02': + return "object/tangible/wearables/necklace/shared_necklace_s07.iff" + + if name == 'item_trader_clicky_01_02': + return "object/tangible/crafting/station/shared_generic_generic_tool.iff" + + if name == 'item_roadmap_belt_trader_01_02': + return "object/tangible/wearables/armor/zam/shared_armor_zam_wesell_belt.iff" + return \ No newline at end of file diff --git a/scripts/roadmap/trader_0b.py b/scripts/roadmap/trader_0b.py index 203b6ad9..c3a7e4ec 100644 --- a/scripts/roadmap/trader_0b.py +++ b/scripts/roadmap/trader_0b.py @@ -24,5 +24,32 @@ def getHealth(): def getAction(): return 75 + def getRewards(name): - return \ No newline at end of file + if name == 'item_npe_gen_craft_tool_trader_03_01': + return "object/tangible/crafting/base/shared_generic_base_tool.iff" + + if name == 'item_trader_backpack_01_02': + return "object/tangible/wearables/backpack/shared_backpack_s04.iff" + + if name == 'weapon_knife_trader_roadmap_01_02': + return "object/weapon/melee/knife/shared_knife_dagger.iff" + + if name == 'item_trader_ring_01_02': + return "object/tangible/wearables/ring/shared_ring_s02.iff" + + if name == 'item_trader_roadmap_jumpsuit_02_02': + return "object/tangible/wearables/bodysuit/shared_bodysuit_s01.iff" + + if name == 'weapon_pistol_trader_roadmap_01_02': + return "object/weapon/ranged/pistol/shared_pistol_scout_blaster.iff" + + if name == 'item_trader_pendant_01_02': + return "object/tangible/wearables/necklace/shared_necklace_s07.iff" + + if name == 'item_trader_clicky_01_02': + return "object/tangible/crafting/station/shared_generic_generic_tool.iff" + + if name == 'item_roadmap_belt_trader_01_02': + return "object/tangible/wearables/armor/zam/shared_armor_zam_wesell_belt.iff" + return \ No newline at end of file diff --git a/scripts/roadmap/trader_0c.py b/scripts/roadmap/trader_0c.py index 203b6ad9..7ac4a0d7 100644 --- a/scripts/roadmap/trader_0c.py +++ b/scripts/roadmap/trader_0c.py @@ -25,4 +25,30 @@ def getAction(): return 75 def getRewards(name): - return \ No newline at end of file + if name == 'item_npe_gen_craft_tool_trader_03_01': + return "object/tangible/crafting/base/shared_generic_base_tool.iff" + + if name == 'item_trader_backpack_01_02': + return "object/tangible/wearables/backpack/shared_backpack_s04.iff" + + if name == 'weapon_knife_trader_roadmap_01_02': + return "object/weapon/melee/knife/shared_knife_dagger.iff" + + if name == 'item_trader_ring_01_02': + return "object/tangible/wearables/ring/shared_ring_s02.iff" + + if name == 'item_trader_roadmap_jumpsuit_02_02': + return "object/tangible/wearables/bodysuit/shared_bodysuit_s01.iff" + + if name == 'weapon_pistol_trader_roadmap_01_02': + return "object/weapon/ranged/pistol/shared_pistol_scout_blaster.iff" + + if name == 'item_trader_pendant_01_02': + return "object/tangible/wearables/necklace/shared_necklace_s07.iff" + + if name == 'item_trader_clicky_01_02': + return "object/tangible/crafting/station/shared_generic_generic_tool.iff" + + if name == 'item_roadmap_belt_trader_01_02': + return "object/tangible/wearables/armor/zam/shared_armor_zam_wesell_belt.iff" + return \ No newline at end of file diff --git a/scripts/roadmap/trader_0d.py b/scripts/roadmap/trader_0d.py index 203b6ad9..7ac4a0d7 100644 --- a/scripts/roadmap/trader_0d.py +++ b/scripts/roadmap/trader_0d.py @@ -25,4 +25,30 @@ def getAction(): return 75 def getRewards(name): - return \ No newline at end of file + if name == 'item_npe_gen_craft_tool_trader_03_01': + return "object/tangible/crafting/base/shared_generic_base_tool.iff" + + if name == 'item_trader_backpack_01_02': + return "object/tangible/wearables/backpack/shared_backpack_s04.iff" + + if name == 'weapon_knife_trader_roadmap_01_02': + return "object/weapon/melee/knife/shared_knife_dagger.iff" + + if name == 'item_trader_ring_01_02': + return "object/tangible/wearables/ring/shared_ring_s02.iff" + + if name == 'item_trader_roadmap_jumpsuit_02_02': + return "object/tangible/wearables/bodysuit/shared_bodysuit_s01.iff" + + if name == 'weapon_pistol_trader_roadmap_01_02': + return "object/weapon/ranged/pistol/shared_pistol_scout_blaster.iff" + + if name == 'item_trader_pendant_01_02': + return "object/tangible/wearables/necklace/shared_necklace_s07.iff" + + if name == 'item_trader_clicky_01_02': + return "object/tangible/crafting/station/shared_generic_generic_tool.iff" + + if name == 'item_roadmap_belt_trader_01_02': + return "object/tangible/wearables/armor/zam/shared_armor_zam_wesell_belt.iff" + return \ No newline at end of file diff --git a/scripts/skillMods/expertise_strikethrough_chance.py b/scripts/skillMods/expertise_strikethrough_chance.py index b5c5e291..47e3d763 100644 --- a/scripts/skillMods/expertise_strikethrough_chance.py +++ b/scripts/skillMods/expertise_strikethrough_chance.py @@ -1,8 +1,10 @@ import sys def add(core, actor, skillMod, value): + core.skillModService.addSkillMod(actor, 'display_only_strikethrough', 100 * skillMod.getBase()) return def deduct(core, actor, skillMod, value): + core.skillModService.deductSkillMod(actor, 'display_only_strikethrough', 100 * skillMod.getBase()) return - \ No newline at end of file + diff --git a/scripts/static_spawns/dantooine/dantooine.py b/scripts/static_spawns/dantooine/dantooine.py new file mode 100644 index 00000000..ad56f992 --- /dev/null +++ b/scripts/static_spawns/dantooine/dantooine.py @@ -0,0 +1,21 @@ +import sys +from resources.datatables import Options +from resources.datatables import State + +def addPlanetSpawns(core, planet): +######################################################## +# DO NOT ADD ANYTHING ELSE TO THIS SCRIPT, PLEASE USE THE +# SUBFOLDERS FOR EACH PLANET AND CREATE NEW SCRIPTS FOR +# EACH AREA OF A PLANET. - LEVARRIS +######################################################## + stcSvc = core.staticService + # Blue Frog: Uncomment only when needed for testing. + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_character_builder.iff', 'dantooine', long(0), float(4196), float(9), float(5206), float(0.70), float(0.71)) + +######################################################## +# DO NOT ADD ANYTHING ELSE TO THIS SCRIPT, PLEASE USE THE +# SUBFOLDERS FOR EACH PLANET AND CREATE NEW SCRIPTS FOR +# EACH AREA OF A PLANET. - LEVARRIS +######################################################## + return + diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 1fb03377..5e6e0ceb 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -225,10 +225,6 @@ public class NGECore { private ObjectDatabase bountiesODB; public static boolean PACKET_DEBUG = false; - - - - public NGECore() { @@ -318,6 +314,7 @@ public class NGECore { harvesterService = new HarvesterService(this); mountService = new MountService(this); playerCityService = new PlayerCityService(this); + staticService = new StaticService(this); if (config.keyExists("JYTHONCONSOLE.PORT")) { int jythonPort = config.getInt("JYTHONCONSOLE.PORT"); @@ -375,6 +372,7 @@ public class NGECore { zoneDispatch.addService(mountService); zoneDispatch.addService(housingService); zoneDispatch.addService(playerCityService); + zoneDispatch.addService(staticService); if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") == 1) { zoneDispatch.addService(surveyService); @@ -383,7 +381,7 @@ public class NGECore { zoneServer = new MINAServer(zoneDispatch, config.getInt("ZONE.PORT")); zoneServer.start(); - staticService = new StaticService(this); + //Start terrainList // Original Planets terrainService.addPlanet(1, "tatooine", "terrain/tatooine.trn", true); @@ -449,7 +447,6 @@ public class NGECore { travelService.loadTravelPoints(); simulationService = new SimulationService(this); - objectService.loadBuildings(); if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") > 0) { resourceService.loadResourceRoots(); @@ -457,16 +454,15 @@ public class NGECore { } terrainService.loadSnapShotObjects(); - objectService.loadServerTemplates(); + objectService.loadServerTemplates(); + objectService.loadBuildings(); + harvesterService.loadHarvesters(); + simulationService.insertSnapShotObjects(); simulationService.insertPersistentBuildings(); // Zone services that need to be loaded after the above zoneDispatch.addService(simulationService); - - // Static Spawns - staticService.spawnStatics(); - guildService = new GuildService(this); zoneDispatch.addService(guildService); @@ -484,7 +480,6 @@ public class NGECore { instanceService = new InstanceService(this); zoneDispatch.addService(instanceService); - weatherService = new WeatherService(this); weatherService.loadPlanetSettings(); @@ -494,6 +489,8 @@ public class NGECore { spawnService.loadDynamicGroups();; spawnService.loadSpawnAreas(); + staticService.spawnStatics(); + equipmentService.loadBonusSets(); retroService.run(); diff --git a/src/protocol/swg/CharacterSheetResponseMessage.java b/src/protocol/swg/CharacterSheetResponseMessage.java index 70e14124..bdb6531d 100644 --- a/src/protocol/swg/CharacterSheetResponseMessage.java +++ b/src/protocol/swg/CharacterSheetResponseMessage.java @@ -49,11 +49,11 @@ public class CharacterSheetResponseMessage extends SWGMessage { public IoBuffer serialize() { CreatureObject creature = (CreatureObject) player.getContainer(); - if (creature != null) { + if (creature != null && player != null) { SWGObject desCloner = null; - if (creature.getAttachment("preDesignatedCloner") != null) - desCloner = NGECore.getInstance().objectService.getObject((long) creature.getAttachment("preDesignatedCloner")); + if (player.getBindLocation() != 0) + desCloner = NGECore.getInstance().objectService.getObject(player.getBindLocation()); String clonerPlanet = ""; String spouse = ""; diff --git a/src/protocol/swg/CreateClientPathMessage.java b/src/protocol/swg/CreateClientPathMessage.java index 37a6d571..930f9eb2 100644 --- a/src/protocol/swg/CreateClientPathMessage.java +++ b/src/protocol/swg/CreateClientPathMessage.java @@ -26,8 +26,8 @@ import java.util.List; import org.apache.mina.core.buffer.IoBuffer; -import resources.common.StringUtilities; import engine.resources.common.CRC; +import engine.resources.common.StringUtilities; import engine.resources.scene.Point3D; public class CreateClientPathMessage extends SWGMessage { diff --git a/src/protocol/swg/OkMessage.java b/src/protocol/swg/OkMessage.java index 4c31f533..a5bc1276 100644 --- a/src/protocol/swg/OkMessage.java +++ b/src/protocol/swg/OkMessage.java @@ -4,7 +4,7 @@ import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; -import resources.common.StringUtilities; +import engine.resources.common.StringUtilities; public class OkMessage extends SWGMessage { diff --git a/src/protocol/swg/chat/ChatOnLeaveRoom.java b/src/protocol/swg/chat/ChatOnLeaveRoom.java index 1fecfe5f..a45b1def 100644 --- a/src/protocol/swg/chat/ChatOnLeaveRoom.java +++ b/src/protocol/swg/chat/ChatOnLeaveRoom.java @@ -25,8 +25,8 @@ import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import engine.resources.common.StringUtilities; import protocol.swg.SWGMessage; -import resources.common.StringUtilities; public class ChatOnLeaveRoom extends SWGMessage { diff --git a/src/protocol/swg/chat/ChatSendToRoom.java b/src/protocol/swg/chat/ChatSendToRoom.java index 1c603c3c..302390de 100644 --- a/src/protocol/swg/chat/ChatSendToRoom.java +++ b/src/protocol/swg/chat/ChatSendToRoom.java @@ -26,8 +26,8 @@ import java.nio.ByteBuffer; import org.apache.mina.core.buffer.IoBuffer; +import engine.resources.common.StringUtilities; import protocol.swg.SWGMessage; -import resources.common.StringUtilities; public class ChatSendToRoom extends SWGMessage { diff --git a/src/protocol/swg/objectControllerObjects/MissionListRequest.java b/src/protocol/swg/objectControllerObjects/MissionListRequest.java index 5e7aa208..974b69cd 100644 --- a/src/protocol/swg/objectControllerObjects/MissionListRequest.java +++ b/src/protocol/swg/objectControllerObjects/MissionListRequest.java @@ -23,8 +23,8 @@ package protocol.swg.objectControllerObjects; import org.apache.mina.core.buffer.IoBuffer; +import engine.resources.common.StringUtilities; import resources.common.Console; -import resources.common.StringUtilities; public class MissionListRequest extends ObjControllerObject { diff --git a/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java b/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java index 092b2556..c9387ffa 100644 --- a/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java +++ b/src/protocol/swg/objectControllerObjects/NpcConversationOptions.java @@ -26,9 +26,9 @@ import java.util.Vector; import org.apache.mina.core.buffer.IoBuffer; +import engine.resources.objects.Delta; import protocol.swg.ObjControllerMessage; import resources.common.ConversationOption; -import resources.objects.Delta; public class NpcConversationOptions extends ObjControllerObject { diff --git a/src/protocol/swg/objectControllerObjects/ShowFlyText.java b/src/protocol/swg/objectControllerObjects/ShowFlyText.java index 39530a87..71b32631 100644 --- a/src/protocol/swg/objectControllerObjects/ShowFlyText.java +++ b/src/protocol/swg/objectControllerObjects/ShowFlyText.java @@ -25,10 +25,10 @@ import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import engine.resources.common.RGB; +import engine.resources.common.Stf; import protocol.swg.ObjControllerMessage; import resources.common.OutOfBand; -import resources.common.RGB; -import resources.common.Stf; public class ShowFlyText extends ObjControllerObject { diff --git a/src/resources/buffs/Buff.java b/src/resources/buffs/Buff.java index 72728526..4f0656ff 100644 --- a/src/resources/buffs/Buff.java +++ b/src/resources/buffs/Buff.java @@ -32,15 +32,13 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.buffer.SimpleBufferAllocator; -import resources.objects.IDelta; import resources.objects.creature.CreatureObject; import com.sleepycat.persist.model.NotPersistent; -import com.sleepycat.persist.model.Persistent; import engine.resources.common.CRC; +import engine.resources.objects.IDelta; -@Persistent(version=10) public class Buff implements IDelta, Serializable { private static final long serialVersionUID = 1L; diff --git a/src/resources/buffs/BuffItem.java b/src/resources/buffs/BuffItem.java index 208df3f6..0c46f9ce 100644 --- a/src/resources/buffs/BuffItem.java +++ b/src/resources/buffs/BuffItem.java @@ -23,9 +23,6 @@ package resources.buffs; import java.io.Serializable; -import com.sleepycat.persist.model.Persistent; - -@Persistent public class BuffItem implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/resources/buffs/DamageOverTime.java b/src/resources/buffs/DamageOverTime.java index d1aa8bc9..fcd91ad5 100644 --- a/src/resources/buffs/DamageOverTime.java +++ b/src/resources/buffs/DamageOverTime.java @@ -25,9 +25,7 @@ import java.io.Serializable; import java.util.concurrent.ScheduledFuture; import com.sleepycat.persist.model.NotPersistent; -import com.sleepycat.persist.model.Persistent; -@Persistent(version=1) public class DamageOverTime implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/resources/common/BountyListItem.java b/src/resources/common/BountyListItem.java index 10033656..3b09ec0f 100644 --- a/src/resources/common/BountyListItem.java +++ b/src/resources/common/BountyListItem.java @@ -33,7 +33,7 @@ public class BountyListItem implements Serializable { private static final long serialVersionUID = 1L; @PrimaryKey - private long objectId; + private long objectID; private int creditReward; private String profession; private String faction; @@ -44,8 +44,8 @@ public class BountyListItem implements Serializable { public BountyListItem() { } - public BountyListItem(long objectId, int creditReward, String profession, String faction, String name) { - this.objectId = objectId; + public BountyListItem(long objectID, int creditReward, String profession, String faction, String name) { + this.objectID = objectID; this.creditReward = creditReward; this.profession = profession; this.faction = faction; @@ -54,11 +54,11 @@ public class BountyListItem implements Serializable { this.setBountyPlacers(new ArrayList()); } - public long getObjectId() { - return objectId; + public long getObjectID() { + return objectID; } - public void setObjectId(long objectId) { - this.objectId = objectId; + public void setObjectID(long objectID) { + this.objectID = objectID; } public int getCreditReward() { return creditReward; diff --git a/src/resources/common/Console.java b/src/resources/common/Console.java index 292e78e3..770eb5b2 100644 --- a/src/resources/common/Console.java +++ b/src/resources/common/Console.java @@ -24,12 +24,15 @@ package resources.common; import java.util.Calendar; public class Console { + public static void println(String string) { Calendar cal = Calendar.getInstance(); System.out.println(cal.getTime() + ": " + string); } + public static void print(String string) { Calendar cal = Calendar.getInstance(); System.out.print(cal.getTime() + ": " + string); } + } diff --git a/src/resources/common/Forager.java b/src/resources/common/Forager.java index 6e27a207..66b11041 100644 --- a/src/resources/common/Forager.java +++ b/src/resources/common/Forager.java @@ -27,13 +27,10 @@ import java.util.Random; import java.util.Vector; import engine.resources.objects.SWGObject; -import engine.resources.scene.Planet; import engine.resources.scene.Point3D; -import engine.resources.scene.Quaternion; import main.NGECore; import resources.datatables.Options; import resources.loot.LootGroup; -import resources.objects.cell.CellObject; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; import resources.objects.tangible.TangibleObject; diff --git a/src/resources/common/OutOfBand.java b/src/resources/common/OutOfBand.java index be36d672..ed4909f8 100644 --- a/src/resources/common/OutOfBand.java +++ b/src/resources/common/OutOfBand.java @@ -24,11 +24,11 @@ package resources.common; import java.nio.ByteOrder; import java.util.Vector; -import resources.common.StringUtilities; -import resources.objects.Delta; - import org.apache.mina.core.buffer.IoBuffer; +import engine.resources.common.StringUtilities; +import engine.resources.objects.Delta; + public class OutOfBand { private Vector prosePackages = new Vector(); diff --git a/src/resources/common/ProsePackage.java b/src/resources/common/ProsePackage.java index 6af9bbe4..22549d40 100644 --- a/src/resources/common/ProsePackage.java +++ b/src/resources/common/ProsePackage.java @@ -21,6 +21,8 @@ ******************************************************************************/ package resources.common; +import engine.resources.common.Stf; + public class ProsePackage { /* diff --git a/src/resources/common/RGB.java b/src/resources/common/RGB.java deleted file mode 100644 index 50723be5..00000000 --- a/src/resources/common/RGB.java +++ /dev/null @@ -1,37 +0,0 @@ -package resources.common; - -import resources.objects.Delta; - -public class RGB extends Delta { - - private byte red, green, blue; - - public RGB(byte red, byte green, byte blue) { - this.red = red; - this.green = green; - this.blue = blue; - } - - public RGB(int red, int green, int blue) { - this.red = (byte) red; - this.green = (byte) green; - this.blue = (byte) blue; - } - - public byte getRed() { - return red; - } - - public byte getGreen() { - return green; - } - - public byte getBlue() { - return blue; - } - - public byte[] getBytes() { - return new byte[] { red, green, blue }; - } - -} diff --git a/src/resources/common/Stf.java b/src/resources/common/Stf.java deleted file mode 100644 index 8907ecba..00000000 --- a/src/resources/common/Stf.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * 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 resources.common; - -import org.apache.mina.core.buffer.IoBuffer; - -import resources.objects.Delta; - -import com.sleepycat.persist.model.Persistent; - -@Persistent -public class Stf extends Delta { - - private AString stfFilename = new AString(""); - private int spacer = 0; - private AString stfName = new AString(""); - - public Stf(String stfFilename, int spacer, String stfName) { - this.stfFilename = new AString(stfFilename); - this.spacer = spacer; - this.stfName = new AString(stfName); - } - - public Stf(String stf) { - setString(stf); - } - - public Stf() { - - } - - public String getStfFilename() { - synchronized(objectMutex) { - return stfFilename.get(); - } - } - - public void setStfFilename(String stfFilename) { - synchronized(objectMutex) { - this.stfFilename = new AString(stfFilename); - } - } - - public int getSpacer() { - synchronized(objectMutex) { - return spacer; - } - } - - public void setSpacer(int spacer) { - synchronized(objectMutex) { - this.spacer = spacer; - } - } - - public String getStfName() { - synchronized(objectMutex) { - return stfName.get(); - } - } - - public void setStfName(String stfName) { - synchronized(objectMutex) { - this.stfName = new AString(stfName); - } - } - - public String getString() { - synchronized(objectMutex) { - return ("@" + stfFilename.get() + ":" + stfName.get()); - } - } - - public void setString(String stf) { - synchronized(objectMutex) { - if (stf == null || stf.equals("")) { - stfFilename.set(""); - stfName.set(""); - } else if (stf.contains(":")) { - stf = stf.replace("@", ""); - stfFilename.set(stf.split(":")[0]); - stfName.set(stf.split(":")[1]); - } - } - } - - public byte[] getBytes() { - synchronized(objectMutex) { - int size = stfFilename.getBytes().length + 4 + stfName.getBytes().length; - - IoBuffer buffer = createBuffer(size); - buffer.put(stfFilename.getBytes()); - buffer.putInt(spacer); - buffer.put(stfName.getBytes()); - buffer.flip(); - - return buffer.array(); - } - } - -} diff --git a/src/resources/common/StringUtilities.java b/src/resources/common/StringUtilities.java deleted file mode 100644 index e7d34d3a..00000000 --- a/src/resources/common/StringUtilities.java +++ /dev/null @@ -1,187 +0,0 @@ -/******************************************************************************* - * 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 resources.common; - -import java.io.UnsupportedEncodingException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import org.apache.mina.core.buffer.IoBuffer; - -import engine.resources.common.Utilities; - -public class StringUtilities { - - final protected static char[] hexArray = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; - - public static String getAsciiString(ByteBuffer buffer) { - return getString(buffer, "US-ASCII"); - } - - public static String getAsciiString(IoBuffer buffer) { - return getString(buffer, "US-ASCII"); - } - - public static String getAsciiString(IoBuffer buffer, boolean integer) { - return getString(buffer, "US-ASCII", integer); - } - - public static String getUnicodeString(ByteBuffer buffer) { - return getString(buffer, "UTF-16LE"); - } - - public static String getUnicodeString(IoBuffer buffer) { - return getString(buffer, "UTF-16LE"); - } - - public static String getUnicodeString(IoBuffer buffer, boolean integer) { - return getString(buffer, "UTF-16LE", integer); - } - - public static byte[] getAsciiString(String string) { - return getString(string, "US-ASCII"); - } - - public static byte[] getUnicodeString(String string) { - return getString(string, "UTF-16LE"); - } - - private static String getString(ByteBuffer buffer, String charFormat) { - String result; - int length; - - if (charFormat == "UTF-16LE") { - length = buffer.order(ByteOrder.LITTLE_ENDIAN).getInt(); - } else { - length = buffer.order(ByteOrder.LITTLE_ENDIAN).getShort(); - } - - int bufferPosition = buffer.position(); - - try { - result = new String(buffer.array(), bufferPosition, length, charFormat); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - return ""; - } - - buffer.position(bufferPosition + length); - - return result; - } - - private static String getString(IoBuffer buffer, String charFormat) { - String result; - int length; - - if (charFormat == "UTF-16LE") { - length = buffer.order(ByteOrder.LITTLE_ENDIAN).getInt(); - } else { - length = buffer.order(ByteOrder.LITTLE_ENDIAN).getShort(); - } - - int bufferPosition = buffer.position(); - - try { - result = new String(buffer.array(), bufferPosition, length, charFormat); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - return ""; - } - - buffer.position(bufferPosition + length); - - return result; - } - - private static String getString(IoBuffer buffer, String charFormat, boolean integer) { - String result; - int length; - - if (charFormat == "UTF-16LE") { - if (integer) { - length = buffer.order(ByteOrder.LITTLE_ENDIAN).getInt() * 2; - } else { - length = buffer.order(ByteOrder.LITTLE_ENDIAN).getInt(); - } - } else { - if (integer) { - length = buffer.order(ByteOrder.LITTLE_ENDIAN).getInt(); - } else { - length = buffer.order(ByteOrder.LITTLE_ENDIAN).getShort(); - } - } - - int bufferPosition = buffer.position(); - - try { - result = new String(buffer.array(), bufferPosition, length, charFormat); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - return ""; - } - - buffer.position(bufferPosition + length); - - return result; - } - - private static byte[] getString(String string, String charFormat) { - ByteBuffer result; - int length = 2 + string.length(); - - if (charFormat == "UTF-16LE") { - result = ByteBuffer.allocate(length * 2).order(ByteOrder.LITTLE_ENDIAN); - result.putInt(string.length()); - } else { - result = ByteBuffer.allocate(length).order(ByteOrder.LITTLE_ENDIAN); - result.putShort((short)string.length()); - } - - try { - result.put(string.getBytes(charFormat)); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - return new byte[] { }; - } - - return result.array(); - } - - public static String bytesToHex(byte[] bytes) { - char[] hexChars = new char[bytes.length * 2]; - int v; - - for ( int j = 0; j < bytes.length; j++ ) { - v = bytes[j] & 0xFF; - hexChars[j * 2] = hexArray[v >>> 4]; - hexChars[j * 2 + 1] = hexArray[v & 0x0F]; - } - - return new String(hexChars); - } - - public static void printBytes(byte[] bytes) { - System.out.println(Utilities.getHexString(bytes)); - } - -} diff --git a/src/resources/common/UString.java b/src/resources/common/UString.java deleted file mode 100644 index 37564bd1..00000000 --- a/src/resources/common/UString.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * 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 resources.common; - -import java.io.Serializable; -import java.io.UnsupportedEncodingException; - -import com.sleepycat.persist.model.Persistent; - -import resources.objects.Delta; - -@Persistent -public final class UString extends Delta implements Serializable { - - private static final long serialVersionUID = 1L; - private String string; - - public UString() { - string = ""; - } - - public UString(String string) { - this.string = ((string == null) ? "" : string); - } - - public String get() { - synchronized(objectMutex) { - return string; - } - } - - public void set(String string) { - synchronized(objectMutex) { - this.string = string; - } - } - - public int length() { - synchronized(objectMutex) { - return string.length(); - } - } - - public byte[] getBytes() { - synchronized(objectMutex) { - try { - return createBuffer(4 + (string.length() * 2)).putInt(string.length()).put(string.getBytes("UTF-16LE")).flip().array(); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - return new byte[] { 0x00, 0x00, 0x00, 0x00 }; - } - } - } - -} diff --git a/src/resources/common/AString.java b/src/resources/craft/DraftSchematic.java similarity index 58% rename from src/resources/common/AString.java rename to src/resources/craft/DraftSchematic.java index 14677cb6..9f203e2f 100644 --- a/src/resources/common/AString.java +++ b/src/resources/craft/DraftSchematic.java @@ -19,52 +19,68 @@ * 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 resources.common; +package resources.craft; import java.io.Serializable; -import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; -import com.sleepycat.persist.model.Persistent; +import engine.resources.objects.Delta; -import resources.objects.Delta; - -@Persistent -public final class AString extends Delta implements Serializable { +public class DraftSchematic extends Delta implements Serializable { private static final long serialVersionUID = 1L; - private String string; - public AString() { - string = ""; + private int serverSchematicCrc = 0; + private int schematicCrc = 0; + private int amount = 1; + + public DraftSchematic(int serverSchematicCrc, int schematicCrc, int amount) { + this.serverSchematicCrc = serverSchematicCrc; + this.schematicCrc = schematicCrc; + this.amount = amount; } - public AString(String string) { - this.string = ((string == null) ? "" : string); + public DraftSchematic(int serverSchematicCrc, int schematicCrc) { + this.serverSchematicCrc = serverSchematicCrc; + this.schematicCrc = schematicCrc; } - public String get() { + public DraftSchematic() { + + } + + public int getServerSchematicCrc() { synchronized(objectMutex) { - return string; + return serverSchematicCrc; } } - public void set(String string) { + public int getSchematicCrc() { synchronized(objectMutex) { - this.string = string; + return schematicCrc; } } - public short length() { + public int getAmount() { synchronized(objectMutex) { - return (short) string.length(); + return amount; + } + } + + public void setAmount(int amount) { + synchronized(objectMutex) { + this.amount = amount; } } public byte[] getBytes() { synchronized(objectMutex) { - return IoBuffer.allocate(2 + string.length(), false).order(ByteOrder.LITTLE_ENDIAN).putShort((short) string.length()).put(string.getBytes()).flip().array(); + IoBuffer buffer = createBuffer(12); + buffer.putInt(serverSchematicCrc); + buffer.putInt(schematicCrc); + buffer.putInt(amount); + return buffer.array(); } } diff --git a/src/resources/datatables/LightsaberColors.java b/src/resources/datatables/LightsaberColors.java new file mode 100644 index 00000000..cb2028c5 --- /dev/null +++ b/src/resources/datatables/LightsaberColors.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * 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 resources.datatables; + +import org.python.google.common.collect.BiMap; +import org.python.google.common.collect.HashBiMap; + +public final class LightsaberColors { + + public static BiMap map = HashBiMap.create(); + + static + { + // Basic color crystals with the basic lightsaber shader + map.put("Red", 0); + map.put("Dark Red", 1); + map.put("Light Green", 2); + map.put("Dark Green", 3); + map.put("Blue", 4); + map.put("Dark Blue", 5); + map.put("Yellow", 6); + map.put("Dark Yellow", 7); + map.put("Light Purple", 8); + map.put("Dark Purple", 9); + map.put("Orange", 10); + map.put("Brown", 11); + map.put("Allya's Exile", 12); + map.put("Kun's Blood", 13); + map.put("Bondara's Folly", 14); + map.put("Ulic's Redemption", 15); + map.put("Bane's Heart", 16); + map.put("Gallia's Intuition", 17); + map.put("Prowess of Plo Koon", 18); + map.put("B'Nar's Sacrifice", 19); + map.put("Windu's Guile", 20); + map.put("Mundi's Response", 21); + map.put("Strength of Luminaria", 22); + map.put("Baaa's Wisdom", 23); + map.put("Quintessence of the Force", 24); + map.put("Dawn of Dagobah", 25); + map.put("Horn's Future", 26); + map.put("Allya's Redemption", 27); + map.put("Kenobi's Legacy", 28); + map.put("Sunrider's Destiny", 29); + map.put("Kit's Ferocity", 30); + + // Special crystals that have seperate shaders - the 256 is for a hacky way to set blade type and color without more code + map.put("Lava", 256 + 1); + map.put("Permafrost", 256 + 2); + map.put("Blackwing Bezoar", 256 + 3); + } + + public static int getByName(String colorName) + { + return map.get(colorName); + } + + public static String get(int index) + { + return map.inverse().get(index); + } + + +} diff --git a/src/resources/datatables/STF.java b/src/resources/datatables/STF.java new file mode 100644 index 00000000..411b929a --- /dev/null +++ b/src/resources/datatables/STF.java @@ -0,0 +1,29 @@ +package resources.datatables; + +import engine.clientdata.StfTable; + +public class STF +{ + /* + Returns a string containing the value of a key in the SWG STF path; + Example: get("@cmd_err:success_prose") returns "The command %TO was a success." + */ + static public String get(String stfPath) + { + stfPath = stfPath.replace("@", ""); + String stfFile = stfPath.split(":")[0]; + String stfKey = stfPath.split(":")[1]; + + try + { + StfTable stf = new StfTable("clientdata/string/en/" + stfFile + ".stf"); + for (int s = 1; s < stf.getRowCount(); s++) + { + if(stf.getStringById(s).getKey() != null && stf.getStringById(s).getKey().equals(stfKey)) return stf.getStringById(s).getValue(); + } + } + catch (Exception e) { } + + return ""; + } +} diff --git a/src/resources/gcw/CurrentServerGCWZoneHistory.java b/src/resources/gcw/CurrentServerGCWZoneHistory.java index c8f81fda..b98bba3b 100644 --- a/src/resources/gcw/CurrentServerGCWZoneHistory.java +++ b/src/resources/gcw/CurrentServerGCWZoneHistory.java @@ -25,11 +25,8 @@ import java.io.Serializable; import org.apache.mina.core.buffer.IoBuffer; -import com.sleepycat.persist.model.Persistent; +import engine.resources.objects.Delta; -import resources.objects.Delta; - -@Persistent(version=0) public class CurrentServerGCWZoneHistory extends Delta implements Cloneable, Serializable { private static final long serialVersionUID = 1L; diff --git a/src/resources/gcw/CurrentServerGCWZonePercent.java b/src/resources/gcw/CurrentServerGCWZonePercent.java index 6e5bf56a..8829b1b3 100644 --- a/src/resources/gcw/CurrentServerGCWZonePercent.java +++ b/src/resources/gcw/CurrentServerGCWZonePercent.java @@ -27,12 +27,9 @@ import java.math.MathContext; import org.apache.mina.core.buffer.IoBuffer; -import com.sleepycat.persist.model.Persistent; - +import engine.resources.objects.Delta; import engine.resources.scene.Point2D; -import resources.objects.Delta; -@Persistent(version=0) public class CurrentServerGCWZonePercent extends Delta implements Cloneable, Serializable { private static final long serialVersionUID = 1L; diff --git a/src/resources/gcw/OtherServerGCWZonePercent.java b/src/resources/gcw/OtherServerGCWZonePercent.java index 15d9da9d..d97bf098 100644 --- a/src/resources/gcw/OtherServerGCWZonePercent.java +++ b/src/resources/gcw/OtherServerGCWZonePercent.java @@ -25,11 +25,8 @@ import java.io.Serializable; import org.apache.mina.core.buffer.IoBuffer; -import com.sleepycat.persist.model.Persistent; +import engine.resources.objects.Delta; -import resources.objects.Delta; - -@Persistent(version=0) public class OtherServerGCWZonePercent extends Delta implements Cloneable, Serializable { private static final long serialVersionUID = 1L; diff --git a/src/resources/guild/Guild.java b/src/resources/guild/Guild.java index 7ecdd2bb..b45d8dca 100644 --- a/src/resources/guild/Guild.java +++ b/src/resources/guild/Guild.java @@ -26,12 +26,9 @@ import java.util.List; import org.apache.mina.core.buffer.IoBuffer; -import com.sleepycat.persist.model.Persistent; - -import resources.objects.Delta; +import engine.resources.objects.Delta; import engine.resources.objects.SWGObject; -@Persistent(version=0) public class Guild extends Delta implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/resources/loot/LootGroup.java b/src/resources/loot/LootGroup.java index a43e435d..9df63790 100644 --- a/src/resources/loot/LootGroup.java +++ b/src/resources/loot/LootGroup.java @@ -29,7 +29,6 @@ import com.sleepycat.persist.model.Persistent; * @author Charon */ -@Persistent(version=0) public class LootGroup implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/resources/loot/LootRollSession.java b/src/resources/loot/LootRollSession.java index addd0af8..b20f1030 100644 --- a/src/resources/loot/LootRollSession.java +++ b/src/resources/loot/LootRollSession.java @@ -49,7 +49,10 @@ public class LootRollSession { private int lootedObjectLevel=0; private int lootedObjectDifficulty=0; - public LootRollSession(){ + public LootRollSession() + { + droppedItems = new ArrayList(); + errorMessages = new ArrayList(); } public LootRollSession(CreatureObject requester, TangibleObject lootedObject){ @@ -114,8 +117,9 @@ public class LootRollSession { return sessionPlanet; } - public void setSessionPlanet(Planet planet) { - sessionPlanet = planet; + public void setSessionPlanet(Planet planet) + { + this.sessionPlanet = planet; } public List getErrorMessages() { diff --git a/src/resources/objectives/BountyMissionObjective.java b/src/resources/objectives/BountyMissionObjective.java index 09a928f4..6c6dcff1 100644 --- a/src/resources/objectives/BountyMissionObjective.java +++ b/src/resources/objectives/BountyMissionObjective.java @@ -29,7 +29,6 @@ import java.util.concurrent.atomic.AtomicInteger; import protocol.swg.CommPlayerMessage; import protocol.swg.PlayClientEffectLocMessage; -import protocol.swg.UpdatePVPStatusMessage; import engine.resources.common.CRC; import engine.resources.container.Traverser; import engine.resources.objects.SWGObject; @@ -79,7 +78,7 @@ public class BountyMissionObjective extends MissionObjective { if (isActivated()) return; - BountyListItem bountyTarget = core.missionService.getBountyListItem(getMissionObject().getBountyObjId()); + BountyListItem bountyTarget = core.missionService.getBountyListItem(getMissionObject().getBountyMarkId()); if (bountyTarget == null) { core.missionService.handleMissionAbort(player, getMissionObject()); @@ -87,9 +86,9 @@ public class BountyMissionObjective extends MissionObjective { return; } - bountyTarget.addBountyHunter(player.getObjectId()); + bountyTarget.addBountyHunter(player.getObjectID()); - setMarkObjId(bountyTarget.getObjectId()); + setMarkObjId(bountyTarget.getObjectID()); String message = "@mission/mission_bounty_informant:target_hard_" + Integer.toString(new Random().nextInt(4) + 1); @@ -111,11 +110,7 @@ public class BountyMissionObjective extends MissionObjective { player.getPlayerObject().setBountyMissionId(getMissionObject().getObjectId()); - /*CreatureObject target = (CreatureObject) core.objectService.getObject(markObjId); - if (target != null && target.getPlanetId() == player.getPlanetId()) { - UpdatePVPStatusMessage upvpm = new UpdatePVPStatusMessage(player.getObjectID(), core.factionService.calculatePvpStatus(player, target), player.getFaction()); - player.getClient().getSession().write(upvpm.serialize()); - }*/ + player.updatePvpStatus(); } @@ -133,12 +128,15 @@ public class BountyMissionObjective extends MissionObjective { else player.addBankCredits(bounty.getCreditReward()); + bounty.removeBountyHunter(player.getObjectId()); + notifyBountyPlacers(core, player, bounty); clearActiveMissions(core, bounty); core.missionService.removeBounty(markObjId); player.getPlayerObject().setBountyMissionId(0); + player.updatePvpStatus(); } @Override @@ -152,6 +150,7 @@ public class BountyMissionObjective extends MissionObjective { bounty.removeBountyHunter(player.getObjectId()); player.getPlayerObject().setBountyMissionId(0); + player.updatePvpStatus(); } @Override @@ -184,6 +183,7 @@ public class BountyMissionObjective extends MissionObjective { public void clearActiveMissions(NGECore core, BountyListItem bounty) { bounty.getAssignedHunters().forEach(id -> { + CreatureObject hunter = (CreatureObject) core.objectService.getObject(id); if (hunter != null) { @@ -204,7 +204,7 @@ public class BountyMissionObjective extends MissionObjective { } public void checkBountyActiveStatus(NGECore core) { - BountyListItem bountyTarget = core.missionService.getBountyListItem(getMissionObject().getBountyObjId()); + BountyListItem bountyTarget = core.missionService.getBountyListItem(getMissionObject().getBountyMarkId()); CreatureObject player = (CreatureObject) getMissionObject().getGrandparent(); if (bountyTarget == null || !bountyTarget.getAssignedHunters().contains(player.getObjectId())) { @@ -289,7 +289,7 @@ public class BountyMissionObjective extends MissionObjective { return; } else { - if (updates.get() >= 5) { + if (updates.get() >= 6) { actor.sendSystemMessage("@mission/mission_generic:target_track_lost", DisplayType.Broadcast); cancelLocationUpdates(); return; @@ -306,12 +306,12 @@ public class BountyMissionObjective extends MissionObjective { waypoint.setPlanetCRC(CRC.StringtoCRC(target.getPlanet().getName())); waypoint.setStringAttribute("", ""); getMissionObject().setAttachedWaypoint(waypoint); - actor.sendSystemMessage("@mission/mission_generic:target_location_updated_ground", DisplayType.Broadcast); } else { missionWp.setPosition(target.getWorldPosition()); mission.setAttachedWaypoint(missionWp); - actor.sendSystemMessage("@mission/mission_generic:target_location_updated_ground", DisplayType.Broadcast); } + actor.sendSystemMessage("@mission/mission_generic:target_location_updated_ground", DisplayType.Broadcast); + actor.sendSystemMessage("@mission/mission_generic:target_continue_tracking", DisplayType.Broadcast); updates.getAndIncrement(); } } diff --git a/src/resources/objectives/SurveyMissionObjective.java b/src/resources/objectives/SurveyMissionObjective.java new file mode 100644 index 00000000..025b15bf --- /dev/null +++ b/src/resources/objectives/SurveyMissionObjective.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * 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 resources.objectives; + +import java.util.concurrent.atomic.AtomicInteger; + +import engine.resources.scene.Point3D; +import main.NGECore; +import resources.datatables.DisplayType; +import resources.objects.creature.CreatureObject; +import resources.objects.mission.MissionObject; +import services.mission.MissionObjective; + +public class SurveyMissionObjective extends MissionObjective{ + + private static final long serialVersionUID = 1L; + + private String resourceFamily; + private Point3D pickupLocation; + private String pickupPlanet; + private int surveyMissionNum; + + public SurveyMissionObjective(MissionObject parent) { + super(parent); + } + + @Override + public void activate(NGECore core, CreatureObject player) { + pickupPlanet = player.getPlanet().getName(); + pickupLocation = player.getPosition(); + resourceFamily = getMissionObject().getMissionTargetName(); + + // This way will allow 2 survey missions at a time. + AtomicInteger number = new AtomicInteger(); + player.getSlottedObject("datapad").viewChildren(player, true, false, (obj) -> { + if (obj instanceof MissionObject && ((MissionObject) obj).getMissionType().equals("survey")) { number.getAndIncrement(); } + }); + player.setAttachment("surveyMission" + Integer.valueOf(number.get()), getMissionObject().getObjectID()); + surveyMissionNum = number.get(); + + player.sendSystemMessage("@mission/mission_generic:survey_start", DisplayType.Broadcast); + } + + @Override + public void complete(NGECore core, CreatureObject player) { + player.addBankCredits(getMissionObject().getCreditReward()); + player.setAttachment("surveyMission" + Integer.valueOf(surveyMissionNum), 0); + } + + @Override + public void abort(NGECore core, CreatureObject player) { + player.setAttachment("surveyMission" + Integer.valueOf(surveyMissionNum), 0); + } + + @Override + public void update(NGECore core, CreatureObject player) { + } + + public String getResourceFamily() { return resourceFamily; } + + public Point3D getPickupLocation() { return pickupLocation; } + + public String getPickupPlanet() { return pickupPlanet; } +} diff --git a/src/resources/objects/Delta.java b/src/resources/objects/Delta.java deleted file mode 100644 index 19033f03..00000000 --- a/src/resources/objects/Delta.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * 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 resources.objects; - -import java.io.Serializable; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -import org.apache.mina.core.buffer.IoBuffer; -import org.apache.mina.core.buffer.SimpleBufferAllocator; - -import com.sleepycat.persist.model.NotPersistent; -import com.sleepycat.persist.model.Persistent; - -import resources.common.StringUtilities; - -@Persistent -public abstract class Delta implements IDelta, Serializable { - - private static final long serialVersionUID = 1L; - @NotPersistent - protected transient Object objectMutex = new Object(); - @NotPersistent - private transient static SimpleBufferAllocator bufferPool = new SimpleBufferAllocator(); - - public Delta() { - - } - - public void init() { - objectMutex = new Object(); - } - - protected String getAsciiString(ByteBuffer buffer) { - return StringUtilities.getAsciiString(buffer); - } - - protected String getUnicodeString(ByteBuffer buffer) { - return StringUtilities.getUnicodeString(buffer); - } - - protected byte[] getAsciiString(String string) { - return StringUtilities.getAsciiString(string); - } - - protected byte[] getUnicodeString(String string) { - return StringUtilities.getUnicodeString(string); - } - - protected byte getBoolean(boolean variable) { - return ((byte) ((variable) ? 1 : 0)); - } - - public static IoBuffer createBuffer(int size) { - return IoBuffer.allocate(size, false).order(ByteOrder.LITTLE_ENDIAN); - } - - public static IoBuffer resizeBuffer(IoBuffer buffer) { - int size = buffer.position(); - return buffer == null ? createBuffer(0) : createBuffer(size).put(buffer.flip().array(), 0, size).flip(); - } - -} diff --git a/src/resources/objects/ObjectMessageBuilder.java b/src/resources/objects/ObjectMessageBuilder.java index 073e7c6e..20a294c8 100644 --- a/src/resources/objects/ObjectMessageBuilder.java +++ b/src/resources/objects/ObjectMessageBuilder.java @@ -24,25 +24,112 @@ package resources.objects; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.util.Map; import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.buffer.SimpleBufferAllocator; -import com.sleepycat.persist.model.NotPersistent; -import com.sleepycat.persist.model.Persistent; - import resources.common.Opcodes; - +import engine.resources.common.StringUtilities; +import engine.resources.objects.Baseline; +import engine.resources.objects.Builder; import engine.resources.objects.SWGObject; -@Persistent -public abstract class ObjectMessageBuilder { +public class ObjectMessageBuilder { + protected SWGObject object; - public SWGObject object; - @NotPersistent + public ObjectMessageBuilder(SWGObject object) { + this.object = object; + } + + public ObjectMessageBuilder() { + + } + + public void buildBaseline1(Map baselineBuilders, Map deltaBuilders) { + /* + baselineBuilders.put(5, new Builder { + public byte[] build() { + IoBuffer = Baseline.createBuffer(2); + buffer.putShort((short) 27); + return buffer.array(); + } + }); + + deltaBuilders.put(7, new Builder { + public byte[] build() { + IoBuffer = Baseline.createBuffer(4); + buffer.putInt(27); + return buffer.array(); + } + }); + */ + } + + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + + } + + public void buildBaseline4(Map baselineBuilders, Map deltaBuilders) { + + } + + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + + } + + public void buildBaseline7(Map baselineBuilders, Map deltaBuilders) { + + } + + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + + } + + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + + } + + public IoBuffer createBuffer(int size, boolean autoSize) { + return createBuffer(size).setAutoExpand(autoSize); + } + + public IoBuffer createBuffer(int size) { + return Baseline.createBuffer(size); + } + + protected byte getBoolean(boolean variable) { + return Baseline.getBoolean(variable); + } + + protected String getAsciiString(ByteBuffer buffer) { + return StringUtilities.getAsciiString(buffer); + } + + protected String getUnicodeString(ByteBuffer buffer) { + return StringUtilities.getUnicodeString(buffer); + } + + protected byte[] getAsciiString(String string) { + return StringUtilities.getAsciiString(string); + } + + protected byte[] getUnicodeString(String string) { + return StringUtilities.getUnicodeString(string); + } + + // Temporary for compatibility public SimpleBufferAllocator bufferPool = new SimpleBufferAllocator(); + public SWGObject getObject() { + return object; + } + + public void setObject(SWGObject object) { + this.object = object; + } + public IoBuffer createBaseline(String objectType, byte viewType, IoBuffer data, int size) { IoBuffer buffer = bufferPool.allocate(23 + size, false).order(ByteOrder.LITTLE_ENDIAN); @@ -83,92 +170,11 @@ public abstract class ObjectMessageBuilder { return buffer; } - public IoBuffer createDelta(String objectType, byte viewType, short updateCount, IoBuffer data, int size) { - IoBuffer buffer = bufferPool.allocate(25 + size, false).order(ByteOrder.LITTLE_ENDIAN); - - buffer.putShort((short) 5); - buffer.putInt(Opcodes.DeltasMessage); - buffer.putLong(object.getObjectID()); - try { - buffer.put(reverse(objectType).getBytes("US-ASCII")); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - buffer.put(viewType); - buffer.putInt(size); - buffer.putShort(updateCount); - buffer.put(data); - buffer.flip(); - - return buffer; - } - - public IoBuffer createDeltaObject(short updateType, IoBuffer data, int size) { - IoBuffer buffer = bufferPool.allocate(2 + size, false).order(ByteOrder.LITTLE_ENDIAN); - - buffer.putShort(updateType); - buffer.put(data.array()); - - return buffer; - } - - public SWGObject getObject() { return object; } - public void setObject(SWGObject object) { this.object = object; } - - public abstract void sendListDelta(byte viewType, short updateType, IoBuffer buffer); - - public abstract void sendBaselines(); - private String reverse(String reverseString) { if (reverseString.length() <= 1) return reverseString; return reverse(reverseString.substring(1, reverseString.length())) + reverseString.charAt(0); } - - protected String getAsciiString(ByteBuffer buffer) { return getString(buffer, "US-ASCII"); } - protected String getUnicodeString(ByteBuffer buffer) { return getString(buffer, "UTF-16LE"); } - protected byte[] getAsciiString(String string) { return getString(string, "US-ASCII"); } - protected byte[] getUnicodeString(String string) { return getString(string, "UTF-16LE"); } - private String getString(ByteBuffer buffer, String charFormat) { - String result; - int length; - if (charFormat == "UTF-16LE") - length = buffer.order(ByteOrder.LITTLE_ENDIAN).getInt(); - else - length = buffer.order(ByteOrder.LITTLE_ENDIAN).getShort(); - - int bufferPosition = buffer.position(); - try { - result = new String(buffer.array(), bufferPosition, length, charFormat); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - return ""; - } - buffer.position(bufferPosition + length); - - return result; - } - - private byte[] getString(String string, String charFormat) { - ByteBuffer result; - int length = 2 + string.length(); - if (charFormat == "UTF-16LE") { - result = ByteBuffer.allocate(length * 2).order(ByteOrder.LITTLE_ENDIAN); - result.putInt(string.length()); - } - else { - result = ByteBuffer.allocate(length).order(ByteOrder.LITTLE_ENDIAN); - result.putShort((short)string.length()); - } - try { - result.put(string.getBytes(charFormat)); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - return new byte[] { }; - } - return result.array(); - } - } diff --git a/src/resources/objects/SWGList.java b/src/resources/objects/SWGList.java index 9316760e..0a7e2d0d 100644 --- a/src/resources/objects/SWGList.java +++ b/src/resources/objects/SWGList.java @@ -22,7 +22,6 @@ package resources.objects; import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -30,72 +29,79 @@ import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Spliterator; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.UnaryOperator; import java.util.stream.Stream; -import main.NGECore; - import org.apache.mina.core.buffer.IoBuffer; import org.python.google.common.collect.Lists; -import com.sleepycat.persist.model.NotPersistent; -import com.sleepycat.persist.model.Persistent; - +import engine.resources.objects.Baseline; +import engine.resources.objects.Delta; +import engine.resources.objects.IDelta; import engine.resources.objects.SWGObject; -/* A SWGList element MUST implement IDelta, or it will refuse to work with it */ +/* A SWGList element should extend Delta or implement IDelta */ -@Persistent public class SWGList implements List, Serializable { private static final long serialVersionUID = 1L; - private List list = new ArrayList(); - @NotPersistent - private transient int updateCounter = 1; - private long objectId; - private transient ObjectMessageBuilder messageBuilder; + + private List list = new CopyOnWriteArrayList(); + private transient int updateCounter = 0; private byte viewType; private short updateType; - @NotPersistent + private boolean addByte; protected transient Object objectMutex = new Object(); + private transient SWGObject object; public SWGList() { } - public SWGList(long objectId, int viewType, int updateType) { - this.objectId = objectId; + public SWGList(SWGObject object, int viewType, int updateType, boolean addByte) { this.viewType = (byte) viewType; this.updateType = (short) updateType; + this.addByte = addByte; + this.object = object; } - public void init() { + public void init(SWGObject object) { objectMutex = new Object(); - updateCounter = 1; + updateCounter = 0; + this.object = object; + + for (Object item : list) { + try { + if (item instanceof IDelta) { + item.getClass().getMethod("init", new Class[] {}).invoke(item, new Object[] { }); + } + } catch (Exception e) { + e.printStackTrace(); + } + } } - @Override public boolean add(E e) { synchronized(objectMutex) { - if (list.add(e) && e instanceof IDelta) { - queue(item(1, list.lastIndexOf(e), ((IDelta) e).getBytes(), true, true)); + if (valid(e) && list.add(e)) { + queue(item(1, list.lastIndexOf(e), Baseline.toBytes(e), true, true)); return true; - } + } + return false; } } - @Override public void add(int index, E element) { synchronized(objectMutex) { - if (element instanceof IDelta) { + if (valid(element)) { list.add(index, element); - queue(item(1, index, ((IDelta) element).getBytes(), true, true)); + queue(item(1, index, Baseline.toBytes(element), true, true)); } } } - @Override public boolean addAll(Collection c) { synchronized(objectMutex) { if (!c.isEmpty()) { @@ -103,9 +109,9 @@ public class SWGList implements List, Serializable { boolean success = false; for (E element : c) { - if (element instanceof IDelta) { + if (valid(element)) { if (list.add(element)) { - buffer.add(item(1, list.lastIndexOf(element), ((IDelta) element).getBytes(), true, true)); + buffer.add(item(1, list.lastIndexOf(element), Baseline.toBytes(element), true, true)); success = true; } } else { @@ -124,16 +130,15 @@ public class SWGList implements List, Serializable { } } - @Override public boolean addAll(int index, Collection c) { synchronized(objectMutex) { if (!c.isEmpty()) { List buffer = new ArrayList(); for (E element : c) { - if (element instanceof IDelta) { + if (valid(element)) { list.add(index, element); - buffer.add(item(1, index, ((IDelta) element).getBytes(), true, true)); + buffer.add(item(1, index, Baseline.toBytes(element), true, true)); index++; } else { return false; @@ -149,7 +154,6 @@ public class SWGList implements List, Serializable { } } - @Override public void clear() { synchronized(objectMutex) { list.clear(); @@ -157,21 +161,22 @@ public class SWGList implements List, Serializable { } } - @Override public boolean contains(Object o) { synchronized(objectMutex) { return list.contains(o); } } - @Override public boolean containsAll(Collection c) { synchronized(objectMutex) { return list.containsAll(c); } } - @Override + public void forEach(Consumer action) { + list.forEach(action); + } + public E get(int index) { synchronized(objectMutex) { return list.get(index); @@ -182,49 +187,48 @@ public class SWGList implements List, Serializable { return list; } - @Override public int indexOf(Object o) { synchronized(objectMutex) { return list.indexOf(o); } } - @Override public boolean isEmpty() { synchronized(objectMutex) { return list.isEmpty(); } } - @Override public Iterator iterator() { synchronized(objectMutex) { return list.iterator(); } } - @Override public int lastIndexOf(Object o) { synchronized(objectMutex) { return list.lastIndexOf(o); } } - @Override public ListIterator listIterator() { synchronized(objectMutex) { return list.listIterator(); } } - @Override public ListIterator listIterator(int index) { synchronized(objectMutex) { return listIterator(index); } } - @Override + public Stream parallelStream() { + synchronized(objectMutex) { + return list.parallelStream(); + } + } + public boolean remove(Object o) { synchronized(objectMutex) { int index = list.indexOf(o); @@ -238,7 +242,6 @@ public class SWGList implements List, Serializable { } } - @Override public E remove(int index) { synchronized(objectMutex) { E element = list.remove(index); @@ -249,7 +252,6 @@ public class SWGList implements List, Serializable { } } - @Override public boolean removeAll(Collection c) { synchronized(objectMutex) { if (!c.isEmpty()) { @@ -277,20 +279,34 @@ public class SWGList implements List, Serializable { } } - @Override + public void replaceAll(UnaryOperator operator) { + System.err.println("SWGList::sort: Not currently supported."); + } + public boolean retainAll(Collection c) { synchronized(objectMutex) { return list.retainAll(c); } } - @Override + public List reverseGet() { + synchronized(objectMutex) { + return Lists.reverse(list); + } + } + + public boolean removeIf(Predicate filter) { + synchronized(objectMutex) { + return false; + } + } + public E set(int index, E element) { synchronized(objectMutex) { - if (element instanceof IDelta) { + if (valid(element)) { E previousElement = list.set(index, element); - queue(item(2, index, ((IDelta) element).getBytes(), true, true)); + queue(item(2, index, Baseline.toBytes(element), true, true)); return previousElement; } @@ -305,10 +321,10 @@ public class SWGList implements List, Serializable { if (!list.isEmpty()) { for (E element : list) { - if (element instanceof IDelta) { - IoBuffer buffer = Delta.createBuffer((newListData.length + ((IDelta) element).getBytes().length)); + if (valid(element)) { + IoBuffer buffer = Delta.createBuffer((newListData.length + Baseline.toBytes(element).length)); buffer.put(newListData); - buffer.put(((IDelta) element).getBytes()); + buffer.put(Baseline.toBytes(element)); newListData = buffer.array(); } else { return false; @@ -327,28 +343,42 @@ public class SWGList implements List, Serializable { } } - @Override public int size() { synchronized(objectMutex) { return list.size(); } } - @Override + public void sort(Comparator c) { + synchronized(objectMutex) { + System.err.println("SWGList::sort: Not supported."); + } + } + + public Spliterator spliterator() { + synchronized(objectMutex) { + return list.spliterator(); + } + } + + public Stream stream() { + synchronized(objectMutex) { + return list.stream(); + } + } + public List subList(int fromIndex, int toIndex) { synchronized(objectMutex) { return list.subList(fromIndex, toIndex); } } - @Override public Object[] toArray() { synchronized(objectMutex) { return list.toArray(); } } - @Override public T[] toArray(T[] a) { synchronized(objectMutex) { return list.toArray(a); @@ -356,25 +386,61 @@ public class SWGList implements List, Serializable { } public int getUpdateCounter() { - return updateCounter; + synchronized(objectMutex) { + return updateCounter; + } } public Object getMutex() { return objectMutex; } + public byte[] getBytes() { + synchronized(objectMutex) { + byte[] objects = { }; + int size = 0; + + for (Object o : list) { + byte[] object = Baseline.toBytes(o); + size += object.length; + + IoBuffer buffer = Delta.createBuffer(size); + buffer.put(objects); + if (addByte) buffer.put((byte) 0); + buffer.put(object); + buffer.flip(); + + objects = buffer.array(); + } + + IoBuffer buffer = Delta.createBuffer(8 + size); + buffer.putInt(list.size()); + buffer.putInt(updateCounter); + buffer.put(objects); + buffer.flip(); + + return buffer.array(); + } + } + + private boolean valid(Object o) { + if (o instanceof String || o instanceof Byte || o instanceof Short || + o instanceof Integer || o instanceof Float || o instanceof Long || + o instanceof IDelta) { + return true; + } else { + return false; + } + } + private byte[] item(int type, int index, byte[] data, boolean useIndex, boolean useData) { int size = 1 + ((useIndex) ? 2 : 0) + ((useData) ? data.length : 0); - if (messageBuilder == null) { - updateCounter++; - return new byte[] { }; - } - IoBuffer buffer = Delta.createBuffer(size); buffer.put((byte) type); if (useIndex) buffer.putShort((short) index); if (useData) buffer.put(data); + buffer.flip(); updateCounter++; @@ -382,22 +448,12 @@ public class SWGList implements List, Serializable { } private void queue(byte[] data) { - if (messageBuilder == null) { - try { - SWGObject object = NGECore.getInstance().objectService.getObject(objectId); - this.messageBuilder = (ObjectMessageBuilder) object.getClass().getMethod("getMessageBuilder", new Class[] {}).invoke(object, new Object[] { }); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } - IoBuffer buffer = Delta.createBuffer((data.length + 8)); buffer.putInt(1); buffer.putInt(updateCounter); buffer.put(data); - messageBuilder.sendListDelta(viewType, updateType, buffer); + buffer.flip(); + object.sendListDelta(viewType, updateType, buffer); } private void queue(List data) { @@ -407,66 +463,13 @@ public class SWGList implements List, Serializable { size += queued.length; } - if (messageBuilder == null) { - try { - SWGObject object = NGECore.getInstance().objectService.getObject(objectId); - this.messageBuilder = (ObjectMessageBuilder) object.getClass().getMethod("getMessageBuilder", new Class[] {}).invoke(object, new Object[] { }); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } - IoBuffer buffer = Delta.createBuffer((size + 8)); buffer.putInt(data.size()); buffer.putInt(updateCounter); for (byte[] queued : data) buffer.put(queued); + buffer.flip(); - messageBuilder.sendListDelta(viewType, updateType, buffer); - } - - @Override - public boolean removeIf(Predicate filter) { - return false; - } - - public List reverseGet() - { - return Lists.reverse(list); - } - - @Override - public Stream stream() { - return list.stream(); - } - - @Override - public Stream parallelStream() { - return list.parallelStream(); - } - - @Override - public void forEach(Consumer action) { - list.forEach(action); - } - - @Override - public void replaceAll(UnaryOperator operator) { - // TODO Auto-generated method stub - - } - - @Override - public void sort(Comparator c) { - // TODO Auto-generated method stub - - } - - @Override - public Spliterator spliterator() { - // TODO Auto-generated method stub - return null; + object.sendListDelta(viewType, updateType, buffer); } } diff --git a/src/resources/objects/SWGMap.java b/src/resources/objects/SWGMap.java index 8d873024..a8ffc398 100644 --- a/src/resources/objects/SWGMap.java +++ b/src/resources/objects/SWGMap.java @@ -22,72 +22,95 @@ package resources.objects; import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.nio.ByteOrder; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; -import java.util.Map.Entry; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Function; -import main.NGECore; - import org.apache.mina.core.buffer.IoBuffer; -import resources.common.StringUtilities; - -import com.sleepycat.persist.model.NotPersistent; import com.sleepycat.persist.model.Persistent; +import engine.resources.objects.Baseline; +import engine.resources.objects.Delta; +import engine.resources.objects.IDelta; import engine.resources.objects.SWGObject; -@SuppressWarnings("unused") +/* A SWGMap element should extend Delta or implement IDelta */ @Persistent public class SWGMap implements Map, Serializable { private static final long serialVersionUID = 1L; private Map map = new TreeMap(); - @NotPersistent private transient int updateCounter = 0; - long objectId; - private transient ObjectMessageBuilder messageBuilder; private byte viewType; private short updateType; - @NotPersistent + private boolean addByte; protected transient Object objectMutex = new Object(); + private transient SWGObject object; public SWGMap() { } - public SWGMap(long objectId, int viewType, int updateType) { - this.objectId = objectId; + public SWGMap(SWGObject object, int viewType, int updateType, boolean addByte) { this.viewType = (byte) viewType; this.updateType = (short) updateType; + this.addByte = addByte; + this.object = object; } public SWGMap(Map m) { if (m instanceof SWGMap) { - this.objectId = ((SWGMap) m).objectId; - this.messageBuilder = ((SWGMap) m).messageBuilder; + this.object = ((SWGMap) m).object; this.viewType = ((SWGMap) m).viewType; this.updateType = ((SWGMap) m).updateType; map.putAll(m); } } - public void init() { + public void init(SWGObject object) { objectMutex = new Object(); + updateCounter = 0; + this.object = object; + + for (Object item : map.values()) { + try { + if (item instanceof IDelta) { + item.getClass().getMethod("init", new Class[] {}).invoke(item, new Object[] { }); + } + } catch (Exception e) { + e.printStackTrace(); + } + } } public void clear() { throw new UnsupportedOperationException(); } + public V computeIfAbsent(K key, Function mappingFunction) { + synchronized(objectMutex) { + return map.computeIfAbsent(key, mappingFunction); + } + } + + public V computeIfPresent(K key, BiFunction remappingFunction) { + synchronized(objectMutex) { + return map.computeIfPresent(key, remappingFunction); + } + } + + public V compute(K key, BiFunction remappingFunction) { + synchronized(objectMutex) { + return map.compute(key, remappingFunction); + } + } + public boolean containsKey(Object key) { synchronized(objectMutex) { return map.containsKey(key); @@ -106,12 +129,22 @@ public class SWGMap implements Map, Serializable { } } + public void forEach(BiConsumer action) { + map.forEach(action); + } + public V get(Object key) { synchronized(objectMutex) { return map.get(key); } } + public V getOrDefault(Object key, V defaultValue) { + synchronized(objectMutex) { + return map.getOrDefault(key, defaultValue); + } + } + public boolean isEmpty() { synchronized(objectMutex) { return map.isEmpty(); @@ -124,23 +157,26 @@ public class SWGMap implements Map, Serializable { } } + public V merge(K key, V value, BiFunction remappingFunction) { + System.err.println("SWGMap::merge: Not implemented."); + return null; + } + public V put(K key, V value) { synchronized(objectMutex) { - if ((key instanceof String || key instanceof Byte || key instanceof Short || - key instanceof Integer || key instanceof Float ||key instanceof Long) && - value instanceof IDelta) { + if (valid(key) && valid(value)) { if (map.containsKey(key)) { V oldValue = map.put(key, value); if (oldValue != null) { - queue(item(2, (String) key, ((IDelta) value).getBytes(), true, true)); + queue(item(2, key, Baseline.toBytes(value), true, true)); } return oldValue; } else { V oldValue = map.put(key, value); - queue(item(0, (String) key, ((IDelta) value).getBytes(), true, true)); + queue(item(0, key, Baseline.toBytes(value), true, true)); return oldValue; } @@ -158,16 +194,14 @@ public class SWGMap implements Map, Serializable { K key = entry.getKey(); V value = entry.getValue(); - if (key instanceof String || key instanceof Byte || key instanceof Short || - key instanceof Integer || key instanceof Float || key instanceof Long || - value instanceof IDelta) { + if (valid(key) && valid(value)) { if (map.containsKey(key)) { if (map.put(key, value) != null) { - buffer.add(item(2, (String) key, ((IDelta) value).getBytes(), true, true)); + buffer.add(item(2, key, Baseline.toBytes(value), true, true)); } } else { if (map.put(key, value) != null) { - buffer.add(item(0, (String) key, ((IDelta) value).getBytes(), true, true)); + buffer.add(item(0, key, Baseline.toBytes(value), true, true)); } } } @@ -179,14 +213,21 @@ public class SWGMap implements Map, Serializable { } } + public V putIfAbsent(K key, V value) { + if (!map.containsKey(key)) { + return put(key, value); + } + + return null; + } + public V remove(Object key) { synchronized(objectMutex) { - if (key instanceof String || key instanceof Byte || key instanceof Short || - key instanceof Integer || key instanceof Float || key instanceof Long) { + if (valid(key)) { V value = map.remove(key); if (value != null) { - queue(item(1, (String) key, ((IDelta) value).getBytes(), true, true)); + queue(item(1, key, Baseline.toBytes(value), true, true)); } return value; @@ -196,6 +237,47 @@ public class SWGMap implements Map, Serializable { } } + public boolean remove(Object key, Object value) { + synchronized(objectMutex) { + if (valid(key) && valid(value)) { + boolean removed = map.remove(key, value); + + if (removed) { + queue(item(1, key, Baseline.toBytes(value), true, true)); + } + + return removed; + } + + return false; + } + } + + public V replace(K key, V value) { + synchronized(objectMutex) { + if (map.containsKey(key)) { + return put(key, value); + } + + return null; + } + } + + public boolean replace(K key, V oldValue, V newValue) { + synchronized(objectMutex) { + if (map.containsKey(key) && map.containsValue(oldValue)) { + put(key, newValue); + return true; + } + + return false; + } + } + + public void replaceAll(BiFunction function) { + System.err.println("SWGMap::replaceAll: Not implemented."); + } + public int size() { synchronized(objectMutex) { return map.size(); @@ -218,60 +300,71 @@ public class SWGMap implements Map, Serializable { return objectMutex; } + public byte[] getBytes() { + synchronized(objectMutex) { + byte[] objects = { }; + int size = 0; + + for (Entry entry : map.entrySet()) { + byte[] key = Baseline.toBytes(entry.getKey()); + byte[] value = Baseline.toBytes(entry.getValue()); + size += ((addByte) ? 1 : 0) + key.length + value.length; + + IoBuffer buffer = Baseline.createBuffer(size); + buffer.put(objects); + if (addByte) buffer.put((byte) 0); + buffer.put(key); + buffer.put(value); + buffer.flip(); + + objects = buffer.array(); + } + + IoBuffer buffer = Baseline.createBuffer(8 + size); + buffer.putInt(map.size()); + buffer.putInt(updateCounter); + buffer.put(objects); + buffer.flip(); + + return buffer.array(); + } + } + + private boolean valid(Object o) { + if (o instanceof String || o instanceof Byte || o instanceof Short || + o instanceof Integer || o instanceof Float || o instanceof Long || + o instanceof IDelta) { + return true; + } else { + return false; + } + } + private byte[] item(int type, Object index, byte[] data, boolean useIndex, boolean useData) { - if (useIndex && !(index instanceof Byte) && !(index instanceof Short) - && !(index instanceof Integer) && !(index instanceof Float) - && !(index instanceof Long) && !(index instanceof String)) { + if (useIndex && ((index instanceof IDelta) && !valid(index))) { throw new IllegalArgumentException(); } - int size = 1 + ((useIndex) ? (2 + index.toString().getBytes().length) : 0) + ((useData) ? data.length : 0); - - IoBuffer buffer = Delta.createBuffer((size)); - buffer.put((byte) type); - if (useIndex) { - if (index instanceof String) { - buffer.put(StringUtilities.getAsciiString((String) index)); - } else if (index instanceof Byte) { - buffer.put(((Byte) index).byteValue()); - } else if (index instanceof Short) { - buffer.putShort(((Short) index).shortValue()); - } else if (index instanceof Integer) { - buffer.putInt(((Integer) index).intValue()); - } else if (index instanceof Float) { - buffer.putFloat(((Float) index).floatValue()); - } else if (index instanceof Long) { - buffer.putLong(((Long) index).longValue()); - } else { - throw new IllegalArgumentException(); - } - } - if (useData) buffer.put(data); - buffer.flip(); - - updateCounter++; - - return buffer.array(); - } - - private void queue(byte[] data) { - if (messageBuilder == null) { - try { - SWGObject object = NGECore.getInstance().objectService.getObject(objectId); - this.messageBuilder = (ObjectMessageBuilder) object.getClass().getMethod("getMessageBuilder", new Class[] {}).invoke(object, new Object[] { }); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } + int size = 1 + ((useIndex) ? (Baseline.toBytes(index).length) : 0) + ((useData) ? data.length : 0); - IoBuffer buffer = Delta.createBuffer((data.length + 8)); + IoBuffer buffer = Delta.createBuffer(size); + buffer.put((byte) type); + if (useIndex) buffer.put(Baseline.toBytes(index)); + if (useData) buffer.put(data); + buffer.flip(); + + updateCounter++; + + return buffer.array(); + } + + private void queue(byte[] data) { + IoBuffer buffer = Delta.createBuffer(data.length + 8); buffer.putInt(1); buffer.putInt(updateCounter); buffer.put(data); buffer.flip(); - messageBuilder.sendListDelta(viewType, updateType, buffer); + object.sendListDelta(viewType, updateType, buffer); } private void queue(List data) { @@ -281,94 +374,13 @@ public class SWGMap implements Map, Serializable { size += queued.length; } - if (messageBuilder == null) { - try { - SWGObject object = NGECore.getInstance().objectService.getObject(objectId); - this.messageBuilder = (ObjectMessageBuilder) object.getClass().getMethod("getMessageBuilder", new Class[] {}).invoke(object, new Object[] { }); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } - IoBuffer buffer = Delta.createBuffer((size + 8)); buffer.putInt(data.size()); buffer.putInt(updateCounter); for (byte[] queued : data) buffer.put(queued); buffer.flip(); - messageBuilder.sendListDelta(viewType, updateType, buffer); - } - - @Override - public V getOrDefault(Object key, V defaultValue) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void forEach(BiConsumer action) { - map.forEach(action); - } - - @Override - public void replaceAll( - BiFunction function) { - // TODO Auto-generated method stub - - } - - @Override - public V putIfAbsent(K key, V value) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean remove(Object key, Object value) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean replace(K key, V oldValue, V newValue) { - // TODO Auto-generated method stub - return false; - } - - @Override - public V replace(K key, V value) { - // TODO Auto-generated method stub - return null; - } - - @Override - public V computeIfAbsent(K key, - Function mappingFunction) { - // TODO Auto-generated method stub - return null; - } - - @Override - public V computeIfPresent(K key, - BiFunction remappingFunction) { - // TODO Auto-generated method stub - return null; - } - - @Override - public V compute(K key, - BiFunction remappingFunction) { - // TODO Auto-generated method stub - return null; - } - - @Override - public V merge(K key, V value, - BiFunction remappingFunction) { - // TODO Auto-generated method stub - return null; + object.sendListDelta(viewType, updateType, buffer); } } diff --git a/src/resources/objects/SWGMultiMap.java b/src/resources/objects/SWGMultiMap.java index a2126a3b..fce0b1c9 100644 --- a/src/resources/objects/SWGMultiMap.java +++ b/src/resources/objects/SWGMultiMap.java @@ -22,71 +22,68 @@ package resources.objects; import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.nio.ByteOrder; import java.util.ArrayList; import java.util.Collection; -import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import java.util.TreeMap; - -import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; import org.python.google.common.collect.ArrayListMultimap; import org.python.google.common.collect.Multimap; import org.python.google.common.collect.Multiset; -import org.python.google.common.collect.Ordering; -import org.python.google.common.collect.TreeMultimap; - -import resources.common.StringUtilities; - -import com.sleepycat.persist.model.NotPersistent; -import com.sleepycat.persist.model.Persistent; +import engine.resources.objects.Baseline; +import engine.resources.objects.Delta; +import engine.resources.objects.IDelta; import engine.resources.objects.SWGObject; -@SuppressWarnings("unused") - -@Persistent public class SWGMultiMap implements Multimap, Serializable { private static final long serialVersionUID = 1L; private Multimap map = ArrayListMultimap.create(); - @NotPersistent private transient int updateCounter = 0; - private long objectId; - private transient ObjectMessageBuilder messageBuilder; private byte viewType; private short updateType; - @NotPersistent + private boolean addByte; protected transient Object objectMutex = new Object(); + private transient SWGObject object; public SWGMultiMap() { } - public SWGMultiMap(long objectId, int viewType, int updateType) { - this.objectId = objectId; + public SWGMultiMap(SWGObject object, int viewType, int updateType, boolean addByte) { this.viewType = (byte) viewType; this.updateType = (short) updateType; + this.addByte = addByte; + this.object = object; } public SWGMultiMap(Multimap m) { if (m instanceof SWGMultiMap) { - this.objectId = ((SWGMultiMap) m).objectId; - this.messageBuilder = ((SWGMultiMap) m).messageBuilder; + this.object = ((SWGMultiMap) m).object; this.viewType = ((SWGMultiMap) m).viewType; this.updateType = ((SWGMultiMap) m).updateType; map.putAll(m); } } - public void init() { + public void init(SWGObject object) { objectMutex = new Object(); + updateCounter = 0; + this.object = object; + + for (Object item : map.values()) { + try { + if (item instanceof IDelta) { + item.getClass().getMethod("init", new Class[] {}).invoke(item, new Object[] { }); + } + } catch (Exception e) { + e.printStackTrace(); + } + } } - + public Map> asMap() { synchronized(objectMutex) { return map.asMap(); @@ -147,11 +144,9 @@ public class SWGMultiMap implements Multimap, Serializable { public boolean put(K key, V value) { synchronized(objectMutex) { - if (key instanceof String || key instanceof Byte || key instanceof Short || - key instanceof Integer || key instanceof Float || key instanceof Long || - value instanceof IDelta) { + if (valid(key) && valid(value)) { if (map.put(key, value)) { - queue(item(0, (String) key, ((IDelta) value).getBytes(), true, true)); + queue(item(0, key, Baseline.toBytes(value), true, true)); return true; } } @@ -162,14 +157,13 @@ public class SWGMultiMap implements Multimap, Serializable { public boolean putAll(K key, Iterable values) { synchronized(objectMutex) { - if (key instanceof String || key instanceof Byte || key instanceof Short || - key instanceof Integer || key instanceof Float || key instanceof Long) { + if (valid(key)) { List buffer = new ArrayList(); for (V value : values) { - if (value instanceof IDelta) { + if (valid(value)) { if (map.put(key, value)) { - buffer.add(item(0, (String) key, ((IDelta) value).getBytes(), true, true)); + buffer.add(item(0, key, Baseline.toBytes(value), true, true)); } } } @@ -192,11 +186,9 @@ public class SWGMultiMap implements Multimap, Serializable { K key = entry.getKey(); V value = entry.getValue(); - if (key instanceof String || key instanceof Byte || key instanceof Short || - key instanceof Integer || key instanceof Float || key instanceof Long || - value instanceof IDelta) { + if (valid(key) && valid(value)) { if (this.map.put(key, value)) { - buffer.add(item(0, (String) key, ((IDelta) value).getBytes(), true, true)); + buffer.add(item(0, key, Baseline.toBytes(value), true, true)); } } } @@ -210,13 +202,11 @@ public class SWGMultiMap implements Multimap, Serializable { } } - @SuppressWarnings("unchecked") public boolean remove(Object key, Object value) { synchronized(objectMutex) { - if (key instanceof String || key instanceof Byte || key instanceof Short || - key instanceof Integer || key instanceof Float || key instanceof Long) { + if (valid(key)) { if (map.remove(key, value)) { - queue(item(1, (String) key, ((IDelta) map.get((K) key)).getBytes(), true, true)); + queue(item(1, key, Baseline.toBytes(value), true, true)); return true; } @@ -229,14 +219,13 @@ public class SWGMultiMap implements Multimap, Serializable { @SuppressWarnings("unchecked") public Collection removeAll(Object key) { synchronized(objectMutex) { - if (key instanceof String || key instanceof Byte || key instanceof Short || - key instanceof Integer || key instanceof Float || key instanceof Long) { + if (valid(key)) { Collection collection = map.get((K) key); List buffer = new ArrayList(); for (V value : map.get((K) key)) { if (map.remove(key, value)) { - buffer.add(item(1, (String) key, ((IDelta) map.get((K) key)).getBytes(), true, true)); + buffer.add(item(1, key, Baseline.toBytes(value), true, true)); } } @@ -252,15 +241,14 @@ public class SWGMultiMap implements Multimap, Serializable { public Collection replaceValues(K key, Iterable values) { synchronized(objectMutex) { - if (key instanceof String || key instanceof Byte || key instanceof Short || - key instanceof Integer || key instanceof Float || key instanceof Long) { + if (valid(key)) { if (map.containsKey(key)) { List buffer = new ArrayList(); for (V value : values) { - if (value instanceof IDelta) { + if (valid(value)) { if (!map.get(key).contains(value)) { - buffer.add(item(2, (String) key, ((IDelta) value).getBytes(), true, true)); + buffer.add(item(2, key, Baseline.toBytes(value), true, true)); } } else { return null; @@ -300,6 +288,46 @@ public class SWGMultiMap implements Multimap, Serializable { return objectMutex; } + public byte[] getBytes() { + synchronized(objectMutex) { + byte[] objects = { }; + int size = 0; + + for (Entry entry : map.entries()) { + byte[] key = Baseline.toBytes(entry.getKey()); + byte[] value = Baseline.toBytes(entry.getValue()); + size += ((addByte) ? 1 : 0) + key.length + value.length; + + IoBuffer buffer = Baseline.createBuffer(size); + buffer.put(objects); + if (addByte) buffer.put((byte) 0); + buffer.put(key); + buffer.put(value); + buffer.flip(); + + objects = buffer.array(); + } + + IoBuffer buffer = Baseline.createBuffer(8 + size); + buffer.putInt(map.size()); + buffer.putInt(updateCounter); + buffer.put(objects); + buffer.flip(); + + return buffer.array(); + } + } + + private boolean valid(Object o) { + if (o instanceof String || o instanceof Byte || o instanceof Short || + o instanceof Integer || o instanceof Float || o instanceof Long || + o instanceof IDelta) { + return true; + } else { + return false; + } + } + private byte[] item(int type, Object index, byte[] data, boolean useIndex, boolean useData) { if (useIndex && !(index instanceof Byte) && !(index instanceof Short) && !(index instanceof Integer) && !(index instanceof Float) @@ -307,28 +335,13 @@ public class SWGMultiMap implements Multimap, Serializable { throw new IllegalArgumentException(); } - int size = 1 + ((useIndex) ? (2 + index.toString().getBytes().length) : 0) + ((useData) ? data.length : 0); + int size = 1 + ((useIndex) ? (2 + Baseline.toBytes(index).length) : 0) + ((useData) ? data.length : 0); IoBuffer buffer = Delta.createBuffer(size); buffer.put((byte) type); - if (useIndex) { - if (index instanceof String) { - buffer.put(StringUtilities.getAsciiString((String) index)); - } else if (index instanceof Byte) { - buffer.put(((Byte) index).byteValue()); - } else if (index instanceof Short) { - buffer.putShort(((Short) index).shortValue()); - } else if (index instanceof Integer) { - buffer.putInt(((Integer) index).intValue()); - } else if (index instanceof Float) { - buffer.putFloat(((Float) index).floatValue()); - } else if (index instanceof Long) { - buffer.putLong(((Long) index).longValue()); - } else { - throw new IllegalArgumentException(); - } - } + if (useIndex) buffer.put(Baseline.toBytes(index)); if (useData) buffer.put(data); + buffer.flip(); updateCounter++; @@ -336,22 +349,12 @@ public class SWGMultiMap implements Multimap, Serializable { } private void queue(byte[] data) { - if (messageBuilder == null) { - try { - SWGObject object = NGECore.getInstance().objectService.getObject(objectId); - this.messageBuilder = (ObjectMessageBuilder) object.getClass().getMethod("getMessageBuilder", new Class[] {}).invoke(object, new Object[] { }); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } - IoBuffer buffer = Delta.createBuffer((data.length + 8)); buffer.putInt(1); buffer.putInt(updateCounter); buffer.put(data); - messageBuilder.sendListDelta(viewType, updateType, buffer); + buffer.flip(); + object.sendListDelta(viewType, updateType, buffer); } private void queue(List data) { @@ -361,23 +364,13 @@ public class SWGMultiMap implements Multimap, Serializable { size += queued.length; } - if (messageBuilder == null) { - try { - SWGObject object = NGECore.getInstance().objectService.getObject(objectId); - this.messageBuilder = (ObjectMessageBuilder) object.getClass().getMethod("getMessageBuilder", new Class[] {}).invoke(object, new Object[] { }); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } - IoBuffer buffer = Delta.createBuffer((size + 8)); buffer.putInt(data.size()); buffer.putInt(updateCounter); for (byte[] queued : data) buffer.put(queued); + buffer.flip(); - messageBuilder.sendListDelta(viewType, updateType, buffer); + object.sendListDelta(viewType, updateType, buffer); } } diff --git a/src/resources/objects/SWGSet.java b/src/resources/objects/SWGSet.java new file mode 100644 index 00000000..9d316343 --- /dev/null +++ b/src/resources/objects/SWGSet.java @@ -0,0 +1,293 @@ +/******************************************************************************* + * 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 resources.objects; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import org.apache.mina.core.buffer.IoBuffer; + +import engine.resources.objects.Baseline; +import engine.resources.objects.Delta; +import engine.resources.objects.IDelta; +import engine.resources.objects.SWGObject; + +/* A SWGSet element should extend Delta or implement IDelta */ + +public class SWGSet implements Set, Serializable { + + private static final long serialVersionUID = 1L; + private TreeSet set = new TreeSet(); + private transient int updateCounter = 0; + private byte viewType; + private short updateType; + private boolean addByte; + protected transient Object objectMutex = new Object(); + private transient SWGObject object; + + public SWGSet() { } + + public SWGSet(SWGObject object, int viewType, int updateType, boolean addByte) { + this.viewType = (byte) viewType; + this.updateType = (short) updateType; + this.addByte = addByte; + this.object = object; + } + + public SWGSet(Set s) { + if (s instanceof SWGSet) { + this.object = ((SWGSet) s).object; + this.viewType = ((SWGSet) s).viewType; + this.updateType = ((SWGSet) s).updateType; + set.addAll(s); + } + } + + public void init(SWGObject object) { + objectMutex = new Object(); + updateCounter = 0; + this.object = object; + + for (Object item : set) { + try { + if (item instanceof IDelta) { + item.getClass().getMethod("init", new Class[] {}).invoke(item, new Object[] { }); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public boolean add(E e) { + synchronized(objectMutex) { + if (valid(e)) { + if (set.add(e)) { + queue(item(1, e, null, true, false)); + return true; + } + } + + return false; + } + } + + public boolean addAll(Collection c) { + synchronized(objectMutex) { + List buffer = new ArrayList(); + + for (E e : c) { + if (valid(e) && set.add(e)) { + buffer.add(item(1, e, null, true, false)); + } + } + + if (buffer.size() > 0) { + queue(buffer); + return true; + } else { + return false; + } + } + } + + public void clear() { + synchronized(objectMutex) { + queue(item(2, null, null, false, false)); + } + } + + public boolean contains(Object o) { + synchronized(objectMutex) { + return set.contains(o); + } + } + + public boolean containsAll(Collection c) { + synchronized(objectMutex) { + return set.containsAll(c); + } + } + + public boolean isEmpty() { + synchronized(objectMutex) { + return set.isEmpty(); + } + } + + public Iterator iterator() { + synchronized(objectMutex) { + return set.iterator(); + } + } + + public boolean remove(Object e) { + synchronized(objectMutex) { + if (valid(e) && set.remove(e)) { + queue(item(0, e, null, true, false)); + return true; + } + + return false; + } + } + + public boolean removeAll(Collection c) { + synchronized(objectMutex) { + List buffer = new ArrayList(); + + for (Object o : c) { + if (valid(o) && set.remove(o)) { + buffer.add(item(0, o, null, true, false)); + } + } + + if (buffer.size() > 0) { + queue(buffer); + return true; + } else { + return false; + } + } + } + + public boolean retainAll(Collection c) { + synchronized(objectMutex) { + return set.retainAll(c); + } + } + + public int size() { + synchronized(objectMutex) { + return set.size(); + } + } + + public Object[] toArray() { + synchronized(objectMutex) { + return set.toArray(); + } + } + + public T[] toArray(T[] a) { + synchronized(objectMutex) { + return set.toArray(a); + } + } + + public int getUpdateCounter() { + synchronized(objectMutex) { + return updateCounter; + } + } + + public Object getMutex() { + return objectMutex; + } + + public byte[] getBytes() { + synchronized(objectMutex) { + byte[] objects = { }; + int size = 0; + + for (Object o : set) { + byte[] object = Baseline.toBytes(o); + size += object.length; + + IoBuffer buffer = Delta.createBuffer(size); + buffer.put(objects); + if (addByte) buffer.put((byte) 0); + buffer.put(object); + buffer.flip(); + + objects = buffer.array(); + } + + IoBuffer buffer = Delta.createBuffer(8 + size); + buffer.putInt(set.size()); + buffer.putInt(updateCounter); + buffer.put(objects); + buffer.flip(); + + return buffer.array(); + } + } + + private boolean valid(Object o) { + if (o instanceof String || o instanceof Byte || o instanceof Short || + o instanceof Integer || o instanceof Float || o instanceof Long || + o instanceof IDelta) { + return true; + } else { + return false; + } + } + + private byte[] item(int type, Object index, byte[] data, boolean useIndex, boolean useData) { + if (useIndex && ((index instanceof IDelta) || !valid(index))) { + throw new IllegalArgumentException(); + } + + int size = 1 + ((useIndex) ? (2 + Baseline.toBytes(index).length) : 0) + ((useData) ? data.length : 0); + + IoBuffer buffer = Delta.createBuffer(size); + buffer.put((byte) type); + if (useIndex) buffer.put(Baseline.toBytes(index)); + if (useData) buffer.put(data); + buffer.flip(); + + updateCounter++; + + return buffer.array(); + } + + private void queue(byte[] data) { + IoBuffer buffer = Delta.createBuffer(data.length + 8); + buffer.putInt(1); + buffer.putInt(updateCounter); + buffer.put(data); + buffer.flip(); + object.sendListDelta(viewType, updateType, buffer); + } + + private void queue(List data) { + int size = 0; + + for (byte[] queued : data) { + size += queued.length; + } + + IoBuffer buffer = Delta.createBuffer(size + 8); + buffer.putInt(data.size()); + buffer.putInt(updateCounter); + for (byte[] queued : data) buffer.put(queued); + buffer.flip(); + + object.sendListDelta(viewType, updateType, buffer); + } + +} diff --git a/src/resources/objects/building/BuildingMessageBuilder.java b/src/resources/objects/building/BuildingMessageBuilder.java index 8dbf7ec8..6861117f 100644 --- a/src/resources/objects/building/BuildingMessageBuilder.java +++ b/src/resources/objects/building/BuildingMessageBuilder.java @@ -22,16 +22,22 @@ package resources.objects.building; import java.nio.ByteOrder; +import java.util.Map; import java.util.Vector; import org.apache.mina.core.buffer.IoBuffer; -import resources.objects.ObjectMessageBuilder; +import engine.resources.objects.Builder; +import resources.objects.tangible.TangibleMessageBuilder; -public class BuildingMessageBuilder extends ObjectMessageBuilder { +public class BuildingMessageBuilder extends TangibleMessageBuilder { - public BuildingMessageBuilder(BuildingObject buildingObject) { - setObject(buildingObject); + public BuildingMessageBuilder(BuildingObject object) { + super(object); + } + + public BuildingMessageBuilder() { + super(); } public IoBuffer buildBaseline3() { @@ -145,17 +151,25 @@ public class BuildingMessageBuilder extends ObjectMessageBuilder { tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); } - @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(deltaBuilders, deltaBuilders); } - + @Override - public void sendBaselines() { - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(deltaBuilders, deltaBuilders); } - + + @Override + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(deltaBuilders, deltaBuilders); + } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(deltaBuilders, deltaBuilders); + } + } diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index 431f3d61..ed6adb3c 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -23,17 +23,12 @@ package resources.objects.building; import java.io.Serializable; import java.util.Vector; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import main.NGECore; import resources.objects.ObjectMessageBuilder; import resources.objects.cell.CellObject; import resources.objects.creature.CreatureObject; - -import com.sleepycat.je.Environment; -import com.sleepycat.je.Transaction; - import resources.objects.tangible.TangibleObject; import com.sleepycat.persist.model.Entity; diff --git a/src/resources/objects/cell/CellMessageBuilder.java b/src/resources/objects/cell/CellMessageBuilder.java index 1884d4b0..89c28951 100644 --- a/src/resources/objects/cell/CellMessageBuilder.java +++ b/src/resources/objects/cell/CellMessageBuilder.java @@ -22,15 +22,21 @@ package resources.objects.cell; import java.nio.ByteOrder; +import java.util.Map; import org.apache.mina.core.buffer.IoBuffer; import resources.objects.ObjectMessageBuilder; +import engine.resources.objects.Builder; public class CellMessageBuilder extends ObjectMessageBuilder { - public CellMessageBuilder(CellObject cellObject) { - setObject(cellObject); + public CellMessageBuilder(CellObject object) { + super(object); + } + + public CellMessageBuilder() { + super(); } public IoBuffer buildBaseline3() { @@ -80,18 +86,25 @@ public class CellMessageBuilder extends ObjectMessageBuilder { return buffer; } - - - + @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(deltaBuilders, deltaBuilders); } - + @Override - public void sendBaselines() { - // TODO Auto-generated method stub - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(deltaBuilders, deltaBuilders); } + + @Override + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(deltaBuilders, deltaBuilders); + } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(deltaBuilders, deltaBuilders); + } + } diff --git a/src/resources/objects/cell/CellObject.java b/src/resources/objects/cell/CellObject.java index cd95919f..2709577f 100644 --- a/src/resources/objects/cell/CellObject.java +++ b/src/resources/objects/cell/CellObject.java @@ -23,6 +23,8 @@ package resources.objects.cell; import java.io.Serializable; +import org.apache.mina.core.buffer.IoBuffer; + import protocol.swg.UpdateCellPermissionMessage; import resources.objects.ObjectMessageBuilder; @@ -95,4 +97,10 @@ public class CellObject extends SWGObject implements Serializable { return messageBuilder; } + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + // TODO Auto-generated method stub + + } + } diff --git a/src/resources/objects/craft/DraftSchematic.java b/src/resources/objects/craft/DraftSchematic.java index 54d203a5..0539eba4 100644 --- a/src/resources/objects/craft/DraftSchematic.java +++ b/src/resources/objects/craft/DraftSchematic.java @@ -23,6 +23,8 @@ package resources.objects.craft; import java.io.Serializable; +import org.apache.mina.core.buffer.IoBuffer; + import resources.objects.ObjectMessageBuilder; import com.sleepycat.persist.model.Persistent; @@ -58,4 +60,10 @@ public class DraftSchematic extends SWGObject implements Serializable { return messageBuilder; } + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + // TODO Auto-generated method stub + + } + } diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index 7420ea47..30a53018 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -22,34 +22,33 @@ package resources.objects.creature; import java.nio.ByteOrder; +import java.util.Map; import java.util.Map.Entry; import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; -import com.sleepycat.persist.model.Persistent; - import engine.resources.common.CRC; import resources.buffs.Buff; -import resources.objects.ObjectMessageBuilder; +import engine.resources.objects.Builder; import engine.resources.objects.SWGObject; import resources.objects.player.PlayerObject; +import resources.objects.tangible.TangibleMessageBuilder; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; import resources.skills.SkillMod; -@Persistent -public class CreatureMessageBuilder extends ObjectMessageBuilder { - - public CreatureMessageBuilder() { } +public class CreatureMessageBuilder extends TangibleMessageBuilder { - public CreatureMessageBuilder(CreatureObject creatureObject) { - - setObject(creatureObject); - + public CreatureMessageBuilder(CreatureObject object) { + super(object); } - + + public CreatureMessageBuilder() { + super(); + } + public IoBuffer buildBaseline1() { CreatureObject creature = (CreatureObject) object; IoBuffer buffer = bufferPool.allocate(26, false).order(ByteOrder.LITTLE_ENDIAN); @@ -1063,7 +1062,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putInt(1); buffer.putInt(creature.getEquipmentListUpdateCounter()); buffer.put((byte) 1); - buffer.putShort((short) creature.getEquipmentList().indexOf(item)); + buffer.putShort((short) creature.getEquipmentList().indexOf(item.getObjectId())); if(item.getCustomization() == null || item.getCustomization().length == 0) { buffer.putShort((short) 0); } else { @@ -1099,7 +1098,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putInt(1); buffer.putInt(creature.getEquipmentListUpdateCounter()); buffer.put((byte) 0); - buffer.putShort((short) creature.getEquipmentList().indexOf(item)); + buffer.putShort((short) creature.getEquipmentList().indexOf(item.getObjectId())); int size = buffer.position(); buffer.flip(); @@ -1192,36 +1191,35 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x1E, buffer, size + 4); return buffer; } - - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - switch (viewType) { - case 4: { - switch (updateType) { - case 3: { - buffer = createDelta("CREO", (byte) 4, (short) 1, (byte) 3, buffer, buffer.array().length + 4); - - if (object.getClient() != null && object.getClient().getSession() != null) { - object.getClient().getSession().write(buffer); - } - - break; - } - } - } - case 1: - case 3: - case 6: - case 8: - case 9: - default: { - return; - } - } + + @Override + public void buildBaseline1(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline1(baselineBuilders, deltaBuilders); } @Override - public void sendBaselines() { - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline4(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline4(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(baselineBuilders, deltaBuilders); } } diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index d31c5c36..84e0bf2c 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -50,13 +50,11 @@ import main.NGECore; import engine.clients.Client; import resources.buffs.Buff; import resources.buffs.DamageOverTime; -import resources.common.Cooldown; import resources.common.OutOfBand; import resources.objects.ObjectMessageBuilder; import resources.objects.SWGList; import resources.objects.SWGMap; import engine.resources.common.CRC; -import engine.resources.objects.MissionCriticalObject; import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; @@ -101,7 +99,7 @@ public class CreatureObject extends TangibleObject implements Serializable { private int abilitiesUpdateCounter = 0; private int xpBarValue = 0; - private SWGList missionCriticalObjects; + private SWGMap missionCriticalObjects; @NotPersistent private transient int missionCriticalObjectsUpdateCounter = 0; @@ -193,12 +191,12 @@ public class CreatureObject extends TangibleObject implements Serializable { messageBuilder = new CreatureMessageBuilder(this); loadTemplateData(); skills = new ArrayList(); - skillMods = new SWGMap(getObjectID(), 4, 3); - abilities = new SWGList(getObjectID(), 4, 14); - missionCriticalObjects = new SWGList(getObjectID(), 4, 13); - equipmentList = new SWGList(getObjectID(), 6, 0x17); - buffList = new SWGList(getObjectID(), 6, 0x1A); - appearanceEquipmentList = new SWGList(getObjectID(), 6, 0x1F); + skillMods = new SWGMap(this, 4, 3, true); + abilities = new SWGList(this, 4, 14, true); + missionCriticalObjects = new SWGMap(this, 4, 13, false); + equipmentList = new SWGList(this, 6, 23, false); + buffList = new SWGList(this, 6, 26, false); + appearanceEquipmentList = new SWGList(this, 6, 31, false); } public CreatureObject() { @@ -214,14 +212,13 @@ public class CreatureObject extends TangibleObject implements Serializable { cooldowns = new ConcurrentHashMap(); performanceAudience = new Vector(); messageBuilder = new CreatureMessageBuilder(this); - dotList.init(); - buffList.init(); - equipmentList.init(); - appearanceEquipmentList.init(); - missionCriticalObjects.init(); - abilities.init(); - skillMods.init(); - skillMods.forEach((name, skillMod) -> skillMod.init()); + dotList.init(this); + buffList.init(this); + equipmentList.init(this); + appearanceEquipmentList.init(this); + missionCriticalObjects.init(this); + abilities.init(this); + skillMods.init(this); } private void loadTemplateData() { @@ -810,12 +807,11 @@ public class CreatureObject extends TangibleObject implements Serializable { } } - - - public SWGList getMissionCriticalObjects() { + + public SWGMap getMissionCriticalObjects() { return missionCriticalObjects; } - + public byte getCombatFlag() { synchronized(objectMutex) { return combatFlag; @@ -1490,7 +1486,7 @@ public class CreatureObject extends TangibleObject implements Serializable { } public void playMusic(String sndFile, long targetId, int repetitions, boolean flag) { - getClient().getSession().write(new PlayMusicMessage(sndFile, targetId, 1, false)); + getClient().getSession().write(new PlayMusicMessage(sndFile, targetId, 1, false).serialize()); } public boolean getGroupDance() { @@ -1557,20 +1553,6 @@ public class CreatureObject extends TangibleObject implements Serializable { if(getClient() != null) getClient().getSession().write(messageBuilder.buildListenToId(performanceListenee.getObjectId())); } - - - - @Override - public void setPvPBitmask(int pvpBitmask) { - super.setPvPBitmask(pvpBitmask); - notifyObservers(new UpdatePVPStatusMessage(getObjectID(), getPvPBitmask(), getFaction()), false); - } - - @Override - public void setPvpStatus(int pvpBitmask, boolean add) { - super.setPvpStatus(pvpBitmask, add); - notifyObservers(new UpdatePVPStatusMessage(getObjectID(), getPvPBitmask(), getFaction()), false); - } public byte getDifficulty() { synchronized(objectMutex) { @@ -1801,10 +1783,6 @@ public class CreatureObject extends TangibleObject implements Serializable { return false; } - public Cooldown getCooldown(String cooldownGroup) { - return new Cooldown(getRemainingCooldown(cooldownGroup)); - } - public long getRemainingCooldown(String cooldownGroup) { if (cooldowns.containsKey(cooldownGroup)) { if (System.currentTimeMillis() < cooldowns.get(cooldownGroup)) { @@ -1846,12 +1824,34 @@ public class CreatureObject extends TangibleObject implements Serializable { return adder.intValue(); } - //public float getCooldown(String cooldownGroup) { - //return ((float) getCooldown(cooldownGroup) / (float) 1000); - //} - public ObjectMessageBuilder getMessageBuilder() { return messageBuilder; } + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + switch (viewType) { + case 4: { + switch (updateType) { + case 3: { + buffer = messageBuilder.createDelta("CREO", (byte) 4, (short) 1, (byte) 3, buffer, buffer.array().length + 4); + + if (getClient() != null && getClient().getSession() != null) { + getClient().getSession().write(buffer); + } + + break; + } + } + } + case 1: + case 3: + case 6: + case 8: + case 9: + default: { + return; + } + } + } + } diff --git a/src/resources/objects/factorycrate/FactoryCrateMessageBuilder.java b/src/resources/objects/factorycrate/FactoryCrateMessageBuilder.java index 59c39cbe..bcde4afc 100644 --- a/src/resources/objects/factorycrate/FactoryCrateMessageBuilder.java +++ b/src/resources/objects/factorycrate/FactoryCrateMessageBuilder.java @@ -22,23 +22,22 @@ package resources.objects.factorycrate; import java.nio.ByteOrder; +import java.util.Map; import org.apache.mina.core.buffer.IoBuffer; -import resources.objects.ObjectMessageBuilder; -import resources.objects.resource.GalacticResource; -import resources.objects.resource.ResourceContainerObject; +import engine.resources.objects.Builder; +import resources.objects.tangible.TangibleMessageBuilder; -/** - * @author Charon - */ - -public class FactoryCrateMessageBuilder extends ObjectMessageBuilder{ +public class FactoryCrateMessageBuilder extends TangibleMessageBuilder{ - public FactoryCrateMessageBuilder(FactoryCrateObject factoryCrateObject) { - setObject(factoryCrateObject); + public FactoryCrateMessageBuilder(FactoryCrateObject object) { + super(object); } + public FactoryCrateMessageBuilder() { + super(); + } public IoBuffer buildBaseline3() { FactoryCrateObject factoryCrateObject = (FactoryCrateObject) object; @@ -162,15 +161,23 @@ public class FactoryCrateMessageBuilder extends ObjectMessageBuilder{ } @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(deltaBuilders, deltaBuilders); } - @Override - public void sendBaselines() { - // TODO Auto-generated method stub - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(deltaBuilders, deltaBuilders); } + + @Override + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(deltaBuilders, deltaBuilders); + } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(deltaBuilders, deltaBuilders); + } + } diff --git a/src/resources/objects/factorycrate/FactoryCrateObject.java b/src/resources/objects/factorycrate/FactoryCrateObject.java index 69f4d537..8c82e824 100644 --- a/src/resources/objects/factorycrate/FactoryCrateObject.java +++ b/src/resources/objects/factorycrate/FactoryCrateObject.java @@ -44,10 +44,6 @@ import resources.objects.ObjectMessageBuilder; import resources.objects.creature.CreatureObject; import resources.objects.tangible.TangibleObject; -/** - * @author Charon - */ - @Persistent(version=0) public class FactoryCrateObject extends TangibleObject implements Serializable { diff --git a/src/resources/objects/group/GroupMessageBuilder.java b/src/resources/objects/group/GroupMessageBuilder.java index a04b639a..2c407e36 100644 --- a/src/resources/objects/group/GroupMessageBuilder.java +++ b/src/resources/objects/group/GroupMessageBuilder.java @@ -22,16 +22,23 @@ package resources.objects.group; import java.nio.ByteOrder; +import java.util.Map; + import org.apache.mina.core.buffer.IoBuffer; + +import engine.resources.objects.Builder; import engine.resources.objects.SWGObject; -import resources.objects.ObjectMessageBuilder; +import resources.objects.universe.UniverseMessageBuilder; -public class GroupMessageBuilder extends ObjectMessageBuilder { +public class GroupMessageBuilder extends UniverseMessageBuilder { - public GroupMessageBuilder(GroupObject groupObject) { - setObject(groupObject); + public GroupMessageBuilder(GroupObject object) { + super(object); + } + + public GroupMessageBuilder() { + super(); } - public IoBuffer buildBaseline3() { @@ -178,18 +185,15 @@ public class GroupMessageBuilder extends ObjectMessageBuilder { return buffer = createDelta("GRUP", (byte) 6, (short) 1, (short) 2, buffer, size + 4); } - - + @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(baselineBuilders, deltaBuilders); } - + @Override - public void sendBaselines() { - // TODO Auto-generated method stub - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(baselineBuilders, deltaBuilders); } - + } diff --git a/src/resources/objects/guild/GuildMessageBuilder.java b/src/resources/objects/guild/GuildMessageBuilder.java index ade7d71d..a29b8f68 100644 --- a/src/resources/objects/guild/GuildMessageBuilder.java +++ b/src/resources/objects/guild/GuildMessageBuilder.java @@ -22,22 +22,26 @@ package resources.objects.guild; import java.nio.ByteOrder; +import java.util.Map; import java.util.Map.Entry; import org.apache.mina.core.buffer.IoBuffer; -import engine.clients.Client; - +import engine.resources.objects.Builder; import resources.gcw.CurrentServerGCWZoneHistory; import resources.gcw.CurrentServerGCWZonePercent; import resources.gcw.OtherServerGCWZonePercent; import resources.guild.Guild; -import resources.objects.ObjectMessageBuilder; +import resources.objects.universe.UniverseMessageBuilder; -public class GuildMessageBuilder extends ObjectMessageBuilder { +public class GuildMessageBuilder extends UniverseMessageBuilder { - public GuildMessageBuilder(GuildObject guildObject) { - setObject(guildObject); + public GuildMessageBuilder(GuildObject object) { + super(object); + } + + public GuildMessageBuilder() { + super(); } public IoBuffer buildBaseline3() { @@ -216,55 +220,13 @@ public class GuildMessageBuilder extends ObjectMessageBuilder { } @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - - switch (viewType) { - case 3: - { - switch (updateType) { - case 4: - { - buffer = createDelta("GILD", (byte) 3, (short) 1, (short) 4, buffer.flip(), buffer.array().length + 4); - - for (Client client : ((GuildObject) object).core.getActiveConnectionsMap().values()) { - client.getSession().write(buffer); - } - - break; - } - } - } - case 6: - { - switch (updateType) { - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - { - buffer = createDelta("GILD", (byte) 6, (short) 1, (short) updateType, buffer.flip(), buffer.array().length + 4); - - for (Client client : ((GuildObject) object).core.getActiveConnectionsMap().values()) { - client.getSession().write(buffer); - } - - break; - } - default: - { - return; - } - } - } - } + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(baselineBuilders, deltaBuilders); } - + @Override - public void sendBaselines() { - // TODO Auto-generated method stub - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(baselineBuilders, deltaBuilders); } } diff --git a/src/resources/objects/guild/GuildObject.java b/src/resources/objects/guild/GuildObject.java index e614df21..bee39d0c 100644 --- a/src/resources/objects/guild/GuildObject.java +++ b/src/resources/objects/guild/GuildObject.java @@ -68,19 +68,19 @@ public class GuildObject extends UniverseObject implements Serializable { private String STFName = ""; private String customName = ""; private int volume = 0; - private SWGList guildList = new SWGList(getObjectID(), 3, 4); + private SWGList guildList = new SWGList(this, 3, 4, false); // GILD 6 private int serverId = 0x43; //private String STFName = "string_id_table"; private int unknown1 = 0; private short unknown2 = 0; - private SWGMap currentServerGCWZonePercentMap = new SWGMap(getObjectID(), 6, 2); - private SWGMap currentServerGCWTotalPercentMap = new SWGMap(getObjectID(), 6, 3); - private SWGMultiMap currentServerGCWZoneHistoryMap = new SWGMultiMap(getObjectID(), 6, 4); - private SWGMultiMap currentServerGCWTotalHistoryMap = new SWGMultiMap(getObjectID(), 6, 5); - private SWGMultiMap otherServerGCWZonePercentMap = new SWGMultiMap(getObjectID(), 6, 6); - private SWGMultiMap otherServerGCWTotalPercentMap = new SWGMultiMap(getObjectID(), 6, 7); + private SWGMap currentServerGCWZonePercentMap = new SWGMap(this, 6, 2, true); + private SWGMap currentServerGCWTotalPercentMap = new SWGMap(this, 6, 3, true); + private SWGMultiMap currentServerGCWZoneHistoryMap = new SWGMultiMap(this, 6, 4, true); + private SWGMultiMap currentServerGCWTotalHistoryMap = new SWGMultiMap(this, 6, 5, true); + private SWGMultiMap otherServerGCWZonePercentMap = new SWGMultiMap(this, 6, 6, true); + private SWGMultiMap otherServerGCWTotalPercentMap = new SWGMultiMap(this, 6, 7, true); private int unknown3 = 5; public GuildObject(NGECore core, long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) { @@ -92,15 +92,14 @@ public class GuildObject extends UniverseObject implements Serializable { public void initAfterDBLoad() { super.init(); messageBuilder = new GuildMessageBuilder(this); - guildList.init(); - currentServerGCWZonePercentMap.init(); - currentServerGCWTotalPercentMap.init(); - currentServerGCWZoneHistoryMap.init(); - currentServerGCWTotalHistoryMap.init(); - otherServerGCWZonePercentMap.init(); - otherServerGCWTotalPercentMap.init(); + guildList.init(this); + currentServerGCWZonePercentMap.init(this); + currentServerGCWTotalPercentMap.init(this); + currentServerGCWZoneHistoryMap.init(this); + currentServerGCWTotalHistoryMap.init(this); + otherServerGCWZonePercentMap.init(this); + otherServerGCWTotalPercentMap.init(this); } - public float getComplexity() { synchronized(objectMutex) { @@ -317,4 +316,50 @@ public class GuildObject extends UniverseObject implements Serializable { return messageBuilder; } + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + + switch (viewType) { + case 3: + { + switch (updateType) { + case 4: + { + buffer = messageBuilder.createDelta("GILD", (byte) 3, (short) 1, (short) 4, buffer.flip(), buffer.array().length + 4); + + for (Client client : core.getActiveConnectionsMap().values()) { + client.getSession().write(buffer); + } + + break; + } + } + } + case 6: + { + switch (updateType) { + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + { + buffer = messageBuilder.createDelta("GILD", (byte) 6, (short) 1, (short) updateType, buffer.flip(), buffer.array().length + 4); + + for (Client client : core.getActiveConnectionsMap().values()) { + client.getSession().write(buffer); + } + + break; + } + default: + { + return; + } + } + } + } + } + } diff --git a/src/resources/objects/harvester/HarvesterMessageBuilder.java b/src/resources/objects/harvester/HarvesterMessageBuilder.java index cbe9b4d9..bf3422cb 100644 --- a/src/resources/objects/harvester/HarvesterMessageBuilder.java +++ b/src/resources/objects/harvester/HarvesterMessageBuilder.java @@ -22,24 +22,26 @@ package resources.objects.harvester; import java.nio.ByteOrder; +import java.util.Map; import java.util.Vector; import org.apache.mina.core.buffer.IoBuffer; +import engine.resources.objects.Builder; import engine.resources.objects.SWGObject; - -import resources.objects.ObjectMessageBuilder; import resources.objects.creature.CreatureObject; import resources.objects.resource.GalacticResource; import resources.objects.resource.ResourceContainerObject; +import resources.objects.tangible.TangibleMessageBuilder; -/** - * @author Charon - */ -public class HarvesterMessageBuilder extends ObjectMessageBuilder{ +public class HarvesterMessageBuilder extends TangibleMessageBuilder { - public HarvesterMessageBuilder(HarvesterObject harvesterObject) { - setObject(harvesterObject); + public HarvesterMessageBuilder(HarvesterObject object) { + super(object); + } + + public HarvesterMessageBuilder() { + super(); } public IoBuffer buildBaseline3() { @@ -812,15 +814,24 @@ public class HarvesterMessageBuilder extends ObjectMessageBuilder{ return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); } + @Override + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(deltaBuilders, deltaBuilders); + } @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(deltaBuilders, deltaBuilders); } - + @Override - public void sendBaselines() { - + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(deltaBuilders, deltaBuilders); } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(deltaBuilders, deltaBuilders); + } + } diff --git a/src/resources/objects/harvester/HarvesterObject.java b/src/resources/objects/harvester/HarvesterObject.java index 42300a49..d53eb991 100644 --- a/src/resources/objects/harvester/HarvesterObject.java +++ b/src/resources/objects/harvester/HarvesterObject.java @@ -40,10 +40,6 @@ import resources.objects.resource.GalacticResource; import resources.objects.resource.ResourceContainerObject; import resources.objects.tangible.TangibleObject; -/** - * @author Charon - */ - @Persistent(version=0) public class HarvesterObject extends InstallationObject implements Serializable { @@ -121,7 +117,6 @@ public class HarvesterObject extends InstallationObject implements Serializable private String deedTemplate; private int specRate; - public HarvesterObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ super(objectID, planet, template, position, orientation); diff --git a/src/resources/objects/installation/InstallationMessageBuilder.java b/src/resources/objects/installation/InstallationMessageBuilder.java index f9fe356d..8b67f8d3 100644 --- a/src/resources/objects/installation/InstallationMessageBuilder.java +++ b/src/resources/objects/installation/InstallationMessageBuilder.java @@ -22,18 +22,22 @@ package resources.objects.installation; import java.nio.ByteOrder; +import java.util.Map; + import org.apache.mina.core.buffer.IoBuffer; -import resources.objects.ObjectMessageBuilder; + +import engine.resources.objects.Builder; import resources.objects.harvester.HarvesterObject; +import resources.objects.tangible.TangibleMessageBuilder; -/** - * @author Charon - */ - -public class InstallationMessageBuilder extends ObjectMessageBuilder{ +public class InstallationMessageBuilder extends TangibleMessageBuilder{ - public InstallationMessageBuilder(InstallationObject installationObject) { - setObject(installationObject); + public InstallationMessageBuilder(InstallationObject object) { + super(object); + } + + public InstallationMessageBuilder() { + super(); } public IoBuffer buildBaseline3(InstallationObject installationObject) { @@ -211,15 +215,30 @@ public class InstallationMessageBuilder extends ObjectMessageBuilder{ // 0000: 05 00 53 21 86 12 82 EC 7D 16 00 00 02 00 4F 53 ..S!....}.....OS // 0010: 4E 49 07 12 00 00 00 02 00 09 00 00 00 00 00 05 NI.............. // 0020: 00 8A D3 79 16 00 00 0F 00 ...y..... - + @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(deltaBuilders, deltaBuilders); } - + @Override - public void sendBaselines() { - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(deltaBuilders, deltaBuilders); } + + @Override + public void buildBaseline7(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline7(deltaBuilders, deltaBuilders); + } + + @Override + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(deltaBuilders, deltaBuilders); + } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(deltaBuilders, deltaBuilders); + } + } diff --git a/src/resources/objects/intangible/IntangibleMessageBuilder.java b/src/resources/objects/intangible/IntangibleMessageBuilder.java index c71177be..b6c572f8 100644 --- a/src/resources/objects/intangible/IntangibleMessageBuilder.java +++ b/src/resources/objects/intangible/IntangibleMessageBuilder.java @@ -21,26 +21,39 @@ ******************************************************************************/ package resources.objects.intangible; -import org.apache.mina.core.buffer.IoBuffer; +import java.util.Map; import resources.objects.ObjectMessageBuilder; +import engine.resources.objects.Builder; public class IntangibleMessageBuilder extends ObjectMessageBuilder { - public IntangibleMessageBuilder(IntangibleObject intangibleObject) { - setObject(intangibleObject); + public IntangibleMessageBuilder(IntangibleObject object) { + super(object); + } + + public IntangibleMessageBuilder() { + super(); } @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(baselineBuilders, deltaBuilders); } - + @Override - public void sendBaselines() { - // TODO Auto-generated method stub - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(baselineBuilders, deltaBuilders); } - + + @Override + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(baselineBuilders, deltaBuilders); + } + } diff --git a/src/resources/objects/intangible/IntangibleObject.java b/src/resources/objects/intangible/IntangibleObject.java index 6bb64e6f..0e1d788f 100644 --- a/src/resources/objects/intangible/IntangibleObject.java +++ b/src/resources/objects/intangible/IntangibleObject.java @@ -23,59 +23,107 @@ package resources.objects.intangible; import java.io.Serializable; +import org.apache.mina.core.buffer.IoBuffer; + import resources.objects.ObjectMessageBuilder; - -import com.sleepycat.persist.model.Persistent; - import engine.clients.Client; +import engine.resources.objects.Baseline; import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=0) public class IntangibleObject extends SWGObject implements Serializable { private static final long serialVersionUID = 1L; - private transient IntangibleMessageBuilder messageBuilder; - private int genericInt; - public IntangibleObject() { - super(); - messageBuilder = new IntangibleMessageBuilder(this); - } - + private transient IntangibleMessageBuilder messageBuilder; + public IntangibleObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) { super(objectID, planet, position, orientation, Template); messageBuilder = new IntangibleMessageBuilder(this); } - - @Override + + public IntangibleObject() { + super(); + } + public void initAfterDBLoad() { super.init(); messageBuilder = new IntangibleMessageBuilder(this); } - + + public Baseline getOtherVariables() { + Baseline baseline = super.getOtherVariables(); + return baseline; + } + + public Baseline getBaseline3() { + Baseline baseline = super.getBaseline3(); + baseline.put("genericInt", 0); + return baseline; + } + + public Baseline getBaseline6() { + Baseline baseline = super.getBaseline6(); + return baseline; + } + + public Baseline getBaseline8() { + Baseline baseline = super.getBaseline8(); + return baseline; + } + + public Baseline getBaseline9() { + Baseline baseline = super.getBaseline9(); + return baseline; + } + public int getGenericInt() { - synchronized(objectMutex) { - return genericInt; - } + return (int) getBaseline(3).get("genericInt"); } - + public void setGenericInt(int genericInt) { - synchronized(objectMutex) { - this.genericInt = genericInt; - } + notifyClients(getBaseline(3).set("genericInt", genericInt), true); } - - @Override - public void sendBaselines(Client client) { - // TODO Auto-generated method stub - + + public void incrementGenericInt(int increase) { + setGenericInt((getGenericInt() + increase)); + } + + public void decrementGenericInt(int decrease) { + setGenericInt((((getGenericInt() - decrease) < 1) ? 0 : (getGenericInt() - decrease))); + } + + public void notifyClients(IoBuffer buffer, boolean notifySelf) { + notifyObservers(buffer, notifySelf); } public ObjectMessageBuilder getMessageBuilder() { - return messageBuilder; + synchronized(objectMutex) { + if (messageBuilder == null) { + messageBuilder = new IntangibleMessageBuilder(this); + } + + return messageBuilder; + } + } + + public void sendBaselines(Client destination) { + if (destination != null && destination.getSession() != null) { + destination.getSession().write(getBaseline(3).getBaseline()); + destination.getSession().write(getBaseline(6).getBaseline()); + + // FIXME Check if destination has view permissions to this + if (this.getContainer() == destination.getParent() || this.getGrandparent() == destination.getParent()) { + destination.getSession().write(getBaseline(8).getBaseline()); + destination.getSession().write(getBaseline(9).getBaseline()); + } + } + } + + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + } } diff --git a/src/resources/objects/manufacture/ManufactureSchematicMessageBuilder.java b/src/resources/objects/manufacture/ManufactureSchematicMessageBuilder.java index 30c04def..ce90c1ab 100644 --- a/src/resources/objects/manufacture/ManufactureSchematicMessageBuilder.java +++ b/src/resources/objects/manufacture/ManufactureSchematicMessageBuilder.java @@ -21,26 +21,44 @@ ******************************************************************************/ package resources.objects.manufacture; -import org.apache.mina.core.buffer.IoBuffer; +import java.util.Map; -import resources.objects.ObjectMessageBuilder; +import engine.resources.objects.Builder; +import resources.objects.intangible.IntangibleMessageBuilder; -public class ManufactureSchematicMessageBuilder extends ObjectMessageBuilder { +public class ManufactureSchematicMessageBuilder extends IntangibleMessageBuilder { public ManufactureSchematicMessageBuilder(ManufactureSchematicObject object) { - setObject(object); + super(object); + } + + public ManufactureSchematicMessageBuilder() { + super(); } @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(baselineBuilders, deltaBuilders); } - + @Override - public void sendBaselines() { - // TODO Auto-generated method stub - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline7(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline7(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(baselineBuilders, deltaBuilders); } } diff --git a/src/resources/objects/manufacture/ManufactureSchematicObject.java b/src/resources/objects/manufacture/ManufactureSchematicObject.java index b8532f00..c2693da5 100644 --- a/src/resources/objects/manufacture/ManufactureSchematicObject.java +++ b/src/resources/objects/manufacture/ManufactureSchematicObject.java @@ -32,11 +32,6 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; - -/** - * @author Charon - */ - @Persistent(version=0) public class ManufactureSchematicObject extends IntangibleObject implements Serializable { diff --git a/src/resources/objects/mission/MissionMessageBuilder.java b/src/resources/objects/mission/MissionMessageBuilder.java index 071a4f58..c7b61268 100644 --- a/src/resources/objects/mission/MissionMessageBuilder.java +++ b/src/resources/objects/mission/MissionMessageBuilder.java @@ -22,22 +22,26 @@ package resources.objects.mission; import java.nio.ByteOrder; +import java.util.Map; import org.apache.mina.core.buffer.IoBuffer; import engine.resources.common.CRC; +import engine.resources.objects.Builder; import engine.resources.scene.Point3D; -import resources.common.Console; -import resources.common.StringUtilities; -import resources.objects.ObjectMessageBuilder; +import resources.objects.intangible.IntangibleMessageBuilder; import resources.objects.waypoint.WaypointObject; -public class MissionMessageBuilder extends ObjectMessageBuilder { - - public MissionMessageBuilder(MissionObject missionObject) { - setObject(missionObject); +public class MissionMessageBuilder extends IntangibleMessageBuilder { + + public MissionMessageBuilder(MissionObject object) { + super(object); } - + + public MissionMessageBuilder() { + super(); + } + public IoBuffer buildBaseline3() { MissionObject mission = (MissionObject) object; IoBuffer buffer = IoBuffer.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); @@ -394,15 +398,25 @@ public class MissionMessageBuilder extends ObjectMessageBuilder { return buffer; } - + @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(baselineBuilders, deltaBuilders); } - + @Override - public void sendBaselines() { - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(baselineBuilders, deltaBuilders); } - + + @Override + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(baselineBuilders, deltaBuilders); + } + } diff --git a/src/resources/objects/mission/MissionObject.java b/src/resources/objects/mission/MissionObject.java index 47a8f07b..aa3f4ba2 100644 --- a/src/resources/objects/mission/MissionObject.java +++ b/src/resources/objects/mission/MissionObject.java @@ -303,11 +303,11 @@ public class MissionObject extends IntangibleObject implements Serializable { this.missionId = missionId; } - public long getBountyObjId() { + public long getBountyMarkId() { return bountyObjId; } - public void setBountyObjId(long bountyObjId) { + public void setBountyMarkId(long bountyObjId) { this.bountyObjId = bountyObjId; } diff --git a/src/resources/objects/player/PlayerMessageBuilder.java b/src/resources/objects/player/PlayerMessageBuilder.java index 7e518a32..a1a19436 100644 --- a/src/resources/objects/player/PlayerMessageBuilder.java +++ b/src/resources/objects/player/PlayerMessageBuilder.java @@ -23,19 +23,25 @@ package resources.objects.player; import java.nio.ByteOrder; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import org.apache.mina.core.buffer.IoBuffer; -import resources.objects.ObjectMessageBuilder; +import engine.resources.objects.Builder; +import resources.objects.intangible.IntangibleMessageBuilder; import resources.objects.waypoint.WaypointObject; -public class PlayerMessageBuilder extends ObjectMessageBuilder { +public class PlayerMessageBuilder extends IntangibleMessageBuilder { - public PlayerMessageBuilder(PlayerObject playerObject) { - setObject(playerObject); + public PlayerMessageBuilder(PlayerObject object) { + super(object); } - + + public PlayerMessageBuilder() { + super(); + } + public IoBuffer buildBaseline3() { PlayerObject player = (PlayerObject) object; @@ -662,17 +668,23 @@ public class PlayerMessageBuilder extends ObjectMessageBuilder { return buffer; } - + @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(baselineBuilders, deltaBuilders); } - + @Override - public void sendBaselines() { - // TODO Auto-generated method stub - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(baselineBuilders, deltaBuilders); } - + + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(baselineBuilders, deltaBuilders); + } + + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(baselineBuilders, deltaBuilders); + } + } diff --git a/src/resources/objects/player/PlayerObject.java b/src/resources/objects/player/PlayerObject.java index 079c29b9..436daeef 100644 --- a/src/resources/objects/player/PlayerObject.java +++ b/src/resources/objects/player/PlayerObject.java @@ -28,20 +28,21 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.Vector; +import resources.craft.DraftSchematic; import resources.objects.ObjectMessageBuilder; import resources.objects.intangible.IntangibleObject; import resources.objects.resource.ResourceContainerObject; import resources.objects.tool.SurveyTool; import resources.objects.waypoint.WaypointObject; import resources.objects.creature.CreatureObject; +import resources.quest.Quest; import com.sleepycat.persist.model.NotPersistent; import com.sleepycat.persist.model.Persistent; import engine.clients.Client; -import engine.resources.objects.DraftSchematic; -import engine.resources.objects.Quest; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; @@ -151,6 +152,8 @@ public class PlayerObject extends IntangibleObject implements Serializable { private transient boolean callingCompanion = false; private long bountyMissionId; + private Vector ownedVendors = new Vector(); + private long bindLocation; public PlayerObject() { super(); @@ -921,5 +924,33 @@ public class PlayerObject extends IntangibleObject implements Serializable { public ObjectMessageBuilder getMessageBuilder() { return messageBuilder; } + + public Vector getOwnedVendors() { + return ownedVendors; + } + + public void addVendor(long vendorId) { + ownedVendors.add(vendorId); + } + + public void removeVendor(long vendorId) { + ownedVendors.remove(vendorId); + } + + public int getAmountOfVendors() { + return ownedVendors.size(); + } + + public long getBindLocation() { + synchronized(objectMutex) { + return bindLocation; + } + } + + public void setBindLocation(long bindLocation) { + synchronized(objectMutex) { + this.bindLocation = bindLocation; + } + } } diff --git a/src/resources/objects/resource/GalacticResource.java b/src/resources/objects/resource/GalacticResource.java index eb8d1635..e8141781 100644 --- a/src/resources/objects/resource/GalacticResource.java +++ b/src/resources/objects/resource/GalacticResource.java @@ -26,6 +26,8 @@ import java.util.List; import java.util.Random; import java.util.Vector; +import org.apache.mina.core.buffer.IoBuffer; + import main.NGECore; import protocol.swg.SurveyMapUpdateMessage; import resources.objects.creature.CreatureObject; @@ -675,4 +677,11 @@ public class GalacticResource extends SWGObject implements Serializable { return historicResource; } + + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + // TODO Auto-generated method stub + + } + } diff --git a/src/resources/objects/resource/ResourceContainerMessageBuilder.java b/src/resources/objects/resource/ResourceContainerMessageBuilder.java index 92192c3f..c81e4932 100644 --- a/src/resources/objects/resource/ResourceContainerMessageBuilder.java +++ b/src/resources/objects/resource/ResourceContainerMessageBuilder.java @@ -22,17 +22,22 @@ package resources.objects.resource; import java.nio.ByteOrder; +import java.util.Map; import org.apache.mina.core.buffer.IoBuffer; -import resources.objects.ObjectMessageBuilder; +import engine.resources.objects.Builder; +import resources.objects.tangible.TangibleMessageBuilder; -public class ResourceContainerMessageBuilder extends ObjectMessageBuilder { - - public ResourceContainerMessageBuilder(ResourceContainerObject resourceContainerObject) { - setObject(resourceContainerObject); +public class ResourceContainerMessageBuilder extends TangibleMessageBuilder { + + public ResourceContainerMessageBuilder(ResourceContainerObject object) { + super(object); } + public ResourceContainerMessageBuilder() { + super(); + } public IoBuffer buildBaseline3() { ResourceContainerObject resourceContainer = (ResourceContainerObject) object; @@ -106,7 +111,6 @@ public class ResourceContainerMessageBuilder extends ObjectMessageBuilder { public IoBuffer buildBaseline8() { - ResourceContainerObject resourceContainer = (ResourceContainerObject) object; IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); buffer.setAutoExpand(true); @@ -271,18 +275,24 @@ public class ResourceContainerMessageBuilder extends ObjectMessageBuilder { return IoBuffer.allocate(size).put(result.array(), 0, size).flip(); } - @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(baselineBuilders, deltaBuilders); } - @Override - public void sendBaselines() { - // TODO Auto-generated method stub - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(baselineBuilders, deltaBuilders); } - + + @Override + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(baselineBuilders, deltaBuilders); + } + } diff --git a/src/resources/objects/ship/ShipMessageBuilder.java b/src/resources/objects/ship/ShipMessageBuilder.java index b3874e8e..5905c0f7 100644 --- a/src/resources/objects/ship/ShipMessageBuilder.java +++ b/src/resources/objects/ship/ShipMessageBuilder.java @@ -21,6 +21,39 @@ ******************************************************************************/ package resources.objects.ship; -public class ShipMessageBuilder { +import java.util.Map; +import engine.resources.objects.Builder; +import resources.objects.tangible.TangibleMessageBuilder; + +public class ShipMessageBuilder extends TangibleMessageBuilder { + + public ShipMessageBuilder(ShipObject object) { + super(object); + } + + public ShipMessageBuilder() { + super(); + } + + @Override + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(baselineBuilders, deltaBuilders); + } + } diff --git a/src/resources/objects/staticobject/StaticMessageBuilder.java b/src/resources/objects/staticobject/StaticMessageBuilder.java index e6c1e141..ffcfe443 100644 --- a/src/resources/objects/staticobject/StaticMessageBuilder.java +++ b/src/resources/objects/staticobject/StaticMessageBuilder.java @@ -22,17 +22,22 @@ package resources.objects.staticobject; import java.nio.ByteOrder; +import java.util.Map; import org.apache.mina.core.buffer.IoBuffer; import resources.objects.ObjectMessageBuilder; +import engine.resources.objects.Builder; public class StaticMessageBuilder extends ObjectMessageBuilder { - public StaticMessageBuilder(StaticObject staticObject) { - setObject(staticObject); + public StaticMessageBuilder(StaticObject object) { + super(object); + } + + public StaticMessageBuilder() { + super(); } - public IoBuffer buildBaseline3() { @@ -79,18 +84,15 @@ public class StaticMessageBuilder extends ObjectMessageBuilder { return buffer; } - + @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(baselineBuilders, deltaBuilders); } - + @Override - public void sendBaselines() { - // TODO Auto-generated method stub - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(baselineBuilders, deltaBuilders); } - - + } diff --git a/src/resources/objects/staticobject/StaticObject.java b/src/resources/objects/staticobject/StaticObject.java index a0c2de5c..d116f7cb 100644 --- a/src/resources/objects/staticobject/StaticObject.java +++ b/src/resources/objects/staticobject/StaticObject.java @@ -23,6 +23,8 @@ package resources.objects.staticobject; import java.io.Serializable; +import org.apache.mina.core.buffer.IoBuffer; + import resources.objects.ObjectMessageBuilder; import com.sleepycat.persist.model.NotPersistent; @@ -76,4 +78,10 @@ public class StaticObject extends SWGObject implements Serializable { return messageBuilder; } + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + // TODO Auto-generated method stub + + } + } diff --git a/src/resources/objects/tangible/TangibleMessageBuilder.java b/src/resources/objects/tangible/TangibleMessageBuilder.java index ec017af4..befaeddf 100644 --- a/src/resources/objects/tangible/TangibleMessageBuilder.java +++ b/src/resources/objects/tangible/TangibleMessageBuilder.java @@ -22,16 +22,21 @@ package resources.objects.tangible; import java.nio.ByteOrder; +import java.util.Map; import org.apache.mina.core.buffer.IoBuffer; import resources.objects.ObjectMessageBuilder; - +import engine.resources.objects.Builder; public class TangibleMessageBuilder extends ObjectMessageBuilder { - public TangibleMessageBuilder(TangibleObject tangible) { - setObject(tangible); + public TangibleMessageBuilder(TangibleObject object) { + setObject(object); + } + + public TangibleMessageBuilder() { + super(); } public IoBuffer buildBaseline3() { @@ -151,8 +156,9 @@ public class TangibleMessageBuilder extends ObjectMessageBuilder { } public IoBuffer buildCustomizationDelta(byte[] customization) { - IoBuffer buffer = bufferPool.allocate(customization.length, false).order(ByteOrder.LITTLE_ENDIAN); - + IoBuffer buffer = bufferPool.allocate(customization.length + 2, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putShort((short) customization.length); buffer.put(customization); int size = buffer.position(); @@ -205,15 +211,23 @@ public class TangibleMessageBuilder extends ObjectMessageBuilder { } @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(baselineBuilders, deltaBuilders); } @Override - public void sendBaselines() { - // TODO Auto-generated method stub - + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(baselineBuilders, deltaBuilders); } } diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 6b9f01a2..9cf7a8ef 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -32,6 +32,8 @@ import java.util.Map; import java.util.Set; import java.util.Vector; +import org.apache.mina.core.buffer.IoBuffer; + import main.NGECore; import protocol.swg.ObjControllerMessage; import protocol.swg.PlayClientEffectObjectMessage; @@ -39,19 +41,20 @@ import protocol.swg.StopClientEffectObjectByLabel; import protocol.swg.UpdatePVPStatusMessage; import protocol.swg.objectControllerObjects.ShowFlyText; import resources.common.OutOfBand; -import resources.common.RGB; import resources.datatables.Options; import resources.datatables.PvpStatus; +import resources.datatables.STF; import resources.loot.LootGroup; import resources.objects.ObjectMessageBuilder; import resources.objects.creature.CreatureObject; -import resources.visitors.IDManagerVisitor; import com.sleepycat.persist.model.NotPersistent; import com.sleepycat.persist.model.Persistent; import engine.clientdata.ClientFileManager; +import engine.clientdata.visitors.IDManagerVisitor; import engine.clients.Client; +import engine.resources.common.RGB; import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; @@ -80,11 +83,8 @@ public class TangibleObject extends SWGObject implements Serializable { @NotPersistent private transient TangibleMessageBuilder messageBuilder; - private int respawnTime = 0; - private Point3D spawnCoordinates = new Point3D(0, 0, 0); - //private TreeSet> lootSpecification = new TreeSet>(); - private List lootGroups = new ArrayList(); + private transient List lootGroups = new ArrayList(); @NotPersistent private transient boolean looted = false; // These 4 should not need to be persisted, since a looted corpse will get wiped with server restart @@ -115,7 +115,6 @@ public class TangibleObject extends SWGObject implements Serializable { public TangibleObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation) { super(objectID, planet, position, orientation, template); messageBuilder = new TangibleMessageBuilder(this); - spawnCoordinates = position.clone(); if (this.getClass().getSimpleName().equals("TangibleObject")) setIntAttribute("volume", 1); } @@ -131,10 +130,10 @@ public class TangibleObject extends SWGObject implements Serializable { messageBuilder = new TangibleMessageBuilder(this); } + @Deprecated public void setCustomName2(String customName) { setCustomName(customName); - - notifyObservers(messageBuilder.buildCustomNameDelta(customName), true); + System.err.println("setCustomName2 is now deprecated - please use setCustomName"); } public int getIncapTimer() { @@ -164,7 +163,7 @@ public class TangibleObject extends SWGObject implements Serializable { else if(conditionDamage > getMaxDamage()) conditionDamage = getMaxDamage(); this.conditionDamage = conditionDamage; - notifyObservers(messageBuilder.buildConditionDamageDelta(conditionDamage), false); + notifyObservers(messageBuilder.buildConditionDamageDelta(conditionDamage), true); if (maxDamage > 0) { this.setStringAttribute("condition", (maxDamage + "/" + (maxDamage - conditionDamage))); } @@ -179,7 +178,7 @@ public class TangibleObject extends SWGObject implements Serializable { this.customization = customization; } - notifyObservers(messageBuilder.buildCustomizationDelta(customization), false); + notifyObservers(messageBuilder.buildCustomizationDelta(customization), true); } public List getComponentCustomizations() { @@ -297,12 +296,21 @@ public class TangibleObject extends SWGObject implements Serializable { } } + public Byte getCustomizationVariable(String type) + { + if(customizationVariables.containsKey(type)) return customizationVariables.get(type); + System.err.println("Error: object doesn't have customization variable " + type); + return null; + } + public void setCustomizationVariable(String type, byte value) { if(customizationVariables.containsKey(type)) customizationVariables.replace(type, value); else customizationVariables.put(type, value); - buildCustomizationBytes(); + byte[] customizationBytes = getCustomizationBytes(); + customization = customizationBytes; + notifyObservers(messageBuilder.buildCustomizationDelta(customizationBytes), true); } public void removeCustomizationVariable(String type) @@ -310,11 +318,13 @@ public class TangibleObject extends SWGObject implements Serializable { if(customizationVariables.containsKey(type)) { customizationVariables.remove(type); - buildCustomizationBytes(); + byte[] customizationBytes = getCustomizationBytes(); + customization = customizationBytes; + notifyObservers(messageBuilder.buildCustomizationDelta(customizationBytes), true); } } - private void buildCustomizationBytes() + private byte[] getCustomizationBytes() { //if(customizationVariables.size() == 0) customization = { 0x00 }; @@ -336,9 +346,10 @@ public class TangibleObject extends SWGObject implements Serializable { stream.write((byte) 0xBF); stream.write((byte) 0x03); } - customization = stream.toByteArray(); + return stream.toByteArray(); } - catch (Exception e) { e.printStackTrace(); } + catch (Exception e) { e.printStackTrace(); } + return null; } public String getFaction() { @@ -481,18 +492,6 @@ public class TangibleObject extends SWGObject implements Serializable { notifyObservers(new StopClientEffectObjectByLabel(getObjectID(), commandString), true); } - public int getRespawnTime() { - synchronized(objectMutex) { - return respawnTime; - } - } - - public void setRespawnTime(int respawnTime) { - synchronized(objectMutex) { - this.respawnTime = respawnTime; - } - } - public TangibleObject getKiller() { synchronized(objectMutex) { return killer; @@ -508,13 +507,22 @@ public class TangibleObject extends SWGObject implements Serializable { public List getLootGroups() { return lootGroups; } + + public void setLootGroups(List lootGroups) { + this.lootGroups = lootGroups; + } public void addToLootGroups(String[] lootPoolNames, double[] lootPoolChances, double lootGroupChance) { - System.out.println("lootPoolNames[0] " + lootPoolNames[0]); + //System.out.println("lootPoolNames[0] " + lootPoolNames[0]); LootGroup lootGroup = new LootGroup(lootPoolNames, lootPoolChances, lootGroupChance); this.lootGroups.add(lootGroup); } + public void addToLootGroups(LootGroup lootGroup) { + this.lootGroups.add(lootGroup); + } + + public boolean isLooted() { return looted; } @@ -641,4 +649,23 @@ public class TangibleObject extends SWGObject implements Serializable { return messageBuilder; } + public boolean isFull() + { + if(getTemplateData().getAttribute("containerVolumeLimit") == null) return false; + + int containerVolumeLimit = (int)getTemplateData().getAttribute("containerVolumeLimit") >> 8; // Shifting because it seems to be returning an extra byte before it should + + if(containerVolumeLimit == 0) return false; + + if(NGECore.getInstance().objectService.objsInContainer(this, this) >= containerVolumeLimit) return true; + + return false; + } + + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + // TODO Auto-generated method stub + + } + } diff --git a/src/resources/objects/IDelta.java b/src/resources/objects/universe/UniverseMessageBuilder.java similarity index 80% rename from src/resources/objects/IDelta.java rename to src/resources/objects/universe/UniverseMessageBuilder.java index cf1d8802..f0c72079 100644 --- a/src/resources/objects/IDelta.java +++ b/src/resources/objects/universe/UniverseMessageBuilder.java @@ -19,13 +19,18 @@ * 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 resources.objects; +package resources.objects.universe; -import com.sleepycat.persist.model.Persistent; +import resources.objects.ObjectMessageBuilder; -@Persistent -public interface IDelta { +public class UniverseMessageBuilder extends ObjectMessageBuilder { - public byte[] getBytes(); + public UniverseMessageBuilder(UniverseObject object) { + super(object); + } + + public UniverseMessageBuilder() { + super(); + } } diff --git a/src/resources/objects/universe/UniverseObject.java b/src/resources/objects/universe/UniverseObject.java index 841e300a..3f3bb6b1 100644 --- a/src/resources/objects/universe/UniverseObject.java +++ b/src/resources/objects/universe/UniverseObject.java @@ -23,6 +23,8 @@ package resources.objects.universe; import java.io.Serializable; +import org.apache.mina.core.buffer.IoBuffer; + import resources.objects.ObjectMessageBuilder; import com.sleepycat.persist.model.Persistent; @@ -62,4 +64,10 @@ public class UniverseObject extends SWGObject implements Serializable { return messageBuilder; } + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + // TODO Auto-generated method stub + + } + } diff --git a/src/resources/objects/waypoint/WaypointObject.java b/src/resources/objects/waypoint/WaypointObject.java index 6cd72dca..d73c6b66 100644 --- a/src/resources/objects/waypoint/WaypointObject.java +++ b/src/resources/objects/waypoint/WaypointObject.java @@ -25,14 +25,11 @@ import java.io.Serializable; import resources.objects.intangible.IntangibleObject; -import com.sleepycat.persist.model.Persistent; - import engine.clients.Client; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=0) public class WaypointObject extends IntangibleObject implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/resources/objects/weapon/WeaponMessageBuilder.java b/src/resources/objects/weapon/WeaponMessageBuilder.java index 5084b9cf..80eec11a 100644 --- a/src/resources/objects/weapon/WeaponMessageBuilder.java +++ b/src/resources/objects/weapon/WeaponMessageBuilder.java @@ -22,18 +22,24 @@ package resources.objects.weapon; import java.nio.ByteOrder; +import java.util.Map; import org.apache.mina.core.buffer.IoBuffer; -import resources.objects.ObjectMessageBuilder; +import engine.resources.objects.Builder; +import resources.objects.tangible.TangibleMessageBuilder; import resources.datatables.Elemental; -public class WeaponMessageBuilder extends ObjectMessageBuilder { - - public WeaponMessageBuilder(WeaponObject weaponObject) { - setObject(weaponObject); +public class WeaponMessageBuilder extends TangibleMessageBuilder { + + public WeaponMessageBuilder(WeaponObject object) { + super(object); } - + + public WeaponMessageBuilder() { + super(); + } + public IoBuffer buildBaseline3() { WeaponObject weapon = (WeaponObject) object; IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); @@ -134,15 +140,40 @@ public class WeaponMessageBuilder extends ObjectMessageBuilder { } @Override - public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { - // TODO Auto-generated method stub - + public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline3(baselineBuilders, deltaBuilders); } @Override - public void sendBaselines() { - // TODO Auto-generated method stub + public void buildBaseline6(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline6(baselineBuilders, deltaBuilders); + /* + baselineBuilders.put(13, new Builder() { + + public byte[] build() { + return Baseline.createBuffer(4).putInt(((WeaponObject) object).getWeaponType()).array(); + } + + }); + deltaBuilders.put(13, new Builder() { + + public byte[] build() { + return Baseline.createBuffer(4).putInt(((WeaponObject) object).getWeaponType()).array(); + } + + }); + */ + } + + @Override + public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline8(baselineBuilders, deltaBuilders); + } + + @Override + public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { + super.buildBaseline9(baselineBuilders, deltaBuilders); } } diff --git a/src/resources/objects/weapon/WeaponObject.java b/src/resources/objects/weapon/WeaponObject.java index 46526b1b..a4ef7b31 100644 --- a/src/resources/objects/weapon/WeaponObject.java +++ b/src/resources/objects/weapon/WeaponObject.java @@ -28,14 +28,12 @@ import resources.datatables.WeaponType; import resources.objects.tangible.TangibleObject; import com.sleepycat.persist.model.NotPersistent; -import com.sleepycat.persist.model.Persistent; import engine.clients.Client; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=1) public class WeaponObject extends TangibleObject implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/resources/common/Cooldown.java b/src/resources/quest/Quest.java similarity index 58% rename from src/resources/common/Cooldown.java rename to src/resources/quest/Quest.java index 2c7e2240..80348605 100644 --- a/src/resources/common/Cooldown.java +++ b/src/resources/quest/Quest.java @@ -19,42 +19,22 @@ * 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 resources.common; +package resources.quest; -import java.util.concurrent.ScheduledFuture; +import java.io.Serializable; -public class Cooldown { - private long startTimestamp; - private long endTimestamp; +import engine.resources.objects.Delta; + +public class Quest extends Delta implements Serializable { - private ScheduledFuture removalTask; - - public Cooldown(long end) { - startTimestamp = System.currentTimeMillis(); - endTimestamp = startTimestamp + end; + private static final long serialVersionUID = 1L; + + public Quest() { + } - - public long getStartTimestamp() { - return startTimestamp; - } - - public void setStartTimestamp(long startTimestamp) { - this.startTimestamp = startTimestamp; - } - - public long getEndTimestamp() { - return endTimestamp; - } - - public void setEndTimestamp(long endTimestamp) { - this.endTimestamp = endTimestamp; - } - - public ScheduledFuture getRemovalTask() { - return removalTask; - } - - public void setRemovalTask(ScheduledFuture removalTask) { - this.removalTask = removalTask; + + public byte[] getBytes() { + return new byte[] { }; } + } diff --git a/src/resources/skills/SkillMod.java b/src/resources/skills/SkillMod.java index c3cbbbfe..a667f6b0 100644 --- a/src/resources/skills/SkillMod.java +++ b/src/resources/skills/SkillMod.java @@ -25,11 +25,8 @@ import java.io.Serializable; import org.apache.mina.core.buffer.IoBuffer; -import resources.objects.Delta; +import engine.resources.objects.Delta; -import com.sleepycat.persist.model.Persistent; - -@Persistent(version=0) public class SkillMod extends Delta implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/resources/visitors/IDManagerVisitor.java b/src/resources/visitors/IDManagerVisitor.java deleted file mode 100644 index 3c7a1617..00000000 --- a/src/resources/visitors/IDManagerVisitor.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * 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 resources.visitors; - -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.mina.core.buffer.IoBuffer; - -import engine.clientdata.VisitorInterface; - -public class IDManagerVisitor implements VisitorInterface { - - private ConcurrentHashMap customizationMap; - private CharsetDecoder charsetDecoder; - - public IDManagerVisitor() { - customizationMap = new ConcurrentHashMap(); - charsetDecoder = Charset.forName("US-ASCII").newDecoder(); - } - - @Override - public void parseData(String node, IoBuffer data, int depth, int size) throws Exception { - - if (!node.equals("0001DATA") || depth != 2) - return; - - while(data.hasRemaining()) { - - byte designNumber = data.get(); - data.get(); - String customizationType = data.getString(charsetDecoder); - charsetDecoder.reset(); - - customizationMap.put(customizationType, designNumber); - - //System.out.println(designNumber + ": " + customizationType); - } - } - - public byte getAttributeIndex(String type) - { - return customizationMap.get(type); - } - - @Override - public void notifyFolder(String node, int depth) throws Exception { - } - - public ConcurrentHashMap getCustomizationMap() { - return this.customizationMap; - } -} diff --git a/src/resources/visitors/ProfessionTemplateVisitor.java b/src/resources/visitors/ProfessionTemplateVisitor.java deleted file mode 100644 index 8b46a49d..00000000 --- a/src/resources/visitors/ProfessionTemplateVisitor.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * 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 resources.visitors; - -import java.nio.charset.CharacterCodingException; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.util.Vector; - -import org.apache.mina.core.buffer.IoBuffer; - -import engine.clientdata.VisitorInterface; - -public class ProfessionTemplateVisitor implements VisitorInterface { - - - private class RaceTemplate { - private Vector items; - private String template; - public RaceTemplate(String template) { - this.template = template; - this.items = new Vector(); - } - - public Vector getItems() { - return items; - } - - public String getTemplate() { - return template; - } - } - - private CharsetDecoder charsetDecoder; - - private Vector pItems; - - public ProfessionTemplateVisitor() { - this.charsetDecoder = Charset.forName("US-ASCII").newDecoder(); - this.pItems = new Vector(); - } - - public Vector getItems(String template) { - for(RaceTemplate rTemplate : pItems) { - if (rTemplate.getTemplate().equals(template)) { - return rTemplate.getItems(); - } - } - return null; - } - - @Override - public void notifyFolder(String str, int depth) throws Exception { - } - - @Override - public void parseData(String node, IoBuffer data, int depth, int size) { - - try { - if (depth != 3) - return; - - if (node.equals("PTMPNAME")) { - String ptmpname = data.getString(charsetDecoder); - - pItems.add(new RaceTemplate(ptmpname)); - charsetDecoder.reset(); - } else if (node.equals("ITEM")){ - int index = pItems.size() - 1; - data.skip(4); - String item = data.getString(charsetDecoder); - pItems.get(index).getItems().add(item); - charsetDecoder.reset(); - } - } catch(CharacterCodingException e) { - e.printStackTrace(); - } - } -} diff --git a/src/services/CharacterService.java b/src/services/CharacterService.java index 55fd1de3..531895f4 100644 --- a/src/services/CharacterService.java +++ b/src/services/CharacterService.java @@ -34,10 +34,9 @@ import main.NGECore; import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.session.IoSession; - - import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; +import engine.clientdata.visitors.ProfessionTemplateVisitor; import engine.clients.Client; import engine.resources.common.CRC; import engine.resources.container.CreatureContainerPermissions; @@ -65,7 +64,6 @@ import resources.objects.mission.MissionObject; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; -import resources.visitors.ProfessionTemplateVisitor; @SuppressWarnings("unused") @@ -89,6 +87,18 @@ public class CharacterService implements INetworkDispatch { } } + public boolean checkName(String name, Client client) { + // TODO: check for dev names, profane names, iconic names etc + try { + if(checkForDuplicateName(name, client.getAccountId()) || !name.matches(allowedCharsRegex)) + return false; + } catch (SQLException e) { + e.printStackTrace(); + } + + return true; + } + @Override public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { diff --git a/src/services/ConnectionService.java b/src/services/ConnectionService.java index faf3b513..73102790 100644 --- a/src/services/ConnectionService.java +++ b/src/services/ConnectionService.java @@ -195,6 +195,8 @@ public class ConnectionService implements INetworkDispatch { CreatureObject object = (CreatureObject) client.getParent(); + object.setPvPBitmask(0); + object.setInviteCounter(0); object.setInviteSenderId(0); object.setInviteSenderName(""); @@ -270,7 +272,7 @@ public class ConnectionService implements INetworkDispatch { } }*/ - core.missionService.getBountyList().remove(core.getBountiesODB().get(object.getObjectId())); + core.missionService.getBountyMap().remove(core.getBountiesODB().get(object.getObjectID())); ghost.toggleFlag(PlayerFlags.LD); diff --git a/src/services/ConversationService.java b/src/services/ConversationService.java index b2b3854a..29dd18ec 100644 --- a/src/services/ConversationService.java +++ b/src/services/ConversationService.java @@ -57,6 +57,8 @@ public class ConversationService implements INetworkDispatch { if(player.getConversingNpc() != null && player.getConversingNpc() != npc) handleEndConversation(player, player.getConversingNpc()); + core.simulationService.faceTarget(npc, player); + player.setConversingNpc(npc); sendStartConversation(player, npc); core.scriptService.callScript("scripts/conversation/", (String) npc.getAttachment("conversationFile"), "startConversation", core, player, npc); diff --git a/src/services/DevService.java b/src/services/DevService.java index 0ea128fb..7b79dcfe 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -74,6 +74,7 @@ public class DevService implements INetworkDispatch { case 0: // Root suiOptions.put((long) 1, "Character"); suiOptions.put((long) 2, "Items"); + suiOptions.put((long) 3, "Locations"); break; case 1: // Character suiOptions.put((long) 10, "Set combat level to 90"); @@ -90,10 +91,7 @@ public class DevService implements INetworkDispatch { if(creature.getClient().isGM()) suiOptions.put((long) 120, "House Deeds"); if(creature.getClient().isGM()) suiOptions.put((long) 125, "Crafting Tools"); if(creature.getClient().isGM()) suiOptions.put((long) 130, "Vehicle Deeds"); - if(creature.getClient().isGM()) suiOptions.put((long) 121, "Sandbox City"); - if(creature.getClient().isGM()) suiOptions.put((long) 122, "Jedi Ruins"); - if(creature.getClient().isGM()) suiOptions.put((long) 153, "Force Crystal Hunter's Cave"); - + if(creature.getClient().isGM()) suiOptions.put((long) 121, "Sandbox City"); break; case 3: // [Items] Weapons suiOptions.put((long) 30, "Jedi Weapons"); @@ -131,11 +129,16 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 90, "(Light) Jedi Robe"); suiOptions.put((long) 91, "(Dark) Jedi Robe"); suiOptions.put((long) 92, "Belt of Master Bodo Baas"); + suiOptions.put((long) 93, "Lightsaber Crystals"); break; case 10: // [Items] Jedi Items suiOptions.put((long) 111, "Harvesters"); suiOptions.put((long) 112, "Energy resources"); break; + case 11: // Locations + suiOptions.put((long) 122, "Teleport to Jedi Ruins"); + suiOptions.put((long) 124, "Teleport to Mos Eisley"); + break; } @@ -164,6 +167,9 @@ public class DevService implements INetworkDispatch { case 2: // Items sendCharacterBuilderSUI(player, 2); return; + case 3: // Locations + sendCharacterBuilderSUI(player, 11); + return; // Character case 10: // Set combat level to 90 @@ -993,6 +999,55 @@ public class DevService implements INetworkDispatch { case 92: // Belt of Master Bodo Baas inventory.add(core.objectService.createObject("object/tangible/wearables/backpack/shared_fannypack_s01.iff", planet)); return; + case 93: // Lightsaber Crystals + TangibleObject kraytPearl = (TangibleObject) core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff", planet); + kraytPearl.setAttachment("LootItemName", "kraytpearl_flawless"); + core.lootService.handleSpecialItems(kraytPearl, "kraytpearl"); + inventory.add(kraytPearl); + + TangibleObject kraytPearl2 = (TangibleObject) core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff", planet); + kraytPearl2.setAttachment("LootItemName", "kraytpearl_flawless"); + core.lootService.handleSpecialItems(kraytPearl2, "kraytpearl"); + inventory.add(kraytPearl2); + + TangibleObject kraytPearl3 = (TangibleObject) core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff", planet); + kraytPearl3.setAttachment("LootItemName", "kraytpearl_flawless"); + core.lootService.handleSpecialItems(kraytPearl3, "kraytpearl"); + inventory.add(kraytPearl3); + + TangibleObject kraytPearl4 = (TangibleObject) core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff", planet); + kraytPearl4.setAttachment("LootItemName", "kraytpearl_flawless"); + core.lootService.handleSpecialItems(kraytPearl4, "kraytpearl"); + inventory.add(kraytPearl4); + + TangibleObject kraytPearl5 = (TangibleObject) core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff", planet); + kraytPearl5.setAttachment("LootItemName", "kraytpearl_flawless"); + core.lootService.handleSpecialItems(kraytPearl5, "kraytpearl"); + inventory.add(kraytPearl5); + + TangibleObject kraytPearl6 = (TangibleObject) core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff", planet); + kraytPearl6.setAttachment("LootItemName", "kraytpearl_premium"); + core.lootService.handleSpecialItems(kraytPearl6, "kraytpearl"); + inventory.add(kraytPearl6); + + + + TangibleObject colorCrystal = (TangibleObject) core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff", planet); + colorCrystal.getAttributes().put("@obj_attr_n:condition", "100/100"); + colorCrystal.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF "); + colorCrystal.setAttachment("radial_filename", "item/tunable"); + core.lootService.setCustomization(colorCrystal, "colorcrystal"); + inventory.add(colorCrystal); + + TangibleObject lavaCrystal = (TangibleObject) core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_lava_crystal.iff", planet); + lavaCrystal.getAttributes().put("@obj_attr_n:condition", "100/100"); + lavaCrystal.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF "); + lavaCrystal.getAttributes().put("@obj_attr_n:color", "Lava"); + lavaCrystal.setAttachment("radial_filename", "item/tunable"); + inventory.add(lavaCrystal); + + return; + case 110: SurveyTool mineralSurveyTool = (SurveyTool) core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_mineral.iff", planet); mineralSurveyTool.setCustomName("Mineral Survey Device"); @@ -1180,13 +1235,11 @@ public class DevService implements INetworkDispatch { return; case 122: - Point3D position = new Point3D(4086,15,5554); - core.simulationService.transferToPlanet(player, core.terrainService.getPlanetByName("dantooine"), position, player.getOrientation(), null); + core.simulationService.transferToPlanet(player, core.terrainService.getPlanetByName("dantooine"), new Point3D(4198,9,5210), player.getOrientation(), null); return; - case 153: - position = new Point3D(-6222,1,7380); - core.simulationService.transferToPlanet(player, core.terrainService.getPlanetByName("dantooine"), position, player.getOrientation(), null); + case 124: + core.simulationService.transferToPlanet(player, core.terrainService.getPlanetByName("tatooine"), new Point3D(3521,4,-4800), player.getOrientation(), null); return; case 123: diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index 0643348e..fccb607b 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -28,19 +28,19 @@ import resources.common.ObjControllerOpcodes; import resources.common.OutOfBand; import resources.common.Performance; import resources.common.PerformanceEffect; -import resources.common.RGB; import resources.datatables.Posture; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.skills.SkillMod; -import resources.visitors.IDManagerVisitor; import services.sui.SUIService.InputBoxType; import services.sui.SUIWindow; import services.sui.SUIWindow.Trigger; import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; +import engine.clientdata.visitors.IDManagerVisitor; import engine.clients.Client; +import engine.resources.common.RGB; import engine.resources.objects.SWGObject; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; diff --git a/src/services/EquipmentService.java b/src/services/EquipmentService.java index be901fc7..a75ba2d6 100644 --- a/src/services/EquipmentService.java +++ b/src/services/EquipmentService.java @@ -41,10 +41,13 @@ import org.python.core.PyObject; import resources.datatables.FactionStatus; import resources.objects.creature.CreatureObject; import main.NGECore; +import engine.resources.container.Traverser; import engine.resources.objects.SWGObject; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import resources.objects.player.PlayerObject; +import resources.objects.tangible.TangibleObject; +import resources.objects.weapon.WeaponObject; import services.equipment.BonusSetTemplate; public class EquipmentService implements INetworkDispatch { @@ -66,61 +69,92 @@ public class EquipmentService implements INetworkDispatch { } - public boolean canEquip(CreatureObject actor, SWGObject item) { + + /* + Returns an array; + [0] = boolean, whether or not the item may be equipped; + [1] = string, in case of failure, why + */ + public Object[] canEquip(CreatureObject actor, SWGObject item) { // TODO: Species restrictions // TODO: Gender restrictions boolean result = true; + String message = ""; - if (item == null) - return false; + if (item == null) + { + result = false; + message = "null_item"; + return new Object[] { result, message }; + } if (item.getAttributes().toString().contains("cat_armor")) { - if (actor.hasAbility("wear_all_armor")) result = true; // Change to "wear_all_armor" ability instead of lvl 22 - else return false; + if (actor.hasAbility("wear_all_armor")) result = true; + else + { + result = false; + message = "@error_message:insufficient_skill"; // I am unsure if this is the right message + return new Object[] { result, message }; + } } - if (item.getStringAttribute("class_required") != null) { + if (item.getStringAttribute("class_required") != null) + { String classRequired = item.getStringAttribute("class_required"); String profession = ((PlayerObject) actor.getSlottedObject("ghost")).getProfession(); - if (classRequired.contains(",")) { - String[] classes = classRequired.split(","); - - for (int i = 0; i < classes.length; i++) { - if (classes[i].contains(core.playerService.getFormalProfessionName(profession))) { - return true; - } - } + if (classRequired.contains(core.playerService.getFormalProfessionName(profession)) || classRequired.equals("None")) result = true; + else + { + result = false; + message = "@error_message:insufficient_skill"; // I am unsure if this is the right message + return new Object[] { result, message }; } - if (classRequired.contentEquals(core.playerService.getFormalProfessionName(profession)) || classRequired.contentEquals("None")) - result = true; - else - return false; } if (item.getStringAttribute("faction_restriction") != null) - if (item.getStringAttribute("faction_restriction").toLowerCase().contentEquals(actor.getFaction()) && actor.getFactionStatus() >= FactionStatus.Combatant) - result = true; - else - return false; + { + if (item.getStringAttribute("faction_restriction").toLowerCase().contentEquals(actor.getFaction()) && actor.getFactionStatus() >= FactionStatus.Combatant) result = true; + else + { + result = false; + message = "@faction_recruiter:must_be_faction_member_use"; // will have to somehow manage prose %TO for faction name + return new Object[] { result, message }; + } + } if (item.getAttributes().containsKey("required_combat_level")) { - if (actor.getLevel() >= item.getIntAttribute("required_combat_level")) - result = true; - else - return false; + if (actor.getLevel() >= item.getIntAttribute("required_combat_level")) result = true; + else + { + result = false; + message = "@error_message:insufficient_skill"; // I am unsure if this is the right message + return new Object[] { result, message }; + } } if(item.getAttachment("unity") != null) { - actor.sendSystemMessage("@unity:cannot_remove_ring", (byte) 0); - return false; + result = false; + message = "@unity:cannot_remove_ring"; + return new Object[] { result, message }; } - return result; + if(item.getTemplate().startsWith("object/weapon/") && item.getTemplate().contains("lightsaber") && item.getAttachment("hasColorCrystal") == null) item.setAttachment("hasColorCrystal", false); + + if(item.getAttachment("hasColorCrystal") != null && (Boolean) item.getAttachment("hasColorCrystal") == false) + { + result = false; + message = "@jedi_spam:lightsaber_no_color"; + return new Object[] { result, message }; + } + + result = true; + message = "success"; + return new Object[] { result, message }; } public void equip(CreatureObject actor, SWGObject item) @@ -133,7 +167,7 @@ public class EquipmentService implements INetworkDispatch { // TODO: bio-link (assign it by objectID with setAttachment and then just display the customName for that objectID). - if(!actor.getEquipmentList().contains(item)) + if(!actor.getEquipmentList().contains(item.getObjectId())) { actor.addObjectToEquipList(item); processItemAtrributes(actor, item, true); @@ -149,7 +183,7 @@ public class EquipmentService implements INetworkDispatch { if(func != null) func.__call__(Py.java2py(core), Py.java2py(actor), Py.java2py(item)); - if(actor.getEquipmentList().contains(item)) + if(actor.getEquipmentList().contains(item.getObjectId())) { actor.removeObjectFromEquipList(item); processItemAtrributes(actor, item, false); @@ -290,6 +324,109 @@ public class EquipmentService implements INetworkDispatch { } } + public void calculateLightsaberAttributes(CreatureObject actor, TangibleObject item, SWGObject targetContainer) + { + WeaponObject lightsaber = null; + TangibleObject lightsaberInventory = null; + long tunerId = 0; + + // Get our lightsaber weapon object + if(item.getContainer().getTemplate().startsWith("object/tangible/inventory/shared_lightsaber_inventory")) lightsaber = (WeaponObject) item.getGrandparent(); + else if(targetContainer.getTemplate().startsWith("object/tangible/inventory/shared_lightsaber_inventory")) lightsaber = (WeaponObject) targetContainer.getContainer(); + lightsaberInventory = (TangibleObject) lightsaber.getSlottedObject("saber_inv"); + + if(lightsaber.getAttachment("weaponBaseDamageMin") == null) lightsaber.setAttachment("weaponBaseDamageMin", lightsaber.getMinDamage()); + if(lightsaber.getAttachment("weaponBaseDamageMax") == null) lightsaber.setAttachment("weaponBaseDamageMax", lightsaber.getMaxDamage()); + + // Check if item is a lightsaber component + if(lightsaber == null) return; + if(lightsaberInventory == null) return; + if(lightsaber.getContainer() instanceof CreatureObject) + { + actor.sendSystemMessage("@jedi_spam:saber_not_while_equpped", (byte) 0); + return; + } + + if(!item.getTemplate().startsWith("object/tangible/component/weapon/lightsaber/")) + { + actor.sendSystemMessage("@jedi_spam:saber_not_crystal", (byte) 0); + return; + } + if(lightsaber.getAttachment("hasColorCrystal") == null) lightsaber.setAttachment("hasColorCrystal", false); + if(item.getAttributes().containsKey("@obj_attr_n:color") && (Boolean) lightsaber.getAttachment("hasColorCrystal") && !(targetContainer.getContainer() instanceof CreatureObject)) + { + actor.sendSystemMessage("@jedi_spam:saber_already_has_color", (byte) 0); + return; + } + + // Find our tuner + if(item.getAttachment("tunerId") == null) item.setAttachment("tunerId", 0); + tunerId = (int) item.getAttachment("tunerId"); + + // Check if player tuned the crystal + if(tunerId == 0) + { + actor.sendSystemMessage("@jedi_spam:saber_crystal_not_tuned", (byte) 0); + return; + } + if(tunerId != actor.getObjectId()) + { + actor.sendSystemMessage("@jedi_spam:saber_crystal_not_owner", (byte) 0); + return; + } + else item.getContainer().transferTo(actor, targetContainer, item); + + // Calculate attributes + lightsaber.setAttachment("hasColorCrystal", false); + + lightsaberInventory.viewChildren(lightsaberInventory, false, false, new Traverser() + { + WeaponObject saber; + TangibleObject saberInv; + + int minDamageBonus = 0; + int maxDamageBonus = 0; + Boolean hasColorCrystal = false; + + public void process(SWGObject item) + { + saber = (WeaponObject) item.getGrandparent(); + saberInv = (TangibleObject) saber.getSlottedObject("saber_inv"); + + if(item.getAttributes().get("@obj_attr_n:color") != null) // "Blade Color Modification" + { + int crystalColorIndex = resources.datatables.LightsaberColors.getByName((String) item.getAttributes().get("@obj_attr_n:color")); + + byte bladeType = crystalColorIndex > 256 ? (byte) (crystalColorIndex % 256) : 0x00; + byte bladeColor = crystalColorIndex > 256 ? (byte) 0x00 : (byte) crystalColorIndex; + + saber.setCustomizationVariable("private/alternate_shader_blade", bladeType); + saber.setCustomizationVariable("/private/index_color_blade", bladeColor); + + // System.out.println("bladeColorName: " + item.getAttributes().get("@obj_attr_n:color")); + // System.out.println("bladeColor: " + bladeColor); + // System.out.println("bladeType: " + bladeType); + // System.out.println(); + + hasColorCrystal = true; + } + else + { + minDamageBonus += Integer.parseInt(item.getAttributes().get("@obj_attr_n:mindamage")); // "Minimum Damage" + maxDamageBonus += Integer.parseInt(item.getAttributes().get("@obj_attr_n:maxdamage")); // "Maximum Damage" + } + + int saberBaseDamageMin = (int) saber.getAttachment("weaponBaseDamageMin"); + int saberBaseDamageMax = (int) saber.getAttachment("weaponBaseDamageMax"); + + saber.setMinDamage(saberBaseDamageMin + minDamageBonus); + saber.setMaxDamage(saberBaseDamageMax + maxDamageBonus); + + saber.setAttachment("hasColorCrystal", hasColorCrystal); + } + }); + } + private int getWeaponCriticalChance(CreatureObject actor, SWGObject item) { int weaponCriticalChance = 0; String weaponCriticalSkillMod = (core.scriptService.getMethod("scripts/equipment/", "weapon_critical", "weap_" + item.getStringAttribute("cat_wpn_damage.wpn_category").replace("@obj_attr_n:wpn_category_", "")).__call__().asString()); diff --git a/src/services/LootService.java b/src/services/LootService.java index c7b4e365..61182e17 100644 --- a/src/services/LootService.java +++ b/src/services/LootService.java @@ -288,6 +288,17 @@ public class LootService implements INetworkDispatch { } } + public SWGObject generateLootItem(CreatureObject requester, String template) + { + LootRollSession rollSession = new LootRollSession(); + rollSession.setSessionPlanet(requester.getPlanet()); + + handleLootPoolItems(template, rollSession); + if(rollSession.getDroppedItems().get(0) != null) return rollSession.getDroppedItems().get(0); + + return null; + } + @SuppressWarnings("unused") private void handleLootPoolItems(String itemName,LootRollSession lootRollSession){ @@ -402,7 +413,7 @@ public class LootService implements INetworkDispatch { customName = setRandomStatsJewelry(droppedItem, lootRollSession); } - if (customName!=null) + if (!customName.isEmpty()) handleCustomDropName(droppedItem, customName); if (stackable!=-1){ @@ -454,6 +465,9 @@ public class LootService implements INetworkDispatch { droppedItem.setStringAttribute("required_faction", requiredFaction); } + if(core.scriptService.getMethod(itemPath,"","customSetup") != null) + core.scriptService.callScript(itemPath, "", "customSetup", droppedItem); + lootRollSession.addDroppedItem(droppedItem); System.out.println("END REACHED"); @@ -536,12 +550,21 @@ public class LootService implements INetworkDispatch { } - private void setCustomization(TangibleObject droppedItem,String itemName) { + public void setCustomization(TangibleObject droppedItem,String itemName) { // Example color crystal if (itemName.contains("colorcrystal")) { System.out.println("colorcrystal"); - droppedItem.setCustomizationVariable("/private/index_color_1", (byte) new Random().nextInt(11)); + + int crystalColor = new Random().nextInt(11); + + droppedItem.setCustomizationVariable("/private/index_color_1", (byte) crystalColor); + droppedItem.getAttributes().put("@obj_attr_n:condition", "100/100"); + droppedItem.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF "); + droppedItem.getAttributes().put("@obj_attr_n:color", resources.datatables.LightsaberColors.get(crystalColor)); + droppedItem.setAttachment("radial_filename", "item/tunable"); + //droppedItem.getAttributes().put("@obj_attr_n:color", "@jedi_spam:saber_color_" + crystalColor); // Commented out for now + } // Example power crystal @@ -561,7 +584,7 @@ public class LootService implements INetworkDispatch { // } } - private void handleSpecialItems(TangibleObject droppedItem,String itemName) { + public void handleSpecialItems(TangibleObject droppedItem,String itemName) { if (itemName.contains("kraytpearl")){ handleKraytPearl(droppedItem); } @@ -693,25 +716,25 @@ public class LootService implements INetworkDispatch { droppedItem.setDetailName("item_junk_imitation_pearl_01_01"); return; case "kraytpearl_poor": - qualityString="Poor"; + qualityString="@jedi_spam:crystal_quality_0"; break; case "kraytpearl_fair": - qualityString="Fair"; + qualityString="@jedi_spam:crystal_quality_1"; break; case "kraytpearl_good": - qualityString="Good"; + qualityString="@jedi_spam:crystal_quality_2"; break; case "kraytpearl_quality": - qualityString="Quality"; + qualityString="@jedi_spam:crystal_quality_3"; break; case "kraytpearl_select": - qualityString="Select"; + qualityString="@jedi_spam:crystal_quality_4"; break; case "kraytpearl_premium": - qualityString="Premium"; + qualityString="@jedi_spam:crystal_quality_5"; break; case "kraytpearl_flawless": - qualityString="Flawless"; + qualityString="@jedi_spam:crystal_quality_6"; break; default: qualityString="Undetermined"; @@ -721,6 +744,7 @@ public class LootService implements INetworkDispatch { droppedItem.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF "); droppedItem.getAttributes().put("@obj_attr_n:crystal_quality", qualityString); droppedItem.setAttachment("radial_filename", "item/tunable"); + droppedItem.setAttachment("TuneType", "KraytPearl"); } private void handlePowerCrystal(TangibleObject droppedItem) { @@ -730,28 +754,28 @@ public class LootService implements INetworkDispatch { switch (itemName) { case "powercrystal_poor": - qualityString="Poor"; + qualityString="@jedi_spam:crystal_quality_0"; break; case "powercrystal_fair": - qualityString="Fair"; + qualityString="@jedi_spam:crystal_quality_1"; break; case "powercrystal_good": - qualityString="Good"; + qualityString="@jedi_spam:crystal_quality_2"; break; case "powercrystal_quality": - qualityString="Quality"; + qualityString="@jedi_spam:crystal_quality_3"; break; case "powercrystal_select": - qualityString="Select"; + qualityString="@jedi_spam:crystal_quality_4"; break; case "powercrystal_premium": - qualityString="Premium"; + qualityString="@jedi_spam:crystal_quality_5"; break; case "powercrystal_flawless": - qualityString="Flawless"; + qualityString="@jedi_spam:crystal_quality_6"; break; case "powercrystal_perfect": - qualityString="Perfect"; + qualityString="@jedi_spam:crystal_quality_7"; break; default: qualityString="Undetermined"; @@ -761,8 +785,129 @@ public class LootService implements INetworkDispatch { droppedItem.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF "); droppedItem.getAttributes().put("@obj_attr_n:crystal_quality", qualityString); droppedItem.setAttachment("radial_filename", "item/tunable"); + droppedItem.setAttachment("TuneType", "PowerCrystal"); } + public void tuneProcess(SWGObject tunableObject){ + + String objectType = (String) tunableObject.getAttachment("LootItemName"); + if (objectType==null || objectType.length()==0) + return; + + int finalMinDmg = 0; + int finalMaxDmg = 0; + String tunableObjectName = ""; + + if (objectType.contains("powercrystal")){ + tunableObjectName = "Power Crystal"; + switch (objectType) { + case "powercrystal_poor": // Poor - Up to 3/4 damage + int minValue1 = 1; + int maxValue1 = 3; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + case "powercrystal_fair": // Fair - Up to 5/6 damage + minValue1 = 3; + maxValue1 = 5; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + case "powercrystal_good": // Good - Up to 10/11 damage + minValue1 = 6; + maxValue1 = 10; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + case "powercrystal_quality": // Quality - Up to 12/13 damage + minValue1 = 11; + maxValue1 = 12; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + case "powercrystal_select": // Select - Up to 14/15 damage + minValue1 = 13; + maxValue1 = 14; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + case "powercrystal_premium": // Premium - Up to 17/18 damage + minValue1 = 15; + maxValue1 = 17; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + case "powercrystal_flawless": // Flawless - 20-22 possibly more or less + finalMinDmg = 20; + finalMaxDmg = 22; + break; + case "powercrystal_perfect": // Perfect - Up to 23/25 damage + minValue1 = 21; + maxValue1 = 23; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + } + } + + if (objectType.contains("kraytpearl")){ + tunableObjectName = "Krayt Dragon Pearl"; + switch (objectType) { + case "kraytpearl_poor": // Poor - Up to 3/4 damage + int minValue1 = 1; + int maxValue1 = 3; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + case "kraytpearl_fair": // Fair - Up to 5/6 damage + minValue1 = 3; + maxValue1 = 5; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + case "kraytpearl_good": // Good - Up to 10/11 damage + minValue1 = 6; + maxValue1 = 10; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + case "kraytpearl_quality": // Quality - Up to 12/13 damage + minValue1 = 11; + maxValue1 = 12; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + case "kraytpearl_select": // Select - Up to 14/15 damage + minValue1 = 13; + maxValue1 = 14; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + case "kraytpearl_premium": // Premium - Up to 18/19 damage + minValue1 = 15; + maxValue1 = 17; + finalMinDmg = minValue1+new Random().nextInt(maxValue1+1-minValue1); + finalMaxDmg = finalMinDmg+1; + break; + case "kraytpearl_flawless": // Flawless - 19/20 damage + finalMinDmg = 19; + finalMaxDmg = 20; + break; + case "kraytpearl_ancient": // Ancient - 20/22 damage + finalMinDmg = 20; + finalMaxDmg = 22; + break; + } + } + + tunableObject.getAttributes().remove("@obj_attr_n:crystal_quality"); +// tunableObject.setIntAttribute("@obj_attr_n:componentbonuslow", finalMinDmg); +// tunableObject.setIntAttribute("@obj_attr_n:componentbonushigh", finalMaxDmg); + tunableObject.setIntAttribute("@obj_attr_n:mindamage", finalMinDmg); + tunableObject.setIntAttribute("@obj_attr_n:maxdamage", finalMaxDmg); + //((TangibleObject) tunableObject).setCustomName2(tunableObjectName + " (tuned)"); + } + private void setWeaponStat(WeaponObject weapon, String statName, String minValue, String maxValue){ // weapon.setConditionDamage(100); shows 1000/926 ??!! diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index efaa0919..37f6757e 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -65,9 +65,7 @@ import resources.common.ObjControllerOpcodes; import resources.common.Opcodes; import resources.common.OutOfBand; import resources.common.ProsePackage; -import resources.common.RGB; import resources.common.SpawnPoint; -import resources.common.StringUtilities; import resources.datatables.DisplayType; import resources.datatables.Options; import resources.datatables.PlayerFlags; @@ -91,8 +89,8 @@ import engine.clientdata.visitors.CrcStringTableVisitor; import engine.clientdata.visitors.DatatableVisitor; import engine.clients.Client; import engine.resources.common.CRC; +import engine.resources.common.RGB; import engine.resources.container.Traverser; -import engine.resources.objects.DraftSchematic; import engine.resources.objects.SWGObject; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; @@ -490,15 +488,15 @@ public class PlayerService implements INetworkDispatch { SWGObject preDesignatedCloner = null; - if(creature.getAttachment("preDesignatedCloner") != null) { - preDesignatedCloner = core.objectService.getObject((long) creature.getAttachment("preDesignatedCloner")); + if(creature.getPlayerObject().getBindLocation() != 0) { + preDesignatedCloner = core.objectService.getObject((long) creature.getPlayerObject().getBindLocation()); if(preDesignatedCloner != null) - cloneData.put(preDesignatedCloner.getObjectID(), core.mapService.getClosestCityName(preDesignatedCloner) /*+ " (" + String.valueOf(position.getDistance2D(cloner.getPosition())) + "m)"*/); + cloneData.put(preDesignatedCloner.getObjectID(), "@base_player:clone_location_registered_select_begin " + core.mapService.getClosestCityName(preDesignatedCloner) + " @base_player:clone_location_registered_select_end"); } final long preDesignatedObjectId = (preDesignatedCloner != null) ? preDesignatedCloner.getObjectID() : 0; cloners.stream().filter(c -> c.getObjectID() != preDesignatedObjectId).forEach(c -> cloneData.put(c.getObjectID(), core.mapService.getClosestCityName(c))); - final SUIWindow window = core.suiService.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "@base_player:revive_title", "Select the desired option and click OK.", + final SUIWindow window = core.suiService.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "@base_player:revive_title", "@base_player:clone_prompt_header", cloneData, creature, null, 0); Vector returnList = new Vector(); returnList.add("List.lstList:SelectedRow"); @@ -555,7 +553,7 @@ public class PlayerService implements INetworkDispatch { } creature.setFactionStatus(0); - core.buffService.addBuffToCreature(creature, "cloning_sickness"); + core.buffService.addBuffToCreature(creature, "cloning_sickness", creature); } @@ -575,12 +573,37 @@ public class PlayerService implements INetworkDispatch { return; } - player.setProfession(profession); - String xpType = ((profession.contains("entertainer")) ? "entertainer" : ((profession.contains("trader")) ? "crafting" : "combat_general")); - int experience = player.getXp(xpType); + // Remove old profession abilties + + try { + String[] skills; + + DatatableVisitor skillTemplate = ClientFileManager.loadFile("datatables/skill_template/skill_template.iff", DatatableVisitor.class); + + for (int s = 0; s < skillTemplate.getRowCount(); s++) { + if (skillTemplate.getObject(s, 0) != null) { + if (((String) skillTemplate.getObject(s, 0)).equals(player.getProfession())) { + skills = ((String) skillTemplate.getObject(s, 4)).split(","); + + for (String skill : skills) { + core.skillService.removeSkill(creature, skill); + } + + break; + } + } + } + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + + core.skillService.resetExpertise(creature); + + player.setProfession(profession); + try { experienceTable = ClientFileManager.loadFile("datatables/player/player_level.iff", DatatableVisitor.class); @@ -606,28 +629,27 @@ public class PlayerService implements INetworkDispatch { public void resetLevel(CreatureObject creature) { PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); - try - { - for (Long equipmentId : new ArrayList(creature.getEquipmentList())) { - - SWGObject equipment = core.objectService.getObject(equipmentId); - - if (equipment == null) { - continue; - } - - switch (equipment.getTemplate()) { - case "object/tangible/inventory/shared_character_inventory.iff": - case "object/tangible/inventory/shared_appearance_inventory.iff": - case "object/tangible/datapad/shared_character_datapad.iff": - case "object/tangible/bank/shared_character_bank.iff": - case "object/tangible/mission_bag/shared_mission_bag.iff": - case "object/weapon/creature/shared_creature_default_weapon.iff": - continue; - default: - core.equipmentService.unequip(creature, equipment); - } + try { + for (Long equipmentId : new ArrayList(creature.getEquipmentList())) { + + SWGObject equipment = core.objectService.getObject(equipmentId); + + if (equipment == null) { + continue; } + + switch (equipment.getTemplate()) { + case "object/tangible/inventory/shared_character_inventory.iff": + case "object/tangible/inventory/shared_appearance_inventory.iff": + case "object/tangible/datapad/shared_character_datapad.iff": + case "object/tangible/bank/shared_character_bank.iff": + case "object/tangible/mission_bag/shared_mission_bag.iff": + case "object/weapon/creature/shared_creature_default_weapon.iff": + continue; + default: + core.equipmentService.unequip(creature, equipment); + } + } } catch (Exception e) { e.printStackTrace(); } @@ -770,18 +792,20 @@ public class PlayerService implements INetworkDispatch { int arrayLength = items.length; - if (wookieeItems.length > 0 && creature.getStfName().contains("wookiee")) + if (wookieeItems.length > 0 && creature.getStfName().contains("wookiee")) { arrayLength = wookieeItems.length; - else if (ithorianItems.length > 0 && creature.getStfName().contains("ithorian")) + } else if (ithorianItems.length > 0 && creature.getStfName().contains("ithorian")) { arrayLength = ithorianItems.length; - + } + for (int n = 0; n < arrayLength; n++) { String item = items[n]; - if (creature.getStfName().contains("wookiee")) + if (creature.getStfName().contains("wookiee")) { item = wookieeItems[n]; - else if (creature.getStfName().contains("ithorian")) + } else if (creature.getStfName().contains("ithorian")) { item = ithorianItems[n]; + } try { String customServerTemplate = null; @@ -801,8 +825,7 @@ public class PlayerService implements INetworkDispatch { } catch (Exception e) { e.printStackTrace(); } - } - + } } } } @@ -878,194 +901,195 @@ public class PlayerService implements INetworkDispatch { return; } - //synchronized(objectMutex) { - try { - experienceTable = ClientFileManager.loadFile("datatables/player/player_level.iff", DatatableVisitor.class); - - // Cannot gain more than half of the XP needed for the next level in one go - // Do check - - int experienceBonus = creature.getSkillModBase("flush_with_success"); - - experience += ((experience * experienceBonus) / 100); - - // 1. Add the experience. - if (experience > 0 && !creature.isStationary()) { - creature.showFlyText(OutOfBand.ProsePackage("@base_player:prose_flytext_xp", experience), 2.5f, new RGB(180, 60, 240), 1, true); - } - - String xpType = ((player.getProfession().contains("entertainer")) ? "entertainer" : ((player.getProfession().contains("trader")) ? "crafting" : "combat_general")); - - if (player.getXpList().containsKey(xpType)) { - experience += player.getXp(xpType); - } - - player.setXp(xpType, experience); - - // 2. See if they need to level up. - for (int i = 0; i < experienceTable.getRowCount(); i++) { - if (experienceTable.getObject(i, 0) != null) { - if (experience >= ((Integer) experienceTable.getObject(i, 1))) { - if (creature.getLevel() < (Integer) experienceTable.getObject(i, 0)) { - creature.playEffectObject("clienteffect/level_granted.cef", ""); - creature.getClient().getSession().write((new ClientMfdStatusUpdateMessage((float) ((creature.getLevel() == 90) ? 90 : (creature.getLevel() + 1)), "/GroundHUD.MFDStatus.vsp.role.targetLevel")).serialize()); - creature.setLevel(((Integer) experienceTable.getObject(i, 0)).shortValue()); - core.scriptService.callScript("scripts/collections/", "master_" + player.getProfession(), "addMasterBadge", core, creature); - - // 3. Add the relevant health/action and expertise points. - float luck = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getLuck").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getLuck").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("luck"))); - float precision = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getPrecision").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getPrecision").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("precision"))); - float strength = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getStrength").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getStrength").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("strength"))); - float constitution = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getConstitution").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getConstitution").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("constitution"))); - float stamina = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getStamina").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getStamina").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("stamina"))); - float agility = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getAgility").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getAgility").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("agility"))); - float health = 100; - float action = 75; - - int healthGranted = ((Integer) experienceTable.getObject(i, 4)); - - if (luck >= 1) { - core.skillModService.addSkillMod(creature, "luck", (int) luck); - creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_0", (int) luck), DisplayType.Broadcast); - } - - if (precision >= 1) { - core.skillModService.addSkillMod(creature, "precision", (int) precision); - creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_1", (int) precision), DisplayType.Broadcast); - } - - if (strength >= 1) { - core.skillModService.addSkillMod(creature, "strength", (int) strength); - creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_2", (int) strength), DisplayType.Broadcast); - } - - if (constitution >= 1) { - core.skillModService.addSkillMod(creature, "constitution", (int) constitution); - creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_3", (int) constitution), DisplayType.Broadcast); - } - - if (stamina >= 1) { - core.skillModService.addSkillMod(creature, "stamina", (int) stamina); - creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_4", (int) stamina), DisplayType.Broadcast); - } - - if (agility >= 1) { - core.skillModService.addSkillMod(creature, "agility", (int) agility); - creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_5", (int) agility), DisplayType.Broadcast); - } - - if (health >= 1) { - creature.setMaxHealth((creature.getMaxHealth() + (int) health + (healthGranted - creature.getGrantedHealth()))); - creature.setHealth(creature.getMaxHealth()); - creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_6", (((int) health) + (((int) constitution) * 8) + (((int) stamina) * 2))), DisplayType.Broadcast); - } - - if (action >= 1) { - creature.setMaxAction((creature.getMaxAction() + (int) action)); - creature.setAction(creature.getMaxAction()); - creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_7", (((int) action) + (((int) stamina) * 8) + (((int) constitution) * 2))), DisplayType.Broadcast); - } - - creature.setGrantedHealth(((Integer) experienceTable.getObject(i, 4))); - // -> Expertise point added automatically by client - creature.showFlyText(OutOfBand.ProsePackage("@cbt_spam:level_up"), 2.5f, new RGB(100, 149, 237), 0, true); - - // 4. Adds roadmap rewards - int level = creature.getLevel(); - - if ((level == 4 || level == 7 || level == 10) || ((level > 10) && (((creature.getLevel() - 10) % 4) == 0))) { - int skill = ((level <= 10) ? ((level - 1) / 3) : ((((level - 10) / 4)) + 3)); - String roadmapSkillName = ""; - DatatableVisitor skillTemplate, roadmap; - - try { - skillTemplate = ClientFileManager.loadFile("datatables/skill_template/skill_template.iff", DatatableVisitor.class); - - for (int s = 0; s < skillTemplate.getRowCount(); s++) { - if (skillTemplate.getObject(s, 0) != null) { - if (((String) skillTemplate.getObject(s, 0)).equals(player.getProfession())) { - String[] skillArray = ((String) skillTemplate.getObject(s, 4)).split(","); - roadmapSkillName = skillArray[skill]; - break; - } - } - } - - creature.showFlyText(OutOfBand.ProsePackage("@cbt_spam:skill_up"), 2.5f, new RGB(154, 205, 50), 0, true); - creature.playEffectObject("clienteffect/skill_granted.cef", ""); - creature.playMusic("sound/music_acq_bountyhunter.snd"); - core.skillService.addSkill(creature, roadmapSkillName); - player.setProfessionWheelPosition(roadmapSkillName); - } catch (InstantiationException | IllegalAccessException e) { - e.printStackTrace(); - } - - try { - roadmap = ClientFileManager.loadFile("datatables/roadmap/item_rewards.iff", DatatableVisitor.class); - - Vector rewards = new Vector(); - - for (int s = 0; s < roadmap.getRowCount(); s++) { - if (roadmap.getObject(s, 0) != null) { - if (((String) roadmap.getObject(s, 1)).equals(roadmapSkillName)) { - String[] apts = ((String) roadmap.getObject(s, 2)).split(","); - String[] items = ((String) roadmap.getObject(s, 4)).split(","); - String[] wookieeItems = ((String) roadmap.getObject(s, 5)).split(","); - String[] ithorianItems = ((String) roadmap.getObject(s, 6)).split(","); - - for (int n = 0; n < items.length; n++) { - String item = items[n]; - - if (wookieeItems[0].length() > 0 && creature.getStfName().contains("wookiee")) { - item = wookieeItems[n]; - } else if (ithorianItems[0].length() > 0 && creature.getStfName().contains("ithorian")) { - item = ithorianItems[n]; - } - - try { - String customServerTemplate = null; - - if (item.contains("/")) { - item = (item.substring(0, (item.lastIndexOf("/") + 1)) + "shared_" + item.substring((item.lastIndexOf("/") + 1))); - } else { - customServerTemplate = item; - item = core.scriptService.callScript("scripts/roadmap/", player.getProfession(), "getRewards", item).asString(); - } - - if (item != null && item != "") { - SWGObject itemObj = core.objectService.createObject(item, 0, creature.getPlanet(), new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), customServerTemplate); - rewards.add(itemObj); - } else { - //System.out.println("Can't find template: " + item); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - } - } - } - - if (rewards != null && !rewards.isEmpty()) { - giveItems(creature, rewards); - } - - } catch (InstantiationException | IllegalAccessException e) { - e.printStackTrace(); - } - } - } - } - } - } - } catch (InstantiationException | IllegalAccessException e) { - e.printStackTrace(); + try { + experienceTable = ClientFileManager.loadFile("datatables/player/player_level.iff", DatatableVisitor.class); + + // Cannot gain more than half of the XP needed for the next level in one go + // TODO: Do check + + int experienceBonus = creature.getSkillModBase("flush_with_success"); + + experience += ((experience * experienceBonus) / 100); + + // 1. Add the experience. + if (experience > 0 && !creature.isStationary()) { + creature.showFlyText(OutOfBand.ProsePackage("@base_player:prose_flytext_xp", experience), 2.5f, new RGB(180, 60, 240), 1, true); } - if(player.getProfession().equals("entertainer_1a") && creature.getLevel() == (short) 90 && creature.getEntertainerExperience() != null) - creature.getEntertainerExperience().cancel(true); - //} + String xpType = ((player.getProfession().contains("entertainer")) ? "entertainer" : ((player.getProfession().contains("trader")) ? "crafting" : "combat_general")); + + if (player.getXpList().containsKey(xpType)) { + experience += player.getXp(xpType); + } + + player.setXp(xpType, experience); + + // 2. See if they need to level up. + for (int i = 0; i < experienceTable.getRowCount(); i++) { + if (experienceTable.getObject(i, 0) != null) { + if (experience >= ((Integer) experienceTable.getObject(i, 1))) { + if (creature.getLevel() < (Integer) experienceTable.getObject(i, 0)) { + creature.playEffectObject("clienteffect/level_granted.cef", ""); + creature.getClient().getSession().write((new ClientMfdStatusUpdateMessage((float) ((creature.getLevel() == 90) ? 90 : (creature.getLevel() + 1)), "/GroundHUD.MFDStatus.vsp.role.targetLevel")).serialize()); + creature.setLevel(((Integer) experienceTable.getObject(i, 0)).shortValue()); + core.scriptService.callScript("scripts/collections/", "master_" + player.getProfession(), "addMasterBadge", core, creature); + + // 3. Add the relevant health/action and expertise points. + float luck = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getLuck").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getLuck").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("luck"))); + float precision = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getPrecision").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getPrecision").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("precision"))); + float strength = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getStrength").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getStrength").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("strength"))); + float constitution = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getConstitution").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getConstitution").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("constitution"))); + float stamina = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getStamina").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getStamina").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("stamina"))); + float agility = (((((float) (core.scriptService.getMethod("scripts/roadmap/", player.getProfession(), "getAgility").__call__().asInt()) + (core.scriptService.getMethod("scripts/roadmap/", creature.getStfName(), "getAgility").__call__().asInt())) / ((float) 90)) * ((float) creature.getLevel())) - ((float) creature.getSkillModBase("agility"))); + float health = 100; + float action = 75; + + int healthGranted = ((Integer) experienceTable.getObject(i, 4)); + + if (luck >= 1) { + core.skillModService.addSkillMod(creature, "luck", (int) luck); + creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_0", (int) luck), DisplayType.Broadcast); + } + + if (precision >= 1) { + core.skillModService.addSkillMod(creature, "precision", (int) precision); + creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_1", (int) precision), DisplayType.Broadcast); + } + + if (strength >= 1) { + core.skillModService.addSkillMod(creature, "strength", (int) strength); + creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_2", (int) strength), DisplayType.Broadcast); + } + + if (constitution >= 1) { + core.skillModService.addSkillMod(creature, "constitution", (int) constitution); + creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_3", (int) constitution), DisplayType.Broadcast); + } + + if (stamina >= 1) { + core.skillModService.addSkillMod(creature, "stamina", (int) stamina); + creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_4", (int) stamina), DisplayType.Broadcast); + } + + if (agility >= 1) { + core.skillModService.addSkillMod(creature, "agility", (int) agility); + creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_5", (int) agility), DisplayType.Broadcast); + } + + if (health >= 1) { + creature.setMaxHealth((creature.getMaxHealth() + (int) health + (healthGranted - creature.getGrantedHealth()))); + creature.setHealth(creature.getMaxHealth()); + creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_6", (((int) health) + (((int) constitution) * 8) + (((int) stamina) * 2))), DisplayType.Broadcast); + } + + if (action >= 1) { + creature.setMaxAction((creature.getMaxAction() + (int) action)); + creature.setAction(creature.getMaxAction()); + creature.sendSystemMessage(OutOfBand.ProsePackage("@spam:level_up_stat_gain_7", (((int) action) + (((int) stamina) * 8) + (((int) constitution) * 2))), DisplayType.Broadcast); + } + + creature.setGrantedHealth(((Integer) experienceTable.getObject(i, 4))); + // -> Expertise point added automatically by client + creature.showFlyText(OutOfBand.ProsePackage("@cbt_spam:level_up"), 2.5f, new RGB(100, 149, 237), 0, true); + + // 4. Adds roadmap rewards + int level = creature.getLevel(); + + if ((level == 4 || level == 7 || level == 10) || ((level > 10) && (((creature.getLevel() - 10) % 4) == 0))) { + int skill = ((level <= 10) ? ((level - 1) / 3) : ((((level - 10) / 4)) + 3)); + String roadmapSkillName = ""; + DatatableVisitor skillTemplate, roadmap; + + try { + skillTemplate = ClientFileManager.loadFile("datatables/skill_template/skill_template.iff", DatatableVisitor.class); + + for (int s = 0; s < skillTemplate.getRowCount(); s++) { + if (skillTemplate.getObject(s, 0) != null) { + if (((String) skillTemplate.getObject(s, 0)).equals(player.getProfession())) { + String[] skillArray = ((String) skillTemplate.getObject(s, 4)).split(","); + roadmapSkillName = skillArray[skill]; + break; + } + } + } + + creature.showFlyText(OutOfBand.ProsePackage("@cbt_spam:skill_up"), 2.5f, new RGB(154, 205, 50), 0, true); + creature.playEffectObject("clienteffect/skill_granted.cef", ""); + creature.playMusic("sound/music_acq_bountyhunter.snd"); + core.skillService.addSkill(creature, roadmapSkillName); + player.setProfessionWheelPosition(roadmapSkillName); + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + + try { + roadmap = ClientFileManager.loadFile("datatables/roadmap/item_rewards.iff", DatatableVisitor.class); + + Vector rewards = new Vector(); + + for (int s = 0; s < roadmap.getRowCount(); s++) { + if (roadmap.getObject(s, 0) != null) { + if (((String) roadmap.getObject(s, 1)).equals(roadmapSkillName)) { + String[] apts = ((String) roadmap.getObject(s, 2)).split(","); + String[] items = ((String) roadmap.getObject(s, 4)).split(","); + String[] wookieeItems = ((String) roadmap.getObject(s, 5)).split(","); + String[] ithorianItems = ((String) roadmap.getObject(s, 6)).split(","); + + int arrayLength = items.length; + + if (wookieeItems.length > 0 && creature.getStfName().contains("wookiee")) { + arrayLength = wookieeItems.length; + } else if (ithorianItems.length > 0 && creature.getStfName().contains("ithorian")) { + arrayLength = ithorianItems.length; + } + + for (int n = 0; n < arrayLength; n++) { + String item = items[n]; + + if (creature.getStfName().contains("wookiee")) { + item = wookieeItems[n]; + } else if (creature.getStfName().contains("ithorian")) { + item = ithorianItems[n]; + } + + try { + String customServerTemplate = null; + + if (item.contains("/")) { + item = (item.substring(0, (item.lastIndexOf("/") + 1)) + "shared_" + item.substring((item.lastIndexOf("/") + 1))); + } else { + customServerTemplate = item; + item = core.scriptService.callScript("scripts/roadmap/", player.getProfession(), "getRewards", item).asString(); + } + + if (item != null && item != "") { + SWGObject itemObj = core.objectService.createObject(item, 0, creature.getPlanet(), new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), customServerTemplate); + } else { + //System.out.println("Can't find template: " + item); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + + if (rewards != null && !rewards.isEmpty()) { + giveItems(creature, rewards); + } + + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + } + } + } + } + } + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } } public void addPlayerTitle(PlayerObject player, String title) { @@ -1213,7 +1237,7 @@ public class PlayerService implements INetworkDispatch { // need to set a unity attachment. ringList.get(0).setAttachment("unity", (Boolean) true); - if(!acceptor.getEquipmentList().contains(ringList.get(0))) + if(!acceptor.getEquipmentList().contains(ringList.get(0).getObjectId())) core.equipmentService.equip(acceptor, ringList.get(0)); aGhost.setSpouseName(proposer.getCustomName()); @@ -1248,7 +1272,7 @@ public class PlayerService implements INetworkDispatch { SWGObject selectedRing = core.objectService.getObject(ringWindow.getObjectIdByIndex(index)); selectedRing.setAttachment("unity", (Boolean) true); - if(!actor.getEquipmentList().contains(selectedRing)) + if(!actor.getEquipmentList().contains(selectedRing.getObjectId())) core.equipmentService.equip(actor, selectedRing); PlayerObject aGhost = (PlayerObject) actor.getSlottedObject("ghost"); @@ -1330,8 +1354,8 @@ public class PlayerService implements INetworkDispatch { victim.setCashCredits(0); } else { victim.setBankCredits(victim.getBankCredits() - bounty); } - if (!core.missionService.addToExistingBounty(attacker.getObjectId(), victim.getObjectId(), bounty)) - core.missionService.createNewBounty(attacker, victim.getObjectId(), bounty); + if (!core.missionService.addToExistingBounty(attacker.getObjectID(), victim.getObjectID(), bounty)) + core.missionService.createNewBounty(attacker, victim.getObjectID(), bounty); victim.sendSystemMessage("You have placed a bounty for " + bounty + " credits on the head of " + attacker.getCustomName(), (byte) 0); } diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index a6d592e7..1eb8ede6 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -52,6 +52,7 @@ import engine.clientdata.visitors.PortalVisitor.Cell; import engine.clients.Client; import engine.resources.common.Event; import engine.resources.common.Mesh3DTriangle; +import engine.resources.common.RGB; import engine.resources.common.Ray; import engine.resources.container.Traverser; import engine.resources.database.ODBCursor; @@ -78,6 +79,7 @@ import resources.objects.building.BuildingObject; import resources.objects.cell.CellObject; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; +import resources.objects.harvester.HarvesterObject; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.common.*; @@ -192,7 +194,7 @@ public class SimulationService implements INetworkDispatch { while(cursor.hasNext()) { SWGObject building = core.objectService.getObject(((SWGObject) cursor.next()).getObjectID()); - if(building == null || !(building instanceof BuildingObject)) + if(building == null || (!(building instanceof BuildingObject) && !(building instanceof HarvesterObject))) continue; if(building.getAttachment("hasLoadedServerTemplate") == null) core.objectService.loadServerTemplate(building); @@ -764,8 +766,6 @@ public class SimulationService implements INetworkDispatch { if(object.getAttachment("proposer") != null) object.setAttachment("proposer", null); - object.setPvPBitmask(0); - //session.suspendWrite(); final long objectId = object.getObjectID(); @@ -911,7 +911,7 @@ public class SimulationService implements INetworkDispatch { HeartBeatMessage heartBeat = new HeartBeatMessage(); session.write(heartBeat.serialize()); - CmdStartScene startScene = new CmdStartScene((byte) 0, object.getObjectID(), object.getPlanet().getPath(), object.getTemplate(), newPos.x, newPos.y, newPos.z, System.currentTimeMillis() / 1000, object.getRadians()); + CmdStartScene startScene = new CmdStartScene((byte) 0, object.getObjectID(), object.getPlanet().getPath(), object.getTemplate(), newPos.x, newPos.y, newPos.z, core.getGalacticTime() / 1000, object.getRadians()); session.write(startScene.serialize()); handleZoneIn(client); @@ -947,6 +947,36 @@ public class SimulationService implements INetworkDispatch { teleport(obj, obj.getPosition(), newRotation, obj.getParentId()); } + public void rotateToFaceTarget(SWGObject object, SWGObject target) { + float radians = (float) (((float) Math.atan2(target.getPosition().z - object.getPosition().z, target.getPosition().x - object.getPosition().x)) - object.getRadians()); + transform(object, radians, object.getPosition()); + } + + public void faceTarget(SWGObject object, SWGObject target) { + float direction = (float) Math.atan2(target.getWorldPosition().x - object.getWorldPosition().x, target.getWorldPosition().z - object.getWorldPosition().z); + + if (direction < 0) { + direction = (float) (2 * Math.PI + direction); + } + + if (Math.abs(direction - object.getRadians()) < 0.05) { + return; + } + + Quaternion quaternion = new Quaternion((float) Math.cos(direction / 2), 0, (float) Math.sin(direction / 2), 0); + + if (quaternion.y < 0.0f && quaternion.w > 0.0f) { + quaternion.y *= -1; + quaternion.w *= -1; + } + + if (object.getContainer() instanceof CellObject) { + NGECore.getInstance().simulationService.moveObject(object, object.getPosition(), quaternion, object.getMovementCounter(), 0, (CellObject) object.getContainer()); + } else { + NGECore.getInstance().simulationService.moveObject(object, object.getPosition(), quaternion, object.getMovementCounter(), 0, null); + } + } + public void teleport(SWGObject obj, Point3D position, Quaternion orientation, long cellId) { if(cellId == 0) { diff --git a/src/services/StaticService.java b/src/services/StaticService.java index e15ca781..11b9dee8 100644 --- a/src/services/StaticService.java +++ b/src/services/StaticService.java @@ -32,11 +32,11 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Random; import resources.common.FileUtilities; import resources.objects.building.BuildingObject; import resources.objects.cell.CellObject; +import services.ai.AIActor; import services.spawn.MobileTemplate; import main.NGECore; import engine.clientdata.ClientFileManager; @@ -96,6 +96,11 @@ public class StaticService implements INetworkDispatch { } public SWGObject spawnObject(String template, String planetName, long cellId, float x, float y, float z, float qW, float qX, float qY, float qZ) { + return spawnObject(template, planetName, cellId, x, y, z, qW, qX, qY, qZ, -1); + } + + + public SWGObject spawnObject(String template, String planetName, long cellId, float x, float y, float z, float qW, float qX, float qY, float qZ, int respawnTime) { Planet planet = core.terrainService.getPlanetByName(planetName); if (planet == null) { @@ -115,13 +120,22 @@ public class StaticService implements INetworkDispatch { long objectId = core.objectService.getDOId(planetName, template, 0, buildingId, cellNumber, x, y, z); - SWGObject object; - + SWGObject object = null; MobileTemplate mobileTemplate = core.spawnService.getMobileTemplate(template); + if (mobileTemplate != null) { - System.out.println("SPAWN MOBILE TEMPLATE " + mobileTemplate.getTemplates().get(new Random().nextInt(mobileTemplate.getTemplates().size()))); - object = core.spawnService.spawnCreature(template, planetName, cellId, x, y, z, qW, qX, qY, qZ, (short) -1); - System.out.println("objectid " + object.getObjectID()); + if(respawnTime > 0) { + try { + MobileTemplate clone = (MobileTemplate) mobileTemplate.clone(); + object = core.spawnService.spawnCreature(template, objectId, planetName, cellId, x, y, z, qW, qX, qY, qZ, (short) -1); + clone.setRespawnTime(respawnTime); + ((AIActor) object.getAttachment("AI")).setMobileTemplate(clone); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + } else { + object = core.spawnService.spawnCreature(template, objectId, planetName, cellId, x, y, z, qW, qX, qY, qZ, (short) -1); + } } else { object = core.objectService.createObject(template, objectId, planet, new Point3D(x, y, z), new Quaternion(qW, qX, qY, qZ), null, true, true); } diff --git a/src/services/bazaar/BazaarService.java b/src/services/bazaar/BazaarService.java index c94feb02..2efde273 100644 --- a/src/services/bazaar/BazaarService.java +++ b/src/services/bazaar/BazaarService.java @@ -81,6 +81,7 @@ public class BazaarService implements INetworkDispatch { public BazaarService(NGECore core) { this.core = core; + core.commandService.registerCommand("createvendor"); loadAuctionItems(); } @@ -141,9 +142,11 @@ public class BazaarService implements INetworkDispatch { SWGObject terminal = core.objectService.getObject(terminalId); if(terminal == null) return; + int permission = 2; + if(terminal.getAttachment("isVendor") != null && (Boolean) terminal.getAttachment("isVendor")) + permission = (long) terminal.getAttachment("vendorOwner") == player.getObjectID() ? 0 : 1; Point3D pos = terminal.getWorldPosition(); - session.write(new IsVendorOwnerResponseMessage(2, 0, terminalId, getVendorUID((TangibleObject) terminal)).serialize()); - + session.write(new IsVendorOwnerResponseMessage(permission, 0, terminalId, getVendorUID((TangibleObject) terminal)).serialize()); }); diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index 26e6c611..e75acf0a 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -708,6 +708,8 @@ public class ChatService implements INetworkDispatch { while(cursor.hasNext()) { Mail mail = (Mail) cursor.next(); + if(mail == null) + continue; if(mail.getRecieverId() == obj.getObjectID()) { sendPersistentMessageHeader(client, mail); } diff --git a/src/services/collections/CollectionService.java b/src/services/collections/CollectionService.java index d0b43268..dc339b70 100644 --- a/src/services/collections/CollectionService.java +++ b/src/services/collections/CollectionService.java @@ -32,10 +32,12 @@ import org.python.core.PyObject; import resources.common.FileUtilities; import resources.common.OutOfBand; import resources.datatables.DisplayType; +import resources.datatables.STF; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import main.NGECore; import engine.clientdata.ClientFileManager; +import engine.clientdata.StfTable; import engine.clientdata.visitors.DatatableVisitor; import engine.resources.scene.Point3D; import engine.resources.service.INetworkDispatch; @@ -309,16 +311,16 @@ public class CollectionService implements INetworkDispatch { } if (hidden && !(getCollection(creature, collectionName) > 0)) { - creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_hidden_slot_added", "TO", collectionName), DisplayType.Broadcast); + creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_hidden_slot_added", "TO", STF.get("@collection_n:" + collectionName).replace(":", " -")), DisplayType.Broadcast); } player.setCollections(collections.toByteArray()); if (!noMessage) { if (!bookName.equals("crafting_book")) { - creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_slot_added", "TU", slotName, "TO", collectionName), DisplayType.Broadcast); + creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_slot_added", "TU", STF.get("@collection_n:" + slotName).replace(":", " -"), "TO", STF.get("@collection_n:" + collectionName).replace(":", " -")), DisplayType.Broadcast); } else { - creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_slot_increment", "TU", slotName, "TO", collectionName), DisplayType.Broadcast); + creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_slot_increment", "TU", STF.get("@collection_n:" + slotName).replace(":", " -"), "TO", STF.get("@collection_n:" + collectionName).replace(":", " -")), DisplayType.Broadcast); } } @@ -355,9 +357,79 @@ public class CollectionService implements INetworkDispatch { } if (isComplete(creature, collectionName)) { - creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_collection_complete", "TO", collectionName), DisplayType.Broadcast); + creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_collection_complete", "TO", STF.get("@collection_n:" + collectionName).replace(":", " -")), DisplayType.Broadcast); if (!noReward) { + try { + StfTable stf = new StfTable("clientdata/string/en/collection_reward.stf"); + + for (int s = 1; s < stf.getRowCount(); s++) { + String key = stf.getStringById(s).getKey(); + + if (key != null && key.equals(collectionName)) { + String reward = stf.getStringById(s).getValue(); + + if (reward != null && reward.length() > 0) { + int xp = 0; + + // Give experience + + try { + DatatableVisitor experienceTable = ClientFileManager.loadFile("datatables/player/player_level.iff", DatatableVisitor.class); + + for (int i = 0; i < experienceTable.getRowCount(); i++) { + if (experienceTable.getObject(i, 0) != null) { + if (creature.getLevel() == (Integer) experienceTable.getObject(i, 0)) { + int nextLevelRequiredXp = (Integer) experienceTable.getObject((i + 1), 1); + int currentLevelRequiredXp = (Integer) experienceTable.getObject(i, 1); + xp = nextLevelRequiredXp - currentLevelRequiredXp; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + if (reward.contains("small amount of XP")) { + xp = 10 / 100 * xp; + } else if (reward.contains("medium amount of XP")) { + xp = 20 / 100 * xp; + } else if (reward.contains("large amount of XP")) { + xp = 30 / 100 * xp; + } else if (reward.contains("Space XP")) { + // TODO calculate space XP + } else if (reward.contains("XP")) { + String[] array = reward.split(" "); + + for (int i = 0; i < array.length; i++) { + if (array[i].equals("XP")) { + if (i == 0) { + xp = 20 / 100 * xp; + } else { + try { + xp = Integer.parseInt(array[i - 1]); + } catch (NumberFormatException e) { + xp = 20 / 100 * xp; + } + } + } + } + } + + if (xp > 0) { + if (key.contains("space")) { + // TODO add XP to space (not currently implemented) + } else { + core.playerService.giveExperience(creature, xp); + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + if (FileUtilities.doesFileExist("scripts/collections/" + collectionName + ".py")) { PyObject method = core.scriptService.getMethod("scripts/collections/", collectionName, "complete"); @@ -374,7 +446,7 @@ public class CollectionService implements INetworkDispatch { if (trackServerFirst) { if (core.guildService.getGuildObject().addServerFirst(collectionName, new ServerFirst(creature.getCustomName(), creature.getObjectId(), collectionName, System.currentTimeMillis()))) { addCollection(creature, "bdg_server_first_01"); - creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_server_first", "TT", core.getGalaxyName(), "TO", collectionName), DisplayType.Broadcast); + creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_server_first", "TT", core.getGalaxyName(), "TO", STF.get("@collection_n:" + collectionName).replace(":", " -")), DisplayType.Broadcast); } } @@ -747,7 +819,7 @@ public class CollectionService implements INetworkDispatch { } if (collection.equals(collectionName)) { - creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_collection_reset", "TO", collectionName), DisplayType.Broadcast); + creature.sendSystemMessage(OutOfBand.ProsePackage("@collection:player_collection_reset", "TO", STF.get("@collection_n:" + collectionName).replace(":", " -")), DisplayType.Broadcast); } continue; diff --git a/src/services/collections/ServerFirst.java b/src/services/collections/ServerFirst.java index 0811d9c9..3bbf0adc 100644 --- a/src/services/collections/ServerFirst.java +++ b/src/services/collections/ServerFirst.java @@ -25,10 +25,10 @@ import java.io.Serializable; import org.apache.mina.core.buffer.IoBuffer; -import resources.objects.Delta; - import com.sleepycat.persist.model.Persistent; +import engine.resources.objects.Delta; + @Persistent public class ServerFirst extends Delta implements Serializable { diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index fc61e166..db087e12 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -45,6 +45,7 @@ import resources.buffs.DamageOverTime; import resources.common.FileUtilities; import resources.common.OutOfBand; import resources.common.ProsePackage; +import resources.datatables.DisplayType; import resources.datatables.Options; import resources.datatables.Elemental; import resources.datatables.Posture; @@ -509,7 +510,27 @@ public class CombatService implements INetworkDispatch { } private boolean attemptCombat(CreatureObject attacker, TangibleObject target) { - + + if (attacker.isInStealth()) { + attacker.setInStealth(false); + + if (attacker.getPlayerObject() != null && attacker.getPlayerObject().getProfession().equals("spy_1a")) { + attacker.setRadarVisible(true); + } + } + + if (attacker.getSlottedObject("ghost") != null) { + PlayerObject ghost = attacker.getPlayerObject(); + if (ghost.getBountyMissionId() != 0) { + MissionObject mission = (MissionObject) core.objectService.getObject(ghost.getBountyMissionId()); + if (mission != null && mission.getBountyMarkId() == target.getObjectID()) { + target.addDefender(attacker); + + target.updatePvpStatus(); + } + } + } + if(target.getDefendersList().contains(attacker) && attacker.getDefendersList().contains(target)) return true; @@ -529,7 +550,7 @@ public class CombatService implements INetworkDispatch { } else { attacker.addDefender(target); // See below comment } - + //attacker.addDefender(target); // Why do we need to add target to defender list twice? return true; @@ -783,10 +804,12 @@ public class CombatService implements INetworkDispatch { } synchronized(target.getMutex()) { + if(core.mountService.isMounted(target)) core.mountService.dismount(target, (CreatureObject) target.getContainer()); + target.setHealth(1); target.setPosture((byte) 13); target.setTurnRadius(0); - target.setSpeedMultiplierBase(0); + target.setSpeedMultiplierBase(0); } ScheduledFuture incapTask = scheduler.schedule(() -> { @@ -804,10 +827,10 @@ public class CombatService implements INetworkDispatch { }, target.getIncapTimer(), TimeUnit.SECONDS); target.setIncapTask(incapTask); core.buffService.addBuffToCreature(target, "incapWeaken", target); - if(target.getSlottedObject("ghost") != null) { + if(target.getSlottedObject("ghost") != null && attacker.getSlottedObject("ghost") != null) { target.sendSystemMessage(new OutOfBand(new ProsePackage("base_player", "prose_victim_incap", attacker.getCustomName())), (byte) 0); attacker.sendSystemMessage(new OutOfBand(new ProsePackage("base_player", "prose_target_incap", target.getCustomName())), (byte) 0); - } + } else {target.sendSystemMessage(new OutOfBand(new ProsePackage("base_player", "prose_victim_incap", "@" + attacker.getStfFilename() + ":" + attacker.getStfName())), (byte) 0); } return; } else if(target.getHealth() - damage <= 0 && target.getAttachment("AI") != null) { synchronized(target.getMutex()) { @@ -985,40 +1008,48 @@ public class CombatService implements INetworkDispatch { } public void deathblowPlayer(CreatureObject attacker, CreatureObject target) { - target.stopIncapTask(); target.setIncapTask(null); target.setPosture((byte) 14); if (target.getSlottedObject("ghost") != null && attacker.getSlottedObject("ghost") != null) { boolean bountyWindow = true; - if (target.getPlayerObject().getBountyMissionId() != 0) { - MissionObject mission = (MissionObject) core.objectService.getObject(target.getPlayerObject().getBountyMissionId()); - if (mission != null && mission.getBountyObjId() == attacker.getObjectId()) { - bountyWindow = false; - target.sendSystemMessage(new OutOfBand(new ProsePackage("bounty_hunter", "bounty_failed_hunter", attacker.getCustomName())), (byte) 0); - - ProsePackage pp = new ProsePackage("bounty_hunter", "bounty_failed_target", attacker.getCustomName()); - pp.setToCustomString("their"); - attacker.sendSystemMessage(new OutOfBand(pp), (byte) 0); - - core.missionService.handleMissionAbort(target, mission); - } - } else if (attacker.getPlayerObject().getBountyMissionId() != 0) { + + if (attacker.getPlayerObject().getBountyMissionId() != 0) { // Bounty Hunter is deathblowing (attacker) + bountyWindow = false; MissionObject mission = (MissionObject) core.objectService.getObject(attacker.getPlayerObject().getBountyMissionId()); - if (mission != null && mission.getBountyObjId() == target.getObjectId()) { - bountyWindow = false; - ProsePackage targetProse = new ProsePackage("bounty_hunter", "bounty_success_target", attacker.getCustomName()); - targetProse.setDiInteger(mission.getCreditReward()); - target.sendSystemMessage(new OutOfBand(targetProse), (byte) 0); + + if (mission != null && mission.getBountyMarkId() == target.getObjectID()) { - ProsePackage attackerProse = new ProsePackage("bounty_hunter", "bounty_success_hunter", target.getCustomName()); - attackerProse.setToCustomString("their"); // should be his or her: http://youtu.be/BqeDQQSETJI?t=2m19s - attackerProse.setDiInteger(mission.getCreditReward()); - attacker.sendSystemMessage(new OutOfBand(attackerProse), (byte) 0); + ProsePackage attackerPp = new ProsePackage("bounty_hunter", "bounty_success_hunter", target.getCustomName()); + attackerPp.setToCustomString("his"); // TODO: Genders + attackerPp.setDiInteger(mission.getCreditReward()); + attacker.sendSystemMessage(new OutOfBand(attackerPp), DisplayType.Broadcast); + + ProsePackage targetPp = new ProsePackage ("bounty_hunter", "bounty_success_hunter", attacker.getCustomName()); + targetPp.setDiInteger(mission.getCreditReward()); + target.sendSystemMessage(new OutOfBand(targetPp), DisplayType.Broadcast); core.missionService.handleMissionComplete(attacker, mission); } + + } else if (target.getPlayerObject().getBountyMissionId() != 0) { // Bounty Hunter is being deathblown (They're the target) + bountyWindow = false; + MissionObject mission = (MissionObject) core.objectService.getObject(target.getPlayerObject().getBountyMissionId()); + + if (mission != null && mission.getBountyMarkId() == attacker.getObjectID()) { + + ProsePackage attackerPp = new ProsePackage("bounty_hunter", "bounty_failed_target", target.getCustomName()); + attackerPp.setToCustomString("his"); // TODO: Genders + attackerPp.setDiInteger(mission.getCreditReward()); + attacker.sendSystemMessage(new OutOfBand(attackerPp), DisplayType.Broadcast); + + ProsePackage targetPp = new ProsePackage ("bounty_hunter", "bounty_failed_hunter", attacker.getCustomName()); + target.sendSystemMessage(new OutOfBand(targetPp), DisplayType.Broadcast); + + core.missionService.handleMissionAbort(target, mission); + } + } if(target.getDuelList().contains(attacker)) @@ -1032,7 +1063,11 @@ public class CombatService implements INetworkDispatch { target.removeDefender(attacker); target.setSpeedMultiplierBase(0); target.setTurnRadius(0); - target.sendSystemMessage(new OutOfBand(new ProsePackage("base_player", "prose_victim_dead", attacker.getCustomName())), (byte) 0); + + if (attacker.getSlottedObject("ghost") != null) + target.sendSystemMessage(new OutOfBand(new ProsePackage("base_player", "prose_victim_dead", attacker.getCustomName())), (byte) 0); + else + target.sendSystemMessage(new OutOfBand(new ProsePackage("base_player", "prose_victim_dead", "@" + attacker.getStfFilename() + ":" + attacker.getStfName())), (byte) 0); core.playerService.sendCloningWindow(target, attacker.getSlottedObject("ghost") != null); } diff --git a/src/services/command/BaseSWGCommand.java b/src/services/command/BaseSWGCommand.java index 9c2d639f..8ea09061 100644 --- a/src/services/command/BaseSWGCommand.java +++ b/src/services/command/BaseSWGCommand.java @@ -214,9 +214,9 @@ public class BaseSWGCommand implements Cloneable { this.commandCRC = commandCRC; } - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } public boolean isGmCommand() { return (godLevel > 0); diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index c778a25f..f30411d3 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -38,6 +38,7 @@ import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; import engine.clients.Client; import engine.resources.common.CRC; +import engine.resources.common.RGB; import engine.resources.objects.SWGObject; import engine.resources.scene.Point3D; import engine.resources.service.INetworkDispatch; @@ -47,6 +48,7 @@ import protocol.swg.ObjControllerMessage; import protocol.swg.objectControllerObjects.CommandEnqueue; import protocol.swg.objectControllerObjects.CommandEnqueueRemove; import protocol.swg.objectControllerObjects.StartTask; +import resources.objects.cell.CellObject; import resources.objects.creature.CreatureObject; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; @@ -141,6 +143,11 @@ public class CommandService implements INetworkDispatch { return false; } + + if (!target.isInQuadtree() && (target.getContainer() == null || !(target.getContainer() instanceof CellObject))) { + break; + } + if (!core.simulationService.checkLineOfSight(actor, target)) { actor.showFlyText("@combat_effects:cant_see", 1.5f, new RGB(72, 209, 204), 1, true); return false; @@ -170,6 +177,10 @@ public class CommandService implements INetworkDispatch { return false; } + if (!target.isInQuadtree() && (target.getContainer() == null || !(target.getContainer() instanceof CellObject))) { + break; + } + if (!core.simulationService.checkLineOfSight(actor, target)) { actor.showFlyText("@combat_effects:cant_see", 1.5f, new RGB(72, 209, 204), 1, true); return false; @@ -218,6 +229,10 @@ public class CommandService implements INetworkDispatch { return false; } + if (!target.isInQuadtree() && (target.getContainer() == null || !(target.getContainer() instanceof CellObject))) { + break; + } + if (!core.simulationService.checkLineOfSight(actor, target)) { actor.showFlyText("@combat_effects:cant_see", 1.5f, new RGB(72, 209, 204), 1, true); return false; diff --git a/src/services/gcw/FactionService.java b/src/services/gcw/FactionService.java index e7312318..b0df8f91 100644 --- a/src/services/gcw/FactionService.java +++ b/src/services/gcw/FactionService.java @@ -276,22 +276,20 @@ public class FactionService implements INetworkDispatch { long targetId = target.getObjectID(); - if (object.getSlottedObject("datapad") != null) { - object.getSlottedObject("datapad").viewChildren(object, false, false, (mission) -> { - if (mission instanceof MissionObject && ((MissionObject) mission).getBountyObjId() == targetId) { - ref.set(PvpStatus.Attackable | PvpStatus.Aggressive); - } - }); + if (ghost != null && ghost.getBountyMissionId() != 0) { + if (((MissionObject) core.objectService.getObject(ghost.getBountyMissionId())).getBountyMarkId() == targetId) { + ref.set(PvpStatus.Attackable | PvpStatus.Aggressive); + } } - if (ghost != null && ghost.getProfession().contains("smuggler") && + /*if (ghost != null && ghost.getProfession().contains("smuggler") && target.getSlottedObject("datapad") != null) { target.getSlottedObject("datapad").viewChildren(target, false, false, (mission) -> { - if (mission instanceof MissionObject && ((MissionObject) mission).getBountyObjId() == object.getObjectID()) { + if (mission instanceof MissionObject && ((MissionObject) mission).getBountyMarkId() == object.getObjectID()) { ref.set(PvpStatus.Attackable); } }); - } + }*/ pvpBitmask |= ref.get(); diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index 2b092b6f..ce6d289e 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -128,7 +128,7 @@ public class HousingService implements INetworkDispatch { String playerFirstName = actor.getCustomName().split(" ")[0]; if (sign != null) { - sign.setCustomName2(playerFirstName + "'s House"); + sign.setCustomName(playerFirstName + "'s House"); } //building.add(sign); @@ -168,10 +168,15 @@ public class HousingService implements INetworkDispatch { } } - // Save structure to DB - /*building.createTransaction(core.getBuildingODB().getEnvironment()); - core.getBuildingODB().put(building, Long.class, BuildingObject.class, building.getTransaction()); - building.getTransaction().commitSync();*/ + core.objectService.persistObject(building.getObjectID(), building, core.getSWGObjectODB()); + + } + + public void saveBuildings() { + core.objectService.getObjectList() + .values().stream() + .filter(obj -> obj instanceof BuildingObject && obj.getAttachment("structureOwner") != null) + .forEach(building -> core.objectService.persistObject(building.getObjectID(), building, core.getSWGObjectODB())); } @SuppressWarnings("unchecked") @@ -465,7 +470,7 @@ public class HousingService implements INetworkDispatch { Vector itemList = building.getItemsList(); for (int i=0;i entryCounts = new ConcurrentHashMap(); - private Vector bountyList = new Vector(); + private Map bountyMap = new ConcurrentHashMap(); private ObjectDatabase bountiesODB; private Random ran = new Random(); @@ -150,17 +151,25 @@ public class MissionService implements INetworkDispatch { int terminalType = (int) terminal.getAttachment("terminalType"); - if (terminalType == TerminalType.GENERIC) { - handleMissionListRequest(core.objectService.getObject(request.getObjectId()), request.getTickCount(), TerminalType.GENERIC); - } else if (terminalType == TerminalType.BOUNTY) { - if (!object.hasSkill("class_bountyhunter_phase1_novice")) { object.sendSystemMessage("@mission/mission_generic:not_bounty_hunter_terminal", (byte) 0); } - else { handleMissionListRequest(core.objectService.getObject(request.getObjectId()), request.getTickCount(), TerminalType.BOUNTY); } - } else if (terminalType == TerminalType.ENTERTAINER) { + switch(terminalType) { + case TerminalType.GENERIC: + handleMissionListRequest(core.objectService.getObject(request.getObjectId()), request.getTickCount(), TerminalType.GENERIC); + break; + + case TerminalType.BOUNTY: + if (!object.hasSkill("class_bountyhunter_phase1_novice")) { object.sendSystemMessage("@mission/mission_generic:not_bounty_hunter_terminal", (byte) 0); } + else { handleMissionListRequest(core.objectService.getObject(request.getObjectId()), request.getTickCount(), TerminalType.BOUNTY); } + break; + + case TerminalType.ARTISAN: + //handleMissionListRequest(core.objectService.getObject(request.getObjectId()), request.getTickCount(), TerminalType.ARTISAN); + break; + + case TerminalType.ENTERTAINER: + //handleMissionListRequest(core.objectService.getObject(request.getObjectId()), request.getTickCount(), TerminalType.ENTERTAINER); + break; - } else if (terminalType == TerminalType.ARTISAN) { - - } else { - //Console.println("ERROR: Unsupported terminal " + terminal.getObjectId()); + default: break; } } @@ -291,7 +300,7 @@ public class MissionService implements INetworkDispatch { randomBountyMission(player, mission); else if (type == TerminalType.ARTISAN) - return; + randomSurveyMission(player, mission); else return; @@ -301,20 +310,20 @@ public class MissionService implements INetworkDispatch { } else if (typeTwoCount.get() < 5) { - if (type == TerminalType.GENERIC) + if (type == TerminalType.GENERIC) // destroy + return; + + else if (type == TerminalType.ARTISAN) // crafting return; else if (type == TerminalType.BOUNTY) - return; - - else if (type == TerminalType.ARTISAN) - return; + randomBountyMission(player, mission); else return; - //mission.setRepeatCount(requestCounter); - //typeTwoCount.incrementAndGet(); + mission.setRepeatCount(requestCounter); + typeTwoCount.incrementAndGet(); } } }); @@ -355,13 +364,18 @@ public class MissionService implements INetworkDispatch { } }); - if (hasBountyMission.get() && mission.getMissionType().equals("bounty")) // Can only have 1 bounty mission - return false; + if (mission.getMissionType().equals("bounty")) { + if (hasBountyMission.get()) { + creature.sendSystemMessage("@bounty_hunter:already_have_target", (byte) 0); + return false; + } + } if (missionCount.get() == 2) { creature.sendSystemMessage("@mission/mission_generic:too_many_missions", (byte) 0); return false; } + missionBag.transferTo(creature, datapad, mission); createMissionObjective(creature, mission); return true; @@ -403,11 +417,75 @@ public class MissionService implements INetworkDispatch { bountyObjective.activate(core, creature); return bountyObjective; + + case "survey": + SurveyMissionObjective surveyObjective = new SurveyMissionObjective(mission); + + mission.setObjective(surveyObjective); + + if (!silent) + surveyObjective.activate(core, creature); + + return surveyObjective; default: return null; } } + private void randomSurveyMission(SWGObject player, MissionObject mission) { + + byte generalType = (byte) (ran.nextInt(3) == 0 ? 1 : 0); + + // TODO: Change way of getting resources for planet. Possibly a map, would solve future concurrency problems. + Vector resources = core.resourceService.getSpawnedResourcesByPlanetAndType(player.getPlanetId(), generalType); + if (resources == null || resources.size() == 0) + return; + + // The level and reward calculations are taken from EMU. Can hardly find anything related to survey missions from NGE. + int maxLevel = 50; + int minLevel = 50; + float surveySkill = core.skillModService.getSkillModValue((CreatureObject) player, "surveying"); + + if (surveySkill > 30) { maxLevel += 10; } + if (surveySkill > 50) { maxLevel += 10; } + if (surveySkill > 70) { maxLevel += 10; } + if (surveySkill > 90) { maxLevel += 10; } + if (surveySkill > 100) { maxLevel += 5; } //Max mission level is 95. + + int randNumber = (maxLevel == minLevel ? 0 : ran.nextInt(maxLevel - minLevel)); // prevent bound error (can't randomize 0) + int randLevel = minLevel + (5 * randNumber) / 5; + + if (randLevel > maxLevel) + randLevel = maxLevel; + + GalacticResource resource = resources.get(ran.nextInt(resources.size() - 1)); + + if (resource == null) + return; + + ResourceRoot family = resource.getResourceRoot(); + + mission.setMissionType("survey"); + + String missionStf = "mission/mission_npc_survey_neutral_easy"; + + mission.setMissionId(getRandomStringEntry(missionStf)); + mission.setMissionDescription(missionStf); + mission.setMissionTitle(missionStf); + + mission.setCreator(nameGenerator.compose(2) + " " + nameGenerator.compose(3)); + + mission.setMissionLevel(randLevel); + + mission.setStartLocation(player.getPosition(), player.getPlanet().name); + + mission.setCreditReward(400 + (randLevel - minLevel) * 20 + ran.nextInt(100)); + + mission.setMissionTemplateObject(CRC.StringtoCRC(ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[family.getContainerType()])); // This should be the resource container obj + mission.setMissionTargetName(family.getResourceType() + family.getResourceClass()); + + } + private void randomDeliveryMission(SWGObject player, MissionObject mission) { mission.setMissionType("deliver"); @@ -416,7 +494,7 @@ public class MissionService implements INetworkDispatch { String missionStf = "mission/mission_deliver_neutral_" + difficulties[ran.nextInt(difficulties.length)]; mission.setMissionId(getRandomStringEntry(missionStf)); - mission.setMissionDescription(missionStf); + mission.setMissionDescription(missionStf, "o"); mission.setMissionTitle(missionStf); mission.setCreator(nameGenerator.compose(2) + " " + nameGenerator.compose(3)); @@ -430,7 +508,7 @@ public class MissionService implements INetworkDispatch { mission.setStartLocation(startLocation, player.getPlanet().name); mission.setDestination(destination, player.getPlanet().name); - mission.setCreditReward((int) (50 + ((startLocation.getDistance2D(destination) / 10)))); + mission.setCreditReward((int) (200 + ((startLocation.getDistance2D(destination) / 10)))); mission.setMissionTemplateObject(CRC.StringtoCRC("object/tangible/mission/shared_mission_datadisk.iff")); mission.setMissionTargetName("Datadisk"); @@ -439,23 +517,22 @@ public class MissionService implements INetworkDispatch { private void randomBountyMission(SWGObject player, MissionObject mission) { BountyListItem bountyTarget = null; - if (bountyList.size() > 0) { + if (bountyMap.size() > 0) { boolean gotBounty = false; int attempts = 0; while (!gotBounty && attempts < 5) { bountyTarget = getRandomBounty(); - if (bountyTarget == null || bountyTarget.getAssignedHunters().size() >= 3 || bountyTarget.getCreditReward() < 20000 || bountyTarget.getObjectId() == player.getObjectId()) { + if (bountyTarget == null || bountyTarget.getAssignedHunters().size() >= 3 || bountyTarget.getCreditReward() < 20000 || bountyTarget.getObjectID() == player.getObjectId()) { attempts++; continue; } else gotBounty = true; } + if (attempts >= 5 && !gotBounty) + return; } - - if (bountyTarget == null || bountyTarget.getAssignedHunters().contains(player.getObjectId())) - return; mission.setMissionType("bounty"); @@ -494,13 +571,13 @@ public class MissionService implements INetworkDispatch { mission.setMissionDescription(missionStf, "s"); } - mission.setMissionLevel(new Random().nextInt(100 - 95) + 95); + mission.setMissionLevel(95 + bountyTarget.getFailedAttempts()); mission.setCreditReward(bountyTarget.getCreditReward()); mission.setMissionTemplateObject(CRC.StringtoCRC("object/tangible/mission/shared_mission_bounty_jedi_target.iff")); - mission.setBountyObjId(bountyTarget.getObjectId()); + mission.setBountyMarkId(bountyTarget.getObjectID()); } public enum TerminalType {; @@ -511,23 +588,21 @@ public class MissionService implements INetworkDispatch { public static final int EXPLORER = 5; } - public Vector getBountyList() { - return this.bountyList; + public Map getBountyMap() { + return this.bountyMap; } public BountyListItem getRandomBounty() { - int bountyListId = ran.nextInt(bountyList.size()); - - return bountyList.get(bountyListId); + int bountyListId = ran.nextInt(bountyMap.size()); + List bounties = new ArrayList(bountyMap.keySet()); + + return bountyMap.get(bounties.get(bountyListId)); } public BountyListItem getBountyListItem(long objectId) { - Vector bounties = bountyList; - for (BountyListItem bounty : bounties) { - if (bounty.getObjectId() == objectId) - return bounty; - } - return null; + if (bountyMap.containsKey(objectId)) + return bountyMap.get(objectId); + else return null; } public BountyListItem createNewBounty(CreatureObject bountyTarget, long placer, int reward) { @@ -535,17 +610,17 @@ public class MissionService implements INetworkDispatch { if (player == null) return null; - if (getBountyListItem(bountyTarget.getObjectId()) != null) + if (getBountyListItem(bountyTarget.getObjectID()) != null) return null; - BountyListItem bounty = new BountyListItem(bountyTarget.getObjectId(), reward, core.playerService.getFormalProfessionName(player.getProfession()), bountyTarget.getFaction(), bountyTarget.getCustomName()); + BountyListItem bounty = new BountyListItem(bountyTarget.getObjectID(), reward, core.playerService.getFormalProfessionName(player.getProfession()), bountyTarget.getFaction(), bountyTarget.getCustomName()); if (placer != 0) bounty.getBountyPlacers().add(placer); - bountiesODB.put(bounty.getObjectId(), bounty); + bountiesODB.put(bountyTarget.getObjectID(), bounty); - bountyList.add(bounty); + bountyMap.put(bountyTarget.getObjectID(), bounty); //System.out.println("Created bounty of " + reward + " to " + bounty.getName()); return bounty; @@ -563,7 +638,7 @@ public class MissionService implements INetworkDispatch { if (placer != 0 && !bounty.getBountyPlacers().contains(placer)) bounty.getBountyPlacers().add(placer); - bountiesODB.put(bounty.getObjectId(), bounty); + bountiesODB.put(bounty.getObjectID(), bounty); //System.out.println("Added bounty of " + amountToAdd + " to " + bounty.getName()); return true; @@ -571,7 +646,7 @@ public class MissionService implements INetworkDispatch { public boolean removeBounty(long bountyTarget, boolean listRemove) { if (listRemove) - bountyList.remove(bountiesODB.get(bountyTarget)); + bountyMap.remove(bountiesODB.get(bountyTarget)); bountiesODB.remove(bountyTarget); return true; } @@ -585,11 +660,12 @@ public class MissionService implements INetworkDispatch { ODBCursor cursor = bountiesODB.getCursor(); while(cursor.hasNext()) { BountyListItem bounty = (BountyListItem) cursor.next(); - if (!core.characterService.playerExists(bounty.getObjectId())) { + + if (bounty != null && !core.characterService.playerExists(bounty.getObjectID())) { bounties.add(bounty); } } - bounties.stream().mapToLong(b -> b.getObjectId()).forEach(bountiesODB::remove); + bounties.stream().mapToLong(b -> b.getObjectID()).forEach(bountiesODB::remove); if (bounties.size() != 0) System.out.println("Removed " + bounties.size() + " bounties."); } diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index b15e8cbe..a1b6b79b 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -90,6 +90,7 @@ import engine.resources.container.WorldPermissions; import engine.resources.database.DatabaseConnection; import engine.resources.database.ODBCursor; import engine.resources.database.ObjectDatabase; +import engine.resources.objects.Delta; import engine.resources.objects.IPersistent; import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; @@ -99,7 +100,6 @@ import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import main.NGECore; import resources.objectives.BountyMissionObjective; -import resources.objects.Delta; import resources.objects.building.BuildingObject; import resources.objects.cell.CellObject; import resources.objects.craft.DraftSchematic; @@ -121,6 +121,8 @@ import resources.objects.tangible.TangibleObject; import resources.objects.tool.SurveyTool; import resources.objects.waypoint.WaypointObject; import resources.objects.weapon.WeaponObject; +import services.EquipmentService; +import services.ai.AIActor; import services.command.BaseSWGCommand; import services.command.CombatCommand; import services.bazaar.AuctionItem; @@ -157,6 +159,8 @@ public class ObjectService implements INetworkDispatch { } } core.bazaarService.saveAllItems(); + core.housingService.saveBuildings(); + core.harvesterService.saveHarvesters(); core.closeODBs(); } }); @@ -239,13 +243,7 @@ public class ObjectService implements INetworkDispatch { object = new SurveyTool(objectID, planet, Template, position, orientation); - } -// else if(Template.startsWith("object/tangible/container/drum/shared_treasure_drum.iff")) { -// -// object = new CreatureObject(objectID, planet, position, orientation, Template); -// -// } - else if(Template.startsWith("object/tangible")) { + } else if(Template.startsWith("object/tangible")) { object = new TangibleObject(objectID, planet, Template, position, orientation); @@ -253,7 +251,7 @@ public class ObjectService implements INetworkDispatch { object = new IntangibleObject(objectID, planet, position, orientation,Template); - }else if(Template.startsWith("object/weapon")) { + } else if(Template.startsWith("object/weapon")) { object = new WeaponObject(objectID, planet, Template, position, orientation); @@ -336,9 +334,10 @@ public class ObjectService implements INetworkDispatch { object.setAttachment("customServerTemplate", customServerTemplate); object.setisInSnapshot(isSnapshot); - if(!core.getObjectIdODB().contains(objectID)) - core.getObjectIdODB().put(objectID, new ObjectId(objectID)); - + synchronized(objectMutex) { + if(!core.getObjectIdODB().contains(objectID)) + core.getObjectIdODB().put(objectID, new ObjectId(objectID)); + } // Set Options - easier to set them across the board here // because we'll be spawning them despite most of them being unscripted. // Any such settings can be completely reset with setOptionsBitmask @@ -459,22 +458,23 @@ public class ObjectService implements INetworkDispatch { return; } - if (object instanceof TangibleObject && - ((TangibleObject) object).getRespawnTime() > 0) { + if (object.getAttachment("AI") != null && object.getAttachment("AI") instanceof AIActor && ((AIActor) object.getAttachment("AI")).getMobileTemplate().getRespawnTime() > 0) { final long objectId = object.getObjectID(); final String Template = object.getTemplate(); final Planet planet = object.getPlanet(); final Point3D position = object.getPosition(); final Quaternion orientation = object.getOrientation(); + final long cellId = ((object.getContainer() == null) ? 0L : object.getContainer().getObjectID()); + final short level = ((object instanceof CreatureObject) ? ((CreatureObject) object).getLevel() : (short) 0); scheduler.schedule(new Runnable() { @Override public void run() { - createObject(Template, objectId, planet, position, orientation); + NGECore.getInstance().spawnService.spawnCreature(Template, objectId, planet.getName(), cellId, position.x, position.y, position.z, orientation.w, orientation.x, orientation.y, orientation.z, level); } - }, ((TangibleObject) object).getRespawnTime(), TimeUnit.SECONDS); + }, ((AIActor) object.getAttachment("AI")).getMobileTemplate().getRespawnTime(), TimeUnit.SECONDS); } String filePath = "scripts/" + object.getTemplate().split("shared_" , 2)[0].replace("shared_", "") + object.getTemplate().split("shared_" , 2)[1].replace(".iff", "") + ".py"; @@ -502,6 +502,8 @@ public class ObjectService implements INetworkDispatch { if(parent != null) { if(parent instanceof CreatureObject) { + core.equipmentService.unequip((CreatureObject) parent, object); + ((CreatureObject) parent).removeObjectFromEquipList(object); ((CreatureObject) parent).removeObjectFromAppearanceEquipList(object); } @@ -618,24 +620,22 @@ public class ObjectService implements INetworkDispatch { long newId = 0; boolean found = false; // stack overflow when using recursion - while(!found) { - synchronized(objectMutex) { + synchronized(objectMutex) { + while(!found) { newId = highestId.incrementAndGet(); + PreparedStatement ps2; + try { + ps2 = databaseConnection.preparedStatement("UPDATE highestid SET id=" + newId + " WHERE id=(SELECT MAX(id) FROM highestid)"); + ps2.executeUpdate(); + ps2.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + if(objectList.containsKey(newId) || core.getObjectIdODB().contains(newId)) + found = false; + else + found = true; } - - PreparedStatement ps2; - - try { - ps2 = databaseConnection.preparedStatement("UPDATE highestid SET id=" + newId + " WHERE id=" + (newId-1)); - ps2.executeUpdate(); - ps2.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - if(getObject(newId) != null || core.getObjectIdODB().contains(newId)) - found = false; - else - found = true; } return newId; @@ -841,9 +841,9 @@ public class ObjectService implements INetworkDispatch { core.buffService.clearBuffs(creature); - CmdStartScene startScene = new CmdStartScene((byte) 0, objectId, creature.getPlanet().getPath(), creature.getTemplate(), position.x, position.y, position.z, core.getGalacticTime(), 0); + CmdStartScene startScene = new CmdStartScene((byte) 0, objectId, creature.getPlanet().getPath(), creature.getTemplate(), position.x, position.y, position.z, core.getGalacticTime() / 1000, 0); session.write(startScene.serialize()); - + ChatServerStatus chatServerStatus = new ChatServerStatus(); client.getSession().write(chatServerStatus.serialize()); @@ -906,8 +906,8 @@ public class ObjectService implements INetworkDispatch { if(!core.getConfig().getString("MOTD").equals("")) creature.sendSystemMessage(core.getConfig().getString("MOTD"), (byte) 2); - if (core.getBountiesODB().contains(creature.getObjectId())) - core.missionService.getBountyList().add((BountyListItem) core.getBountiesODB().get(creature.getObjectId())); + if (core.getBountiesODB().contains(creature.getObjectID())) + core.missionService.getBountyMap().put(creature.getObjectID(), (BountyListItem) core.getBountiesODB().get(creature.getObjectID())); if (creature.getSlottedObject("datapad") != null) { creature.getSlottedObject("datapad").viewChildren(creature, true, false, new Traverser() { diff --git a/src/services/pet/MountService.java b/src/services/pet/MountService.java index 6108e0a2..1ffc8949 100644 --- a/src/services/pet/MountService.java +++ b/src/services/pet/MountService.java @@ -63,7 +63,7 @@ public class MountService implements INetworkDispatch { } if (actor.getSlottedObject("ghost") == null) { - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:failed_to_call_vehicle"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:failed_to_call_vehicle"), DisplayType.Broadcast); return; } @@ -75,12 +75,12 @@ public class MountService implements INetworkDispatch { // Unsure if these are the right attributes. It doesn't generate the vehicle if the datapad has max # of vehicles. //if (datapad.getIntAttribute("data_size") >= datapad.getIntAttribute("datapad_slots")) { - //actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:has_max_vehicle"), DisplayType.Broadcast); + //actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:has_max_vehicle"), DisplayType.Broadcast); //return; //} if (actor.getTefTime() > 0){ - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:prose_cant_generate_yet", actor.getTefTime()), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:prose_cant_generate_yet", actor.getTefTime()), DisplayType.Broadcast); return; } @@ -114,7 +114,7 @@ public class MountService implements INetworkDispatch { core.objectService.destroyObject(deed); } - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:device_added"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:device_added"), DisplayType.Broadcast); call(actor, pcd); } @@ -129,38 +129,38 @@ public class MountService implements INetworkDispatch { } if (pcd == null) { - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cant_call"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cant_call"), DisplayType.Broadcast); return; } if (isMounted(actor)) { - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cannot_call_another_rideable"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cannot_call_another_rideable"), DisplayType.Broadcast); return; } if (actor.getCombatFlag() == 1) { - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cannot_call_in_combat"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cannot_call_in_combat"), DisplayType.Broadcast); return; } if (actor.getContainer() != null) { - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cannot_call_indoors"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cannot_call_indoors"), DisplayType.Broadcast); return; } if (actor.getPosture() == Posture.Dead) { - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cannot_call_while_dead"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cannot_call_while_dead"), DisplayType.Broadcast); return; } if (pcd.getSlottedObject("inventory") == null) { - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cant_call"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cant_call"), DisplayType.Broadcast); return; } if (pcd.getStringAttribute("required_faction") != null && pcd.getStringAttribute("required_faction").length() > 0) { if (!actor.getFaction().equals(pcd.getStringAttribute("required_faction"))) { - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:officer_faction"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:officer_faction"), DisplayType.Broadcast); return; } } @@ -175,7 +175,7 @@ public class MountService implements INetworkDispatch { if (mount == null) { // Somehow the vehicle object has got lost - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cant_call"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cant_call"), DisplayType.Broadcast); return; } @@ -194,24 +194,24 @@ public class MountService implements INetworkDispatch { private void callVehicle(CreatureObject actor, SWGObject pcd, PlayerObject player, CreatureObject mount) { if ((mount.getLevel() - actor.getLevel()) > 5) { - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cant_call_level"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cant_call_level"), DisplayType.Broadcast); return; } // FIXME Movement skillmod should always be used instead of CREO4 speed vars directly. Movement skillmod should NEVER be 0 unless rooted. Currently it is, which is wrong. //if (actor.getSkillModBase("movement") == 0) { - //actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cant_call_vehicle_rooted"), DisplayType.Broadcast); + //actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cant_call_vehicle_rooted"), DisplayType.Broadcast); //return; //} if (actor.getPlanet().getName().contains("kashyyyk") && !actor.getPlanet().getName().contains("_main")) { - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:vehicle_restricted_scene"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:vehicle_restricted_scene"), DisplayType.Broadcast); //mount_restricted_scene for creature mounts return; } if (player.isCallingCompanion()) { - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cant_call_1sec"), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cant_call_1sec"), DisplayType.Broadcast); return; } @@ -220,7 +220,7 @@ public class MountService implements INetworkDispatch { player.setCallingCompanion(true); if (actor.getTefTime() > 0) { - actor.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:call_vehicle_delay", actor.getTefTime()), DisplayType.Broadcast); + actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:call_vehicle_delay", actor.getTefTime()), DisplayType.Broadcast); } try { @@ -303,7 +303,7 @@ public class MountService implements INetworkDispatch { dismount(rider, mount); - rider.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:veh_disabled"), DisplayType.Broadcast); + rider.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:veh_disabled"), DisplayType.Broadcast); } }); @@ -361,12 +361,12 @@ public class MountService implements INetworkDispatch { } if (mount.getOption(Options.DISABLED)) { - repairer.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cannot_repair_disabled"), DisplayType.Broadcast); + repairer.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cannot_repair_disabled"), DisplayType.Broadcast); return; } if (mount.getConditionDamage() == 0) { - repairer.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:undamaged_vehicle"), DisplayType.Broadcast); + repairer.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:undamaged_vehicle"), DisplayType.Broadcast); return; } @@ -374,14 +374,14 @@ public class MountService implements INetworkDispatch { // But at the moment it's not important. if (!canRepair(repairer, mount)) { - repairer.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:repair_unrecognized_garages"), DisplayType.Broadcast); + repairer.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:repair_unrecognized_garages"), DisplayType.Broadcast); return; } int cost = mount.getConditionDamage(); if (repairer.getCashCredits() < cost) { - repairer.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:repair_failed_due_to_funds"), DisplayType.Broadcast); + repairer.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:repair_failed_due_to_funds"), DisplayType.Broadcast); return; } @@ -389,7 +389,7 @@ public class MountService implements INetworkDispatch { mount.setOptions(Options.DISABLED, false); - repairer.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:repaired_to_max"), DisplayType.Broadcast); + repairer.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:repaired_to_max"), DisplayType.Broadcast); } public void mount(CreatureObject rider, CreatureObject mount) { @@ -408,17 +408,17 @@ public class MountService implements INetworkDispatch { } if (mount.getOption(Options.DISABLED)) { - rider.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cant_mount_veh_disabled"), DisplayType.Broadcast); + rider.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cant_mount_veh_disabled"), DisplayType.Broadcast); return; } if (rider.isInStealth()) { - rider.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:no_mount_stealth"), DisplayType.Broadcast); + rider.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:no_mount_stealth"), DisplayType.Broadcast); return; } if (!canMount(rider, mount)) { - rider.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cant_mount"), DisplayType.Broadcast); + rider.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cant_mount"), DisplayType.Broadcast); return; } @@ -429,8 +429,8 @@ public class MountService implements INetworkDispatch { rider.setState(State.RidingMount, true); mount.setState(State.MountedCreature, true); - rider.setPosture((mount.getTemplate().contains("vehicle")) ? Posture.DrivingVehicle : Posture.RidingCreature); - //mount.setPosture((mount.getTemplate().contains("vehicle")) ? Posture.DrivingVehicle : Posture.RidingCreature); + // For some reason SOE decided the mount would need the following posture to be set for the character to have the driving or riding animation. + mount.setPosture((mount.getTemplate().contains("vehicle")) ? Posture.DrivingVehicle : Posture.RidingCreature); if (!mount.getSlotNameForObject(rider).equals("rider1")) { core.buffService.addBuffToCreature(rider, "vehicle_passenger", mount); @@ -551,7 +551,11 @@ public class MountService implements INetworkDispatch { LongAdder adder = new LongAdder(); - mount.getSlottedObject("inventory").viewChildren(mount, false, false, (obj) -> adder.increment()); + try { + mount.viewChildren(mount, false, false, (object) -> adder.increment()); + } catch(Exception ex) { + + } int passengers = adder.intValue(); @@ -589,8 +593,7 @@ public class MountService implements INetworkDispatch { } public void dismount(CreatureObject rider, CreatureObject mount) { - // Check if mount is currently mounted // Not necessary since nobody'll be dismounted if so - + if (rider == null || mount == null) { return; } @@ -605,12 +608,12 @@ public class MountService implements INetworkDispatch { // Dismount all passengers if (rider.getObjectID() == mount.getOwnerId()) { - CreatureObject owner = rider; - mount.viewChildren(owner, false, false, new Traverser() { - - public void process(SWGObject passenger) { - if (passenger != owner) dismount(rider, mount); + mount.viewChildren(mount, false, false, new Traverser() + { + public void process(SWGObject passenger) + { + if (passenger.getObjectId() != mount.getOwnerId()) dismount((CreatureObject) passenger, mount); } }); @@ -666,17 +669,17 @@ public class MountService implements INetworkDispatch { PlayerObject player = (PlayerObject) owner.getSlottedObject("ghost"); if (player.isCallingCompanion()) { - storer.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cant_store_1sec"), DisplayType.Broadcast); + storer.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cant_store_1sec"), DisplayType.Broadcast); return; } if (isMounted(owner, mount)) { - storer.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:must_dismount"), DisplayType.Broadcast); + storer.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:must_dismount"), DisplayType.Broadcast); return; } if (owner.getTefTime() > 0) { - owner.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:prose_cant_store_yet", owner.getTefTime()), DisplayType.Broadcast); + owner.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:prose_cant_store_yet", owner.getTefTime()), DisplayType.Broadcast); return; } @@ -764,9 +767,9 @@ public class MountService implements INetworkDispatch { core.objectService.destroyObject(pcd); if (type.contains("vehicle")) { - destroyer.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:vehicle_released"), DisplayType.Broadcast); + destroyer.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:vehicle_released"), DisplayType.Broadcast); } else { - destroyer.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:pet_released"), DisplayType.Broadcast); + destroyer.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:pet_released"), DisplayType.Broadcast); } } diff --git a/src/services/playercities/PlayerCity.java b/src/services/playercities/PlayerCity.java index 066c015e..2a271b9e 100644 --- a/src/services/playercities/PlayerCity.java +++ b/src/services/playercities/PlayerCity.java @@ -460,6 +460,14 @@ public class PlayerCity implements Serializable { electionVotes.add(vote); } + public void addToTreasury(int amountToAdd) { + cityTreasury += amountToAdd; + } + + public void removeFromTreasury(int amountToDeduct) { + cityTreasury -= amountToDeduct; + } + // Stalinesque method :D public void setElectionVotes(Vector electionVotes) { this.electionVotes = electionVotes; diff --git a/src/services/resources/HarvesterService.java b/src/services/resources/HarvesterService.java index 151a6d67..b49e048e 100644 --- a/src/services/resources/HarvesterService.java +++ b/src/services/resources/HarvesterService.java @@ -47,12 +47,15 @@ import main.NGECore; import engine.clients.Client; import engine.resources.common.CRC; import engine.resources.container.Traverser; +import engine.resources.database.ODBCursor; import engine.resources.objects.SWGObject; +import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import resources.common.ObjControllerOpcodes; +import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; import resources.objects.harvester.HarvesterMessageBuilder; import resources.objects.harvester.HarvesterObject; @@ -95,6 +98,35 @@ public class HarvesterService implements INetworkDispatch { scheduleHarvesterService(); } + public void loadHarvesters() { + ODBCursor cursor = core.getSWGObjectODB().getCursor(); + + while(cursor.hasNext()) { + final SWGObject harvester = (SWGObject) cursor.next(); + if(!(harvester instanceof HarvesterObject) || harvester == null) + continue; + core.objectService.getObjectList().put(harvester.getObjectID(), harvester); + Planet planet = core.terrainService.getPlanetByID(harvester.getPlanetId()); + harvester.setPlanet(planet); + harvester.viewChildren(harvester, true, true, (object) -> { + core.objectService.getObjectList().put(object.getObjectID(), object); + if(object.getParentId() != 0 && object.getContainer() == null) + object.setParent(harvester); + object.getContainerInfo(object.getTemplate()); + }); + allHarvesters.add((HarvesterObject) harvester); + } + + cursor.close(); + } + + public void saveHarvesters() { + for(HarvesterObject harvester : allHarvesters) { + core.objectService.persistObject(harvester.getObjectID(), harvester, core.getSWGObjectODB()); + } + } + + @Override public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { @@ -1055,6 +1087,7 @@ public class HarvesterService implements INetworkDispatch { //NGECore.getInstance().chatService.sendPersistentMessage(actor.getClient(), constructionNotificationMail); NGECore.getInstance().chatService.storePersistentMessage(constructionNotificationMail); NGECore.getInstance().chatService.sendPersistentMessageHeader(actor.getClient(), constructionNotificationMail); + //core.objectService.persistObject(harvester.getObjectID(), harvester, core.getSWGObjectODB()); } diff --git a/src/services/spawn/MobileTemplate.java b/src/services/spawn/MobileTemplate.java index 564a2be4..18505f7d 100644 --- a/src/services/spawn/MobileTemplate.java +++ b/src/services/spawn/MobileTemplate.java @@ -21,12 +21,14 @@ ******************************************************************************/ package services.spawn; +import java.util.List; import java.util.Vector; import resources.datatables.Options; import resources.datatables.PvpStatus; +import resources.loot.LootGroup; -public class MobileTemplate { +public class MobileTemplate implements Cloneable { private Vector templates; private int optionBitmask = Options.ATTACKABLE; @@ -56,6 +58,9 @@ public class MobileTemplate { private boolean isStalker = false; private String meatType, milkType, boneType, hideType; private int meatAmount, milkAmount, boneAmount, hideAmount; + private int respawnTime = 0; + private List lootGroups; + public Vector getTemplates() { return templates; @@ -328,4 +333,31 @@ public class MobileTemplate { public void setHideAmount(int hideAmount) { this.hideAmount = hideAmount; } + + public int getRespawnTime() { + return respawnTime; + } + + public void setRespawnTime(int respawnTime) { + this.respawnTime = respawnTime; + } + + public List getLootGroups() { + return lootGroups; + } + + public void setLootGroups(List lootGroups) { + this.lootGroups = lootGroups; + } + + public void addToLootGroups(String[] lootPoolNames, double[] lootPoolChances, double lootGroupChance) { + //System.out.println("lootPoolNames[0] " + lootPoolNames[0]); + LootGroup lootGroup = new LootGroup(lootPoolNames, lootPoolChances, lootGroupChance); + this.lootGroups.add(lootGroup); + } + + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + } diff --git a/src/services/spawn/SpawnService.java b/src/services/spawn/SpawnService.java index b3b51689..2d30d0c3 100644 --- a/src/services/spawn/SpawnService.java +++ b/src/services/spawn/SpawnService.java @@ -85,7 +85,7 @@ public class SpawnService { return null; } - CreatureObject creature = (CreatureObject) core.objectService.createObject(mobileTemplate.getTemplates().get(new Random().nextInt(mobileTemplate.getTemplates().size())), objectId, planet, new Point3D(x, y, z), new Quaternion(qW, qX, qY, qZ)); + CreatureObject creature = (CreatureObject) core.objectService.createObject(mobileTemplate.getTemplates().get(new Random().nextInt(mobileTemplate.getTemplates().size())), objectId, planet, new Point3D(x, y, z), new Quaternion(qW, qX, qY, qZ), null, (objectId > 0), true); if(creature == null) return null; @@ -100,6 +100,9 @@ public class SpawnService { creature.setWeaponId(mobileTemplate.getCustomWeapon().getObjectID()); }*/ + if(mobileTemplate.getLootGroups() != null) + creature.setLootGroups(mobileTemplate.getLootGroups()); + creature.setOptionsBitmask(mobileTemplate.getOptionBitmask()); creature.setPvPBitmask(mobileTemplate.getPvpBitmask()); creature.setStfFilename("mob/creature_names"); // TODO: set other STFs for NPCs other than creatures diff --git a/src/services/sui/SUIService.java b/src/services/sui/SUIService.java index 7be91518..2ebbe982 100644 --- a/src/services/sui/SUIService.java +++ b/src/services/sui/SUIService.java @@ -133,6 +133,12 @@ public class SUIService implements INetworkDispatch { //System.out.println("SUI target is NOT creatureobject " + target.getTemplate()); } + if(target.getAttachment("isVendor") != null && (Boolean) target.getAttachment("isVendor") && ((CreatureObject) owner).getPlayerObject().getOwnedVendors().contains(target.getObjectID())) { + core.scriptService.callScript("scripts/radial/", "terminal/vendor", "createRadial", core, owner, target, request.getRadialOptions()); + sendRadial(owner, target, request.getRadialOptions(), request.getRadialCount()); + return; + } + if(target.getGrandparent() != null && target.getGrandparent().getAttachment("structureAdmins") != null) { if(core.housingService.getPermissions(owner, target.getContainer()) && !getRadialFilename(target).equals("structure/structure_management_terminal")) @@ -318,7 +324,7 @@ public class SUIService implements INetworkDispatch { window.clearDataSource("List.dataList"); - cloneData.entrySet().forEach(e -> window.addListBoxMenuItem(e.getValue(), e.getKey())); + cloneData.entrySet().forEach(e -> window.addListBoxMenuItem(e.getValue(), (long) e.getKey())); return window; diff --git a/src/services/travel/TravelService.java b/src/services/travel/TravelService.java index addfbfe1..74310bf3 100644 --- a/src/services/travel/TravelService.java +++ b/src/services/travel/TravelService.java @@ -27,9 +27,6 @@ import java.util.List; import java.util.Map; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; - import org.apache.commons.lang3.text.WordUtils; import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.session.IoSession; @@ -52,6 +49,7 @@ import resources.common.Opcodes; import resources.common.SpawnPoint; import resources.objects.creature.CreatureObject; import resources.objects.tangible.TangibleObject; +import services.playercities.PlayerCity; import services.sui.SUIService.ListBoxType; import services.sui.SUIService.MessageBoxType; import services.sui.SUIWindow.SUICallback; @@ -63,7 +61,6 @@ public class TravelService implements INetworkDispatch { private NGECore core; private Map> travelMap = new ConcurrentHashMap>(); private Map> fareMap = new ConcurrentHashMap>(); - private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); public TravelService(NGECore core) { this.core = core; @@ -255,9 +252,13 @@ public class TravelService implements INetworkDispatch { public void purchaseTravelTicket(SWGObject player, String departurePlanet, String departureLoc, String arrivalPlanet, String arrivalLoc, String roundTrip) { CreatureObject creatureObj = (CreatureObject) player; int fare = fareMap.get(player.getPlanet()).get(arrivalPlanet); + int tax = 0; if (roundTrip.equals("1")) { fare += fareMap.get(player.getPlanet()).get(arrivalPlanet); } + PlayerCity city = core.playerCityService.getCityObjectIsIn(player); + if (city != null && city.getTravelTax() != 0) { tax = city.getTravelTax(); fare += tax;} + int playerBankCredits = creatureObj.getBankCredits(); if (playerBankCredits < fare) { int cashDifference = fare - playerBankCredits; @@ -271,9 +272,12 @@ public class TravelService implements INetworkDispatch { creatureObj.setBankCredits(0); creatureObj.setCashCredits(creatureObj.getCashCredits() - cashDifference); + } else { creatureObj.setBankCredits(playerBankCredits - fare); + } + if (tax != 0) { city.addToTreasury(tax);} if (roundTrip.equals("1")) { SWGObject tripTicket = createTravelTicket(arrivalPlanet, arrivalLoc, departurePlanet, departureLoc);