diff --git a/.gitignore b/.gitignore index 8560d241..63147709 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,7 @@ odb/chatRooms/je.info.* odb/resourcehistory/je.info.* odb/resourceroots/je.info.* odb/resources/je.info.* +odb/auction/je.info.* # External tool builders .externalToolBuilders/ diff --git a/nge.cfg b/nge.cfg index 6d4d88df..036d6202 100644 --- a/nge.cfg +++ b/nge.cfg @@ -13,5 +13,4 @@ GALAXY_ID=2 GALAXY_NAME=Local Connection XPMULTIPLIER=1.0 MAXNUMBEROFCHARACTERS=2 -LOAD.RESOURCE.SYSTEM=1 MOTD=Welcome to PSWG Test Center! \ No newline at end of file diff --git a/ngengine_public.jar b/ngengine_public.jar index ddeff30b..8dbc2777 100644 Binary files a/ngengine_public.jar and b/ngengine_public.jar differ diff --git a/odb/auction/placeholder.txt b/odb/auction/placeholder.txt new file mode 100644 index 00000000..e69de29b diff --git a/options.cfg b/options.cfg index 4f6d91ad..5a3a7f8e 100644 --- a/options.cfg +++ b/options.cfg @@ -1,2 +1,3 @@ LOAD.SNAPSHOT_OBJECTS=1 -LOAD.BUILDOUT_OBJECTS=1 \ No newline at end of file +LOAD.BUILDOUT_OBJECTS=1 +LOAD.RESOURCE.SYSTEM=1 \ No newline at end of file diff --git a/scripts/commands/harvesteractivate.py b/scripts/commands/harvesteractivate.py new file mode 100644 index 00000000..5411445a --- /dev/null +++ b/scripts/commands/harvesteractivate.py @@ -0,0 +1,10 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + core.harvesterService.handleHarvesterActivateCommand(actor, target, commandString) + return + + \ No newline at end of file diff --git a/scripts/commands/harvesterdeactivate.py b/scripts/commands/harvesterdeactivate.py new file mode 100644 index 00000000..3a225b3f --- /dev/null +++ b/scripts/commands/harvesterdeactivate.py @@ -0,0 +1,10 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + core.harvesterService.handleHarvesterDeactivateCommand(actor, target, commandString) + return + + \ No newline at end of file diff --git a/scripts/commands/harvesterdiscardhopper.py b/scripts/commands/harvesterdiscardhopper.py new file mode 100644 index 00000000..3a52f754 --- /dev/null +++ b/scripts/commands/harvesterdiscardhopper.py @@ -0,0 +1,11 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + actor.sendSystemMessage('handleEmptyHarvester', 0) + core.harvesterService.handleEmptyHarvester(actor, target, commandString) + return + + \ No newline at end of file diff --git a/scripts/commands/harvesterselectresource.py b/scripts/commands/harvesterselectresource.py new file mode 100644 index 00000000..69c8c725 --- /dev/null +++ b/scripts/commands/harvesterselectresource.py @@ -0,0 +1,10 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + core.harvesterService.handleHarvesterSelectResourceCommand(actor, target, commandString) + return + + \ No newline at end of file diff --git a/scripts/commands/movefurniture.py b/scripts/commands/movefurniture.py index 3c45c55e..1f4a7148 100644 --- a/scripts/commands/movefurniture.py +++ b/scripts/commands/movefurniture.py @@ -6,7 +6,6 @@ def setup(): def run(core, actor, target, commandString): tarObj = core.objectService.getObject(actor.getTargetId()) - container = actor.getContainer() parsedMsg = commandString.split(' ', 2) diff --git a/scripts/commands/permissionlistmodify.py b/scripts/commands/permissionlistmodify.py new file mode 100644 index 00000000..8c0108ba --- /dev/null +++ b/scripts/commands/permissionlistmodify.py @@ -0,0 +1,17 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + permissionType = 'Undetermined' + commandArgs = commandString.split(' ') + if len(commandArgs) > 3: + permissionType = commandArgs[2] + if permissionType=='ENTRY' | permissionType=='BAN': + core.housingService.handlePermissionListModify(actor, target, commandString) + if permissionType=='ADMIN' | permissionType=='HOPPER': + core.harvesterService.handlePermissionListModify(actor, target, commandString) + return + + \ No newline at end of file diff --git a/scripts/commands/placestructure.py b/scripts/commands/placestructure.py index edddb24e..f6f5c122 100644 --- a/scripts/commands/placestructure.py +++ b/scripts/commands/placestructure.py @@ -1,4 +1,5 @@ import sys +import resources.objects.deed.Harvester_Deed def setup(): return @@ -8,7 +9,12 @@ def run(core, actor, target, commandString): deedId = long(cmdArgs[0]) deed = core.objectService.getObject(deedId) - + + if (actor.getAttachment('UsingHarvesterDeed') == '1'): + actor.setAttachment('UsingHarvesterDeed', '0'); + core.harvesterService.handlePlaceStructureCommand(actor, target, commandString) + return + positionX = float(cmdArgs[1]) positionZ = float(cmdArgs[2]) #positionY = core.terrainService.getHeight(actor.getPlanetId(), positionX, positionZ) + 2 diff --git a/scripts/commands/resourceemptyhopper.py b/scripts/commands/resourceemptyhopper.py new file mode 100644 index 00000000..3a225b3f --- /dev/null +++ b/scripts/commands/resourceemptyhopper.py @@ -0,0 +1,10 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + core.harvesterService.handleHarvesterDeactivateCommand(actor, target, commandString) + return + + \ No newline at end of file diff --git a/scripts/commands/setspeed.py b/scripts/commands/setspeed.py index e5929c25..c73266de 100644 --- a/scripts/commands/setspeed.py +++ b/scripts/commands/setspeed.py @@ -5,6 +5,5 @@ def setup(): def run(core, actor, target, commandString): actor.setSpeedMultiplierBase(float(commandString)) - core.buffService.addBuffToCreature(actor, 'bh_prescience') return \ No newline at end of file diff --git a/scripts/commands/transferitemmisc.py b/scripts/commands/transferitemmisc.py index 27bfde45..dbe46f8a 100644 --- a/scripts/commands/transferitemmisc.py +++ b/scripts/commands/transferitemmisc.py @@ -12,9 +12,10 @@ def run(core, actor, target, commandString): actorContainer = actor.getContainer() if actorContainer != None and (container.getTemplate() == "object/cell/shared_cell.iff") & core.housingService.getPermissions(actor, actorContainer): - target.getContainer().transferTo(actor, container, target) - core.simulationService.teleport(target, actor.getPosition(), Quaternion(1,0,0,0), containerID) - return + target.getContainer().transferTo(actor, container, target) + core.simulationService.teleport(target, actor.getPosition(), Quaternion(1,0,0,0), containerID) + #core.housingService.addItemToHouseItemList(target,actorContainer) + return elif actorContainer != None and container.getTemplate() == "object/cell/shared_cell.iff": actor.sendSystemMessage("You do not have permission to access that container!", 0) return diff --git a/scripts/loot/lootItems/colorcrystal.py b/scripts/loot/lootItems/colorcrystal.py new file mode 100644 index 00000000..cce04300 --- /dev/null +++ b/scripts/loot/lootItems/colorcrystal.py @@ -0,0 +1,21 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' + +def customItemName(): + + return '' + +def customItemStackCount(): + + return 1 + +def customizationAttributes(): + + return [] + +def customizationValues(): + + return [] + diff --git a/scripts/loot/lootItems/junk/antenna.py b/scripts/loot/lootItems/junk/antenna.py new file mode 100644 index 00000000..747de5b7 --- /dev/null +++ b/scripts/loot/lootItems/junk/antenna.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/creature_loot/generic/shared_generic_antennae.iff' diff --git a/scripts/loot/lootItems/junk/armor_repair_device.py b/scripts/loot/lootItems/junk/armor_repair_device.py new file mode 100644 index 00000000..713dc0ce --- /dev/null +++ b/scripts/loot/lootItems/junk/armor_repair_device.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_armor_repair_device_generic.iff' diff --git a/scripts/loot/lootItems/junk/brain.py b/scripts/loot/lootItems/junk/brain.py new file mode 100644 index 00000000..bb01bf52 --- /dev/null +++ b/scripts/loot/lootItems/junk/brain.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/loot/creature_loot/generic/shared_brain_s01.iff' + +def customItemName(): + + return 'Brain' \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/chassis_blueprint.py b/scripts/loot/lootItems/junk/chassis_blueprint.py new file mode 100644 index 00000000..b876b351 --- /dev/null +++ b/scripts/loot/lootItems/junk/chassis_blueprint.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/loot/generic_usable/shared_chassis_blueprint_usuable.iff' + +def customItemName(): + + return 'Chassis Blueprint' \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/comlink.py b/scripts/loot/lootItems/junk/comlink.py new file mode 100644 index 00000000..648802c6 --- /dev/null +++ b/scripts/loot/lootItems/junk/comlink.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_comlink_civilian_generic.iff' + +def customItemName(): + + return 'Comlink' \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/damaged_datapad.py b/scripts/loot/lootItems/junk/damaged_datapad.py new file mode 100644 index 00000000..4fc1a9a9 --- /dev/null +++ b/scripts/loot/lootItems/junk/damaged_datapad.py @@ -0,0 +1,9 @@ + +def itemTemplate(): + + return 'object/tangible/loot/misc/shared_damaged_datapad.iff' + +def customItemName(): + + return 'Damaged Datapad' + diff --git a/scripts/loot/lootItems/junk/ear_jewel.py b/scripts/loot/lootItems/junk/ear_jewel.py new file mode 100644 index 00000000..abe14c33 --- /dev/null +++ b/scripts/loot/lootItems/junk/ear_jewel.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return '/object/tangible/loot/npc_loot/shared_jewelry_ear_s02.iff' diff --git a/scripts/loot/lootItems/junk/explosive_dud.py b/scripts/loot/lootItems/junk/explosive_dud.py new file mode 100644 index 00000000..bc7091a7 --- /dev/null +++ b/scripts/loot/lootItems/junk/explosive_dud.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return '/object/tangible/loot/npc_loot/shared_firework_dud_s1.iff' diff --git a/scripts/loot/lootItems/junk/eye.py b/scripts/loot/lootItems/junk/eye.py new file mode 100644 index 00000000..aa7c6cff --- /dev/null +++ b/scripts/loot/lootItems/junk/eye.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/creature_loot/generic/shared_generic_eye.iff' diff --git a/scripts/loot/lootItems/junk/gland.py b/scripts/loot/lootItems/junk/gland.py new file mode 100644 index 00000000..071a60ef --- /dev/null +++ b/scripts/loot/lootItems/junk/gland.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/loot/creature_loot/generic/shared_lungs_gland.iff' + +def customItemName(): + + return 'Gland' \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/heart.py b/scripts/loot/lootItems/junk/heart.py new file mode 100644 index 00000000..3715f029 --- /dev/null +++ b/scripts/loot/lootItems/junk/heart.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/creature_loot/generic/shared_generic_heart.iff' diff --git a/scripts/loot/lootItems/junk/hyperdrive_unit.py b/scripts/loot/lootItems/junk/hyperdrive_unit.py new file mode 100644 index 00000000..25afcd63 --- /dev/null +++ b/scripts/loot/lootItems/junk/hyperdrive_unit.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/miscshared_hyperdrive_part_s01.iff' diff --git a/scripts/loot/lootItems/junk/id_chip.py b/scripts/loot/lootItems/junk/id_chip.py new file mode 100644 index 00000000..e4738035 --- /dev/null +++ b/scripts/loot/lootItems/junk/id_chip.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_id_chip_generic.iff' + +def customItemName(): + + return 'ID Chip' diff --git a/scripts/loot/lootItems/junk/impulse_detector.py b/scripts/loot/lootItems/junk/impulse_detector.py new file mode 100644 index 00000000..17f08a9d --- /dev/null +++ b/scripts/loot/lootItems/junk/impulse_detector.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_impulse_detector_01_generic.iff' diff --git a/scripts/loot/lootItems/junk/laser_trap.py b/scripts/loot/lootItems/junk/laser_trap.py new file mode 100644 index 00000000..4bbcdb48 --- /dev/null +++ b/scripts/loot/lootItems/junk/laser_trap.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_laser_trap_generic.iff' diff --git a/scripts/loot/lootItems/junk/launcher_tube.py b/scripts/loot/lootItems/junk/launcher_tube.py new file mode 100644 index 00000000..4159a299 --- /dev/null +++ b/scripts/loot/lootItems/junk/launcher_tube.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_launcher_tube_generic.iff' + +def customItemName(): + + return 'Launcher Tube' \ No newline at end of file diff --git a/scripts/loot/lootItems/junk/ledger.py b/scripts/loot/lootItems/junk/ledger.py new file mode 100644 index 00000000..093e2caf --- /dev/null +++ b/scripts/loot/lootItems/junk/ledger.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_ledger_generic.iff' diff --git a/scripts/loot/lootItems/junk/magseal_detector.py b/scripts/loot/lootItems/junk/magseal_detector.py new file mode 100644 index 00000000..bce0a6c7 --- /dev/null +++ b/scripts/loot/lootItems/junk/magseal_detector.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_magseal_detector_generic.iff' diff --git a/scripts/loot/lootItems/junk/medical_console.py b/scripts/loot/lootItems/junk/medical_console.py new file mode 100644 index 00000000..db82ffa3 --- /dev/null +++ b/scripts/loot/lootItems/junk/medical_console.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_medical_console_generic.iff' diff --git a/scripts/loot/lootItems/junk/medical_device.py b/scripts/loot/lootItems/junk/medical_device.py new file mode 100644 index 00000000..eb55b264 --- /dev/null +++ b/scripts/loot/lootItems/junk/medical_device.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_medical_device_generic.iff' diff --git a/scripts/loot/lootItems/junk/motor.py b/scripts/loot/lootItems/junk/motor.py new file mode 100644 index 00000000..63d2def6 --- /dev/null +++ b/scripts/loot/lootItems/junk/motor.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_small_motor_generic.iff' diff --git a/scripts/loot/lootItems/junk/power_output_analyzer.py b/scripts/loot/lootItems/junk/power_output_analyzer.py new file mode 100644 index 00000000..b44f9808 --- /dev/null +++ b/scripts/loot/lootItems/junk/power_output_analyzer.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_power_output_analyzer_generic.iff' diff --git a/scripts/loot/lootItems/junk/red_wiring.py b/scripts/loot/lootItems/junk/red_wiring.py new file mode 100644 index 00000000..d2f31c46 --- /dev/null +++ b/scripts/loot/lootItems/junk/red_wiring.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_red_wiring_generic.iff' diff --git a/scripts/loot/lootItems/junk/shield_module.py b/scripts/loot/lootItems/junk/shield_module.py new file mode 100644 index 00000000..43335cfa --- /dev/null +++ b/scripts/loot/lootItems/junk/shield_module.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_shield_module_generic.iff' diff --git a/scripts/loot/lootItems/junk/software_module.py b/scripts/loot/lootItems/junk/software_module.py new file mode 100644 index 00000000..8041a85a --- /dev/null +++ b/scripts/loot/lootItems/junk/software_module.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_software_module_generic.iff' diff --git a/scripts/loot/lootItems/junk/stomach.py b/scripts/loot/lootItems/junk/stomach.py new file mode 100644 index 00000000..e3692923 --- /dev/null +++ b/scripts/loot/lootItems/junk/stomach.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/creature_loot/generic/shared_generic_stomach.iff' diff --git a/scripts/loot/lootItems/junk/survival_gear.py b/scripts/loot/lootItems/junk/survival_gear.py new file mode 100644 index 00000000..e8ad23ae --- /dev/null +++ b/scripts/loot/lootItems/junk/survival_gear.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_survival_equipment_generic.iff' diff --git a/scripts/loot/lootItems/junk/underpowered_survey_pad.py b/scripts/loot/lootItems/junk/underpowered_survey_pad.py new file mode 100644 index 00000000..3dca4fa8 --- /dev/null +++ b/scripts/loot/lootItems/junk/underpowered_survey_pad.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_survey_pad_adv_generic.iff' diff --git a/scripts/loot/lootItems/junk/unidentified_serum_vial.py b/scripts/loot/lootItems/junk/unidentified_serum_vial.py new file mode 100644 index 00000000..1f4f8e84 --- /dev/null +++ b/scripts/loot/lootItems/junk/unidentified_serum_vial.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_serum_vial_generic.iff' diff --git a/scripts/loot/lootItems/junk/used_notebook.py b/scripts/loot/lootItems/junk/used_notebook.py new file mode 100644 index 00000000..9a3acb30 --- /dev/null +++ b/scripts/loot/lootItems/junk/used_notebook.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_notebook_generic.iff' diff --git a/scripts/loot/lootItems/junk/weak_droid_battery.py b/scripts/loot/lootItems/junk/weak_droid_battery.py new file mode 100644 index 00000000..5ba36675 --- /dev/null +++ b/scripts/loot/lootItems/junk/weak_droid_battery.py @@ -0,0 +1,4 @@ + +def itemTemplate(): + + return 'object/tangible/loot/generic/shared_battery_useable_generic.iff' diff --git a/scripts/loot/lootItems/junk/worklight_generic.py b/scripts/loot/lootItems/junk/worklight_generic.py new file mode 100644 index 00000000..86a9231b --- /dev/null +++ b/scripts/loot/lootItems/junk/worklight_generic.py @@ -0,0 +1,21 @@ + +def itemTemplate(): + + return 'object/tangible/loot/npc_loot/shared_worklight_generic.iff' + +def customItemName(): + + return '' + +def customItemStackCount(): + + return 1 + +def customizationAttributes(): + + return [] + +def customizationValues(): + + return [] + diff --git a/scripts/loot/lootItems/kraytpearl_cracked.py b/scripts/loot/lootItems/kraytpearl_cracked.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_cracked.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_fair.py b/scripts/loot/lootItems/kraytpearl_fair.py new file mode 100644 index 00000000..ef8d2dc0 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_fair.py @@ -0,0 +1,12 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_flawless.py b/scripts/loot/lootItems/kraytpearl_flawless.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_flawless.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_good.py b/scripts/loot/lootItems/kraytpearl_good.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_good.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_poor.py b/scripts/loot/lootItems/kraytpearl_poor.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_poor.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_premium.py b/scripts/loot/lootItems/kraytpearl_premium.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_premium.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_quality.py b/scripts/loot/lootItems/kraytpearl_quality.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_quality.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_scratched.py b/scripts/loot/lootItems/kraytpearl_scratched.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_scratched.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/kraytpearl_select.py b/scripts/loot/lootItems/kraytpearl_select.py new file mode 100644 index 00000000..8e532580 --- /dev/null +++ b/scripts/loot/lootItems/kraytpearl_select.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_fair.py b/scripts/loot/lootItems/powercrystal_fair.py new file mode 100644 index 00000000..3c533136 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_fair.py @@ -0,0 +1,12 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' + +def customItemName(): + + return '' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_flawless.py b/scripts/loot/lootItems/powercrystal_flawless.py new file mode 100644 index 00000000..8163cb74 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_flawless.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_good.py b/scripts/loot/lootItems/powercrystal_good.py new file mode 100644 index 00000000..8163cb74 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_good.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_perfect.py b/scripts/loot/lootItems/powercrystal_perfect.py new file mode 100644 index 00000000..8163cb74 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_perfect.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_poor.py b/scripts/loot/lootItems/powercrystal_poor.py new file mode 100644 index 00000000..8163cb74 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_poor.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_premium.py b/scripts/loot/lootItems/powercrystal_premium.py new file mode 100644 index 00000000..8163cb74 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_premium.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_quality.py b/scripts/loot/lootItems/powercrystal_quality.py new file mode 100644 index 00000000..8163cb74 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_quality.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/powercrystal_select.py b/scripts/loot/lootItems/powercrystal_select.py new file mode 100644 index 00000000..8163cb74 --- /dev/null +++ b/scripts/loot/lootItems/powercrystal_select.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/rarelootchest1.py b/scripts/loot/lootItems/rarelootchest1.py new file mode 100644 index 00000000..1541e62a --- /dev/null +++ b/scripts/loot/lootItems/rarelootchest1.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/item/shared_rare_loot_chest_3.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/rarelootchest2.py b/scripts/loot/lootItems/rarelootchest2.py new file mode 100644 index 00000000..1541e62a --- /dev/null +++ b/scripts/loot/lootItems/rarelootchest2.py @@ -0,0 +1,8 @@ + +def itemTemplate(): + + return 'object/tangible/item/shared_rare_loot_chest_3.iff' + +def customItemName(): + + return '' diff --git a/scripts/loot/lootItems/weapons/shared_rifle_cdef.py b/scripts/loot/lootItems/weapons/shared_rifle_cdef.py new file mode 100644 index 00000000..0d683b7f --- /dev/null +++ b/scripts/loot/lootItems/weapons/shared_rifle_cdef.py @@ -0,0 +1,20 @@ + +def itemTemplate(): + + return 'object/weapon/ranged/rifle/shared_rifle_cdef.iff' + +def customItemName(): + + return '' + +def customItemStackCount(): + + return 1 + +def customizationAttributes(): + + return [] + +def customizationValues(): + + return [] diff --git a/scripts/loot/lootPools/colorcrystals.py b/scripts/loot/lootPools/colorcrystals.py new file mode 100644 index 00000000..d372b968 --- /dev/null +++ b/scripts/loot/lootPools/colorcrystals.py @@ -0,0 +1,8 @@ + +def itemNames(): + + return ['colorCrystal'] + +def itemChances(): + + return [70] \ No newline at end of file diff --git a/scripts/loot/lootPools/jediholocrons.py b/scripts/loot/lootPools/jediholocrons.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/loot/lootPools/junk.py b/scripts/loot/lootPools/junk.py new file mode 100644 index 00000000..ef757825 --- /dev/null +++ b/scripts/loot/lootPools/junk.py @@ -0,0 +1,15 @@ + +def itemNames(): + + templates=['damaged_datapad','red_wiring','worklight_generic','antenna','brain','eye','gland','heart','stomach','armor_repair_device'] #10 + templates=templates+['brain','chassis_blueprint','comlink','explosive_dud','hyperdrive_unit','id_chip','impulse_detector','laser_trap'] #8 + templates=templates+['launcher_tube','ledger','magseal_detector','medical_console','medical_device','motor','power_output_analyzer','shield_module'] #8 + templates=templates+['software_module','survival_gear','underpowered_survey_pad','unidentified_serum_vial','used_notebook','weak_droid_battery'] #6 + return templates + +def itemChances(): + chances=[3.125,3.125,3.125,3.125,3.125,3.125,3.125,3.125] + chances=chances+[3.125,3.125,3.125,3.125,3.125,3.125,3.125,3.125] + chances=chances+[3.125,3.125,3.125,3.125,3.125,3.125,3.125,3.125] + chances=chances+[3.125,3.125,3.125,3.125,3.125,3.125,3.125,3.125] + return chances #32 \ No newline at end of file diff --git a/scripts/loot/lootPools/kraytpearl_lowq.py b/scripts/loot/lootPools/kraytpearl_lowq.py new file mode 100644 index 00000000..4fe709c2 --- /dev/null +++ b/scripts/loot/lootPools/kraytpearl_lowq.py @@ -0,0 +1,8 @@ + +def itemNames(): + + return ['kraytpearl_cracked','kraytpearl_scratched','kraytpearl_poor'] + +def itemChances(): + + return [33,33,34] \ No newline at end of file diff --git a/scripts/loot/lootPools/kraytpearls_range.py b/scripts/loot/lootPools/kraytpearls_range.py new file mode 100644 index 00000000..23477840 --- /dev/null +++ b/scripts/loot/lootPools/kraytpearls_range.py @@ -0,0 +1,6 @@ + +def itemTemplates(): + return ['kraytpearl_fair','kraytpearl_good','kraytpearl_quality','kraytpearl_select','kraytpearl_premium','kraytpearl_flawless'] + +def itemChances(): + return [10,20,30,34,5,1] #= 100% \ No newline at end of file diff --git a/scripts/loot/lootPools/powercrystals_hiq.py b/scripts/loot/lootPools/powercrystals_hiq.py new file mode 100644 index 00000000..63d33a9b --- /dev/null +++ b/scripts/loot/lootPools/powercrystals_hiq.py @@ -0,0 +1,6 @@ + +def itemNames(): + return ['powercrystal_premium','powercrystal_flawless','powercrystal_perfect'] + +def itemChances(): + return [94,5,1] #= 100% \ No newline at end of file diff --git a/scripts/loot/lootPools/rareloot.py b/scripts/loot/lootPools/rareloot.py new file mode 100644 index 00000000..435ebfce --- /dev/null +++ b/scripts/loot/lootPools/rareloot.py @@ -0,0 +1,9 @@ + + +def itemNames(): + + templates=['rarelootchest1','rarelootchest2'] + return templates + +def itemChances(): + return [70,30] \ No newline at end of file diff --git a/scripts/loot/lootPools/rifles.py b/scripts/loot/lootPools/rifles.py new file mode 100644 index 00000000..c24909b7 --- /dev/null +++ b/scripts/loot/lootPools/rifles.py @@ -0,0 +1,8 @@ + +def itemNames(): + + return ['shared_rifle_cdef'] + +def itemChances(): + return [100] + \ No newline at end of file diff --git a/scripts/loot/lootPools/sithholocrons.py b/scripts/loot/lootPools/sithholocrons.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/loot/rarelootchestcontents/exceptionaltable.py b/scripts/loot/rarelootchestcontents/exceptionaltable.py new file mode 100644 index 00000000..b8c4ba4d --- /dev/null +++ b/scripts/loot/rarelootchestcontents/exceptionaltable.py @@ -0,0 +1,12 @@ + +def itemTemplates(): + templates = ['Biological_Focus_Crystal','Synapse_Focus_Crystal','Concentrated_Bacta_Tank','DNA_Storage_Device_Kowakian'] + templates = templates + ['Dug_Costume_Instructions','Dusk_in_Kachirho','Mercenaries_Despair','Mercenaries_Lament','Nightsister_Melee_Armguard'] + templates = templates + ['Rare_Painting','Sunriders_Destiny'] + return templates + +def itemChances(): + chances = [9,9,9,9] + chances = chances+[9,9,9,9,9] + chances = chances+[9,9] #= 100% + return chances \ No newline at end of file diff --git a/scripts/loot/rarelootchestcontents/legendarytable.py b/scripts/loot/rarelootchestcontents/legendarytable.py new file mode 100644 index 00000000..d372b968 --- /dev/null +++ b/scripts/loot/rarelootchestcontents/legendarytable.py @@ -0,0 +1,8 @@ + +def itemNames(): + + return ['colorCrystal'] + +def itemChances(): + + return [70] \ No newline at end of file diff --git a/scripts/loot/rarelootchestcontents/raretable.py b/scripts/loot/rarelootchestcontents/raretable.py new file mode 100644 index 00000000..e69de29b diff --git a/scripts/mobiles/tatooine/krayt_dragon.py b/scripts/mobiles/tatooine/krayt_dragon.py new file mode 100644 index 00000000..aded5429 --- /dev/null +++ b/scripts/mobiles/tatooine/krayt_dragon.py @@ -0,0 +1,19 @@ +import sys +from services.spawn import MobileTemplate +from java.util import Vector + +def addTemplate(core): + mobileTemplate = MobileTemplate() + templates = Vector() + templates.add('object/mobile/shared_krayt_dragon.iff') + mobileTemplate.setTemplates(templates) + mobileTemplate.setLevel(10) + mobileTemplate.setDifficulty(2) + attacks = Vector() + mobileTemplate.setDefaultAttack('creatureMeleeAttack') + mobileTemplate.setAttacks(attacks) + mobileTemplate.setCreatureName('krayt_dragon') + mobileTemplate.setScale(2) + mobileTemplate.setAttackRange(12) + core.spawnService.addMobileTemplate('krayt_dragon', mobileTemplate) + \ No newline at end of file diff --git a/scripts/mobiles/tatooine/tusken_raider.py b/scripts/mobiles/tatooine/tusken_raider.py new file mode 100644 index 00000000..b2747696 --- /dev/null +++ b/scripts/mobiles/tatooine/tusken_raider.py @@ -0,0 +1,27 @@ +import sys +from services.spawn import MobileTemplate +from java.util import Vector + +def addTemplate(core): + mobileTemplate = MobileTemplate() + + mobileTemplate.setCreatureName('tusken_raider') + mobileTemplate.setLevel(90) + mobileTemplate.setDifficulty(0) + mobileTemplate.setAttackRange(24) + + templates = Vector() + templates.add('object/mobile/shared_tusken_raider.iff') + mobileTemplate.setTemplates(templates) + + weaponTemplates = Vector() + weaponTemplates.add('object/weapon/ranged/rifle/shared_rifle_tusken.iff') + mobileTemplate.setWeaponTemplates(weaponTemplates) + + + attacks = Vector() + mobileTemplate.setDefaultAttack('rangedShot') + mobileTemplate.setAttacks(attacks) + + core.spawnService.addMobileTemplate('tusken_raider', mobileTemplate) + \ No newline at end of file diff --git a/scripts/object/building/player/player_house_generic_small_style_01.py b/scripts/object/building/player/player_house_generic_small_style_01.py index 17c11b52..6e0ae61d 100644 --- a/scripts/object/building/player/player_house_generic_small_style_01.py +++ b/scripts/object/building/player/player_house_generic_small_style_01.py @@ -5,5 +5,7 @@ def setup(core, object): print(sign) object.setAttachment("structureSign", sign) - core.objectService.createChildObject(object, 'object/tangible/terminal/shared_terminal_player_structure.iff', -5, 0.74, -1.81, 0.707107, -0.707107, 1) + structureterminal = core.objectService.createChildObject(object, 'object/tangible/terminal/shared_terminal_player_structure.iff', -5, 0.74, -1.81, 0.707107, -0.707107, 1) + #structureterminal.setAttachment('radial_filename', 'structure_management_terminal') + structureterminal.setAttachment('housing_parentstruct', object) return \ No newline at end of file diff --git a/scripts/object/installation/generators/power_generator_fusion_style_1.py b/scripts/object/installation/generators/power_generator_fusion_style_1.py index ccad8904..be7d0439 100644 --- a/scripts/object/installation/generators/power_generator_fusion_style_1.py +++ b/scripts/object/installation/generators/power_generator_fusion_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'generator') + object.setHarvester_type(5) + object.setMaintenanceCost(30) + object.setGenerator(1) return \ No newline at end of file diff --git a/scripts/object/installation/generators/power_generator_geothermal_style_1.py b/scripts/object/installation/generators/power_generator_geothermal_style_1.py index ccad8904..be7d0439 100644 --- a/scripts/object/installation/generators/power_generator_geothermal_style_1.py +++ b/scripts/object/installation/generators/power_generator_geothermal_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'generator') + object.setHarvester_type(5) + object.setMaintenanceCost(30) + object.setGenerator(1) return \ No newline at end of file diff --git a/scripts/object/installation/generators/power_generator_photo_bio_style_1.py b/scripts/object/installation/generators/power_generator_photo_bio_style_1.py index ccad8904..be7d0439 100644 --- a/scripts/object/installation/generators/power_generator_photo_bio_style_1.py +++ b/scripts/object/installation/generators/power_generator_photo_bio_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'generator') + object.setHarvester_type(5) + object.setMaintenanceCost(30) + object.setGenerator(1) return \ No newline at end of file diff --git a/scripts/object/installation/generators/power_generator_solar_style_1.py b/scripts/object/installation/generators/power_generator_solar_style_1.py index ccad8904..be7d0439 100644 --- a/scripts/object/installation/generators/power_generator_solar_style_1.py +++ b/scripts/object/installation/generators/power_generator_solar_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'generator') + object.setHarvester_type(5) + object.setMaintenanceCost(30) + object.setGenerator(1) return \ No newline at end of file diff --git a/scripts/object/installation/generators/power_generator_wind_style_1.py b/scripts/object/installation/generators/power_generator_wind_style_1.py index ccad8904..b82445bb 100644 --- a/scripts/object/installation/generators/power_generator_wind_style_1.py +++ b/scripts/object/installation/generators/power_generator_wind_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'generator') + object.setHarvester_type(5) + object.setMaintenanceCost(20) + object.setGenerator(1) return \ No newline at end of file diff --git a/scripts/object/installation/mining_gas/mining_gas_harvester_style_1.py b/scripts/object/installation/mining_gas/mining_gas_harvester_style_1.py index ccad8904..e90b9514 100644 --- a/scripts/object/installation/mining_gas/mining_gas_harvester_style_1.py +++ b/scripts/object/installation/mining_gas/mining_gas_harvester_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(3) + object.setPowerCost(25); + object.setMaintenanceCost(16); return \ No newline at end of file diff --git a/scripts/object/installation/mining_gas/mining_gas_harvester_style_2.py b/scripts/object/installation/mining_gas/mining_gas_harvester_style_2.py index ccad8904..f90bf1bf 100644 --- a/scripts/object/installation/mining_gas/mining_gas_harvester_style_2.py +++ b/scripts/object/installation/mining_gas/mining_gas_harvester_style_2.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(3) + object.setPowerCost(60); + object.setMaintenanceCost(60); return \ No newline at end of file diff --git a/scripts/object/installation/mining_gas/mining_gas_harvester_style_3.py b/scripts/object/installation/mining_gas/mining_gas_harvester_style_3.py index ccad8904..5b0bb40b 100644 --- a/scripts/object/installation/mining_gas/mining_gas_harvester_style_3.py +++ b/scripts/object/installation/mining_gas/mining_gas_harvester_style_3.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(3) + object.setPowerCost(75); + object.setMaintenanceCost(90); return \ No newline at end of file diff --git a/scripts/object/installation/mining_gas/mining_gas_harvester_style_4.py b/scripts/object/installation/mining_gas/mining_gas_harvester_style_4.py index ccad8904..145b1356 100644 --- a/scripts/object/installation/mining_gas/mining_gas_harvester_style_4.py +++ b/scripts/object/installation/mining_gas/mining_gas_harvester_style_4.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(3) + object.setPowerCost(100); + object.setMaintenanceCost(120); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_1.py b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_1.py index ccad8904..25f6673f 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_1.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(1) + object.setPowerCost(25); + object.setMaintenanceCost(16); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_2.py b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_2.py index ccad8904..1fc10f74 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_2.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_2.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(1) + object.setPowerCost(60); + object.setMaintenanceCost(60); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_3.py b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_3.py index ccad8904..dab15cfd 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_3.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_3.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(1) + object.setPowerCost(75); + object.setMaintenanceCost(90); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_4.py b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_4.py index ccad8904..b848b851 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_4.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_harvester_style_4.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(1) + object.setPowerCost(100); + object.setMaintenanceCost(120); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester.py b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester.py index ccad8904..3e112037 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(4) + object.setPowerCost(25); + object.setMaintenanceCost(16); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_elite.py b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_elite.py index ccad8904..7577292f 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_elite.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_elite.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(4) + object.setPowerCost(100); + object.setMaintenanceCost(120); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_heavy.py b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_heavy.py index ccad8904..1fcc5436 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_heavy.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_heavy.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(4) + object.setPowerCost(75); + object.setMaintenanceCost(90); return \ No newline at end of file diff --git a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_medium.py b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_medium.py index ccad8904..41919756 100644 --- a/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_medium.py +++ b/scripts/object/installation/mining_liquid/mining_liquid_moisture_harvester_medium.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(4) + object.setPowerCost(60); + object.setMaintenanceCost(60); return \ No newline at end of file diff --git a/scripts/object/installation/mining_ore/mining_ore_harvester_elite.py b/scripts/object/installation/mining_ore/mining_ore_harvester_elite.py index ccad8904..05c3be8a 100644 --- a/scripts/object/installation/mining_ore/mining_ore_harvester_elite.py +++ b/scripts/object/installation/mining_ore/mining_ore_harvester_elite.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(0) + object.setPowerCost(100); + object.setMaintenanceCost(120); return \ No newline at end of file diff --git a/scripts/object/installation/mining_ore/mining_ore_harvester_heavy.py b/scripts/object/installation/mining_ore/mining_ore_harvester_heavy.py index ccad8904..5dfeb966 100644 --- a/scripts/object/installation/mining_ore/mining_ore_harvester_heavy.py +++ b/scripts/object/installation/mining_ore/mining_ore_harvester_heavy.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(0) + object.setPowerCost(75); + object.setMaintenanceCost(90); return \ No newline at end of file diff --git a/scripts/object/installation/mining_ore/mining_ore_harvester_style_1.py b/scripts/object/installation/mining_ore/mining_ore_harvester_style_1.py index ccad8904..2973a685 100644 --- a/scripts/object/installation/mining_ore/mining_ore_harvester_style_1.py +++ b/scripts/object/installation/mining_ore/mining_ore_harvester_style_1.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(0) + object.setPowerCost(25); + object.setMaintenanceCost(16); return \ No newline at end of file diff --git a/scripts/object/installation/mining_ore/mining_ore_harvester_style_2.py b/scripts/object/installation/mining_ore/mining_ore_harvester_style_2.py index ccad8904..e6cfc1b1 100644 --- a/scripts/object/installation/mining_ore/mining_ore_harvester_style_2.py +++ b/scripts/object/installation/mining_ore/mining_ore_harvester_style_2.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(0) + object.setPowerCost(60); + object.setMaintenanceCost(60); return \ No newline at end of file diff --git a/scripts/object/installation/mining_organic/mining_organic_flora_farm.py b/scripts/object/installation/mining_organic/mining_organic_flora_farm.py index ccad8904..ace61f59 100644 --- a/scripts/object/installation/mining_organic/mining_organic_flora_farm.py +++ b/scripts/object/installation/mining_organic/mining_organic_flora_farm.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(2) + object.setPowerCost(25); + object.setMaintenanceCost(16); return \ No newline at end of file diff --git a/scripts/object/installation/mining_organic/mining_organic_flora_farm_elite.py b/scripts/object/installation/mining_organic/mining_organic_flora_farm_elite.py index ccad8904..53ef7fa9 100644 --- a/scripts/object/installation/mining_organic/mining_organic_flora_farm_elite.py +++ b/scripts/object/installation/mining_organic/mining_organic_flora_farm_elite.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(2) + object.setPowerCost(100); + object.setMaintenanceCost(120); return \ No newline at end of file diff --git a/scripts/object/installation/mining_organic/mining_organic_flora_farm_heavy.py b/scripts/object/installation/mining_organic/mining_organic_flora_farm_heavy.py index ccad8904..08daa7ee 100644 --- a/scripts/object/installation/mining_organic/mining_organic_flora_farm_heavy.py +++ b/scripts/object/installation/mining_organic/mining_organic_flora_farm_heavy.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(2) + object.setPowerCost(60); + object.setMaintenanceCost(60); return \ No newline at end of file diff --git a/scripts/object/installation/mining_organic/mining_organic_flora_farm_medium.py b/scripts/object/installation/mining_organic/mining_organic_flora_farm_medium.py index ccad8904..08daa7ee 100644 --- a/scripts/object/installation/mining_organic/mining_organic_flora_farm_medium.py +++ b/scripts/object/installation/mining_organic/mining_organic_flora_farm_medium.py @@ -1,4 +1,8 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvester') + object.setHarvester_type(2) + object.setPowerCost(60); + object.setMaintenanceCost(60); return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_female_twk_01.py b/scripts/object/mobile/dressed_dark_jedi_master_female_twk_01.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_female_twk_01.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_female_twk_01.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_female_twk_02.py b/scripts/object/mobile/dressed_dark_jedi_master_female_twk_02.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_female_twk_02.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_female_twk_02.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_female_zab_01.py b/scripts/object/mobile/dressed_dark_jedi_master_female_zab_01.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_female_zab_01.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_female_zab_01.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_female_zab_02.py b/scripts/object/mobile/dressed_dark_jedi_master_female_zab_02.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_female_zab_02.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_female_zab_02.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_male_human_01.py b/scripts/object/mobile/dressed_dark_jedi_master_male_human_01.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_male_human_01.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_male_human_01.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_male_human_02.py b/scripts/object/mobile/dressed_dark_jedi_master_male_human_02.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_male_human_02.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_male_human_02.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_male_human_03.py b/scripts/object/mobile/dressed_dark_jedi_master_male_human_03.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_male_human_03.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_male_human_03.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_male_human_04.py b/scripts/object/mobile/dressed_dark_jedi_master_male_human_04.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_male_human_04.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_male_human_04.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_male_human_05.py b/scripts/object/mobile/dressed_dark_jedi_master_male_human_05.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_male_human_05.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_male_human_05.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_dark_jedi_master_male_human_06.py b/scripts/object/mobile/dressed_dark_jedi_master_male_human_06.py index ccad8904..58245dfb 100644 --- a/scripts/object/mobile/dressed_dark_jedi_master_male_human_06.py +++ b/scripts/object/mobile/dressed_dark_jedi_master_male_human_06.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['powercrystals_hiq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/dressed_stormtrooper_m.py b/scripts/object/mobile/dressed_stormtrooper_m.py index ccad8904..a4b0d784 100644 --- a/scripts/object/mobile/dressed_stormtrooper_m.py +++ b/scripts/object/mobile/dressed_stormtrooper_m.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk','Rifles'] + lootPoolChances_1 = [90,70] + lootGroupChance_1 = 90 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['Colorcrystals'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 20 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/krayt_dragon.py b/scripts/object/mobile/krayt_dragon.py index ccad8904..e023f206 100644 --- a/scripts/object/mobile/krayt_dragon.py +++ b/scripts/object/mobile/krayt_dragon.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['kraytpearl_lowq'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/mobile/tusken_raider.py b/scripts/object/mobile/tusken_raider.py index ccad8904..97f7842a 100644 --- a/scripts/object/mobile/tusken_raider.py +++ b/scripts/object/mobile/tusken_raider.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + + lootPoolNames_1 = ['Junk','Rifles'] + lootPoolChances_1 = [90,70] + lootGroupChance_1 = 90 + object.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['Colorcrystals'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 20 + object.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed.py index ccad8904..d6d7b4a8 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_1.iff') + object.setStructureTemplate('object/installation/mining_organic/shared_mining_organic_flora_farm.iff') + object.setLotRequirement(1) + object.setBMR(16) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_elite.py b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_elite.py index ccad8904..66784568 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_elite.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_elite.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_organic/shared_mining_organic_flora_farm_elite.iff') + object.setLotRequirement(3) + object.setBMR(120) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_heavy.py b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_heavy.py index ccad8904..097a35ea 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_heavy.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_heavy.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_organic/shared_mining_organic_flora_farm_heavy.iff') + object.setLotRequirement(1) + object.setBMR(90) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_medium.py b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_medium.py index ccad8904..70ea50f2 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_medium.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_flora_deed_medium.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_2.iff') + object.setStructureTemplate('object/installation/mining_organic/shared_mining_organic_flora_farm_medium.iff') + object.setLotRequirement(1) + object.setBMR(60) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed.py index ccad8904..a11974a2 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_1.iff') + object.setStructureTemplate('object/installation/mining_gas/shared_mining_gas_harvester_style_1.iff') + object.setLotRequirement(1) + object.setBMR(16) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_elite.py b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_elite.py index ccad8904..814daa8a 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_elite.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_elite.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_gas/shared_mining_gas_harvester_style_4.iff') + object.setLotRequirement(3) + object.setBMR(120) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_heavy.py b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_heavy.py index ccad8904..2111f7bf 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_heavy.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_heavy.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_gas/shared_mining_gas_harvester_style_3.iff') + object.setLotRequirement(1) + object.setBMR(90) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_medium.py b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_medium.py index ccad8904..401da10e 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_medium.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_gas_deed_medium.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_2.iff') + object.setStructureTemplate('object/installation/mining_gas/shared_mining_gas_harvester_style_2.iff') + object.setLotRequirement(1) + object.setBMR(60) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed.py index ccad8904..9bce9e66 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_1.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_harvester_style_1.iff') + object.setLotRequirement(1) + object.setBMR(16) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_elite.py b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_elite.py index ccad8904..15cbfa5d 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_elite.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_elite.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_harvester_style_4.iff') + object.setLotRequirement(3) + object.setBMR(120) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_heavy.py b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_heavy.py index ccad8904..ae4c3c71 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_heavy.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_heavy.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_harvester_style_3.iff') + object.setLotRequirement(1) + object.setBMR(90) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_medium.py b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_medium.py index ccad8904..4de7136b 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_medium.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_liquid_deed_medium.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_2.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_harvester_style_2.iff') + object.setLotRequirement(1) + object.setBMR(60) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed.py index ccad8904..6540aa1d 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_1.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_moisture_harvester.iff') + object.setLotRequirement(1) + object.setBMR(16) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_elite.py b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_elite.py index ccad8904..21dc0cfc 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_elite.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_elite.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_elite.iff') + object.setLotRequirement(3) + object.setBMR(120) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_heavy.py b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_heavy.py index ccad8904..afeb3a4b 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_heavy.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_heavy.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_heavy.iff') + object.setLotRequirement(1) + object.setBMR(90) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_medium.py b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_medium.py index ccad8904..7e9a5efe 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_medium.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_moisture_deed_medium.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_2.iff') + object.setStructureTemplate('object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_medium.iff') + object.setLotRequirement(1) + object.setBMR(60) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_ore_deed_elite.py b/scripts/object/tangible/deed/harvester_deed/harvester_ore_deed_elite.py index ccad8904..5e0dde67 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_ore_deed_elite.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_ore_deed_elite.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_ore/shared_mining_ore_harvester_elite.iff') + object.setLotRequirement(3) + object.setBMR(120) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_ore_heavy_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_ore_heavy_deed.py index ccad8904..7f765aa8 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_ore_heavy_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_ore_heavy_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_heavy.iff') + object.setStructureTemplate('object/installation/mining_ore/shared_mining_ore_harvester_heavy.iff') + object.setLotRequirement(1) + object.setBMR(90) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_ore_s1_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_ore_s1_deed.py index ccad8904..d2edcd91 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_ore_s1_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_ore_s1_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_1.iff') + object.setStructureTemplate('object/installation/mining_ore/shared_mining_ore_harvester_style_1.iff') + object.setLotRequirement(1) + object.setBMR(16) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/harvester_deed/harvester_ore_s2_deed.py b/scripts/object/tangible/deed/harvester_deed/harvester_ore_s2_deed.py index ccad8904..34c6d56c 100644 --- a/scripts/object/tangible/deed/harvester_deed/harvester_ore_s2_deed.py +++ b/scripts/object/tangible/deed/harvester_deed/harvester_ore_s2_deed.py @@ -1,4 +1,9 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'harvesterDeed') + object.setConstructorTemplate('object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_2.iff') + object.setStructureTemplate('object/installation/mining_ore/shared_mining_ore_harvester_style_2.iff') + object.setLotRequirement(1) + object.setBMR(60) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py b/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py index e100519a..5dbae10f 100644 --- a/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py +++ b/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py @@ -1,7 +1,11 @@ import sys def setup(core, object): - object.setAttachment('radial_filename', 'structureDeed'); + object.setAttachment('radial_filename', 'structureDeed') + object.setConstructorTemplate('object/building/player/construction/shared_construction_player_house_corellia_small_style_01.iff') + object.setStructureTemplate('object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff') + object.setLotRequirement(1) + object.setBMR(15) return def use(core, actor, object): diff --git a/scripts/object/tangible/item/rare_loot_chest_1.py b/scripts/object/tangible/item/rare_loot_chest_1.py index ccad8904..33b2b963 100644 --- a/scripts/object/tangible/item/rare_loot_chest_1.py +++ b/scripts/object/tangible/item/rare_loot_chest_1.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'lootchest') return \ No newline at end of file diff --git a/scripts/object/tangible/item/rare_loot_chest_2.py b/scripts/object/tangible/item/rare_loot_chest_2.py index ccad8904..33b2b963 100644 --- a/scripts/object/tangible/item/rare_loot_chest_2.py +++ b/scripts/object/tangible/item/rare_loot_chest_2.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'lootchest') return \ No newline at end of file diff --git a/scripts/object/tangible/item/rare_loot_chest_3.py b/scripts/object/tangible/item/rare_loot_chest_3.py index ccad8904..33b2b963 100644 --- a/scripts/object/tangible/item/rare_loot_chest_3.py +++ b/scripts/object/tangible/item/rare_loot_chest_3.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'lootchest') return \ No newline at end of file diff --git a/scripts/object/tangible/terminal/terminal_player_structure.py b/scripts/object/tangible/terminal/terminal_player_structure.py index ccad8904..839210a3 100644 --- a/scripts/object/tangible/terminal/terminal_player_structure.py +++ b/scripts/object/tangible/terminal/terminal_player_structure.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'structure_management_terminal') return \ No newline at end of file diff --git a/scripts/object/tangible/terminal/terminal_player_structure_new.py b/scripts/object/tangible/terminal/terminal_player_structure_new.py index ccad8904..839210a3 100644 --- a/scripts/object/tangible/terminal/terminal_player_structure_new.py +++ b/scripts/object/tangible/terminal/terminal_player_structure_new.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'structure_management_terminal') return \ No newline at end of file diff --git a/scripts/object/tangible/terminal/terminal_player_structure_nosnap.py b/scripts/object/tangible/terminal/terminal_player_structure_nosnap.py index ccad8904..839210a3 100644 --- a/scripts/object/tangible/terminal/terminal_player_structure_nosnap.py +++ b/scripts/object/tangible/terminal/terminal_player_structure_nosnap.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'structure_management_terminal') return \ No newline at end of file diff --git a/scripts/object/tangible/terminal/terminal_player_structure_nosnap_mini.py b/scripts/object/tangible/terminal/terminal_player_structure_nosnap_mini.py index ccad8904..839210a3 100644 --- a/scripts/object/tangible/terminal/terminal_player_structure_nosnap_mini.py +++ b/scripts/object/tangible/terminal/terminal_player_structure_nosnap_mini.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'structure_management_terminal') return \ No newline at end of file diff --git a/scripts/radial/generator.py b/scripts/radial/generator.py new file mode 100644 index 00000000..44d7a9b4 --- /dev/null +++ b/scripts/radial/generator.py @@ -0,0 +1,53 @@ +from resources.common import RadialOptions +from protocol.swg import ResourceListForSurveyMessage +from services.sui.SUIService import MessageBoxType +from services.SurveyService import createSurveyRangeSUIWindow +from services.sui.SUIWindow import Trigger +from java.util import Vector +import sys + +def createRadial(core, owner, target, radials): + #(byte parentId, short optionId, byte optionType, String description) + radials.clear() + radials.add(RadialOptions(0, 7, 0, 'Examine')) + radials.add(RadialOptions(0, 78, 0, '@player_structure:management')) + radials.add(RadialOptions(0, 117, 0, '@player_structure:permissions')) + radials.add(RadialOptions(2, 118, 0, '@harvester:manage')) + radials.add(RadialOptions(2, 128, 0, '@player_structure:permission_destroy')) + radials.add(RadialOptions(2, 124, 0, '@player_structure:management_status')) + radials.add(RadialOptions(2, 129, 0, '@player_structure:management_pay')) + radials.add(RadialOptions(2, 50, 0, '@base_player:set_name')) + radials.add(RadialOptions(3, 121, 0, '@player_structure:permission_admin')) + radials.add(RadialOptions(3, 123, 0, '@player_structure:permissions')) + + return + +def handleSelection(core, owner, target, option): + if option == 118 and target: + if owner is not None: + core.harvesterService.handleOperateMachinery(owner,target) + return + if option == 128: + if owner is not None: + core.harvesterService.createDestroySUIPage(owner,target) + return + if option == 124: + if owner is not None: + core.harvesterService.createStatusSUIPage(owner,target) + return + if option == 129: + if owner is not None: + core.harvesterService.createPayMaintenanceSUIPage(owner,target) + return + if option == 50: + if owner is not None: + core.harvesterService.createRenameSUIPage(owner,target) + return + if option == 121: + if owner is not None: + core.harvesterService.handlePermissionAdmin(owner,target) + return + if option == 123: + if owner is not None: + core.harvesterService.handlePermissionHopper(owner,target) + return diff --git a/scripts/radial/harvester.py b/scripts/radial/harvester.py new file mode 100644 index 00000000..079c99ae --- /dev/null +++ b/scripts/radial/harvester.py @@ -0,0 +1,58 @@ +from resources.common import RadialOptions +from protocol.swg import ResourceListForSurveyMessage +from services.sui.SUIService import MessageBoxType +from services.SurveyService import createSurveyRangeSUIWindow +from services.sui.SUIWindow import Trigger +from java.util import Vector +import sys + +def createRadial(core, owner, target, radials): + #(byte parentId, short optionId, byte optionType, String description) + radials.clear() + radials.add(RadialOptions(0, 7, 0, 'Examine')) + radials.add(RadialOptions(0, 78, 0, '@player_structure:management')) + radials.add(RadialOptions(0, 117, 0, '@player_structure:permissions')) + radials.add(RadialOptions(2, 118, 0, '@harvester:manage')) + radials.add(RadialOptions(2, 128, 0, '@player_structure:permission_destroy')) + radials.add(RadialOptions(2, 124, 0, '@player_structure:management_status')) + radials.add(RadialOptions(2, 129, 0, '@player_structure:management_pay')) + radials.add(RadialOptions(2, 50, 0, '@base_player:set_name')) + radials.add(RadialOptions(2, 51, 0, '@player_structure:management_power')) + radials.add(RadialOptions(3, 121, 0, '@player_structure:permission_admin')) + radials.add(RadialOptions(3, 123, 0, '@player_structure:permissions')) + + return + +def handleSelection(core, owner, target, option): + if option == 118 and target: + if owner is not None: + core.harvesterService.handleOperateMachinery(owner,target) + return + if option == 128: + if owner is not None: + core.harvesterService.createDestroySUIPage(owner,target) + return + if option == 124: + if owner is not None: + core.harvesterService.createStatusSUIPage(owner,target) + return + if option == 129: + if owner is not None: + core.harvesterService.createPayMaintenanceSUIPage(owner,target) + return + if option == 50: + if owner is not None: + core.harvesterService.createRenameSUIPage(owner,target) + return + if option == 51: + if owner is not None: + core.harvesterService.handleDepositPower(owner,target) + return + if option == 121: + if owner is not None: + core.harvesterService.handlePermissionAdmin(owner,target) + return + if option == 123: + if owner is not None: + core.harvesterService.handlePermissionHopper(owner,target) + return diff --git a/scripts/radial/harvesterDeed.py b/scripts/radial/harvesterDeed.py new file mode 100644 index 00000000..cc8fdc7a --- /dev/null +++ b/scripts/radial/harvesterDeed.py @@ -0,0 +1,23 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + radials.clear() + radials.add(RadialOptions(0, 21, 1, 'Use Deed')) + #radials.add(RadialOptions(0, 7, 1, '111111')) + #radials.add(RadialOptions(0, 15, 1, '')) + #radials.add(RadialOptions(0, 61, 1, '')) + return + +def handleSelection(core, owner, target, option): + + if option == 21 and target: + owner.setAttachment('UsingHarvesterDeed', '1'); + core.harvesterService.enterStructurePlacementMode(target,owner) + if option == 61 and target: + object5 = core.harvesterService.constructionSite(owner,target) + core.objectService.useObject(owner, target) + if option == 15 and target: + core.objectService.destroyObject(target) + return + \ No newline at end of file diff --git a/scripts/radial/harvesterHopper.py b/scripts/radial/harvesterHopper.py new file mode 100644 index 00000000..3323d45b --- /dev/null +++ b/scripts/radial/harvesterHopper.py @@ -0,0 +1,21 @@ +from resources.common import RadialOptions +from protocol.swg import ResourceListForSurveyMessage +from services.sui.SUIService import MessageBoxType +from services.SurveyService import createSurveyRangeSUIWindow +from services.sui.SUIWindow import Trigger +from java.util import Vector +import sys + +def createRadial(core, owner, target, radials): + #(byte parentId, short optionId, byte optionType, String description) + radials.clear() + radials.add(RadialOptions(0, 7, 0, 'Examine')) + radials.add(RadialOptions(0, 78, 0, '@player_structure:management')) + radials.add(RadialOptions(2, 118, 0, '@harvester:manage')) + return + +def handleSelection(core, owner, target, option): + if option == 118 and target: + if owner is not None: + core.harvesterService.handleOperateMachinery(owner,target) + return diff --git a/scripts/radial/lootchest.py b/scripts/radial/lootchest.py new file mode 100644 index 00000000..1a0c9889 --- /dev/null +++ b/scripts/radial/lootchest.py @@ -0,0 +1,13 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + radials.add(RadialOptions(0, 21, 1, 'Open')) + radials.add(RadialOptions(0, 7, 1, '')) + return + +def handleSelection(core, owner, target, option): + if option == 21 and target: + owner.sendSystemMessage('RLS chest content system not yet implemented.',1) + return + \ No newline at end of file diff --git a/scripts/radial/npc/corpse.py b/scripts/radial/npc/corpse.py new file mode 100644 index 00000000..3155798a --- /dev/null +++ b/scripts/radial/npc/corpse.py @@ -0,0 +1,16 @@ +from resources.common import RadialOptions +import sys + +def createRadial(core, owner, target, radials): + radials.clear() + radials.add(RadialOptions(0, 36, 0, 'Loot')) + + return + +def handleSelection(core, owner, target, option): + if option == 36 and target: + core.lootService.handleLootRequest(owner,target) + if option == 15 and target: + core.objectService.destroyObject(target) + return + \ No newline at end of file diff --git a/scripts/radial/structure_management_terminal.py b/scripts/radial/structure_management_terminal.py new file mode 100644 index 00000000..b6e7ae3a --- /dev/null +++ b/scripts/radial/structure_management_terminal.py @@ -0,0 +1,77 @@ +from resources.common import RadialOptions +from protocol.swg import ResourceListForSurveyMessage +from services.sui.SUIService import MessageBoxType +from services.sui.SUIWindow import Trigger +from java.util import Vector +import sys + +def createRadial(core, owner, target, radials): + #(byte parentId, short optionId, byte optionType, String description) + radials.clear() + radials.add(RadialOptions(0, 7, 0, 'Examine')) + radials.add(RadialOptions(0, 78, 0, '@player_structure:management')) + radials.add(RadialOptions(0, 117, 0, '@player_structure:permissions')) + radials.add(RadialOptions(2, 128, 0, '@player_structure:permission_destroy')) + radials.add(RadialOptions(2, 124, 0, '@player_structure:management_status')) + radials.add(RadialOptions(2, 129, 0, '@player_structure:management_pay')) + radials.add(RadialOptions(2, 50, 0, '@base_player:set_name')) + radials.add(RadialOptions(2, 127, 0, '@player_structure:management_residence')) + radials.add(RadialOptions(2, 125, 0, '@player_structure:management_privacy : ' + core.housingService.fetchPrivacyString(target))) + radials.add(RadialOptions(2, 171, 0, '@player_structure:find_items_find_all_house_items')) + radials.add(RadialOptions(2, 173, 0, '@player_structure:move_first_item')) + radials.add(RadialOptions(2, 174, 0, '@player_structure:find_items_search_for_house_items')) + radials.add(RadialOptions(2, 175, 0, '@player_structure:delete_all_items_title')) + 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')) + + return + +def handleSelection(core, owner, target, option): + + if option == 128: + if owner is not None: + core.housingService.createDestroySUIPage(owner,target) + return + if option == 124: + if owner is not None: + core.housingService.createStatusSUIPage(owner,target) + return + if option == 129: + if owner is not None: + core.housingService.createPayMaintenanceSUIPage(owner,target) + return + if option == 50: + if owner is not None: + core.housingService.createRenameSUIPage(owner,target) + return + if option == 127: + if owner is not None: + core.housingService.declareResidency(owner,target) + return + if option == 171: + if owner is not None: + core.housingService.handleListAllItems(owner,target) + return + if option == 175: + if owner is not None: + core.housingService.handleDeleteAllItems(owner,target) + return + if option == 173: + if owner is not None: + core.housingService.handleFindLostItems(owner,target) + return + if option == 174: + if owner is not None: + core.housingService.handleSearchForItems(owner,target) + return + if option == 121: + if owner is not None: + core.housingService.handlePermissionEntry(owner,target) + return + if option == 123: + if owner is not None: + core.housingService.handlePermissionBan(owner,target) + return + + diff --git a/scripts/radial/tunable.py b/scripts/radial/tunable.py new file mode 100644 index 00000000..f226f86b --- /dev/null +++ b/scripts/radial/tunable.py @@ -0,0 +1,15 @@ +from resources.common import RadialOptions +import sys + +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')) + 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) + return diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 4f2fc5f9..56f33e88 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -60,6 +60,7 @@ import services.GroupService; import services.housing.HousingService; import services.InstanceService; import services.LoginService; +import services.LootService; import services.MissionService; import services.PlayerService; import services.ScriptService; @@ -71,6 +72,7 @@ import services.SurveyService; import services.TerrainService; import services.WeatherService; import services.ai.AIService; +import services.bazaar.BazaarService; import services.chat.ChatService; import services.collections.CollectionService; import services.combat.CombatService; @@ -83,6 +85,7 @@ import services.LoginService; import services.map.MapService; import services.object.ObjectService; import services.object.UpdateService; +import services.resources.HarvesterService; import services.resources.ResourceService; import services.retro.RetroService; import services.spawn.SpawnService; @@ -171,13 +174,13 @@ public class NGECore { //public MissionService missionService; public InstanceService instanceService; public DevService devService; - public SurveyService surveyService; public ResourceService resourceService; - public ConversationService conversationService; - + public BazaarService bazaarService; public HousingService housingService; + public LootService lootService; + public HarvesterService harvesterService; // Login Server @@ -202,7 +205,7 @@ public class NGECore { private BusConfiguration eventBusConfig = BusConfiguration.Default(1, new ThreadPoolExecutor(1, 4, 1, TimeUnit.MINUTES, new LinkedBlockingQueue())); private ObjectDatabase buildingODB; - + private ObjectDatabase auctionODB; private ObjectDatabase resourcesODB; private ObjectDatabase resourceRootsODB; private ObjectDatabase resourceHistoryODB; @@ -238,6 +241,11 @@ public class NGECore { if (!(config.loadConfigFile())) { config = DefaultConfig.getConfig(); } + + Config options = new Config(); + options.setFilePath("options.cfg"); + boolean optionsConfigLoaded = options.loadConfigFile(); + // Database databaseConnection = new DatabaseConnection(); databaseConnection.connect(config.getString("DB.URL"), config.getString("DB.NAME"), config.getString("DB.USER"), config.getString("DB.PASS"), "postgresql"); @@ -261,6 +269,7 @@ public class NGECore { resourcesODB = new ObjectDatabase("resources", true, false, true); resourceRootsODB = new ObjectDatabase("resourceroots", true, false, true); resourceHistoryODB = new ObjectDatabase("resourcehistory", true, false, true); + auctionODB = new ObjectDatabase("auction", true, false, true); // Services loginService = new LoginService(this); @@ -289,7 +298,10 @@ public class NGECore { entertainmentService = new EntertainmentService(this); devService = new DevService(this); conversationService = new ConversationService(this); + bazaarService = new BazaarService(this); housingService = new HousingService(this); + lootService = new LootService(this); + harvesterService = new HarvesterService(this); if (config.keyExists("JYTHONCONSOLE.PORT")) { int jythonPort = config.getInt("JYTHONCONSOLE.PORT"); @@ -306,7 +318,7 @@ public class NGECore { aiService = new AIService(this); //missionService = new MissionService(this); - if (config.getInt("LOAD.RESOURCE.SYSTEM") == 1) { + if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") == 1) { surveyService = new SurveyService(this); resourceService = new ResourceService(this); } @@ -342,6 +354,7 @@ public class NGECore { zoneDispatch.addService(buffService); zoneDispatch.addService(entertainmentService); //zoneDispatch.addService(missionService); + zoneDispatch.addService(bazaarService); zoneServer = new MINAServer(zoneDispatch, config.getInt("ZONE.PORT")); zoneServer.start(); @@ -410,7 +423,7 @@ public class NGECore { objectService.loadBuildings(); - if (config.getInt("LOAD.RESOURCE.SYSTEM") == 1) { + if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") > 0) { objectService.loadResourceRoots(); objectService.loadResources(); } diff --git a/src/protocol/swg/ObjControllerMessage.java b/src/protocol/swg/ObjControllerMessage.java index b3aa94eb..1c94c6b7 100644 --- a/src/protocol/swg/ObjControllerMessage.java +++ b/src/protocol/swg/ObjControllerMessage.java @@ -83,8 +83,9 @@ public class ObjControllerMessage extends SWGMessage { } public IoBuffer serialize() { - IoBuffer buffer = IoBuffer.allocate(1024).order(ByteOrder.LITTLE_ENDIAN); - + //IoBuffer buffer = IoBuffer.allocate(1024).order(ByteOrder.LITTLE_ENDIAN); -> java.nio.BufferOverflowException + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); buffer.putShort((short)5); buffer.putInt(0x80CE5E46); buffer.putInt(update); diff --git a/src/protocol/swg/auctionManagerClientListener/AcceptAuctionResponseMessage.java b/src/protocol/swg/auctionManagerClientListener/AcceptAuctionResponseMessage.java new file mode 100644 index 00000000..49aae248 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/AcceptAuctionResponseMessage.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class AcceptAuctionResponseMessage extends SWGMessage { + + private long itemId; + private int error; + + public AcceptAuctionResponseMessage(long itemId, int error) { + this.itemId = itemId; + this.error = error; + } + + @Override + public void deserialize(IoBuffer data) { + + } + + @Override + public IoBuffer serialize() { + IoBuffer result = IoBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN); + result.putShort((short) 3); + result.putInt(0xC58A446E); + result.putLong(itemId); + result.putInt(error); + return result.flip(); + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/AuctionItemDescriptionMessage.java b/src/protocol/swg/auctionManagerClientListener/AuctionItemDescriptionMessage.java new file mode 100644 index 00000000..bdb7e95e --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/AuctionItemDescriptionMessage.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class AuctionItemDescriptionMessage extends SWGMessage { + + private long itemId; + private String description; + + public AuctionItemDescriptionMessage(long itemId, String description) { + this.itemId = itemId; + this.description = description; + } + + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + IoBuffer result = IoBuffer.allocate(26 + (description.length() * 2)).order(ByteOrder.LITTLE_ENDIAN); + result.putShort((short) 2); + result.putInt(0xFE0E644B); + result.putLong(itemId); + result.put(getUnicodeString(description)); + result.putInt(0); + result.putInt(0); + return result.flip(); + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersMessage.java b/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersMessage.java new file mode 100644 index 00000000..14f345ba --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersMessage.java @@ -0,0 +1,183 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class AuctionQueryHeadersMessage extends SWGMessage { + + private int range; + private int counter; + private int screen; + private int category; + private int itemTypeCRC; + private String searchString; + private int unkInt; + private int minPrice; + private int maxPrice; + private byte includeEntranceFee; + private long vendorId; + private byte vendorFlag; + private short offset; + + @Override + public void deserialize(IoBuffer data) { + data.skip(6); + setRange(data.getInt()); + setCounter(data.getInt()); + setScreen(data.getInt()); + setCategory(data.getInt()); + setItemTypeCRC(data.getInt()); + int size = data.getInt(); + try { + setSearchString(new String(ByteBuffer.allocate(size * 2).put(data.array(), data.position(), size * 2).array(), "UTF-16LE")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + data.position(data.position() + size * 2); + setUnkInt(data.getInt()); + setMinPrice(data.getInt()); + setMaxPrice(data.getInt()); + setIncludeEntranceFee(data.get()); + data.skip(5); // unk + setVendorId(data.getLong()); + setVendorFlag(data.get()); + setOffset(data.getShort()); + + } + + @Override + public IoBuffer serialize() { + // TODO Auto-generated method stub + return null; + } + + public int getRange() { + return range; + } + + public void setRange(int range) { + this.range = range; + } + + public int getCounter() { + return counter; + } + + public void setCounter(int counter) { + this.counter = counter; + } + + public int getScreen() { + return screen; + } + + public void setScreen(int screen) { + this.screen = screen; + } + + public int getCategory() { + return category; + } + + public void setCategory(int category) { + this.category = category; + } + + public int getItemTypeCRC() { + return itemTypeCRC; + } + + public void setItemTypeCRC(int itemTypeCRC) { + this.itemTypeCRC = itemTypeCRC; + } + + public String getSearchString() { + return searchString; + } + + public void setSearchString(String searchString) { + this.searchString = searchString; + } + + public int getUnkInt() { + return unkInt; + } + + public void setUnkInt(int unkInt) { + this.unkInt = unkInt; + } + + public int getMinPrice() { + return minPrice; + } + + public void setMinPrice(int minPrice) { + this.minPrice = minPrice; + } + + public int getMaxPrice() { + return maxPrice; + } + + public void setMaxPrice(int maxPrice) { + this.maxPrice = maxPrice; + } + + public byte getIncludeEntranceFee() { + return includeEntranceFee; + } + + public void setIncludeEntranceFee(byte includeEntranceFee) { + this.includeEntranceFee = includeEntranceFee; + } + + public long getVendorId() { + return vendorId; + } + + public void setVendorId(long vendorId) { + this.vendorId = vendorId; + } + + public byte getVendorFlag() { + return vendorFlag; + } + + public void setVendorFlag(byte vendorFlag) { + this.vendorFlag = vendorFlag; + } + + public short getOffset() { + return offset; + } + + public void setOffset(short offset) { + this.offset = offset; + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersResponseMessage.java b/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersResponseMessage.java new file mode 100644 index 00000000..4c2776c9 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersResponseMessage.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class AuctionQueryHeadersResponseMessage extends SWGMessage { + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/BidAuctionMessage.java b/src/protocol/swg/auctionManagerClientListener/BidAuctionMessage.java new file mode 100644 index 00000000..ea769785 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/BidAuctionMessage.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class BidAuctionMessage extends SWGMessage { + + private long auctionId; + private int myPrice; + private int proxyPrice; + + @Override + public void deserialize(IoBuffer data) { + data.skip(6); + setAuctionId(data.getLong()); + setMyPrice(data.getInt()); + setProxyPrice(data.getInt()); + } + + @Override + public IoBuffer serialize() { + // TODO Auto-generated method stub + return null; + } + + public long getAuctionId() { + return auctionId; + } + + public void setAuctionId(long auctionId) { + this.auctionId = auctionId; + } + + public int getMyPrice() { + return myPrice; + } + + public void setMyPrice(int myPrice) { + this.myPrice = myPrice; + } + + public int getProxyPrice() { + return proxyPrice; + } + + public void setProxyPrice(int proxyPrice) { + this.proxyPrice = proxyPrice; + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/BidAuctionResponseMessage.java b/src/protocol/swg/auctionManagerClientListener/BidAuctionResponseMessage.java new file mode 100644 index 00000000..2ff213ef --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/BidAuctionResponseMessage.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class BidAuctionResponseMessage extends SWGMessage { + + private long objectId; + private int status; + + public static final int SUCCESS = 0; + public static final int INVALIDAUCTIONER = 1; + public static final int INVALIDITEM = 2; + public static final int INVALIDPRICE = 4; + public static final int NOTENOUGHCREDITS = 9; + public static final int PURCHASEFAILED = 10; + public static final int PURCHASEREJECTED = 11; + public static final int PRICETOOHIGH = 13; + public static final int PRICEOVERFLOW = 14; + + public BidAuctionResponseMessage(long objectId, int status) { + this.objectId = objectId; + this.status = status; + } + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + IoBuffer result = IoBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN); + result.putShort((short) 3); + result.putInt(0x8FCBEF4A); + result.putLong(objectId); + result.putInt(status); + return result.flip(); + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionMessage.java b/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionMessage.java new file mode 100644 index 00000000..cc3705a1 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionMessage.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class CancelLiveAuctionMessage extends SWGMessage { + + private long objectId; + + @Override + public void deserialize(IoBuffer data) { + data.skip(6); + setObjectId(data.getLong()); + } + + @Override + public IoBuffer serialize() { + // TODO Auto-generated method stub + return null; + } + + public long getObjectId() { + return objectId; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionResponseMessage.java b/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionResponseMessage.java new file mode 100644 index 00000000..d820f45b --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionResponseMessage.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class CancelLiveAuctionResponseMessage extends SWGMessage { + + public static final int SUCCESS = 0; + public static final int NOTALLOWED = 1; + public static final int INVALIDITEM = 2; + public static final int NOTOWNER = 8; + public static final int ALREADYCOMPLETED = 15; + private long itemId; + private int status; + + public CancelLiveAuctionResponseMessage(long itemId, int status) { + this.itemId = itemId; + this.status = status; + } + + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + IoBuffer result = IoBuffer.allocate(19).order(ByteOrder.LITTLE_ENDIAN); + result.putShort((short) 4); + result.putInt(0x7DA2246C); + result.putLong(itemId); + result.putInt(status); + result.put((byte) 0); // unk + return result.flip(); + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/CommoditiesItemTypeListResponse.java b/src/protocol/swg/auctionManagerClientListener/CommoditiesItemTypeListResponse.java new file mode 100644 index 00000000..d299a44e --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/CommoditiesItemTypeListResponse.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import java.nio.ByteOrder; + +import main.NGECore; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class CommoditiesItemTypeListResponse extends SWGMessage { + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + // TODO: research how categories work + String galaxy = NGECore.getInstance().getGalaxyName(); + IoBuffer result = IoBuffer.allocate(14 + galaxy.length()).order(ByteOrder.LITTLE_ENDIAN); + result.putShort((short) 2); + result.putInt(0xD4E937FC); + result.put(getAsciiString(galaxy + ".0")); + result.putInt(0); + return result.flip(); + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/CommoditiesResourceTypeListResponse.java b/src/protocol/swg/auctionManagerClientListener/CommoditiesResourceTypeListResponse.java new file mode 100644 index 00000000..f898ade4 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/CommoditiesResourceTypeListResponse.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import java.nio.ByteOrder; +import java.util.Vector; + +import main.NGECore; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class CommoditiesResourceTypeListResponse extends SWGMessage { + + private Vector resNames; + + public CommoditiesResourceTypeListResponse(Vector resNames) { + this.resNames = resNames; + } + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + String galaxyName = NGECore.getInstance().getGalaxyName(); + final IoBuffer result = IoBuffer.allocate(100).order(ByteOrder.LITTLE_ENDIAN); + result.setAutoExpand(true); + + result.putShort((short) 2); + result.putInt(0x5EDD19CB); + + result.put(getAsciiString(galaxyName + "." + String.valueOf(resNames.size()))); + result.putInt(479); + result.putLong(0); + + // wrong struct, TODO: research + resNames.forEach(s -> result.put(getAsciiString(s))); + + int size = result.position(); + IoBuffer result2 = IoBuffer.allocate(size).put(result.array(), 0, size); + + return result2.flip(); + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/CreateAuctionMessage.java b/src/protocol/swg/auctionManagerClientListener/CreateAuctionMessage.java new file mode 100644 index 00000000..cdabef34 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/CreateAuctionMessage.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class CreateAuctionMessage extends SWGMessage { + + private long objectId; + private long vendorId; + private int price; + private int duration; + private String description; + private byte premium; + + @Override + public void deserialize(IoBuffer data) { + data.skip(6); + setObjectId(data.getLong()); + setVendorId(data.getLong()); + setPrice(data.getInt()); + setDuration(data.getInt()); // in minutes + int size = data.getInt(); + try { + setDescription(new String(ByteBuffer.allocate(size * 2).put(data.array(), data.position(), size * 2).array(), "UTF-16LE")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + data.position(data.position() + size * 2); + setPremium(data.get()); + } + + @Override + public IoBuffer serialize() { + // TODO Auto-generated method stub + return null; + } + + public long getObjectId() { + return objectId; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + + public long getVendorId() { + return vendorId; + } + + public void setVendorId(long vendorId) { + this.vendorId = vendorId; + } + + public int getPrice() { + return price; + } + + public void setPrice(int price) { + this.price = price; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public byte getPremium() { + return premium; + } + + public void setPremium(byte premium) { + this.premium = premium; + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/CreateImmediateAuctionMessage.java b/src/protocol/swg/auctionManagerClientListener/CreateImmediateAuctionMessage.java new file mode 100644 index 00000000..33307c41 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/CreateImmediateAuctionMessage.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import java.io.UnsupportedEncodingException; +import java.nio.ByteBuffer; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class CreateImmediateAuctionMessage extends SWGMessage { + + private long objectId; + private long vendorId; + private int price; + private int duration; + private String description; + private byte premium; + + @Override + public void deserialize(IoBuffer data) { + data.skip(6); + setObjectId(data.getLong()); + setVendorId(data.getLong()); + setPrice(data.getInt()); + setDuration(data.getInt()); // in minutes + int size = data.getInt(); + try { + setDescription(new String(ByteBuffer.allocate(size * 2).put(data.array(), data.position(), size * 2).array(), "UTF-16LE")); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + data.position(data.position() + size * 2); + setPremium(data.get()); + } + + @Override + public IoBuffer serialize() { + // TODO Auto-generated method stub + return null; + } + + public long getObjectId() { + return objectId; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + + public long getVendorId() { + return vendorId; + } + + public void setVendorId(long vendorId) { + this.vendorId = vendorId; + } + + public int getPrice() { + return price; + } + + public void setPrice(int price) { + this.price = price; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public byte getPremium() { + return premium; + } + + public void setPremium(byte premium) { + this.premium = premium; + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/GetAuctionDetails.java b/src/protocol/swg/auctionManagerClientListener/GetAuctionDetails.java new file mode 100644 index 00000000..946c0a06 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/GetAuctionDetails.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class GetAuctionDetails extends SWGMessage { + + private long objectId; + + @Override + public void deserialize(IoBuffer data) { + data.skip(6); + setObjectId(data.getLong()); + } + + @Override + public IoBuffer serialize() { + // TODO Auto-generated method stub + return null; + } + + public long getObjectId() { + return objectId; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/GetAuctionDetailsResponse.java b/src/protocol/swg/auctionManagerClientListener/GetAuctionDetailsResponse.java new file mode 100644 index 00000000..4fe23725 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/GetAuctionDetailsResponse.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class GetAuctionDetailsResponse extends SWGMessage { + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerMessage.java b/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerMessage.java new file mode 100644 index 00000000..35b3b498 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerMessage.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class IsVendorOwnerMessage extends SWGMessage { + + private long terminalId; + + @Override + public void deserialize(IoBuffer data) { + data.skip(6); + setTerminalId(data.getLong()); + } + + @Override + public IoBuffer serialize() { + // TODO Auto-generated method stub + return null; + } + + public long getTerminalId() { + return terminalId; + } + + public void setTerminalId(long terminalId) { + this.terminalId = terminalId; + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerResponseMessage.java b/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerResponseMessage.java new file mode 100644 index 00000000..cfc73637 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerResponseMessage.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class IsVendorOwnerResponseMessage extends SWGMessage { + + private int permission; + private int errorCode; + private long terminalId; + private String terminalString; + + public IsVendorOwnerResponseMessage(int permission, int errorCode, long terminalId, String terminalString) { + this.permission = permission; + this.errorCode = errorCode; + this.terminalId = terminalId; + this.terminalString = terminalString; + } + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + IoBuffer result = IoBuffer.allocate(26 + terminalString.length()).order(ByteOrder.LITTLE_ENDIAN); + result.putShort((short) 6); + result.putInt(0xCE04173E); + result.putInt(permission); + result.putInt(errorCode); + result.putLong(terminalId); + result.put(getAsciiString(terminalString)); + result.putShort((short) 0x64); // unk + return result.flip(); + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/ItemSoldMessage.java b/src/protocol/swg/auctionManagerClientListener/ItemSoldMessage.java new file mode 100644 index 00000000..6c22d1a1 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/ItemSoldMessage.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class ItemSoldMessage extends SWGMessage { + + public static final int SUCCESS = 0; + public static final int INVALIDAUCTIONER = 1; + public static final int INVALIDITEM = 2; + public static final int BADVENDOR = 3; + public static final int INVALIDPRICE = 4; + public static final int INVALIDDURATION = 5; + public static final int ALREADYFORSALE = 6; + public static final int UNKERROR = 6; + public static final int DONTOWNITEM = 8; + public static final int NOTENOUGHCREDITS = 9; + public static final int TOOMANYITEMS = 13; + public static final int PRICETOOHIGH = 14; + public static final int CANTSELLTRADINGITEM = 19; + public static final int VENDORFULL = 25; + + private long objectId; + private int status; + + public ItemSoldMessage(long objectId, int status) { + this.objectId = objectId; + this.status = status; + } + + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + IoBuffer result = IoBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN); + result.putShort((short) 3); + result.putInt(0x0E61CC92); + result.putLong(objectId); + result.putInt(status); + return result.flip(); + } + + public void setStatus(int status) { + this.status = status; + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemMessage.java b/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemMessage.java new file mode 100644 index 00000000..af2f0c0c --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemMessage.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class RetrieveAuctionItemMessage extends SWGMessage { + + private long objectId; + private long vendorId; + + @Override + public void deserialize(IoBuffer data) { + data.skip(6); + setObjectId(data.getLong()); + setVendorId(data.getLong()); + } + + @Override + public IoBuffer serialize() { + // TODO Auto-generated method stub + return null; + } + + public long getObjectId() { + return objectId; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + + public long getVendorId() { + return vendorId; + } + + public void setVendorId(long vendorId) { + this.vendorId = vendorId; + } + +} diff --git a/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemResponseMessage.java b/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemResponseMessage.java new file mode 100644 index 00000000..2d883695 --- /dev/null +++ b/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemResponseMessage.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.auctionManagerClientListener; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class RetrieveAuctionItemResponseMessage extends SWGMessage { + + private long objectId; + private int status; + + public static final int SUCCESS = 0; + public static final int NOTALLOWED = 1; + public static final int FULLINVENTORY = 12; + public static final int TOOFAR = 0x100; + public static final int DONTRETRIEVE = 0x200; + + public RetrieveAuctionItemResponseMessage(long objectId, int status) { + this.objectId = objectId; + this.status = status; + } + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + + @Override + public IoBuffer serialize() { + IoBuffer result = IoBuffer.allocate(18).order(ByteOrder.LITTLE_ENDIAN); + result.putShort((short) 3); + result.putInt(0x9499EF8C); + result.putLong(objectId); + result.putInt(status); + return result.flip(); + } + +} diff --git a/src/protocol/swg/chat/ChatQueryRoomResults.java b/src/protocol/swg/chat/ChatQueryRoomResults.java index da760c20..33d29f77 100644 --- a/src/protocol/swg/chat/ChatQueryRoomResults.java +++ b/src/protocol/swg/chat/ChatQueryRoomResults.java @@ -54,37 +54,37 @@ public class ChatQueryRoomResults extends SWGMessage { buffer.putShort((short) 7); buffer.putInt(0xC4DE864E); - Vector users = room.getUserList(); + Vector users = room.getUserList(); buffer.putInt(users.size()); if (users.size() > 0) { - for (CreatureObject creo : users) { + for (String str : users) { buffer.put(getAsciiString("SWG")); buffer.put(getAsciiString(server)); - buffer.put(getAsciiString(creo.getCustomName())); + buffer.put(getAsciiString(str)); } } buffer.putInt(0); // TODO: Invited list for chat rooms - Vector moderators = room.getModeratorList(); + Vector moderators = room.getModeratorList(); buffer.putInt(moderators.size()); if (moderators.size() > 0) { - for (CreatureObject creo : users) { + for (String str : moderators) { buffer.put(getAsciiString("SWG")); buffer.put(getAsciiString(server)); - buffer.put(getAsciiString(creo.getCustomName())); + buffer.put(getAsciiString(str)); } } - Vector banned = room.getBanList(); + Vector banned = room.getBanList(); buffer.putInt(banned.size()); if (banned.size() > 0) { - for (CreatureObject creo : users) { + for (String str : banned) { buffer.put(getAsciiString("SWG")); buffer.put(getAsciiString(server)); - buffer.put(getAsciiString(creo.getCustomName())); + buffer.put(getAsciiString(str)); } } diff --git a/src/protocol/swg/chat/ChatRoomList.java b/src/protocol/swg/chat/ChatRoomList.java index b183b140..3021f72f 100644 --- a/src/protocol/swg/chat/ChatRoomList.java +++ b/src/protocol/swg/chat/ChatRoomList.java @@ -34,11 +34,16 @@ import services.chat.ChatRoom; public class ChatRoomList extends SWGMessage { private ConcurrentHashMap chatRooms; + private ChatRoom room; public ChatRoomList(ConcurrentHashMap chatRooms) { this.chatRooms = chatRooms; } + public ChatRoomList(ChatRoom room) { + this.room = room; + } + @Override public void deserialize(IoBuffer data) { @@ -53,24 +58,42 @@ public class ChatRoomList extends SWGMessage { buffer.putShort((short) 2); buffer.putInt(0x70DEB197); - buffer.putInt(chatRooms.size()); - chatRooms.forEach((key, value) -> { - if (value.isVisible()) { - buffer.putInt(value.getRoomId()); - buffer.putInt((int) ((value.isPrivateRoom() ? 1 : 0))); - buffer.put((byte) ((value.isModeratorsOnly() ? 1 : 0))); - buffer.put(getAsciiString(value.getRoomAddress())); - buffer.put(getAsciiString("SWG")); - buffer.put(getAsciiString(server)); - buffer.put(getAsciiString(value.getOwner())); - buffer.put(getAsciiString("SWG")); - buffer.put(getAsciiString(server)); - buffer.put(getAsciiString(value.getCreator())); - buffer.put(getUnicodeString(value.getDescription())); - buffer.putInt(0); // moderator list (not used by client) - buffer.putInt(0); // user list (not used by client) - } - }); + if (room != null) { + buffer.putInt(1); + + buffer.putInt(room.getRoomId()); + buffer.putInt((int) ((room.isPrivateRoom() ? 1 : 0))); + buffer.put((byte) ((room.isModeratorsOnly() ? 1 : 0))); + buffer.put(getAsciiString(room.getRoomAddress())); + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(room.getOwner())); + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(room.getCreator())); + buffer.put(getUnicodeString(room.getDescription())); + buffer.putInt(0); // moderator list (not used by client) + buffer.putInt(0); // user list (not used by client) + } else { + buffer.putInt(chatRooms.size()); + chatRooms.forEach((key, value) -> { + if (value.isVisible()) { + buffer.putInt(value.getRoomId()); + buffer.putInt((int) ((value.isPrivateRoom() ? 1 : 0))); + buffer.put((byte) ((value.isModeratorsOnly() ? 1 : 0))); + buffer.put(getAsciiString(value.getRoomAddress())); + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(value.getOwner())); + buffer.put(getAsciiString("SWG")); + buffer.put(getAsciiString(server)); + buffer.put(getAsciiString(value.getCreator())); + buffer.put(getUnicodeString(value.getDescription())); + buffer.putInt(0); // moderator list (not used by client) + buffer.putInt(0); // user list (not used by client) + } + }); + } buffer.flip(); //StringUtilities.printBytes(buffer.array()); return buffer; diff --git a/src/protocol/swg/chat/ChatServerStatus.java b/src/protocol/swg/chat/ChatServerStatus.java index a867a244..2de0db65 100644 --- a/src/protocol/swg/chat/ChatServerStatus.java +++ b/src/protocol/swg/chat/ChatServerStatus.java @@ -29,6 +29,8 @@ import protocol.swg.SWGMessage; public class ChatServerStatus extends SWGMessage { + public ChatServerStatus() { } + @Override public void deserialize(IoBuffer data) { } diff --git a/src/protocol/swg/chat/VoiceChatStatus.java b/src/protocol/swg/chat/VoiceChatStatus.java new file mode 100644 index 00000000..97936a19 --- /dev/null +++ b/src/protocol/swg/chat/VoiceChatStatus.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg.chat; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import protocol.swg.SWGMessage; + +public class VoiceChatStatus extends SWGMessage { + + public VoiceChatStatus() { } + + @Override + public void deserialize(IoBuffer data) { + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 2); + buffer.putInt(0x9E601905); + buffer.putInt(1); + return buffer.flip(); + } + +} diff --git a/src/resources/common/ObjControllerOpcodes.java b/src/resources/common/ObjControllerOpcodes.java index c2d117bd..1c7b626b 100644 --- a/src/resources/common/ObjControllerOpcodes.java +++ b/src/resources/common/ObjControllerOpcodes.java @@ -42,5 +42,6 @@ public class ObjControllerOpcodes { public static final int STOP_NPC_CONVERSATION = 0xDE000000; public static final int NPC_CONVERSATION_OPTIONS = 0xE0000000; public static final int SET_PROFESSION_TEMPLATE = 0x5C040000; - + public static final int RESOURCE_EMPTY_HOPPER = 0xED000000; + } diff --git a/src/resources/common/Opcodes.java b/src/resources/common/Opcodes.java index 4ac4d5ad..59b9880d 100644 --- a/src/resources/common/Opcodes.java +++ b/src/resources/common/Opcodes.java @@ -34,7 +34,7 @@ public class Opcodes { public static int ChatRequestRoomList = 0x4C3D2CFA; public static int ChatSystemMessage = CRC.StringtoCRC("ChatSystemMessage"); public static int ClientOpenContainerMessage = 0x2D2D6EE1; - public static int CommodotiesItemTypeListRequest = 0x48F493C5; + public static int CommoditiesItemTypeListRequest = 0x48F493C5; public static int CommoditiesResourceTypeListRequest = 0xCB1AE82D; public static int NewbieTutorialResponse = 0xCA88FBAD; public static int CmdSceneReady = 0x43FD1C22; @@ -45,6 +45,7 @@ public class Opcodes { public static int ClientVerifyAndLockNameRequest = 0x9eb04b9f; public static int DeleteCharacterMessage = 0xE87AD031; public static int GetMapLocationsMessage = 0x1A7AB839; + public static int IsVendorOwnerMessage = CRC.StringtoCRC("IsVendorOwnerMessage"); public static int LagRequest = 0x31805EE0; public static int LoginClientId = 0x41131F96; public static int ObjControllerMessage = 0x80CE5E46; @@ -77,9 +78,9 @@ public class Opcodes { public static int CollectionServerFirstListRequest = CRC.StringtoCRC("CollectionServerFirstListRequest"); public static int ShowHelmet = CRC.StringtoCRC("ShowHelmet"); public static int ShowBackpack = CRC.StringtoCRC("ShowBackpack"); + public static int CreateAuctionMessage = CRC.StringtoCRC("CreateAuctionMessage"); public static int ChatOnEnteredRoom = CRC.StringtoCRC("ChatOnEnteredRoom"); public static int ChatCreateRoom = CRC.StringtoCRC("ChatCreateRoom"); public static int ChatQueryRoom = 0x9CF2B192; - public static int Unknown = 0x173B91C2; // packet sent to server on every character load-in } diff --git a/src/resources/objects/building/BuildingMessageBuilder.java b/src/resources/objects/building/BuildingMessageBuilder.java index 5a751d8f..b3639d99 100644 --- a/src/resources/objects/building/BuildingMessageBuilder.java +++ b/src/resources/objects/building/BuildingMessageBuilder.java @@ -22,8 +22,12 @@ package resources.objects.building; import java.nio.ByteOrder; +import java.util.Vector; + import org.apache.mina.core.buffer.IoBuffer; + import resources.objects.ObjectMessageBuilder; +import resources.objects.harvester.HarvesterObject; public class BuildingMessageBuilder extends ObjectMessageBuilder { @@ -122,6 +126,26 @@ public class BuildingMessageBuilder extends ObjectMessageBuilder { return buffer; } + + public IoBuffer buildPermissionListCreate(Vector permissionList, String listName) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + int listSize = permissionList.size(); + buffer.putShort((short)4); + buffer.putInt(0x52F364B8); + buffer.putInt(listSize); + for (String name : permissionList){ + buffer.put(getUnicodeString(name)); + } + //buffer.putInt(0x61); + buffer.putInt(0); + //buffer.putShort((short)0); + buffer.put(getUnicodeString(listName)); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } @Override diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index f604d0a3..36486462 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -21,36 +21,57 @@ ******************************************************************************/ package resources.objects.building; +import java.util.Vector; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; + +import main.NGECore; 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; import com.sleepycat.persist.model.NotPersistent; + import engine.clients.Client; import engine.resources.objects.IPersistent; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Entity(version=0) +@Entity(version=6) public class BuildingObject extends TangibleObject implements IPersistent { @NotPersistent private BuildingMessageBuilder messageBuilder; @NotPersistent private Transaction txn; + + private float maintenanceAmount = 0; + private int BMR = 0; + private String deedTemplate=""; + private boolean residency=false; + private byte privacy=(byte)0; + public static byte PRIVATE = (byte)0; + public static byte PUBLIC = (byte)1; + private short maximumStorageCapacity=0; + private Vector entryList = new Vector(); // Preferably the OIDs should be stored, because of name changes + private Vector banList = new Vector(); public BuildingObject() { super(); messageBuilder = new BuildingMessageBuilder(this); + this.setConditionDamage(100); } public BuildingObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) { super(objectID, planet, Template, position, orientation); messageBuilder = new BuildingMessageBuilder(this); + this.setConditionDamage(100); } public CellObject getCellByCellNumber(final int cellNumber) { @@ -67,6 +88,134 @@ public class BuildingObject extends TangibleObject implements IPersistent { return ref.get(); } + + public float getMaintenanceAmount() { + return maintenanceAmount; + } + + public void setMaintenanceAmount(float maintenanceAmount) { + this.maintenanceAmount = maintenanceAmount; + } + + public void setDeedTemplate(String deedTemplate){ + this.deedTemplate = deedTemplate; + } + + public String getDeedTemplate(){ + return this.deedTemplate; + } + + public String getBuildingName() { + return this.getCustomName(); + } + + public void setBuildingName(String buildingName, CreatureObject owner) { + //owner.getClient().getSession().write(messageBuilder.buildCustomNameDelta(this,buildingName)); + this.setCustomName(buildingName); + ((CreatureObject)owner).sendSystemMessage("Structure renamed.", (byte) 0); + } + + public int getBMR() { + return BMR; + } + + public void setBMR(int BMR) { + this.BMR = BMR; + } + + public void setResidency(CreatureObject owner){ + owner.sendSystemMessage("@player_structure:declared_residency", (byte) 1); + residency = true; + } + + public boolean getResidency(){ + return this.residency; + } + + public byte getPrivacy() { + return privacy; + } + + public String getPrivacyString() { + if (privacy==PRIVATE) + return "private"; + if (privacy==PUBLIC) + return "public"; + return "42"; + } + + public void setPrivacy(byte privacy) { + this.privacy = privacy; + } + + public Vector getItemsList() { + Vector items = new Vector(); + getCells().forEach(c -> c.viewChildren(c, true, false, (item) -> { + if(!(item instanceof CreatureObject) && item.getTemplate() != "object/tangible/terminal/shared_terminal_player_structure.iff") + items.add((TangibleObject) item); + })); + return items; + } + + public short getMaximumStorageCapacity() { + return maximumStorageCapacity; + } + + public void setMaximumStorageCapacity(short maximumStorageCapacity) { + this.maximumStorageCapacity = maximumStorageCapacity; + } + + public void setPermissionEntry(String name,CreatureObject owner){ + Vector entryListFirstNames = new Vector(); + for (long oid : entryList){ + String firstName = NGECore.getInstance().characterService.getPlayerFirstName(oid); + entryListFirstNames.add(firstName); + } + entryListFirstNames.add("Peter"); + entryListFirstNames.add("Jackson"); + owner.getClient().getSession().write(messageBuilder.buildPermissionListCreate(entryListFirstNames, name)); + } + + public void setPermissionBan(String name,CreatureObject owner){ + Vector banListFirstNames = new Vector(); + for (long oid : banList){ + String firstName = NGECore.getInstance().characterService.getPlayerFirstName(oid); + banListFirstNames.add(firstName); + } + banListFirstNames.add("Peter"); + banListFirstNames.add("Smith"); + owner.getClient().getSession().write(messageBuilder.buildPermissionListCreate(banListFirstNames, name)); + } + + public void addPlayerToEntryList(CreatureObject owner,long oid, String firstName){ + if (!entryList.contains(oid)){ + this.entryList.add(oid); + owner.sendSystemMessage(firstName+ " added to the list.", (byte)1); // player_added %NO added to the list. + } + } + + public void removePlayerFromEntryList(CreatureObject owner,long oid, String firstName){ + if (entryList.contains(oid)){ + this.entryList.remove(oid); + owner.sendSystemMessage(firstName+ " removed to the list.", (byte)1); // player_removed %NO removed from the list. + } + } + + public void addPlayerToBanList(CreatureObject owner,long oid, String firstName){ + if (!banList.contains(oid)){ + this.banList.add(oid); + owner.sendSystemMessage(firstName+ " added to the list.", (byte)1); + } + } + + public void removePlayerFromBanList(CreatureObject owner,long oid, String firstName){ + if (banList.contains(oid)){ + this.banList.remove(oid); + owner.sendSystemMessage(firstName+ " removed to the list.", (byte)1); + } + } + + @Override public void sendBaselines(Client destination) { @@ -89,5 +238,14 @@ public class BuildingObject extends TangibleObject implements IPersistent { txn = env.beginTransaction(null, null); txn.setLockTimeout(500, TimeUnit.MILLISECONDS); } - + + public Vector getCells() { + final Vector cells = new Vector(); + this.viewChildren(this, true, false, (obj) -> { + if(obj instanceof CellObject) + cells.add((CellObject) obj); + }); + return cells; + } + } diff --git a/src/resources/objects/deed/Deed.java b/src/resources/objects/deed/Deed.java new file mode 100644 index 00000000..f98c6398 --- /dev/null +++ b/src/resources/objects/deed/Deed.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.deed; + +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; +import resources.objects.tangible.TangibleObject; + +/** + * @author Charon + */ +public class Deed extends TangibleObject { + + public Deed(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ + super(objectID, planet, template, position, orientation); + } +} diff --git a/src/resources/objects/deed/Harvester_Deed.java b/src/resources/objects/deed/Harvester_Deed.java new file mode 100644 index 00000000..945d9eb3 --- /dev/null +++ b/src/resources/objects/deed/Harvester_Deed.java @@ -0,0 +1,121 @@ +/******************************************************************************* + * 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.deed; +import com.sleepycat.persist.model.Persistent; + +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; + +/** + * @author Charon + */ +@Persistent(version=0) +public class Harvester_Deed extends Deed { + + private String name; + private String structureTemplate; + private String constructorTemplate; + private int outputHopperCapacity=0; + private int BER=0; + private int BMR=0; + private int surplusMaintenance=0; + private int surplusPower=0; + private int lotRequirement; + + + public Harvester_Deed(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ + super(objectID, planet, template, position, orientation); + } + + public int getOutputHopperCapacity() { + return outputHopperCapacity; + } + public void setOutputHopperCapacity(int outputHopperCapacity) { + this.outputHopperCapacity = outputHopperCapacity; + } + public int getBER() { + return BER; + } + public void setBER(int bER) { + this.BER = bER; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getStructureTemplate() { + return structureTemplate; + } + public void setStructureTemplate(String structureTemplate) { + this.structureTemplate = structureTemplate; + } + public int getLotRequirement() { + return lotRequirement; + } + public void setLotRequirement(int lotRequirement) { + this.lotRequirement = lotRequirement; + } + public String getConstructorTemplate() { + return constructorTemplate; + } + public void setConstructorTemplate(String constructorTemplate) { + this.constructorTemplate = constructorTemplate; + } + public int getBMR() { + return BMR; + } + public void setBMR(int BMR) { + this.BMR = BMR; + } + public int getSurplusMaintenance() { + return surplusMaintenance; + } + public void setSurplusMaintenance(int surplusMaintenance) { + this.surplusMaintenance = surplusMaintenance; + } + + public int getSurplusPower() { + return surplusPower; + } + + public void setSurplusPower(int surplusPower) { + this.surplusPower = surplusPower; + } + + + public void setAttributes() { + this.getAttributes().put("@obj_attr_n:volume", "1"); + this.getAttributes().put("@obj_attr_n:examine_maintenance_rate", ""+this.getBMR() + "/hour"); + if (this.getSurplusMaintenance()>0) + this.getAttributes().put("@obj_attr_n:examine_maintenance", ""+this.getSurplusMaintenance()); + + //this.getAttributes().put("@obj_attr_n:energy_maintenance", "0"); + if (this.getSurplusPower()>0) + this.getAttributes().put("@obj_attr_n:examine_power", ""+this.getSurplusPower()); + + this.getAttributes().put("@obj_attr_n:examine_hoppersize", ""+this.getOutputHopperCapacity()); + this.getAttributes().put("@obj_attr_n:examine_extractionrate", ""+this.getBER()); + } +} diff --git a/src/resources/objects/deed/Player_House_Deed.java b/src/resources/objects/deed/Player_House_Deed.java new file mode 100644 index 00000000..448f3da9 --- /dev/null +++ b/src/resources/objects/deed/Player_House_Deed.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * 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.deed; +import com.sleepycat.persist.model.Persistent; + +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; + +/** + * @author Seefo + * @author Charon + */ + +@Persistent(version=0) +public class Player_House_Deed extends Deed { + + private String name; + private String structureTemplate; + private String constructorTemplate; + private int BMR=0; + private int surplusMaintenance=0; + private int lotRequirement; + + + public Player_House_Deed(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ + super(objectID, planet, template, position, orientation); + } + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getStructureTemplate() { + return structureTemplate; + } + public void setStructureTemplate(String structureTemplate) { + this.structureTemplate = structureTemplate; + } + public int getLotRequirement() { + return lotRequirement; + } + public void setLotRequirement(int lotRequirement) { + this.lotRequirement = lotRequirement; + } + public String getConstructorTemplate() { + return constructorTemplate; + } + public void setConstructorTemplate(String constructorTemplate) { + this.constructorTemplate = constructorTemplate; + } + public int getBMR() { + return BMR; + } + public void setBMR(int BMR) { + this.BMR = BMR; + } + public int getSurplusMaintenance() { + return surplusMaintenance; + } + public void setSurplusMaintenance(int surplusMaintenance) { + this.surplusMaintenance = surplusMaintenance; + } + + public void setAttributes() { + this.getAttributes().put("@obj_attr_n:volume", "1"); + this.getAttributes().put("@obj_attr_n:examine_maintenance_rate", ""+this.getBMR() + "/hour"); + if (this.getSurplusMaintenance()>0) + this.getAttributes().put("@obj_attr_n:examine_maintenance", ""+this.getSurplusMaintenance()); + + + } +} diff --git a/src/resources/objects/group/GroupObject.java b/src/resources/objects/group/GroupObject.java index 0cac422d..0f5c4622 100644 --- a/src/resources/objects/group/GroupObject.java +++ b/src/resources/objects/group/GroupObject.java @@ -41,6 +41,11 @@ public class GroupObject extends UniverseObject { private GroupMessageBuilder messageBuilder; private int chatRoomId; + public static int FREE_FOR_ALL = 0; + public static int MASTER_LOOTER = 1; + public static int LOTTERY = 2; + + public GroupObject(long objectId) { super(objectId, null, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), "object/group/shared_group_object.iff"); messageBuilder = new GroupMessageBuilder(this); diff --git a/src/resources/objects/harvester/HarvesterMessageBuilder.java b/src/resources/objects/harvester/HarvesterMessageBuilder.java index 3b6c4602..98daa62a 100644 --- a/src/resources/objects/harvester/HarvesterMessageBuilder.java +++ b/src/resources/objects/harvester/HarvesterMessageBuilder.java @@ -21,6 +21,807 @@ ******************************************************************************/ package resources.objects.harvester; -public class HarvesterMessageBuilder { +import java.nio.ByteOrder; +import java.util.Vector; +import org.apache.mina.core.buffer.IoBuffer; + +import engine.resources.objects.SWGObject; + +import resources.objects.ObjectMessageBuilder; +import resources.objects.building.BuildingObject; +import resources.objects.creature.CreatureObject; +import resources.objects.resource.GalacticResource; +import resources.objects.resource.ResourceContainerObject; + +/** + * @author Charon + */ +public class HarvesterMessageBuilder extends ObjectMessageBuilder{ + + public HarvesterMessageBuilder(HarvesterObject harvesterObject) { + setObject(harvesterObject); + } + + public IoBuffer buildBaseline3() { + + HarvesterObject building = (HarvesterObject) object; + IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + + buffer.putShort((short) 0x0D); + buffer.putFloat(building.getComplexity()); + buffer.put(getAsciiString(building.getStfFilename())); + buffer.putInt(0); + buffer.put(getAsciiString(building.getStfName())); + buffer.putInt(0); + buffer.putInt(0xFF); + //buffer.putInt(0x64); + buffer.putInt(0); + buffer.putInt(0); + buffer.putShort((short) 0); + + buffer.putInt(0); + buffer.putInt(0); + // buffer.putInt(16777216); + buffer.putInt(0x100); + buffer.putInt(0); + buffer.putInt(64); + buffer.putInt(0x201C); + buffer.put((byte) 1); + + int size = buffer.position(); + buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); + + buffer.flip(); + buffer = createBaseline("BUIO", (byte) 3, buffer, size); + + return buffer; + + } + + public IoBuffer buildHINO3Delta(HarvesterObject harvester,byte state) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)3); + buffer.putInt(0xB); + buffer.putShort((short)2); + buffer.putShort((short)8); + buffer.put((byte)1); + buffer.putShort((short)1); + buffer.put((byte)0); + buffer.putShort((short)0xD); + buffer.put(state); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } +// 0000: 05 00 53 21 86 12 33 01 0E BE 41 00 00 00 4F 4E ..S!..3...A...ON +// 0010: 49 48 03 0B 00 00 00 02 00 08 00 01 01 00 00 0D IH.............. +// 0020: 00 01 + + + public IoBuffer buildHINO3Delta2(HarvesterObject harvester,byte state) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)3); + buffer.putInt(0xB); + buffer.putShort((short)2); + buffer.putShort((short)8); + buffer.put((byte)0); + buffer.putShort((short)1); + buffer.put((byte)0); + buffer.putShort((short)0xD); + buffer.put(state); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + public IoBuffer buildBaseline6() { + + HarvesterObject building = (HarvesterObject) object; + IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + + buffer.putShort((short) 8); + buffer.putInt(0x43); + + buffer.put(getAsciiString(building.getDetailFilename())); + buffer.putInt(0); + buffer.put(getAsciiString(building.getDetailName())); + buffer.putInt(0); + buffer.put((byte) 0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + + int size = buffer.position(); + buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); + + buffer.flip(); + buffer = createBaseline("BUIO", (byte) 6, buffer, size); + + return buffer; + + } + + + public IoBuffer buildHINO7Delta(HarvesterObject harvester,byte state) { + + Vector outputHopperContent = harvester.getOutputHopperContent(); + int hopperContentSize = outputHopperContent.size(); + int iHopperList = 1; + if (hopperContentSize==0) { + iHopperList = 0; + } + //int sizeP = 30 + 15*hopperContentSize; + int sizeP = 30-2-4-4; + //System.out.println("sizeP " + sizeP); + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + buffer.putInt(sizeP); + // dOut.writeInt(0x2D); + buffer.putShort((short)5); + buffer.putShort((short)6); + buffer.put(state); + buffer.putShort((short)9); + buffer.putFloat(harvester.getActualExtractionRate()); + buffer.putShort((short)0x0C); + buffer.put(harvester.getUpdateCount()); +// buffer.putShort((short)0x0D); +// buffer.putInt(iHopperList); +// buffer.putInt(harvester.getResourceUpdateCount()); + int sumOfHopper = 0; + int i = 0; + sumOfHopper = 0; + Vector outputHopper = harvester.getOutputHopperContent(); + for (ResourceContainerObject cont : outputHopper){ + sumOfHopper += cont.getStackCount(); + i++; + } + + buffer.putShort((short)0x0A); + buffer.putInt(sumOfHopper); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildHINO7Delta2(HarvesterObject harvester,byte state) { + + Vector outputHopperContent = harvester.getOutputHopperContent(); + int hopperContentSize = outputHopperContent.size(); + int iHopperList = 1; + if (hopperContentSize==0) { + iHopperList = 0; + } + int sizeP = 30 + 15*hopperContentSize; + //System.out.println("sizeP " + sizeP); + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + buffer.putInt(sizeP); + // dOut.writeInt(0x2D); + buffer.putShort((short)5); + buffer.putShort((short)6); + buffer.put(state); + buffer.putShort((short)9); + buffer.putFloat(harvester.getActualExtractionRate()); + buffer.putShort((short)0x0C); + buffer.put(harvester.getUpdateCount()); + buffer.putShort((short)0x0D); + buffer.putInt(iHopperList); + buffer.putInt(harvester.getResourceUpdateCount()); + int sumOfHopper = 0; + + byte i = 0; + for (ResourceContainerObject container : outputHopperContent){ + buffer.putShort((short)harvester.getResourceUpdateCount()); + buffer.put(i); + buffer.putLong(container.getReferenceID()); + buffer.putInt(container.getStackCount()); + sumOfHopper += container.getStackCount(); + i++; + } + + buffer.putShort((short)0x0A); + buffer.putInt(sumOfHopper); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + // 2 + 2 + 1 + 2 + 4 + 2 + 1 + 2 + 4 + 4 + (hoppersize* 2+1+8+4=15) + 2 + 4 + +// 0000: 05 00 53 21 86 12 33 01 0E BE 41 00 00 00 4F 4E ..S!..3...A...ON +// 0010: 49 48 07 2D 00 00 00 05 00 06 00 01 09 00 3F AE IH.-..........?. +// 0020: 2D 42 0C 00 02 0D 00 01 00 00 00 01 00 00 00 02 -B.............. +// 0030: 00 00 5E C8 62 AB 41 00 00 00 CC F1 0A 40 0A 00 ..^.b.A......@.. +// 0040: CC F1 0A 40 ...@ + + public IoBuffer buildHINO7EmptyHopperDelta(HarvesterObject harvester) { + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + buffer.putInt(21); + buffer.putShort((short)3); + buffer.putShort((short)0x0C); + buffer.put((byte)harvester.getResourceUpdateCount()); + buffer.putShort((short)0x0D); + buffer.putInt(0); + buffer.putInt(harvester.getResourceUpdateCount()); + buffer.putShort((short)0x0A); + buffer.putFloat(harvester.getOutputHopperContent().size()); + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + public IoBuffer buildHINO7ExperimentalDelta(HarvesterObject harvester) { + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + buffer.putInt(0x18); + buffer.putShort((short)3); + buffer.putShort((short)0x0C); + buffer.put((byte)harvester.getResourceUpdateCount()); + buffer.putShort((short)0x0D); + buffer.putInt(1); + buffer.putInt(0x1E); + buffer.put((byte)0); + buffer.putShort((short)0); + buffer.putInt(harvester.getResourceUpdateCount()); + buffer.putShort((short)0x0A); + buffer.putFloat(0); // since it's 0 outputhoppercontent + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + +// 0000: 05 00 53 21 86 12 53 D0 AC 41 3F 00 00 00 4F 4E ..S!..S..A?...ON +// 0010: 49 48 07 18 00 00 00 03 00 0C 00 25 0D 00 01 00 IH.........%.... +// 0020: 00 00 1E 00 00 00 00 00 00 0A 00 00 00 00 00 ............... + + + public IoBuffer buildHINO7ExperimentalDelta2(HarvesterObject harvester) { + + int iHopperList = 0; + if (harvester.getOutputHopperContent().size() >= 1) { + iHopperList = 1; + } + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + + buffer.putInt(36); + buffer.putShort((short)3); + buffer.putShort((short)0x0C); + buffer.put(harvester.getUpdateCount()); + buffer.putShort((short)0x0D); + buffer.putInt(iHopperList); + buffer.putInt(harvester.getResourceUpdateCount()); + int i = 0; + int totalStackCount = 0; + Vector outputHopper = harvester.getOutputHopperContent(); + for (ResourceContainerObject cont : outputHopper){ + totalStackCount += cont.getStackCount(); + if (cont.getReferenceID() == harvester.getSelectedHarvestResource().getId()) { + buffer.put((byte)2); + buffer.putShort((short) i); + buffer.putLong(cont.getReferenceID()); + buffer.putFloat((float)cont.getStackCount()); + //System.out.println("TOTAL STACKCOUNT " + (float)cont.getStackCount()); + } + i++; + } + + buffer.putShort((short)0x0A); + buffer.putFloat((float)totalStackCount); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildHINO7ActivateDelta(HarvesterObject harvester) { + + int iHopperList = 0; + if (harvester.getOutputHopperContent().size() >= 1) { + iHopperList = 1; + } + int factor = 0; + Vector outputHopper = harvester.getOutputHopperContent(); + for (ResourceContainerObject cont : outputHopper){ + if (cont.getReferenceID() == harvester.getSelectedHarvestResource().getId()) { + factor = 1; + } + } + + byte iHopperUpdateCounter = harvester.getResourceUpdateCount(); + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + buffer.putInt(5+19+(15*factor)); + buffer.putShort((short)5); + buffer.putShort((short)6); + buffer.put((byte)1); + // 2 + 4 + 4 + 2 + 4 + (15*h) = 16 + 2 + 1 = 19 + buffer.putShort((short)0x0C); + buffer.put(harvester.getUpdateCount()); + buffer.putShort((short)0x0D); + buffer.putInt(iHopperList); + buffer.putInt(iHopperUpdateCounter); + int totalStackCount = 0; + + int i = 0; + + for (ResourceContainerObject cont : outputHopper){ + totalStackCount += cont.getStackCount(); + if (cont.getReferenceID() == harvester.getSelectedHarvestResource().getId()) { + buffer.put((byte)2); + buffer.putShort((short) i); + buffer.putLong(cont.getReferenceID()); + buffer.putFloat((float)cont.getStackCount()); + } + i++; + } + + buffer.putShort((short)0x0A); + buffer.putFloat((float)totalStackCount); + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + public IoBuffer buildHINO7ActivateDelta2(HarvesterObject harvester) { + + int iHopperList = 0; + if (harvester.getOutputHopperContent().size() >= 1) { + iHopperList = 1; + } + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + + buffer.putInt(11); + buffer.putShort((short)2); + buffer.putShort((short)6); + buffer.put((byte)1); + buffer.putShort((short)9); + buffer.putFloat(harvester.getActualExtractionRate()); + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } +// +// 02 00 06 00 01 09 00 43 94 IH............C. +// 0020: 59 42 YB + + public IoBuffer buildHINO7ActivateDelta2old(HarvesterObject harvester) { + + int iHopperList = 0; + if (harvester.getOutputHopperContent().size() >= 1) { + iHopperList = 1; + } + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + + buffer.putInt(5); + buffer.putShort((short)5); + buffer.putShort((short)6); + buffer.put((byte)1); + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildHINO7DeactivateDelta(HarvesterObject harvester) { + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + + buffer.putInt(14); + buffer.putShort((short)5); + buffer.putShort((short)6); + buffer.put((byte)0); + buffer.putShort((short)9); + buffer.putFloat(0); + buffer.putShort((short)0xC); + buffer.put((byte)5); + + // new +// buffer.putShort((short)6); +// buffer.put((byte)0); +// buffer.putShort((short)9); +// buffer.put((byte)0); +// buffer.putShort((short)0xC); +// buffer.put((byte)5); + + // + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + public IoBuffer buildHINO7DeactivateDeltaold(HarvesterObject harvester) { + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + + buffer.putInt(5); + buffer.putShort((short)5); + buffer.putShort((short)6); + buffer.put((byte)0); + + // new + buffer.putShort((short)6); + buffer.put((byte)0); + buffer.putShort((short)9); + buffer.put((byte)0); + buffer.putShort((short)0xC); + buffer.put((byte)5); + + // + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildHINO7ClearDelta(HarvesterObject harvester) { + + int iHopperList = 0; + if (harvester.getOutputHopperContent().size() >= 1) { + iHopperList = 1; + } + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x48494E4F); + buffer.put((byte)7); + + buffer.putInt(36); + buffer.putShort((short)3); + buffer.putShort((short)0x0C); + buffer.put(harvester.getUpdateCount()); + buffer.putShort((short)0x0D); + buffer.putInt(iHopperList); + buffer.putInt(harvester.getResourceUpdateCount()); + buffer.put((byte)4); + buffer.putShort((short)0x0A); + buffer.putFloat((float)0.0F); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + public IoBuffer buildDiscardResourceResponse(HarvesterObject harvester, byte actionMode, byte actionCounter,CreatureObject owner) { + + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x80CE5E46); + buffer.putInt(0x0B); + buffer.putInt(0xEE); + buffer.putLong(owner.getObjectID()); + buffer.putInt(0); + buffer.putInt(0xED); + buffer.put((byte)1); + buffer.put(actionCounter); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + +//0000: 05 00 46 5E CE 80 0B 00 00 00 EE 00 00 00 62 5F ..F^..........b_ +//0010: 02 15 00 00 01 00 00 00 00 00 ED 00 00 00 01 01 ................ +// ^^ weird but works, should be zero allowed too + + public IoBuffer buildBaseline8() { + IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 0); + int size = buffer.position(); + buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size); + buffer.flip(); + buffer = createBaseline("TANO", (byte) 8, buffer, size); + + return buffer; + } + + public IoBuffer buildBaseline9() { + IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 0); + int size = buffer.position(); + buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size); + buffer.flip(); + buffer = createBaseline("TANO", (byte) 9, buffer, size); + + return buffer; + } + + + public IoBuffer buildHINOBaseline7(HarvesterObject harvester,Vector vSRD) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + int sizeP = 74; + + buffer.putShort((short)5); + buffer.putInt(0x68A75F0C); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x4F4E4948); + buffer.put((byte)7); + + int iResourceCount = vSRD.size(); + Vector outputHopperContent = harvester.getOutputHopperContent(); + int hopperContentSize = outputHopperContent.size(); + float outputHopperCount = 0; + + //y = a + 4x + 16x + 12z = a + 20x + 12z + sizeP += (iResourceCount * 4); + sizeP += (iResourceCount * 16); + + sizeP += (hopperContentSize * 12); + + for (int i = 0; i < iResourceCount; i++) { + sizeP += vSRD.get(i).getName().length(); + sizeP += vSRD.get(i).getFileName().length(); + } + + buffer.putInt(sizeP); + + for (ResourceContainerObject container : outputHopperContent){ + outputHopperCount += container.getStackCount(); + } + + buffer.putShort((short)0x0F); + buffer.put((byte)1); + buffer.putInt(iResourceCount); + buffer.putInt(iResourceCount); + + for (int i = 0; i < iResourceCount; i++) { + buffer.putLong(vSRD.get(i).getId()); + } + buffer.putInt(iResourceCount); + + buffer.putInt(iResourceCount); + + for (int i = 0; i < iResourceCount; i++) { + buffer.putLong(vSRD.get(i).getId()); + } + + buffer.putInt(iResourceCount); + + buffer.putInt(iResourceCount); + + for (int i = 0; i < iResourceCount; i++) { + buffer.put(getAsciiString(vSRD.get(i).getName())); + } + + buffer.putInt(iResourceCount); + buffer.putInt(iResourceCount); + for (int i = 0; i < iResourceCount; i++) { + buffer.put(getAsciiString(vSRD.get(i).getFileName())); + + } + + if (harvester.getSelectedHarvestResource() != null) { + buffer.putLong(harvester.getSelectedHarvestResource().getId()); + } else { + buffer.putLong(0); + } + + buffer.put(harvester.isActivated() ? (byte)1 : (byte)0); + + buffer.putInt(harvester.getSpecRate()); // SPEC RATE buffer.putInt(harvester.getBER()); + + buffer.putFloat(harvester.getBER()); + + buffer.putFloat(harvester.getActualExtractionRate()); + buffer.putFloat(outputHopperCount); + buffer.putInt(harvester.getOutputHopperCapacity()); + buffer.put(harvester.getUpdateCount()); + buffer.putInt(hopperContentSize); + buffer.putInt(0); + for (ResourceContainerObject container : outputHopperContent){ + buffer.putLong(container.getReferenceID()); + buffer.putFloat(container.getStackCount()); + } + buffer.put(harvester.getStructuralCondition()); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildCustomNameDelta(HarvesterObject harvester, String customName) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + int sizeP = 8; + sizeP += 2*customName.length(); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(harvester.getObjectID()); + buffer.putInt(0x54414E4F); + buffer.put((byte)3); + buffer.putInt(sizeP); + buffer.putShort((short)1); + buffer.putShort((short)2); + buffer.put(getUnicodeString(customName)); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildPermissionListCreate(HarvesterObject harvester, Vector permissionList, String listName) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + int listSize = permissionList.size(); + buffer.putShort((short)4); + buffer.putInt(0x52F364B8); + buffer.putInt(listSize); + for (String name : permissionList){ + buffer.put(getUnicodeString(name)); + } + //buffer.putInt(0x61); + buffer.putInt(0); + //buffer.putShort((short)0); + buffer.put(getUnicodeString(listName)); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + /* + 0000: 04 00 B8 64 F3 52 01 00 00 00 06 00 00 00 63 00 ...d.R........c. + 0010: 68 00 61 00 72 00 6F 00 6E 00 00 00 00 00 05 00 h.a.r.o.n....... + 0020: 00 00 41 00 44 00 4D 00 49 00 4E 00 ..A.D.M.I.N. + */ + + // Send this in response to the Radial Menu to manage harvesters, + // it is necessary to send this *before* the 07 Baseline! + //ResourceHarvesterActivatePageMessage (BD18C679) + public IoBuffer buildResourceHarvesterActivatePageMessage(HarvesterObject harvester) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)2); + buffer.putInt(0xBD18C679); + buffer.putLong(harvester.getObjectID()); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildHarvesterGetResourceData(HarvesterObject harvester,SWGObject owner,Vector planetResources) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x80CE5E46); + buffer.putInt(0x0B); + buffer.putInt(0x000000EA); + buffer.putLong(owner.getObjectID()); + buffer.putInt(0); + buffer.putLong(harvester.getObjectID()); + if (planetResources == null || planetResources.isEmpty()) { + buffer.putInt(0); + } else { + buffer.putInt(planetResources.size()); + for (int i = 0; i < planetResources.size(); i++) { + float localConcentration = planetResources.get(i).deliverConcentrationForSurvey(owner.getPlanetId(), owner.getPosition().x, owner.getPosition().z); + buffer.putLong(planetResources.get(i).getId()); + buffer.put(getAsciiString(planetResources.get(i).getName())); + buffer.put(getAsciiString(planetResources.get(i).getFileName())); + buffer.put((byte)localConcentration); + } + } + + int size = buffer.position(); + buffer.flip(); + 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 + + } + + @Override + public void sendBaselines() { + + } } diff --git a/src/resources/objects/harvester/HarvesterObject.java b/src/resources/objects/harvester/HarvesterObject.java index b31b40cf..7fe12cbb 100644 --- a/src/resources/objects/harvester/HarvesterObject.java +++ b/src/resources/objects/harvester/HarvesterObject.java @@ -21,11 +21,405 @@ ******************************************************************************/ package resources.objects.harvester; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Vector; + +import main.NGECore; +import protocol.swg.SceneCreateObjectByCrc; +import protocol.swg.SceneDestroyObject; +import protocol.swg.SceneEndBaselines; +import protocol.swg.UpdatePVPStatusMessage; + import com.sleepycat.persist.model.Persistent; +import services.chat.WaypointAttachment; +import engine.clients.Client; +import engine.resources.common.CRC; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; +import resources.objects.creature.CreatureObject; +import resources.objects.installation.InstallationMessageBuilder; import resources.objects.installation.InstallationObject; +import resources.objects.player.PlayerObject; +import resources.objects.resource.GalacticResource; +import resources.objects.resource.ResourceContainerObject; +import resources.objects.waypoint.WaypointObject; +import services.chat.Mail; + + +/** + * @author Charon + */ @Persistent(version=0) public class HarvesterObject extends InstallationObject { + + private HarvesterMessageBuilder messageBuilder; + private InstallationMessageBuilder installationMessageBuilder; + + public final static byte HARVESTER_TYPE_MINERAL = 0; + public final static byte HARVESTER_TYPE_CHEMICAL = 1; + public final static byte HARVESTER_TYPE_FLORA = 2; + public final static byte HARVESTER_TYPE_GAS = 3; + public final static byte HARVESTER_TYPE_WATER = 4; + public final static byte HARVESTER_TYPE_SOLAR = 5; + public final static byte HARVESTER_TYPE_WIND = 6; + public final static byte HARVESTER_TYPE_FUSION = 7; + public final static byte HARVESTER_TYPE_GEO = 8; + + public String[] mineral_type_iff = new String[]{"object/installation/mining_ore/shared_mining_ore_harvester_style_1.iff", + "object/installation/mining_ore/shared_mining_ore_harvester_style_2.iff", + "object/installation/mining_ore/shared_mining_ore_harvester_heavy.iff", + "object/installation/mining_ore/shared_mining_ore_harvester_elite.iff"}; + + public String[] chemical_type_iff = new String[]{"object/installation/mining_liquid/shared_mining_liquid_harvester_style_1.iff", + "object/installation/mining_liquid/shared_mining_liquid_harvester_style_2.iff", + "object/installation/mining_liquid/shared_mining_liquid_harvester_style_3.iff", + "object/installation/mining_liquid/shared_mining_liquid_harvester_style_4.iff"}; + + public String[] flora_type_iff = new String[]{"object/installation/mining_organic/shared_mining_organic_flora_farm.iff", + "object/installation/mining_organic/shared_mining_organic_flora_farm_medium.iff", + "object/installation/mining_organic/shared_mining_organic_flora_farm_heavy.iff", + "object/installation/mining_organic/shared_mining_organic_flora_farm_elite.iff"}; + + public String[] water_type_iff = new String[]{"object/installation/mining_liquid/shared_mining_liquid_moisture_harvester.iff", + "object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_medium.iff", + "object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_heavy.iff", + "object/installation/mining_liquid/shared_mining_liquid_moisture_harvester_elite.iff"}; + + public String[] gas_type_iff = new String[]{"object/installation/mining_gas/shared_mining_gas_harvester_style_1.iff", + "object/installation/mining_gas/shared_mining_gas_harvester_style_2.iff", + "object/installation/mining_gas/shared_mining_gas_harvester_style_3.iff", + "object/installation/mining_gas/shared_mining_gas_harvester_style_4.iff"}; + + public String[] wind_type_iff = new String[]{"object/installation/generators/shared_power_generator_wind_style_1.iff"}; + + public String[] solar_type_iff = new String[]{"object/installation/generators/shared_power_generator_solar_style_1.iff"}; + + public String[] fusion_type_iff = new String[]{"object/installation/generators/shared_power_generator_fusion_style_1.iff"}; + + public String[] geo_type_iff = new String[]{"object/installation/generators/shared_power_generator_geothermal_style_1.iff"}; + //for nothing "object/installation/generators/shared_power_generator_photo_bio_style_1.iff" + + + public byte harvester_type = 0; + public byte harvester_size = 0; + private Vector outputHopperContent = new Vector(); + private int outputHopperCapacity = 0; + private int BER = 0; + private float maintenanceAmount = 0; + private float powerLevel = 0; + private int powerCost = 0; + private int maintenanceCost = 0; + private byte structuralCondition = 100; + private boolean activated = false; + private boolean generator = false; + private GalacticResource selectedHarvestResource; + private float selectedResourceConcentration; + private byte updateCount; + private byte resourceUpdateCount; + private Vector adminList = new Vector(); + private Vector hopperList = new Vector(); + private long owner; + private float currentHarvestedCountFloat=0.0F; + private String deedTemplate; + + private int specRate; + + + public HarvesterObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ + super(objectID, planet, template, position, orientation); + this.setConditionDamage(100); + messageBuilder = new HarvesterMessageBuilder(this); + installationMessageBuilder = new InstallationMessageBuilder((InstallationObject)this); + } + + public int getBER() { + return BER; + } + + + public void setBER(int baseExtractionRate) { + this.BER = baseExtractionRate; + } + + + public float getActualExtractionRate() { + //float resourceDraw = (getBER() * getSelectedResourceConcentration()) / 400; // /100 + float resourceDraw = 1.5F*(getBER() * getSelectedResourceConcentration()) / 100; + // BER * concentration * publish 27 bonus * profession buffs = AER + // 14* 0.83 * 1.5 * 1.05 = 18.3015 AER + return resourceDraw; + } + + public int getSpecRate() { + return specRate; + } + + public void setSpecRate(int specRate) { + this.specRate = specRate; + } + + + public GalacticResource getSelectedHarvestResource() { + return selectedHarvestResource; + } + + + public void setSelectedHarvestResource(GalacticResource selectedHarvestResource,CreatureObject owner) { + this.selectedHarvestResource = selectedHarvestResource; + setSelectedResourceConcentration(selectedHarvestResource.deliverConcentrationForSurvey(this.getPlanetId(), this.getPosition().x, this.getPosition().z)); + + owner.getClient().getSession().write(installationMessageBuilder.constructINSO7Var1((InstallationObject) this,selectedHarvestResource.getObjectId())); + owner.getClient().getSession().write(installationMessageBuilder.constructINSO7Var2((InstallationObject) this,selectedHarvestResource.getObjectId())); + } + + + public float getSelectedResourceConcentration() { + return selectedResourceConcentration; + } + + + private void setSelectedResourceConcentration(float selectedResourceConcentration) { + this.selectedResourceConcentration = selectedResourceConcentration; + } + + + public void activateHarvester(CreatureObject owner){ + activated = true; + this.setOwner(owner.getObjectID()); + owner.getClient().getSession().write(messageBuilder.buildHINO3Delta(this,(byte)1)); + owner.getClient().getSession().write(messageBuilder.buildHINO7ActivateDelta2(this)); + } + + + public void deactivateHarvester(CreatureObject owner){ + activated = false; + owner.getClient().getSession().write(messageBuilder.buildHINO3Delta2(this,(byte)0)); + owner.getClient().getSession().write(messageBuilder.buildHINO7DeactivateDelta(this)); + } + + + public boolean isActivated(){ + return this.activated; + } + + + public byte getHarvester_type() { + return harvester_type; + } + + + public void setHarvester_type(byte harvester_type) { + this.harvester_type = harvester_type; + } + + + public Vector getOutputHopperContent() { + return outputHopperContent; + } + + + public void setOutputHopperContent(Vector outputHopperContent) { + this.outputHopperContent = outputHopperContent; + } + + + public byte getStructuralCondition() { + return structuralCondition; + } + + + public void setStructuralCondition(byte structuralCondition) { + this.structuralCondition = structuralCondition; + } + + + public int getOutputHopperCapacity() { + return outputHopperCapacity; + } + + + public void setOutputHopperCapacity(int outputHopperCapacity) { + this.outputHopperCapacity = outputHopperCapacity; + } + + + public byte getUpdateCount() { + if (updateCount>254) updateCount = 0; + return updateCount++; + } + + public byte getResourceUpdateCount() { + if (resourceUpdateCount>254) resourceUpdateCount = 0; + return resourceUpdateCount++; + } + + + public void setUpdateCount(byte updateCount) { + this.updateCount = updateCount; + } + + + public Vector getAdminList() { + return adminList; + } + + + public void setAdminList(Vector adminList) { + this.adminList = adminList; + } + + + public Vector getHopperList() { + return hopperList; + } + + + public void setHopperList(Vector hopperList) { + this.hopperList = hopperList; + } + + + public float getPowerLevel() { + return powerLevel; + } + + + public void setPowerLevel(float energyLevel) { + this.powerLevel = energyLevel; + } + + + public float getMaintenanceAmount() { + return maintenanceAmount; + } + + + public void setMaintenanceAmount(float maintenanceAmount) { + this.maintenanceAmount = maintenanceAmount; + } + + public int getPowerCost() { + return powerCost; + } + + + public void setPowerCost(int powerCost) { + this.powerCost = powerCost; + } + + + public int getMaintenanceCost() { + return maintenanceCost; + } + + + public void setMaintenanceCost(int maintenanceCost) { + this.maintenanceCost = maintenanceCost; + } + + + public float getCurrentHarvestedCountFloat() { + return currentHarvestedCountFloat; + } + + + public void setCurrentHarvestedCountFloat(float currentHarvestedCountFloat) { + this.currentHarvestedCountFloat = currentHarvestedCountFloat; + } + + + public long getOwner() { + return owner; + } + + + public void setOwner(long owner) { + this.owner = owner; + } + + public void setDeedTemplate(String deedTemplate){ + this.deedTemplate = deedTemplate; + } + + public String getDeedTemplate(){ + return this.deedTemplate; + } + + + public boolean isGenerator() { + return generator; + } + + public void setGenerator(boolean generator) { + this.generator = generator; + } + + + public void setHarvesterName(String name,CreatureObject owner){ + owner.getClient().getSession().write(messageBuilder.buildCustomNameDelta(this,name)); + this.setCustomName(name); + ((CreatureObject)owner).sendSystemMessage("Structure renamed.", (byte) 0); + } + + public void setPermissionAdmin(String name,CreatureObject owner){ + Vector permissionList = this.getAdminList(); + owner.getClient().getSession().write(messageBuilder.buildPermissionListCreate(this, permissionList, name)); + } + + public void setPermissionHopper(String name,CreatureObject owner){ + Vector permissionList = this.getAdminList(); + owner.getClient().getSession().write(messageBuilder.buildPermissionListCreate(this, permissionList, name)); + } + + public void operateMachinery(CreatureObject owner){ + owner.getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this)); + // Assemble resources at that spot + // For later, it might be needed to also pass the template to differentiate liquid resources + Vector planetResourcesVector = NGECore.getInstance().resourceService.getSpawnedResourcesByPlanetAndHarvesterType(this.getPlanetId(),this.getHarvester_type()); + owner.getClient().getSession().write(messageBuilder.buildHarvesterGetResourceData(this, owner, planetResourcesVector)); + owner.getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector)); + } + + public void deActivate(){ + NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this)); + } + + public void placeHarvester(){ + NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this)); + } + + public void createNewHopperContainer(){ + Vector planetResourcesVector = NGECore.getInstance().resourceService.getSpawnedResourcesByPlanetAndHarvesterType(this.getPlanetId(),this.getHarvester_type()); + NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector)); + NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHINO7Delta(this,(byte)1)); + } + + public void continueHopperContainer(){ + Vector planetResourcesVector = NGECore.getInstance().resourceService.getSpawnedResourcesByPlanetAndHarvesterType(this.getPlanetId(),this.getHarvester_type()); + NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHarvesterGetResourceData(this, NGECore.getInstance().objectService.getObject(owner), planetResourcesVector)); + NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector)); + } + + @Override + public void sendBaselines(Client destination) { + + + if(destination == null || destination.getSession() == null) { + System.out.println("NULL destination"); + return; + } + + destination.getSession().write(installationMessageBuilder.buildBaseline3(this)); + //destination.getSession().write(installationMessageBuilder.buildBaseline6(this)); + //destination.getSession().write(installationMessageBuilder.buildBaseline8()); + //destination.getSession().write(installationMessageBuilder.buildBaseline9()); + + } } diff --git a/src/resources/objects/installation/InstallationMessageBuilder.java b/src/resources/objects/installation/InstallationMessageBuilder.java index f7902d4e..f9fe356d 100644 --- a/src/resources/objects/installation/InstallationMessageBuilder.java +++ b/src/resources/objects/installation/InstallationMessageBuilder.java @@ -21,6 +21,205 @@ ******************************************************************************/ package resources.objects.installation; -public class InstallationMessageBuilder { +import java.nio.ByteOrder; +import org.apache.mina.core.buffer.IoBuffer; +import resources.objects.ObjectMessageBuilder; +import resources.objects.harvester.HarvesterObject; +/** + * @author Charon + */ + +public class InstallationMessageBuilder extends ObjectMessageBuilder{ + + public InstallationMessageBuilder(InstallationObject installationObject) { + setObject(installationObject); + } + + public IoBuffer buildBaseline3(InstallationObject installationObject) { + IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + int packSize = 66; + packSize += installationObject.getStfName().length(); + packSize += installationObject.getStfFilename().length(); + + buffer.putShort((short)5); + buffer.putInt(0x68A75F0C); + buffer.putLong(installationObject.getObjectID()); + buffer.putInt(0x494E534F); + buffer.put((byte)3); + buffer.putInt(packSize); + buffer.putShort((short) 0x05); + buffer.putFloat(installationObject.getComplexity()); + buffer.put(getAsciiString(installationObject.getStfFilename())); // installation_n + buffer.putInt(0); + buffer.put(getAsciiString(installationObject.getStfName())); + buffer.put(getUnicodeString(""));//buffer.put(getUnicodeString(installationObject.getCustomName())); + buffer.putInt(1);// int 1 // oper 3 + buffer.putShort((short)0); + + buffer.putInt(0); + buffer.putInt(0); + buffer.putLong(0); + + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.putInt(0); + buffer.put((byte)1); + buffer.put((byte)0); + buffer.putFloat(0.0F); + buffer.putFloat(0.0F); + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + +// 0000: 05 00 0C 5F A7 68 82 EC 7D 16 00 00 02 00 4F 53 ..._.h..}.....OS +// 0010: 4E 49 06 0E 00 00 00 05 00 76 00 00 00 00 00 00 NI.......v...... +// 0020: 00 01 00 00 00 ..... + + public IoBuffer buildBaseline6(InstallationObject installationObject) { + IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + int packSize = 14; + buffer.putShort((short)5); + buffer.putInt(0x68A75F0C); + buffer.putLong(installationObject.getObjectID()); + buffer.putInt(0x494E534F); + buffer.put((byte)6); + buffer.putInt(packSize); + buffer.putShort((short)5); + buffer.putInt(0x76); + buffer.putInt(0); + buffer.putInt(1); + + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + + public IoBuffer buildBaseline7() { + IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 0); + int size = buffer.position(); + buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size); + buffer.flip(); + buffer = createBaseline("INSO", (byte) 7, buffer, size); + + return buffer; + } + + public IoBuffer buildBaseline8() { + IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 0); + int size = buffer.position(); + buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size); + buffer.flip(); + buffer = createBaseline("INSO", (byte) 8, buffer, size); + + return buffer; + } + + public IoBuffer buildBaseline9() { + IoBuffer buffer = bufferPool.allocate(2, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 0); + int size = buffer.position(); + buffer = IoBuffer.allocate(size).put(buffer.array(), 0, size); + buffer.flip(); + buffer = createBaseline("INSO", (byte) 9, buffer, size); + + return buffer; + } + + public IoBuffer buildDelta3(InstallationObject installationObject,IoBuffer packet,int packSize) { + IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(installationObject.getObjectID()); + buffer.putInt(0x494E534F); + buffer.put((byte)3); + buffer.putInt(packSize); + buffer.put(packet); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer buildDelta7(InstallationObject installationObject,IoBuffer packet,int packSize) { + IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)5); + buffer.putInt(0x12862153); + buffer.putLong(installationObject.getObjectID()); + buffer.putInt(0x494E534F); + buffer.put((byte)7); + buffer.putInt(packSize); + buffer.put(packet); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } + + public IoBuffer constructINSO7Var1(InstallationObject installationObject,long selectedResource) { + IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN); + int hopperContentsSize = ((HarvesterObject)installationObject).getOutputHopperContent().size()+1; + byte updateCounter = ((HarvesterObject)installationObject).getUpdateCount(); + + buffer.setAutoExpand(true); + buffer.putShort((short)2); // buffer.putShort((short)updateCounter); + buffer.putShort((short)0xC); + buffer.put((byte)1); + buffer.putShort((short)0xD); + + buffer.putInt(1);//buffer.putInt(hopperContentsSize); // works once with 1! HopperContentsSize->Number of resources in hopper + buffer.putInt(2); // UpdateCounter works once with 2! + buffer.put((byte)1); // subtype : ADD + buffer.putShort((short)0); // index was 0 buffer.putShort((short)(hopperContentsSize-1)); + buffer.putLong(selectedResource); + buffer.putFloat(0); + int size = buffer.position(); + buffer.flip(); + return buildDelta7(installationObject,IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(),size); + } + +// 0000: 05 00 53 21 86 12 82 EC 7D 16 00 00 02 00 4F 53 ..S!....}.....OS +// 0010: 4E 49 07 1E 00 00 00 02 00 0C 00 01 0D 00 01 00 NI.............. +// 0020: 00 00 02 00 00 00 01 00 00 8A D3 79 16 00 00 0F ...........y.... +// 0030: 00 00 00 00 00 ..... + + public IoBuffer constructINSO7Var2(InstallationObject installationObject,long selectedResource) { + IoBuffer buffer = bufferPool.allocate(10, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short)2); + buffer.putShort((short)0x9); + buffer.putFloat(0); + buffer.putShort((short)0x5); + buffer.putLong(selectedResource); + int size = buffer.position(); + buffer.flip(); + return buildDelta7(installationObject,IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(),size); + } + +// 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 + + } + + @Override + public void sendBaselines() { + + } } diff --git a/src/resources/objects/installation/InstallationObject.java b/src/resources/objects/installation/InstallationObject.java index 728de4a9..856eeb59 100644 --- a/src/resources/objects/installation/InstallationObject.java +++ b/src/resources/objects/installation/InstallationObject.java @@ -21,11 +21,24 @@ ******************************************************************************/ package resources.objects.installation; +import com.sleepycat.persist.model.Entity; 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; import resources.objects.tangible.TangibleObject; -@Persistent(version=0) +@Entity(version=0) public class InstallationObject extends TangibleObject { - -} + + public InstallationObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ + super(objectID, planet, template, position, orientation); + } + + @Override + public void sendBaselines(Client destination) { + + } +} \ No newline at end of file diff --git a/src/resources/objects/loot/LootDrop.java b/src/resources/objects/loot/LootDrop.java new file mode 100644 index 00000000..371c1727 --- /dev/null +++ b/src/resources/objects/loot/LootDrop.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.objects.loot; + +import java.util.ArrayList; +import java.util.List; + +public class LootDrop { + + private List elements = new ArrayList(); + private String droppedItemTemplate; + + public LootDrop(){ + + } + + public void addElement(String element){ + elements.add(element); + } + + public List getElements(){ + return elements; + } + + public String getDroppedItemTemplate() { + return droppedItemTemplate; + } + + public void setDroppedItemTemplate(String droppedItemTemplate) { + this.droppedItemTemplate = droppedItemTemplate; + } +} diff --git a/src/resources/objects/loot/LootGroup.java b/src/resources/objects/loot/LootGroup.java new file mode 100644 index 00000000..e349eaac --- /dev/null +++ b/src/resources/objects/loot/LootGroup.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * 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.loot; + +import com.sleepycat.persist.model.Persistent; + +/** + * @author Charon + */ + +@Persistent(version=0) +public class LootGroup { + + private String[] lootPoolNames; + private int[] lootPoolChances; + private int lootGroupChance; + + public LootGroup(){ + + } + + public LootGroup(String[] lootPoolNames, int[] lootPoolChances, int lootGroupChance){ + this.lootPoolNames = lootPoolNames; + this.lootPoolChances = lootPoolChances; + this.lootGroupChance = lootGroupChance; + } + + public void addLootData(String[] lootPoolNames, int[] lootPoolChances, int lootGroupChance){ + this.lootPoolNames = lootPoolNames; + this.lootPoolChances = lootPoolChances; + this.lootGroupChance = lootGroupChance; + } + + public String[] getLootPoolNames() { + return lootPoolNames; + } + + public int[] getLootPoolChances() { + return lootPoolChances; + } + + public int getLootGroupChance() { + return lootGroupChance; + } +} diff --git a/src/resources/objects/loot/LootPool.java b/src/resources/objects/loot/LootPool.java new file mode 100644 index 00000000..2e74cf8b --- /dev/null +++ b/src/resources/objects/loot/LootPool.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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.loot; + +/** + * @author Charon + */ + +public class LootPool { + + public LootPool(){ + + } +} diff --git a/src/resources/objects/loot/LootRollSession.java b/src/resources/objects/loot/LootRollSession.java new file mode 100644 index 00000000..59e06267 --- /dev/null +++ b/src/resources/objects/loot/LootRollSession.java @@ -0,0 +1,153 @@ +/******************************************************************************* + * 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.loot; + +import java.util.ArrayList; +import java.util.List; + +import engine.resources.scene.Planet; +import main.NGECore; +import resources.objects.creature.CreatureObject; +import resources.objects.group.GroupObject; +import resources.objects.tangible.TangibleObject; + +/** + * @author Charon + */ + +public class LootRollSession { + + private String SessionID; // leaderName-SystemTime + private boolean sessionValid; + private GroupObject playerGroup; + private List droppedItems; + private Planet sessionPlanet; + private List errorMessages; + private int sessionLootMode; + private boolean allowRareLoot; + private boolean increasedRLSChance; + + public LootRollSession(){ + } + + public LootRollSession(CreatureObject requester, TangibleObject lootedObject){ + long requesterGroupId = requester.getGroupId(); + if (requesterGroupId>0){ + this.playerGroup = (GroupObject) NGECore.getInstance().objectService.getObject(requesterGroupId); + this.SessionID = playerGroup.getGroupLeader().getCustomName()+"-"+System.currentTimeMillis(); + + } else { + this.SessionID = requester.getCustomName()+"-"+System.currentTimeMillis(); + } + + if (lootedObject instanceof CreatureObject){ + CreatureObject lootedCreature = (CreatureObject)lootedObject; + // Exclude rare loot depending on creature level + // For groups maybe average CL? + if (requester.getLevel()-lootedCreature.getLevel()<=6){ + this.setAllowRareLoot(true); + } + } + + // Group situation + if (this.getPlayerGroup()!=null){ + if (this.getPlayerGroup().getMemberList().size()>=4) + this.setIncreasedRLSChance(true); + } + + // Possible AFKer check here + + + droppedItems = new ArrayList(); + errorMessages = new ArrayList(); + sessionPlanet = requester.getPlanet(); + allowRareLoot = false; + } + + public List getDroppedItems() { + return droppedItems; + } + + public void addDroppedItem(TangibleObject droppedItem) { + this.droppedItems.add(droppedItem); + } + + public String getSessionID() { + return SessionID; + } + + public void setSessionID(String sessionID) { + SessionID = sessionID; + } + + public void generateSessionID(String sessionID) { + SessionID = sessionID; + } + + public Planet getSessionPlanet() { + return sessionPlanet; + } + + public List getErrorMessages() { + return errorMessages; + } + + public void addErrorMessage(String errorMessage) { + this.errorMessages.add(errorMessage); + } + + public int getSessionLootMode() { + return sessionLootMode; + } + + public void setSessionLootMode(int sessionLootMode) { + this.sessionLootMode = sessionLootMode; + } + + public boolean isAllowRareLoot() { + return allowRareLoot; + } + + public void setAllowRareLoot(boolean allowRareLoot) { + this.allowRareLoot = allowRareLoot; + } + + public GroupObject getPlayerGroup() { + return playerGroup; + } + + public boolean isIncreasedRLSChance() { + return increasedRLSChance; + } + + public void setIncreasedRLSChance(boolean increasedRLSChance) { + this.increasedRLSChance = increasedRLSChance; + } + + public boolean isSessionValid() { + return sessionValid; + } + + public void setSessionValid(boolean sessionValid) { + this.sessionValid = sessionValid; + } +} diff --git a/src/resources/objects/resource/ResourceContainerObject.java b/src/resources/objects/resource/ResourceContainerObject.java index b2a0eada..c5b84a9f 100644 --- a/src/resources/objects/resource/ResourceContainerObject.java +++ b/src/resources/objects/resource/ResourceContainerObject.java @@ -47,7 +47,7 @@ public class ResourceContainerObject extends TangibleObject { private CreatureObject proprietor; private String resourceType; - private String resourceClass; + private String resourceClass=""; private String resourceName; private byte generalType; private long referenceID; @@ -148,7 +148,7 @@ public class ResourceContainerObject extends TangibleObject { public void initializeStats(GalacticResource resource){ this.setResourceName(resource.getName()); - this.setResourceClass(resource.getResourceClass()); + this.setResourceClass(resource.getCategory()); this.setColdResistance(resource.getResourceStats()[0]); this.setConductivity(resource.getResourceStats()[1]); this.setDecayResistance(resource.getResourceStats()[2]); diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index cef963ff..de1b586b 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -40,6 +40,7 @@ import protocol.swg.objectControllerObjects.ShowFlyText; import resources.common.OutOfBand; import resources.common.RGB; import resources.objects.creature.CreatureObject; +import resources.objects.loot.LootGroup; import resources.visitors.IDManagerVisitor; import com.sleepycat.persist.model.NotPersistent; @@ -52,7 +53,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=1) +@Persistent(version=5) public class TangibleObject extends SWGObject { // TODO: Thread safety @@ -75,6 +76,12 @@ public class TangibleObject extends SWGObject { private int respawnTime = 0; private Point3D spawnCoordinates = new Point3D(0, 0, 0); + //private TreeSet> lootSpecification = new TreeSet>(); + private List lootGroups = new ArrayList(); + + private boolean looted = false; + private boolean lootLock = false; + @NotPersistent private TangibleObject killer = null; @@ -369,7 +376,8 @@ public class TangibleObject extends SWGObject { return getPvPBitmask() == 1 || getPvPBitmask() == 2; - } + } else if(attacker.getSlottedObject("ghost") == null) + return true; return getPvPBitmask() == 1 || getPvPBitmask() == 2; } @@ -436,6 +444,33 @@ public class TangibleObject extends SWGObject { } } + public List getLootGroups() { + return lootGroups; + } + + public void addToLootGroups(String[] lootPoolNames, int[] lootPoolChances, int lootGroupChance) { + System.out.println("lootPoolNames[0] " + lootPoolNames[0]); + LootGroup lootGroup = new LootGroup(lootPoolNames, lootPoolChances, lootGroupChance); + this.lootGroups.add(lootGroup); + } + + public boolean isLooted() { + return looted; + } + + public void setLooted(boolean looted) { + this.looted = looted; + } + + public boolean isLootLock() { + return lootLock; + } + + public void setLootLock(boolean lootLock) { + this.lootLock = lootLock; + } + + @Override public void sendBaselines(Client destination) { @@ -459,5 +494,5 @@ public class TangibleObject extends SWGObject { } - + } diff --git a/src/services/CharacterService.java b/src/services/CharacterService.java index ec394752..9a00b424 100644 --- a/src/services/CharacterService.java +++ b/src/services/CharacterService.java @@ -542,6 +542,59 @@ public class CharacterService implements INetworkDispatch { return false; } + /** + * Checks the database if a player with the given first name exists + * and returns the objectID of that player. + * @param name : String + * @return objectID : long + */ + public long getPlayerOID(String name) { + if (!name.equals("")) { + long oid = 0L; + try { + PreparedStatement ps = databaseConnection.preparedStatement("SELECT * FROM characters WHERE \"firstName\"=?"); + ps.setString(1, name); + ResultSet resultSet = ps.executeQuery(); + while (resultSet.next()) { + oid = resultSet.getLong("id"); + } + return oid; + } + + catch (SQLException e) { e.printStackTrace(); } + } + return 0L; + } + + /** + * Delivers the first name of a player + * @param oid : long + * @return firstName : String + */ + public String getPlayerFirstName(long oid) { + + String name = ""; + try { + PreparedStatement ps = databaseConnection.preparedStatement("SELECT * FROM characters WHERE \"id\"=?"); + ps.setLong(1, oid); + ResultSet resultSet = ps.executeQuery(); + while (resultSet.next()) { + name = resultSet.getString("firstName"); + if (!name.equals("")) { + if (name.contains(" ")) { + name = name.split(" ")[0]; + } + name = name.toLowerCase(); + + } + return name; + } + + } catch (SQLException e) { e.printStackTrace(); } + + return ""; + } + /** * Checks the database for if the object ID of the player exists. * @param objectId Object ID to check for in the database diff --git a/src/services/DevService.java b/src/services/DevService.java index ef265f41..da4a5561 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -38,6 +38,8 @@ import resources.common.Opcodes; import resources.common.SpawnPoint; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; +import resources.objects.deed.Harvester_Deed; +import resources.objects.deed.Player_House_Deed; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.objects.tool.SurveyTool; @@ -84,8 +86,10 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 21, "Weapons"); suiOptions.put((long) 22, "Misc Items"); suiOptions.put((long) 23, "Jedi Items"); + suiOptions.put((long) 26, "Installations"); suiOptions.put((long) 110, "Survey Devices"); if(creature.getClient().isGM()) suiOptions.put((long) 120, "House Deeds"); + //suiOptions.put((long) 120, "House Deeds"); break; case 3: // [Items] Weapons suiOptions.put((long) 30, "Jedi Weapons"); @@ -122,6 +126,10 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 91, "(Dark) Jedi Robe"); suiOptions.put((long) 92, "Belt of Master Bodo Baas"); break; + case 10: // [Items] Jedi Items + suiOptions.put((long) 111, "Harvesters"); + suiOptions.put((long) 112, "Energy resources"); + break; } @@ -187,6 +195,9 @@ public class DevService implements INetworkDispatch { case 25: // Tools sendCharacterBuilderSUI(player, 15); return; + case 26: // Installations + sendCharacterBuilderSUI(player, 10); + return; // [Items] Weapons case 30: // Jedi Weapons @@ -992,10 +1003,206 @@ public class DevService implements INetworkDispatch { solarSurveyTool.setCustomName("Solar Survey Device"); inventory.add(solarSurveyTool); return; + case 111: + // Minerals + String templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_s1_deed.iff"; + Harvester_Deed deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(5); + deed1.setAttributes(); + inventory.add(deed1); + templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_s2_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(11); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_heavy_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(135400); + deed1.setBER(14); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_deed_elite.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(44); + deed1.setAttributes(); + inventory.add(deed1); + + + // Chemicals + templateString="object/tangible/deed/harvester_deed/shared_harvester_liquid_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(5); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_liquid_deed_medium.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(11); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_liquid_deed_heavy.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(135400); + deed1.setBER(14); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_liquid_deed_elite.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(44); + deed1.setAttributes(); + inventory.add(deed1); + + + // Flora + templateString="object/tangible/deed/harvester_deed/shared_harvester_flora_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(5); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_flora_deed_medium.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(11); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_flora_deed_heavy.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(135400); + deed1.setBER(14); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_flora_deed_elite.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(44); + deed1.setAttributes(); + inventory.add(deed1); + + + // Gas + templateString="object/tangible/deed/harvester_deed/shared_harvester_gas_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(5); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_gas_deed_medium.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(11); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_gas_deed_heavy.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(135400); + deed1.setBER(14); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_gas_deed_elite.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(44); + deed1.setAttributes(); + inventory.add(deed1); + + + // Water + templateString="object/tangible/deed/harvester_deed/shared_harvester_moisture_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(5); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_moisture_deed_medium.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(27344); + deed1.setBER(11); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_moisture_deed_heavy.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(135400); + deed1.setBER(14); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/harvester_deed/shared_harvester_moisture_deed_elite.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(44); + deed1.setAttributes(); + inventory.add(deed1); + + + // Generators + templateString="object/tangible/deed/generator_deed/shared_generator_fusion_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(19); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/generator_deed/shared_generator_wind_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(10); + deed1.setAttributes(); + inventory.add(deed1); + + templateString="object/tangible/deed/generator_deed/shared_generator_solar_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(15); + deed1.setAttributes(); + inventory.add(deed1); + +// templateString="object/tangible/deed/generator_deed/shared_generator_photo_bio_deed.iff"; +// deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); +// deed1.setOutputHopperCapacity(250000); +// deed1.setBER(19); +// inventory.add(deed1); + + templateString="object/tangible/deed/generator_deed/shared_generator_geothermal_deed.iff"; + deed1 = (Harvester_Deed)core.objectService.createObject(templateString, planet); + deed1.setOutputHopperCapacity(250000); + deed1.setBER(15); + deed1.setAttributes(); + inventory.add(deed1); + + break; + case 112: + core.resourceService.spawnSpecificResourceContainer("Radioactive", player, 100000); + break; case 120: - SWGObject houseDeed = core.objectService.createObject("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", planet); - inventory.add(houseDeed); +// SWGObject houseDeed = core.objectService.createObject("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", planet); +// inventory.add(houseDeed); + + templateString="object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff"; + Player_House_Deed deed = (Player_House_Deed)core.objectService.createObject(templateString, planet); + deed.setBMR(15); + deed.setAttributes(); + inventory.add(deed); + return; } } diff --git a/src/services/LootService.java b/src/services/LootService.java new file mode 100644 index 00000000..a0929b07 --- /dev/null +++ b/src/services/LootService.java @@ -0,0 +1,521 @@ +/******************************************************************************* + * 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 services; + +import java.io.File; +import java.io.IOException; +import java.nio.file.DirectoryStream; +import java.nio.file.DirectoryStream.Filter; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.BasicFileAttributeView; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Vector; + +import resources.objects.creature.CreatureObject; +import resources.objects.group.GroupObject; +import resources.objects.loot.LootGroup; +import resources.objects.loot.LootRollSession; +import resources.objects.tangible.TangibleObject; +import main.NGECore; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Planet; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; + +/** + * @author Charon + */ + +public class LootService implements INetworkDispatch { + + private NGECore core; + + public LootService(NGECore core) { + this.core = core; + } + + @Override + public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + + } + + @Override + public void shutdown() { + + } + + public void handleLootRequest(CreatureObject requester, TangibleObject lootedObject) { + + GroupObject group = (GroupObject) core.objectService.getObject(requester.getGroupId()); + + if (lootedObject.isLooted() || lootedObject.isLootLock() || (group == null && !lootedObject.getKiller().equals(requester)) || (group != null && !group.getMemberList().contains(lootedObject.getKiller()))) + return; + + lootedObject.setLootLock(true); + + if (requester.getCustomName().contains("Kun")){ + requester.setCashCredits(requester.getCashCredits()+1); + requester.sendSystemMessage("You looted 1 credit.", (byte)1); + lootedObject.setLooted(true); + return; + } + + LootRollSession lootRollSession = new LootRollSession(requester,lootedObject); + + handleCreditDrop(requester,lootedObject); + + lootSituationAssessment(requester,lootedObject,lootRollSession); + + CreatureObject lootedCreature = (CreatureObject) lootedObject; + + //TreeSet> lootSpec = lootedObject.getLootSpecification(); + List lootGroups = lootedCreature.getLootGroups(); + System.out.println("lootGroups size " + lootGroups.size()); + Iterator iterator = lootGroups.iterator(); + + while (iterator.hasNext()){ + LootGroup lootGroup = iterator.next(); + int groupChance = lootGroup.getLootGroupChance(); + int lootGroupRoll = new Random().nextInt(100); + if (lootGroupRoll <= groupChance){ + System.out.println("this lootGroup will drop something"); + handleLootGroup(lootGroup,lootRollSession); //this lootGroup will drop something e.g. {kraytpearl_range,krayt_tissue_rare} + } + } + + // Rare Loot System Stage (Is in place for all looted creatures) + if (lootRollSession.isAllowRareLoot()){ + int randomRareLoot = new Random().nextInt(100); + int chanceRequirement = 1; + if (lootRollSession.isIncreasedRLSChance()) + chanceRequirement+=3; // RLS chance is at 4% for groupsize >= 4 + if (randomRareLoot <= chanceRequirement){ + handleRareLootChest(lootRollSession); + } + } + + + // ********** Phase 1 complete, loot items determined ********** + // stored in the lootSession + + // Distribute the loot drops according to group loot rules + // For now just spawn items into requester's inventory + + if (lootRollSession.getErrorMessages().size()>0){ + for (String msg : lootRollSession.getErrorMessages()){ + // ToDo: Show this for each group member later! + requester.sendSystemMessage(msg,(byte) 1); + lootedObject.setLootLock(false); + return; + } + } + + SWGObject requesterInventory = requester.getSlottedObject("inventory"); + + for (TangibleObject droppedItem : lootRollSession.getDroppedItems()){ + + requesterInventory.add(droppedItem); + if (droppedItem.getAttachment("LootItemName").toString().contains("Loot Chest")){ + requester.playEffectObject("clienteffect/level_granted.cef", ""); + } + } + + lootedObject.setLooted(true); + + + // ToDo: Group loot settings etc. actual loot chance was lootgroupchance*lootchance + } + + + private void handleLootGroup(LootGroup lootGroup,LootRollSession lootRollSession){ + + int[] lootPoolChances = lootGroup.getLootPoolChances(); + String[] lootPoolNames = lootGroup.getLootPoolNames(); + if (lootPoolChances==null || lootPoolNames==null){ + System.err.println("Lootpools are null!"); + return; + } + if (lootPoolChances.length==0 || lootPoolNames.length==0){ + System.err.println("No Lootpools in Lootgroup!"); + return; + } + + int randomItemFromGroup = new Random().nextInt(100); + int remainder = 0; // [10,20,30,34,5,1] + + for(int i=0;i itemNames = (Vector)core.scriptService.fetchStringVector(path,"itemNames"); + + for (String s : itemNames){ + System.out.println("template: " + s); + } + + Vector itemChances = (Vector)core.scriptService.fetchIntegerVector(path,"itemChances"); + + int randomItemFromPool = new Random().nextInt(100); + int remainder = 0; // [10,20,30,34,5,1] + + for (int i=0;i { + @Override + public boolean accept(Path entry) throws IOException { + return Files.isDirectory(entry); + } + } + + private void handleLootPoolItems(String itemName,LootRollSession lootRollSession){ + + List subfolders = new ArrayList(); // Consider all sub-folders + try (DirectoryStream ds = Files.newDirectoryStream(FileSystems.getDefault().getPath("scripts/loot/lootItems/"), new DirectoriesFilter())) { + for (Path p : ds) { + subfolders.add(p.getFileName().toString()); + } + } catch (IOException e) { + lootRollSession.addErrorMessage("File system check caused an error. Please contact Charon about this issue."); + return; + } + + String itemPath = "scripts/loot/lootItems/"+itemName.toLowerCase()+".py"; + File file = new File(itemPath); + if (!file.isFile()){ + for (String subfolderName : subfolders){ + itemPath = "scripts/loot/lootItems/"+ subfolderName +"/"+itemName.toLowerCase()+".py"; + File subfile = new File(itemPath); + if (subfile.isFile()) + break; + } + } + + File checkfile = new File(itemPath); + if (!checkfile.isFile()){ + String errorMessage = "Loot item '" + itemName + "' not found in file system. Please contact Charon about this issue."; + lootRollSession.addErrorMessage(errorMessage); + return; + } + + itemPath = itemPath.substring(0, itemPath.length()-3); // remove the file type + + String customName = ""; + String itemTemplate = ""; + int stackCount = 1; + Vector customizationAttributes = null; + Vector customizationValues = null; + + if(core.scriptService.getMethod(itemPath,"","itemTemplate")==null){ + String errorMessage = "Loot item '" + itemName + "' has no template function assigned in its script. Please contact Charon about this issue."; + lootRollSession.addErrorMessage(errorMessage); + return; + } + + itemTemplate = (String)core.scriptService.fetchString(itemPath,"itemTemplate"); + + // only consider the following variables, if they are in the python-script file + if(core.scriptService.getMethod(itemPath,"","customItemName")!=null) + customName = (String)core.scriptService.fetchString(itemPath,"customItemName"); + + if(core.scriptService.getMethod(itemPath,"","customItemStackCount")!=null) + stackCount = (Integer)core.scriptService.fetchInteger(itemPath,"customItemStackCount"); + + if(core.scriptService.getMethod(itemPath,"","customizationAttributes")!=null) + customizationAttributes = (Vector)core.scriptService.fetchStringVector(itemPath,"customizationAttributes"); + + if(core.scriptService.getMethod(itemPath,"","customizationValues")!=null) + customizationValues = (Vector)core.scriptService.fetchIntegerVector(itemPath,"customizationValues"); + + System.out.println("itemTemplate " + itemTemplate); + + TangibleObject droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet()); + + droppedItem.setAttachment("LootItemName", itemName); + handleCustomDropName(droppedItem,customName); + handleStats(droppedItem); + setCustomization(droppedItem, itemName); + handleSpecialItems(droppedItem,itemName); + + lootRollSession.addDroppedItem(droppedItem); + } + + private void handleCustomDropName(TangibleObject droppedItem,String customName) { +// String customItemName = droppedItem.getCustomName(); +// if (customName.charAt(0) == '@' || customName.contains("_n:")) { +// if (customName!=null) { +// customName = ""; // Look the name up in some tre table +// } +// } + droppedItem.setCustomName(customName); + } + + private TangibleObject createDroppedItem(String template,Planet planet){ + TangibleObject droppedItem = (TangibleObject) core.objectService.createObject(template, planet); + System.out.println("droppedItem " + droppedItem); + return droppedItem; + } + + private void handleRareLootChest(LootRollSession lootRollSession){ + + TangibleObject droppedItem = null; + + int legendaryRoll = new Random().nextInt(100); + int exceptionalRoll = new Random().nextInt(100); + int chancemodifier = 0; + if (lootRollSession.isIncreasedRLSChance()) + chancemodifier += 15; + + if (legendaryRoll<2+chancemodifier){ + String itemTemplate="object/tangible/item/shared_rare_loot_chest_3.iff"; + droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet()); + String itemName = "Legendary Loot Chest"; + droppedItem.setStfFilename("loot_n"); + droppedItem.setStfName("rare_loot_chest_3_n"); + droppedItem.setDetailFilename("loot_n"); + droppedItem.setDetailName("rare_loot_chest_3_d"); + droppedItem.setAttachment("LootItemName", itemName); + droppedItem.getAttributes().put("@obj_attr_n:rare_loot_category", "\\#D1F56F Rare Item \\#FFFFFF "); + fillLegendaryChest(droppedItem); + + } else if (exceptionalRoll<10+chancemodifier){ + String itemTemplate="object/tangible/item/shared_rare_loot_chest_2.iff"; + droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet()); + String itemName = "Exceptional Loot Chest"; + droppedItem.setStfFilename("loot_n"); + droppedItem.setStfName("rare_loot_chest_2_n"); + droppedItem.setDetailFilename("loot_n"); + droppedItem.setDetailName("rare_loot_chest_2_d"); + droppedItem.setAttachment("LootItemName", itemName); + droppedItem.getAttributes().put("@obj_attr_n:rare_loot_category", "\\#D1F56F Rare Item \\#FFFFFF "); + fillExceptionalChest(droppedItem); + } else { + String itemTemplate="object/tangible/item/shared_rare_loot_chest_1.iff"; + droppedItem = createDroppedItem(itemTemplate,lootRollSession.getSessionPlanet()); + String itemName = "Rare Loot Chest"; + droppedItem.setStfFilename("loot_n"); + droppedItem.setStfName("rare_loot_chest_1_n"); + droppedItem.setDetailFilename("loot_n"); + droppedItem.setDetailName("rare_loot_chest_1_d"); + droppedItem.setAttachment("LootItemName", itemName); + droppedItem.getAttributes().put("@obj_attr_n:rare_loot_category", "\\#D1F56F Rare Item \\#FFFFFF "); + fillRareChest(droppedItem); + } + + lootRollSession.addDroppedItem(droppedItem); + } + + private void fillLegendaryChest(TangibleObject droppedItem){ + + } + + private void fillExceptionalChest(TangibleObject droppedItem){ + + } + + private void fillRareChest(TangibleObject droppedItem){ + + } + + private 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)); + } + + // Example power crystal + if (itemName.contains("powercrystal")) { + System.out.println("powercrystal"); + droppedItem.setCustomizationVariable("/private/index_color_1", (byte) 0x21); // 0x1F + } + + // More general +// String path = "scripts/loot/lootItems/"+droppedItem.getCustomName().toLowerCase(); +// Vector customizationPaths = (Vector)core.scriptService.fetchStringVector(path,"itemCustomizationPaths"); +// Vector customizationValues = (Vector)core.scriptService.fetchIntegerVector(path,"itemCustomizationValues"); +// for (int i=0;i { }); - - swgOpcodes.put(Opcodes.CommodotiesItemTypeListRequest, (session, data) -> { - - }); - + swgOpcodes.put(Opcodes.SetFurnitureRoationDegree, (session, data) -> { }); diff --git a/src/services/ScriptService.java b/src/services/ScriptService.java index 9ea1c999..c7bac81d 100644 --- a/src/services/ScriptService.java +++ b/src/services/ScriptService.java @@ -21,6 +21,9 @@ ******************************************************************************/ package services; +import java.util.Iterator; +import java.util.Vector; + import org.python.core.Py; import org.python.core.PyObject; import org.python.util.PythonInterpreter; @@ -107,4 +110,34 @@ public class ScriptService { return func; } + public String fetchString(String path, String method) { + PyObject result = core.scriptService.callScript(path, "", method); + return ((PyObject)result).asString(); + } + + public int fetchInteger(String path, String method) { + PyObject result = core.scriptService.callScript(path, "", method); + return ((PyObject)result).asInt(); + } + + public Vector fetchStringVector(String path, String method) { + Vector vector = new Vector(); + PyObject result = core.scriptService.callScript(path, "", method); + Iterable comp = (Iterable)result.asIterable(); + for (Iterator temp = comp.iterator(); temp.hasNext();){ + vector.add(temp.next().asString()); + } + return vector; + } + + public Vector fetchIntegerVector(String path, String method) { + Vector vector = new Vector(); + PyObject result = core.scriptService.callScript(path, "", method); + Iterable comp = (Iterable)result.asIterable(); + for (Iterator temp = comp.iterator(); temp.hasNext();){ + vector.add(temp.next().asInt()); + } + return vector; + } + } diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index f628f078..e76920c7 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -809,7 +809,9 @@ public class SimulationService implements INetworkDispatch { PlayerObject ghost = (PlayerObject) object.getSlottedObject("ghost"); core.weatherService.sendWeather(object); - + + //core.chatService.joinChatRoom(object.getCustomName().toLowerCase(), "SWG." + core.getGalaxyName() + "." + object.getPlanet().getName()); + if (!object.hasSkill(ghost.getProfessionWheelPosition())) { object.showFlyText(OutOfBand.ProsePackage("@cbt_spam:skill_up"), 2.5f, new RGB(154, 205, 50), 0, true); object.playEffectObject("clienteffect/skill_granted.cef", ""); diff --git a/src/services/TerrainService.java b/src/services/TerrainService.java index c8b3aaf5..ddc66042 100644 --- a/src/services/TerrainService.java +++ b/src/services/TerrainService.java @@ -175,6 +175,12 @@ public class TerrainService { core.mapService.addPlanet(planet); noBuildAreas.put(planet, new ArrayList()); loadClientRegions(planet); + + core.chatService.createChatRoom("", name, "system", true); + core.chatService.createChatRoom("public chat for this planet, cannot create rooms here", name + ".Planet", "SYSTEM", true); + core.chatService.createChatRoom("system messages for this planet, cannot create rooms here", name + ".system", "SYSTEM", true); + + System.out.println("Created chat rooms for " + name); } diff --git a/src/services/ai/states/DeathState.java b/src/services/ai/states/DeathState.java index 13abdec0..14df1485 100644 --- a/src/services/ai/states/DeathState.java +++ b/src/services/ai/states/DeathState.java @@ -29,6 +29,7 @@ public class DeathState extends AIState { @Override public byte onEnter(AIActor actor) { NGECore.getInstance().aiService.awardExperience(actor); + actor.getCreature().setAttachment("radial_filename", "npc/corpse"); actor.scheduleDespawn(); return 0; } diff --git a/src/services/bazaar/AuctionItem.java b/src/services/bazaar/AuctionItem.java new file mode 100644 index 00000000..8b134e97 --- /dev/null +++ b/src/services/bazaar/AuctionItem.java @@ -0,0 +1,264 @@ +/******************************************************************************* + * 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 services.bazaar; + +import com.sleepycat.je.Environment; +import com.sleepycat.je.Transaction; +import com.sleepycat.persist.model.Entity; +import com.sleepycat.persist.model.NotPersistent; +import com.sleepycat.persist.model.PrimaryKey; +import engine.resources.objects.IPersistent; + +@Entity(version=0) +public class AuctionItem implements IPersistent { + + @PrimaryKey + private long objectId; + private long ownerId; + private long vendorId; + private long buyerId; + private long offerToId; + private int itemType; + private String ownerName; + private String bidderName; + private String itemName; + private String itemDescription; + private int price; + private int proxyBid; + private boolean auction; + private String vuid; + private int status; + private boolean onBazaar; + private long expireTime; + private int auctionOptions; + + public static final int PREMIUM = 0x400; + public static final int WITHDRAW = 0x800; + public final static int FORSALE = 1; + public final static int SOLD = 2; + public final static int EXPIRED = 4; + public final static int OFFERED = 5; + public final static int RETRIEVED = 6; + + @NotPersistent + private Transaction txn; + + public AuctionItem() { + + } + + public AuctionItem(long objectId, long ownerId) { + this.objectId = objectId; + this.ownerId = ownerId; + } + + + public long getObjectId() { + return objectId; + } + + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + + + public long getOwnerId() { + return ownerId; + } + + + public void setOwnerId(long ownerId) { + this.ownerId = ownerId; + } + + + public long getVendorId() { + return vendorId; + } + + + public void setVendorId(long vendorId) { + this.vendorId = vendorId; + } + + + public long getBuyerId() { + return buyerId; + } + + + public void setBuyerId(long buyerId) { + this.buyerId = buyerId; + } + + + public long getOfferToId() { + return offerToId; + } + + + public void setOfferToId(long offerToId) { + this.offerToId = offerToId; + } + + + public int getItemType() { + return itemType; + } + + + public void setItemType(int itemType) { + this.itemType = itemType; + } + + + public String getOwnerName() { + return ownerName; + } + + + public void setOwnerName(String ownerName) { + this.ownerName = ownerName; + } + + + public String getBidderName() { + return bidderName; + } + + + public void setBidderName(String bidderName) { + this.bidderName = bidderName; + } + + + public String getItemName() { + return itemName; + } + + + public void setItemName(String itemName) { + this.itemName = itemName; + } + + + public String getItemDescription() { + return itemDescription; + } + + + public void setItemDescription(String itemDescription) { + this.itemDescription = itemDescription; + } + + + public int getPrice() { + return price; + } + + + public void setPrice(int price) { + this.price = price; + } + + + public int getProxyBid() { + return proxyBid; + } + + + public void setProxyBid(int proxyBid) { + this.proxyBid = proxyBid; + } + + + public boolean isAuction() { + return auction; + } + + + public void setAuction(boolean auction) { + this.auction = auction; + } + + + public String getVuid() { + return vuid; + } + + + public void setVuid(String vuid) { + this.vuid = vuid; + } + + + public int getStatus() { + return status; + } + + + public void setStatus(int status) { + this.status = status; + } + + + public boolean isOnBazaar() { + return onBazaar; + } + + + public void setOnBazaar(boolean onBazaar) { + this.onBazaar = onBazaar; + } + + + public long getExpireTime() { + return expireTime; + } + + + public void setExpireTime(long expireTime) { + this.expireTime = expireTime; + } + + + public int getAuctionOptions() { + return auctionOptions; + } + + + public void setAuctionOptions(int auctionOptions) { + this.auctionOptions = auctionOptions; + } + + @Override + public void createTransaction(Environment env) { + txn = env.beginTransaction(null, null); + } + + @Override + public Transaction getTransaction() { + return txn; + } + +} diff --git a/src/services/bazaar/BazaarService.java b/src/services/bazaar/BazaarService.java new file mode 100644 index 00000000..1700aa64 --- /dev/null +++ b/src/services/bazaar/BazaarService.java @@ -0,0 +1,170 @@ +/******************************************************************************* + * 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 services.bazaar; + +import java.nio.ByteOrder; +import java.util.Map; + +import main.NGECore; +import engine.clients.Client; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Point3D; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; +import resources.common.Opcodes; +import resources.objects.building.BuildingObject; +import resources.objects.creature.CreatureObject; +import protocol.swg.ClientIdMsg; +import protocol.swg.auctionManagerClientListener.CommoditiesItemTypeListResponse; +import protocol.swg.auctionManagerClientListener.CommoditiesResourceTypeListResponse; +import protocol.swg.auctionManagerClientListener.CreateAuctionMessage; +import protocol.swg.auctionManagerClientListener.IsVendorOwnerMessage; +import protocol.swg.auctionManagerClientListener.IsVendorOwnerResponseMessage; +import protocol.swg.auctionManagerClientListener.ItemSoldMessage; + +public class BazaarService implements INetworkDispatch { + + private NGECore core; + + public BazaarService(NGECore core) { + this.core = core; + } + + @Override + public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + + swgOpcodes.put(Opcodes.CommoditiesItemTypeListRequest, (session, data) -> { + + Client client = core.getClient(session); + + if (client == null) + return; + + SWGObject player = client.getParent(); + + if (player == null) + return; + + session.write(new CommoditiesItemTypeListResponse().serialize()); + + }); + + swgOpcodes.put(Opcodes.IsVendorOwnerMessage, (session, data) -> { + + Client client = core.getClient(session); + + if (client == null) + return; + + SWGObject player = client.getParent(); + + if (player == null) + return; + + data = data.order(ByteOrder.LITTLE_ENDIAN); + data.position(0); + + IsVendorOwnerMessage request = new IsVendorOwnerMessage(); + request.deserialize(data); + long terminalId = request.getTerminalId(); + SWGObject terminal = core.objectService.getObject(terminalId); + if(terminal == null) + return; + Point3D pos = terminal.getWorldPosition(); + session.write(new IsVendorOwnerResponseMessage(2, 0, terminalId, "tatooine.@tatooine_region_names:mos_eisley.@terminal_name:terminal_bazaar." + terminalId + "#" + pos.x + "," + pos.z).serialize()); + + + }); + + swgOpcodes.put(Opcodes.CommoditiesResourceTypeListRequest, (session, data) -> { + + Client client = core.getClient(session); + + if (client == null) + return; + + SWGObject player = client.getParent(); + + if (player == null) + return; + + data = data.order(ByteOrder.LITTLE_ENDIAN); + + if(data.remaining() > 2) // if client attaches a string to the request then it has already recieved it on zone-in + return; + + //session.write(new CommoditiesResourceTypeListResponse(core.resourceService.getCompleteResourceNameHistory()).serialize()); + + }); + + swgOpcodes.put(Opcodes.CreateAuctionMessage, (session, data) -> { + + Client client = core.getClient(session); + + if (client == null) + return; + + SWGObject player = client.getParent(); + + if (player == null) + return; + + data = data.order(ByteOrder.LITTLE_ENDIAN); + data.position(0); + + CreateAuctionMessage createAuction = new CreateAuctionMessage(); + + SWGObject vendor = core.objectService.getObject(createAuction.getVendorId()); + SWGObject item = core.objectService.getObject(createAuction.getObjectId()); + + if(vendor == null || item == null || item instanceof CreatureObject || item instanceof BuildingObject) + return; + + + + }); + + + + } + + public void addAuction(CreatureObject player, SWGObject item, SWGObject vendor, int price, int duration, String description, boolean auction, boolean premium) { + + ItemSoldMessage itemSoldMsg = new ItemSoldMessage(item.getObjectID(), ItemSoldMessage.SUCCESS); + + if(item.getAttributes().containsKey("no_trade") || !item.isSubChildOf(player)) { + itemSoldMsg.setStatus(ItemSoldMessage.INVALIDITEM); + player.getClient().getSession().write(itemSoldMsg.serialize()); + return; + } + + + + } + + @Override + public void shutdown() { + + } + + +} diff --git a/src/services/chat/ChatRoom.java b/src/services/chat/ChatRoom.java index a2428907..1cc7f2a2 100644 --- a/src/services/chat/ChatRoom.java +++ b/src/services/chat/ChatRoom.java @@ -23,7 +23,6 @@ package services.chat; import java.util.Vector; -import resources.objects.creature.CreatureObject; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.NotPersistent; @@ -37,10 +36,10 @@ public class ChatRoom { private int roomId; private String roomAddress; // name - private Vector moderatorList = new Vector(); - private Vector banList = new Vector(); + private Vector moderatorList = new Vector(); + private Vector banList = new Vector(); @NotPersistent - private Vector userList = new Vector(); // current users + private Vector userList = new Vector(); // current users private boolean moderatorsOnly; private boolean privateRoom; @@ -50,9 +49,9 @@ public class ChatRoom { public String getCreator() { return creator; } - + public void setCreator(String creator) { - this.creator = creator; + this.creator = creator.toLowerCase(); } public String getRoomAddress() { @@ -71,22 +70,14 @@ public class ChatRoom { this.roomId = roomId; } - public Vector getModeratorList() { + public Vector getModeratorList() { return moderatorList; } - public void setModeratorList(Vector moderatorList) { - this.moderatorList = moderatorList; - } - - public Vector getUserList() { + public Vector getUserList() { return userList; } - public void setUserList(Vector userList) { - this.userList = userList; - } - public boolean isModeratorsOnly() { return moderatorsOnly; } @@ -108,17 +99,13 @@ public class ChatRoom { } public void setOwner(String owner) { - this.owner = owner; + this.owner = owner.toLowerCase(); } - public Vector getBanList() { + public Vector getBanList() { return banList; } - public void setBanList(Vector banList) { - this.banList = banList; - } - public String getDescription() { return description; } @@ -134,4 +121,28 @@ public class ChatRoom { public void setVisible(boolean visible) { this.visible = visible; } + + public void addUser(String user) { + userList.add(user.toLowerCase()); + } + + public void addModerator(String moderator) { + moderatorList.add(moderator.toLowerCase()); + } + + public void banUser(String user) { + banList.add(user.toLowerCase()); + } + + public boolean hasUser(String user) { + return userList.contains(user.toLowerCase()); + } + + public boolean hasModerator(String moderator) { + return moderatorList.contains(moderator.toLowerCase()); + } + + public boolean hasBan(String user) { + return banList.contains(user.toLowerCase()); + } } diff --git a/src/services/chat/ChatService.java b/src/services/chat/ChatService.java index 3ba38bad..38476166 100644 --- a/src/services/chat/ChatService.java +++ b/src/services/chat/ChatService.java @@ -24,6 +24,7 @@ package services.chat; import java.nio.ByteOrder; import java.util.Date; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Random; import java.util.Vector; @@ -40,6 +41,7 @@ import engine.resources.config.Config; import engine.resources.config.DefaultConfig; import engine.resources.database.ObjectDatabase; import engine.resources.objects.SWGObject; +import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -49,6 +51,7 @@ import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import protocol.swg.AddIgnoreMessage; import protocol.swg.ObjControllerMessage; +import protocol.swg.chat.ChatCreateRoom; import protocol.swg.chat.ChatDeletePersistentMessage; import protocol.swg.chat.ChatEnterRoomById; import protocol.swg.chat.ChatFriendsListUpdate; @@ -56,6 +59,7 @@ import protocol.swg.chat.ChatInstantMessageToCharacter; import protocol.swg.chat.ChatInstantMessagetoClient; import protocol.swg.chat.ChatOnAddFriend; import protocol.swg.chat.ChatOnChangeFriendStatus; +import protocol.swg.chat.ChatOnCreateRoom; import protocol.swg.chat.ChatOnEnteredRoom; import protocol.swg.chat.ChatOnSendInstantMessage; import protocol.swg.chat.ChatOnSendPersistentMessage; @@ -66,6 +70,7 @@ import protocol.swg.chat.ChatRequestPersistentMessage; import protocol.swg.chat.ChatRoomList; import protocol.swg.chat.ChatRoomMessage; import protocol.swg.chat.ChatSendToRoom; +import protocol.swg.chat.ChatServerStatus; import protocol.swg.chat.ChatSystemMessage; import protocol.swg.objectControllerObjects.PlayerEmote; import protocol.swg.objectControllerObjects.SpatialChat; @@ -360,11 +365,10 @@ public class ChatService implements INetworkDispatch { if (obj == null) return; - //ChatServerStatus chatServerStatus = new ChatServerStatus(); - //client.getSession().write(chatServerStatus.serialize()); - ChatRoomList listMessage = new ChatRoomList(chatRooms); client.getSession().write(listMessage.serialize()); + + //System.out.println("Sent the room request responses."); } }); @@ -392,11 +396,13 @@ public class ChatService implements INetworkDispatch { if (room != null) { room.setPrivateRoom(sentPacket.isPrivacy()); room.setModeratorsOnly(sentPacket.isModeratorOnly()); - room.getUserList().add(creo); - room.getModeratorList().add(creo); + room.addUser(creo.getCustomName()); + room.addModerator(creo.getCustomName()); ChatOnCreateRoom response = new ChatOnCreateRoom(room, 0, sentPacket.getRequest()); session.write(response.serialize()); - }*/ + } + + System.out.println("Created room.");*/ }); @@ -418,6 +424,7 @@ public class ChatService implements INetworkDispatch { }); swgOpcodes.put(Opcodes.ChatSendToRoom, (session, data) -> { + //System.out.println("send to room!"); Client client = core.getClient(session); if(client == null) @@ -452,7 +459,7 @@ public class ChatService implements INetworkDispatch { ChatEnterRoomById sentPacket = new ChatEnterRoomById(); sentPacket.deserialize(data); - joinChatRoom((CreatureObject) obj, sentPacket.getRoomId()); + joinChatRoom(obj.getCustomName(), sentPacket.getRoomId()); //System.out.println("Entering room... " + sentPacket.getRoomId()); @@ -724,8 +731,22 @@ public class ChatService implements INetworkDispatch { } private void loadChatRooms() { - ChatRoom system = createChatRoom("", "Chat", "system", true); - chatRooms.put(system.getRoomId(), system); + + /* + * Battlefields channel format: + * SWG.serverName.battlefield.bfMapName + * + * TODO: Research other channel address formats + */ + + createChatRoom("", "SWG", "system", true); + createChatRoom("", "SWG." + core.getGalaxyName(), "system", true); + + createChatRoom("", "system", "system", true); // galaxy system messages + createChatRoom("", "Auction", "system", true); + + //createChatRoom("Bounty Hunter chat for this galaxy", "BountyHunter", "SYSTEM", true); + //createChatRoom("Commando chat for this galaxy", "Commando", "SYSTEM", true); EntityCursor cursor = chatRoomsODB.getCursor(Integer.class, ChatRoom.class); cursor.forEach(room -> { @@ -734,23 +755,23 @@ public class ChatService implements INetworkDispatch { cursor.close(); } - public ChatRoom createChatRoom(String roomName, String address, String creator, boolean showInList) { - return createChatRoom(roomName, address, creator, showInList, false); + public ChatRoom createChatRoom(String roomName, String address, String creator, boolean isPublic) { + return createChatRoom(roomName, address, creator, isPublic, false); } - public ChatRoom createChatRoom(String roomName, String address, String creator, boolean showInList, boolean store) { + public ChatRoom createChatRoom(String roomName, String address, String creator, boolean isPublic, boolean store) { if (creator.contains(" ")) creator = creator.split(" ")[0]; ChatRoom room = new ChatRoom(); room.setDescription(roomName); - if (!address.startsWith("SWG.")) + if (!address.startsWith("SWG")) room.setRoomAddress("SWG." + core.getGalaxyName() + "." + address); else room.setRoomAddress(address); room.setCreator(creator.toLowerCase()); room.setOwner(creator.toLowerCase()); - room.setVisible(showInList); + room.setVisible(isPublic); room.setRoomId(generateChatRoomId()); chatRooms.put(room.getRoomId(), room); @@ -764,26 +785,45 @@ public class ChatService implements INetworkDispatch { return room; } - public void joinChatRoom(CreatureObject player, int roomId) { + public boolean joinChatRoom(String user, String roomAddress) { + chatRooms.forEach((k, v) -> { + if (v.getRoomAddress().equals(roomAddress)) { + joinChatRoom(user, k, true); + return; + } + }); + return false; + } + public boolean joinChatRoom(String user, int roomId, boolean resendList) { - String playerName = player.getCustomName().toLowerCase(); - - if (playerName.contains(" ")) - playerName = playerName.split(" ")[0]; + if (user.contains(" ")) + user = user.split(" ")[0]; ChatRoom room = getChatRoom(roomId); if (room == null) - return; - - ChatOnEnteredRoom enterRoom = new ChatOnEnteredRoom(playerName, 0, roomId, true); - - if (!room.getUserList().contains(player)) - room.getUserList().add(player); - - room.getUserList().stream().forEach(user -> user.getClient().getSession().write(enterRoom.serialize())); + return false; + if (!room.hasUser(user.toLowerCase())) { + room.addUser(user.toLowerCase()); + + if (!room.isVisible() || resendList) { + CreatureObject creo = (CreatureObject) getObjectByFirstName(user); + if (creo != null) { + ChatRoomList listMessage = new ChatRoomList(room); + creo.getClient().getSession().write(listMessage.serialize()); + } + } + ChatOnEnteredRoom enterRoom = new ChatOnEnteredRoom(user, 0, roomId, true); + getObjectByFirstName(user).getClient().getSession().write(enterRoom.serialize()); + //System.out.println("Sent message for room " + room.getRoomAddress()); + return true; + } + return false; } + public boolean joinChatRoom(String user, int roomId) { + return joinChatRoom(user, roomId, false); + } public void leaveChatRoom(CreatureObject player, int roomId) { String playerName = player.getCustomName().toLowerCase(); @@ -816,11 +856,8 @@ public class ChatService implements INetworkDispatch { sender.getClient().getSession().write(onSend.serialize()); ChatRoomMessage roomMessage = new ChatRoomMessage(roomId, senderName, message); - Vector users = room.getUserList(); + Vector users = room.getUserList(); - for (CreatureObject user : users) { - user.getClient().getSession().write(roomMessage.serialize()); - } } public ConcurrentHashMap getChatRooms() { diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 1f455338..f8cbb7fc 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -191,7 +191,9 @@ public class CombatService implements INetworkDispatch { { defender.removeDefender(creature); creature.removeDefender(defender); - } + } + + if(((CreatureObject) target).getPlayerObject() == null) target.setKiller(attacker); } } else if(target instanceof TangibleObject) diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 666f1573..a08b267d 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -47,6 +47,7 @@ import protocol.swg.objectControllerObjects.CommandEnqueue; import protocol.swg.objectControllerObjects.CommandEnqueueRemove; import protocol.swg.objectControllerObjects.StartTask; import resources.objects.creature.CreatureObject; +import resources.objects.harvester.HarvesterObject; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; @@ -74,7 +75,7 @@ public class CommandService implements INetworkDispatch { return false; } - if (command.getCharacterAbility().length() > 0 && !actor.hasAbility(command.getCharacterAbility())) { + if (command.getCharacterAbility().length() > 0 && !actor.hasAbility(command.getCharacterAbility()) && !command.getCharacterAbility().equals("admin") && actor.getClient() != null) { return false; } @@ -109,7 +110,7 @@ public class CommandService implements INetworkDispatch { //return false; } } - + switch (command.getTargetType()) { case 0: // Target Not Used For This Command break; @@ -143,6 +144,10 @@ public class CommandService implements INetworkDispatch { break; case 2: // Anyone (objectId/targetName) + if (actor.getClient() == null) { + break; + } + if (target == null) { if (commandArgs != null && !commandArgs.equals("")) { String name = commandArgs.split(" ")[0]; @@ -229,7 +234,10 @@ public class CommandService implements INetworkDispatch { TangibleObject object = (TangibleObject) target; - if (object.isAttackableBy(actor) || actor.getFactionStatus() < ((CreatureObject) object).getFactionStatus() || (!object.getFaction().equals("") && !object.getFaction().equals(actor.getFaction()))) { + if(object instanceof CreatureObject && actor.getFactionStatus() < ((CreatureObject) object).getFactionStatus()) + return false; + + if (object.isAttackableBy(actor) || (!object.getFaction().equals("") && !object.getFaction().equals(actor.getFaction()))) { return false; } @@ -256,7 +264,7 @@ public class CommandService implements INetworkDispatch { default: break; } - + if (command.shouldCallOnTarget()) { if (target == null || !(target instanceof CreatureObject)) { return false; @@ -267,10 +275,12 @@ public class CommandService implements INetworkDispatch { long warmupTime = (long) (command.getWarmupTime() * 1000F); - try { - Thread.sleep(warmupTime); - } catch (InterruptedException e) { - e.printStackTrace(); + if(warmupTime > 0) { + try { + Thread.sleep(warmupTime); + } catch (InterruptedException e) { + e.printStackTrace(); + } } processCommand(actor, target, command, actionCounter, commandArgs); @@ -372,7 +382,7 @@ public class CommandService implements INetworkDispatch { sub += 5; } - if (hasCharacterAbility || isCombatCommand(commandName)) { + if (/*hasCharacterAbility ||*/ isCombatCommand(commandName)) { CombatCommand command = new CombatCommand(commandName); commandLookup.add(command); return command; @@ -409,15 +419,16 @@ public class CommandService implements INetworkDispatch { } public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { - actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); - + if(command.getCooldown() > 0) + actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); + if (command instanceof CombatCommand) { processCombatCommand(actor, target, (CombatCommand) command, actionCounter, commandArgs); } else { - if (FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName() + ".py")) { - core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandArgs); - } else if (FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) { - core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "run", core, actor, target, commandArgs); + if (FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName().toLowerCase() + ".py")) { + core.scriptService.callScript("scripts/commands/", command.getCommandName().toLowerCase(), "run", core, actor, target, commandArgs); + } else if (FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName().toLowerCase() + ".py")) { + core.scriptService.callScript("scripts/commands/combat/", command.getCommandName().toLowerCase(), "run", core, actor, target, commandArgs); } } } @@ -584,6 +595,45 @@ public class CommandService implements INetworkDispatch { } }); + + objControllerOpcodes.put(ObjControllerOpcodes.RESOURCE_EMPTY_HOPPER, new INetworkRemoteEvent() { + + @Override + public void handlePacket(IoSession session, IoBuffer data) throws Exception { + data.order(ByteOrder.LITTLE_ENDIAN); + Client client = core.getClient(session); + CommandEnqueue commandEnqueue = new CommandEnqueue(); + +// StringBuilder sb = new StringBuilder(); +// for (byte b : data.array()) { +// sb.append(String.format("%02X ", b)); +// } +// System.out.println(sb.toString()); + + /* + 05 00 46 5E CE 80 83 00 00 00 ED 00 00 00 3E 45 + 04 00 00 00 00 00 00 00 00 00 3E 45 04 00 00 00 + 00 00 90 52 05 00 00 00 00 00 D7 35 05 00 00 00 + 00 00 01 00 00 00 00 07 + */ + + long playerId = data.getLong(); // 3E 45 04 00 00 00 00 00 + data.getInt(); // 00 00 00 00 + data.getLong(); // 3E 45 04 00 00 00 00 00 + long harvesterId = data.getLong(); // 1E 55 05 00 00 00 00 00 + //long containerId = data.getLong(); // 1E 55 05 00 00 00 00 00 Resources ID + long resourceId = data.getLong(); // 1E 55 05 00 00 00 00 00 Resources ID + int stackCount = data.getInt(); // Stack count + byte actionMode = data.get(); // 0 for retrieving, 1 for discarding + byte updateCount = data.get(); // updateCount + + CreatureObject actor = (CreatureObject) client.getParent(); + SWGObject target = core.objectService.getObject(harvesterId); + + core.harvesterService.handleEmptyHopper(actor,target,harvesterId,resourceId,stackCount,actionMode,updateCount); + } + }); + } @@ -594,6 +644,11 @@ public class CommandService implements INetworkDispatch { public BaseSWGCommand registerCombatCommand(String name) { return getCommandByName(name); } public BaseSWGCommand registerCommand(String name) { return getCommandByName(name); } - public BaseSWGCommand registerGmCommand(String name) { return getCommandByName(name); } + public BaseSWGCommand registerGmCommand(String name) { + BaseSWGCommand command = getCommandByName(name); + if(command != null) + command.setGodLevel(5); + return command; + } } diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index a9f427b5..3367c412 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -29,15 +29,27 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; +import java.util.HashMap; import java.util.Map; +import java.util.Random; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import main.NGECore; import protocol.swg.EnterStructurePlacementModeMessage; +import protocol.swg.SceneCreateObjectByCrc; +import protocol.swg.SceneDestroyObject; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; +import resources.objects.deed.Harvester_Deed; +import resources.objects.deed.Player_House_Deed; +import resources.objects.harvester.HarvesterObject; +import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; +import services.sui.SUIWindow; +import services.sui.SUIWindow.SUICallback; +import services.sui.SUIWindow.Trigger; +import engine.resources.common.CRC; import engine.resources.objects.SWGObject; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; @@ -75,7 +87,7 @@ public class HousingService implements INetworkDispatch { public void placeStructure(final CreatureObject actor, TangibleObject deed, float positionX, float positionZ, float rotation) { HouseTemplate houseTemplate = housingTemplates.get(deed.getTemplate()); - + Player_House_Deed playerHourseDeed = (Player_House_Deed)core.objectService.getObject(deed.getObjectID()); int structureLotCost = houseTemplate.getLotCost(); String structureTemplate = houseTemplate.getBuildingTemplate(); @@ -122,6 +134,9 @@ public class HousingService implements INetworkDispatch { building.setAttachment("structureOwner", actor.getObjectID()); building.setAttachment("structureAdmins", admins); + building.setDeedTemplate(deed.getTemplate()); + building.setBMR(playerHourseDeed.getBMR()); + building.setConditionDamage(100); // Save structure to DB //building.createTransaction(core.getBuildingODB().getEnvironment()); @@ -160,6 +175,575 @@ public class HousingService implements INetworkDispatch { catch (IOException e) { e.printStackTrace(); } } + public void createDestroySUIPage(final SWGObject owner, final TangibleObject target) { + + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + //final BuildingObject building = (BuildingObject) core.objectService.getObject(target.getParentId()); + // harvester.getStfFilename(); installation_n .getTemplate(); + + if (building.getItemsList().size()>0){ + ((CreatureObject) owner).sendSystemMessage("@player_structure:clear_building_for_delete", (byte)1); + } + + String displayname = "@installation_n:"+building.getStfName(); + if (building.getCustomName()!=null) + displayname = building.getCustomName(); + final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", displayname); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:confirm_destruction_d1 " + + "@player_structure:confirm_destruction_d2 " + + "\n \n @player_structure:confirm_destruction_d3a " + + "\\#32CD32 @player_structure:confirm_destruction_d3b \\#FFFFFF " + + "@player_structure:confirm_destruction_d4 "); + if (building.getConditionDamage()<20 && building.getMaintenanceAmount()<3000){ + window.addListBoxMenuItem("@player_structure:redeed_confirmation \\#BB0000 @player_structure:can_redeed_no_suffix \\#FFFFFF ",1 ); + } else { + window.addListBoxMenuItem("@player_structure:redeed_confirmation \\#32CD32 @player_structure:can_redeed_yes_suffix \\#FFFFFF ",1 ); + } + if (building.getConditionDamage()<20){ + window.addListBoxMenuItem("@player_structure:redeed_condition \\#BB0000 " + building.getConditionDamage() + " \\#FFFFFF ",1 ); + } else { + window.addListBoxMenuItem("@player_structure:redeed_condition \\#32CD32 " + building.getConditionDamage() + " \\#FFFFFF ",1 ); + } + if (building.getMaintenanceAmount()<0){ + window.addListBoxMenuItem("@player_structure:redeed_maintenance \\#BB0000 " + (int)building.getMaintenanceAmount() + " \\#FFFFFF ",2 ); + } else { + window.addListBoxMenuItem("@player_structure:redeed_maintenance \\#32CD32 " + (int)building.getMaintenanceAmount() + " \\#FFFFFF ",2 ); + } + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@yes"); + window.setProperty("btnCancel:Text", "@no"); + Vector returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + createCodeWindow(owner, target); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void createCodeWindow(SWGObject owner, TangibleObject target) { + + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + //final BuildingObject building = (BuildingObject)target; + Random rnd = new Random(); + final int confirmCode = 100000 + rnd.nextInt(900000); + final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:confirm_destruction_t"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:your_structure_prefix " + + "\\#32CD32 @player_structure:will_redeed_confirm \\#FFFFFF "+ + "@player_structure:will_redeed_suffix " + + "\n \n Code: " + confirmCode); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@yes"); + window.setProperty("btnCancel:Text", "@no"); + Vector returnList = new Vector(); + returnList.add("txtInput:LocalText"); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject crafter = (CreatureObject)owner; + core.suiService.closeSUIWindow(owner, 0); + if (returnList.get(0).equals(""+confirmCode)){ + // handle creation of correct deed in player inventory + PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost"); + String deedTemplate = building.getDeedTemplate(); + + Player_House_Deed deed = (Player_House_Deed)core.objectService.createObject(deedTemplate, owner.getPlanet()); + if(player.getLotsRemaining()+deed.getLotRequirement()>10){ + // Something went wrong or hacking attempt + crafter.sendSystemMessage("Structure can't be redeeded. Maximum lot count exceeded.",(byte)1); + return; + } + + deed.setStructureTemplate(building.getTemplate()); + deed.setSurplusMaintenance((int)building.getMaintenanceAmount()); + deed.setAttributes(); + + core.objectService.destroyObject(building.getObjectID()); + + SWGObject ownerInventory = owner.getSlottedObject("inventory"); + ownerInventory.add(deed); + + if(player.getLotsRemaining()+deed.getLotRequirement()<=10) + player.setLotsRemaining(player.getLotsRemaining()+deed.getLotRequirement()); + + crafter.sendSystemMessage("@player_structure:processing_destruction",(byte)1); + crafter.sendSystemMessage("@player_structure:deed_reclaimed",(byte)1); + + } else { + crafter.sendSystemMessage("@player_structure:incorrect_destroy_code",(byte)1); + } + + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void createPayMaintenanceSUIPage(SWGObject owner, TangibleObject target) { + CreatureObject creature = (CreatureObject) owner; + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + final SUIWindow window = core.suiService.createSUIWindow("Script.transfer", owner, target, 10); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:select_amount"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:select_maint_amount" + + "\n \n @player_structure:current_maint_pool : " + (int)building.getMaintenanceAmount()); + + window.setProperty("msgPayMaintenance", "transaction.txtInputFrom"); + + window.setProperty("transaction.lblFrom:Text", "@player_structure:total_funds"); + window.setProperty("transaction.lblTo:Text", "@player_structure:to_pay"); + window.setProperty("transaction.lblFrom", "@player_structure:total_funds"); + window.setProperty("transaction.lblTo", "@player_structure:to_pay"); + + window.setProperty("transaction.lblStartingFrom:Text", ""+creature.getCashCredits()); + window.setProperty("transaction.lblStartingTo:Text", "0"); + + window.setProperty("transaction:InputFrom", "555555"); + window.setProperty("transaction:InputTo", "666666"); + + window.setProperty("transaction:txtInputFrom", ""+creature.getCashCredits()); + window.setProperty("transaction:txtInputTo", "1"); + window.setProperty("transaction.txtInputFrom:Text", ""+creature.getCashCredits()); + window.setProperty("transaction.txtInputTo:Text", "" + "0"); + + window.setProperty("transaction.ConversionRatioFrom", "1"); + window.setProperty("transaction.ConversionRatioTo", "0"); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@ok"); + window.setProperty("btnCancel:Text", "@cancel"); + + Vector returnList = new Vector(); + returnList.add("transaction.txtInputFrom:Text"); + returnList.add("transaction.txtInputTo:Text"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject crafter = (CreatureObject)owner; + crafter.setCashCredits(crafter.getCashCredits() - Integer.parseInt(returnList.get(1))); + building.setMaintenanceAmount(building.getMaintenanceAmount()+Float.parseFloat(returnList.get(1))); + String displayname = "the structure"; + if (building.getCustomName()!=null) + displayname = building.getCustomName(); + crafter.sendSystemMessage("You successfully make a payment of " + Integer.parseInt(returnList.get(1)) + " credits to " + displayname + ".", (byte) 0); + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void createRenameSUIPage(SWGObject owner, TangibleObject target) { + final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); + Vector returnList = new Vector(); + returnList.add("txtInput:LocalText"); + final TangibleObject outerSurveyTool = target; + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.housingService.handleSetName((CreatureObject)owner, (TangibleObject)outerSurveyTool,returnList.get(0)); + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void handleSetName(CreatureObject owner, TangibleObject target,String name) { + + ((BuildingObject) target).setBuildingName(name,owner); + } + + public void createStatusSUIPage(SWGObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + String displayname = "@installation_n:"+building.getStfName(); + if (building.getCustomName()!=null) + displayname = building.getCustomName(); + final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:structure_status_t"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:structure_name_prompt" + " " + displayname); + String ownerName = owner.getCustomName(); + if (ownerName.length()>0){ + String[] helper = ownerName.split(" "); + ownerName = helper[0]; + } + + String maintenancePool_string = ""+(int)building.getMaintenanceAmount(); + int hourlyMaintenance = building.getBMR(); + float totalNumberOfHours = (float)building.getMaintenanceAmount()/hourlyMaintenance; + float minuteFraction = ((totalNumberOfHours * 100) % 100) / 100; + int nDays = (int)totalNumberOfHours / 24; + float difference = totalNumberOfHours % 24; + int nHours = (int)difference; + int nMinutes = (int)(minuteFraction *60); + maintenancePool_string += " (" + nDays + " days, " + nHours + " hours, " + nMinutes + " minutes)"; + + window.addListBoxMenuItem("@player_structure:owner_prompt" + " " + ownerName, 0); + if (building.getPrivacy()==BuildingObject.PRIVATE) + window.addListBoxMenuItem("@player_structure:structure_private", 1); + else + window.addListBoxMenuItem("@player_structure:structure_public", 1); + window.addListBoxMenuItem("@player_structure:condition_prompt" + " " + target.getConditionDamage()+"%", 2); + window.addListBoxMenuItem("@player_structure:maintenance_pool_prompt " + maintenancePool_string, 3); + window.addListBoxMenuItem("@player_structure:maintenance_rate_prompt " + building.getBMR() + " cr/h", 4); // @player_structure:credits_per_hour + window.addListBoxMenuItem("@player_structure:maintenance_mods_prompt", 5); + window.addListBoxMenuItem("@player_structure:items_in_building_prompt " + building.getItemsList().size(), 6); + window.addListBoxMenuItem("@player_structure:total_house_storage " + building.getMaximumStorageCapacity(), 7); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@ok"); + window.setProperty("btnCancel:Text", "@cancel"); + Vector returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void declareResidency(SWGObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + building.setResidency((CreatureObject)owner); + //owner.setResidence(); + } + + public void handleListAllItems(SWGObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + String displayname = "@installation_n:"+building.getStfName(); + if (building.getCustomName()!=null) + displayname = building.getCustomName(); + final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:find_items_find_all_house_items"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:find_items_prompt"); + + Vector itemList = building.getItemsList(); + + for (int i=0;i returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + + + } + + public void handleDeleteAllItems(SWGObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + //building.getItemsList().clear(); + // confirmation needed + confirmDeleteAllItems(owner, target); + } + + public void confirmDeleteAllItems(SWGObject owner, TangibleObject target) { + + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + + Random rnd = new Random(); + final int confirmCode = 100000 + rnd.nextInt(900000); + final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:confirm_destruction_t"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:delete_all_items_d " + + "@player_structure:delete_all_items_prompt " + + "\n \n Code: " + confirmCode); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@yes"); + window.setProperty("btnCancel:Text", "@no"); + Vector returnList = new Vector(); + returnList.add("txtInput:LocalText"); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject ownerC = (CreatureObject)owner; + core.suiService.closeSUIWindow(owner, 0); + if (returnList.get(0).equals(""+confirmCode)){ + confirmDeleteAllItems2ndStage(ownerC,building); + } else { + ownerC.sendSystemMessage("@player_structure:incorrect_destroy_code",(byte)1); + } + + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void confirmDeleteAllItems2ndStage(final CreatureObject ownerC, BuildingObject building) { + + final SUIWindow window = core.suiService.createMessageBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", ownerC, building, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:confirm_destruction_t"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:delete_all_items_second_d"); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@yes"); + window.setProperty("btnCancel:Text", "@no"); + Vector returnList = new Vector(); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + for (TangibleObject del : building.getItemsList()){ + core.objectService.destroyObject(del); + } + ownerC.sendSystemMessage("@player_structure:items_deleted",(byte)1); + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void handleFindLostItems(SWGObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + String displayname = "@installation_n:"+building.getStfName(); + if (building.getCustomName()!=null) + displayname = building.getCustomName(); + final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:find_items_find_all_house_items"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:structure_name_prompt" + " " + displayname); + + Vector itemList = building.getItemsList(); + final Map itemIDMapping = new HashMap(); + + for (int i=0;i returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + + int index = Integer.parseInt(returnList.get(0)); + long foundItemID = (long) itemIDMapping.get(index); + TangibleObject foundItem = (TangibleObject) core.objectService.getObject(foundItemID); + //core.simulationService.transform(foundItem,owner.getPosition()); + foundItem.setPosition(owner.getPosition()); + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + + + } + + public void handleSearchForItems(SWGObject owner, TangibleObject target) { + // Spawning the structure terminal outside makes it display the correct radial + core.staticService.spawnObject("object/tangible/terminal/shared_terminal_player_structure.iff", "tatooine", 0L, 3525.0F, 4.0F, -4800.0F, 0.70F, 0.71F); + // I assume that childobject does not get a radial somehow + + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:find_items_search_keyword_title"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:find_items_search_keyword_prompt"); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@ok"); + window.setProperty("btnCancel:Text", "@cancel"); + Vector returnList = new Vector(); + returnList.add("txtInput:LocalText"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + + String itemSearchName = (String) returnList.get(0); + Vector allItems = building.getItemsList(); + Vector foundItems = new Vector(); + + for (TangibleObject obj : allItems){ + String searchAttribute=obj.getCustomName(); + if (searchAttribute==null) + searchAttribute=obj.getTemplate(); + if (searchAttribute.toLowerCase().contains(itemSearchName.toLowerCase())){ + foundItems.add(obj); + } + } + if (foundItems.size()>0){ + ((CreatureObject) owner).sendSystemMessage("@player_structure:find_items_search_list_title", (byte) 1); + displayFoundItems(owner, target, foundItems); + } else { + ((CreatureObject) owner).sendSystemMessage("@player_structure:find_items_search_not_found", (byte) 1); + } + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void displayFoundItems(SWGObject owner, TangibleObject target, Vector foundItems) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:find_items_search_keyword_title"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:find_items_search_list_prompt"); + + Vector itemList = building.getItemsList(); + + final Map itemIDMapping = new HashMap(); + + for (int i=0;i returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void handlePermissionEntry(CreatureObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + String listName = "ENTRY"; + building.setPermissionEntry(listName,owner); + } + + public void handlePermissionBan(CreatureObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + String listName = "BAN"; + building.setPermissionBan(listName,owner); + } + + public void handlePermissionListModify(CreatureObject owner, SWGObject target, String commandArgs){ + + String[] commandSplit = commandArgs.split(" "); + if (commandSplit.length==3){ + if (core.characterService.playerExists(commandSplit[2]) && + core.characterService.getPlayerOID(commandSplit[2])>0){ + long playerOID = core.characterService.getPlayerOID(commandSplit[2]); + if (commandSplit[2].equals("ENTRY")){ + + if (commandSplit[0].equals("add")){ + ((BuildingObject)target).addPlayerToEntryList(owner, playerOID, commandSplit[2]); + } + if (commandSplit[0].equals("remove")){ + ((BuildingObject)target).removePlayerFromEntryList(owner, playerOID, commandSplit[2]); + } + } + if (commandSplit[2].equals("BAN")){ + + if (commandSplit[0].equals("add")){ + ((BuildingObject)target).addPlayerToBanList(owner, playerOID, commandSplit[2]); + } + if (commandSplit[0].equals("remove")){ + ((BuildingObject)target).removePlayerFromBanList(owner, playerOID, commandSplit[2]); + } + } + } else { + owner.sendSystemMessage(commandSplit[2]+ " is an invalid player name", (byte) 0); // modify_list_invalid_player %NO is an invalid player name. + } + } + if (commandSplit.length==2){ + owner.sendSystemMessage("No name was entered", (byte) 0); + } + + } + + public String fetchPrivacyString(TangibleObject object){ + final BuildingObject building = (BuildingObject) object.getAttachment("housing_parentstruct"); + return building.getPrivacyString(); + } @Override diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 6e11f834..f993e851 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -55,6 +55,7 @@ import org.python.core.Py; import org.python.core.PyObject; import com.sleepycat.je.Transaction; +import com.sleepycat.je.TransactionConfig; import com.sleepycat.persist.EntityCursor; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.PrimaryKey; @@ -74,6 +75,7 @@ import protocol.swg.chat.ChatOnGetFriendsList; import protocol.swg.chat.ChatRoomList; import protocol.swg.chat.ChatServerStatus; import protocol.swg.objectControllerObjects.ShowFlyText; +import protocol.swg.chat.VoiceChatStatus; import protocol.swg.objectControllerObjects.UiPlayEffect; import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.CrcStringTableVisitor; @@ -97,8 +99,12 @@ import resources.objects.Delta; import resources.objects.building.BuildingObject; import resources.objects.cell.CellObject; import resources.objects.creature.CreatureObject; +import resources.objects.deed.Harvester_Deed; +import resources.objects.deed.Player_House_Deed; import resources.objects.group.GroupObject; import resources.objects.guild.GuildObject; +import resources.objects.harvester.HarvesterObject; +import resources.objects.installation.InstallationObject; import resources.objects.intangible.IntangibleObject; import resources.objects.mission.MissionObject; import resources.objects.player.PlayerObject; @@ -315,7 +321,15 @@ public class ObjectService implements INetworkDispatch { object = new SurveyTool(objectID, planet, Template, position, orientation); - }else if(Template.startsWith("object/tangible")) { + } else if(Template.startsWith("object/tangible/deed/harvester_deed") || Template.startsWith("object/tangible/deed/generator_deed")) { + + object = new Harvester_Deed(objectID, planet, Template, position, orientation); + + } else if(Template.startsWith("object/tangible/deed/player_house_deed")) { + + object = new Player_House_Deed(objectID, planet, Template, position, orientation); + + } else if(Template.startsWith("object/tangible")) { object = new TangibleObject(objectID, planet, Template, position, orientation); @@ -371,7 +385,22 @@ public class ObjectService implements INetworkDispatch { object = new ResourceContainerObject(objectID, planet, Template, position, orientation); - }else { + } else if(Template.startsWith("object/installation/mining_ore/construction")) { + + float positionY = core.terrainService.getHeight(planet.getID(), position.x, position.z)-1f; + Point3D newpoint = new Point3D(position.x,positionY,position.z); + object = new InstallationObject(objectID, planet, Template, newpoint, orientation); + + } else if(Template.startsWith("object/installation/mining_ore") || Template.startsWith("object/installation/mining_liquid") || + Template.startsWith("object/installation/mining_gas") || Template.startsWith("object/installation/mining_organic") || + Template.startsWith("object/installation/generators")) { + + float positionY = core.terrainService.getHeight(planet.getID(), position.x, position.z)-1f; + Point3D newpoint = new Point3D(position.x,positionY,position.z); + object = new HarvesterObject(objectID, planet, Template, newpoint, orientation); + core.harvesterService.addHarvester(object); + + } else { return null; } @@ -780,7 +809,7 @@ public class ObjectService implements INetworkDispatch { objectList.put(object.getObjectID(), object); } - }); + }); if(creature.getParentId() != 0) { SWGObject parent = getObject(creature.getParentId()); @@ -806,25 +835,25 @@ public class ObjectService implements INetworkDispatch { CmdStartScene startScene = new CmdStartScene((byte) 0, objectId, creature.getPlanet().getPath(), creature.getTemplate(), position.x, position.y, position.z, core.getGalacticTime(), 0); session.write(startScene.serialize()); + ChatServerStatus chatServerStatus = new ChatServerStatus(); + client.getSession().write(chatServerStatus.serialize()); + + VoiceChatStatus voiceStatus = new VoiceChatStatus(); + client.getSession().write(voiceStatus.serialize()); + ParametersMessage parameters = new ParametersMessage(); session.write(parameters.serialize()); - creature.makeAware(core.guildService.getGuildObject()); + ChatOnConnectAvatar chatConnect = new ChatOnConnectAvatar(); + creature.getClient().getSession().write(chatConnect.serialize()); + + creature.makeAware(core.guildService.getGuildObject()); core.chatService.loadMailHeaders(client); core.simulationService.handleZoneIn(client); creature.makeAware(creature); - ChatServerStatus chatStatus = new ChatServerStatus(); - creature.getClient().getSession().write(chatStatus.serialize()); - - ChatOnConnectAvatar chatConnect = new ChatOnConnectAvatar(); - creature.getClient().getSession().write(chatConnect.serialize()); - - ChatRoomList chatRooms = new ChatRoomList(core.chatService.getChatRooms()); - creature.getClient().getSession().write(chatRooms.serialize()); - //ChatOnGetFriendsList friendsListMessage = new ChatOnGetFriendsList(ghost); //client.getSession().write(friendsListMessage.serialize()); @@ -976,7 +1005,8 @@ public class ObjectService implements INetworkDispatch { CrcStringTableVisitor crcTable = ClientFileManager.loadFile("misc/object_template_crc_string_table.iff", CrcStringTableVisitor.class); List persistentBuildings = new ArrayList(); Map duplicate = new HashMap(); - + Transaction txn = core.getDuplicateIdODB().getEnvironment().beginTransaction(null, null); + for (int i = 0; i < buildoutTable.getRowCount(); i++) { String template; @@ -1055,15 +1085,17 @@ public class ObjectService implements INetworkDispatch { newObjectId = core.getDuplicateIdODB().get(key, String.class, DuplicateId.class).getObjectId(); } else { newObjectId = generateObjectID(); - Transaction txn = core.getDuplicateIdODB().getEnvironment().beginTransaction(null, null); core.getDuplicateIdODB().put(new DuplicateId(key, newObjectId), String.class, DuplicateId.class, txn); - txn.commitSync(); } duplicate.put(objectId, newObjectId); objectId = newObjectId; } - + if(txn.isValid()) { + System.out.println("Committed doid transaction."); + txn.commitSync(); + } + List containers = new ArrayList(); SWGObject object; if(objectId != 0 && containerId == 0) { diff --git a/src/services/resources/HarvesterService.java b/src/services/resources/HarvesterService.java new file mode 100644 index 00000000..d8e028fc --- /dev/null +++ b/src/services/resources/HarvesterService.java @@ -0,0 +1,1131 @@ +/******************************************************************************* + * 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 services.resources; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Vector; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + +import protocol.swg.EnterStructurePlacementModeMessage; +import protocol.swg.SceneCreateObjectByCrc; +import protocol.swg.SceneDestroyObject; +import protocol.swg.SceneEndBaselines; +import main.NGECore; +import engine.resources.common.CRC; +import engine.resources.container.Traverser; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; +import engine.resources.service.INetworkDispatch; +import engine.resources.service.INetworkRemoteEvent; +import resources.objects.creature.CreatureObject; +import resources.objects.deed.Harvester_Deed; +import resources.objects.harvester.HarvesterMessageBuilder; +import resources.objects.harvester.HarvesterObject; +import resources.objects.installation.InstallationObject; +import resources.objects.player.PlayerObject; +import resources.objects.resource.GalacticResource; +import resources.objects.resource.ResourceContainerObject; +import resources.objects.resource.ResourceRoot; +import resources.objects.tangible.TangibleObject; +import resources.objects.waypoint.WaypointObject; +import services.chat.Mail; +import services.chat.WaypointAttachment; +import services.sui.SUIWindow; +import services.sui.SUIWindow.SUICallback; +import services.sui.SUIWindow.Trigger; + +/** + * @author Charon + */ + +public class HarvesterService implements INetworkDispatch { + + private NGECore core; + private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + + private Vector allHarvesters = new Vector(); + private Vector allConstructors = new Vector(); + + public HarvesterService(NGECore core) { + this.core = core; + //core.commandService.registerCommand("permissionlistmodify"); + //core.commandService.registerCommand("harvesterselectresource"); + //core.commandService.registerCommand("harvesteractivate"); + //core.commandService.registerCommand("harvesterdeactivate"); + //core.commandService.registerCommand("harvesterdiscardhopper"); + //core.commandService.registerCommand("harvestergetresourcedata"); + //core.commandService.registerCommand("resourceemptyhopper"); + //core.commandService.registerCommand("placestructure"); + //generateNoBuildData(); + scheduleHarvesterService(); + } + + @Override + public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { + + + } + + + public void scheduleHarvesterService(){ + + final ScheduledFuture task = scheduler.scheduleAtFixedRate(new Runnable() { + + @Override + public void run() { + ServiceProcessing(); + } + + }, 10, 5000, TimeUnit.MILLISECONDS); + + } + + public void ServiceProcessing(){ + synchronized(allHarvesters){ + for (HarvesterObject harvester : allHarvesters){ + updateHarvester(harvester); + } + } + synchronized(allConstructors){ + Vector removeConstructors = new Vector(); + for (InstallationObject constructor : allConstructors){ + boolean readyToBuild = checkBuildTime(constructor); + if (readyToBuild) + removeConstructors.add(constructor); + } + allConstructors.removeAll(removeConstructors); + } + } + + + public void addHarvester(SWGObject harvester){ + synchronized(allHarvesters){ + allHarvesters.add((HarvesterObject)harvester); + } + } + + public void removeHarvester(SWGObject harvester){ + synchronized(allHarvesters){ + allHarvesters.remove((HarvesterObject)harvester); + } + } + + public boolean checkBuildTime(InstallationObject installation){ + boolean value = false; + long startTime = (long) installation.getAttachment("ConstructionStart"); + if (startTime+50000){ + String[] helper = ownerName.split(" "); + ownerName = helper[0]; + } + + String maintenancePool_string = ""+(int)harvester.getMaintenanceAmount(); + int hourlyMaintenance = harvester.getMaintenanceCost(); + float totalNumberOfHours = (float)harvester.getMaintenanceAmount()/hourlyMaintenance; + float minuteFraction = ((totalNumberOfHours * 100) % 100) / 100; + int nDays = (int)totalNumberOfHours / 24; + float difference = totalNumberOfHours % 24; + int nHours = (int)difference; + int nMinutes = (int)(minuteFraction *60); + maintenancePool_string += " (" + nDays + " days, " + nHours + " hours, " + nMinutes + " minutes)"; + // Power reserves calculation + String powerReserves_string = ""+(int)harvester.getPowerLevel(); + int hourlyPower = harvester.getPowerCost(); + totalNumberOfHours = (float)harvester.getPowerLevel()/hourlyPower; + minuteFraction = ((totalNumberOfHours * 100) % 100) / 100; + nDays = (int)totalNumberOfHours / 24; + difference = totalNumberOfHours % 24; + nHours = (int)difference; + nMinutes = (int)(minuteFraction *60); + powerReserves_string += " (" + nDays + " days, " + nHours + " hours, " + nMinutes + " minutes)"; + + window.addListBoxMenuItem("@player_structure:owner_prompt" + " " + ownerName, 0); + window.addListBoxMenuItem("@player_structure:structure_public", 1); + window.addListBoxMenuItem("@player_structure:condition_prompt" + " " + target.getConditionDamage(), 2); + window.addListBoxMenuItem("@player_structure:maintenance_pool_prompt " + maintenancePool_string, 3); + window.addListBoxMenuItem("@player_structure:maintenance_rate_prompt " + harvester.getMaintenanceCost() + " cr/h", 4); // @player_structure:credits_per_hour + window.addListBoxMenuItem("@player_structure:maintenance_mods_prompt", 5); + window.addListBoxMenuItem("@player_structure:power_reserve_prompt " + powerReserves_string, 6); + window.addListBoxMenuItem("@player_structure:power_consumption_prompt " + harvester.getPowerCost() + " @player_structure:units_per_hour", 7); + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@ok"); + window.setProperty("btnCancel:Text", "@cancel"); + Vector returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void createPayMaintenanceSUIPage(SWGObject owner, TangibleObject target) { + CreatureObject creature = (CreatureObject) owner; + final HarvesterObject harvester = (HarvesterObject)target; + final SUIWindow window = core.suiService.createSUIWindow("Script.transfer", owner, target, 10); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:select_amount"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:select_maint_amount" + + "\n \n @player_structure:current_maint_pool : " + (int)harvester.getMaintenanceAmount()); + + window.setProperty("msgPayMaintenance", "transaction.txtInputFrom"); + + window.setProperty("transaction.lblFrom:Text", "@player_structure:total_funds"); + window.setProperty("transaction.lblTo:Text", "@player_structure:to_pay"); + window.setProperty("transaction.lblFrom", "@player_structure:total_funds"); + window.setProperty("transaction.lblTo", "@player_structure:to_pay"); + + window.setProperty("transaction.lblStartingFrom:Text", ""+creature.getCashCredits()); + window.setProperty("transaction.lblStartingTo:Text", "0"); + + window.setProperty("transaction:InputFrom", "555555"); + window.setProperty("transaction:InputTo", "666666"); + + window.setProperty("transaction:txtInputFrom", ""+creature.getCashCredits()); + window.setProperty("transaction:txtInputTo", "1"); + window.setProperty("transaction.txtInputFrom:Text", ""+creature.getCashCredits()); + window.setProperty("transaction.txtInputTo:Text", "" + "0"); + + window.setProperty("transaction.ConversionRatioFrom", "1"); + window.setProperty("transaction.ConversionRatioTo", "0"); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@ok"); + window.setProperty("btnCancel:Text", "@cancel"); + + Vector returnList = new Vector(); + returnList.add("transaction.txtInputFrom:Text"); + returnList.add("transaction.txtInputTo:Text"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject crafter = (CreatureObject)owner; + crafter.setCashCredits(crafter.getCashCredits() - Integer.parseInt(returnList.get(1))); + harvester.setMaintenanceAmount(harvester.getMaintenanceAmount()+Float.parseFloat(returnList.get(1))); + //String displayname = "@installation_n:"+harvester.getStfName(); + String displayname = "the structure"; + if (harvester.getCustomName()!=null) + displayname = harvester.getCustomName(); + crafter.sendSystemMessage("You successfully make a payment of " + Integer.parseInt(returnList.get(1)) + " credits to " + displayname + ".", (byte) 0); + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject crafter = (CreatureObject)owner; + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void createRenameSUIPage(SWGObject owner, TangibleObject target) { + //updateHarvester(owner, target); + final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); + Vector returnList = new Vector(); + returnList.add("txtInput:LocalText"); + final TangibleObject outerSurveyTool = target; + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.harvesterService.handleSetName((CreatureObject)owner, (TangibleObject)outerSurveyTool,returnList.get(0)); + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + + public void createDestroySUIPage(final SWGObject owner, final TangibleObject target) { + + // "\\#32CD32 @player_structure:confirm_destruction_d3b \#" + + final HarvesterObject harvester = (HarvesterObject)target; + // harvester.getStfFilename(); installation_n .getTemplate(); + String displayname = "@installation_n:"+harvester.getStfName(); + if (harvester.getCustomName()!=null) + displayname = harvester.getCustomName(); + final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", displayname); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:confirm_destruction_d1 " + + "@player_structure:confirm_destruction_d2 " + + "\n \n @player_structure:confirm_destruction_d3a " + + "\\#32CD32 @player_structure:confirm_destruction_d3b \\#FFFFFF " + + "@player_structure:confirm_destruction_d4 "); + if (harvester.getConditionDamage()<20 && harvester.getMaintenanceAmount()<3000){ + window.addListBoxMenuItem("@player_structure:redeed_confirmation \\#BB0000 @player_structure:can_redeed_no_suffix \\#FFFFFF ",1 ); + } else { + window.addListBoxMenuItem("@player_structure:redeed_confirmation \\#32CD32 @player_structure:can_redeed_yes_suffix \\#FFFFFF ",1 ); + } + if (harvester.getConditionDamage()<20){ + window.addListBoxMenuItem("@player_structure:redeed_condition \\#BB0000 " + harvester.getConditionDamage() + " \\#FFFFFF ",1 ); + } else { + window.addListBoxMenuItem("@player_structure:redeed_condition \\#32CD32 " + harvester.getConditionDamage() + " \\#FFFFFF ",1 ); + } + if (harvester.getMaintenanceAmount()<0){ + window.addListBoxMenuItem("@player_structure:redeed_maintenance \\#BB0000 " + (int)harvester.getMaintenanceAmount() + " \\#FFFFFF ",2 ); + } else { + window.addListBoxMenuItem("@player_structure:redeed_maintenance \\#32CD32 " + (int)harvester.getMaintenanceAmount() + " \\#FFFFFF ",2 ); + } + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@yes"); + window.setProperty("btnCancel:Text", "@no"); + Vector returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + createCodeWindow(owner, target); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void createCodeWindow(SWGObject owner, TangibleObject target) { + + // "\\#32CD32 @player_structure:confirm_destruction_d3b \#" + + final HarvesterObject harvester = (HarvesterObject)target; + // harvester.getStfFilename(); installation_n .getTemplate(); + Random rnd = new Random(); + final int confirmCode = 100000 + rnd.nextInt(900000); + final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:confirm_destruction_t"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:your_structure_prefix " + + "\\#32CD32 @player_structure:will_redeed_confirm \\#FFFFFF "+ + "@player_structure:will_redeed_suffix " + + "\n \n Code: " + confirmCode); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@yes"); + window.setProperty("btnCancel:Text", "@no"); + Vector returnList = new Vector(); + returnList.add("txtInput:LocalText"); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject crafter = (CreatureObject)owner; + core.suiService.closeSUIWindow(owner, 0); + if (returnList.get(0).equals(""+confirmCode)){ + // handle creation of correct deed in player inventory + PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost"); + String deedTemplate = harvester.getDeedTemplate(); + Harvester_Deed deed = (Harvester_Deed)core.objectService.createObject(deedTemplate, owner.getPlanet()); + if(player.getLotsRemaining()+deed.getLotRequirement()>10){ + // Something went wrong or hacking attempt + crafter.sendSystemMessage("Structure can't be redeeded. Maximum lot count exceeded.",(byte)1); + return; + } + + deed.setStructureTemplate(harvester.getTemplate()); + deed.setOutputHopperCapacity(harvester.getOutputHopperCapacity()); + deed.setBER(harvester.getBER()); + deed.setSurplusMaintenance((int)harvester.getMaintenanceAmount()); + deed.setSurplusPower((int)harvester.getPowerLevel()); + deed.setAttributes(); + + core.objectService.destroyObject(harvester.getObjectID()); + + SWGObject crafterInventory = owner.getSlottedObject("inventory"); + crafterInventory.add(deed); + + if(player.getLotsRemaining()+deed.getLotRequirement()<=10) + player.setLotsRemaining(player.getLotsRemaining()+deed.getLotRequirement()); + + crafter.sendSystemMessage("@player_structure:processing_destruction",(byte)1); + crafter.sendSystemMessage("@player_structure:deed_reclaimed",(byte)1); + + } else { + crafter.sendSystemMessage("@player_structure:incorrect_destroy_code",(byte)1); + } + + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void handleOperateMachinery(CreatureObject owner, TangibleObject target) { + + HarvesterObject harvester = (HarvesterObject) target; + harvester.operateMachinery(owner); + } + + public void handleDestroy(SWGObject owner, TangibleObject target) { + + HarvesterObject harvester = (HarvesterObject) target; + // Assemble resources at that spot + // For later, it might be needed to also pass the template to differentiate liquid resources + Vector planetVector = core.resourceService.getSpawnedResourcesByPlanetAndHarvesterType(target.getPlanetId(),harvester.getHarvester_type()); + HarvesterMessageBuilder messenger = new HarvesterMessageBuilder((HarvesterObject)target); + owner.getClient().getSession().write(messenger.buildHINOBaseline7((HarvesterObject)target, planetVector)); + } + + public void handleSetName(CreatureObject owner, TangibleObject target,String name) { + + ((HarvesterObject) target).setHarvesterName(name,owner); + } + + public void handleDepositPower(SWGObject owner, TangibleObject target) { + + CreatureObject creature = (CreatureObject) owner; + final HarvesterObject harvester = (HarvesterObject) target; + int playerEnergyLevel = 0; + playerEnergyLevel = calculateTotalPlayerEnergy(creature); + + final SUIWindow window = core.suiService.createSUIWindow("Script.transfer", owner, target, 10); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:add_power"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:select_power_amount"+ + "\n \n @player_structure:current_power_value " + (int)harvester.getPowerLevel()); + window.setProperty("transaction.txtInputFrom:Text", "" + playerEnergyLevel); + window.setProperty("transaction.txtInputTo:Text", "" + "0"); + window.setProperty("transaction.lblFrom:Text", "@player_structure:total_energy"); + window.setProperty("transaction.lblTo:Text", "@player_structure:to_deposit"); + window.setProperty("transaction:InputFrom", "5555"); + window.setProperty("transaction:InputTo", "6666"); + window.setProperty("transaction.lblStartingFrom:Text", ""+playerEnergyLevel); + window.setProperty("transaction.lblStartingTo:Text", "0"); + window.setProperty("transaction.ConversionRatioFrom", "0"); + window.setProperty("transaction.ConversionRatioTo", "1"); + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@ok"); + window.setProperty("btnCancel:Text", "@cancel"); + + Vector returnList = new Vector(); + returnList.add("transaction.txtInputFrom:Text"); + returnList.add("transaction.txtInputTo:Text"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject crafter = (CreatureObject)owner; + harvester.setPowerLevel(harvester.getPowerLevel()+Integer.parseInt(returnList.get(1))); + updateEnergyInventoryContainers(crafter,Integer.parseInt(returnList.get(1))); + crafter.sendSystemMessage("You successfully deposit " + Integer.parseInt(returnList.get(1)) + " units of energy.", (byte) 0); + crafter.sendSystemMessage("Energy reserves now at " + (int)harvester.getPowerLevel() + " units.", (byte) 0); + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public int calculateTotalPlayerEnergy(CreatureObject owner){ + // final int energy = 0; Doesn't work with generic types + int energy = 0; + final Vector energyVector = new Vector(); + TangibleObject playerInventory = (TangibleObject) owner.getSlottedObject("inventory"); + playerInventory.viewChildren(owner, false, false, new Traverser() { + @Override + public void process(SWGObject obj) { + + if (obj instanceof ResourceContainerObject){ + ResourceContainerObject container = (ResourceContainerObject) obj; + if (container.getResourceClass()==null)System.out.println("container.getResourceClass()==null " + container.getTemplate()); + if (container.getResourceClass().equals("Radioactive") || + container.getResourceClass().equals("Wind Renewable Energy") || + container.getResourceClass().equals("Solar Renewable Energy") || + container.getResourceClass().equals("Geothermal Renewable Energy") || + container.getResourceClass().equals("Tidal Renewable Energy") || + container.getResourceClass().equals("Hydron-3 Renewable Energy")) { + energyVector.add(container.getStackCount()); + } + } + } + /* + public void process(SWGObject a1) { + if(!(a1 instanceof PlayerObject) && a1 != null) { + if(a1.getClient() != null && a1 != a.this$0) { + a1.makeAware(a.this$0); + } + a.this$0.makeAware(a1); + } + } + } + */ + }); + + for (Integer value : energyVector){ + energy += value; + } + return energy; + } + + /* + * This is deducting the deposited power from the inventory + */ + public void updateEnergyInventoryContainers(SWGObject owner, int deductedEnergy){ + + final Vector containerVector = new Vector(); + TangibleObject playerInventory = (TangibleObject) owner.getSlottedObject("inventory"); + playerInventory.viewChildren(owner, false, false, new Traverser() { + @Override + public void process(SWGObject obj) { + // is energy resource? + if (obj instanceof ResourceContainerObject){ + ResourceContainerObject container = (ResourceContainerObject) obj; + if (container.getResourceClass().equals("Radioactive") || + container.getResourceClass().equals("Wind Renewable Energy") || + container.getResourceClass().equals("Solar Renewable Energy") || + container.getResourceClass().equals("Geothermal Renewable Energy") || + container.getResourceClass().equals("Tidal Renewable Energy") || + container.getResourceClass().equals("Hydron-3 Renewable Energy")) { + containerVector.add(container); + } + } + } + }); + + Comparator comp = new ResourceContainerObjectComparator(); + Collections.sort(containerVector, comp); + + for (int i=containerVector.size()-1;i >= 0; i--){ + int containerEnergy = containerVector.get(i).getStackCount(); + if (containerEnergy <= deductedEnergy){ + deductedEnergy -= containerEnergy; + playerInventory.remove(containerVector.get(i)); + } else { + containerEnergy -= deductedEnergy; + containerVector.get(i).setStackCount(containerEnergy,(CreatureObject)owner); + playerInventory._remove(containerVector.get(i)); + playerInventory._add(containerVector.get(i)); + +// ResourceMessenger messenger = new ResourceMessenger(IoBuffer.allocate(1)); +// owner.getClient().getSession().write(messenger.serialize_buildRCNO3Delta(containerVector.get(i).getObjectID(),containerEnergy)); + } + } + } + + public class ResourceContainerObjectComparator implements Comparator { + + @Override + public int compare(ResourceContainerObject b1, ResourceContainerObject b2) { + if (b1.getStackCount() == b2.getStackCount()) { + return 0; + } + if (b1.getStackCount() > b2.getStackCount()) { + return 1; + } + if (b1.getStackCount() < b2.getStackCount()) { + return -1; + } + return 0; + } + } + + public void handlePermissionAdmin(CreatureObject owner, TangibleObject target) { + + String listName = "ADMIN"; + ((HarvesterObject) target).setPermissionAdmin(listName,owner); + } + + public void handlePermissionHopper(CreatureObject owner, TangibleObject target) { + + String listName = "HOPPER"; + ((HarvesterObject) target).setPermissionHopper(listName,owner); + } + + public void handlePermissionListModify(CreatureObject crafter, SWGObject target, String commandArgs){ + + String[] commandSplit = commandArgs.split(" "); + if (commandSplit.length==3){ + if (core.characterService.playerExists(commandSplit[2])){ + if (commandSplit[2].equals("ADMIN")){ + Vector adminList = ((HarvesterObject)target).getAdminList(); + if (commandSplit[0].equals("add") && (!adminList.contains(commandSplit[2]))){ + crafter.sendSystemMessage(commandSplit[2] + " added as administrator", (byte) 0); + adminList.add(commandSplit[2]); + ((HarvesterObject)target).setAdminList(adminList); + } + if (commandSplit[0].equals("remove") && (adminList.contains(commandSplit[2]))){ + crafter.sendSystemMessage(commandSplit[2] + " removed as administrator", (byte) 0); + adminList.remove(commandSplit[2]); + ((HarvesterObject)target).setAdminList(adminList); + } + } + if (commandSplit[2].equals("HOPPER")){ + Vector hopperList = ((HarvesterObject)target).getHopperList(); + if (commandSplit[0].equals("add") && (!hopperList.contains(commandSplit[2]))){ + crafter.sendSystemMessage(commandSplit[2] + " added as administrator", (byte) 0); + hopperList.add(commandSplit[2]); + ((HarvesterObject)target).setHopperList(hopperList); + } + if (commandSplit[0].equals("remove") && (hopperList.contains(commandSplit[2]))){ + crafter.sendSystemMessage(commandSplit[2] + " removed as administrator", (byte) 0); + hopperList.remove(commandSplit[2]); + ((HarvesterObject)target).setHopperList(hopperList); + } + } + } else { + crafter.sendSystemMessage(commandSplit[2]+ " is an invalid player name", (byte) 0); + } + } + if (commandSplit.length==2){ + crafter.sendSystemMessage("No name was entered", (byte) 0); + } + + } + + public void handleHarvesterSelectResourceCommand(CreatureObject owner, SWGObject target, String commandArgs){ + + long selectedResourceId = Long.parseLong(commandArgs); + GalacticResource resource = core.resourceService.findResourceById(selectedResourceId); + ((HarvesterObject) target).setSelectedHarvestResource(resource,owner); + } + + public void handleHarvesterActivateCommand(CreatureObject owner, SWGObject target, String commandArgs){ + + + if (((HarvesterObject)target).getPowerLevel()<=0 && !((HarvesterObject)target).isGenerator()){ + ((CreatureObject)owner).sendSystemMessage("The installation is lacking power.", (byte) 0); + return; + } + if (((HarvesterObject)target).getMaintenanceAmount()<=0){ + ((CreatureObject)owner).sendSystemMessage("The installation is lacking maintenance.", (byte) 0); + return; + } + + + ((HarvesterObject)target).activateHarvester(owner); + } + + public void handleHarvesterDeactivateCommand(CreatureObject owner, SWGObject target, String commandArgs){ + + ((HarvesterObject)target).deactivateHarvester(owner); + } + + public void handleEmptyHopper(CreatureObject owner,SWGObject target,long harvesterId, long resourceId, int stackcount, byte actionMode, byte updateCount){ + + HarvesterMessageBuilder messenger = new HarvesterMessageBuilder((HarvesterObject)target); + //DiscardResourceResponse + owner.getClient().getSession().write(messenger.buildDiscardResourceResponse((HarvesterObject)target, actionMode, updateCount,owner)); + + + ResourceContainerObject foundContainer = null; + Vector hopperContent = ((HarvesterObject) target).getOutputHopperContent(); + for (ResourceContainerObject cont : hopperContent){ + if (cont.getReferenceID()==resourceId){ + foundContainer = cont; + } + } + if (foundContainer==null) + return; // something went wrong + + if (foundContainer.getStackCount()==stackcount){ + ((HarvesterObject) target).setCurrentHarvestedCountFloat(1); + foundContainer.setStackCount(0, owner); + } else { + ((HarvesterObject) target).setCurrentHarvestedCountFloat(foundContainer.getStackCount()-stackcount); + foundContainer.setStackCount(foundContainer.getStackCount()-stackcount,owner); + } + ((HarvesterObject) target).setOutputHopperContent(hopperContent); + + // <<< + Vector planetResourcesVector = core.resourceService.getSpawnedResourcesByPlanetAndHarvesterType(target.getPlanetId(),((HarvesterObject)target).getHarvester_type()); + owner.getClient().getSession().write(messenger.buildHINOBaseline7((HarvesterObject)target, planetResourcesVector)); + owner.getClient().getSession().write(messenger.buildHINO7ExperimentalDelta2((HarvesterObject)target)); + // >> + + hopperContent = ((HarvesterObject) target).getOutputHopperContent(); + for (ResourceContainerObject cont : hopperContent){ + if (cont.getReferenceID()==resourceId){ + foundContainer = cont; + } + } + + // create retrieved resource container + GalacticResource sampleResource = core.resourceService.findResourceById(resourceId); + String resourceContainerIFF = ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[sampleResource.getResourceRoot().getContainerType()]; + ResourceContainerObject containerObject = (ResourceContainerObject) core.objectService.createObject(resourceContainerIFF, owner.getPlanet()); + containerObject.initializeStats(sampleResource); + containerObject.setProprietor(owner); + containerObject.setStackCount(stackcount,owner); + containerObject.setIffFileName(resourceContainerIFF); + SWGObject crafterInventory = owner.getSlottedObject("inventory"); +// containerObject.sendBaselines(owner.getClient()); +// SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(containerObject.getObjectID()); +// owner.getClient().getSession().write(sceneEndBaselinesMsg.serialize()); +// tools.CharonPacketUtils.printAnalysis(sceneEndBaselinesMsg.serialize()); + crafterInventory.add(containerObject); + } + + + public void handleEmptyHarvester(CreatureObject owner, SWGObject target, String commandArgs){ + + HarvesterMessageBuilder messenger = new HarvesterMessageBuilder((HarvesterObject)target); + Vector hopperContent = ((HarvesterObject) target).getOutputHopperContent(); + Vector deleteContent = new Vector(); + + for (ResourceContainerObject cont : hopperContent){ + ResourceContainerObject foundContainer = cont; + + if (foundContainer==null) + return; // something went wrong + + long resourceId = foundContainer.getReferenceID(); + int stackcount = foundContainer.getStackCount(); + + SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(resourceId); + owner.getClient().getSession().write(destroyObjectMsg.serialize()); + + // create retrieved resource container + GalacticResource sampleResource = core.resourceService.findResourceById(resourceId); + String resourceContainerIFF = ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[sampleResource.getResourceRoot().getContainerType()]; + ResourceContainerObject containerObject = (ResourceContainerObject) core.objectService.createObject(resourceContainerIFF, owner.getPlanet()); + containerObject.initializeStats(sampleResource); + containerObject.setProprietor(owner); + containerObject.setStackCount(stackcount,owner); + int resCRC = CRC.StringtoCRC(resourceContainerIFF); + containerObject.setIffFileName(resourceContainerIFF); + + long objectId = containerObject.getObjectID(); + SWGObject crafterInventory = owner.getSlottedObject("inventory"); + +// SceneCreateObjectByCrc createObjectMsg = new SceneCreateObjectByCrc(objectId, owner.getOrientation().x, owner.getOrientation().y, owner.getOrientation().z, owner.getOrientation().w, owner.getPosition().x, owner.getPosition().y, owner.getPosition().z, resCRC, (byte) 0); +// owner.getClient().getSession().write(createObjectMsg.serialize()); +// tools.CharonPacketUtils.printAnalysis(createObjectMsg.serialize()); +// +// containerObject.sendBaselines(owner.getClient()); +// +// SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(containerObject.getObjectID()); +// owner.getClient().getSession().write(sceneEndBaselinesMsg.serialize()); +// tools.CharonPacketUtils.printAnalysis(sceneEndBaselinesMsg.serialize()); + + crafterInventory.add(containerObject); + + if (cont.getReferenceID()!=((HarvesterObject) target).getSelectedHarvestResource().getId()){ + deleteContent.add(cont); + } else { + ((HarvesterObject) target).setCurrentHarvestedCountFloat(0); + foundContainer.setStackCount(0,owner); + } + } + hopperContent.removeAll(deleteContent); + + ((HarvesterObject) target).setOutputHopperContent(hopperContent); + + Vector planetResourcesVector = core.resourceService.getSpawnedResourcesByPlanetAndHarvesterType(target.getPlanetId(),((HarvesterObject)target).getHarvester_type()); + owner.getClient().getSession().write(messenger.buildHINOBaseline7((HarvesterObject)target, planetResourcesVector)); + owner.getClient().getSession().write(messenger.buildHINO7ExperimentalDelta2((HarvesterObject)target)); + } + + public void updateHarvester(HarvesterObject harvester){ + + CreatureObject owner = (CreatureObject)core.objectService.getObject(harvester.getOwner()); + + if(harvester.isActivated()) + { + // Check maintenance and power + if (harvester.getMaintenanceAmount()<=0){ + owner.sendSystemMessage("The installation is lacking maintenance.", (byte) 0); + // ToDo: Send mail + harvester.deactivateHarvester(owner); + return; + } + + if (harvester.getPowerLevel()<=0 && !harvester.isGenerator()){ + owner.sendSystemMessage("The installation is lacking power.", (byte) 0); + // ToDo: Send mail + harvester.deactivateHarvester(owner); + return; + } + + harvester.setMaintenanceAmount(harvester.getMaintenanceAmount()-(harvester.getMaintenanceCost()/3600.0F)); + harvester.setPowerLevel(harvester.getPowerLevel()-(harvester.getPowerCost()/3600.0F)); + + Vector outputHopperContent = harvester.getOutputHopperContent(); + GalacticResource currentResource = harvester.getSelectedHarvestResource(); + ResourceContainerObject hopperContainer = hopperHasContainer(currentResource, outputHopperContent); + // check if output hopper contains already a container with the selected harvest resource + if(hopperContainer==null) + { + + //ResourceContainerObject container = new ResourceContainerObject(); + String resourceContainerIFF = ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[currentResource.getResourceRoot().getContainerType()]; + ResourceContainerObject container = (ResourceContainerObject) core.objectService.createObject(resourceContainerIFF, harvester.getPlanet()); + container.initializeStats(harvester.getSelectedHarvestResource()); + container.setStackCount(0,false); + harvester.setCurrentHarvestedCountFloat(0.0F); + outputHopperContent.add(container); + harvester.setOutputHopperContent(outputHopperContent); + harvester.createNewHopperContainer(); + + } else { + + harvester.continueHopperContainer(); + + // add harvested amount + int BER = harvester.getBER(); + //BER = 15; + float minuteRate = harvester.getActualExtractionRate(); + float updateRate = minuteRate / 60; + harvester.setCurrentHarvestedCountFloat(harvester.getCurrentHarvestedCountFloat()+updateRate); + + int oldStackCount = hopperContainer.getStackCount(); + int newStackCount = (int) (harvester.getCurrentHarvestedCountFloat()); + if (newStackCount>oldStackCount){ + for (ResourceContainerObject iterContainer : outputHopperContent){ + if (iterContainer.getReferenceID()==hopperContainer.getReferenceID()){ + iterContainer.setStackCount(newStackCount,owner); // updates collection + } + } + harvester.setOutputHopperContent(outputHopperContent); + //((CreatureObject)harvester.getOwner()).getClient().getSession().write(messenger.buildHINO7ExperimentalDelta2(harvester)); + } + harvester.setCurrentHarvestedCountFloat(harvester.getCurrentHarvestedCountFloat()+updateRate); + } + } + } + + private ResourceContainerObject hopperHasContainer(GalacticResource resource, Vector outputHopperContent){ + ResourceContainerObject container = null; + for (ResourceContainerObject iterContainer : outputHopperContent){ + if (iterContainer.getReferenceID()==resource.getId()){ + return iterContainer; + } + } + return container; + } + + + public void constructionSite(CreatureObject actor,SWGObject target, long objectId, float posX, float posZ, float dir){ + + SWGObject usedDeed = (SWGObject)actor.getAttachment("LastUsedDeed"); + String constructorTemplate = ((Harvester_Deed)usedDeed).getConstructorTemplate(); + //String structureTemplate = "object/installation/mining_ore/construction/shared_construction_mining_ore_harvester_style_1.iff"; + + float positionY = core.terrainService.getHeight(actor.getPlanetId(), posX, posZ) + 2f; + Quaternion quaternion = new Quaternion(1, 0, 0, 0); + quaternion = resources.common.MathUtilities.rotateQuaternion(quaternion, (float)((Math.PI/2) * dir), new Point3D(0, 1, 0)); + InstallationObject installation = (InstallationObject) core.objectService.createObject(constructorTemplate, 0, actor.getPlanet(), new Point3D(posX, positionY, posZ), quaternion); + + + installation.setAttachment("ConstructionStart", System.currentTimeMillis()); + installation.setAttachment("Owner", actor); + installation.setAttachment("Deed_StructureTemplate", ((Harvester_Deed)usedDeed).getStructureTemplate()); + installation.setAttachment("Deed_DeedTemplate", ((Harvester_Deed)usedDeed).getTemplate()); + installation.setAttachment("Deed_BER", ((Harvester_Deed)usedDeed).getBER()); + installation.setAttachment("Deed_Capacity", ((Harvester_Deed)usedDeed).getOutputHopperCapacity()); + installation.setAttachment("Deed_DeedLots", ((Harvester_Deed)usedDeed).getLotRequirement()); + installation.setAttachment("Deed_SurplusMaintenance", ((Harvester_Deed)usedDeed).getSurplusMaintenance()); + installation.setAttachment("Deed_SurplusPower", ((Harvester_Deed)usedDeed).getSurplusPower()); + + // destroy deed + TangibleObject playerInventory = (TangibleObject) actor.getSlottedObject("inventory"); + playerInventory.remove(usedDeed); + + core.simulationService.add(installation, posX, posZ, true); + + PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); + player.setLotsRemaining(player.getLotsRemaining()-(int)((Harvester_Deed)usedDeed).getLotRequirement()); + synchronized(allConstructors){ + allConstructors.add(installation); + } + } + + public void placeHarvester(SWGObject object) { + CreatureObject actor = (CreatureObject) object.getAttachment("Owner"); + String structureTemplate = (String)object.getAttachment("Deed_StructureTemplate"); + HarvesterObject harvester = (HarvesterObject) NGECore.getInstance().objectService.createObject(structureTemplate, actor.getPlanet()); + long objectId = harvester.getObjectID(); + Vector adminList = harvester.getAdminList(); + //String[] fullName = ((CreatureObject)actor).getCustomName().split(" "); + adminList.add(actor.getCustomName()); + // Set BER and outputhopper capacity here, take it from deed + harvester.setBER((int)object.getAttachment("Deed_BER")); + harvester.setSpecRate((int)(1.5F*(int)object.getAttachment("Deed_BER"))); + harvester.setOutputHopperCapacity((int)object.getAttachment("Deed_Capacity")); + harvester.setDeedTemplate((String)object.getAttachment("Deed_DeedTemplate")); + if ((int)object.getAttachment("Deed_SurplusMaintenance")>0){ + harvester.setMaintenanceAmount((int)object.getAttachment("Deed_SurplusMaintenance")); + } + if ((int)object.getAttachment("Deed_SurplusPower")>0){ + harvester.setPowerLevel((int)object.getAttachment("Deed_SurplusPower")); + } + + + // build harvester + float positionY = NGECore.getInstance().terrainService.getHeight(actor.getPlanetId(), object.getPosition().x, object.getPosition().z); + harvester.setPosition(new Point3D(object.getPosition().x,positionY, object.getPosition().z)); + core.simulationService.add(harvester, harvester.getPosition().x, harvester.getPosition().z, true); + PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); + WaypointObject constructionWaypoint = (WaypointObject)NGECore.getInstance().objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", actor.getPlanet(), harvester.getPosition().x, 0 ,harvester.getPosition().z); + String displayname = "@installation_n:"+harvester.getStfName(); + constructionWaypoint.setName(displayname); + constructionWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName())); + constructionWaypoint.setPosition(new Point3D(object.getPosition().x,0, object.getPosition().z)); + player.waypointAdd(constructionWaypoint); + constructionWaypoint.setPosition(new Point3D(object.getPosition().x,0, object.getPosition().z)); + constructionWaypoint.setActive(true); + constructionWaypoint.setColor((byte)1); + constructionWaypoint.setStringAttribute("", ""); + player.waypointAdd(constructionWaypoint); + constructionWaypoint.setName(displayname); + constructionWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName())); + player.setLastSurveyWaypoint(constructionWaypoint); + + List attachments = new ArrayList(); + WaypointAttachment attachment = new WaypointAttachment(); + attachment.active = true; + attachment.cellID = constructionWaypoint.getCellId(); + attachment.color = (byte)1; + attachment.name = displayname; + attachment.planetCRC = engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName()); + attachment.positionX = object.getPosition().x; + attachment.positionY = 0; + attachment.positionZ = object.getPosition().z; + attachments.add(attachment); + + // remove constructor + NGECore.getInstance().objectService.destroyObject(object); + + // ToDo: waypoint attachment fix + Date date = new Date(); + Mail constructionNotificationMail = new Mail(); + constructionNotificationMail.setSenderName("Structure Service"); + constructionNotificationMail.setSubject("Your structure"); + constructionNotificationMail.setRecieverId(actor.getObjectID()); + constructionNotificationMail.setTimeStamp((int) (date.getTime() / 1000)); + constructionNotificationMail.setMailId(NGECore.getInstance().chatService.generateMailId()); + String message = "Your construction is ready"; + constructionNotificationMail.setMessage(message); + constructionNotificationMail.setStatus(Mail.NEW); + constructionNotificationMail.setAttachments(attachments); + //NGECore.getInstance().chatService.sendPersistentMessage(actor.getClient(), constructionNotificationMail); + NGECore.getInstance().chatService.storePersistentMessage(constructionNotificationMail); + NGECore.getInstance().chatService.sendPersistentMessageHeader(actor.getClient(), constructionNotificationMail); + } + + + public void enterStructurePlacementMode(SWGObject object, CreatureObject actor){ + + if (!core.terrainService.canBuildAtPosition(actor,actor.getPosition().x,actor.getPosition().z)){ + actor.sendSystemMessage("@player_structure:not_permitted", (byte) 0); + return; + } + + PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); + if (((Harvester_Deed)object).getLotRequirement()>player.getLotsRemaining()){ + actor.sendSystemMessage("@player_structure:not_enough_lots", (byte) 0); + return; + } + + actor.setAttachment("LastUsedDeed", object); + String structureTemplate = ((Harvester_Deed)object).getStructureTemplate(); + //String temp = "object/installation/mining_ore/shared_mining_ore_harvester_style_1.iff"; + EnterStructurePlacementModeMessage placementMsg = new EnterStructurePlacementModeMessage(actor,structureTemplate); + actor.getClient().getSession().write(placementMsg.serialize()); + } + + + public void handlePlaceStructureCommand(CreatureObject crafter, SWGObject target, String commandArgs){ + + // 511379 3516.08 -4804.08 0 + // Split Args by Delimiter + long objectId = crafter.getObjectID(); + float posX = crafter.getPosition().x; + float posZ = crafter.getPosition().z; + float dir = 0; + String[] splitter = commandArgs.split(" "); + if (splitter.length==4){ //QA + objectId = Long.parseLong(splitter[0]); + posX = Float.parseFloat(splitter[1]); + posZ = Float.parseFloat(splitter[2]); + dir = Float.parseFloat(splitter[3]); + } + + constructionSite(crafter, target, objectId, posX, posZ, dir); + } + + + // helper method to simulate a harvester deed in the player inventory + // that contains BER,cap,template info about the harvester + public void createExampleDeed(CreatureObject actor){ + + String templateString="object/tangible/deed/harvester_deed/shared_harvester_ore_s1_deed.iff"; + Harvester_Deed deed = (Harvester_Deed)core.objectService.createObject(templateString, actor.getPlanet()); + deed.setName("Example Harvester Deed"); + deed.setStructureTemplate("object/installation/mining_ore/shared_mining_ore_harvester_style_1.iff"); + deed.setOutputHopperCapacity(27344); + deed.setBER(15); + + TangibleObject playerInventory = (TangibleObject) actor.getSlottedObject("inventory"); + playerInventory.add(deed); + + deed.setParent(playerInventory); + + core.resourceService.spawnSpecificResourceContainer("Radioactive", actor, 50); + core.resourceService.spawnSpecificResourceContainer("Radioactive", actor, 501); + core.resourceService.spawnSpecificResourceContainer("Radioactive", actor, 3); + core.resourceService.spawnSpecificResourceContainer("Radioactive", actor, 66); +// core.resourceService.spawnSpecificResourceContainer("Steel", actor, 50); +// core.resourceService.spawnSpecificResourceContainer("Fiberplast", actor, 50); + + } + + + // Stress Test (Server) for many harvesters running in the service + // 200 are running fine, 400 also + public void moduleTestManyHarvesters(CreatureObject actor){ + // assuming an average number of 200 harvesters per planet + for (int i=0;i<400;i++){ + createSingleTestHarvester(actor,i); + } + } + + public void createSingleTestHarvester(CreatureObject actor,int counter){ + // determine random position + String structureTemplate = "object/installation/mining_ore/shared_mining_ore_harvester_style_1.iff"; + HarvesterObject harvester = (HarvesterObject) core.objectService.createObject(structureTemplate, actor.getPlanet()); + long objectId = harvester.getObjectID(); + Vector adminList = harvester.getAdminList(); + String[] fullName = ((CreatureObject)actor).getCustomName().split(" "); + adminList.add(fullName[0]); + harvester.setAdminList(adminList); + // Set BER and outputhopper capacity here, take it from deed + harvester.setBER(8); + harvester.setOutputHopperCapacity(27344); + harvester.setMaintenanceAmount(2993); + harvester.setMaintenanceCost(30); + harvester.setPowerLevel(14714); + harvester.setPowerCost(25); + + Random generator = new Random(); + generator = new Random(); // Exclude mountains at the edge of the maps + int spawnCoordsX = generator.nextInt(15000) - 7500; + int spawnCoordsZ = generator.nextInt(15000) - 7500; + + // build harvester + int resCRC = CRC.StringtoCRC(structureTemplate); + Quaternion quaternion = new Quaternion(1, 0, 0, 0); + quaternion = resources.common.MathUtilities.rotateQuaternion(quaternion, (float)((Math.PI/2) * 1), new Point3D(0, 1, 0)); + float positionY = core.terrainService.getHeight(actor.getPlanetId(), spawnCoordsX, spawnCoordsZ)+ 2f; + SceneCreateObjectByCrc createObjectMsg = new SceneCreateObjectByCrc(objectId,quaternion.x,quaternion.y, quaternion.z, quaternion.w, spawnCoordsX, positionY, spawnCoordsZ, resCRC, (byte) 0); + actor.getClient().getSession().write(createObjectMsg.serialize()); + tools.CharonPacketUtils.printAnalysis(createObjectMsg.serialize()); + + resources.objects.installation.InstallationMessageBuilder messenger = new resources.objects.installation.InstallationMessageBuilder((InstallationObject)harvester); + actor.getClient().getSession().write(messenger.buildBaseline3((InstallationObject)harvester)); + SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(harvester.getObjectID()); + actor.getClient().getSession().write(sceneEndBaselinesMsg.serialize()); + tools.CharonPacketUtils.printAnalysis(sceneEndBaselinesMsg.serialize()); + + // select resource + long selectedResourceId = core.resourceService.getAllSpawnedResources().get(51).getId(); + GalacticResource resource = core.resourceService.findResourceById(selectedResourceId); + harvester.setSelectedHarvestResource(resource,actor); + + + // activate harvester + harvester.activateHarvester(actor); + HarvesterMessageBuilder messenger2 = new HarvesterMessageBuilder(harvester); + actor.getClient().getSession().write(messenger2.buildHINO3Delta(harvester,(byte)1)); + actor.getClient().getSession().write(messenger2.buildHINO7ActivateDelta2(harvester)); + + + //create waypoint + if (counter<200){ + PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); + WaypointObject constructionWaypoint = (WaypointObject)core.objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", actor.getPlanet(), harvester.getPosition().x, 0 ,harvester.getPosition().z); + String displayname = "@installation_n:"+harvester.getStfName() + " " + counter; + constructionWaypoint.setName(displayname); + constructionWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName())); + constructionWaypoint.setPosition(new Point3D(spawnCoordsX,0, spawnCoordsZ)); + player.waypointAdd(constructionWaypoint); + constructionWaypoint.setPosition(new Point3D(spawnCoordsX,0, spawnCoordsZ)); + constructionWaypoint.setActive(true); + constructionWaypoint.setColor((byte)1); + constructionWaypoint.setStringAttribute("", ""); + player.waypointAdd(constructionWaypoint); + constructionWaypoint.setName(displayname); + constructionWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName())); + player.setLastSurveyWaypoint(constructionWaypoint); + } + + allHarvesters.add(harvester); + } + + @Override + public void shutdown() { + // TODO Auto-generated method stub + + } +} \ No newline at end of file diff --git a/src/services/resources/ResourceService.java b/src/services/resources/ResourceService.java index efc62fe1..8b06a4a0 100644 --- a/src/services/resources/ResourceService.java +++ b/src/services/resources/ResourceService.java @@ -28,13 +28,16 @@ import java.util.Random; import java.util.Vector; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; + import com.sleepycat.persist.EntityCursor; + import main.NGECore; import engine.resources.common.CRC; import engine.resources.objects.SWGObject; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import resources.objects.creature.CreatureObject; +import resources.objects.harvester.HarvesterObject; import resources.objects.resource.GalacticResource; import resources.objects.resource.ResourceContainerObject; import resources.objects.resource.ResourceRoot; @@ -11306,6 +11309,36 @@ public class ResourceService implements INetworkDispatch { return resource; } + public Vector getSpawnedResourcesByPlanetAndHarvesterType(int planetId, byte harvesterType) { + Vector planetResourceList = new Vector(); + byte searchtype = harvesterType; + if (harvesterType==7) searchtype = (byte) 0; + for (GalacticResource gal : allSpawnedResources){ + if (gal.isSpawnedOn(planetId) && gal.getGeneralType()==searchtype) + if (harvesterType!=HarvesterObject.HARVESTER_TYPE_FUSION) + planetResourceList.add(gal); + else if (harvesterType==HarvesterObject.HARVESTER_TYPE_FUSION) { + System.err.println("gal.getContainerType() " + gal.getContainerType()); + if (gal.getResourceRoot().getContainerType()==ResourceRoot.CONTAINER_TYPE_ENERGY_RADIOACTIVE) + planetResourceList.add(gal); + } else if (harvesterType==HarvesterObject.HARVESTER_TYPE_GEO) { + System.err.println("gal.getContainerType() " + gal.getContainerType()); + if (gal.getGeneralType()==GalacticResource.GENERAL_GEOTHERM) + planetResourceList.add(gal); + } + } + return planetResourceList; + } + + public GalacticResource findResourceById(long id){ + GalacticResource resource = new GalacticResource(); + for (GalacticResource sampleResource : allSpawnedResources){ + if (sampleResource.getId()==id) + return sampleResource; + } + return resource; + } + // ToDo: Improve public GalacticResource grabMeatForCreature(CreatureObject corpse){ GalacticResource resource = null; @@ -11342,4 +11375,8 @@ public class ResourceService implements INetworkDispatch { } return containerObject; } + + public Vector getCompleteResourceNameHistory() { + return completeResourceNameHistory; + } } diff --git a/src/services/spawn/SpawnService.java b/src/services/spawn/SpawnService.java index eddfffa7..96d45123 100644 --- a/src/services/spawn/SpawnService.java +++ b/src/services/spawn/SpawnService.java @@ -48,6 +48,7 @@ import resources.objects.weapon.WeaponObject; import services.ai.AIActor; import services.ai.LairActor; import engine.resources.container.CreatureContainerPermissions; +import engine.resources.container.StaticContainerPermissions; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; @@ -90,7 +91,7 @@ public class SpawnService { return null; TangibleObject inventory = (TangibleObject) core.objectService.createObject("object/tangible/inventory/shared_character_inventory.iff", creature.getPlanet()); - inventory.setContainerPermissions(CreatureContainerPermissions.CREATURE_CONTAINER_PERMISSIONS); + inventory.setContainerPermissions(StaticContainerPermissions.STATIC_CONTAINER_PERMISSIONS); /*if(mobileTemplate.getCustomWeapon() != null) { @@ -164,6 +165,7 @@ public class SpawnService { AIActor actor = new AIActor(creature, creature.getPosition(), scheduler); creature.setAttachment("AI", actor); actor.setMobileTemplate(mobileTemplate); + if(cell == null) { diff --git a/src/services/sui/SUIService.java b/src/services/sui/SUIService.java index eb853838..a2d32ce3 100644 --- a/src/services/sui/SUIService.java +++ b/src/services/sui/SUIService.java @@ -46,6 +46,8 @@ import resources.common.FileUtilities; import resources.common.ObjControllerOpcodes; import resources.common.Opcodes; import resources.common.RadialOptions; +import resources.objects.creature.CreatureObject; +import resources.objects.harvester.HarvesterObject; import services.sui.SUIWindow.SUICallback; import services.sui.SUIWindow.Trigger; import engine.clients.Client; @@ -81,9 +83,31 @@ public class SUIService implements INetworkDispatch { if(target == null || owner == null) return; + if (target instanceof HarvesterObject){ + HarvesterObject harvester = (HarvesterObject) target; + Vector admins = harvester.getAdminList(); + Vector hoppers = harvester.getHopperList(); + CreatureObject creature = (CreatureObject) core.objectService.getObject(harvester.getOwner()); + if (creature == owner && !admins.contains(owner.getCustomName())){ + admins.add(owner.getCustomName()); + } + + if (! admins.contains(owner.getCustomName()) && ! hoppers.contains(owner.getCustomName())){ + return; // Completely unauthorized + } + + if (! admins.contains(owner.getCustomName()) && hoppers.contains(owner.getCustomName())){ + // authorized for hopper + // change radialOptions to hopper access + core.scriptService.callScript("scripts/radial/", "harvesterHopper", "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())) + if(core.housingService.getPermissions(owner, target.getContainer()) && !getRadialFilename(target).equals("structure_management_terminal")) { core.scriptService.callScript("scripts/radial/", "moveable", "createRadial", core, owner, target, request.getRadialOptions()); sendRadial(owner, target, request.getRadialOptions(), request.getRadialCount());