diff --git a/ngengine_public.jar b/ngengine_public.jar index 99fc3d2a..d64a9419 100644 Binary files a/ngengine_public.jar and b/ngengine_public.jar differ diff --git a/scripts/commands/dismissgroupmember.py b/scripts/commands/dismissgroupmember.py new file mode 100644 index 00000000..7c384e0a --- /dev/null +++ b/scripts/commands/dismissgroupmember.py @@ -0,0 +1,10 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + if actor and target: + core.groupService.handleGroupKick(actor, target) + return + \ No newline at end of file diff --git a/scripts/commands/pvp.py b/scripts/commands/pvp.py index c313fbc4..34f6c5ff 100644 --- a/scripts/commands/pvp.py +++ b/scripts/commands/pvp.py @@ -14,6 +14,9 @@ def run(core, actor, target, commandString): if actor.getPvpStatus(PvpStatus.GoingOvert) or actor.getPvpStatus(PvpStatus.GoingCovert): actor.sendSystemMessage('@faction_recruiter:pvp_status_changing', 0) return + if core.gcwService.isInPvpZone(actor): + actor.sendSystemMessage('@gcw:pvp_advanced_region_cannot_go_covert', 0) + return if commandString != '' and commandString != faction: if commandString == 'rebel' or commandString == 'imperial' or commandString == 'neutral': @@ -60,6 +63,8 @@ def run(core, actor, target, commandString): actor.sendSystemMessage('@faction_recruiter:covert_to_overt', 0) actor.setPvpStatus(PvpStatus.GoingOvert, True) time.sleep(30) + if core.gcwService.isInPvpZone(actor): + return actor.setFactionStatus(FactionStatus.SpecialForces) actor.setPvpStatus(PvpStatus.GoingOvert, False) actor.sendSystemMessage('@faction_recruiter:overt_complete', 0) @@ -70,6 +75,8 @@ def run(core, actor, target, commandString): actor.sendSystemMessage('@faction_recruiter:overt_to_covert', 0) actor.setPvpStatus(PvpStatus.GoingCovert, True) time.sleep(300) + if core.gcwService.isInPvpZone(actor): + return actor.setFactionStatus(FactionStatus.Combatant) actor.setPvpStatus(PvpStatus.GoingCovert, False) actor.sendSystemMessage('@faction_recruiter:covert_complete', 0) diff --git a/scripts/commands/transferitemmisc.py b/scripts/commands/transferitemmisc.py index 6ebaf183..30dd0846 100644 --- a/scripts/commands/transferitemmisc.py +++ b/scripts/commands/transferitemmisc.py @@ -28,7 +28,7 @@ def run(core, actor, target, commandString): if target.isLootItem(): target.setLootItem(0) - actor.sendSystemMessage('You looted ' + target.getStf().getStfValue() + ' from corpse.', 0) + actor.sendSystemMessage('You looted ' + target.getObjectName().getStfValue() + ' from corpse.', 0) if actorContainer != None and (container.getTemplate() == "object/cell/shared_cell.iff") & core.housingService.getPermissions(actor, actorContainer): target.getContainer().transferTo(actor, container, target) @@ -95,4 +95,4 @@ def run(core, actor, target, commandString): #core.scriptService.callScript(path, 'unequip', module, core, actor, target) core.equipmentService.unequip(actor, target) - return \ No newline at end of file + return diff --git a/scripts/mobiles/dantooine/dark_jedi_master.py b/scripts/mobiles/dantooine/dark_jedi_master.py index 99c61f86..f5310c74 100644 --- a/scripts/mobiles/dantooine/dark_jedi_master.py +++ b/scripts/mobiles/dantooine/dark_jedi_master.py @@ -42,6 +42,32 @@ def addTemplate(core): attacks = Vector() mobileTemplate.setDefaultAttack('saberHit') mobileTemplate.setAttacks(attacks) + + + lootPoolNames_1 = ['Junk'] + lootPoolChances_1 = [100] + lootGroupChance_1 = 65 + mobileTemplate.addToLootGroups(lootPoolNames_1,lootPoolChances_1,lootGroupChance_1) + + lootPoolNames_2 = ['jedi_relic_1'] + lootPoolChances_2 = [100] + lootGroupChance_2 = 85 + mobileTemplate.addToLootGroups(lootPoolNames_2,lootPoolChances_2,lootGroupChance_2) + + lootPoolNames_3 = ['powercrystals_hiq'] + lootPoolChances_3 = [100] + lootGroupChance_3 = 12 + mobileTemplate.addToLootGroups(lootPoolNames_3,lootPoolChances_3,lootGroupChance_3) + + lootPoolNames_4 = ['random_stat_jewelry'] + lootPoolChances_4 = [100] + lootGroupChance_4 = 8 + mobileTemplate.addToLootGroups(lootPoolNames_4,lootPoolChances_4,lootGroupChance_4) + + lootPoolNames_5 = ['sithholocrons'] + lootPoolChances_5 = [100] + lootGroupChance_5 = 3 + mobileTemplate.addToLootGroups(lootPoolNames_5,lootPoolChances_5,lootGroupChance_5) core.spawnService.addMobileTemplate('dark_jedi_master', mobileTemplate) \ No newline at end of file diff --git a/scripts/mobiles/tatooine/bocatt.py b/scripts/mobiles/tatooine/bocatt.py index 4c08e53c..69d0b5ef 100644 --- a/scripts/mobiles/tatooine/bocatt.py +++ b/scripts/mobiles/tatooine/bocatt.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("bocatt") mobileTemplate.setAssistRange(12) mobileTemplate.setStalker(True) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_bocatt.iff') diff --git a/scripts/mobiles/tatooine/bull_ronto.py b/scripts/mobiles/tatooine/bull_ronto.py index ce7b4fb6..01ffb015 100644 --- a/scripts/mobiles/tatooine/bull_ronto.py +++ b/scripts/mobiles/tatooine/bull_ronto.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("ronto") mobileTemplate.setAssistRange(0) mobileTemplate.setStalker(False) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_ronto.iff') diff --git a/scripts/mobiles/tatooine/cannibal_dewback.py b/scripts/mobiles/tatooine/cannibal_dewback.py index 4bc2e1e8..f6dcf294 100644 --- a/scripts/mobiles/tatooine/cannibal_dewback.py +++ b/scripts/mobiles/tatooine/cannibal_dewback.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("dewback cannibal") mobileTemplate.setAssistRange(10) mobileTemplate.setStalker(True) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_dewback.iff') diff --git a/scripts/mobiles/tatooine/canyon_krayt_dragon.py b/scripts/mobiles/tatooine/canyon_krayt_dragon.py index e0a570bc..fa96fdf6 100644 --- a/scripts/mobiles/tatooine/canyon_krayt_dragon.py +++ b/scripts/mobiles/tatooine/canyon_krayt_dragon.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("krayt dragon") mobileTemplate.setAssistRange(36) mobileTemplate.setStalker(True) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_canyon_krayt_dragon.iff') diff --git a/scripts/mobiles/tatooine/death_kreetle.py b/scripts/mobiles/tatooine/death_kreetle.py index 02bffd96..adaad64f 100644 --- a/scripts/mobiles/tatooine/death_kreetle.py +++ b/scripts/mobiles/tatooine/death_kreetle.py @@ -25,6 +25,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("uber kreetle") mobileTemplate.setAssistRange(6) mobileTemplate.setStalker(False) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_kreetle.iff') diff --git a/scripts/mobiles/tatooine/desert_squill.py b/scripts/mobiles/tatooine/desert_squill.py index e98b07b5..23ef655b 100644 --- a/scripts/mobiles/tatooine/desert_squill.py +++ b/scripts/mobiles/tatooine/desert_squill.py @@ -26,7 +26,8 @@ def addTemplate(core): mobileTemplate.setHideAmount(3) mobileTemplate.setSocialGroup("squill") mobileTemplate.setAssistRange(10) - mobileTemplate.setStalker(False) + mobileTemplate.setStalker(False) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_squill.iff') diff --git a/scripts/mobiles/tatooine/diseased_bocatt.py b/scripts/mobiles/tatooine/diseased_bocatt.py index 59843cbe..81638d7d 100644 --- a/scripts/mobiles/tatooine/diseased_bocatt.py +++ b/scripts/mobiles/tatooine/diseased_bocatt.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("bocatt") mobileTemplate.setAssistRange(10) mobileTemplate.setStalker(True) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_bocatt.iff') diff --git a/scripts/mobiles/tatooine/dragonet.py b/scripts/mobiles/tatooine/dragonet.py index 490771fb..d67323d9 100644 --- a/scripts/mobiles/tatooine/dragonet.py +++ b/scripts/mobiles/tatooine/dragonet.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("dragonet") mobileTemplate.setAssistRange(10) mobileTemplate.setStalker(True) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_dune_lizard.iff') diff --git a/scripts/mobiles/tatooine/dune_lizard.py b/scripts/mobiles/tatooine/dune_lizard.py index 00f04692..0b8d0664 100644 --- a/scripts/mobiles/tatooine/dune_lizard.py +++ b/scripts/mobiles/tatooine/dune_lizard.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("dune lizard") mobileTemplate.setAssistRange(10) mobileTemplate.setStalker(True) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_dune_lizard.iff') diff --git a/scripts/mobiles/tatooine/feral_bantha.py b/scripts/mobiles/tatooine/feral_bantha.py index 12847076..f030e8ae 100644 --- a/scripts/mobiles/tatooine/feral_bantha.py +++ b/scripts/mobiles/tatooine/feral_bantha.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("bantha") mobileTemplate.setAssistRange(6) mobileTemplate.setStalker(False) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_bantha_hue.iff') diff --git a/scripts/mobiles/tatooine/giant_canyon_krayt_dragon.py b/scripts/mobiles/tatooine/giant_canyon_krayt_dragon.py index eec41245..3ea26e1c 100644 --- a/scripts/mobiles/tatooine/giant_canyon_krayt_dragon.py +++ b/scripts/mobiles/tatooine/giant_canyon_krayt_dragon.py @@ -27,8 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("krayt dragon") mobileTemplate.setAssistRange(34) mobileTemplate.setStalker(True) - - + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_canyon_krayt_dragon.iff') diff --git a/scripts/mobiles/tatooine/giant_sand_beetle.py b/scripts/mobiles/tatooine/giant_sand_beetle.py index 54d9aed8..1d582005 100644 --- a/scripts/mobiles/tatooine/giant_sand_beetle.py +++ b/scripts/mobiles/tatooine/giant_sand_beetle.py @@ -25,6 +25,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("giant sand beetle") mobileTemplate.setAssistRange(10) mobileTemplate.setStalker(False) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_giant_sand_beetle.iff') diff --git a/scripts/mobiles/tatooine/giant_worrt.py b/scripts/mobiles/tatooine/giant_worrt.py index 6a5aa8b1..0eb02618 100644 --- a/scripts/mobiles/tatooine/giant_worrt.py +++ b/scripts/mobiles/tatooine/giant_worrt.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("worrt") mobileTemplate.setAssistRange(6) mobileTemplate.setStalker(False) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_giant_worrt.iff') diff --git a/scripts/mobiles/tatooine/gorg.py b/scripts/mobiles/tatooine/gorg.py index 2762675f..21ed5741 100644 --- a/scripts/mobiles/tatooine/gorg.py +++ b/scripts/mobiles/tatooine/gorg.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("gorg") mobileTemplate.setAssistRange(10) mobileTemplate.setStalker(False) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_gorg.iff') diff --git a/scripts/mobiles/tatooine/grand_krayt_dragon.py b/scripts/mobiles/tatooine/grand_krayt_dragon.py index 294c58e2..f68ebdbf 100644 --- a/scripts/mobiles/tatooine/grand_krayt_dragon.py +++ b/scripts/mobiles/tatooine/grand_krayt_dragon.py @@ -27,8 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("krayt dragon") mobileTemplate.setAssistRange(24) mobileTemplate.setStalker(True) - - + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_canyon_krayt_dragon.iff') diff --git a/scripts/mobiles/tatooine/greater_desert_womprat.py b/scripts/mobiles/tatooine/greater_desert_womprat.py index 5bd75203..bedb34e1 100644 --- a/scripts/mobiles/tatooine/greater_desert_womprat.py +++ b/scripts/mobiles/tatooine/greater_desert_womprat.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("womprat") mobileTemplate.setAssistRange(6) mobileTemplate.setStalker(True) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_greater_desert_womp_rat.iff') diff --git a/scripts/mobiles/tatooine/grizzled_dewback.py b/scripts/mobiles/tatooine/grizzled_dewback.py index ea05f928..dcdc227f 100644 --- a/scripts/mobiles/tatooine/grizzled_dewback.py +++ b/scripts/mobiles/tatooine/grizzled_dewback.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("dewback") mobileTemplate.setAssistRange(10) mobileTemplate.setStalker(False) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_dewback.iff') diff --git a/scripts/mobiles/tatooine/juvenile_canyon_krayt_dragon.py b/scripts/mobiles/tatooine/juvenile_canyon_krayt_dragon.py index bed7b9f4..aa72a0be 100644 --- a/scripts/mobiles/tatooine/juvenile_canyon_krayt_dragon.py +++ b/scripts/mobiles/tatooine/juvenile_canyon_krayt_dragon.py @@ -27,8 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("krayt dragon") mobileTemplate.setAssistRange(24) mobileTemplate.setStalker(False) - - + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_krayt_dragon.iff') diff --git a/scripts/mobiles/tatooine/krayt_dragon.py b/scripts/mobiles/tatooine/krayt_dragon.py index d458d1c8..6eb4001c 100644 --- a/scripts/mobiles/tatooine/krayt_dragon.py +++ b/scripts/mobiles/tatooine/krayt_dragon.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("krayt dragon") mobileTemplate.setAssistRange(24) mobileTemplate.setStalker(False) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_krayt_dragon.iff') diff --git a/scripts/mobiles/tatooine/krayt_dragon_ancient.py b/scripts/mobiles/tatooine/krayt_dragon_ancient.py index 0e8ba26c..7b93a5b0 100644 --- a/scripts/mobiles/tatooine/krayt_dragon_ancient.py +++ b/scripts/mobiles/tatooine/krayt_dragon_ancient.py @@ -27,8 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("krayt dragon") mobileTemplate.setAssistRange(36) mobileTemplate.setStalker(True) - - + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_krayt_dragon.iff') diff --git a/scripts/mobiles/tatooine/mountain_squill.py b/scripts/mobiles/tatooine/mountain_squill.py index bf036a18..eadfb722 100644 --- a/scripts/mobiles/tatooine/mountain_squill.py +++ b/scripts/mobiles/tatooine/mountain_squill.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("squill") mobileTemplate.setAssistRange(10) mobileTemplate.setStalker(True) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_mountain_squill.iff') diff --git a/scripts/mobiles/tatooine/mountain_worrt.py b/scripts/mobiles/tatooine/mountain_worrt.py index a20ef946..01e6f591 100644 --- a/scripts/mobiles/tatooine/mountain_worrt.py +++ b/scripts/mobiles/tatooine/mountain_worrt.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("mountain worrt") mobileTemplate.setAssistRange(0) mobileTemplate.setStalker(False) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_worrt.iff') diff --git a/scripts/mobiles/tatooine/mutant_womprat.py b/scripts/mobiles/tatooine/mutant_womprat.py index 2bb9cb93..206a8a0c 100644 --- a/scripts/mobiles/tatooine/mutant_womprat.py +++ b/scripts/mobiles/tatooine/mutant_womprat.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("womprat") mobileTemplate.setAssistRange(6) mobileTemplate.setStalker(False) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_womp_rat.iff') diff --git a/scripts/mobiles/tatooine/overkreetle.py b/scripts/mobiles/tatooine/overkreetle.py index 3f47de1a..e8c4030f 100644 --- a/scripts/mobiles/tatooine/overkreetle.py +++ b/scripts/mobiles/tatooine/overkreetle.py @@ -25,6 +25,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("uber kreetle") mobileTemplate.setAssistRange(6) mobileTemplate.setStalker(False) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_kreetle.iff') diff --git a/scripts/mobiles/tatooine/scyk.py b/scripts/mobiles/tatooine/scyk.py index 4b8a0267..c93319b5 100644 --- a/scripts/mobiles/tatooine/scyk.py +++ b/scripts/mobiles/tatooine/scyk.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("scyk") mobileTemplate.setAssistRange(10) mobileTemplate.setStalker(True) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_scyk.iff') diff --git a/scripts/mobiles/tatooine/swarming_lesser_dewback.py b/scripts/mobiles/tatooine/swarming_lesser_dewback.py index b1a547fd..aa7dcff5 100644 --- a/scripts/mobiles/tatooine/swarming_lesser_dewback.py +++ b/scripts/mobiles/tatooine/swarming_lesser_dewback.py @@ -27,6 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("dewback") mobileTemplate.setAssistRange(10) mobileTemplate.setStalker(True) + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_swarming_lesser_dewback.iff') diff --git a/scripts/mobiles/tatooine/variegated_womprat.py b/scripts/mobiles/tatooine/variegated_womprat.py index 6384ef09..f2df5312 100644 --- a/scripts/mobiles/tatooine/variegated_womprat.py +++ b/scripts/mobiles/tatooine/variegated_womprat.py @@ -27,7 +27,7 @@ def addTemplate(core): mobileTemplate.setSocialGroup("variegated womprat") mobileTemplate.setAssistRange(6) mobileTemplate.setStalker(False) - + mobileTemplate.setOptionsBitmask(192) templates = Vector() templates.add('object/mobile/shared_variegated_womp_rat.iff') diff --git a/scripts/pvpzones.py b/scripts/pvpzones.py new file mode 100644 index 00000000..91ab32ef --- /dev/null +++ b/scripts/pvpzones.py @@ -0,0 +1,9 @@ +import sys + +def addZones(core): + + gcwService = core.gcwService + + gcwService.addPvPZone('rori', 5318, 5680, 400) + + \ No newline at end of file diff --git a/scripts/skillMods/expertise_stance_saber_block.py b/scripts/skillMods/expertise_stance_saber_block.py index b5c5e291..64962f76 100644 --- a/scripts/skillMods/expertise_stance_saber_block.py +++ b/scripts/skillMods/expertise_stance_saber_block.py @@ -1,8 +1,10 @@ import sys def add(core, actor, skillMod, value): + core.skillModService.addSkillMod(actor, 'display_only_parry', skillMod.getBase() * 100) return def deduct(core, actor, skillMod, value): + core.skillModService.deductSkillMod(actor, 'display_only_parry', skillMod.getBase() * 100) return \ No newline at end of file diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 44cab1a0..1da3308a 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -524,7 +524,9 @@ public class NGECore { List deletedObjects = new ArrayList(); while(cursor.hasNext()) { - SWGObject creature = (SWGObject) cursor.next(); + Object next = cursor.next(); + if (next == null) continue; + SWGObject creature = (SWGObject) next; if(!characterService.playerExists(creature.getObjectID()) && creature instanceof CreatureObject) deletedObjects.add((CreatureObject) creature); } diff --git a/src/resources/datatables/Citizenship.java b/src/resources/datatables/Citizenship.java new file mode 100644 index 00000000..ced0f364 --- /dev/null +++ b/src/resources/datatables/Citizenship.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.datatables; + +public class Citizenship { + + public static final byte Homeless = 0; + public static final byte Citizen = 1; + public static final byte Militia = 2; + public static final byte Mayor = 3; + +} diff --git a/src/resources/datatables/GcwType.java b/src/resources/datatables/GcwType.java new file mode 100644 index 00000000..30664208 --- /dev/null +++ b/src/resources/datatables/GcwType.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.datatables; + +public class GcwType { + + public static final byte Generic = 0; + public static final byte Enemy = 1; + public static final byte Player = 2; + public static final byte Zone = 3; + +} diff --git a/src/resources/gcw/RegionDefender.java b/src/resources/gcw/RegionDefender.java new file mode 100644 index 00000000..e72d1877 --- /dev/null +++ b/src/resources/gcw/RegionDefender.java @@ -0,0 +1,98 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.gcw; + +import org.apache.mina.core.buffer.IoBuffer; + +import engine.resources.common.AString; +import engine.resources.objects.Baseline; +import engine.resources.objects.Delta; + +public class RegionDefender extends Delta { + + private static final long serialVersionUID = 1L; + + private AString region; + private byte byte1 = 0; + private byte byte2 = 0; + + public RegionDefender(String region, byte byte1, byte byte2) { + this.region = new AString(region); + this.byte1 = byte1; + this.byte2 = byte2; + } + + public RegionDefender(String region) { + this.region = new AString(region); + } + + public RegionDefender() { + this.region = new AString(); + } + + public String getRegion() { + synchronized(objectMutex) { + return region.get(); + } + } + + public void setRegion(String region) { + synchronized(objectMutex) { + this.region = new AString(region); + } + } + + public byte getByte1() { + synchronized(objectMutex) { + return byte1; + } + } + + public void setByte1(byte byte1) { + synchronized(objectMutex) { + this.byte1 = byte1; + } + } + + public byte getByte2() { + synchronized(objectMutex) { + return byte2; + } + } + + public void setByte2(byte byte2) { + synchronized(objectMutex) { + this.byte2 = byte2; + } + } + + public byte[] getBytes() { + synchronized(objectMutex) { + IoBuffer buffer = Baseline.createBuffer(region.getBytes().length + 2); + buffer.put(region.getBytes()); + buffer.put(byte1); + buffer.put(byte2); + return buffer.array(); + } + } + +} diff --git a/src/resources/objects/tool/SurveyTool.java b/src/resources/harvest/SurveyTool.java similarity index 97% rename from src/resources/objects/tool/SurveyTool.java rename to src/resources/harvest/SurveyTool.java index 464c8534..f23be1d2 100644 --- a/src/resources/objects/tool/SurveyTool.java +++ b/src/resources/harvest/SurveyTool.java @@ -19,16 +19,13 @@ * 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.tool; +package resources.harvest; import java.io.Serializable; import java.util.Vector; import main.NGECore; -import com.sleepycat.persist.model.NotPersistent; -import com.sleepycat.persist.model.Persistent; - import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; @@ -40,8 +37,6 @@ import resources.objects.tangible.TangibleObject; /** * @author Charon */ - -@Persistent(version=0) public class SurveyTool extends TangibleObject implements Serializable { private static final long serialVersionUID = 1L; @@ -51,25 +46,15 @@ public class SurveyTool extends TangibleObject implements Serializable { private Long tanoID=0L; private byte SurveyRangeSetting=0; - @NotPersistent private transient String surveyEffectString=""; - @NotPersistent private transient String sampleEffectString=""; - @NotPersistent private transient boolean currentlySurveying=false; - @NotPersistent private transient boolean currentlySampling=false; - @NotPersistent private transient boolean currentlyCoolingDown=false; - @NotPersistent private transient boolean exceptionalState=false; - @NotPersistent private transient boolean recoveryMode=false; - @NotPersistent private transient Long lastSurveyTime=0L; - @NotPersistent private transient Long lastSampleTime=0L; - @NotPersistent private transient Long recoveryTime=10L; public static byte MineralSurveyDevice = 1; diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index 6e5fd02c..2c996e3c 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -88,7 +88,7 @@ public class BuildingObject extends TangibleObject implements IPersistent, Seria @Override public Baseline getOtherVariables() { Baseline baseline = super.getOtherVariables(); - baseline.put("maintainanceAmount", (float) 0); + baseline.put("maintenanceAmount", (float) 0); baseline.put("baseMaintenanceRate", 0); baseline.put("deedTemplate", ""); baseline.put("residency", false); diff --git a/src/resources/objects/guild/GuildObject.java b/src/resources/objects/guild/GuildObject.java index b3723937..e87d3210 100644 --- a/src/resources/objects/guild/GuildObject.java +++ b/src/resources/objects/guild/GuildObject.java @@ -34,7 +34,6 @@ import resources.gcw.CurrentServerGCWZonePercent; import resources.gcw.OtherServerGCWZonePercent; import resources.guild.Guild; import resources.objects.ObjectMessageBuilder; -import resources.objects.SWGList; import resources.objects.SWGMap; import resources.objects.SWGMultiMap; import resources.objects.SWGSet; diff --git a/src/resources/objects/player/PlayerMessageBuilder.java b/src/resources/objects/player/PlayerMessageBuilder.java index a1a19436..adc62e2b 100644 --- a/src/resources/objects/player/PlayerMessageBuilder.java +++ b/src/resources/objects/player/PlayerMessageBuilder.java @@ -21,16 +21,10 @@ ******************************************************************************/ package resources.objects.player; -import java.nio.ByteOrder; -import java.util.List; import java.util.Map; -import java.util.Map.Entry; - -import org.apache.mina.core.buffer.IoBuffer; import engine.resources.objects.Builder; import resources.objects.intangible.IntangibleMessageBuilder; -import resources.objects.waypoint.WaypointObject; public class PlayerMessageBuilder extends IntangibleMessageBuilder { @@ -42,633 +36,6 @@ public class PlayerMessageBuilder extends IntangibleMessageBuilder { super(); } - public IoBuffer buildBaseline3() { - - PlayerObject player = (PlayerObject) object; - - IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - buffer.putShort((short) 0x14); - buffer.putFloat(1); - buffer.put(getAsciiString("string_id_table")); - buffer.putInt(0); // spacer - buffer.putShort((short) 0); - buffer.putInt(0); // custom name - buffer.putInt(0); // volume - buffer.putInt(0); // generic int - - buffer.putInt(4); // flag bitmask list size - buffer.putInt(player.getFlagBitmask()); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - buffer.putInt(4); // profile bitmask list size - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - if(player.getTitle() == null || player.getTitle().length() < 1) - buffer.putShort((short) 0); - else - buffer.put(getAsciiString(player.getTitle())); - - buffer.putInt(0); // born date - Needs to be in yyymmdd format - Stored as epoch time of character create - - buffer.putInt(player.getTotalPlayTime()); // total play time? - - buffer.putInt(player.getProfessionIcon()); - - buffer.put(getAsciiString(player.getProfession())); - buffer.putInt(0); // GCW - buffer.putInt(0); // PvP Kills - buffer.putLong(0); // Lifetime GCW - buffer.putInt(0); // Lifetime PvP Kills - buffer.putInt(player.getCollections().length); - buffer.putInt(player.getHighestSetBit()); - buffer.put(player.getCollections()); - buffer.putInt(0); // Unknown, part of one delta, maybe a list - buffer.putInt(0); // Unknown, part of one delta, maybe a list - buffer.put((byte) ((player.isShowBackpack()) ? 1 : 0)); - buffer.put((byte) ((player.isShowHelmet()) ? 1 : 0)); - - int size = buffer.position(); - - buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); - - - buffer.flip(); - buffer = createBaseline("PLAY", (byte) 3, buffer, size); - - return buffer; - - } - - public IoBuffer buildBaseline6() { - - PlayerObject player = (PlayerObject) object; - - IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - buffer.putShort((short) 0x11); - buffer.putInt((short) 0x43); - buffer.put(getAsciiString("string_id_table")); - buffer.putInt(0); // probably stringId - buffer.putShort((short) 0); // detailedDescription - buffer.put(player.getGodLevel()); - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - if(player.getHome() == null || player.getHome().length() < 1) { - buffer.putShort((short) 0); - } else { - buffer.put(getAsciiString(player.getHome())); - } - buffer.putInt(0); // unk - buffer.put((byte) 0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - buffer.putInt(0); // unk - - int size = buffer.position(); - - buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); - - - buffer.flip(); - buffer = createBaseline("PLAY", (byte) 6, buffer, size); - - return buffer; - - } - - public IoBuffer buildBaseline8() { - - PlayerObject player = (PlayerObject) object; - - IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - buffer.putShort((short) 0x09); - - if(player.getXpList().isEmpty()) { - buffer.putInt(0); - buffer.putInt(player.getXpListUpdateCounter()); - } else { - buffer.putInt(player.getXpList().size()); - buffer.putInt(player.getXpListUpdateCounter()); - - // no need for locking here, concurrent hash map iterator wont throw concurrency exceptions and multiple thread access at zone in is unlikely to occur for the PlayerObject - for(Entry entry : player.getXpList().entrySet()) { - - buffer.put((byte) 0); - buffer.put(getAsciiString(entry.getKey())); - buffer.putInt(entry.getValue()); - - } - - } - - if(player.getWaypoints().isEmpty()) { - buffer.putInt(0); - buffer.putInt(0); - } else { - buffer.putInt(player.getWaypoints().size()); - buffer.putInt(0); - - synchronized(player.getWaypoints()) { - - for(WaypointObject waypoint : player.getWaypoints()) { - - buffer.put((byte) 0); - buffer.putLong(waypoint.getObjectID()); - buffer.putInt(waypoint.getCellId()); - buffer.putFloat(waypoint.getPosition().x); - buffer.putFloat(waypoint.getPosition().y); - buffer.putFloat(waypoint.getPosition().z); - buffer.putLong(waypoint.getLocationNetworkId()); - buffer.putInt(waypoint.getPlanetCRC()); - buffer.put(getUnicodeString(waypoint.getName())); - buffer.putLong(waypoint.getObjectID()); - buffer.put(waypoint.getColor()); - buffer.put((byte) (waypoint.isActive() ? 1 : 0)); - - } - - } - } - - buffer.putInt(0); // Current force power ? - buffer.putInt(0); // Max force power ? - buffer.putInt(0); // Current FS Quest List size ? - buffer.putInt(0); // Current FS Quest List update counter ? - - buffer.putInt(0); // Completed FS Quest List size ? - buffer.putInt(0); // Completed FS Quest List update counter ? - - buffer.putInt(0); // Quest Journal List size ? - buffer.putInt(0); // Quest Journal List update counter ? - - buffer.putInt(0); // unk - - buffer.put(getAsciiString(player.getProfessionWheelPosition())); - int size = buffer.position(); - buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); - - buffer.flip(); - buffer = createBaseline("PLAY", (byte) 8, buffer, size); - - return buffer; - -} - - public IoBuffer buildBaseline9() { - - PlayerObject player = (PlayerObject) object; - - IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - - buffer.putShort((short) 0x1F); - - buffer.putInt(0); // ExperimentationFlag? - buffer.putInt(0); // CraftingStage? - - buffer.putLong(0); // Nearest Crafting Station id ? - - - buffer.putInt(0); // Draft Schematic List Size - buffer.putInt(0); // Draft Schematic List update counter - - buffer.putInt(0); // ExperimentationPoints? - buffer.putInt(0); // CraftingStage? - - buffer.putInt(8); // unk - - buffer.putInt(0); // unk - - if(player.getFriendList().isEmpty()) { - buffer.putInt(0); - buffer.putInt(0); - } else { - buffer.putInt(player.getFriendList().size()); - buffer.putInt(player.getFriendListUpdateCounter()); - - synchronized(player.getFriendList()) { - - for(String friend : player.getFriendList()) { - buffer.put(getAsciiString(friend)); - } - } - } - - if(player.getIgnoreList().isEmpty()) { - buffer.putInt(0); - buffer.putInt(0); - } else { - buffer.putInt(player.getIgnoreList().size()); - buffer.putInt(player.getIgnoreListUpdateCounter()); - - synchronized(player.getIgnoreList()) { - - for(String ignored : player.getIgnoreList()) { - buffer.put(getAsciiString(ignored)); - } - - } - } - - buffer.putInt(1); - buffer.putInt(0); // Current stomach unused in NGE - buffer.putInt(0x64); // Max stomach unused in NGE - buffer.putInt(0); // Current drink unused in NGE - buffer.putInt(0x64); // Max drink unused in NGE - buffer.putInt(0); // Current consumable unused in NGE - buffer.putInt(0x64); // Max consumable unused in NGE - - buffer.putInt(0); - buffer.putInt(0); - - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - buffer.putInt(0); // jedi state??? - buffer.putShort((short) 0); - int size = buffer.position(); - - buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); - - - buffer.flip(); - buffer = createBaseline("PLAY", (byte) 9, buffer, size); - - return buffer; - - } - - public IoBuffer buildTitleDelta(String title) { - IoBuffer buffer = bufferPool.allocate(4 + getAsciiString(title).length, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.put(getAsciiString(title)); - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 0x07, buffer, size + 4); - return buffer; - - } - - public IoBuffer buildProfessionIconDelta(int professionIcon) { - IoBuffer buffer = bufferPool.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(professionIcon); - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 0x0A, buffer, size + 4); - return buffer; - } - - public IoBuffer buildCollectionsDelta(byte[] collections, int highestSetBit) { - IoBuffer buffer = bufferPool.allocate(8 + collections.length, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(collections.length); - buffer.putInt(highestSetBit); - for (byte collection : collections) buffer.put(collection); - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 16, buffer, size + 4); - return buffer; - } - - public IoBuffer buildXPListDelta(String type, int amount, boolean alreadyExists) { - PlayerObject player = (PlayerObject) object; - player.setXpListUpdateCounter(player.getXpListUpdateCounter() + 1); - - IoBuffer result = bufferPool.allocate(15 + type.length(), false).order(ByteOrder.LITTLE_ENDIAN); - - result.putInt(1); - result.putInt(player.getXpListUpdateCounter()); - result.put((byte) ((alreadyExists) ? 2 : 0)); - result.put(getAsciiString(type)); - result.putInt(amount); - - int size = result.position(); - result.flip(); - result = createDelta("PLAY", (byte) 8, (short) 1, (short) 0, result, size + 4); - return result; - } - - public IoBuffer buildProfessionWheelPositionDelta(String professionWheelPosition) { - IoBuffer buffer = bufferPool.allocate(2 + professionWheelPosition.length(), false).order(ByteOrder.LITTLE_ENDIAN); - - buffer.put(getAsciiString(professionWheelPosition)); - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 8, (short) 1, (short) 8, buffer, size + 4); - return buffer; - - } - - public IoBuffer buildWaypointAddDelta(WaypointObject waypoint) { - - PlayerObject player = (PlayerObject) object; - IoBuffer buffer = bufferPool.allocate(59 + waypoint.getName().length() * 2, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - - int nextCounter = player.getWaypointListUpdateCounter() + 1; - player.setWaypointListUpdateCounter(nextCounter); - buffer.putInt(1); - buffer.putInt(player.getWaypointListUpdateCounter()); - - buffer.put((byte) 0); // updateType (SubType) - - buffer.putLong(waypoint.getObjectID()); - buffer.putInt(waypoint.getCellId()); - - buffer.putFloat(waypoint.getPosition().x); - buffer.putFloat(waypoint.getPosition().y); - buffer.putFloat(waypoint.getPosition().z); - - buffer.putLong(0); // networklocationId - buffer.putInt(waypoint.getPlanetCRC()); - - buffer.put(getUnicodeString(waypoint.getName())); - buffer.putLong(waypoint.getObjectID()); - - buffer.put((byte) waypoint.getColor()); - - if (waypoint.isActive()) { buffer.put((byte) 1); } - else { buffer.put((byte) 0); } - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 8, (short) 1, (short) 1, buffer, size + 4); - //System.out.println("WaypointAdd: " + buffer.getHexDump()); - return buffer; - - } - - public IoBuffer buildWaypointRemoveDelta(WaypointObject waypoint) { - - IoBuffer buffer = bufferPool.allocate(59 + waypoint.getName().length() * 2, false).order(ByteOrder.LITTLE_ENDIAN); - PlayerObject player = (PlayerObject) object; - - int nextCounter = player.getWaypointListUpdateCounter() + 1; - player.setWaypointListUpdateCounter(nextCounter); - - buffer.putInt(1); - buffer.putInt(player.getWaypointListUpdateCounter()); - - buffer.put((byte) 1); // updateType (SubType) - - buffer.putLong(waypoint.getObjectID()); - buffer.putInt(waypoint.getCellId()); - - buffer.putFloat(waypoint.getPosition().x); - buffer.putFloat(waypoint.getPosition().y); - buffer.putFloat(waypoint.getPosition().z); - - buffer.putLong(0); // networklocationId - buffer.putInt(waypoint.getPlanetCRC()); - - buffer.put(getUnicodeString(waypoint.getName())); - buffer.putLong(waypoint.getObjectID()); - - buffer.put((byte) waypoint.getColor()); - - if (waypoint.isActive()) { buffer.put((byte) 1); } - else { buffer.put((byte) 0); } - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 8, (short) 1, (short) 1, buffer, size + 4); - - return buffer; - - } - - public IoBuffer buildWaypointUpdateDelta(WaypointObject waypoint) { - - IoBuffer buffer = bufferPool.allocate(59 + waypoint.getName().length() * 2, false).order(ByteOrder.LITTLE_ENDIAN); - PlayerObject player = (PlayerObject) object; - - int nextCounter = player.getWaypointListUpdateCounter() + 1; - player.setWaypointListUpdateCounter(nextCounter); - - buffer.putInt(1); - buffer.putInt(player.getWaypointListUpdateCounter()); - - buffer.put((byte) 2); // updateType (SubType) - - buffer.putLong(waypoint.getObjectID()); - buffer.putInt(waypoint.getCellId()); - - buffer.putFloat(waypoint.getPosition().x); - buffer.putFloat(waypoint.getPosition().y); - buffer.putFloat(waypoint.getPosition().z); - - buffer.putLong(0); // networklocationId << cluster system I guess? - buffer.putInt(waypoint.getPlanetCRC()); - - buffer.put(getUnicodeString(waypoint.getName())); - buffer.putLong(waypoint.getObjectID()); - - buffer.put((byte) waypoint.getColor()); - - if (waypoint.isActive()) { buffer.put((byte) 1); } - else { buffer.put((byte) 0); } // isActive. Activates automatically when created. - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 8, (short) 1, (short) 1, buffer, size + 4); - - return buffer; - - } - - public IoBuffer buildTotalPlayTimeDelta(int totalPlayTime) { - - IoBuffer buffer = bufferPool.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(totalPlayTime); - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 0x09, buffer, size + 4); - - return buffer; - - } - - public IoBuffer buildFriendAddDelta(List friends) { - - IoBuffer buffer = bufferPool.allocate(13 + (friends.size() * 2), false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - - PlayerObject player = (PlayerObject) object; - - buffer.putInt(1); - buffer.putInt(player.getFriendListUpdateCounter()); - - buffer.put((byte) 3); // updateType (SubType) - - buffer.putShort((short) (player.getFriendList().size())); - for (String f : friends) { - buffer.put(getAsciiString(f)); - } - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 9, (short) 1, (short) 7, buffer, size + 4); - - return buffer; - - } - - public IoBuffer buildFriendRemoveDelta(List friends) { - - IoBuffer buffer = bufferPool.allocate(13 + (friends.size() * 2), false).order(ByteOrder.LITTLE_ENDIAN); - PlayerObject player = (PlayerObject) object; - - buffer.putInt(1); - buffer.putInt(player.getFriendListUpdateCounter()); - - buffer.put((byte) 3); // updateType (SubType) - - buffer.putShort((short) friends.size()); - for (String f : friends) { - buffer.put(getAsciiString(f)); - } - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 9, (short) 1, (short) 7, buffer, size + 4); - - return buffer; - } - - - public IoBuffer buildIgnoreAddDelta(List ignoreList) { - IoBuffer buffer = bufferPool.allocate(13 + (ignoreList.size() * 2) , false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - PlayerObject player = (PlayerObject) object; - - buffer.putInt(1); - buffer.putInt(player.getIgnoreListUpdateCounter()); - - buffer.put((byte) 3); // updateType (SubType) - - buffer.putShort((short) ignoreList.size()); - for (String ignore : ignoreList) { - buffer.put(getAsciiString(ignore)); - } - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 9, (short) 1, (short) 8, buffer, size + 4); - - return buffer; - } - - public IoBuffer buildIgnoreRemoveDelta(List ignoreList) { - IoBuffer buffer = bufferPool.allocate(13 + (ignoreList.size() * 2) , false).order(ByteOrder.LITTLE_ENDIAN); - buffer.setAutoExpand(true); - PlayerObject player = (PlayerObject) object; - - buffer.putInt(1); - buffer.putInt(player.getIgnoreListUpdateCounter()); - - buffer.put((byte) 3); // updateType (SubType) - - buffer.putShort((short) ignoreList.size()); - for (String ignore : ignoreList) { - buffer.put(getAsciiString(ignore)); - } - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 9, (short) 1, (short) 8, buffer, size + 4); - - return buffer; - } - - public IoBuffer buildFlagBitmask(int bitmask) { - IoBuffer buffer = bufferPool.allocate(20, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(4); - buffer.putInt(bitmask); - buffer.putInt(0); - buffer.putInt(0); - buffer.putInt(0); - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 5, buffer, size + 4); - return buffer; - } - - public IoBuffer buildShowBackpackDelta(boolean showBackpack) { - IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN); - - buffer.put((byte) (showBackpack ? 1 : 0)); - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 18, buffer, size + 4); - return buffer; - } - - public IoBuffer buildShowHelmetDelta(boolean showHelmet) { - IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN); - - buffer.put((byte) (showHelmet ? 1 : 0)); - - int size = buffer.position(); - buffer.flip(); - - buffer = createDelta("PLAY", (byte) 3, (short) 1, (short) 19, buffer, size + 4); - return buffer; - } - - public IoBuffer buildGodLevelDelta(byte godLevel) { - IoBuffer buffer = bufferPool.allocate(1, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.put(godLevel); - int size = buffer.position(); - buffer.flip(); - buffer = createDelta("PLAY", (byte) 6, (short) 1, (short) 0x02, buffer, size + 4); - return buffer; - - } - @Override public void buildBaseline3(Map baselineBuilders, Map deltaBuilders) { super.buildBaseline3(baselineBuilders, deltaBuilders); @@ -679,10 +46,12 @@ public class PlayerMessageBuilder extends IntangibleMessageBuilder { super.buildBaseline6(baselineBuilders, deltaBuilders); } + @Override public void buildBaseline8(Map baselineBuilders, Map deltaBuilders) { super.buildBaseline8(baselineBuilders, deltaBuilders); } + @Override public void buildBaseline9(Map baselineBuilders, Map deltaBuilders) { super.buildBaseline9(baselineBuilders, deltaBuilders); } diff --git a/src/resources/objects/player/PlayerObject.java b/src/resources/objects/player/PlayerObject.java index 436daeef..962cc765 100644 --- a/src/resources/objects/player/PlayerObject.java +++ b/src/resources/objects/player/PlayerObject.java @@ -22,934 +22,984 @@ package resources.objects.player; import java.io.Serializable; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.BitSet; -import java.util.HashMap; +import java.util.Calendar; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.TreeMap; import java.util.Vector; +import main.NGECore; + +import org.apache.mina.core.buffer.IoBuffer; + import resources.craft.DraftSchematic; -import resources.objects.ObjectMessageBuilder; +import resources.datatables.Citizenship; +import resources.datatables.Professions; +import resources.gcw.RegionDefender; +import resources.harvest.SurveyTool; +import resources.objects.SWGList; +import resources.objects.SWGMap; +import resources.objects.SWGSet; import resources.objects.intangible.IntangibleObject; import resources.objects.resource.ResourceContainerObject; -import resources.objects.tool.SurveyTool; import resources.objects.waypoint.WaypointObject; -import resources.objects.creature.CreatureObject; import resources.quest.Quest; - -import com.sleepycat.persist.model.NotPersistent; -import com.sleepycat.persist.model.Persistent; - import engine.clients.Client; +import engine.resources.objects.Baseline; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Persistent(version=13) public class PlayerObject extends IntangibleObject implements Serializable { private static final long serialVersionUID = 1L; - // PLAY 3 - private String title; - private String profession; - private int professionIcon; - private List flagsList = new ArrayList(); - private List profileList = new ArrayList(); - private List titleList = new ArrayList(); - private long bornDate = 0; - private int totalPlayTime = 0; - private byte[] collections = new byte[] { }; - private int highestSetBit = 0; - private int flagBitmask = 0; - private boolean showHelmet = true; - private boolean showBackpack = true; - - // PLAY 6 - - private String home; // Player City Name - - // PLAY 8 - - private Map xpList = new HashMap(); - @NotPersistent - private transient int xpListUpdateCounter = 0; - - private List waypoints = new ArrayList(); - @NotPersistent - private transient int waypointListUpdateCounter = 0; - - private int currentForcePower = 0; // unused in NGE - private int maxForcePower = 0; // unused in NGE - - private List currentFSQuestList = new ArrayList(); // unused in NGE - private List completedFSQuestList = new ArrayList(); // unused in NGE - - private List questJournal = new ArrayList(); - @NotPersistent - private transient int questJournalUpdateCounter = 0; - - private String professionWheelPosition; - - // PLAY 9 - - private int experimentationFlag = 0; - private int craftingStage = 0; - private long nearestCraftingStation = 0; - - private List draftSchematicList = new ArrayList(); - @NotPersistent - private transient int draftSchematicListUpdateCounter = 0; - - private int experimentationPoints = 0; - private int accomplishmentCounter = 0; - - private List friendList = new ArrayList(); - @NotPersistent - private transient int friendListUpdateCounter = 0; - private List ignoreList = new ArrayList(); - @NotPersistent - private transient int ignoreListUpdateCounter = 0; - - private int languageId = 0; // unused in NGE - private int currentStomach = 0; // unused in NGE - private int maxStomach = 0; // unused in NGE - private int currentDrink = 0; // unused in NGE - private int maxDrink = 0; // unused in NGE - private int currentConsumable = 0; // unused - private int maxConsumable = 0; // unused - - // TODO: research new NGE vars between maxConsumable and jediState - - private int jediState = 0; // unused in NGE - - private String biography = ""; - private String spouse; - private String holoEmote; - private int holoEmoteUses; - - private int lotsRemaining = 10; - - @NotPersistent private transient PlayerMessageBuilder messageBuilder; - @NotPersistent private transient long lastPlayTimeUpdate = System.currentTimeMillis(); - private Map factionStandingMap = new TreeMap(); + private transient WaypointObject lastSurveyWaypoint; + private transient SurveyTool lastUsedSurveyTool; + private transient ResourceContainerObject recentContainer; - private WaypointObject lastSurveyWaypoint; - private SurveyTool lastUsedSurveyTool; - private ResourceContainerObject recentContainer; - - private byte godLevel = 0; - - private List chatChannels = new ArrayList(); - - @NotPersistent private transient boolean callingCompanion = false; - - private long bountyMissionId; - private Vector ownedVendors = new Vector(); - private long bindLocation; - - public PlayerObject() { - super(); - messageBuilder = new PlayerMessageBuilder(this); - } + private long bountyMissionId; // Bad because you could have 2 missions public PlayerObject(long objectID, Planet planet) { super(objectID, planet, new Point3D(0, 0, 0), new Quaternion(1, 0, 0, 0), "object/player/shared_player.iff"); - messageBuilder = new PlayerMessageBuilder(this); + } + + public PlayerObject() { + super(); } @Override public void initAfterDBLoad() { super.init(); lastPlayTimeUpdate = System.currentTimeMillis(); - messageBuilder = new PlayerMessageBuilder(this); - waypoints.forEach(WaypointObject::initAfterDBLoad); - } - - public String getTitle() { - synchronized(objectMutex) { - return title; - } - } - - public void setTitle(String title) { - synchronized(objectMutex) { - if(!getTitleList().isEmpty() && getTitleList().contains(title)) { - this.title = title; - } - - } - - if (getContainer() != null) { - getContainer().notifyObservers(messageBuilder.buildTitleDelta(title), true); - } - } - - public String getProfession() { - synchronized(objectMutex) { - return profession; - } - } - - public void setProfession(String profession) { - synchronized(objectMutex) { - this.profession = profession; - } - } - - public List getFlagsList() { - return flagsList; - } - - public List getProfileList() { - return profileList; - } - - public long getBornDate() { - synchronized(objectMutex) { - return bornDate; - } - } - - public void setBornDate(long bornDate) { - synchronized(objectMutex) { - this.bornDate = bornDate; - } - } - - public int getTotalPlayTime() { - synchronized(objectMutex) { - return totalPlayTime; - } - } - - public void setTotalPlayTime(int totalPlayTime) { - synchronized(objectMutex) { - this.totalPlayTime = totalPlayTime; - } - //notifyObservers(messageBuilder.buildTotalPlayTimeDelta(totalPlayTime), true); - getContainer().getClient().getSession().write(messageBuilder.buildTotalPlayTimeDelta(totalPlayTime)); - } - - public String getHome() { - synchronized(objectMutex) { - return home; - } - } - - public void setHome(String home) { - synchronized(objectMutex) { - this.home = home; - } - } - - public Map getXpList() { - return xpList; - } - - public int getXp(String type) { - synchronized(objectMutex) { - return ((!xpList.containsKey(type)) ? 0 : xpList.get(type)); - } - } - - // Temporary - public void setXp(String type, int amount) { - boolean xpExists; - - synchronized(objectMutex) { - xpExists = xpList.containsKey(type); - xpList.put(type, amount); - //Console.println("Put " + type + " exp of " + amount + " in the map."); - //Console.println("Map is now: " + xpList.get(type).intValue()); - } - - if (getContainer() != null && getContainer().getClient() != null && getContainer().getClient().getSession() != null) { - getContainer().getClient().getSession().write(messageBuilder.buildXPListDelta(type, amount, xpExists)); - ((CreatureObject) getContainer()).setXpBarValue(amount); - } - - } - - public int getXpListUpdateCounter() { - synchronized(objectMutex) { - return xpListUpdateCounter; - } - } - - public void setXpListUpdateCounter(int xpListUpdateCounter) { - synchronized(objectMutex) { - this.xpListUpdateCounter = xpListUpdateCounter; - } - } - - public List getWaypoints() { - return waypoints; - } - - public int getWaypointListUpdateCounter() { - synchronized(objectMutex) { - return waypointListUpdateCounter; - } - } - - public void setWaypointListUpdateCounter(int count) { - synchronized(objectMutex){ - this.waypointListUpdateCounter = count; - } - } - - public void waypointUpdate(WaypointObject waypoint) { - synchronized(objectMutex) { - getContainer().getClient().getSession().write(messageBuilder.buildWaypointUpdateDelta(waypoint)); - } - } - - public void waypointRemove(WaypointObject waypoint) { - synchronized(objectMutex) { - getContainer().getClient().getSession().write(messageBuilder.buildWaypointRemoveDelta(waypoint)); - getWaypoints().remove(waypoint); - } - } - - public void waypointAdd(WaypointObject waypoint) { - synchronized(objectMutex) { - getContainer().getClient().getSession().write(messageBuilder.buildWaypointAddDelta(waypoint)); - getWaypoints().add(waypoint); - } - } - - public WaypointObject getWaypointFromList(WaypointObject waypoint) { - if (waypoint == null) - return null; - - synchronized(objectMutex) { - for(WaypointObject wp : waypoints) { - if(wp.getObjectID() == waypoint.getObjectID()) - return wp; - } - } - return null; - } - - public int getCurrentForcePower() { - synchronized(objectMutex) { - return currentForcePower; - } - } - - public void setCurrentForcePower(int currentForcePower) { - synchronized(objectMutex) { - this.currentForcePower = currentForcePower; - } - } - - public int getMaxForcePower() { - synchronized(objectMutex) { - return maxForcePower; - } - } - - public void setMaxForcePower(int maxForcePower) { - synchronized(objectMutex) { - this.maxForcePower = maxForcePower; - } - } - - public List getCurrentFSQuestList() { - return currentFSQuestList; - } - - public List getCompletedFSQuestList() { - return completedFSQuestList; - } - - public List getQuestJournal() { - return questJournal; - } - - public String getProfessionWheelPosition() { - synchronized(objectMutex) { - return professionWheelPosition; - } - } - - public void setProfessionWheelPosition(String professionWheelPosition) { - synchronized(objectMutex) { - this.professionWheelPosition = professionWheelPosition; - } - if (getContainer() != null && getContainer().getClient() != null && getContainer().getClient().getSession() != null) { - getContainer().getClient().getSession().write(messageBuilder.buildProfessionWheelPositionDelta(professionWheelPosition)); - } - } - - public int getExperimentationFlag() { - synchronized(objectMutex) { - return experimentationFlag; - } - } - - public void setExperimentationFlag(int experimentationFlag) { - synchronized(objectMutex) { - this.experimentationFlag = experimentationFlag; - } - } - - public int getCraftingStage() { - synchronized(objectMutex) { - return craftingStage; - } - } - - public void setCraftingStage(int craftingStage) { - synchronized(objectMutex) { - this.craftingStage = craftingStage; - } - } - - public long getNearestCraftingStation() { - synchronized(objectMutex) { - return nearestCraftingStation; - } - } - - public void setNearestCraftingStation(long nearestCraftingStation) { - synchronized(objectMutex) { - this.nearestCraftingStation = nearestCraftingStation; - } - } - - public List getDraftSchematicList() { - return draftSchematicList; - } - - public int getExperimentationPoints() { - synchronized(objectMutex) { - return experimentationPoints; - } - } - - public void setExperimentationPoints(int experimentationPoints) { - synchronized(objectMutex) { - this.experimentationPoints = experimentationPoints; - } - } - - public int getAccomplishmentCounter() { - synchronized(objectMutex) { - return accomplishmentCounter; - } - } - - public void setAccomplishmentCounter(int accomplishmentCounter) { - synchronized(objectMutex) { - this.accomplishmentCounter = accomplishmentCounter; - } - } - - public List getFriendList() { - return friendList; - } - - public int getFriendListUpdateCounter() { - synchronized(objectMutex) { - return friendListUpdateCounter; - } - } - - public void setFriendListUpdateCounter(int friendListUpdateCounter) { - synchronized(objectMutex) { - this.friendListUpdateCounter = friendListUpdateCounter; - } - } - - public void friendAdd(String friend) { - synchronized(objectMutex) { - setFriendListUpdateCounter(getFriendListUpdateCounter() + 1); - friendList.add(friend); - getContainer().getClient().getSession().write(messageBuilder.buildFriendAddDelta(getFriendList())); - } - } - - public void friendRemove(String friend) { - synchronized(objectMutex) { - setFriendListUpdateCounter(getFriendListUpdateCounter() + 1); - friendList.remove(friend); - getContainer().getClient().getSession().write(messageBuilder.buildFriendRemoveDelta(getFriendList())); - } - } - - public List getIgnoreList() { - return ignoreList; - } - - public int getIgnoreListUpdateCounter() { - synchronized(objectMutex) { - return ignoreListUpdateCounter; - } - } - - public void ignoreAdd(String ignoreName) { - synchronized(objectMutex) { - setIgnoreListUpdateCounter(getIgnoreListUpdateCounter() + 1); - ignoreList.add(ignoreName); - getContainer().getClient().getSession().write(messageBuilder.buildIgnoreAddDelta(getIgnoreList())); - } - } - - public void ignoreRemove(String removeName) { - synchronized(objectMutex) { - setIgnoreListUpdateCounter(getIgnoreListUpdateCounter() + 1); - ignoreList.remove(removeName); - getContainer().getClient().getSession().write(messageBuilder.buildIgnoreRemoveDelta(getIgnoreList())); - } - } - - public void setIgnoreListUpdateCounter(int ignoreListUpdateCounter) { - synchronized(objectMutex) { - this.ignoreListUpdateCounter = ignoreListUpdateCounter; - } - } - - - public int getLanguageId() { - synchronized(objectMutex) { - return languageId; - } - } - - public void setLanguageId(int languageId) { - synchronized(objectMutex) { - this.languageId = languageId; - } - } - - public int getCurrentStomach() { - synchronized(objectMutex) { - return currentStomach; - } - } - - public void setCurrentStomach(int currentStomach) { - synchronized(objectMutex) { - this.currentStomach = currentStomach; - } - } - - public int getMaxStomach() { - synchronized(objectMutex) { - return maxStomach; - } - } - - public void setMaxStomach(int maxStomach) { - synchronized(objectMutex) { - this.maxStomach = maxStomach; - } - } - - public int getCurrentDrink() { - synchronized(objectMutex) { - return currentDrink; - } - } - - public void setCurrentDrink(int currentDrink) { - synchronized(objectMutex) { - this.currentDrink = currentDrink; - } - } - - public int getMaxDrink() { - synchronized(objectMutex) { - return maxDrink; - } - } - - public void setMaxDrink(int maxDrink) { - synchronized(objectMutex) { - this.maxDrink = maxDrink; - } - } - - public int getCurrentConsumable() { - synchronized(objectMutex) { - return currentConsumable; - } - } - - public void setCurrentConsumable(int currentConsumable) { - synchronized(objectMutex) { - this.currentConsumable = currentConsumable; - } - } - - public int getMaxConsumable() { - synchronized(objectMutex) { - return maxConsumable; - } - } - - public void setMaxConsumable(int maxConsumable) { - synchronized(objectMutex) { - this.maxConsumable = maxConsumable; - } - } - - public int getJediState() { - synchronized(objectMutex) { - return jediState; - } - } - - public void setJediState(int jediState) { - synchronized(objectMutex) { - this.jediState = jediState; - } - } - - public Map getFactionStandingMap() { - return factionStandingMap; - } - - public void setFactionStanding(String faction, int factionStanding) { - synchronized(objectMutex) { - factionStandingMap.put(faction, ((factionStanding < -5000) ? -5000 : ((factionStanding > 5000) ? 5000 : factionStanding))); - } - } - - public void modifyFactionStanding(String faction, int modifier) { - synchronized(objectMutex) { - int factionStanding = (((factionStandingMap.containsKey(faction)) ? factionStandingMap.get(faction) : 0) + modifier); - factionStandingMap.put(faction, ((factionStanding < -5000) ? -5000 : ((factionStanding > 5000) ? 5000 : factionStanding))); - } - } - - public int getFactionStanding(String faction) { - synchronized(objectMutex) { - return ((factionStandingMap.containsKey(faction)) ? factionStandingMap.get(faction) : 0); - } } @Override - public void sendBaselines(Client destination) { - - if(destination == null || destination.getSession() == null) - return; - destination.getSession().write(messageBuilder.buildBaseline3()); - destination.getSession().write(messageBuilder.buildBaseline6()); - if(destination.getParent().getObjectID() == getParentId()) { // only send to self - destination.getSession().write(messageBuilder.buildBaseline8()); - destination.getSession().write(messageBuilder.buildBaseline9()); - } - - - } - - public long getLastPlayTimeUpdate() { - synchronized(objectMutex) { - return lastPlayTimeUpdate; - } - } - - public void setLastPlayTimeUpdate(long lastPlayTimeUpdate) { - synchronized(objectMutex) { - this.lastPlayTimeUpdate = lastPlayTimeUpdate; - } - } - - public List getTitleList() { - return titleList; + public Baseline getOtherVariables() { + Baseline baseline = super.getOtherVariables(); + baseline.put("ownedVendors", new Vector()); + baseline.put("chatChannels", new ArrayList()); + baseline.put("factionStandingMap", new TreeMap()); + baseline.put("biography", ""); + baseline.put("titleList", new ArrayList()); + baseline.put("spouse", ""); + baseline.put("bindLocation", (long) 0); + baseline.put("lotsRemaining", 10); + baseline.put("holoEmote", ""); + baseline.put("holoEmoteUses", 0); + return baseline; } - public void setTitleList(List titleList) { - this.titleList = titleList; + @Override + public Baseline getBaseline3() { + Baseline baseline = super.getBaseline3(); + List flagsList = new ArrayList(); + flagsList.add(0); + flagsList.add(0); + flagsList.add(0); + flagsList.add(0); + baseline.put("flagsList", flagsList); + List profileFlagsList = new ArrayList(); + profileFlagsList.add(0); + profileFlagsList.add(0); + profileFlagsList.add(0); + profileFlagsList.add(0); + baseline.put("profileFlagsList", profileFlagsList); + baseline.put("title", ""); + baseline.put("bornDate", Integer.parseInt(new SimpleDateFormat("yyyymmdd", Locale.ENGLISH).format(Calendar.getInstance().getTime()))); + baseline.put("totalPlayTime", 0); + baseline.put("professionIcon", 0); + baseline.put("profession", "trader_1a"); + baseline.put("gcwPoints", 0); + baseline.put("pvpKills", 0); + baseline.put("lifetimeGcwPoints", (long) 0); + baseline.put("lifetimePvpKills", 0); + baseline.put("collections", new BitSet()); + baseline.put("17", new SWGList(this, 3, 17, false)); // Misc ints (2 ints in tutorial, 5 bytes other times...) + baseline.put("showHelmet", true); + baseline.put("showBackpack", true); + return baseline; } - public void setCollections(byte[] collections) { - synchronized(objectMutex) { - this.collections = collections; - this.highestSetBit = BitSet.valueOf(collections).length(); - } - - notifyObservers(messageBuilder.buildCollectionsDelta(collections, getHighestSetBit()), true); + @Override + public Baseline getBaseline6() { + Baseline baseline = super.getBaseline6(); + baseline.put("godLevel", (byte) 0); + baseline.put("currentRank", 0); + baseline.put("rankProgress", (float) 0); + baseline.put("highestRebelRank", 0); + baseline.put("highestImperialRank", 0); + baseline.put("nextUpdateTime", (int) NGECore.getInstance().gcwService.calculateNextUpdateTime()); + baseline.put("home", ""); + baseline.put("citizenship", Citizenship.Homeless); + baseline.put("cityRegionDefender", new RegionDefender()); + baseline.put("guildRegionDefender", new RegionDefender()); + baseline.put("12", 0); // General? + baseline.put("13", 0); // Guild Rank Title? + baseline.put("14", 0); // Citizen Rank Title? + baseline.put("15", 0); // All random guesses, always seem to be 0 + baseline.put("16", 0); + return baseline; } - public byte[] getCollections() { - synchronized(objectMutex) { - return collections; - } + @Override + public Baseline getBaseline8() { + Baseline baseline = super.getBaseline8(); + baseline.put("xpList", new SWGMap(this, 8, 0, true)); + baseline.put("waypoints", new SWGMap(this, 8, 1, true)); + baseline.put("currentForcePower", 100); + baseline.put("maxForcePower", 100); + baseline.put("currentFSQuestList", new SWGList(this, 8, 4, false)); + baseline.put("completedFSQuestList", new SWGList(this, 8, 5, false)); + baseline.put("questJournal", new SWGList(this, 8, 6, false)); + baseline.put("7", 0); + baseline.put("professionWheelPosition", ""); + return baseline; } - public int getHighestSetBit() { - synchronized(objectMutex) { - return highestSetBit; - } + @Override + public Baseline getBaseline9() { + Baseline baseline = super.getBaseline9(); + baseline.put("experimentationFlag", 0); + baseline.put("craftingStage", 0); + baseline.put("nearestCraftingStation", (long) 0); + baseline.put("draftSchematicList", new SWGList(this, 9, 3, true)); + baseline.put("4", new SWGList(this, 9, 4, false)); // Might or might not be a list, but at the very least it's two 0 ints that are part of the same delta. + baseline.put("experimentationPoints", 0); + baseline.put("accomplishmentCounter", 0); + baseline.put("friendList", new SWGList(this, 9, 7, false)); + baseline.put("ignoreList", new SWGList(this, 9, 8, false)); + baseline.put("languageId", 0); + baseline.put("currentStomach", 0); + baseline.put("maxStomach", 100); + baseline.put("currentDrink", 0); + baseline.put("maxDrink", 100); + baseline.put("currentConsumable", 0); + baseline.put("maxConsumable", 100); + baseline.put("waypointList", new SWGMap(this, 9, 16, false)); + baseline.put("defendersList", new SWGSet(this, 9, 17, false)); + baseline.put("kills", 0); + baseline.put("19", 0); + baseline.put("pet", (long) 0); + baseline.put("petAbilities", new SWGSet(this, 9, 15, false)); + baseline.put("22", (long) 0); // Unknown type currently + baseline.put("23", (byte) 0); // Seen as 1 or 2 sometimes // Gets set to 0x02 sometimes + baseline.put("24", 0); // Seen as 4 + baseline.put("25", (long) 0); // Bitmask starts with 0x20 ends with 0x40 + baseline.put("26", (long) 0); // Changed from 6 bytes to 9 + baseline.put("27", (byte) 0); // Changed from 6 bytes to 9 + baseline.put("28", (long) 0); // Seen as 856 + baseline.put("29", (long) 0); // Seen as 8559 + baseline.put("residenceTime", 0); // Date format of some sort. Seen as Saturday 28th May 2011 + return baseline; } - public int getProfessionIcon() { - synchronized(objectMutex) { - return professionIcon; - } + @SuppressWarnings("unchecked") + public List getFlagsList() { + return (List) getBaseline(3).get("flagsList"); } - public void setProfessionIcon(int professionIcon) { - synchronized(objectMutex) { - this.professionIcon = professionIcon; - } - - if (getContainer() != null) { - getContainer().notifyObservers(messageBuilder.buildProfessionIconDelta(professionIcon), true); - } + public void setFlagsList(int flag1, int flag2, int flag3, int flag4) { + List flagsList = getFlagsList(); + flagsList.set(0, flag1); + flagsList.set(1, flag2); + flagsList.set(2, flag3); + flagsList.set(3, flag4); + notifyClients(getBaseline(3).set("flagsList", flagsList), true); } - public String getBiography() { - return biography; - } - - public void setBiography(String biography) { - synchronized(objectMutex) { - this.biography = biography; - } - } - - public String getSpouseName() { - synchronized(objectMutex) { - return spouse; - } - } - - public void setSpouseName(String spouse) { - synchronized(objectMutex) { - this.spouse = spouse; - } - } - public int getFlagBitmask() { - synchronized(objectMutex) { - return flagBitmask; - } + return getFlagsList().get(0); } - + public void setFlagBitmask(int flagBitmask) { - synchronized(objectMutex) { - this.flagBitmask |= flagBitmask; - } - - if (getContainer() != null) { - getContainer().notifyObservers(messageBuilder.buildFlagBitmask(this.flagBitmask), true); - } + getFlagsList().set(0, getFlagsList().get(0) | flagBitmask); + notifyClients(getBaseline(3).set("flagsList", getFlagsList()), true); } + public void clearFlagBitmask(int flagBitmask) { - synchronized(objectMutex) { - // set flag bitmask to 0 - this.flagBitmask &= ~flagBitmask; - } - - if (getContainer() != null) { - getContainer().notifyObservers(messageBuilder.buildFlagBitmask(this.flagBitmask), true); - } + getFlagsList().set(0, (getFlagsList().get(0) & ~flagBitmask)); + notifyClients(getBaseline(3).set("flagsList", getFlagsList()), true); + } + + public boolean isSet(int flags) { + return ((getFlagsList().get(0) & flags) == flags); } public void toggleFlag(int flag) { - if ((this.flagBitmask & flag) == flag) { + if ((getFlagsList().get(0) & flag) == flag) { clearFlagBitmask(flag); } else { setFlagBitmask(flag); } } - /* - * @return True if specified flag(s) are enabled - */ - public boolean isSet(int flags) { - synchronized(objectMutex) { - return ((flagBitmask & flags) == flags); + @SuppressWarnings("unchecked") + public List getProfileFlagsList() { + return (List) getBaseline(3).get("profileFlagsList"); + } + + @Deprecated + public List getProfileList() { + return getProfileFlagsList(); + } + + public void setProfileFlagsList(int flag1, int flag2, int flag3, int flag4) { + List profileFlagsList = getProfileFlagsList(); + profileFlagsList.set(0, flag1); + profileFlagsList.set(1, flag2); + profileFlagsList.set(2, flag3); + profileFlagsList.set(3, flag4); + notifyClients(getBaseline(3).set("profileFlagsList", profileFlagsList), true); + } + + public String getBiography() { + return (String) otherVariables.get("biography"); + } + + public void setBiography(String biography) { + otherVariables.set("biography", biography); + } + + public String getTitle() { + return (String) getBaseline(3).get("title"); + } + + public void setTitle(String title) { + if (!getTitleList().isEmpty() && getTitleList().contains(title)) { + notifyClients(getBaseline(3).set("title", title), true); } } - - public String getHoloEmote() { - return holoEmote; + + @SuppressWarnings("unchecked") + public List getTitleList() { + return (List) otherVariables.get("titleList"); } - - public void setHoloEmote(String holoEmote) { - this.holoEmote = holoEmote; + + public void setTitleList(List titleList) { + otherVariables.set("titleList", titleList); } - - public int getHoloEmoteUses() { - return holoEmoteUses; + + public int getBornDate() { + return (int) getBaseline(3).get("bornDate"); } - - public void setHoloEmoteUses(int holoEmoteUses) { - this.holoEmoteUses = holoEmoteUses; + + public void setBornDate(int bornDate) { + getBaseline(3).set("bornDate", bornDate); } - - public boolean isShowHelmet() { - return showHelmet; + + public long getLastPlayTimeUpdate() { + synchronized(objectMutex) { + return lastPlayTimeUpdate; + } } - + + public void setLastPlayTimeUpdate(long lastPlayTimeUpdate) { + synchronized(objectMutex) { + this.lastPlayTimeUpdate = lastPlayTimeUpdate; + } + } + + public int getTotalPlayTime() { + return (int) getBaseline(3).get("totalPlayTime"); + } + + public void setTotalPlayTime(int totalPlayTime) { + if (getContainer() != null && getContainer().getClient() != null) { + getContainer().getClient().getSession().write(getBaseline(3).set("totalPlayTime", totalPlayTime)); + } + } + + public int getProfessionIcon() { + return (int) getBaseline(3).get("professionIcon"); + } + + public void setProfessionIcon(int professionIcon) { + notifyClients(getBaseline(3).set("professionIcon", professionIcon), true); + } + + public String getProfession() { + return (String) getBaseline(3).get("profession"); + } + + public void setProfession(String profession) { + notifyClients(getBaseline(3).set("profession", profession), true); + setProfessionIcon(Professions.get(profession)); + } + + public int getGcwPoints() { + return (int) getBaseline(3).get("gcwPoints"); + } + + public void setGcwPoints(int gcwPoints) { + notifyClients(getBaseline(3).set("gcwPoints", gcwPoints), true); + } + + public void resetGcwPoints() { + notifyClients(getBaseline(3).set("gcwPoints", 0), true); + } + + public int getPvpKills() { + return (int) getBaseline(3).get("pvpKills"); + } + + public void addPvpKill() { + IoBuffer buffer; + + synchronized(objectMutex) { + buffer = getBaseline(3).set("pvpKills", (((int) getBaseline(3).get("pvpKills")) + 1)); + } + + notifyClients(buffer, true); + } + + public void resetPvpKills() { + notifyClients(getBaseline(3).set("pvpKills", 0), true); + } + + public long getLifetimeGcwPoints() { + return (long) getBaseline(3).get("lifetimeGcwPoints"); + } + + public void addLifetimeGcwPoints(long gcwPoints) { + IoBuffer buffer; + + synchronized(objectMutex) { + buffer = getBaseline(3).set("lifetimeGcwPoints", (((long) getBaseline(3).get("lifetimeGcwPoints")) + gcwPoints)); + } + + notifyClients(buffer, true); + } + + public int getLifetimePvpKills() { + return (int) getBaseline(3).get("lifetimePvpKills"); + } + + public void addLifetimePvpKills(int pvpKills) { + IoBuffer buffer; + + synchronized(objectMutex) { + buffer = getBaseline(3).set("lifetimePvpKills", (((int) getBaseline(3).get("lifetimePvpKills")) + pvpKills)); + } + + notifyClients(buffer, true); + } + + public byte[] getCollections() { + return ((BitSet) getBaseline(3).get("collections")).toByteArray(); + } + + public void setCollections(byte[] collections) { + getBaseline(3).set("collections", BitSet.valueOf(collections)); + } + + public int getHighestSetBit() { + return ((BitSet) getBaseline(3).get("collections")).length(); + } + + public boolean isShowingHelmet() { + return (boolean) getBaseline(3).get("showHelmet"); + } + public void setShowHelmet(boolean showHelmet) { - synchronized(objectMutex) { - this.showHelmet = showHelmet; - } - - if (getContainer() != null) { - getContainer().getClient().getSession().write(messageBuilder.buildShowHelmetDelta(showHelmet)); - } + notifyClients(getBaseline(3).set("showHelmet", showHelmet), true); } - - public boolean isShowBackpack() { - return showBackpack; + + public boolean isShowingBackpack() { + return (boolean) getBaseline(3).get("showBackpack"); } - + public void setShowBackpack(boolean showBackpack) { + notifyClients(getBaseline(3).set("showBackpack", showBackpack), true); + } + + public byte getGodLevel() { + return (byte) getBaseline(6).get("godLevel"); + } + + public void setGodLevel(int godLevel) { + notifyClients(getBaseline(6).set("godLevel", (byte) godLevel), true); + } + + public int getCurrentRank() { synchronized(objectMutex) { - this.showBackpack = showBackpack; + return (int) getBaseline(6).get("currentRank"); + } + } + + public void setCurrentRank(int currentRank) { + notifyClients(getBaseline(6).set("currentRank", currentRank), true); + } + + public float getRankProgress() { + return (float) getBaseline(6).get("rankProgress"); + } + + public void setRankProgress(float rankProgress) { + notifyClients(getBaseline(6).set("rankProgress", rankProgress), true); + } + + public int getHighestRebelRank() { + return (int) getBaseline(6).get("highestRebelRank"); + } + + public void setHighestRebelRank(int highestRebelRank) { + notifyClients(getBaseline(6).set("highestRebelRank", highestRebelRank), true); + } + + public int getHighestImperialRank() { + return (int) getBaseline(6).get("highestImperialRank"); + } + + public void setHighestImperialRank(int highestImperialRank) { + notifyClients(getBaseline(6).set("highestImperialRank", highestImperialRank), true); + } + + public int getNextUpdateTime() { + return (int) getBaseline(6).get("nextUpdateTime"); + } + + public void setNextUpdateTime(int nextUpdateTime) { + notifyClients(getBaseline(6).set("nextUpdateTime", nextUpdateTime), true); + } + + public String getHome() { + return (String) getBaseline(6).get("home"); + } + + public void setHome(String home) { + notifyClients(getBaseline(6).set("home", home), true); + } + + public byte getCitizenship() { + return (byte) getBaseline(6).get("citizenship"); + } + + public void setCitizenship(byte citizenship) { + notifyClients(getBaseline(6).set("citizenship", citizenship), true); + } + + public RegionDefender getCityRegionDefender() { + return (RegionDefender) getBaseline(6).get("cityRegionDefender"); + } + + public void setCityRegionDefender(RegionDefender cityRegionDefender) { + notifyClients(getBaseline(6).set("cityRegionDefender", cityRegionDefender), true); + } + + public RegionDefender getGuildRegionDefender() { + return (RegionDefender) getBaseline(6).get("guildRegionDefender"); + } + + public void setGuildRegionDefender(RegionDefender guildRegionDefender) { + notifyClients(getBaseline(6).set("guildRegionDefender", guildRegionDefender), true); + } + + @SuppressWarnings("unchecked") + public SWGMap getXpList() { + return (SWGMap) getBaseline(8).get("xpList"); + } + + public int getXp(String type) { + return ((!getXpList().containsKey(type)) ? 0 : getXpList().get(type)); + } + + public void setXp(String type, int amount) { + getXpList().put(type, amount); + } + + @SuppressWarnings("unchecked") + public SWGMap getWaypoints() { + return (SWGMap) getBaseline(8).get("waypoints"); + } + + public void waypointUpdate(WaypointObject waypoint) { + getWaypoints().put(waypoint.getObjectID(), waypoint); + } + + public void waypointRemove(WaypointObject waypoint) { + getWaypoints().remove(waypoint.getObjectID()); + } + + public void waypointAdd(WaypointObject waypoint) { + getWaypoints().put(waypoint.getObjectID(), waypoint); + } + + public WaypointObject getWaypointFromList(WaypointObject waypoint) { + synchronized(objectMutex) { + if (getWaypoints().containsKey(waypoint.getObjectID())) { + return getWaypoints().get(waypoint.getObjectID()); + } } - if (getContainer() != null) { - getContainer().getClient().getSession().write(messageBuilder.buildShowBackpackDelta(showBackpack)); + return null; + } + + public int getCurrentForcePower() { + return (int) getBaseline(8).get("currentForcePower"); + } + + public void setCurrentForcePower(int currentForcePower) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(8).set("currentForcePower", currentForcePower)); } } + public int getMaxForcePower() { + return (int) getBaseline(8).get("maxForcePower"); + } + + public void setMaxForcePower(int maxForcePower) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(8).set("maxForcePower", maxForcePower)); + } + } + + @SuppressWarnings("unchecked") + public SWGList getCurrentFSQuestList() { + return (SWGList) getBaseline(8).get("currentFSQuestList"); + } + + @SuppressWarnings("unchecked") + public SWGList getCompletedFSQuestList() { + return (SWGList) getBaseline(8).get("completedFSQuestList"); + } + + @SuppressWarnings("unchecked") + public SWGList getQuestJournal() { + return (SWGList) getBaseline(8).get("questJournal"); + } + + public String getProfessionWheelPosition() { + return (String) getBaseline(8).get("professionWheelPosition"); + } + + public void setProfessionWheelPosition(String professionWheelPosition) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(8).set("professionWheelPosition", professionWheelPosition)); + } + } + + public int getExperimentationFlag() { + return (int) getBaseline(9).get("experimentationFlag"); + } + + public void setExperimentationFlag(int experimentationFlag) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("experimentationFlag", experimentationFlag)); + } + } + + public int getCraftingStage() { + return (int) getBaseline(9).get("craftingStage"); + } + + public void setCraftingStage(int craftingStage) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("craftingStage", craftingStage)); + } + } + + public long getNearestCraftingStation() { + return (long) getBaseline(9).get("nearestCraftingStation"); + } + + public void setNearestCraftingStation(long nearestCraftingStation) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("nearestCraftingStation", nearestCraftingStation)); + } + } + + @SuppressWarnings("unchecked") + public SWGList getDraftSchematicList() { + return (SWGList) getBaseline(9).get("draftSchematicList"); + } + + public int getExperimentationPoints() { + return (int) getBaseline(9).get("experimentationPoints"); + } + + public void setExperimentationPoints(int experimentationPoints) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("experimentationPoints", experimentationPoints)); + } + } + + public int getAccomplishmentCounter() { + return (int) getBaseline(9).get("accomplishmentCounter"); + } + + public void setAccomplishmentCounter(int accomplishmentCounter) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("accomplishmentCounter", accomplishmentCounter)); + } + } + + @SuppressWarnings("unchecked") + public SWGList getFriendList() { + return (SWGList) getBaseline(9).get("friendList"); + } + + public void friendAdd(String friend) { + getFriendList().add(friend); + } + + public void friendRemove(String friend) { + getFriendList().remove(friend); + } + + @SuppressWarnings("unchecked") + public SWGList getIgnoreList() { + return (SWGList) getBaseline(9).get("ignoreList"); + } + + public void ignoreAdd(String name) { + getIgnoreList().add(name); + } + + public void ignoreRemove(String name) { + getIgnoreList().remove(name); + } + + public int getLanguageId() { + return (int) getBaseline(9).get("languageId"); + } + + public void setLanguageId(int languageId) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("languageId", languageId)); + } + } + + public int getCurrentStomach() { + return (int) getBaseline(9).get("currentStomach"); + } + + public void setCurrentStomach(int currentStomach) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("currentStomach", currentStomach)); + } + } + + public int getMaxStomach() { + return (int) getBaseline(9).get("maxStomach"); + } + + public void setMaxStomach(int maxStomach) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("maxStomach", maxStomach)); + } + } + + public int getCurrentDrink() { + return (int) getBaseline(9).get("currentDrink"); + } + + public void setCurrentDrink(int currentDrink) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("currentDrink", currentDrink)); + } + } + + public int getMaxDrink() { + return (int) getBaseline(9).get("maxDrink"); + } + + public void setMaxDrink(int maxDrink) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("maxDrink", maxDrink)); + } + } + + public int getCurrentConsumable() { + return (int) getBaseline(9).get("currentConsumable"); + } + + public void setCurrentConsumable(int currentConsumable) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("currentConsumable", currentConsumable)); + } + } + + public int getMaxConsumable() { + return (int) getBaseline(9).get("maxConsumable"); + } + + public void setMaxConsumable(int maxConsumable) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("maxConsumable", maxConsumable)); + } + } + + @SuppressWarnings("unchecked") + public SWGSet getDefendersList() { + return (SWGSet) getBaseline(8).get("defendersList"); + } + + public int getKills() { + return (int) getBaseline(9).get("kills"); + } + + public void setKills(int kills) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("kills", kills)); + } + } + + public void addKills(int kills) { + setKills(getKills() + kills); + } + + public long getPet() { + return (long) getBaseline(9).get("pet"); + } + + public void setPet(long pet) { + if (getClient() != null) { + getClient().getSession().write(getBaseline(9).set("pet", pet)); + } + } + + @SuppressWarnings("unchecked") + public SWGSet getPetAbilities() { + return (SWGSet) getBaseline(8).get("petAbilities"); + } + + public int getJediState() { + return 0; + } + + public void setJediState(int jediState) { + + } + + @SuppressWarnings("unchecked") + public Map getFactionStandingMap() { + return (Map) otherVariables.get("factionStandingMap"); + } + + public int getFactionStanding(String faction) { + synchronized(objectMutex) { + return ((getFactionStandingMap().containsKey(faction)) ? getFactionStandingMap().get(faction) : 0); + } + } + + public void setFactionStanding(String faction, int factionStanding) { + synchronized(objectMutex) { + getFactionStandingMap().put(faction, ((factionStanding < -5000) ? -5000 : ((factionStanding > 5000) ? 5000 : factionStanding))); + } + } + + public void modifyFactionStanding(String faction, int modifier) { + synchronized(objectMutex) { + int factionStanding = (((getFactionStandingMap().containsKey(faction)) ? getFactionStandingMap().get(faction) : 0) + modifier); + getFactionStandingMap().put(faction, ((factionStanding < -5000) ? -5000 : ((factionStanding > 5000) ? 5000 : factionStanding))); + } + } + + public String getSpouseName() { + return (String) otherVariables.get("spouse"); + } + + public void setSpouseName(String spouse) { + otherVariables.set("spouse", spouse); + } + + public long getBindLocation() { + return (long) otherVariables.get("bindLocation"); + } + + public void setBindLocation(long bindLocation) { + otherVariables.set("bindLocation", bindLocation); + } + + public int getLotsRemaining() { + return (int) otherVariables.get("lotsRemaining"); + } + + public void setLotsRemaining(int lotsRemaining) { + otherVariables.set("lotsRemaining", lotsRemaining); + } + + public boolean addLots(int lots) { + otherVariables.set("lotsRemaining", getLotsRemaining() + lots); + return true; + } + + public boolean deductLots(int lots) { + if (getLotsRemaining() - lots >= 0) { + setLotsRemaining(getLotsRemaining() - lots); + return true; + } + + return false; + } + + public String getHoloEmote() { + return (String) otherVariables.get("holoEmote"); + } + + public void setHoloEmote(String holoEmote) { + otherVariables.set("holoEmote", holoEmote); + } + + public int getHoloEmoteUses() { + return (int) otherVariables.get("holoEmoteUses"); + } + + public void setHoloEmoteUses(int holoEmoteUses) { + otherVariables.set("holoEmoteUses", holoEmoteUses); + } + public WaypointObject getLastSurveyWaypoint() { return lastSurveyWaypoint; } - + public void setLastSurveyWaypoint(WaypointObject lastSurveyWaypoint) { this.lastSurveyWaypoint = lastSurveyWaypoint; } public SurveyTool getLastUsedSurveyTool() { synchronized(objectMutex) { - return this.lastUsedSurveyTool; + return lastUsedSurveyTool; } } - public void setLastUsedSurveyTool(SurveyTool surveyTool) { + public void setLastUsedSurveyTool(SurveyTool lastUsedSurveyTool) { synchronized(objectMutex) { - this.lastUsedSurveyTool = surveyTool; + this.lastUsedSurveyTool = lastUsedSurveyTool; } } - + public ResourceContainerObject getRecentContainer() { - return recentContainer; + synchronized(objectMutex) { + return recentContainer; + } } - + public void setRecentContainer(ResourceContainerObject recentContainer) { - this.recentContainer = recentContainer; - } - - public void setLotsRemaining(int amount) - { - this.lotsRemaining = amount; - } - - public boolean addLots(int amount) - { - this.lotsRemaining += amount; - return true; - } - - public boolean deductLots(int amount) - { - if(this.lotsRemaining - amount >= 0) - { - this.lotsRemaining -= amount; - return true; - } - return false; - } - - public int getLotsRemaining() - { - return this.lotsRemaining; - } - - public byte getGodLevel() { - return godLevel; - } - - public void setGodLevel(int godLevel) { - this.godLevel = (byte) godLevel; - - if (getContainer() != null) { - getContainer().getClient().getSession().write(messageBuilder.buildGodLevelDelta((byte) godLevel)); + synchronized(objectMutex) { + this.recentContainer = recentContainer; } } + @SuppressWarnings("unchecked") public List getJoinedChatChannels() { - return chatChannels; + return (List) otherVariables.get("chatChannels"); } public void addChannel(int roomId) { - chatChannels.add(roomId); + getJoinedChatChannels().add(roomId); } public void removeChannel(int roomId) { - if (chatChannels.contains(roomId)) - chatChannels.remove(roomId); + if (getJoinedChatChannels().contains(roomId)) { + getJoinedChatChannels().remove(roomId); + } } public boolean isMemberOfChannel(int roomId) { - if (chatChannels.contains(roomId)) { + if (getJoinedChatChannels().contains(roomId)) { return true; } + return false; } public boolean isCallingCompanion() { - return callingCompanion; + synchronized(objectMutex) { + return callingCompanion; + } } public void setCallingCompanion(boolean callingCompanion) { - this.callingCompanion = callingCompanion; + synchronized(objectMutex) { + this.callingCompanion = callingCompanion; + } } public long getBountyMissionId() { - return bountyMissionId; + synchronized(objectMutex) { + return bountyMissionId; + } } - + public void setBountyMissionId(long bountyMissionId) { - this.bountyMissionId = bountyMissionId; + synchronized(objectMutex) { + this.bountyMissionId = bountyMissionId; + } } - - public ObjectMessageBuilder getMessageBuilder() { - return messageBuilder; - } - + + @SuppressWarnings("unchecked") public Vector getOwnedVendors() { - return ownedVendors; + return (Vector) otherVariables.get("ownedVendors"); } - + public void addVendor(long vendorId) { - ownedVendors.add(vendorId); + getOwnedVendors().add(vendorId); } public void removeVendor(long vendorId) { - ownedVendors.remove(vendorId); + getOwnedVendors().remove(vendorId); } public int getAmountOfVendors() { - return ownedVendors.size(); + return getOwnedVendors().size(); } - - public long getBindLocation() { - synchronized(objectMutex) { - return bindLocation; + + @Override + public void notifyClients(IoBuffer buffer, boolean notifySelf) { + if (getContainer() != null) { + getContainer().notifyObservers(buffer, notifySelf); } } - - public void setBindLocation(long bindLocation) { + + @Override + public PlayerMessageBuilder getMessageBuilder() { synchronized(objectMutex) { - this.bindLocation = bindLocation; + if (messageBuilder == null) { + messageBuilder = new PlayerMessageBuilder(this); + } + + return messageBuilder; + } + } + + @Override + public void sendBaselines(Client destination) { + if (destination != null && destination.getSession() != null) { + destination.getSession().write(getBaseline(3).getBaseline()); + destination.getSession().write(getBaseline(6).getBaseline()); + if (destination.getParent().getObjectID() == getContainer().getObjectID()) { + destination.getSession().write(getBaseline(8).getBaseline()); + destination.getSession().write(getBaseline(9).getBaseline()); + } + } + } + + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + switch (viewType) { + case 3: + case 6: + if (getContainer() != null) { + getContainer().notifyObservers(getBaseline(viewType).createDelta(updateType, buffer.array()), true); + } + + break; + default: + if (getContainer() != null && getContainer().getClient() != null) { + getContainer().getClient().getSession().write(getBaseline(viewType).createDelta(updateType, buffer.array())); + } } } diff --git a/src/services/BuffService.java b/src/services/BuffService.java index 839c2b01..de08efd2 100644 --- a/src/services/BuffService.java +++ b/src/services/BuffService.java @@ -149,15 +149,15 @@ public class BuffService implements INetworkDispatch { } } - if(FileUtilities.doesFileExist("scripts/buffs/" + buffName + ".py")) core.scriptService.callScript("scripts/buffs/", buffName, "add", core, target, buff); +/* if(FileUtilities.doesFileExist("scripts/buffs/" + buffName + ".py")) core.scriptService.callScript("scripts/buffs/", buffName, "add", core, target, buff); else - { + { */ if(buff.getEffect1Name().length() > 0) core.skillModService.addSkillMod(target, buff.getEffect1Name(), (int) buff.getEffect1Value()); if(buff.getEffect2Name().length() > 0) core.skillModService.addSkillMod(target, buff.getEffect2Name(), (int) buff.getEffect2Value()); if(buff.getEffect3Name().length() > 0) core.skillModService.addSkillMod(target, buff.getEffect3Name(), (int) buff.getEffect3Value()); if(buff.getEffect4Name().length() > 0) core.skillModService.addSkillMod(target, buff.getEffect4Name(), (int) buff.getEffect4Value()); if(buff.getEffect5Name().length() > 0) core.skillModService.addSkillMod(target, buff.getEffect5Name(), (int) buff.getEffect5Value()); - } +// } target.addBuff(buff); @@ -216,15 +216,16 @@ public class BuffService implements INetworkDispatch { dot.getTask().cancel(true); creature.removeDot(dot); } - if(FileUtilities.doesFileExist("scripts/buffs/" + buff.getBuffName() + ".py")) core.scriptService.callScript("scripts/buffs/", buff.getBuffName(), "remove", core, creature, buff); + +/* if(FileUtilities.doesFileExist("scripts/buffs/" + buff.getBuffName() + ".py")) core.scriptService.callScript("scripts/buffs/", buff.getBuffName(), "remove", core, creature, buff); else - { + {*/ if(buff.getEffect1Name().length() > 0) core.skillModService.deductSkillMod(creature, buff.getEffect1Name(), (int) buff.getEffect1Value()); if(buff.getEffect2Name().length() > 0) core.skillModService.deductSkillMod(creature, buff.getEffect2Name(), (int) buff.getEffect2Value()); if(buff.getEffect1Name().length() > 0) core.skillModService.deductSkillMod(creature, buff.getEffect3Name(), (int) buff.getEffect3Value()); if(buff.getEffect1Name().length() > 0) core.skillModService.deductSkillMod(creature, buff.getEffect4Name(), (int) buff.getEffect4Value()); if(buff.getEffect1Name().length() > 0) core.skillModService.deductSkillMod(creature, buff.getEffect5Name(), (int) buff.getEffect5Value()); - } +// } if (!buff.getCallback().equals("none") && !buff.getCallback().equals("")) { if (FileUtilities.doesFileExist("scripts/buffs/" + buff.getBuffName() + ".py")) { diff --git a/src/services/DevService.java b/src/services/DevService.java index c5c6b2e3..31b4987c 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -36,11 +36,11 @@ import resources.common.FileUtilities; import resources.common.Opcodes; import resources.common.SpawnPoint; import resources.datatables.WeaponType; +import resources.harvest.SurveyTool; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; -import resources.objects.tool.SurveyTool; import resources.objects.weapon.WeaponObject; import services.sui.SUIWindow; import services.sui.SUIService.ListBoxType; diff --git a/src/services/GroupService.java b/src/services/GroupService.java index 032ecd15..d9d55256 100644 --- a/src/services/GroupService.java +++ b/src/services/GroupService.java @@ -26,6 +26,8 @@ import java.util.List; import java.util.Map; import resources.buffs.Buff; +import resources.common.OutOfBand; +import resources.common.ProsePackage; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; import services.chat.ChatRoom; @@ -45,6 +47,7 @@ public class GroupService implements INetworkDispatch { core.commandService.registerCommand("join"); core.commandService.registerCommand("disband"); core.commandService.registerCommand("decline"); + core.commandService.registerCommand("dismissgroupmember"); } @Override @@ -74,7 +77,7 @@ public class GroupService implements INetworkDispatch { } if(memberGroupId != 0) { - leader.sendSystemMessage(member.getCustomName() + " is already in a group.", (byte) 0); + leader.sendSystemMessage(OutOfBand.ProsePackage("TT", member.getObjectID(), "@group:already_grouped"), (byte) 0); return; } @@ -96,16 +99,16 @@ public class GroupService implements INetworkDispatch { } if(member.getInviteSenderId() != 0 && member.getInviteSenderId() != leader.getObjectID()) { - leader.sendSystemMessage(member.getCustomName() + " is considering joining another group.", (byte) 0); + leader.sendSystemMessage(OutOfBand.ProsePackage("TT", member.getObjectID(), "@group:considering_other_group"), (byte) 0); return; } if(member.getInviteSenderId() != 0 && member.getInviteSenderId() == leader.getObjectID()) { - leader.sendSystemMessage(member.getCustomName() + " has already been invited to join your group.", (byte) 0); + leader.sendSystemMessage(OutOfBand.ProsePackage("TT", member.getObjectID(), "@group:considering_your_group"), (byte) 0); return; } - leader.sendSystemMessage("You invite " + member.getCustomName() + " to join the group.", (byte) 0); + leader.sendSystemMessage(OutOfBand.ProsePackage("TT", member.getObjectID(), "@group:invite_leader"), (byte) 0); member.setInviteCounter(member.getInviteCounter() + 1); member.setInviteSenderId(leader.getObjectId()); member.setInviteSenderName(leader.getCustomName()); @@ -121,11 +124,9 @@ public class GroupService implements INetworkDispatch { invited.setInviteCounter(invited.getInviteCounter() + 1); invited.setInviteSenderId(0); invited.setInviteSenderName(""); - - invited.sendSystemMessage("You decline to join " + leader.getCustomName() + "'s group.", (byte) 0); + invited.sendSystemMessage(OutOfBand.ProsePackage("TT", leader.getObjectID(), "@group:decline_self"), (byte) 0); invited.updateGroupInviteInfo(); - - leader.sendSystemMessage(invited.getCustomName() + " declines to join your group.", (byte) 0); + invited.sendSystemMessage(OutOfBand.ProsePackage("TT", invited.getObjectID(), "@group:decline_leader"), (byte) 0); } @@ -245,11 +246,11 @@ public class GroupService implements INetworkDispatch { creature.setGroupId(0); creature.makeUnaware(group); core.chatService.leaveChatRoom(creature, group.getChatRoomId()); - creature.sendSystemMessage("You have left the group.", (byte) 0); + creature.sendSystemMessage("@group:removed", (byte) 0); for(SWGObject member : memberList) { CreatureObject creature2 = (CreatureObject) member; - creature2.sendSystemMessage(creature.getCustomName() + " has left the group.", (byte) 0); + creature2.sendSystemMessage(OutOfBand.ProsePackage("TU", creature.getObjectID(), "@group:other_left_prose"), (byte) 0); } removeGroupBuffs(creature); @@ -272,7 +273,7 @@ public class GroupService implements INetworkDispatch { creature2.makeUnaware(group); core.chatService.leaveChatRoom(creature2, group.getChatRoomId()); - creature2.sendSystemMessage("The group has been disbanded.", (byte) 0); + creature.sendSystemMessage("@group:disbanded", (byte) 0); removeGroupBuffs((CreatureObject) member); @@ -285,4 +286,49 @@ public class GroupService implements INetworkDispatch { public void handleGroupDisband(CreatureObject creature) { handleGroupDisband(creature, true); } + + public void removedFromGroup(GroupObject group, CreatureObject creature) { + removeFromGroup(group, creature, false); + } + + public void removeFromGroup(GroupObject group, CreatureObject creature, boolean kicked) { + + group.removeMember(creature); + creature.setInviteCounter(creature.getInviteCounter() + 1); + creature.setInviteSenderId(0); + creature.setInviteSenderName(""); + creature.updateGroupInviteInfo(); + creature.setGroupId(0); + creature.makeUnaware(group); + core.chatService.leaveChatRoom(creature, group.getChatRoomId()); + creature.sendSystemMessage("@group:removed", (byte) 0); + + for(SWGObject member : group.getMemberList()) { + CreatureObject creature2 = (CreatureObject) member; + creature2.sendSystemMessage(OutOfBand.ProsePackage("TU", creature.getObjectID(), "@group:other_left_prose"), (byte) 0); + } + + removeGroupBuffs(creature); + + if(group.getMemberList().size() <= 1 && kicked) + handleGroupDisband((CreatureObject) group.getGroupLeader()); + + } + + public void handleGroupKick(CreatureObject leader, CreatureObject member) { + + GroupObject group = (GroupObject) core.objectService.getObject(leader.getGroupId()); + + if(group == null || member.getGroupId() == 0 || member.getGroupId() != group.getObjectID()) + return; + + if(group.getGroupLeader() != leader) { + leader.sendSystemMessage("@group:must_be_leader", (byte) 0); + return; + } + + removeFromGroup(group, member, true); + + } + } diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 4eda23aa..0e839581 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -924,6 +924,7 @@ public class PlayerService implements INetworkDispatch { } player.setXp(xpType, experience); + creature.setXpBarValue(experience); // 2. See if they need to level up. for (int i = 0; i < experienceTable.getRowCount(); i++) { diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 432868e4..53a0ddb5 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -193,7 +193,9 @@ public class SimulationService implements INetworkDispatch { ODBCursor cursor = core.getSWGObjectODB().getCursor(); while(cursor.hasNext()) { - SWGObject building = core.objectService.getObject(((SWGObject) cursor.next()).getObjectID()); + Object next = cursor.next(); + if (next == null) continue; + SWGObject building = core.objectService.getObject(((SWGObject) next).getObjectID()); if(building == null || (!(building instanceof BuildingObject) && !(building instanceof HarvesterObject))) continue; if(building.getAttachment("hasLoadedServerTemplate") == null) @@ -405,6 +407,7 @@ public class SimulationService implements INetworkDispatch { } checkForCollidables(object); + object.setAttachment("lastValidPosition", object.getPosition()); MoveEvent event = new MoveEvent(); event.object = object; object.getEventBus().publish(event); @@ -470,6 +473,7 @@ public class SimulationService implements INetworkDispatch { object.notifyObservers(utm, false); checkForCollidables(object); + object.setAttachment("lastValidPosition", object.getPosition()); } diff --git a/src/services/StaticService.java b/src/services/StaticService.java index 7fbaade4..edefd3f2 100644 --- a/src/services/StaticService.java +++ b/src/services/StaticService.java @@ -98,7 +98,10 @@ public class StaticService implements INetworkDispatch { public SWGObject spawnObject(String template, String planetName, long cellId, float x, float y, float z, float qW, float qX, float qY, float qZ) { return spawnObject(template, planetName, cellId, x, y, z, qW, qX, qY, qZ, -1); } - + + public SWGObject spawnObject(String template, String planetName, SWGObject cell, float x, float y, float z, float qW, float qX, float qY, float qZ, int respawnTime) { + return spawnObject(template, planetName, ((cell == null) ? 0L : cell.getObjectID()), x, y, z, qW, qX, qY, qZ, respawnTime); + } public SWGObject spawnObject(String template, String planetName, long cellId, float x, float y, float z, float qW, float qX, float qY, float qZ, int respawnTime) { Planet planet = core.terrainService.getPlanetByName(planetName); diff --git a/src/services/SurveyService.java b/src/services/SurveyService.java index fddea8b1..1088c505 100644 --- a/src/services/SurveyService.java +++ b/src/services/SurveyService.java @@ -31,13 +31,13 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import protocol.swg.PlayClientEffectLocMessage; +import resources.harvest.SurveyTool; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import resources.objects.resource.GalacticResource; import resources.objects.resource.ResourceContainerObject; import resources.objects.resource.ResourceRoot; import resources.objects.tangible.TangibleObject; -import resources.objects.tool.SurveyTool; import services.sui.SUIWindow; import services.sui.SUIWindow.SUICallback; import services.sui.SUIWindow.Trigger; diff --git a/src/services/ai/AIService.java b/src/services/ai/AIService.java index 5f2f3e63..117d057a 100644 --- a/src/services/ai/AIService.java +++ b/src/services/ai/AIService.java @@ -26,12 +26,14 @@ import java.util.Map.Entry; import java.util.Random; import java.util.Vector; +import resources.datatables.Difficulty; +import resources.datatables.FactionStatus; +import resources.datatables.GcwType; import resources.objects.creature.CreatureObject; import resources.objects.group.GroupObject; import resources.objects.player.PlayerObject; - +import engine.resources.objects.SWGObject; import engine.resources.scene.Point3D; - import main.NGECore; public class AIService { @@ -109,5 +111,55 @@ public class AIService { return baseXP; } - + + public void awardGcw(AIActor actor) { + CreatureObject npc = actor.getCreature(); + + if (core.factionService.isPvpFaction(npc.getFaction())) { + int gcwPoints = 5; + + if (npc.getDifficulty() == Difficulty.ELITE) { + gcwPoints *= 2; + } + + if (npc.getDifficulty() == Difficulty.BOSS) { + gcwPoints *= 5; + } + + //gcwPoints = actor.getMobileTemplate().getGcwPoints(); // We might want to make this get set in mobile templates if it was different for different npcs ie. assault squads. + + for (CreatureObject player : actor.getDamageMap().keySet()) { + if (player.getGroupId() == 0) { + if (player.getFaction().length() > 0 && player.getFactionStatus() > FactionStatus.OnLeave) { + if ((npc.getLevel() / player.getLevel() * 100) < 86) { + continue; + } + + core.gcwService.addGcwPoints(player, gcwPoints, GcwType.Enemy); + } + } else { + for (SWGObject object : ((GroupObject) core.objectService.getObject(player.getGroupId())).getMemberList()) { + CreatureObject member = (CreatureObject) object; + + if (member == null) { + continue; + } + + if (npc.getPlanet().getName().equals(member.getPlanet().getName()) && npc.getPosition().getDistance(member.getPosition()) > 300) { + continue; + } + + if ((npc.getLevel() / member.getLevel() * 100) < 86) { + continue; + } + + if (member.getFaction().length() > 0 && member.getFactionStatus() > FactionStatus.OnLeave) { + core.gcwService.addGcwPoints(member, gcwPoints, GcwType.Enemy); + } + } + } + } + } + } + } diff --git a/src/services/ai/states/DeathState.java b/src/services/ai/states/DeathState.java index 926d60f8..f2e593cb 100644 --- a/src/services/ai/states/DeathState.java +++ b/src/services/ai/states/DeathState.java @@ -31,6 +31,7 @@ public class DeathState extends AIState { @Override public byte onEnter(AIActor actor) { NGECore.getInstance().aiService.awardExperience(actor); + NGECore.getInstance().aiService.awardGcw(actor); actor.getCreature().setAttachment("radial_filename", "npc/corpse"); //NGECore.getInstance().scriptService.callScript("scripts/radial/npc/corpse", "", "createRadial", NGECore.getInstance(), actor.getCreature().getKiller(), actor.getCreature(), new Vector()); NGECore.getInstance().lootService.DropLoot((CreatureObject)(actor.getCreature().getKiller()),(TangibleObject)(actor.getCreature())); diff --git a/src/services/bazaar/BazaarService.java b/src/services/bazaar/BazaarService.java index 75f3e3f4..7e1bef59 100644 --- a/src/services/bazaar/BazaarService.java +++ b/src/services/bazaar/BazaarService.java @@ -38,7 +38,6 @@ import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; import resources.common.Opcodes; import resources.common.OutOfBand; -import resources.common.ProsePackage; import resources.datatables.DisplayType; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index d73f7eff..781e44ae 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -45,6 +45,7 @@ import resources.buffs.DamageOverTime; import resources.common.FileUtilities; import resources.common.OutOfBand; import resources.datatables.DisplayType; +import resources.datatables.FactionStatus; import resources.datatables.Options; import resources.datatables.Elemental; import resources.datatables.Posture; @@ -242,7 +243,7 @@ public class CombatService implements INetworkDispatch { if(!(obj instanceof TangibleObject) || obj == attacker) continue; - if(obj instanceof CreatureObject && (((CreatureObject) obj).getPosture() == 13 || ((CreatureObject) obj).getPosture() == 14)) + if(obj instanceof CreatureObject && (((CreatureObject) obj).getPosture() == Posture.Incapacitated || ((CreatureObject) obj).getPosture() == Posture.Dead)) continue; if(command.getAttackType() == 0 && !isInConeAngle(attacker, obj, (int) command.getConeLength(), (int) command.getConeWidth(), dirX, dirZ)) @@ -316,7 +317,7 @@ public class CombatService implements INetworkDispatch { if(!(obj instanceof TangibleObject) || obj == attacker) continue; - if(obj instanceof CreatureObject && (((CreatureObject) obj).getPosture() == 13 || ((CreatureObject) obj).getPosture() == 14)) + if(obj instanceof CreatureObject && (((CreatureObject) obj).getPosture() == Posture.Incapacitated || ((CreatureObject) obj).getPosture() == Posture.Dead)) continue; if(command.getAttackType() == 0 && !isInConeAngle(attacker, obj, (int) command.getConeLength(), (int) command.getConeWidth(), dirX, dirZ)) @@ -805,7 +806,7 @@ public class CombatService implements INetworkDispatch { if(core.mountService.isMounted(target)) core.mountService.dismount(target, (CreatureObject) target.getContainer()); target.setHealth(1); - target.setPosture((byte) 13); + target.setPosture(Posture.Incapacitated); target.setTurnRadius(0); target.setSpeedMultiplierBase(0); } @@ -816,7 +817,7 @@ public class CombatService implements INetworkDispatch { if(target.getPosture() != 13) return; - target.setPosture((byte) 0); + target.setPosture(Posture.Upright); target.setTurnRadius(1); target.setSpeedMultiplierBase(1); @@ -833,7 +834,7 @@ public class CombatService implements INetworkDispatch { } else if(target.getHealth() - damage <= 0 && target.getAttachment("AI") != null) { synchronized(target.getMutex()) { target.setHealth(0); - target.setPosture((byte) 14); + target.setPosture(Posture.Dead); } attacker.removeDefender(target); target.removeDefender(attacker); @@ -901,7 +902,7 @@ public class CombatService implements INetworkDispatch { } else { - if(target.getFactionStatus() == 0) + if(target.getFactionStatus() == FactionStatus.OnLeave) return true; return false; @@ -990,7 +991,7 @@ public class CombatService implements INetworkDispatch { if(!(obj instanceof CreatureObject)) continue; - if(obj instanceof CreatureObject && (((CreatureObject) obj).getPosture() == 14)) + if(obj instanceof CreatureObject && (((CreatureObject) obj).getPosture() == Posture.Dead)) continue; if(!core.simulationService.checkLineOfSight(target, obj)) @@ -1008,7 +1009,7 @@ public class CombatService implements INetworkDispatch { public void deathblowPlayer(CreatureObject attacker, CreatureObject target) { target.stopIncapTask(); target.setIncapTask(null); - target.setPosture((byte) 14); + target.setPosture(Posture.Dead); if (target.getSlottedObject("ghost") != null && attacker.getSlottedObject("ghost") != null) { boolean bountyWindow = true; @@ -1149,11 +1150,11 @@ public class CombatService implements INetworkDispatch { CreatureObject creature = (CreatureObject) owner; - if(eventType != 0 || creature.getPosture() != 14) + if(eventType != 0 || creature.getPosture() != Posture.Dead) return; synchronized(creature.getMutex()) { - creature.setPosture((byte) 0); + creature.setPosture(Posture.Upright); creature.setTurnRadius(1); creature.setSpeedMultiplierBase(1); creature.setHealth(creature.getHealth() + 4000); @@ -1178,7 +1179,7 @@ public class CombatService implements INetworkDispatch { if(!(obj instanceof CreatureObject)) continue; - if(obj instanceof CreatureObject && (((CreatureObject) obj).getPosture() != 14)) + if(obj instanceof CreatureObject && (((CreatureObject) obj).getPosture() != Posture.Dead)) continue; if(!attemptHeal(medic, (CreatureObject) obj)) @@ -1247,29 +1248,21 @@ public class CombatService implements INetworkDispatch { return; if(target.getSkillMod("expertise_dot_absorption_all") != null) - damage *= (1 - target.getSkillMod("expertise_dot_absorption_all").getBase() / 100); + damage *= (1 - target.getSkillModBase("expertise_dot_absorption_all") / 100); switch(dot.getType()) { - case "acid": - baseArmor = target.getSkillMod("acid").getBase(); - case "heat": - baseArmor = target.getSkillMod("heat").getBase(); - case "cold": - baseArmor = target.getSkillMod("cold").getBase(); - case "electricity": - baseArmor = target.getSkillMod("electricity").getBase(); - case "energy": - baseArmor = target.getSkillMod("energy").getBase(); case "kinetic": - baseArmor = target.getSkillMod("electricity").getBase(); + baseArmor = target.getSkillModBase("electricity"); // Is this a mistake or is it legitimate? case "poison": - baseArmor = target.getSkillMod("acid").getBase(); + baseArmor = target.getSkillModBase("acid"); case "disease": // disease damages action in nge baseArmor = 0; case "bleeding": // elemental type unknown case "fire": - baseArmor = target.getSkillMod("heat").getBase(); + baseArmor = target.getSkillModBase("heat"); + default: + baseArmor = target.getSkillModBase(dot.getType()); } diff --git a/src/services/gcw/FactionService.java b/src/services/gcw/FactionService.java index c5bafb16..b42d2b99 100644 --- a/src/services/gcw/FactionService.java +++ b/src/services/gcw/FactionService.java @@ -47,7 +47,9 @@ import resources.objects.creature.CreatureObject; import resources.objects.mission.MissionObject; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; +import engine.clientdata.ClientFileManager; import engine.clientdata.StfTable; +import engine.clientdata.visitors.DatatableVisitor; import engine.clients.Client; import engine.resources.common.CRC; import engine.resources.service.INetworkDispatch; @@ -352,28 +354,58 @@ public class FactionService implements INetworkDispatch { return pvpBitmask; } - // temp fix until calculatePvpStatus is fixed - /* - public int calculatePvpStatus(CreatureObject player, TangibleObject target) { - - if(target.getSlottedObject("ghost") != null) { - - if(!player.getFaction().equals(target.getFaction()) && player.getFactionStatus() == FactionStatus.SpecialForces && ((CreatureObject) target).getFactionStatus() == FactionStatus.SpecialForces) - return 55; - else if(core.combatService.areInDuel(player, (CreatureObject) target)) - return 55; - else - return 0x14; - - } else { - if(target.getAttachment("AI") != null) - return PvpStatus.Attackable; - else - return 0; + public boolean isPvpFaction(String faction) { + if (!isFaction(faction)) { + return false; } + try { + DatatableVisitor PvpFactions = ClientFileManager.loadFile("datatables/player/pvp_factions.iff", DatatableVisitor.class); + + for (int i = 0; i < PvpFactions.getRowCount(); i++) { + if (PvpFactions.getObject(i, 0) != null) { + if (((String) PvpFactions.getObject(i, 0)).equals(faction)) { + return true; + } + } + } + + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + + return false; + } + + public void join(CreatureObject actor, String faction) { + if (actor.getPvpBitmask() == PvpStatus.GoingCovert) { + actor.sendSystemMessage("@faction_recruiter:pvp_status_changing", DisplayType.Broadcast); + return; + } + + if (actor.getPvpBitmask() == PvpStatus.GoingOvert) { + actor.sendSystemMessage("@faction_recruiter:pvp_status_changing", DisplayType.Broadcast); + return; + } + + if (actor.getFaction().length() > 0) { + actor.sendSystemMessage("@faction_recruiter:resign_on_leave", DisplayType.Broadcast); + return; + } + + scheduler.schedule(() -> { + actor.setFaction(faction); + actor.setFactionStatus(FactionStatus.Combatant); + actor.setPvpBitmask(0); + PlayerObject player = ((PlayerObject) actor.getSlottedObject("ghost")); + if (player != null) { + player.resetGcwPoints(); + player.resetPvpKills(); + player.setCurrentRank(1); + } + actor.updatePvpStatus(); + }, 1, TimeUnit.SECONDS); } - */ public void changeFactionStatus(CreatureObject actor, int factionStatus) { long time = 1; @@ -464,6 +496,12 @@ public class FactionService implements INetworkDispatch { actor.setPvpBitmask(0); actor.setFactionStatus(FactionStatus.OnLeave); actor.setFaction(""); + PlayerObject player = ((PlayerObject) actor.getSlottedObject("ghost")); + if (player != null) { + player.resetGcwPoints(); + player.resetPvpKills(); + player.setCurrentRank(0); + } actor.updatePvpStatus(); actor.sendSystemMessage("@faction_recruiter:resign_complete", DisplayType.Broadcast); }, time, TimeUnit.SECONDS); diff --git a/src/services/gcw/GCWService.java b/src/services/gcw/GCWService.java index 73d06d36..9abd601f 100644 --- a/src/services/gcw/GCWService.java +++ b/src/services/gcw/GCWService.java @@ -25,11 +25,14 @@ import java.math.BigDecimal; import java.math.MathContext; import java.nio.ByteOrder; import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -42,28 +45,42 @@ import org.python.google.common.collect.Multimap; import protocol.swg.GcwGroupsRsp; import protocol.swg.GcwRegionsReq; import protocol.swg.GcwRegionsRsp; - import resources.common.Opcodes; +import resources.common.OutOfBand; +import resources.common.collidables.CollidableCircle; +import resources.datatables.DisplayType; import resources.datatables.FactionStatus; +import resources.datatables.GcwType; import resources.gcw.CurrentServerGCWZoneHistory; import resources.gcw.CurrentServerGCWZonePercent; import resources.gcw.OtherServerGCWZonePercent; import resources.objects.creature.CreatureObject; import resources.objects.guild.GuildObject; - +import resources.objects.player.PlayerObject; import main.NGECore; - import engine.clients.Client; +import engine.resources.database.ODBCursor; import engine.resources.objects.SWGObject; +import engine.resources.scene.Planet; import engine.resources.scene.Point2D; +import engine.resources.scene.Point3D; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; public class GCWService implements INetworkDispatch { private NGECore core; + private GuildObject object; + + private static final int[] MOD2 = { 10250, 7250, 7250, 6750, 6750, 6750, 6750, 6750, 6750, 6750, 6750, 6750 }; + private static final int[] DECAY1 = { 0, 0, 0, 0, 0, 0, 2727, 2744, 2769, 2799, 2823, 2857 }; + private static final int[] DECAY2 = { 0, 0, 0, 0, 0, 0, 6000, 6500, 7200, 8200, 9600, 12000 }; + private static final int[] CONST2 = { 0, 0, 0, 0, 0, 0, 12200, 12200, 12900, 14100, 16200, 18700 }; + private static final int[] CONST4 = { 0, 0, 0, 0, 0, 0, 1950, 3550, 5600, 7800, 9350, 11100 }; + private Map> zoneMap() { return object.getZoneMap(); } + private Map> pvpZones = new ConcurrentHashMap>(); private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); @@ -79,6 +96,8 @@ public class GCWService implements INetworkDispatch { private void afterInitialisation() { try { core.scriptService.callScript("scripts/", "gcwzones", "addZones", core); + core.scriptService.callScript("scripts/", "pvpzones", "addZones", core); + updateNextUpdateTime(); } catch (Exception e) { e.printStackTrace(); } @@ -285,6 +304,63 @@ public class GCWService implements INetworkDispatch { } } }, 2, 2, TimeUnit.DAYS); + + scheduler.scheduleAtFixedRate(new Runnable() { + @Override public void run() { gcwUpdate(); } + + private void gcwUpdate() { + long nextUpdateTime = calculateNextUpdateTime(); + + ODBCursor cursor = core.getSWGObjectODB().getCursor(); + + while (cursor.hasNext()) { + SWGObject object = (SWGObject) cursor.next(); + + if (object == null) { + continue; + } + + if (core.objectService.getObject(object.getObjectID()) == null) { + object = core.objectService.getObject(object.getObjectID()); + } + + if (!(object instanceof CreatureObject)) { + continue; + } + + CreatureObject creature = (CreatureObject) object; + + if (creature.getSlottedObject("ghost") == null) { + continue; + } + + PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); + + // TODO update statistics + + if (core.factionService.isPvpFaction(creature.getFaction())) { + updateGcwRank(creature); + player.addLifetimeGcwPoints(player.getGcwPoints()); + player.addLifetimePvpKills(player.getPvpKills()); + player.resetGcwPoints(); + player.resetPvpKills(); + + if (creature.getFaction().equals("rebel") && player.getCurrentRank() > player.getHighestRebelRank()) { + player.setHighestRebelRank(player.getCurrentRank()); + } + + if (creature.getFaction().equals("imperial") && player.getCurrentRank() > player.getHighestImperialRank()) { + player.setHighestImperialRank(player.getCurrentRank()); + } + + player.setNextUpdateTime((int) nextUpdateTime); + } + } + + cursor.close(); + } + + }, (calculateNextUpdateTime() - System.currentTimeMillis()), 604800000, TimeUnit.MILLISECONDS); } public void addZone(String planet, String zone, float x, float z, float radius, int weight, int type) { @@ -365,6 +441,118 @@ public class GCWService implements INetworkDispatch { } } + public void addGcwPoints(CreatureObject actor, int gcwPoints, byte gcwType) { + if (actor == null) { + return; + } + + if (!core.factionService.isPvpFaction(actor.getFaction())) { + return; + } + + if (actor.getSlottedObject("ghost") == null) { + return; + } + + PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); + + String planet = actor.getPlanet().getName(); + + String prefix = ((planet.startsWith("space")) ? (planet + "_space") : planet); + + switch (gcwType) { + case GcwType.Enemy: + adjustZone(planet, prefix + "_pve", actor.getFaction(), gcwPoints); + actor.sendSystemMessage(OutOfBand.ProsePackage("@gcw:gcw_rank_generic_point_grant", gcwPoints), DisplayType.Broadcast); + break; + case GcwType.Player: + adjustZone(planet, prefix + "_pvp", actor.getFaction(), gcwPoints); + //actor.sendSystemMessage(OutOfBand.ProsePackage("@gcw:gcw_rank_pvp_kill_point_grant", gcwPoints), DisplayType.Broadcast); // Put this msg after this function is used rather than inside function + break; + } + + String zone = getCurrentGcwRegion(actor); + + if (zone != null) { + adjustZone(planet, zone, actor.getFaction(), gcwPoints); + } + + player.setGcwPoints(player.getGcwPoints() + gcwPoints); + } + + /* Ported from javascript. + * Written for us by Hendrik of http://swg.activeframe.de. + */ + private double helper(int points, int rank) { + int faktor = points / (MOD2[rank-1] - 250 * rank); + int rt = points / (1 + faktor) - DECAY1[rank-1]; + + if (rank >= 7) { + if (points > DECAY2[rank-1] && rt > 0) { + rt = rt * (((17 - rank) / (14 - rank)) + (CONST2[rank-1] / (points - CONST4[rank-1]))); + } + } + + return Math.floor(rt); + } + + /* Ported from javascript. + * Written for us by Hendrik of http://swg.activeframe.de. + */ + public void updateGcwRank(CreatureObject actor) { + if (actor == null) { + return; + } + + if (actor.getFaction().length() == 0) { + return; + } + + if (actor.getSlottedObject("ghost") == null) { + return; + } + + PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); + + int oldrank = player.getCurrentRank(); + int oldprogress = (int) ((player.getRankProgress() > 100) ? 100 : player.getRankProgress()); + int oldpoints = player.getGcwPoints(); + int newrank = oldrank; + int newprogress = oldprogress; + int oldranktotal = 0; + int oldrankprogress = 0; + int newranktotal = 0; + int newrankprogress = 0; + + oldrankprogress = oldprogress * 50; + oldranktotal = 5000 * (oldrank - 1) + oldrankprogress; + + newprogress = (int) helper(oldpoints, oldrank); + + if (newprogress < -2000) { + newprogress = -2000; + } + + newranktotal = oldranktotal + newprogress; + + if (oldrank == 7 && newprogress < 0 && newranktotal < 30000) { + newranktotal = 29999; + } + + newrank = (int) (Math.floor(newranktotal / 5000) + 1); + + if (newrank > 12) { + newrank = 12; + newranktotal = 12 * 5000 - 1; + } + + newrankprogress = newranktotal - (newrank - 1) * 5000; + newprogress = newrankprogress * 100 / 5000; + + player.setCurrentRank(newrank); + player.setRankProgress((float) Math.floor(newprogress)); + } + public List getSFPlayers() { List flagged = new ArrayList(); @@ -388,6 +576,108 @@ public class GCWService implements INetworkDispatch { return flagged; } + public String getCurrentGcwRegion(CreatureObject actor) { + try { + String planet = actor.getPlanet().getName(); + + if (zoneMap().containsKey(planet)) { + for (String zoneName : zoneMap().get(planet).keySet()) { + CurrentServerGCWZonePercent zone = zoneMap().get(planet).get(zoneName).clone(); + + if (zone.getRadius() > 0) { + List objects = core.simulationService.get(core.terrainService.getPlanetByName(planet), zone.getPosition().x, zone.getPosition().z, (int) zone.getRadius()); + + if (objects.contains(actor)) { + return zoneName; + } + } + } + } + } catch (Exception e) { + return null; + } + + return null; + } + + public long calculateNextUpdateTime() { + Calendar c = Calendar.getInstance(); + Date now = new Date(); + + c.setTime(now); + + int weekday = c.get(Calendar.DAY_OF_WEEK); + + if (weekday != Calendar.THURSDAY) { + int days = ((Calendar.WEDNESDAY - weekday + 2) % 7); + c.add(Calendar.DAY_OF_YEAR, days); + } else if (c.get(Calendar.HOUR_OF_DAY) >= 7) { + c.add(Calendar.DAY_OF_YEAR, 7); + } + + c.set(Calendar.HOUR_OF_DAY, 7); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + + return c.getTimeInMillis(); + } + + public void updateNextUpdateTime() { + ODBCursor cursor = core.getSWGObjectODB().getCursor(); + + while (cursor.hasNext()) { + SWGObject object = (SWGObject) cursor.next(); + + if (object == null) { + continue; + } + + if (core.objectService.getObject(object.getObjectID()) == null) { + object = core.objectService.getObject(object.getObjectID()); + } + + if (!(object instanceof CreatureObject)) { + continue; + } + + CreatureObject creature = (CreatureObject) object; + + if (creature.getSlottedObject("ghost") == null) { + continue; + } + + PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); + + player.setNextUpdateTime((int) calculateNextUpdateTime()); + } + + cursor.close(); + } + + public long calculateResetTime() { + Calendar c = Calendar.getInstance(); + Date now = new Date(); + + c.setTime(now); + + int weekday = c.get(Calendar.DAY_OF_WEEK); + + if (weekday != Calendar.THURSDAY) { + int days = ((Calendar.WEDNESDAY - weekday + 2) % 7); + c.add(Calendar.DAY_OF_YEAR, days); + } else if (c.get(Calendar.HOUR_OF_DAY) >= 7) { + c.add(Calendar.DAY_OF_YEAR, 7); + } + + c.set(Calendar.HOUR_OF_DAY, 7); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + + return c.getTimeInMillis(); + } + public void insertOpcodes(Map swgOpcodes, Map objControllerOpcodes) { swgOpcodes.put(Opcodes.GcwRegionsReq, new INetworkRemoteEvent() { @@ -421,6 +711,25 @@ public class GCWService implements INetworkDispatch { } + public void addPvPZone(String planetName, float x, float z, float radius) { + Planet planet = core.terrainService.getPlanetByName(planetName); + if(planet == null) + return; + if(pvpZones.get(planet) == null) + pvpZones.put(planet, new ArrayList()); + CollidableCircle area = new CollidableCircle(new Point3D(x, 0, z), radius, planet); + PvPZone zone = new PvPZone(planet, area); + pvpZones.get(planet).add(zone); + core.simulationService.addCollidable(area, x, z); + } + + public boolean isInPvpZone(CreatureObject actor) { + List zones = pvpZones.get(actor.getPlanet()); + if(zones == null) + return false; + return zones.stream().anyMatch(z -> z.getArea().doesCollide(actor)); + } + @Override public void shutdown() { diff --git a/src/services/gcw/PvPZone.java b/src/services/gcw/PvPZone.java index e418327b..b272f6bf 100644 --- a/src/services/gcw/PvPZone.java +++ b/src/services/gcw/PvPZone.java @@ -21,16 +21,23 @@ ******************************************************************************/ package services.gcw; +import main.NGECore; import net.engio.mbassy.listener.Handler; import resources.common.collidables.AbstractCollidable; import resources.common.collidables.AbstractCollidable.EnterEvent; import resources.common.collidables.AbstractCollidable.ExitEvent; +import resources.datatables.FactionStatus; +import resources.datatables.PvpStatus; +import resources.objects.creature.CreatureObject; import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; public class PvPZone { private Planet planet; private AbstractCollidable area; + private NGECore core = NGECore.getInstance(); + public PvPZone(Planet planet, AbstractCollidable area) { this.planet = planet; @@ -54,14 +61,51 @@ public class PvPZone { this.area = area; } + public void warpBack(CreatureObject actor) { + if (core.mountService.isMounted(actor)) { + actor = (CreatureObject) actor.getContainer(); + } + core.simulationService.teleport(actor, (Point3D) actor.getAttachment("lastValidPosition"), actor.getOrientation(), actor.getParentId()); + } + @Handler public void onEnter(EnterEvent event) { + CreatureObject actor = (CreatureObject) event.object; + + if(!actor.getFaction().equals("rebel") && !actor.getFaction().equals("imperial")) { + actor.sendSystemMessage("@gcw:pvp_advanced_region_not_allowed", (byte) 0); + warpBack(actor); + return; + } + + if(actor.getLevel() < 75) { + actor.sendSystemMessage("@gcw:pvp_advanced_region_level_low", (byte) 0); + warpBack(actor); + return; + } + + if(actor.getPvpStatus(PvpStatus.GoingCovert) || actor.getPvpStatus(PvpStatus.GoingOvert)) { + actor.setPvpStatus(PvpStatus.GoingCovert, false); + actor.setPvpStatus(PvpStatus.GoingOvert, false); + actor.sendSystemMessage("@gcw:pvp_advanced_region_faction_type_change_cancel", (byte) 0); + } + + actor.setFactionStatus(FactionStatus.SpecialForces); + actor.updatePvpStatus(); + actor.sendSystemMessage("@gcw:pvp_advanced_region_entered", (byte) 0); + } @Handler public void onExit(ExitEvent event) { + CreatureObject actor = (CreatureObject) event.object; + + actor.setFactionStatus(FactionStatus.OnLeave); + actor.updatePvpStatus(); + actor.sendSystemMessage("@gcw:pvp_advanced_region_exited", (byte) 0); + } diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index c1566e45..5fecc24d 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -48,6 +48,7 @@ import java.util.concurrent.atomic.AtomicLong; import resources.common.*; import resources.datatables.Options; import resources.datatables.PlayerFlags; +import resources.harvest.SurveyTool; import org.apache.mina.core.buffer.IoBuffer; import org.apache.mina.core.session.IoSession; @@ -118,7 +119,6 @@ import resources.objects.resource.ResourceContainerObject; import resources.objects.resource.ResourceRoot; import resources.objects.staticobject.StaticObject; import resources.objects.tangible.TangibleObject; -import resources.objects.tool.SurveyTool; import resources.objects.waypoint.WaypointObject; import resources.objects.weapon.WeaponObject; import services.ai.AIActor; diff --git a/src/services/spawn/MobileTemplate.java b/src/services/spawn/MobileTemplate.java index 1d31bb5a..5c67f195 100644 --- a/src/services/spawn/MobileTemplate.java +++ b/src/services/spawn/MobileTemplate.java @@ -21,6 +21,7 @@ ******************************************************************************/ package services.spawn; +import java.util.ArrayList; import java.util.List; import java.util.Vector; @@ -59,7 +60,7 @@ public class MobileTemplate implements Cloneable { private String meatType, milkType, boneType, hideType; private int meatAmount, milkAmount, boneAmount, hideAmount; private int respawnTime = 0; - private List lootGroups; + private List lootGroups = new ArrayList(); public Vector getTemplates() { diff --git a/src/services/spawn/SpawnService.java b/src/services/spawn/SpawnService.java index dc0382c4..65e6d71a 100644 --- a/src/services/spawn/SpawnService.java +++ b/src/services/spawn/SpawnService.java @@ -100,7 +100,7 @@ public class SpawnService { creature.setWeaponId(mobileTemplate.getCustomWeapon().getObjectID()); }*/ - if(mobileTemplate.getLootGroups() != null) + if(mobileTemplate.getLootGroups() != null && !mobileTemplate.getLootGroups().isEmpty()) creature.setLootGroups(mobileTemplate.getLootGroups()); creature.setOptionsBitmask(mobileTemplate.getOptionsBitmask()); @@ -118,7 +118,7 @@ public class SpawnService { level = mobileTemplate.getLevel(); } - if (mobileTemplate.getMinLevel()!=0 && mobileTemplate.getMaxLevel()!=0){ + if (mobileTemplate.getMinLevel()!=0 && mobileTemplate.getMaxLevel()!=0 && level == -1){ level = (short) (mobileTemplate.getMinLevel() + (new Random().nextInt(mobileTemplate.getMaxLevel()-mobileTemplate.getMinLevel()))); creature.setLevel(level); }