Merge pull request #25 from ProjectSWGCore/master

Fork update
This commit is contained in:
tacef
2014-08-01 21:10:27 +02:00
25 changed files with 2017 additions and 13588 deletions
Binary file not shown.
+1 -1
View File
@@ -1,7 +1,7 @@
LOAD.SNAPSHOT_OBJECTS=1
LOAD.BUILDOUT_OBJECTS=1
#LOAD.BUILDOUT_ONLY_FOR="dathomir"
LOAD.RESOURCE.SYSTEM=0
LOAD.RESOURCE.SYSTEM=1
# Misc
CLEAN.ODB.FOLDERS=0
+662
View File
@@ -0,0 +1,662 @@
#This file is to only be edited by Project SWG Staff.
#Do not commit any changes to this file unless authorized.
from resources.common import RadialOptions
from resources.common import OutOfBand
from protocol.swg import ResourceListForSurveyMessage
from services.sui.SUIService import MessageBoxType
from services.sui.SUIWindow import Trigger
from java.util import Vector
from java.lang import System
from java.lang import Long
from java.util import Map
from java.util import TreeMap
from resources.datatables import WeaponType
from engine.resources.scene import Point3D
import main.NGECore
import sys
import math
core = main.NGECore.getInstance()
def screenOne (core, owner):
window = core.suiService.createSUIWindow('Script.listBox', owner, owner, 0);
window.setProperty('bg.caption.lblTitle:Text', 'Character Builder Terminal')
window.setProperty('Prompt.lblPrompt:Text', 'Welcome to the Project SWG Test Center.')
window.setProperty('btnOk:visible', 'True')
window.setProperty('btnCancel:visible', 'True')
window.setProperty('btnOk:Text', '@ok')
window.setProperty('btnCancel:Text', '@cancel')
returnList = Vector()
returnList.add('List.lstList:SelectedRow')
window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, screenOneCallback)
window.addListBoxMenuItem('Character', 0)
window.addListBoxMenuItem('Items', 1)
window.addListBoxMenuItem('Instant Travel Locations', 2)
window.addListBoxMenuItem('Resources', 3)
if owner.getClient() and owner.getClient().isGM() == True:
window.addListBoxMenuItem('Admin', 4)
core.suiService.openSUIWindow(window);
def screenOneCallback(owner, window, eventType, returnList):
if returnList.size()==0:
owner.sendSystemMessage('NULL', 0)
return
if returnList.get(0)=='0':
characterHandler(owner)
return
if returnList.get(0)=='1':
itemsHandler(owner)
return
if returnList.get(0)=='2':
travelHandler(owner)
return
if returnList.get(0)=='3':
resourceHandler(owner)
return
if returnList.get(0)=='4':
adminHandler(owner)
return
return
def characterHandler(owner):
window = core.suiService.createSUIWindow('Script.listBox', owner, owner, 0);
window.setProperty('bg.caption.lblTitle:Text', 'Character Builder Terminal')
window.setProperty('Prompt.lblPrompt:Text', 'Welcome to Project SWG Test Center.')
window.setProperty('btnOk:visible', 'True')
window.setProperty('btnCancel:visible', 'True')
window.setProperty('btnOk:Text', '@ok')
window.setProperty('btnCancel:Text', '@cancel')
returnList = Vector()
returnList.add('List.lstList:SelectedRow')
window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, characterHandlerCallback)
window.addListBoxMenuItem('Set Combat Level To 90', 0)
window.addListBoxMenuItem('Give 50,000 Credits', 1)
window.addListBoxMenuItem('Give Character Buffs', 2)
window.addListBoxMenuItem('Reset Combat Level To 1', 3)
core.suiService.openSUIWindow(window);
def characterHandlerCallback(owner, window, eventType, returnList):
if returnList.size()==0:
owner.sendSystemMessage('NULL', 0)
return
if returnList.get(0)=='0':
combatLevel(owner)
return
if returnList.get(0)=='1':
credits(owner)
return
if returnList.get(0)=='2':
buff(owner)
return
if returnList.get(0)=='3':
combatLevelDown(owner)
return
return
def itemsHandler(owner):
window = core.suiService.createSUIWindow('Script.listBox', owner, owner, 0);
window.setProperty('bg.caption.lblTitle:Text', 'Character Builder Terminal')
window.setProperty('Prompt.lblPrompt:Text', 'Welcome to Project SWG Test Center.')
window.setProperty('btnOk:visible', 'True')
window.setProperty('btnCancel:visible', 'True')
window.setProperty('btnOk:Text', '@ok')
window.setProperty('btnCancel:Text', '@cancel')
returnList = Vector()
returnList.add('List.lstList:SelectedRow')
window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, itemsHandlerCallback)
window.addListBoxMenuItem('Weapons', 0)
window.addListBoxMenuItem('Armor', 1)
window.addListBoxMenuItem('Misc Equipment', 2)
core.suiService.openSUIWindow(window);
def itemsHandlerCallback(owner, window, eventType, returnList):
if returnList.size()==0:
owner.sendSystemMessage('NULL', 0)
return
if returnList.get(0)=='0':
weaponsHandler(owner)
return
if returnList.get(0)=='1':
armorHandler(owner)
return
if returnList.get(0)=='2':
miscHandler(owner)
return
return
def travelHandler(owner):
window = core.suiService.createSUIWindow('Script.listBox', owner, owner, 0);
window.setProperty('bg.caption.lblTitle:Text', 'Character Builder Terminal')
window.setProperty('Prompt.lblPrompt:Text', 'Welcome to Project SWG Test Center.')
window.setProperty('btnOk:visible', 'True')
window.setProperty('btnCancel:visible', 'True')
window.setProperty('btnOk:Text', '@ok')
window.setProperty('btnCancel:Text', '@cancel')
returnList = Vector()
returnList.add('List.lstList:SelectedRow')
window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, travelHandlerCallback)
window.addListBoxMenuItem('Tatooine, Mos Eisley', 0)
window.addListBoxMenuItem('Dantooine, Jedi Ruins', 1)
window.addListBoxMenuItem('Blank', 2)
window.addListBoxMenuItem('Blank', 3)
core.suiService.openSUIWindow(window);
def travelHandlerCallback(owner, window, eventType, returnList):
inventory = owner.getSlottedObject('inventory')
if returnList.size()==0:
owner.sendSystemMessage('NULL', 0)
return
if returnList.get(0)=='0':
eisleyTravel(owner)
return
if returnList.get(0)=='1':
jediRuinsTravel(owner)
return
return
def resourceHandler(owner):
window = core.suiService.createSUIWindow('Script.listBox', owner, owner, 0);
window.setProperty('bg.caption.lblTitle:Text', 'Character Builder Terminal')
window.setProperty('Prompt.lblPrompt:Text', 'Welcome to Project SWG Test Center.')
window.setProperty('btnOk:visible', 'True')
window.setProperty('btnCancel:visible', 'True')
window.setProperty('btnOk:Text', '@ok')
window.setProperty('btnCancel:Text', '@cancel')
returnList = Vector()
returnList.add('List.lstList:SelectedRow')
window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, resourceHandlerCallback)
window.addListBoxMenuItem('Survey Devices', 0)
core.suiService.openSUIWindow(window);
def resourceHandlerCallback(owner, window, eventType, returnList):
inventory = owner.getSlottedObject('inventory')
if returnList.size()==0:
owner.sendSystemMessage('NULL', 0)
return
if returnList.get(0)=='0':
surveyDevices(owner, inventory)
return
def adminHandler(owner):
window = core.suiService.createSUIWindow('Script.listBox', owner, owner, 0);
window.setProperty('bg.caption.lblTitle:Text', 'Character Builder Terminal')
window.setProperty('Prompt.lblPrompt:Text', 'Welcome to Project SWG Test Center.')
window.setProperty('btnOk:visible', 'True')
window.setProperty('btnCancel:visible', 'True')
window.setProperty('btnOk:Text', '@ok')
window.setProperty('btnCancel:Text', '@cancel')
returnList = Vector()
returnList.add('List.lstList:SelectedRow')
window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, adminHandlerCallback)
window.addListBoxMenuItem('Vehicle', 0)
window.addListBoxMenuItem('Crafting', 1)
window.addListBoxMenuItem('Character Builder Terminal', 2)
window.addListBoxMenuItem('Placeholder', 3)
core.suiService.openSUIWindow(window);
def adminHandlerCallback(owner, window, eventType, returnList):
inventory = owner.getSlottedObject('inventory')
if returnList.size()==0:
owner.sendSystemMessage('NULL', 0)
return
if returnList.get(0)=='0':
vehicleHandler(owner, inventory)
return
if returnList.get(0)=='2':
cbtHandler(owner, inventory)
return
return
def weaponsHandler(owner):
window = core.suiService.createSUIWindow('Script.listBox', owner, owner, 0);
window.setProperty('bg.caption.lblTitle:Text', 'Character Builder Terminal')
window.setProperty('Prompt.lblPrompt:Text', 'Welcome to Project SWG Test Center.')
window.setProperty('btnOk:visible', 'True')
window.setProperty('btnCancel:visible', 'True')
window.setProperty('btnOk:Text', '@ok')
window.setProperty('btnCancel:Text', '@cancel')
returnList = Vector()
returnList.add('List.lstList:SelectedRow')
window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, weaponsHandlerCallback)
window.addListBoxMenuItem('Melee', 0)
window.addListBoxMenuItem('Ranged', 1)
window.addListBoxMenuItem('Lightsabers', 2)
window.addListBoxMenuItem('Krayt Pearls', 3)
window.addListBoxMenuItem('Color Crystals', 4)
core.suiService.openSUIWindow(window);
def weaponsHandlerCallback(owner, window, eventType, returnList):
inventory = owner.getSlottedObject('inventory')
if returnList.size()==0:
owner.sendSystemMessage('NULL', 0)
return
if returnList.get(0)=='0':
meleeWeapons(owner, inventory)
return
if returnList.get(0)=='1':
rangedWeapons(owner, inventory)
return
if returnList.get(0)=='2':
lightsabers(owner, inventory)
return
if returnList.get(0)=='3':
lightsaberPowerCrystals(owner, inventory)
return
if returnList.get(0)=='4':
lightsaberColorCrystals(owner, inventory)
return
return
def armorHandler(owner):
window = core.suiService.createSUIWindow('Script.listBox', owner, owner, 0);
window.setProperty('bg.caption.lblTitle:Text', 'Character Builder Terminal')
window.setProperty('Prompt.lblPrompt:Text', 'Welcome to Project SWG Test Center.')
window.setProperty('btnOk:visible', 'True')
window.setProperty('btnCancel:visible', 'True')
window.setProperty('btnOk:Text', '@ok')
window.setProperty('btnCancel:Text', '@cancel')
returnList = Vector()
returnList.add('List.lstList:SelectedRow')
window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, armorHandlerCallback)
window.addListBoxMenuItem('Composite', 0)
window.addListBoxMenuItem('Jedi Master Cloak', 1)
window.addListBoxMenuItem('Jedi Knight Robes', 2)
core.suiService.openSUIWindow(window);
def armorHandlerCallback(owner, window, eventType, returnList):
inventory = owner.getSlottedObject('inventory')
if returnList.size()==0:
owner.sendSystemMessage('NULL', 0)
return
if returnList.get(0)=='0':
compositeArmor(owner, inventory)
return
if returnList.get(0)=='1':
jediMasterCloak(owner, inventory)
return
if returnList.get(0)=='2':
jediKnightRobes(owner, inventory)
return
def miscHandler(owner):
window = core.suiService.createSUIWindow('Script.listBox', owner, owner, 0);
window.setProperty('bg.caption.lblTitle:Text', 'Character Builder Terminal')
window.setProperty('Prompt.lblPrompt:Text', 'Welcome to Project SWG Test Center.')
window.setProperty('btnOk:visible', 'True')
window.setProperty('btnCancel:visible', 'True')
window.setProperty('btnOk:Text', '@ok')
window.setProperty('btnCancel:Text', '@cancel')
returnList = Vector()
returnList.add('List.lstList:SelectedRow')
window.addHandler(0, '', Trigger.TRIGGER_OK, returnList, miscHandlerCallback)
window.addListBoxMenuItem('Backpack', 0)
window.addListBoxMenuItem('Heroism Jewelry Set', 1)
window.addListBoxMenuItem('Belt of Master Bodo Baas', 2)
core.suiService.openSUIWindow(window);
def miscHandlerCallback(owner, window, eventType, returnList):
inventory = owner.getSlottedObject('inventory')
if returnList.size()==0:
owner.sendSystemMessage('NULL', 0)
return
if returnList.get(0)=='0':
backpack(owner, inventory)
return
if returnList.get(0)=='1':
heroismJewelry(owner, inventory)
return
if returnList.get(0)=='2':
jediBelt(owner, inventory)
return
return
def combatLevel(owner):
if (owner.getLevel() < 90):
core.playerService.grantLevel(owner, 90);
screenOne(core, owner)
return
def credits(owner):
owner.setCashCredits(owner.getCashCredits() + 50000);
owner.sendSystemMessage('The Project SWG team has pitched in and given you ' + "50,000" + ' credits for your service.', 0)
screenOne(core, owner)
return
def buff(owner):
core.buffService.addBuffToCreature(owner, 'me_buff_health_2', owner)
buff = owner.getBuffByName('me_buff_health_2')
buff.setDuration(5400)
core.buffService.addBuffToCreature(owner, 'me_buff_action_3', owner)
buff1 = owner.getBuffByName('me_buff_action_3')
buff1.setDuration(5400)
core.buffService.addBuffToCreature(owner, 'me_buff_agility_3', owner)
buff2 = owner.getBuffByName('me_buff_agility_3')
buff2.setDuration(5400)
core.buffService.addBuffToCreature(owner, 'me_buff_melee_gb_1', owner)
buff3 = owner.getBuffByName('me_buff_melee_gb_1')
buff3.setDuration(5400)
core.buffService.addBuffToCreature(owner, 'me_buff_ranged_gb_1', owner)
buff4 = owner.getBuffByName('me_buff_ranged_gb_1')
buff4.setDuration(5400)
core.buffService.addBuffToCreature(owner, 'me_buff_precision_3', owner)
buff5 = owner.getBuffByName('me_buff_precision_3')
buff5.setDuration(5400)
core.buffService.addBuffToCreature(owner, 'me_buff_strength_3', owner)
buff6 = owner.getBuffByName('me_buff_strength_3')
buff6.setDuration(5400)
screenOne(core, owner)
return
def combatLevelDown(owner):
if (owner.getLevel() == 1):
screenOne(core, owner)
return
if (owner.getLevel() > 1):
core.playerService.grantLevel(owner, 1)
screenOne(core, owner)
return
def rangedWeapons(owner, inventory):
rifle = core.objectService.createObject('object/weapon/ranged/rifle/shared_rifle_e11.iff', owner.getPlanet())
rifle.setDamageType("energy");
rifle.setWeaponType(WeaponType.RIFLE);
rifle.setAttackSpeed(0.8);
rifle.setMinDamage(518);
rifle.setMaxDamage(1035);
rifle.setMaxRange(64)
pistol = core.objectService.createObject('object/weapon/ranged/pistol/shared_pistol_dl44.iff', owner.getPlanet())
pistol.setDamageType("energy");
pistol.setWeaponType(WeaponType.PISTOL);
pistol.setAttackSpeed(0.4);
pistol.setMinDamage(259);
pistol.setMaxDamage(518);
pistol.setMaxRange(35);
carbine = core.objectService.createObject('object/weapon/ranged/carbine/shared_carbine_e11.iff', owner.getPlanet())
carbine.setDamageType("energy");
carbine.setWeaponType(WeaponType.CARBINE);
carbine.setAttackSpeed(0.6);
carbine.setMinDamage(389);
carbine.setMaxDamage(780);
carbine.setMaxRange(50);
heavy = core.objectService.createObject('object/weapon/ranged/heavy/shared_som_lava_cannon.iff', owner.getPlanet())
heavy.setDamageType("energy");
heavy.setWeaponType(WeaponType.HEAVYWEAPON);
heavy.setAttackSpeed(1);
heavy.setMinDamage(850);
heavy.setMaxDamage(1350);
heavy.setStringAttribute('wpn_elemental_type', 'Heat')
heavy.setStringAttribute('wpn_elemental_value', '50')
heavy.setMaxRange(64)
inventory.add(rifle)
inventory.add(pistol)
inventory.add(carbine)
inventory.add(heavy)
screenOne(core, owner)
return
def meleeWeapons(owner, inventory):
polearm = core.objectService.createObject('object/weapon/melee/polearm/shared_polearm_vibro_axe.iff', owner.getPlanet())
polearm.setAttackSpeed(1.0)
polearm.setMaxRange(5)
polearm.setDamageType('kinetic')
polearm.setMinDamage(700)
polearm.setMaxDamage(990)
polearm.setWeaponType(WeaponType.POLEARMMELEE)
inventory.add(polearm)
screenOne(core, owner)
return
def compositeArmor(owner, inventory):
comp_bicep_r = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_bicep_r.iff", owner.getPlanet())
comp_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000);
comp_bicep_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000);
comp_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000);
comp_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000);
comp_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000);
comp_bicep_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000);
comp_bicep_l = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_bicep_l.iff", owner.getPlanet())
comp_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000);
comp_bicep_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000);
comp_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000);
comp_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000);
comp_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000);
comp_bicep_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000);
comp_bracer_r = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_bracer_r.iff", owner.getPlanet())
comp_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000);
comp_bracer_r.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000);
comp_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000);
comp_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000);
comp_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000);
comp_bracer_r.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000);
comp_bracer_l = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_bracer_l.iff", owner.getPlanet())
comp_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000);
comp_bracer_l.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000);
comp_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000);
comp_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000);
comp_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000);
comp_bracer_l.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000);
comp_leggings = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_leggings.iff", owner.getPlanet())
comp_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000);
comp_leggings.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000);
comp_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000);
comp_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000);
comp_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000);
comp_leggings.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000);
comp_helmet = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_helmet.iff", owner.getPlanet())
comp_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000);
comp_helmet.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000);
comp_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000);
comp_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000);
comp_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000);
comp_helmet.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000);
comp_chest = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_chest_plate.iff", owner.getPlanet())
comp_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_kinetic", 7000);
comp_chest.setIntAttribute("cat_armor_standard_protection.armor_eff_energy", 5000);
comp_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_heat", 6000);
comp_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_cold", 6000);
comp_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_acid", 6000);
comp_chest.setIntAttribute("cat_armor_special_protection.special_protection_type_electricity", 6000);
comp_boots = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_boots.iff", owner.getPlanet())
comp_gloves = core.objectService.createObject("object/tangible/wearables/armor/composite/shared_armor_composite_gloves.iff", owner.getPlanet())
inventory.add(comp_bicep_r);
inventory.add(comp_bicep_l);
inventory.add(comp_bracer_r);
inventory.add(comp_bracer_l);
inventory.add(comp_leggings);
inventory.add(comp_helmet);
inventory.add(comp_chest);
inventory.add(comp_boots);
inventory.add(comp_gloves);
screenOne(core, owner)
return
def jediMasterCloak(owner, inventory):
cloak = core.objectService.createObject('object/tangible/wearables/robe/shared_robe_s05_h1.iff', owner.getPlanet(), 'item_jedi_robe_06_01')
inventory.add(cloak)
screenOne(core, owner)
return
def jediKnightRobes(owner, inventory):
robe1 = core.objectService.createObject("object/tangible/wearables/robe/shared_robe_jedi_light_s03.iff", owner.getPlanet())
robe2 = core.objectService.createObject("object/tangible/wearables/robe/shared_robe_jedi_dark_s03.iff", owner.getPlanet())
inventory.add(robe1)
inventory.add(robe2)
screenOne(core, owner)
return
def lightsabers(owner, inventory):
lightsaber1 = core.objectService.createObject("object/weapon/melee/sword/crafted_saber/shared_sword_lightsaber_one_handed_gen5.iff", owner.getPlanet())
lightsaber1.setIntAttribute("required_combat_level", 90);
lightsaber1.setStringAttribute("class_required", "Jedi");
lightsaber1.setAttackSpeed(1);
lightsaber1.setDamageType("energy");
lightsaber1.setMaxRange(5);
lightsaber1.setMinDamage(689);
lightsaber1.setMaxDamage(1379);
lightsaber1.setWeaponType(WeaponType.ONEHANDEDSABER);
lightsaber2 = core.objectService.createObject("object/weapon/melee/2h_sword/crafted_saber/shared_sword_lightsaber_two_handed_gen5.iff", owner.getPlanet())
lightsaber2.setIntAttribute("required_combat_level", 90);
lightsaber2.setStringAttribute("class_required", "Jedi");
lightsaber2.setAttackSpeed(1);
lightsaber2.setDamageType("energy");
lightsaber2.setMaxRange(5);
lightsaber2.setMinDamage(689);
lightsaber2.setMaxDamage(1379);
lightsaber2.setWeaponType(WeaponType.TWOHANDEDSABER);
lightsaber3 = core.objectService.createObject("object/weapon/melee/polearm/crafted_saber/shared_sword_lightsaber_polearm_gen5.iff", owner.getPlanet())
lightsaber3.setIntAttribute("required_combat_level", 90);
lightsaber3.setStringAttribute("class_required", "Jedi");
lightsaber3.setAttackSpeed(1);
lightsaber3.setDamageType("energy");
lightsaber3.setMaxRange(5);
lightsaber3.setMinDamage(689);
lightsaber3.setMaxDamage(1379);
lightsaber3.setWeaponType(WeaponType.POLEARMSABER);
inventory.add(lightsaber1)
inventory.add(lightsaber2)
inventory.add(lightsaber3)
screenOne(core, owner)
return
def lightsaberPowerCrystals(owner, inventory):
kraytPearl = core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff", owner.getPlanet())
kraytPearl.setAttachment("LootItemName", "kraytpearl_premium");
core.lootService.handleSpecialItems(kraytPearl, "kraytpearl");
kraytPearl2 = core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff", owner.getPlanet())
kraytPearl2.setAttachment("LootItemName", "kraytpearl_premium");
core.lootService.handleSpecialItems(kraytPearl2, "kraytpearl");
kraytPearl3 = core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff", owner.getPlanet())
kraytPearl3.setAttachment("LootItemName", "kraytpearl_premium");
core.lootService.handleSpecialItems(kraytPearl3, "kraytpearl");
kraytPearl4 = core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff", owner.getPlanet())
kraytPearl4.setAttachment("LootItemName", "kraytpearl_premium");
core.lootService.handleSpecialItems(kraytPearl4, "kraytpearl");
kraytPearl5 = core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_krayt_dragon_pearl.iff", owner.getPlanet())
kraytPearl5.setAttachment("LootItemName", "kraytpearl_premium");
core.lootService.handleSpecialItems(kraytPearl5, "kraytpearl");
inventory.add(kraytPearl);
inventory.add(kraytPearl2);
inventory.add(kraytPearl3);
inventory.add(kraytPearl4);
inventory.add(kraytPearl5);
screenOne(core, owner)
return
def lightsaberColorCrystals(owner, inventory):
colorCrystal = core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff", owner.getPlanet())
colorCrystal.getAttributes().put("@obj_attr_n:condition", "100/100");
colorCrystal.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF ");
colorCrystal.setAttachment("radial_filename", "item/tunable");
colorCrystal.setCustomizationVariable('/private/index_color_1', 5)
colorCrystal2 = core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_force_crystal.iff", owner.getPlanet())
colorCrystal2.getAttributes().put("@obj_attr_n:condition", "100/100");
colorCrystal2.getAttributes().put("@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF ");
colorCrystal2.setAttachment("radial_filename", "item/tunable");
colorCrystal2.setCustomizationVariable('/private/index_color_1', 1)
lavaCrystal = core.objectService.createObject("object/tangible/component/weapon/lightsaber/shared_lightsaber_module_lava_crystal.iff", owner.getPlanet())
inventory.add(colorCrystal)
inventory.add(colorCrystal2)
inventory.add(lavaCrystal)
screenOne(core, owner)
return
def jediBelt(owner, inventory):
inventory.add(core.objectService.createObject("object/tangible/wearables/backpack/shared_fannypack_s01.iff", owner.getPlanet()))
screenOne(core, owner)
return
def backpack(owner, inventory):
inventory.add(core.objectService.createObject("object/tangible/wearables/backpack/shared_backpack_s01.iff", owner.getPlanet()))
screenOne(core, owner)
return
def heroismJewelry(owner, inventory):
heroismBand = core.objectService.createObject("object/tangible/wearables/ring/shared_ring_s04.iff", owner.getPlanet(), "item_band_set_hero_01_01")
heroismRing = core.objectService.createObject("object/tangible/wearables/ring/shared_ring_s02.iff", owner.getPlanet(), "item_ring_set_hero_01_01")
heroismNecklace = core.objectService.createObject("object/tangible/wearables/necklace/shared_necklace_s10.iff", owner.getPlanet(), "item_necklace_set_hero_01_01")
heroismBraceletRight = core.objectService.createObject("object/tangible/wearables/bracelet/shared_bracelet_s03_r.iff", owner.getPlanet(), "item_bracelet_r_set_hero_01_01")
heroismBraceletLeft = core.objectService.createObject("object/tangible/wearables/bracelet/shared_bracelet_s03_l.iff", owner.getPlanet(), "item_bracelet_l_set_hero_01_01")
inventory.add(heroismBand)
inventory.add(heroismRing)
inventory.add(heroismNecklace)
inventory.add(heroismBraceletRight)
inventory.add(heroismBraceletLeft)
screenOne(core, owner)
return
def vehicleHandler(owner, inventory):
speederbike = core.objectService.createObject('object/tangible/deed/vehicle_deed/shared_speederbike_swoop_deed.iff', owner.getPlanet())
inventory.add(speederbike)
screenOne(core, owner)
return
def cbtHandler(owner, inventory):
cbt = core.objectService.createObject('object/tangible/terminal/shared_terminal_character_builder.iff', owner.getPlanet())
inventory.add(cbt)
screenOne(core, owner)
return
def eisleyTravel(owner):
position = Point3D(3472, 4, -4870)
core.simulationService.transferToPlanet(owner, core.terrainService.getPlanetByName("tatooine"), position, owner.getOrientation(), None)
return
def jediRuinsTravel(owner):
position = Point3D(4260, 4, 5373)
core.simulationService.transferToPlanet(owner, core.terrainService.getPlanetByName("dantooine"), position, owner.getOrientation(), None)
return
def surveyDevices(owner, inventory):
mineralSurveyTool = core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_mineral.iff", owner.getPlanet())
chemicalSurveyTool = core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_inorganic.iff", owner.getPlanet())
floraSurveyTool = core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_lumber.iff", owner.getPlanet())
gasSurveyTool = core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_gas.iff", owner.getPlanet())
waterSurveyTool = core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_moisture.iff", owner.getPlanet())
windSurveyTool = core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_wind.iff", owner.getPlanet())
solarSurveyTool = core.objectService.createObject("object/tangible/survey_tool/shared_survey_tool_solar.iff", owner.getPlanet())
inventory.add(mineralSurveyTool)
inventory.add(chemicalSurveyTool)
inventory.add(floraSurveyTool)
inventory.add(gasSurveyTool)
inventory.add(waterSurveyTool)
inventory.add(windSurveyTool)
inventory.add(solarSurveyTool)
return
+14 -6
View File
@@ -5,16 +5,24 @@ def setup():
def run(core, actor, target, commandString):
commandArgs = commandString.split(' ')
arg1 = commandArgs[0]
if len(commandArgs) > 1:
arg2 = commandArgs[1]
if actor.getClient() and actor.getClient().isGM() == False:
return
if not commandString.startswith('object/tangible') and not commandString.startswith('object/weapon'):
return
object = core.objectService.createObject(commandString, actor.getPlanet())
#object.setCustomizationVariable('/private/index_color_blade', 0x02)
#object.setCustomizationVariable('private/alternate_shader_blade', 0x02)
if len(commandArgs) == 2:
object = core.objectService.createObject((arg1), actor.getPlanet(), (arg2))
if len(commandArgs) == 1:
object = core.objectService.createObject((arg1), actor.getPlanet())
if not object:
return
+2 -2
View File
@@ -23,7 +23,7 @@ def run(core, actor, target, commandString):
if arg1 and arg2 and arg3 and arg4 is not None:
try:
actor.sendSystemMessage('Teleporting...', 0)
actor.sendSystemMessage('gm: teleport: Command completed successfully.', 0)
position = Point3D(float(arg1), float(arg2), float(arg3))
core.simulationService.transferToPlanet(actor, core.terrainService.getPlanetByName(arg4), position, actor.getOrientation(), None)
except:
@@ -33,7 +33,7 @@ def run(core, actor, target, commandString):
elif arg1 and arg2 and arg3:
try:
actor.sendSystemMessage('Teleporting...', 0)
actor.sendSystemMessage('gm: teleport: Command completed successfully.', 0)
position = Point3D(float(arg1), 0, float(arg2))
core.simulationService.transferToPlanet(actor, core.terrainService.getPlanetByName(arg3), position, actor.getOrientation(), None)
except:
+1 -1
View File
@@ -12,7 +12,7 @@ def run(core, actor, target, commandString):
return
if target and target.getSlottedObject('ghost') is not None:
actor.sendSystemMessage('Teleporting ' + target.getCustomName() + ' to you...', 0)
actor.sendSystemMessage('gm: teleporttarget: Command completed successfully.', 0)
core.simulationService.teleport(target, actor.getPosition(), actor.getOrientation(), 0)
return
+1 -1
View File
@@ -15,7 +15,7 @@ def run(core, actor, target, commandString):
target = core.objectService.getObjectByFirstName(commandString)
if target and target.getSlottedObject('ghost') is not None:
actor.sendSystemMessage('Teleporting you to ' + target.getCustomName() + '...', 0)
actor.sendSystemMessage('gm: teleportto: Command completed successfully.', 0)
if target.getPlanetId() == actor.getPlanetId():
core.simulationService.teleport(actor, target.getPosition(), target.getOrientation(), target.getParentId())
else:
@@ -27,6 +27,8 @@ def addBonusSet(core):
bonusSet.addRequiredItem("object/tangible/wearables/robe/shared_robe_s32_h1.iff")
bonusSet.addRequiredItem("object/tangible/wearables/robe/shared_robe_s33.iff")
bonusSet.addRequiredItem("object/tangible/wearables/robe/shared_robe_s33_h1.iff")
bonusSet.addRequiredItem("item_jedi_robe_06_01")
core.equipmentService.addBonusSetTemplate(bonusSet)
@@ -11,6 +11,6 @@ def setup(core, object):
object.setStringAttribute('condition', '1000/1000')
object.setStringAttribute("@obj_attr_n:color", "Windu's Guile")
object.setAttachment('radial_filename', 'item/tunable')
object.setStringAttribute('@obj_attr_n:crystal_owner", "\\#D1F56F UNTUNED \\#FFFFFF ')
object.setStringAttribute('@obj_attr_n:crystal_owner', "\\#D1F56F UNTUNED \\#FFFFFF ", )
return
@@ -5,5 +5,5 @@ def setup(core, object):
return
def use(core, owner, target):
core.devService.sendCharacterBuilderSUI(owner, 0);
core.scriptService.callScript("scripts/", "character_builder_terminal", "screenOne", core, owner);
return
@@ -0,0 +1,24 @@
import sys
def setup(core, object):
object.setStfFilename('static_item_n')
object.setStfName('item_jedi_robe_06_01')
object.setDetailFilename('static_item_d')
object.setDetailName('item_jedi_robe_06_01')
object.setStringAttribute('protection_level', 'Luminous')
object.setStringAttribute('class_required', 'Jedi')
object.setIntAttribute('required_combat_level', 80)
object.setIntAttribute('cat_stat_mod_bonus.@stat_n:constitution_modified', 100)
object.setIntAttribute('cat_stat_mod_bonus.@stat_n:strength_modified', 100)
object.setIntAttribute('cat_stat_mod_bonus.@stat_n:agility_modified', 100)
object.setIntAttribute('cat_stat_mod_bonus.@stat_n:luck_modified', 100)
object.setStringAttribute('@set_bonus:piece_bonus_count_2', '@set_bonus:set_bonus_jedi_robe_1')
object.setAttachment('type', 'jedi_cloak')
object.setAttachment('setBonus', 'set_bonus_jedi_robe')
object.setAttachment('radial_filename', 'equipment/jedi_master_robes');
return
@@ -1,22 +1,6 @@
import sys
def setup(core, object):
object.setStfFilename('static_item_n')
object.setStfName('item_jedi_robe_06_01')
object.setDetailFilename('static_item_d')
object.setDetailName('item_jedi_robe_06_01')
object.setStringAttribute('protection_level', 'Luminous')
object.setStringAttribute('class_required', 'Jedi')
object.setIntAttribute('required_combat_level', 80)
object.setIntAttribute('cat_stat_mod_bonus.@stat_n:constitution_modified', 100)
object.setIntAttribute('cat_stat_mod_bonus.@stat_n:strength_modified', 100)
object.setIntAttribute('cat_stat_mod_bonus.@stat_n:agility_modified', 100)
object.setIntAttribute('cat_stat_mod_bonus.@stat_n:luck_modified', 100)
object.setStringAttribute('@set_bonus:piece_bonus_count_2', '@set_bonus:set_bonus_jedi_robe_1')
object.setAttachment('type', 'jedi_robe')
object.setAttachment('setBonus', 'set_bonus_jedi_robe')
return
return
+23 -7
View File
@@ -3,13 +3,13 @@ import sys
def createRadial(core, owner, target, radials):
if target.getContainer() == owner:
return
#if target.getContainer() == owner:
# return
if target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s32.iff" or target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s33.iff":
if target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s32.iff" or target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s33.iff" or target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s05.iff":
radials.add(RadialOptions(0, 98, 1, 'Hood up'))
elif target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s32_h1.iff" or target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s33_h1.iff":
elif target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s32_h1.iff" or target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s33_h1.iff" or target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s05_h1.iff":
radials.add(RadialOptions(0, 99, 1, 'Hood down'))
return
@@ -28,7 +28,15 @@ def handleSelection(core, owner, target, option):
elif target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s33.iff":
newTemplate = "object/tangible/wearables/robe/shared_robe_s33_h1.iff"
if newTemplate != "":
elif target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s05.iff":
newTemplate = "object/tangible/wearables/robe/shared_robe_s05_h1.iff"
if newTemplate == "object/tangible/wearables/robe/shared_robe_s05_h1.iff":
object = core.objectService.createObject('object/tangible/wearables/robe/shared_robe_s05_h1.iff', owner.getPlanet(), 'item_jedi_robe_06_01')
core.objectService.destroyObject(target)
inventory.add(object)
elif newTemplate != "":
object = core.objectService.createObject(newTemplate, owner.getPlanet())
core.objectService.destroyObject(target)
inventory.add(object)
@@ -40,8 +48,16 @@ def handleSelection(core, owner, target, option):
elif target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s33_h1.iff":
newTemplate = "object/tangible/wearables/robe/shared_robe_s33.iff"
if newTemplate != "":
elif target.getTemplate() == "object/tangible/wearables/robe/shared_robe_s05_h1.iff":
newTemplate = "object/tangible/wearables/robe/shared_robe_s05.iff"
if newTemplate == "object/tangible/wearables/robe/shared_robe_s05.iff":
object = core.objectService.createObject('object/tangible/wearables/robe/shared_robe_s05.iff', owner.getPlanet(), 'item_jedi_robe_06_01')
core.objectService.destroyObject(target)
inventory.add(object)
elif newTemplate != "":
object = core.objectService.createObject(newTemplate, owner.getPlanet())
core.objectService.destroyObject(target)
inventory.add(object)
+9 -28
View File
@@ -62,7 +62,6 @@ import services.BuffService;
import services.CharacterService;
import services.ConnectionService;
import services.ConversationService;
import services.DevService;
import services.EntertainmentService;
import services.GroupService;
import services.housing.HousingService;
@@ -197,7 +196,6 @@ public class NGECore {
public AIService aiService;
public MissionService missionService;
public InstanceService instanceService;
public DevService devService;
public SurveyService surveyService;
public ResourceService resourceService;
public ConversationService conversationService;
@@ -233,8 +231,6 @@ public class NGECore {
private BusConfiguration eventBusConfig = BusConfiguration.Default(1, new ThreadPoolExecutor(1, 4, 1, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>()));
private ObjectDatabase auctionODB;
private ObjectDatabase resourcesODB;
private ObjectDatabase resourceRootsODB;
private ObjectDatabase resourceHistoryODB;
private ObjectDatabase swgObjectODB;
private ObjectDatabase bountiesODB;
@@ -312,8 +308,6 @@ public class NGECore {
objectIdODB = new ObjectDatabase("oids", true, true, true, ObjectId.class);
duplicateIdODB = new ObjectDatabase("doids", true, true, true, DuplicateId.class);
chatRoomODB = new ObjectDatabase("chatRooms", true, true, true, ChatRoom.class);
resourcesODB = new ObjectDatabase("resources", true, true, true, GalacticResource.class);
resourceRootsODB = new ObjectDatabase("resourceroots", true, true, true, ResourceRoot.class);
resourceHistoryODB = new ObjectDatabase("resourcehistory", true, true, true, GalacticResource.class);
auctionODB = new ObjectDatabase("auction", true, true, true, AuctionItem.class);
bountiesODB = new ObjectDatabase("bounties", true, true, true, BountyListItem.class);
@@ -355,6 +349,11 @@ public class NGECore {
reverseEngineeringService = new ReverseEngineeringService(this);
petService = new PetService(this);
if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") == 1) {
surveyService = new SurveyService(this);
resourceService = new ResourceService(this);
}
if (config.keyExists("JYTHONCONSOLE.PORT")) {
int jythonPort = config.getInt("JYTHONCONSOLE.PORT");
if (jythonPort > 0) {
@@ -370,13 +369,7 @@ public class NGECore {
aiService = new AIService(this);
missionService = new MissionService(this);
if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") == 1) {
surveyService = new SurveyService(this);
resourceService = new ResourceService(this);
}
// Ping Server
if(config.keyExists("PING.PORT"))
if (config.getInt("PING.PORT") != 0) {
@@ -501,6 +494,10 @@ public class NGECore {
//end terrainList
if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") > 0) {
resourceService.loadResources();
}
chatService.loadChatRooms();
spawnService = new SpawnService(this);
@@ -510,11 +507,6 @@ public class NGECore {
simulationService = new SimulationService(this);
if (optionsConfigLoaded && options.getInt("LOAD.RESOURCE.SYSTEM") > 0) {
resourceService.loadResourceRoots();
resourceService.loadResources();
}
terrainService.loadSnapShotObjects();
objectService.loadServerTemplates();
objectService.loadBuildings();
@@ -560,7 +552,6 @@ public class NGECore {
browserService = new BrowserService(this);
//battlefieldService = new BattlefieldService(this);
devService = new DevService(this);
DevLogQueuer devLogQueuer = new DevLogQueuer();
@@ -705,14 +696,6 @@ public class NGECore {
public ObjectDatabase getBountiesODB() {
return bountiesODB;
}
public ObjectDatabase getResourcesODB() {
return resourcesODB;
}
public ObjectDatabase getResourceRootsODB() {
return resourceRootsODB;
}
public ObjectDatabase getResourceHistoryODB() {
return resourceHistoryODB;
@@ -827,8 +810,6 @@ public class NGECore {
mailODB.close();
guildODB.close();
chatRoomODB.close();
resourcesODB.close();
resourceRootsODB.close();
resourceHistoryODB.close();
objectIdODB.close();
duplicateIdODB.close();
@@ -67,7 +67,9 @@ public class ResourceListForSurveyMessage extends SWGMessage {
if (toolName.equals("survey_tool_liquid"))
generalType = (byte) 7;
Vector<GalacticResource> planetVector = core.resourceService.getSpawnedResourcesByPlanetAndType(surveyor.getPlanetId(),generalType);
if (core.resourceService == null)
System.out.println("heyyyy guess who's confused?!");
List<GalacticResource> planetVector = core.resourceService.getSpawnedResourcesByPlanetAndType(surveyor.getPlanetId(),generalType);
resourceList = new ArrayList<GalacticResource>(planetVector);
@@ -60,7 +60,8 @@ public class BuildingObject extends TangibleObject implements IPersistent, Seria
public BuildingObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
super(objectID, planet, position, orientation, Template);
getBaseline(3).set("volume", 255);
getBaseline(3).set("volume", 255); // 255 seen on player buildings + some server spawned ones and 100 - lucky despot, watto
//getBaseline(3).set("complexity", (float) 1); // seen as 1 (player housing) + some server spawned ones and 0 - lucky despot, watto
setOptionsBitmask(Options.INVULNERABLE);
setConditionDamage(0);
setMaximumCondition(4320);
@@ -70,6 +71,7 @@ public class BuildingObject extends TangibleObject implements IPersistent, Seria
public BuildingObject() {
super();
getBaseline(3).set("volume", 255);
getBaseline(3).set("complexity", (float) 1);
setOptionsBitmask(Options.INVULNERABLE);
setConditionDamage(0);
setMaximumCondition(4320);
@@ -81,6 +83,7 @@ public class BuildingObject extends TangibleObject implements IPersistent, Seria
super.init();
defendersList = new Vector<TangibleObject>();
getBaseline(3).set("volume", 255);
getBaseline(3).set("complexity", (float) 1);
setOptionsBitmask(Options.INVULNERABLE);
setConditionDamage(0);
setMaximumCondition(4320);
@@ -102,6 +105,8 @@ public class BuildingObject extends TangibleObject implements IPersistent, Seria
@Override
public Baseline getBaseline3() {
Baseline baseline = super.getBaseline3();
// No additional variables, uses TANO
return baseline;
}
@@ -3,21 +3,22 @@
*
* 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 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.
* 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 <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 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.
* 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.resource;
@@ -43,11 +44,11 @@ import engine.resources.scene.Planet;
import engine.resources.scene.Point3D;
import engine.resources.scene.Quaternion;
/**
* @author Charon
/**
* @author Charon
*/
@Entity(version=0)
@Entity(version = 0)
public class GalacticResource extends SWGObject implements Serializable {
private static final long serialVersionUID = 1L;
@@ -59,75 +60,64 @@ public class GalacticResource extends SWGObject implements Serializable {
private long spawnTime;
private long vanishTime;
@NotPersistent
public transient static final int INT_COLDRESISTANCE = 0;
public transient static final int INT_COLDRESISTANCE = 0;
@NotPersistent
public transient static final int INT_CONDUCTIVITY = 1;
public transient static final int INT_CONDUCTIVITY = 1;
@NotPersistent
public transient static final int INT_DECAYRESISTANCE = 2;
public transient static final int INT_DECAYRESISTANCE = 2;
@NotPersistent
public transient static final int INT_HEATRESISTANCE = 3;
public transient static final int INT_HEATRESISTANCE = 3;
@NotPersistent
public transient static final int INT_MALLEABILITY = 4;
public transient static final int INT_MALLEABILITY = 4;
@NotPersistent
public transient static final int INT_SHOCKRESISTANCE = 5;
public transient static final int INT_SHOCKRESISTANCE = 5;
@NotPersistent
public transient static final int INT_UNITTOUGHNESS = 6;
public transient static final int INT_UNITTOUGHNESS = 6;
@NotPersistent
public transient static final int INT_ENTANGLERESISTANCE = 7;
@NotPersistent
public transient static final int INT_POTENTIALENERGY = 8;
public transient static final int INT_POTENTIALENERGY = 8;
@NotPersistent
public transient static final int INT_OVERALLQUALITY = 9;
public transient static final int INT_OVERALLQUALITY = 9;
@NotPersistent
public transient static final int INT_FLAVOR = 10;
public transient static final int INT_FLAVOR = 10;
@NotPersistent
public transient static final String[] statNamesLookup = {"Cold Resistance",
"Conductivity",
"Decay Resistance",
"Heat Resistance",
"Malleability",
"Shock Resistance",
"Unit Toughness",
"Entangle Resistance",
"Potential Energy",
"Overall Quality",
"Flavor"};
public transient static final String [] statNamesLookup = { "Cold Resistance", "Conductivity", "Decay Resistance", "Heat Resistance", "Malleability", "Shock Resistance", "Unit Toughness", "Entangle Resistance", "Potential Energy", "Overall Quality", "Flavor" };
private byte poolNumber;
private byte poolNumber;
@SuppressWarnings("unused")
private String stfName;
@SuppressWarnings("unused")
private String iffName;
@SuppressWarnings("unused")
private int type;
private byte generalType;
private byte generalType;
private byte containerType;
private String resourceClass;
private String getresourceType;
private String getresourceType;
//@NotPersistent
Vector<PlanetDeposits> galacticDepositList = new Vector<PlanetDeposits>();
//@NotPersistent
Vector<Integer> spawnedPlanetIDs = new Vector<Integer>();
short[] resourceStats = new short[11];
short [] resourceStats = new short[11];
@NotPersistent
private transient static int RES_CAT_HI = 1; // Up to 99%, easy to find spots over 90%
private transient static int RES_CAT_HI = 1; // Up to 99%, easy to find spots over 90%
@NotPersistent
private transient static int RES_CAT_MID = 2; // Up to 90%, often have to settle at around 80%
private transient static int RES_CAT_MID = 2; // Up to 90%, often have to settle at around 80%
@NotPersistent
private transient static int RES_CAT_LO = 3; // Up to 70%, often have to settle around 60%
private transient static int RES_CAT_LO = 3; // Up to 70%, often have to settle around 60%
@NotPersistent
private transient static int RES_CAT_CRE = 4; // Creature resource
private transient static int RES_CAT_CRE = 4; // Creature resource
@NotPersistent // Direct Persistence Layer entity reference restriction
@NotPersistent
// Direct Persistence Layer entity reference restriction
private transient ResourceRoot resourceRoot;
private int resourceRootID; // This is for re-referencing the resourceRoot in the reloaded resourceRoot collection
@@ -136,17 +126,22 @@ public class GalacticResource extends SWGObject implements Serializable {
@NotPersistent
private transient double minDist = 99999.0;
public GalacticResource(){
public GalacticResource() {
super();
createResourceName();
}
public GalacticResource(long objectID, Planet planet, Point3D position, Quaternion orientation, String template){
public GalacticResource(long objectID, Planet planet, Point3D position, Quaternion orientation, String template) {
super(objectID, planet, position, orientation, template);
this.id = objectID;
createResourceName();
}
public GalacticResource(long id){
private void createResourceName() {
this.name = NAME_SYLLABLE_1[(int) new Random().nextInt(NAME_SYLLABLE_1.length - 1)] + NAME_SYLLABLE_2[(int) new Random().nextInt(NAME_SYLLABLE_2.length - 1)] + NAME_SYLLABLE_3[(int) new Random().nextInt(NAME_SYLLABLE_3.length - 1)];
}
public GalacticResource(long id) {
this.id = id;
}
@@ -155,66 +150,61 @@ public class GalacticResource extends SWGObject implements Serializable {
init();
}
public GalacticResource(String name, String fileName, String category){
this.name = name;
public GalacticResource(String fileName, String category) {
createResourceName();
this.fileName = fileName;
this.category = category;
//this.type = type;
long range = 1234567L;
Random r = new Random();
this.id = (long)(r.nextDouble()*range);
this.id = (long) (r.nextDouble() * range);
}
public Long getId(){
public Long getId() {
return id;
}
public void setId(Long Id){
public void setId(Long Id) {
this.id = Id;
}
public String getName(){
public String getName() {
return name;
}
public void setName(String name){
this.name = name;
}
public String getFileName(){
public String getFileName() {
return fileName;
}
public String getCategory(){
public String getCategory() {
return category;
}
}
public byte getPoolNumber(){
public byte getPoolNumber() {
return poolNumber;
}
}
public void setPoolNumber(byte poolNumber){
public void setPoolNumber(byte poolNumber) {
this.poolNumber = poolNumber;
}
}
public byte getGeneralType(){
public byte getGeneralType() {
return generalType;
}
}
public void setGeneralType(byte generalType){
public void setGeneralType(byte generalType) {
this.generalType = generalType;
}
}
public boolean isSpawnedOn(int planetId){
public boolean isSpawnedOn(int planetId) {
if (spawnedPlanetIDs.contains(planetId))
return true;
return true;
return false;
}
public void initializeNewGalaxyResource(Vector<String> completeResourceNameHistory){
public void initializeNewGalaxyResource() {
galacticDepositList.clear();
constructResourceName(completeResourceNameHistory);
generateResourceType();
generateResourceStats();
generatePlanetarySpawns();
@@ -223,256 +213,260 @@ public class GalacticResource extends SWGObject implements Serializable {
this.category = resourceRoot.getResourceClass();
this.setGeneralType(resourceRoot.getGeneralType());
this.setResourceRootID(resourceRoot.getResourceRootID()); // FK
//setResourceContainerTemplateID(resourceRoot.getTemplateID());
//setResourceContainerTemplateID(resourceRoot.getTemplateID());
}
public void generateResourceType(){
// this.setResourceType(template.getResourceType());
// this.setResourceClass(template.getResourceClass());
public void generateResourceType() {
// this.setResourceType(template.getResourceType());
// this.setResourceClass(template.getResourceClass());
}
public void generateResourceStats(){
public void generateResourceStats() {
// Generate the stats randomly, considering the caps
for (int k=0;k<resourceRoot.getResourceMinCaps().length; k++) {
for (int k = 0; k < resourceRoot.getResourceMinCaps().length; k++) {
//short result = 0;
short randomStatValue = 0;
if ((resourceRoot.getResourceMaxCaps()[k]-resourceRoot.getResourceMinCaps()[k])>0)
randomStatValue = (short) (resourceRoot.getResourceMinCaps()[k] + new Random().nextInt(resourceRoot.getResourceMaxCaps()[k]-resourceRoot.getResourceMinCaps()[k]));
if ((resourceRoot.getResourceMaxCaps()[k] - resourceRoot.getResourceMinCaps()[k]) > 0)
randomStatValue = (short) (resourceRoot.getResourceMinCaps()[k] + new Random().nextInt(resourceRoot.getResourceMaxCaps()[k] - resourceRoot.getResourceMinCaps()[k]));
resourceStats[k] = randomStatValue;
}
}
}
//Better not to make this publically available
private void setResourceStats(short[] statArray){
private void setResourceStats(short [] statArray) {
this.resourceStats = statArray;
}
public short[] getResourceStats(){
public short [] getResourceStats() {
return this.resourceStats;
}
public void setResourceRoot(ResourceRoot root){
public void setResourceRoot(ResourceRoot root) {
this.resourceRoot = root;
}
public ResourceRoot getResourceRoot(){
public ResourceRoot getResourceRoot() {
return this.resourceRoot;
}
public void setPlanetID(int planetID){
public void setPlanetID(int planetID) {
spawnedPlanetIDs.add(planetID);
}
public void generateSpawnTimes(){
public void generateSpawnTimes() {
long minimumTime = resourceRoot.getMinimalLifeTime();
long maximumTime = resourceRoot.getMaximalLifeTime();
long randomTime = new Random(maximumTime).nextLong();
long randomTime = new Random(maximumTime).nextLong();
this.spawnTime = System.currentTimeMillis();
this.vanishTime = spawnTime + minimumTime + randomTime;
}
public int[] generateRandomPlanetArray(){
int planets = 6 + new Random().nextInt(2);
int[] outpool = new int[planets];
int[] pool = new int[10]; // 10 Number of SWG planets
for (int i = 0; i < 10; i++) pool[i] = i+1;
for (int i = 0; i < planets; i++) outpool[i] = i+1;
shuffleArray(pool);
for (int i = 0; i < outpool.length; i++)
{
outpool[i]=pool[i];
}
return outpool;
}
public void shuffleArray(int[] ar)
{
Random rnd = new Random();
for (int i = ar.length - 1; i > 0; i--)
{
int index = rnd.nextInt(i + 1);
int a = ar[index];
ar[index] = ar[i];
ar[i] = a;
}
}
public void generatePlanetarySpawns(){
public int [] generateRandomPlanetArray() {
int planets = 6 + new Random().nextInt(2);
int [] outpool = new int[planets];
int [] pool = new int[10]; // 10 Number of SWG planets
for (int i = 0; i < 10; i++)
pool[i] = i+1;
for (int i = 0; i < planets; i++)
outpool[i] = i+1;
shuffleArray(pool);
for (int i = 0; i < outpool.length; i++) {
outpool[i] = pool[i];
}
return outpool;
}
public void shuffleArray(int [] ar) {
Random rnd = new Random();
for (int i = ar.length - 1; i > 0; i--) {
int index = rnd.nextInt(i + 1);
int a = ar[index];
ar[index] = ar[i];
ar[i] = a;
}
}
public void generatePlanetarySpawns() {
// Generate a number of planets the resource will spawn on
int[] randomPlanetArray = generateRandomPlanetArray();
if (poolNumber!=4){
for (int i = 0; i < randomPlanetArray.length; i++){
if (!spawnedPlanetIDs.contains(i)){
int [] randomPlanetArray = generateRandomPlanetArray();
if (poolNumber != 4) {
for (int i = 0; i < randomPlanetArray.length; i++) {
if (!spawnedPlanetIDs.contains(i)) {
PlanetDeposits planetDeposits = new PlanetDeposits();
planetDeposits.setPlanetId(randomPlanetArray[i]);
spawnedPlanetIDs.add(randomPlanetArray[i]);
planetDeposits.addDeposits(generateDepositSpawns());
planetDeposits.addDeposits(generateDepositSpawns());
galacticDepositList.add(planetDeposits);
}
}
} else {
PlanetDeposits planetDeposits = new PlanetDeposits();
planetDeposits.setPlanetId(getAllSpawnedPlanetIds().get(0));
planetDeposits.addDeposits(generateDepositSpawns());
planetDeposits.addDeposits(generateDepositSpawns());
galacticDepositList.add(planetDeposits);
}
}
public Vector<ResourceDeposit> generateDepositSpawns(){
public Vector<ResourceDeposit> generateDepositSpawns() {
Vector<ResourceDeposit> depositList = new Vector<ResourceDeposit>();
// Calculate deposit positions
Random generator = new Random();
int depositQuantity = 8 + generator.nextInt(24);
int depositQuantity = 10;
// int depositQuantity = 100;
// datatables/clientregion -> cities
for (int i = 0; i < depositQuantity; i++) {
ResourceDeposit deposit = new ResourceDeposit();
generator = new Random(); // Exclude mountains at the edge of the maps
int spawnCoordsX = generator.nextInt(15000) - 7500;
int spawnCoordsZ = generator.nextInt(15000) - 7500;
int spawnCoordsX = 0;
int spawnCoordsZ = 0;
for (int k = 0; k < 10; k++) {
spawnCoordsX = generator.nextInt(15000) - 7500;
spawnCoordsZ = generator.nextInt(15000) - 7500;
boolean works = true;
for (ResourceDeposit r : depositList) {
double dist = Math.pow(r.getSpawnCoordinatesX() - spawnCoordsX, 2);
dist += Math.pow(r.getSpawnCoordinatesZ() - spawnCoordsZ, 2);
dist = Math.sqrt(dist);
if (dist < 1500) {
works = false;
break;
}
}
if (works)
break;
}
// check maybe for: if (!core.terrainService.isWater(player.getPlanetId(), spawnCoordsX, spawnCoordsZ)) ?
generator = new Random();
int spawnConcentration = 30 + generator.nextInt(70);
generator = new Random();
int spawnRadius = 360 + generator.nextInt(1200-360);
// int spawnRadius = 360 + generator.nextInt(1200-360);
int spawnRadius = 1500 + generator.nextInt(1000);
deposit.setSpawnRadius(spawnRadius);
deposit.setSpawnConcentration(spawnConcentration);
deposit.setSpawnConcentration(spawnConcentration);
//System.out.println("spawnConcentration " + spawnConcentration);
deposit.setSpawnCoordinatesX(spawnCoordsX);
deposit.setSpawnCoordinatesZ(spawnCoordsZ);
depositList.add(deposit);
depositList.add(deposit);
}
return depositList;
}
public float deliverConcentrationForSurvey(int planetId, float coordsX, float coordsY) {
float measuredOutput = 0;
for (int i = 0; i < galacticDepositList.size(); i++) {
PlanetDeposits deposits = galacticDepositList.get(i);
if (deposits.getPlanetId()==planetId){
if (deposits.getPlanetId() == planetId) {
List<ResourceDeposit> depositList = deposits.getDeposits();
for (int j=0;j<depositList.size();j++){
for (int j = 0; j < depositList.size(); j++) {
ResourceDeposit resourceDeposit = depositList.get(j);
int spawnCoordsX = (int)resourceDeposit.getSpawnCoordinatesX();
int spawnCoordsZ = (int)resourceDeposit.getSpawnCoordinatesZ();
int spawnRadius = (int)resourceDeposit.getSpawnRadius();
float deltaX = coordsX-spawnCoordsX;
float deltaY = coordsY-spawnCoordsZ;
float localConcentration=0;
double hypothen = Math.sqrt(deltaX*deltaX+deltaY*deltaY);
if (hypothen<minDist)
int spawnCoordsX = (int) resourceDeposit.getSpawnCoordinatesX();
int spawnCoordsZ = (int) resourceDeposit.getSpawnCoordinatesZ();
float spawnRadius = resourceDeposit.getSpawnRadius();
float deltaX = coordsX - spawnCoordsX;
float deltaY = coordsY - spawnCoordsZ;
float localConcentration = 0;
double hypothen = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
if (hypothen < minDist)
minDist = hypothen;
if (hypothen<spawnRadius) {
double depositConcentrationFactor = 1.0f -(hypothen/spawnRadius);
localConcentration = (float)(depositConcentrationFactor*resourceDeposit.getSpawnConcentration());
if (localConcentration>measuredOutput) {
measuredOutput=localConcentration;
if (hypothen < spawnRadius) {
double depositConcentrationFactor = 1.0f - (hypothen / spawnRadius);
localConcentration = (float) (depositConcentrationFactor * resourceDeposit.getSpawnConcentration() / 100);
localConcentration *= 100;
if (localConcentration > measuredOutput) {
measuredOutput = localConcentration;
}
}
}
}
}
}
if (measuredOutput<=10.0f)
if (measuredOutput <= 10.0f)
return 0;
//measuredOutput=80.0f;
return measuredOutput;
}
public Vector<ResourceConcentration> buildConcentrationsCollection(Point3D measurePos, GalacticResource resource, float radius,float differential, int planetId){
float leftXCoordinate = measurePos.x - (0.5f*radius);
float topZCoordinate = measurePos.z - (0.5f*radius);
public Vector<ResourceConcentration> buildConcentrationsCollection(Point3D measurePos, GalacticResource resource, float radius, float differential, int planetId) {
float leftXCoordinate = measurePos.x - (0.5f * radius);
float topZCoordinate = measurePos.z - (0.5f * radius);
float cursorX = leftXCoordinate;
float cursorZ = topZCoordinate;
int divisions=5;
if (radius<=192.0f){
int divisions = 5;
if (radius <= 192.0f) {
divisions = 4;
}
if (radius<=64.0f){
if (radius <= 64.0f) {
divisions = 3;
}
Vector<ResourceConcentration> concentrationsCollection = new Vector<ResourceConcentration>();
for (int z=0;z<divisions;z++) {
for (int x=0;x<divisions;x++) {
ResourceConcentration concentration = new ResourceConcentration(cursorX,cursorZ,(resource.deliverConcentrationForSurvey(planetId, cursorX, cursorZ)));
for (int z = 0; z < divisions; z++) {
for (int x = 0; x < divisions; x++) {
ResourceConcentration concentration = new ResourceConcentration(cursorX, cursorZ, (resource.deliverConcentrationForSurvey(planetId, cursorX, cursorZ)));
concentrationsCollection.add(concentration);
cursorZ+=differential;
cursorZ += differential;
}
cursorZ=topZCoordinate;
cursorX+=differential;
}
return concentrationsCollection;
cursorZ = topZCoordinate;
cursorX += differential;
}
return concentrationsCollection;
}
public void constructSurveyMapMessage(CreatureObject crafter, Vector<ResourceConcentration> concentrationMap, float radius){
public void constructSurveyMapMessage(CreatureObject crafter, Vector<ResourceConcentration> concentrationMap, float radius) {
int pointsAmount = 25;
if (radius<=64.0f) {
pointsAmount=9;
} else if (radius<=128.0) {
if (radius <= 64.0f) {
pointsAmount = 9;
} else if (radius <= 128.0) {
pointsAmount = 16;
} else if (radius<=192.0f) {
} else if (radius <= 192.0f) {
pointsAmount = 16;
} else if (radius<=256.0f) {
} else if (radius <= 256.0f) {
pointsAmount = 25;
} else if (radius>=256.0f) {
} else if (radius >= 256.0f) {
pointsAmount = 25;
}
SurveyMapUpdateMessage smuMsg = new SurveyMapUpdateMessage(concentrationMap, pointsAmount);
crafter.getClient().getSession().write(smuMsg.serialize());
crafter.getClient().getSession().write(smuMsg.serialize());
tools.CharonPacketUtils.printAnalysis(smuMsg.serialize());
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
if (smuMsg.getHighestConcentration() > 0.10f){
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
if (smuMsg.getHighestConcentration() > 0.10f) {
WaypointObject lastSurveyWaypoint = player.getLastSurveyWaypoint();
WaypointObject surveyWaypoint = null;
if (lastSurveyWaypoint==null){
surveyWaypoint = (WaypointObject) NGECore.getInstance().objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", crafter.getPlanet(), smuMsg.getHighestX(), 0 ,smuMsg.getHighestZ());
if (lastSurveyWaypoint == null) {
surveyWaypoint = (WaypointObject) NGECore.getInstance().objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", crafter.getPlanet(), smuMsg.getHighestX(), 0, smuMsg.getHighestZ());
surveyWaypoint.setName("Survey location");
surveyWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(crafter.getPlanet().getName()));
surveyWaypoint.setPosition(new Point3D(smuMsg.getHighestX(),0, smuMsg.getHighestZ()));
surveyWaypoint.setPosition(new Point3D(smuMsg.getHighestX(), 0, smuMsg.getHighestZ()));
player.waypointAdd(surveyWaypoint);
surveyWaypoint.setPosition(new Point3D(smuMsg.getHighestX(),0, smuMsg.getHighestZ()));
surveyWaypoint.setPosition(new Point3D(smuMsg.getHighestX(), 0, smuMsg.getHighestZ()));
surveyWaypoint.setActive(true);
surveyWaypoint.setColor((byte)1);
surveyWaypoint.setColor((byte) 1);
surveyWaypoint.setStringAttribute("", "");
player.waypointAdd(surveyWaypoint);
surveyWaypoint.setName("Survey location");
surveyWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(crafter.getPlanet().getName()));
surveyWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(crafter.getPlanet().getName()));
player.setLastSurveyWaypoint(surveyWaypoint);
} else {
surveyWaypoint = lastSurveyWaypoint;
surveyWaypoint.setPosition(new Point3D(smuMsg.getHighestX(),0, smuMsg.getHighestZ()));
player.waypointUpdate(surveyWaypoint);
}
surveyWaypoint.setPosition(new Point3D(smuMsg.getHighestX(), 0, smuMsg.getHighestZ()));
player.waypointUpdate(surveyWaypoint);
}
crafter.sendSystemMessage("@survey:survey_waypoint", (byte) 0);
}
}
// Redundant just for Testing !!!
public double getHelperMinDist(){
public double getHelperMinDist() {
return minDist;
}
public void constructResourceName(Vector<String> completeResourceNameHistory){
// ToDo: This is where the database check for past names must be added
boolean check=true;
while(check)
{
this.name = NAME_SYLLABLE_1[(int) new Random().nextInt(NAME_SYLLABLE_1.length-1)]
+ NAME_SYLLABLE_2[(int) new Random().nextInt(NAME_SYLLABLE_2.length-1)]
+ NAME_SYLLABLE_3[(int) new Random().nextInt(NAME_SYLLABLE_3.length-1)];
check = completeResourceNameHistory.contains(this.name);
}
}
public Vector<PlanetDeposits> getGalacticDepositList(){
public Vector<PlanetDeposits> getGalacticDepositList() {
return galacticDepositList;
}
@@ -488,19 +482,19 @@ public class GalacticResource extends SWGObject implements Serializable {
public String getIffFileName() {
return this.fileName;
}
// protected String getStfFileName() {
// return stfName;
// }
//
// protected void setSffFileName(String stfName) {
// this.stfName = iffName;
// }
// protected String getStfFileName() {
// return stfName;
// }
//
// protected void setSffFileName(String stfName) {
// this.stfName = iffName;
// }
public byte getContainerType() {
return containerType;
}
public void setContainerType(byte containerType) {
this.containerType = containerType;
}
@@ -508,65 +502,49 @@ public class GalacticResource extends SWGObject implements Serializable {
public long getVanishTime() {
return vanishTime;
}
public void setVanishTime(long vanishTime) {
this.vanishTime = vanishTime;
}
@NotPersistent
public final static String[] GENERAL_TYPES = {
"resource_mineral",
"resource_chemical",
"resource_flora",
"resource_gas",
"resource_water",
"resource_solar",
"resource_wind",
"resource_geothermal",
"resource_tidal",
"resource_hydron",
"resource_bones",
"resource_hide",
"resource_meat",
"resource_milk",
"resource_JTL"
};
public final static String [] GENERAL_TYPES = { "resource_mineral", "resource_chemical", "resource_flora", "resource_gas", "resource_water", "resource_solar", "resource_wind", "resource_geothermal", "resource_tidal", "resource_hydron", "resource_bones", "resource_hide", "resource_meat", "resource_milk", "resource_JTL" };
@NotPersistent
public final static byte GENERAL_MINERAL = 0;
public final static byte GENERAL_MINERAL = 0;
@NotPersistent
public final static byte GENERAL_CHEMICAL = 1;
@NotPersistent
public final static byte GENERAL_FLORA = 2;
public final static byte GENERAL_FLORA = 2;
@NotPersistent
public final static byte GENERAL_GAS = 3;
public final static byte GENERAL_GAS = 3;
@NotPersistent
public final static byte GENERAL_WATER = 4;
public final static byte GENERAL_WATER = 4;
@NotPersistent
public final static byte GENERAL_SOLAR = 5;
public final static byte GENERAL_SOLAR = 5;
@NotPersistent
public final static byte GENERAL_WIND = 6;
public final static byte GENERAL_WIND = 6;
@NotPersistent
public final static byte GENERAL_GEOTHERM = 7;
@NotPersistent
public final static byte GENERAL_TIDAL = 8;
public final static byte GENERAL_TIDAL = 8;
@NotPersistent
public final static byte GENERAL_HYDRON = 9;
public final static byte GENERAL_HYDRON = 9;
@NotPersistent
public final static byte GENERAL_BONES = 10;
public final static byte GENERAL_BONES = 10;
@NotPersistent
public final static byte GENERAL_HORN = 11;
public final static byte GENERAL_HORN = 11;
@NotPersistent
public final static byte GENERAL_HIDE = 12;
public final static byte GENERAL_HIDE = 12;
@NotPersistent
public final static byte GENERAL_MEAT = 13;
public final static byte GENERAL_MEAT = 13;
@NotPersistent
public final static byte GENERAL_MILK = 14;
public final static byte GENERAL_MILK = 14;
@NotPersistent
public final static byte GENERAL_JTL = 15;
public final static byte GENERAL_JTL = 15;
@NotPersistent
public final static String[] CONTAINER_TYPES = {
public final static String [] CONTAINER_TYPES = {
"inorganic_minerals_small",
"inorganic_chemicals_small",
"organic_food_small",
@@ -582,105 +560,45 @@ public class GalacticResource extends SWGObject implements Serializable {
"organic_hide_small",
"organic_food_small",
"organic_milk_small",
"resource_JTL"
};
@NotPersistent
private static String[] NAME_SYLLABLE_1 = {"Zi", "Ao", "Bo", "Gox",
"Ru", "Su", "Tu", "Uu", "Vu", "Wu", "Xu", "Yu", "Zu",
"Ie", "Ce", "Ia", "Tip", "Tri", "Rel", "Xio", "Che", "Fa", "Po",
"Pae", "Doi", "Wa", "Rup", "Ovi", "Ove", "Tae", "Nao", "Lao",
"Lin", "Lex", "Loex", "Paex", "Bib", "Jaw", "Xat", "Lape", "Su",
"Sae", "Epo", "Vix", "Vu", "Ke", "Kel", "Koi", "Cix", "Pal", "Pla",
"Sor", "Lak", "Lek", "Waf", "Weg", "Ga", "Gix", "Nai", "Su",
"Aa", "Ba", "Ca", "Da", "Ea", "Fa", "Ga", "Ha", "Ia", "Ja", "Ka",
"La", "Ma", "Na", "Oa", "Pa", "Qa", "Ra", "Sa", "Ta", "Ua", "Va",
"Wa", "Xa", "Ya", "Za", "Ae", "Be", "Ce", "De", "Ee", "Fe", "Ge",
"He", "Ie", "Je", "Ke", "Le", "Me", "Ne", "Oe", "Pe", "Qe", "Re",
"Se", "Te", "Ue", "Ve", "We", "Xe", "Ye", "Ze", "Ai", "Bi", "Ci",
"Di", "Ei", "Fi", "Gi", "Hi", "Ii", "Ji", "Ki", "Li", "Mi", "Ni",
"Oi", "Pi", "Qi", "Ri", "Si", "Ti", "Ui", "Vi", "Wi", "Xi", "Yi",
"Re", "Iso", "Nab", "Co", "Do", "Eo", "Fo", "Go", "Ho", "Io", "Jo",
"Ko", "Lo", "Mo", "No", "Oo", "Po", "Qo", "Ro", "So", "To", "Uo",
"Vo", "Wo", "Xo", "Yo", "Zo", "Au", "Bu", "Cu", "Du", "Eu", "Fu",
"Or", "Ved", "Pos", "Xe", "Ex", "Sti", "Ir", "Ake", "Geh", "Fig",
"Gu", "Hu", "Iu", "Ju", "Ku", "Lu", "Mu", "Nu", "Ou", "Pu", "Qu",
"Rel", "Xio", "Ie", "Ce", "Ia", "Tip", "Tri", "Che", "Fa", "Po"};
"resource_JTL"};
@NotPersistent
private static String[] NAME_SYLLABLE_2 = {"gi", "hi", "ii", "qo", "ro",
"da", "ea", "fa", "ga", "ha", "ia", "ja", "ka", "la", "ma", "na",
"oa", "pa", "qa", "ra", "sa", "ta", "ua", "va", "wa", "xa", "ya",
"za", "ae", "be", "ce", "de", "ee", "fe", "ge", "he", "ie", "je",
"ke", "le", "me", "ne", "oe", "pe", "qe", "re", "se", "te", "ue",
"ve", "we", "xe", "ye", "ze", "ai", "bi", "ci", "di", "ei", "fi",
"uu", "vu", "wu", "xu", "yu", "zu", "mi", "ni", "oi", "pi", "qi",
"ri", "si", "ti", "ui", "vi", "wi", "xi", "yi", "zi", "ao", "bo",
"co", "do", "eo", "fo", "go", "ho", "io", "jo", "ko", "lo", "mo",
"no", "oo", "po", "so", "to", "uo", "vo", "wo", "xo", "mu", "nu",
"yo", "zo", "au", "bu", "cu", "du", "eu", "fu", "gu", "hu", "iu",
"aa", "ba", "ca", "ji", "ki", "li"};
private static String [] NAME_SYLLABLE_1 = { "Zi", "Ao", "Bo", "Gox", "Ru", "Su", "Tu", "Uu", "Vu", "Wu", "Xu", "Yu", "Zu", "Ie", "Ce", "Ia", "Tip", "Tri", "Rel", "Xio", "Che", "Fa", "Po", "Pae", "Doi", "Wa", "Rup", "Ovi", "Ove", "Tae", "Nao", "Lao", "Lin", "Lex", "Loex", "Paex", "Bib", "Jaw", "Xat", "Lape", "Su", "Sae", "Epo", "Vix", "Vu", "Ke", "Kel", "Koi", "Cix", "Pal", "Pla", "Sor", "Lak", "Lek", "Waf", "Weg", "Ga", "Gix", "Nai", "Su", "Aa", "Ba", "Ca", "Da", "Ea", "Fa", "Ga", "Ha", "Ia", "Ja", "Ka", "La", "Ma", "Na", "Oa", "Pa", "Qa", "Ra", "Sa", "Ta", "Ua", "Va", "Wa", "Xa", "Ya", "Za", "Ae", "Be", "Ce", "De", "Ee", "Fe", "Ge", "He", "Ie", "Je", "Ke", "Le", "Me", "Ne", "Oe", "Pe", "Qe", "Re", "Se", "Te", "Ue", "Ve", "We", "Xe", "Ye", "Ze", "Ai", "Bi", "Ci", "Di", "Ei", "Fi", "Gi", "Hi", "Ii", "Ji", "Ki", "Li", "Mi", "Ni", "Oi", "Pi", "Qi", "Ri", "Si", "Ti", "Ui", "Vi", "Wi", "Xi", "Yi", "Re", "Iso", "Nab", "Co", "Do", "Eo", "Fo", "Go", "Ho", "Io", "Jo", "Ko", "Lo", "Mo", "No", "Oo", "Po", "Qo", "Ro", "So", "To", "Uo", "Vo", "Wo", "Xo", "Yo", "Zo", "Au", "Bu", "Cu", "Du", "Eu", "Fu", "Or", "Ved", "Pos", "Xe", "Ex", "Sti", "Ir", "Ake", "Geh", "Fig", "Gu", "Hu", "Iu", "Ju", "Ku", "Lu", "Mu", "Nu", "Ou", "Pu", "Qu", "Rel", "Xio", "Ie", "Ce", "Ia", "Tip", "Tri", "Che", "Fa", "Po" };
@NotPersistent
private static String[] NAME_SYLLABLE_3 = {"fui", "gti", "hsi", "dwi",
"mna", "nma", "ola", "pka", "qja", "ria", "sha", "tga", "ufa",
"eve", "fue", "gte", "hse", "ire", "jqe", "kpe", "loe", "mne",
"wde", "xce", "ybe", "zae", "azi", "byi", "cxi", "dwi", "evi",
"iri", "jqi", "kpi", "loi", "mni", "nmi", "aza", "bya", "cxa",
"oli", "pki", "qji", "rii", "shi", "tgi", "ufi", "vei", "wdi",
"xci", "ybi", "zai", "azo", "byo", "cxo", "dwo", "evo", "fuo",
"dwa", "eva", "fua", "gta", "hsa", "ira", "jqa", "kpa", "loa",
"gto", "hso", "iro", "jqo", "kpo", "loo", "mno", "nmo", "olo",
"pko", "qjo", "rio", "sho", "tgo", "ufo", "veo", "wdo", "xco",
"ybo", "zao", "azu", "byu", "cxu", "dwu", "evu", "fuu", "gtu",
"nme", "ole", "pke", "qje", "rie", "she", "tge", "ufe", "vee",
"hsu", "iru", "jqu", "kpu", "lou", "mnu", "nmu", "olu", "pku",
"vea", "wda", "xca", "yba", "zaa", "aze", "bye", "cxe", "dwe",
"qju", "riu", "shu", "tgu", "ufu", "veu", "wdu", "xcu", "ybu",
"zau"};
private static String [] NAME_SYLLABLE_2 = { "gi", "hi", "ii", "qo", "ro", "da", "ea", "fa", "ga", "ha", "ia", "ja", "ka", "la", "ma", "na", "oa", "pa", "qa", "ra", "sa", "ta", "ua", "va", "wa", "xa", "ya", "za", "ae", "be", "ce", "de", "ee", "fe", "ge", "he", "ie", "je", "ke", "le", "me", "ne", "oe", "pe", "qe", "re", "se", "te", "ue", "ve", "we", "xe", "ye", "ze", "ai", "bi", "ci", "di", "ei", "fi", "uu", "vu", "wu", "xu", "yu", "zu", "mi", "ni", "oi", "pi", "qi", "ri", "si", "ti", "ui", "vi", "wi", "xi", "yi", "zi", "ao", "bo", "co", "do", "eo", "fo", "go", "ho", "io", "jo", "ko", "lo", "mo", "no", "oo", "po", "so", "to", "uo", "vo", "wo", "xo", "mu", "nu", "yo", "zo", "au", "bu", "cu", "du", "eu", "fu", "gu", "hu", "iu", "aa", "ba", "ca", "ji", "ki", "li" };
@NotPersistent
private static String [] NAME_SYLLABLE_3 = { "fui", "gti", "hsi", "dwi", "mna", "nma", "ola", "pka", "qja", "ria", "sha", "tga", "ufa", "eve", "fue", "gte", "hse", "ire", "jqe", "kpe", "loe", "mne", "wde", "xce", "ybe", "zae", "azi", "byi", "cxi", "dwi", "evi", "iri", "jqi", "kpi", "loi", "mni", "nmi", "aza", "bya", "cxa", "oli", "pki", "qji", "rii", "shi", "tgi", "ufi", "vei", "wdi", "xci", "ybi", "zai", "azo", "byo", "cxo", "dwo", "evo", "fuo", "dwa", "eva", "fua", "gta", "hsa", "ira", "jqa", "kpa", "loa", "gto", "hso", "iro", "jqo", "kpo", "loo", "mno", "nmo", "olo", "pko", "qjo", "rio", "sho", "tgo", "ufo", "veo", "wdo", "xco", "ybo", "zao", "azu", "byu", "cxu", "dwu", "evu", "fuu", "gtu", "nme", "ole", "pke", "qje", "rie", "she", "tge", "ufe", "vee", "hsu", "iru", "jqu", "kpu", "lou", "mnu", "nmu", "olu", "pku", "vea", "wda", "xca", "yba", "zaa", "aze", "bye", "cxe", "dwe", "qju", "riu", "shu", "tgu", "ufu", "veu", "wdu", "xcu", "ybu", "zau" };
@Override
public void sendBaselines(Client arg0) {
}
public int getResourceRootID() {
return resourceRootID;
}
public void setResourceRootID(int resourceRootID) {
this.resourceRootID = resourceRootID;
}
public String getResourceClass() {
return resourceClass;
}
public void setResourceClass(String resourceClass) {
this.resourceClass = resourceClass;
}
public String getResourceType() {
return getresourceType;
}
public void setResourceType(String getresourceType) {
this.getresourceType = getresourceType;
}
public GalacticResource convertToHistoricResource(){
GalacticResource historicResource = new GalacticResource();
historicResource.setName(this.getName());
historicResource.setResourceClass(this.getResourceClass());
historicResource.setResourceStats(this.getResourceStats());
historicResource.setResourceType(this.getResourceType());
historicResource.setGeneralType(this.getGeneralType());
historicResource.setId(this.getId());
historicResource.setIffFileName(this.getIffFileName());
return historicResource;
}
@Override
public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) {
// TODO Auto-generated method stub
@@ -0,0 +1,128 @@
package resources.objects.resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public enum ResourceClass {
IRON("Iron", 0),
ALUMINUM("Aluminum", 0),
STEEL("Steel", 0),
COPPER("Copper", 0),
ORE_EXTRUSIVE("Extrusive Ore", 0),
ORE_INTRUSIVE("Intrusive Ore", 0),
ORE_CARBONITE("Carbonite Ore", 0),
ORE_CARBONATE("Carbonate Ore", 0),
ORE_SILICLASTIC("Siliclastic Ore", 0),
CRYSTALLINE_GEMSTONE("Crystalline Gemstone", 0),
AMORPHOUS_GEMSTONE("Amorphous Gemstone", 0),
NON_FERROUS("Non-Ferrous", 0),
SEDIMENTARY_ORE("Sedimentary Ore", 0),
IGNEOUS_ORE("Igneous Ore", 0),
GEMSTONE("Gemstone", 0),
TYPE_1_CRYSTAL_AMORPHOUS_GEM("Type 1 Crystal Amorphous Gem", 0),
TYPE_2_CRYSTAL_AMORPHOUS_GEM("Type 2 Crystal Amorphous Gem", 0),
TYPE_1_CRYSTALLINE_GEM("Type 1 Crystalline Gem", 0),
TYPE_2_CRYSTALLINE_GEM("Type 2 Crystalline Gem", 0),
RADIOACTIVE("Radioactive", 0),
FERROUS_METAL("Ferrous Metal", 0),
PETROCHEMICAL_SOLID("Petrochemical Solid", 1),
PETROCHEMICAL_LIQUID("Petrochemical Liquid", 1),
POLYMER("Polymer", 1),
PETRO_FUEL("Petro Fuel", 1),
FIBERPLAST("Fiberplast", 1),
LIQUID_PETRO_FUEL("Liquid Petro Fuel", 1),
SOLID_PETRO_FUEL("Solid Petro Fuel", 1),
LUBRICATING_OIL("Lubricating Oil", 1),
OIL("Oil", 1),
VEGETABLE_FUNGI("Vegetable Fungi", 2),
VEGETABLE_FRUITS("Vegetable Fruits", 2),
VEGETABLE_BERRIES("Vegetable Berries", 2),
CONIFER_WOOD("Conifer Wood", 2),
EVERGREEN_WOOD("Evergreen Wood", 2),
DECIDUOUS_WOOD("Deciduous Wood", 2),
FRUIT("Fruit", 2),
FLOWER_FRUIT("Flower Fruit", 2),
DOMESTICATED_CORN("Domesticated Corn", 2),
DOMESTICATED_OATS("Domesticated Oats", 2),
DOMESTICATED_RICE("Domesticated Rice", 2),
DOMESTICATED_WHEAT("Domesticated Wheat", 2),
WILD_CORN("Wild Corn", 2),
WILD_OATS("Wild Oats", 2),
WILD_RICE("Wild Rice", 2),
WILD_WHEAT("Wild Wheat", 2),
VEGETABLE_BEANS("Vegetable Beans", 2),
BERRY_FRUIT("Berry Fruit", 2),
VEGETABLE_FUNGUS("Vegetable Fungus", 2),
VEGETABLE_GREENS("Vegetable Greens", 2),
VEGETABLE_TUBERS("Vegetable Tubers", 2),
REACTIVE_GAS("Reactive Gas", 3),
INERT_GAS("Inert Gas", 3),
WATER_VAPOR("Water Vapor", 4),
SOLAR_RENEWABLE_ENERGY("Solar Renewable Energy", 5),
WIND_RENEWABLE_ENERGY("Wind Renewable Energy", 6),
GEOTHERMAL_RENEWABLE_ENERGY("Geothermal Renewable Energy", 7),
TIDAL_RENEWABLE_ENERGY("Tidal Renewable Energy", 8),
HYDRON3_RENEWABLE_ENERGY("Hydron-3 Renewable Energy", 9),
ANIMAL_BONES("Animal Bones", 10),
AVIAN_BONES("Avian Bones", 10),
HORN("Horn", 11),
BRISTLEY_HIDE("Bristley Hide", 12),
LEATHERY_HIDE("Leathery Hide", 12),
SCALEY_HIDE("Scaley Hide", 12),
WOOLY_HIDE("Wooly Hide", 12),
AVIAN_MEAT("Avian Meat", 13),
CARNIVORE_MEAT("Carnivore Meat", 13),
DOMESTICATED_MEAT("Domesticated Meat", 13),
HERBIVORE_MEAT("Herbivore Meat", 13),
INSECT_MEAT("Insect Meat", 13),
WILD_MEAT("Wild Meat", 13),
CRUSTACEAN_MEAT("Crustacean Meat", 13),
FISH_MEAT("Fish Meat", 13),
MOLLUSK_MEAT("Mollusk Meat", 13),
REPTILIAN_MEAT("Reptilian Meat", 13),
EGG("Egg", 13),
EGG_MEAT("Egg Meat", 13),
DOMESTICATED_MILK("Domesticated Milk", 14),
WILD_MILK("Wild Milk", 14),
UNKNOWN("Unknown", 255);
private static final Map<String, ResourceClass> CLASS_MAP = new ConcurrentHashMap<String, ResourceClass>();
private String name;
private int type;
static {
for (ResourceClass c : values())
CLASS_MAP.put(c.getName(), c);
}
ResourceClass(String name, int type) {
this.name = name;
this.type = type;
}
public String getName() {
return name;
}
public int getType() {
return type;
}
public static final ResourceClass forString(String str) {
ResourceClass c = CLASS_MAP.get(str);
if (c == null)
return UNKNOWN;
return c;
}
public static final ResourceClass forEndOfString(String str) {
ResourceClass ret = forString(str);
if (ret == UNKNOWN) {
for (ResourceClass c : values())
if (str.toLowerCase().endsWith(c.getName().toLowerCase()))
return c;
}
return ret;
}
}
@@ -219,7 +219,7 @@ public class ResourceRoot implements Serializable {
return generalType;
}
public void setgeneralType(byte generalType){
public void setGeneralType(byte generalType){
this.generalType = generalType;
}
@@ -231,10 +231,6 @@ public class ResourceRoot implements Serializable {
this.containerType = containerType;
}
public void setGeneralType(byte generalType) {
this.generalType = generalType;
}
public int getResourceRootID() {
return resourceRootID;
}
File diff suppressed because it is too large Load Diff
+8 -2
View File
@@ -1124,8 +1124,14 @@ public class GuildService implements INetworkDispatch {
public boolean removeGuild(int id) {
Guild guild = getGuildById(id);
if (guild != null)
return true;
if (guild != null) {
if (object.getGuildList().remove(guild.getString())) {
object.getGuilds().remove(id);
if (!object.getGuilds().containsKey(id)) return true;
else return false;
}
else return false;
}
return false;
}
+221 -230
View File
@@ -3,25 +3,27 @@
*
* 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 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.
* 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 <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 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.
* 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.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import java.util.Vector;
@@ -35,6 +37,7 @@ import resources.harvest.SurveyTool;
import resources.objects.creature.CreatureObject;
import resources.objects.player.PlayerObject;
import resources.objects.resource.GalacticResource;
import resources.objects.resource.ResourceConcentration;
import resources.objects.resource.ResourceContainerObject;
import resources.objects.resource.ResourceRoot;
import resources.objects.tangible.TangibleObject;
@@ -47,60 +50,57 @@ import engine.resources.objects.SWGObject;
import engine.resources.service.INetworkDispatch;
import engine.resources.service.INetworkRemoteEvent;
/**
* @author Charon
/**
* @author Charon
*/
public class SurveyService implements INetworkDispatch {
private NGECore core;
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
public Vector<SurveyTool> activeSurveyTools = new Vector<SurveyTool>();
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
public Vector<SurveyTool> activeSurveyTools = new Vector<SurveyTool>();
public SurveyService(NGECore core) {
this.core = core;
scheduleSurveyService();
core.commandService.registerCommand("requestsurvey");
core.commandService.registerCommand("requestcoreSample");
}
@SuppressWarnings("unused")
public void scheduleSurveyService(){
public void scheduleSurveyService() {
final ScheduledFuture<?> task = scheduler.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
try {
ServiceProcessing();
processActiveTools();
} catch (Exception e) {
e.printStackTrace();
}
}
}, 10, 1000, TimeUnit.MILLISECONDS);
}
public void ServiceProcessing(){
synchronized(activeSurveyTools){
private void processActiveTools() {
synchronized (activeSurveyTools) {
// All tools sampling
SurveyTool removeTool=null;
for (SurveyTool surveyTool : activeSurveyTools){
if (surveyTool==null)
Iterator <SurveyTool> surveyIterator = activeSurveyTools.iterator();
while (surveyIterator.hasNext()) {
SurveyTool surveyTool = surveyIterator.next();
if (surveyTool == null)
continue;
CreatureObject user = (CreatureObject) NGECore.getInstance().objectService.getObject(surveyTool.getUserID());
if (surveyTool.getCurrentlySurveying()){
if (surveyTool.getCurrentlySurveying()) {
// Check if survey process has finished
if (System.currentTimeMillis()>surveyTool.getLastSurveyTime()+3000){
removeTool = surveyTool;
if (System.currentTimeMillis() > surveyTool.getLastSurveyTime() + 3000) {
surveyIterator.remove();
surveyTool.setCurrentlySurveying(false);
surveyTool.sendConstructSurveyMapMessage();
}
}
if (surveyTool.getCurrentlySampling()){
if (surveyTool.getCurrentlySampling()) {
// Check if sampling process has finished
if ((System.currentTimeMillis()>surveyTool.getLastSampleTime()+3000) && !surveyTool.getCurrentlyCoolingDown()){
if ((System.currentTimeMillis() > surveyTool.getLastSampleTime() + 3000) && !surveyTool.getCurrentlyCoolingDown()) {
surveyTool.setCurrentlyCoolingDown(true);
// Update inventory
handleSamplingStages(surveyTool);
@@ -108,36 +108,32 @@ public class SurveyService implements INetworkDispatch {
}
// Check if sampling recovery is over
long sampleRecoveryTime = surveyTool.getRecoveryTime();
if (System.currentTimeMillis()>surveyTool.getLastSampleTime()+sampleRecoveryTime && ! surveyTool.isExceptionalState()){
if (System.currentTimeMillis() > surveyTool.getLastSampleTime() + sampleRecoveryTime && !surveyTool.isExceptionalState()) {
// kick off another sampling attempt
surveyTool.setCurrentlyCoolingDown(false);
continueSampling(surveyTool);
}
if (user.getPosture()!=1){
if (user.getPosture() != 1) {
surveyTool.setExceptionalState(false);
surveyTool.setCurrentlySampling(false);
removeTool = surveyTool;
if (user.getPosture()==0)
surveyIterator.remove();
if (user.getPosture() == 0)
user.sendSystemMessage("You stand up", (byte) 0);
user.sendSystemMessage("@survey:sample_cancel", (byte) 0);
}
}
}
if (removeTool!=null)
activeSurveyTools.remove(removeTool); // remove after notification
activeSurveyTools.removeAll(Collections.singleton(null));
}
}
}
@SuppressWarnings("unused")
public void handleSamplingStages(SurveyTool surveyTool){
private void handleSamplingStages(SurveyTool surveyTool) {
if (surveyTool.isExceptionalState())
return;
CreatureObject crafter = (CreatureObject) NGECore.getInstance().objectService.getObject(surveyTool.getUserID());
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
CreatureObject crafter = (CreatureObject) NGECore.getInstance().objectService.getObject(surveyTool.getUserID());
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
GalacticResource sampleResource = (GalacticResource) NGECore.getInstance().objectService.getObject(surveyTool.getSurveyResourceID());
int stackCount = 0;
boolean gamblingwon = false;
@@ -145,198 +141,197 @@ public class SurveyService implements INetworkDispatch {
ResourceContainerObject container = null;
// Attempt to find container with the currently sampled resource in
// player inventory tree
ResourceContainerObject foundContainer = findResourceContainerInInventory(crafter,sampleResource);
if (foundContainer!=null)
ResourceContainerObject foundContainer = findResourceContainerInInventory(crafter, sampleResource);
if (foundContainer != null)
container = foundContainer;
if (! surveyTool.isRecoveryMode())
stackCount = core.resourceService.getResourceSampleQuantity(crafter, sampleResource);
if (!surveyTool.isRecoveryMode())
stackCount = core.resourceService.getResourceSampleQuantity(crafter, sampleResource);
else { // handle particularly rich case
stackCount = core.resourceService.getResourceSampleQuantity(crafter, sampleResource);
int recoveryChance = new Random().nextInt(100);
if (recoveryChance<99){
stackCount = core.resourceService.getResourceSampleQuantity(crafter, sampleResource);
int recoveryChance = new Random().nextInt(100);
if (recoveryChance < 99) {
gamblingwon = true;
stackCount *= 3;
}
surveyTool.setRecoveryMode(false);
}
if (container!=null) {
if (container.getReferenceID()==sampleResource.getId()) {
if (container != null) {
if (container.getReferenceID() == sampleResource.getId()) {
int stackCountToUpdate = container.getStackCount();
if (stackCountToUpdate<ResourceContainerObject.maximalStackCapacity-stackCount){ // sample fits into container
SWGObject crafterInventory = crafter.getSlottedObject("inventory");
container.setStackCount(stackCountToUpdate+stackCount,crafter);
if (stackCountToUpdate < ResourceContainerObject.maximalStackCapacity - stackCount) { // sample fits into container
SWGObject crafterInventory = crafter.getSlottedObject("inventory");
container.setStackCount(stackCountToUpdate + stackCount, crafter);
//crafter.sendSystemMessage("@base_player:prose_grant_xp @exp_n:resource_harvesting_inorganic", (byte) 0);
core.playerService.giveExperience(crafter,(int)(2.5F*stackCount));
core.playerService.giveExperience(crafter, (int) (2.5F * stackCount));
//exp_n:resource_harvesting_inorganic
//container.sendDelta3(crafter.getClient());
//container.buildAttributeListMessage(crafter.getClient());
} else { // new container
if ((stackCount > 0) && (!surveyTool.isRecoveryMode())) {
String resourceContainerIFF = ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[sampleResource.getResourceRoot().getContainerType()];
String resourceContainerIFF = ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[sampleResource.getResourceRoot().getContainerType()];
ResourceContainerObject containerObject = (ResourceContainerObject) core.objectService.createObject(resourceContainerIFF, crafter.getPlanet());
containerObject.initializeStats(sampleResource);
containerObject.setProprietor(crafter);
SWGObject crafterInventory = crafter.getSlottedObject("inventory");
containerObject.setStackCount(stackCount,crafter);
containerObject.setStackCount(stackCount, crafter);
crafterInventory.add(containerObject);
player.setRecentContainer(containerObject);
}
}
} else { // Mismatch -> new container
String resourceContainerIFF = ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[sampleResource.getResourceRoot().getContainerType()];
String resourceContainerIFF = ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[sampleResource.getResourceRoot().getContainerType()];
if ((stackCount > 0) && (!surveyTool.isRecoveryMode())) {
ResourceContainerObject containerObject = (ResourceContainerObject) core.objectService.createObject(resourceContainerIFF, crafter.getPlanet());
containerObject.initializeStats(sampleResource);
containerObject.setProprietor(crafter);
container.setStackCount(stackCount,crafter);
container.setStackCount(stackCount, crafter);
SWGObject crafterInventory = crafter.getSlottedObject("inventory");
crafterInventory.add(containerObject);
player.setRecentContainer(containerObject);
}
}
} else { // create new container, first sample
if ((stackCount > 0) && (!surveyTool.isRecoveryMode())) {
String resourceContainerIFF = ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[sampleResource.getResourceRoot().getContainerType()];
String resourceContainerIFF = ResourceRoot.CONTAINER_TYPE_IFF_SIGNIFIER[sampleResource.getResourceRoot().getContainerType()];
ResourceContainerObject containerObject = (ResourceContainerObject) core.objectService.createObject(resourceContainerIFF, crafter.getPlanet());
containerObject.initializeStats(sampleResource);
containerObject.setProprietor(crafter);
//stackCount = core.resourceService.getResourceSampleQuantity(crafter, sampleResource);
containerObject.setStackCount(stackCount,crafter);
SWGObject crafterInventory = crafter.getSlottedObject("inventory");
containerObject.setStackCount(stackCount, crafter);
SWGObject crafterInventory = crafter.getSlottedObject("inventory");
crafterInventory.add(containerObject);
player.setRecentContainer(containerObject);
}
}
if (gamblingwon) {
crafter.sendSystemMessage("@survey:critical_success", (byte) 0);
core.playerService.giveExperience(crafter,(int)(2.5F*stackCount));
core.playerService.giveExperience(crafter, (int) (2.5F * stackCount));
surveyTool.setExceptionalState(false);
return;
}
if ((stackCount > 0) && (!surveyTool.isRecoveryMode())) {
// @survey:sample_located
crafter.sendSystemMessage("You successfully locate a " + stackCount + " unit sample of " + sampleResource.getName() + "." , (byte) 0);
core.playerService.giveExperience(crafter,(int)(2.5F*stackCount));
}
crafter.sendSystemMessage("You successfully locate a " + stackCount + " unit sample of " + sampleResource.getName() + ".", (byte) 0);
core.playerService.giveExperience(crafter, (int) (2.5F * stackCount));
}
if ((stackCount > 0) && (surveyTool.isRecoveryMode())) {
crafter.sendSystemMessage("@survey:node_recovery", (byte) 0);
core.playerService.giveExperience(crafter,(int)(2.5F*stackCount));
core.playerService.giveExperience(crafter, (int) (2.5F * stackCount));
}
if ((stackCount == 0) && (!surveyTool.isRecoveryMode())) {
crafter.sendSystemMessage("@survey:sample_failed", (byte) 0);
core.playerService.giveExperience(crafter,(int)(2.5F*stackCount));
core.playerService.giveExperience(crafter, (int) (2.5F * stackCount));
//surveyTool.setRecoveryMode(true);
//surveyTool.setRecoveryTime(System.currentTimeMillis());
}
}
public ResourceContainerObject findResourceContainerInInventory(CreatureObject owner, GalacticResource resource){
public ResourceContainerObject findResourceContainerInInventory(CreatureObject owner, GalacticResource resource) {
ResourceContainerObject foundContainer = null;
final Vector<ResourceContainerObject> found = new Vector<ResourceContainerObject>();
TangibleObject playerInventory = (TangibleObject) owner.getSlottedObject("inventory");
playerInventory.viewChildren(owner, false, false, new Traverser() {
@Override
public void process(SWGObject obj) {
if (obj instanceof ResourceContainerObject){
if (obj instanceof ResourceContainerObject) {
ResourceContainerObject container = (ResourceContainerObject) obj;
if (container.getReferenceID()==resource.getId()
&& container.getStackCount()<ResourceContainerObject.maximalStackCapacity-10)
if (container.getReferenceID() == resource.getId() && container.getStackCount() < ResourceContainerObject.maximalStackCapacity - 10)
found.add(container);
}
}
});
if (found.size()>0)
if (found.size() > 0)
foundContainer = found.get(0);
return foundContainer;
}
public void requestSurvey(CreatureObject crafter, SWGObject target, String commandArgs){
public void requestSurvey(CreatureObject crafter, SWGObject target, String commandArgs) {
// Check if crafter has survey skill
// if (!crafter.hasAbility("surveying")) { // ToDo !
// crafter.sendSystemMessage("You have insufficient skill to survey", (byte) 0);
// return;
// }
if (target==null)
if (target == null) {
System.err.println("SurveyService: Target Object Not Valid for surveying.");
return; // target object not valid
if (crafter.getContainer()!=null)
}
if (crafter.getContainer() != null) {
System.err.println("SurveyService: Container is not null!");
return;
}
SurveyTool surveyTool = (SurveyTool)target;
if (surveyTool.getToolType()==-1)
SurveyTool surveyTool = (SurveyTool) target;
if (surveyTool.getToolType() == -1) {
System.err.println("SurveyService: Survey tool type was not recognized.");
return; // Survey tool type was not recognized
}
surveyTool.setUserID(crafter.getObjectID());
surveyTool.setRecoveryTime(10000L);
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
player.setLastUsedSurveyTool(surveyTool);
if(surveyTool.getCurrentlySampling())
{
crafter.sendSystemMessage("@survey:survey_sample", (byte) 0);
if (surveyTool.getCurrentlySampling()) {
crafter.sendSystemMessage("@survey:survey_sample", (byte) 0);
return;
}
// QA tool lockup countermeasure
if(surveyTool.getCurrentlySurveying() && surveyTool.getLastSurveyTime()<System.currentTimeMillis()-3000){
if (surveyTool.getCurrentlySurveying() && surveyTool.getLastSurveyTime() < System.currentTimeMillis() - 3000) {
surveyTool.setCurrentlySurveying(false);
surveyTool.setLastSurveyTime(System.currentTimeMillis());
}
// Counter too frequent survey button activation
if(surveyTool.getCurrentlySurveying()){
return;
if (surveyTool.getCurrentlySurveying()) {
System.err.println("SurveyService: Pressed survey button too frequently");
return;
}
if (core.terrainService.isWater(crafter.getPlanet(), crafter.getPosition().x, crafter.getPosition().z))
crafter.sendSystemMessage("@survey:no_survey_in_water", (byte) 0);
// Observer toolObserver = surveyTool;
// core.surveyService.addObserver(toolObserver);
crafter.sendSystemMessage("@survey:no_survey_in_water", (byte) 0);
// Observer toolObserver = surveyTool;
// core.surveyService.addObserver(toolObserver);
if (!toolIsInList(surveyTool))
addActiveSurveyTool(surveyTool);
String resourceNameString = commandArgs;
GalacticResource resource = core.resourceService.grabResourceByName(resourceNameString);
surveyTool.setCurrentlySurveying(true);
surveyTool.setLastSurveyTime(System.currentTimeMillis());
surveyTool.setSurveyResourceID(resource.getObjectID());
String effectFile = surveyTool.getSurveyEffectString();
PlayClientEffectLocMessage cEffMsg = new PlayClientEffectLocMessage(effectFile,crafter.getPlanet().getName(),crafter.getPosition());
crafter.getClient().getSession().write(cEffMsg.serialize());
synchronized (activeSurveyTools) {
if (!activeSurveyTools.contains(surveyTool))
activeSurveyTools.add(surveyTool);
}
String effectFile = surveyTool.getSurveyEffectString();
PlayClientEffectLocMessage cEffMsg = new PlayClientEffectLocMessage(effectFile, crafter.getPlanet().getName(), crafter.getPosition());
crafter.getClient().getSession().write(cEffMsg.serialize());
crafter.sendSystemMessage("You begin to survey for " + commandArgs, (byte) 0);
}
public void requestSampling(CreatureObject crafter, SWGObject target, String commandArgs){
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
public void requestSampling(CreatureObject crafter, SWGObject target, String commandArgs) {
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
SurveyTool surveyTool = player.getLastUsedSurveyTool();
if (surveyTool.getCurrentlySurveying()){
if (surveyTool.getCurrentlySurveying()) {
crafter.sendSystemMessage("@survey:sample_survey", (byte) 0);
return;
}
if (crafter.getPosture()!=1) // QA
if (crafter.getPosture() != 1) // QA
surveyTool.setCurrentlySampling(false);
if (surveyTool.getCurrentlySampling()) { // QA
@@ -344,22 +339,22 @@ public class SurveyService implements INetworkDispatch {
return;
}
if (crafter.getPosture()==13)
if (crafter.getPosture() == 13)
return; // QA
if (crafter.isInCombat()){ // QA
if (crafter.isInCombat()) { // QA
crafter.sendSystemMessage("@survey:sample_cancel_attack", (byte) 0);
return;
}
if (crafter.getPosture()==10 || crafter.getPosture()==11){ // QA
if (crafter.getPosture() == 10 || crafter.getPosture() == 11) { // QA
crafter.sendSystemMessage("You cannot sample while on a mount", (byte) 0);
return;
}
surveyTool.setCurrentlyCoolingDown(false);
GalacticResource sampleResource = (GalacticResource) NGECore.getInstance().objectService.getObject(surveyTool.getSurveyResourceID());
if(surveyTool==null || sampleResource==null) { // QA
if (surveyTool == null || sampleResource == null) { // QA
crafter.sendSystemMessage("You must survey for a resource before you can sample it.", (byte) 0);
surveyTool.setExceptionalState(false);
surveyTool.setCurrentlySampling(false);
@@ -368,49 +363,45 @@ public class SurveyService implements INetworkDispatch {
}
if (sampleResource.getName().equals(commandArgs)) {
float localConcentration = sampleResource.deliverConcentrationForSurvey(crafter.getPlanetId(), crafter.getPosition().x, crafter.getPosition().z);
//float localConcentration = 1.0F;
if (localConcentration > 0.3) {
// Is the tool ready?
if (surveyTool.getCurrentlySampling() || surveyTool.getCurrentlyCoolingDown() ) {
if (surveyTool.getCurrentlySampling() || surveyTool.getCurrentlyCoolingDown()) {
int remaining = 0; // calculate remaining time
crafter.sendSystemMessage("You will be able to sample again in " + remaining + " seconds.", (byte) 0); // "@survey:tool_recharge_time"
} else {
// ToDo: Find out if NGE really still did this
// if (sampleResource.getResourceRoot().getResourceClass().equals("Radioactive")){ //resourceRoot.getResourceClass("Radioactive");
// createRadioactivityWarningSUIWindow(crafter, surveyTool);
// return;
// }
if (sampleResource.getResourceRoot().getResourceClass().equals("Radioactive")){ //resourceRoot.getResourceClass("Radioactive");
createRadioactivityWarningSUIWindow(crafter, surveyTool);
return;
}
crafter.setPosture((byte) 1);
crafter.sendSystemMessage("You kneel", (byte) 0);
//int samplingCost=125-(int)crafter.getSkillMod("surveying").getModifier();
int samplingCost=125;
if (crafter.getAction()-samplingCost<0){ // Check HAM
int samplingCost = 125;
if (crafter.getAction() - samplingCost < 0) { // Check HAM
crafter.sendSystemMessage("@survey:gamble_no_action", (byte) 0);
crafter.setPosture((byte) 0);
surveyTool.setCurrentlySampling(false);
surveyTool.setExceptionalState(false);
removeActiveSurveyTool(surveyTool);
return;
}
}
surveyTool.setCurrentlySampling(true);
surveyTool.setLastSampleTime(System.currentTimeMillis());
addActiveSurveyTool(surveyTool);
String effectFile = surveyTool.getSampleEffectString();
PlayClientEffectLocMessage cEffMsg = new PlayClientEffectLocMessage(effectFile,crafter.getPlanet().getName(),crafter.getPosition());
String effectFile = surveyTool.getSampleEffectString();
PlayClientEffectLocMessage cEffMsg = new PlayClientEffectLocMessage(effectFile, crafter.getPlanet().getName(), crafter.getPosition());
crafter.getClient().getSession().write(cEffMsg.serialize());
crafter.sendSystemMessage("You begin to sample for " + commandArgs, (byte) 0);
surveyTool.setCurrentlySampling(true);
surveyTool.setCurrentlySampling(true);
crafter.setAction(crafter.getAction()-samplingCost);
crafter.setAction(crafter.getAction() - samplingCost);
}
} else {
@@ -424,29 +415,29 @@ public class SurveyService implements INetworkDispatch {
surveyTool.setExceptionalState(false);
surveyTool.setCurrentlySampling(false);
removeActiveSurveyTool(surveyTool);
}
}
}
public void continueSampling(SurveyTool surveyTool){
public void continueSampling(SurveyTool surveyTool) {
surveyTool.setCurrentlyCoolingDown(false);
CreatureObject crafter = (CreatureObject) NGECore.getInstance().objectService.getObject(surveyTool.getUserID());
if (crafter.getPosture()!=1){
if (crafter.getPosture() != 1) {
crafter.sendSystemMessage("@survey:sample_cancel", (byte) 0);
surveyTool.setExceptionalState(false);
surveyTool.setCurrentlySampling(false);
removeActiveSurveyTool(surveyTool);
return;
}
if (crafter.getPosture()==13)
if (crafter.getPosture() == 13)
return;
if (crafter.isInCombat()){
if (crafter.isInCombat()) {
crafter.sendSystemMessage("@survey:sample_cancel_attack", (byte) 0);
return;
}
GalacticResource sampleResource = (GalacticResource) NGECore.getInstance().objectService.getObject(surveyTool.getSurveyResourceID());
float localConcentration = sampleResource.deliverConcentrationForSurvey(crafter.getPlanetId(), crafter.getPosition().x, crafter.getPosition().z);
//float localConcentration = 1.0F;
@@ -456,19 +447,19 @@ public class SurveyService implements INetworkDispatch {
// ToDo: overfilling resource container with continuesampling
//int samplingCost=125-(int)crafter.getSkillMod("surveying").getModifier();
int samplingCost=125;
if (crafter.getAction()-samplingCost<0 && ! surveyTool.isExceptionalState()){
int samplingCost = 125;
if (crafter.getAction() - samplingCost < 0 && !surveyTool.isExceptionalState()) {
crafter.sendSystemMessage("@survey:gamble_no_action", (byte) 0);
crafter.setPosture((byte) 0);
surveyTool.setCurrentlySampling(false);
surveyTool.setExceptionalState(false);
//removeActiveSurveyTool(surveyTool);
return;
}
}
if (! surveyTool.isRecoveryMode()){
if (!surveyTool.isRecoveryMode()) {
int exceptionalChance = new Random().nextInt(100); // 7 was good
if (exceptionalChance<20 && ! surveyTool.isExceptionalState()){
if (exceptionalChance < 20 && !surveyTool.isExceptionalState()) {
crafter.sendSystemMessage("@survey:gnode_d", (byte) 0);
surveyTool.setExceptionalState(true);
@@ -476,45 +467,45 @@ public class SurveyService implements INetworkDispatch {
window.setProperty("bg.caption.lblTitle:Text", "@base_player:swg");
window.setProperty("Prompt.lblPrompt:Text", "@survey:gnode_d");
window.addListBoxMenuItem("@survey:gnode_1", 0);
window.addListBoxMenuItem("@survey:gnode_2", 1);
window.addListBoxMenuItem("@survey:gnode_2", 1);
window.setProperty("btnOk:visible", "True");
window.setProperty("btnCancel:visible", "True");
window.setProperty("btnOk:Text", "@ok");
window.setProperty("btnCancel:Text", "@cancel");
window.setProperty("btnCancel:Text", "@cancel");
Vector<String> returnList = new Vector<String>();
returnList.add("List.lstList:SelectedRow");
window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() {
@Override
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
int index = Integer.parseInt(returnList.get(0));
if (index==0){
if (index == 0) {
// Continue working
CreatureObject crafter = (CreatureObject)owner;
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
if (crafter!=null){
CreatureObject crafter = (CreatureObject) owner;
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
if (crafter != null) {
SurveyTool surveyTool = player.getLastUsedSurveyTool();
if (surveyTool!=null){
if (surveyTool != null) {
surveyTool.setExceptionalState(false);
core.suiService.closeSUIWindow(owner, 0);
continueSampling(surveyTool);
return;
}
}
}
} else {
// Attempt to recover
CreatureObject crafter = (CreatureObject)owner;
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
SurveyTool surveyTool = player.getLastUsedSurveyTool();
if (surveyTool!=null){
CreatureObject crafter = (CreatureObject) owner;
PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost");
SurveyTool surveyTool = player.getLastUsedSurveyTool();
if (surveyTool != null) {
surveyTool.setRecoveryMode(true);
surveyTool.setExceptionalState(false);
core.suiService.closeSUIWindow(owner, 0);
continueSampling(surveyTool);
return;
}
}
}
}
}
});
core.suiService.openSUIWindow(window);
@@ -524,17 +515,17 @@ public class SurveyService implements INetworkDispatch {
surveyTool.setCurrentlySampling(true);
surveyTool.setLastSampleTime(System.currentTimeMillis());
String effectFile = surveyTool.getSampleEffectString();
PlayClientEffectLocMessage cEffMsg = new PlayClientEffectLocMessage(effectFile,crafter.getPlanet().getName(),crafter.getPosition());
String effectFile = surveyTool.getSampleEffectString();
PlayClientEffectLocMessage cEffMsg = new PlayClientEffectLocMessage(effectFile, crafter.getPlanet().getName(), crafter.getPosition());
crafter.getClient().getSession().write(cEffMsg.serialize());
crafter.setAction(crafter.getAction()-samplingCost);
crafter.setAction(crafter.getAction() - samplingCost);
} else {
// sampling cost for recovery
//surveyTool.setRecoveryMode(false);
samplingCost = 200;
if (crafter.getAction()-samplingCost<0){
if (crafter.getAction() - samplingCost < 0) {
crafter.sendSystemMessage("@survey:gamble_no_action", (byte) 0);
crafter.setPosture((byte) 0);
surveyTool.setCurrentlySampling(false);
@@ -547,22 +538,22 @@ public class SurveyService implements INetworkDispatch {
surveyTool.setLastSampleTime(System.currentTimeMillis());
surveyTool.setExceptionalState(false);
String effectFile = surveyTool.getSampleEffectString();
PlayClientEffectLocMessage cEffMsg = new PlayClientEffectLocMessage(effectFile,crafter.getPlanet().getName(),crafter.getPosition());
String effectFile = surveyTool.getSampleEffectString();
PlayClientEffectLocMessage cEffMsg = new PlayClientEffectLocMessage(effectFile, crafter.getPlanet().getName(), crafter.getPosition());
crafter.getClient().getSession().write(cEffMsg.serialize());
crafter.setAction(crafter.getAction()-samplingCost);
crafter.setAction(crafter.getAction() - samplingCost);
}
surveyTool.setCurrentlySampling(true);
surveyTool.setLastSampleTime(System.currentTimeMillis());
String effectFile = surveyTool.getSampleEffectString();
PlayClientEffectLocMessage cEffMsg = new PlayClientEffectLocMessage(effectFile,crafter.getPlanet().getName(),crafter.getPosition());
String effectFile = surveyTool.getSampleEffectString();
PlayClientEffectLocMessage cEffMsg = new PlayClientEffectLocMessage(effectFile, crafter.getPlanet().getName(), crafter.getPosition());
crafter.getClient().getSession().write(cEffMsg.serialize());
crafter.setAction(crafter.getAction()-samplingCost);
crafter.setAction(crafter.getAction() - samplingCost);
} else {
crafter.sendSystemMessage("There are only trace amounts of " + sampleResource.getName() + " here. Find a higher concentration of the resource, and try sampling again.", (byte) 0); // "@survey:trace_amount:"
surveyTool.setCurrentlySampling(false);
@@ -570,28 +561,29 @@ public class SurveyService implements INetworkDispatch {
}
}
public void addActiveSurveyTool(SurveyTool tool){
synchronized(activeSurveyTools){
if (! activeSurveyTools.contains(tool))
public void addActiveSurveyTool(SurveyTool tool) {
synchronized (activeSurveyTools) {
if (!activeSurveyTools.contains(tool))
activeSurveyTools.add(tool);
}
}
public Vector<SurveyTool> getActiveSurveyTools(){
public Vector<SurveyTool> getActiveSurveyTools() {
return activeSurveyTools;
}
public void removeActiveSurveyTool(SurveyTool surveyTool){
synchronized(activeSurveyTools){
public void removeActiveSurveyTool(SurveyTool surveyTool) {
synchronized (activeSurveyTools) {
activeSurveyTools.remove(surveyTool);
}
}
public boolean toolIsInList(SurveyTool surveyTool){
Vector<SurveyTool> toolList = getActiveSurveyTools();
for (SurveyTool tool : toolList){
if (tool.getTanoID()==surveyTool.getTanoID())
return true;
public boolean toolIsInList(SurveyTool surveyTool) {
synchronized (activeSurveyTools) {
for (SurveyTool tool : activeSurveyTools) {
if (tool.getTanoID() == surveyTool.getTanoID())
return true;
}
}
return false;
}
@@ -600,64 +592,63 @@ public class SurveyService implements INetworkDispatch {
public void insertOpcodes(Map<Integer, INetworkRemoteEvent> arg0, Map<Integer, INetworkRemoteEvent> arg1) {
}
@Override
public void shutdown() {
// TODO Auto-generated method stub
}
public SUICallback handleExceptionalInput(SWGObject crafter,SUIWindow suiWindow){
public SUICallback handleExceptionalInput(SWGObject crafter, SUIWindow suiWindow) {
SUICallback callback = suiWindow.getCallbackByEventId(1);
return callback;
}
public void createSurveyRangeSUIWindow(SWGObject owner, TangibleObject target) {
final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0);
window.setProperty("bg.caption.lblTitle:Text", "@base_player:swg");
window.setProperty("Prompt.lblPrompt:Text", "@survey:select_range");
window.addListBoxMenuItem("64m x 3pts", 0);
window.addListBoxMenuItem("128m x 4pts", 1);
window.addListBoxMenuItem("192m x 4pts", 2);
window.addListBoxMenuItem("256m x 5pts", 3);
window.addListBoxMenuItem("320m x 5pts", 4);
window.addListBoxMenuItem("192m x 4pts", 2);
window.addListBoxMenuItem("256m x 5pts", 3);
window.addListBoxMenuItem("320m x 5pts", 4);
window.setProperty("btnOk:visible", "True");
window.setProperty("btnCancel:visible", "True");
window.setProperty("btnOk:Text", "@ok");
window.setProperty("btnCancel:Text", "@cancel");
window.setProperty("btnCancel:Text", "@cancel");
Vector<String> returnList = new Vector<String>();
returnList.add("List.lstList:SelectedRow");
final SurveyTool outerSurveyTool = (SurveyTool)target;
final SurveyTool outerSurveyTool = (SurveyTool) target;
window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() {
@Override
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
CreatureObject crafter = (CreatureObject)owner;
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
CreatureObject crafter = (CreatureObject) owner;
//crafter.sendSystemMessage("handleSurveyRangeInput process", (byte) 0);
if (crafter!=null) {
if (outerSurveyTool!=null){
if (crafter != null) {
if (outerSurveyTool != null) {
int index = Integer.parseInt(returnList.get(0));
if (index==0){
outerSurveyTool.setSurveyRangeSetting((byte)0);
}
if (index==1){
outerSurveyTool.setSurveyRangeSetting((byte)1);
}
if (index==2){
outerSurveyTool.setSurveyRangeSetting((byte)2);
if (index == 0) {
outerSurveyTool.setSurveyRangeSetting((byte) 0);
}
if (index==3){
outerSurveyTool.setSurveyRangeSetting((byte)3);
if (index == 1) {
outerSurveyTool.setSurveyRangeSetting((byte) 1);
}
if (index==4){
outerSurveyTool.setSurveyRangeSetting((byte)4);
if (index == 2) {
outerSurveyTool.setSurveyRangeSetting((byte) 2);
}
if (index == 3) {
outerSurveyTool.setSurveyRangeSetting((byte) 3);
}
if (index == 4) {
outerSurveyTool.setSurveyRangeSetting((byte) 4);
}
}
}
}
});
}
});
core.suiService.openSUIWindow(window);
}
@@ -671,29 +662,29 @@ public class SurveyService implements INetworkDispatch {
window.setProperty("btnCancel:visible", "True");
window.setProperty("btnOk:Text", "@ok");
window.setProperty("btnCancel:Text", "@cancel");
Vector<String> returnList = new Vector<String>();
returnList.add("List.lstList:SelectedRow");
window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() {
@Override
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
((CreatureObject)owner).sendSystemMessage("Rad confirmed", (byte) 0);
}
});
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
((CreatureObject) owner).sendSystemMessage("Rad confirmed", (byte) 0);
}
});
window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() {
@Override
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
((CreatureObject)owner).sendSystemMessage("Rad declined", (byte) 0);
}
});
public void process(SWGObject owner, int eventType, Vector<String> returnList) {
((CreatureObject) owner).sendSystemMessage("Rad declined", (byte) 0);
}
});
core.suiService.openSUIWindow(window);
}
public SUICallback handleSurveyRangeInput(SWGObject crafter,SUIWindow suiWindow){
public SUICallback handleSurveyRangeInput(SWGObject crafter, SUIWindow suiWindow) {
SUICallback callback = suiWindow.getCallbackByEventId(1);
core.suiService.closeSUIWindow(crafter, 0);
return callback;
}
}
}
}
+26 -27
View File
@@ -251,10 +251,15 @@ public class ObjectService implements INetworkDispatch {
}
}
if(objectID == 0)
objectID = generateObjectID();
else
isSnapshot = !overrideSnapshot;
synchronized(objectMutex) {
if(objectID == 0)
objectID = generateObjectID();
else
isSnapshot = !overrideSnapshot;
if(!core.getObjectIdODB().contains(objectID))
core.getObjectIdODB().put(objectID, new ObjectId(objectID));
}
if (planet == null) {
System.err.println("Planet is null in createObject for some reason.");
@@ -383,10 +388,7 @@ public class ObjectService implements INetworkDispatch {
object.setAttachment("customServerTemplate", customServerTemplate);
object.setisInSnapshot(isSnapshot);
synchronized(objectMutex) {
if(!core.getObjectIdODB().contains(objectID))
core.getObjectIdODB().put(objectID, new ObjectId(objectID));
}
// Set Options - easier to set them across the board here
// because we'll be spawning them despite most of them being unscripted.
// Any such settings can be completely reset with setOptionsBitmask
@@ -691,30 +693,27 @@ public class ObjectService implements INetworkDispatch {
return generateObjectID();
return objectID;*/
long newId = 0;
boolean found = false;
// stack overflow when using recursion
synchronized(objectMutex) {
while(!found) {
newId = highestId.incrementAndGet();
PreparedStatement ps2;
try {
ps2 = databaseConnection.preparedStatement("UPDATE highestid SET id=" + newId + " WHERE id=(SELECT MAX(id) FROM highestid)");
ps2.executeUpdate();
ps2.close();
} catch (SQLException e) {
e.printStackTrace();
long newId = 0;
try {
synchronized(objectMutex) {
newId = highestId.get();
ObjectDatabase objectIdODB = core.getObjectIdODB();
while (objectList.containsKey(newId) || objectIdODB.contains(newId)) {
newId = highestId.incrementAndGet();
}
if(objectList.containsKey(newId) || core.getObjectIdODB().contains(newId))
found = false;
else
found = true;
}
final String sql = "UPDATE highestid SET id=? WHERE id=(SELECT MAX(id) FROM highestid)";
final PreparedStatement ps2 = databaseConnection.preparedStatement(sql);
ps2.setLong(1, newId);
ps2.executeUpdate();
ps2.close();
} catch (SQLException e) {
e.printStackTrace();
}
return newId;
return newId;
}
public long getDOId(String planet, String template, int type, long containerId, int cellNumber, float x1, float y, float z1) {
File diff suppressed because it is too large Load Diff
+16 -15
View File
@@ -1,9 +1,9 @@
package services.trade;
import java.nio.ByteOrder;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import main.NGECore;
@@ -25,13 +25,10 @@ import resources.objects.creature.CreatureObject;
import engine.clients.Client;
import engine.resources.container.AllPermissions;
import engine.resources.container.CreatureContainerPermissions;
import engine.resources.container.CreaturePermissions;
import engine.resources.objects.SWGObject;
import engine.resources.service.INetworkDispatch;
import engine.resources.service.INetworkRemoteEvent;
@SuppressWarnings("unused")
public class TradeService implements INetworkDispatch{
private NGECore core;
@@ -40,11 +37,11 @@ public class TradeService implements INetworkDispatch{
private long senderID;
private Hashtable<SWGObject, Long> tradingObjectsTable = new Hashtable<SWGObject, Long>();
private Map<Long, Long> tradingObjectsTable = new ConcurrentHashMap<Long, Long>();
// key = objectToGive, value = giver's ID
// need to be sure that no giver ID exists in table before adding value
private Hashtable<Long, Integer> tradingCreditsTable = new Hashtable<Long, Integer>();
private Map<Long, Integer> tradingCreditsTable = new ConcurrentHashMap<Long, Integer>();
// key = ID of giver value = amnt recieving
public TradeService(NGECore core) {
@@ -147,17 +144,21 @@ public class TradeService implements INetworkDispatch{
SWGObject tradeObject = null;
Iterator<Map.Entry<SWGObject, Long>> itr = tradingObjectsTable.entrySet().iterator();
Iterator<Map.Entry<Long, Long>> itr = tradingObjectsTable.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry<SWGObject, Long> entry = itr.next();
Map.Entry<Long, Long> entry = itr.next();
if(tradingWithClient == entry.getValue()) {
tradeObject = entry.getKey();
tradeObject = core.objectService.getObject(entry.getKey());
itr.remove();
}
}
if (tradeObject == null) {
cleanTradeSession(client, tradeeClient);
return;
}
client.getSession().removeAttribute("tradeSession");
tradeeClient.getSession().removeAttribute("tradeSession");
@@ -353,13 +354,13 @@ public class TradeService implements INetworkDispatch{
else if (tradePartner.getClient().getSession().containsAttribute("tradeSessionIsVerified"))
{
Iterator<Map.Entry<SWGObject, Long>> itr = tradingObjectsTable.entrySet().iterator();
Iterator<Map.Entry<Long, Long>> itr = tradingObjectsTable.entrySet().iterator();
while (itr.hasNext()) {
Map.Entry<SWGObject, Long> entry = itr.next();
Map.Entry<Long, Long> entry = itr.next();
if(tradingWithClient == entry.getValue()) {
tradeObject = entry.getKey();
tradeObject = core.objectService.getObject(entry.getKey());
if (actingTrader == null || tradePartnerContainer == null || tradePartner == null)
{
cleanTradeSession(client, tradePartner.getClient());
@@ -409,15 +410,15 @@ public class TradeService implements INetworkDispatch{
return tradeSessionValue;
}
public Hashtable<SWGObject, Long> getTradingObjectMap() {
public Map<Long, Long> getTradingObjectMap() {
return tradingObjectsTable;
}
public void addItemForTrade(SWGObject swgObject, long tradePartnerID) {
if (tradingObjectsTable.containsKey(swgObject)) {
if (tradingObjectsTable.containsKey(swgObject.getObjectID())) {
removeItemForTrade(swgObject);
}
tradingObjectsTable.put(swgObject, tradePartnerID);
tradingObjectsTable.put(swgObject.getObjectID(), tradePartnerID);
}
public void removeItemForTrade(SWGObject swgObject) {