diff --git a/README.md b/README.md index 59964377..783721b1 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,5 @@ To contribute, simply commit your changes to your fork of the project and then s Now your changes will be reviewed by other developers and once the changes are approved your code will be merged into the main repository. For more information please visit the wiki: https://github.com/ProjectSWGCore/NGECore2/wiki + +Documentation can be found here: http://projectswgcore.github.io/NGECore2/doc/ diff --git a/ngengine_public.jar b/ngengine_public.jar index 0b3fb96f..353c787a 100644 Binary files a/ngengine_public.jar and b/ngengine_public.jar differ diff --git a/scripts/buffs/bh_prescience.py b/scripts/buffs/bh_prescience.py new file mode 100644 index 00000000..e09c02e5 --- /dev/null +++ b/scripts/buffs/bh_prescience.py @@ -0,0 +1,8 @@ +import sys + +def setup(core, actor, buff): + return + +def removeBuff(core, actor, buff): + return + \ No newline at end of file diff --git a/scripts/buffs/fs_buff_ca_1.py b/scripts/buffs/fs_buff_ca_1.py new file mode 100644 index 00000000..d5941811 --- /dev/null +++ b/scripts/buffs/fs_buff_ca_1.py @@ -0,0 +1,11 @@ +import sys + +def setup(core, actor, buff): + core.skillModService.addSkillMod(actor, 'expertise_stance', 1) + + return + +def removeBuff(core, actor, buff): + core.skillModService.deductSkillMod(actor, 'expertise_stance', 1) + return + \ No newline at end of file diff --git a/scripts/buffs/fs_buff_def_1_1.py b/scripts/buffs/fs_buff_def_1_1.py new file mode 100644 index 00000000..d5941811 --- /dev/null +++ b/scripts/buffs/fs_buff_def_1_1.py @@ -0,0 +1,11 @@ +import sys + +def setup(core, actor, buff): + core.skillModService.addSkillMod(actor, 'expertise_stance', 1) + + return + +def removeBuff(core, actor, buff): + core.skillModService.deductSkillMod(actor, 'expertise_stance', 1) + return + \ No newline at end of file diff --git a/scripts/buffs/proc_old_dark_jedi_gift.py b/scripts/buffs/proc_old_dark_jedi_gift.py new file mode 100644 index 00000000..e09c02e5 --- /dev/null +++ b/scripts/buffs/proc_old_dark_jedi_gift.py @@ -0,0 +1,8 @@ +import sys + +def setup(core, actor, buff): + return + +def removeBuff(core, actor, buff): + return + \ No newline at end of file diff --git a/scripts/commands/deathblow.py b/scripts/commands/deathblow.py new file mode 100644 index 00000000..7b879211 --- /dev/null +++ b/scripts/commands/deathblow.py @@ -0,0 +1,28 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + + combatSvc = core.combatService + + if not target: + return + + if actor.getPosture() == 13 or actor.getPosture() == 14: + return + + if not target.getPosture() == 13: + return + + if not target.isAttackableBy(actor): + return + + if not target.inRange(actor.getPosition(), 5): + return + + combatSvc.deathblowPlayer(actor, target) + + return + \ No newline at end of file diff --git a/scripts/commands/duel.py b/scripts/commands/duel.py new file mode 100644 index 00000000..4ce25bdf --- /dev/null +++ b/scripts/commands/duel.py @@ -0,0 +1,29 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + + combatSvc = core.combatService + + if not target: + return + + if not target.getClient(): + return + + if actor == target: + actor.sendSystemMessage('You cannot challenge yourself.', 0) + return + + if combatSvc.areInDuel(actor, target): + return + + if actor.getDuelList().contains(target): + actor.sendSystemMessage('You already challenged ' + target.getCustomName() + ' to a duel.', 0) + + combatSvc.handleDuel(actor, target) + + return + \ No newline at end of file diff --git a/scripts/commands/endduel.py b/scripts/commands/endduel.py new file mode 100644 index 00000000..030ef9b3 --- /dev/null +++ b/scripts/commands/endduel.py @@ -0,0 +1,25 @@ +import sys + +def setup(): + return + +def run(core, actor, target, commandString): + + combatSvc = core.combatService + + if not target: + return + + if not target.getClient(): + return + + if actor == target: + return + + if not combatSvc.areInDuel(actor, target): + return + + combatSvc.handleEndDuel(actor, target) + + return + \ No newline at end of file diff --git a/scripts/commands/fs_buff_ca_1.py b/scripts/commands/fs_buff_ca_1.py new file mode 100644 index 00000000..141b3158 --- /dev/null +++ b/scripts/commands/fs_buff_ca_1.py @@ -0,0 +1,9 @@ +import sys + +def setup(core, actor, buff): + return + +def run(core, actor, target, commandString): + core.buffService.addBuffToCreature(actor, 'fs_buff_ca_1') + return + \ No newline at end of file diff --git a/scripts/commands/fs_buff_def_1_1.py b/scripts/commands/fs_buff_def_1_1.py new file mode 100644 index 00000000..cd9637f1 --- /dev/null +++ b/scripts/commands/fs_buff_def_1_1.py @@ -0,0 +1,9 @@ +import sys + +def setup(core, actor, buff): + return + +def run(core, actor, target, commandString): + core.buffService.addBuffToCreature(actor, 'fs_buff_def_1_1') + return + \ No newline at end of file diff --git a/scripts/commands/kneel.py b/scripts/commands/kneel.py index b02ab55b..77bec3ee 100644 --- a/scripts/commands/kneel.py +++ b/scripts/commands/kneel.py @@ -4,6 +4,10 @@ def setup(): return def run(core, actor, target, commandString): + + if actor.getPosture() == 13 or actor.getPosture() == 14: + return + actor.setPosture(1) actor.setSpeedMultiplierBase(0) actor.setTurnRadius(0) diff --git a/scripts/commands/prone.py b/scripts/commands/prone.py index e8bc20f0..f93bf085 100644 --- a/scripts/commands/prone.py +++ b/scripts/commands/prone.py @@ -4,6 +4,10 @@ def setup(): return def run(core, actor, target, commandString): + + if actor.getPosture() == 13 or actor.getPosture() == 14: + return + actor.setPosture(2) actor.setSpeedMultiplierBase(0.25) actor.setTurnRadius(1) diff --git a/scripts/commands/setspeed.py b/scripts/commands/setspeed.py index c73266de..e5929c25 100644 --- a/scripts/commands/setspeed.py +++ b/scripts/commands/setspeed.py @@ -5,5 +5,6 @@ def setup(): def run(core, actor, target, commandString): actor.setSpeedMultiplierBase(float(commandString)) + core.buffService.addBuffToCreature(actor, 'bh_prescience') return \ No newline at end of file diff --git a/scripts/commands/sitserver.py b/scripts/commands/sitserver.py index 73b7c77a..2641b8a3 100644 --- a/scripts/commands/sitserver.py +++ b/scripts/commands/sitserver.py @@ -7,6 +7,9 @@ def setup(): def run(core, actor, target, commandString): + if actor.getPosture() == 13 or actor.getPosture() == 14: + return + if len(commandString) > 0: parsedMsg = commandString.split(',', 4) x = float(parsedMsg[0]) diff --git a/scripts/commands/stand.py b/scripts/commands/stand.py index 6add2453..38b0e097 100644 --- a/scripts/commands/stand.py +++ b/scripts/commands/stand.py @@ -5,6 +5,9 @@ def setup(): def run(core, actor, target, commandString): + if actor.getPosture() == 13 or actor.getPosture() == 14: + return + if actor.getStateBitmask() == 32768: actor.setStateBitmask(0) diff --git a/scripts/commands/transferitemmisc.py b/scripts/commands/transferitemmisc.py index d1dedf7b..83f34e8d 100644 --- a/scripts/commands/transferitemmisc.py +++ b/scripts/commands/transferitemmisc.py @@ -1,18 +1,32 @@ import sys - + def setup(): - return - + return + def run(core, actor, target, commandString): - parsedMsg = commandString.split(' ', 3) - objService = core.objectService - containerID = long(parsedMsg[1]) - print str(containerID) - container = objService.getObject(containerID) - if target and container and target.getContainer(): - print 'Misc Test' - oldContainer = target.getContainer() - oldContainer.transferTo(actor, container, target) - - return - \ No newline at end of file + parsedMsg = commandString.split(' ', 3) + objService = core.objectService + containerID = long(parsedMsg[1]) + container = objService.getObject(containerID) + if target and container and target.getContainer(): + oldContainer = target.getContainer() + + if container == oldContainer: + print 'Error: New container is same as old container.' + return; + + oldContainer.transferTo(actor, container, target) + + if actor == container: + if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'): + path = 'scripts/' + target.getTemplate().rpartition('/')[0] + '/' + module = target.getTemplate().rpartition('/')[2].replace('shared_', '').replace('.iff', '') + core.scriptService.callScript(path, 'equip', module, core, actor, target) + + if actor == oldContainer: + if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'): + path = 'scripts/' + target.getTemplate().rpartition('/')[0] + '/' + module = target.getTemplate().rpartition('/')[2].replace('shared_', '').replace('.iff', '') + core.scriptService.callScript(path, 'unequip', module, core, actor, target) + + return \ No newline at end of file diff --git a/scripts/demo.py b/scripts/demo.py index adb7e3df..f7944777 100644 --- a/scripts/demo.py +++ b/scripts/demo.py @@ -44,6 +44,42 @@ def CreateStartingCharacter(core, object): inventory.add(testCloak) profession = object.getSlottedObject('ghost').getProfession() addProfessionAbilities(core, object, profession) + + heroism1 = core.objectService.createObject('object/tangible/wearables/necklace/shared_necklace_s10.iff', object.getPlanet()) + heroism1.setStfFilename('static_item_n') + heroism1.setStfName('item_necklace_set_hero_01_01') + heroism1.setDetailFilename('static_item_d') + heroism1.setDetailName('item_necklace_set_hero_01_01') + heroism1.setStringAttribute('@set_bonus:piece_bonus_count_2', '@set_bonus:set_bonus_hero_1') + heroism1.setStringAttribute('@set_bonus:piece_bonus_count_3', '@set_bonus:set_bonus_hero_2') + heroism1.setStringAttribute('@set_bonus:piece_bonus_count_5', '@set_bonus:set_bonus_hero_3') + heroism1.setIntAttribute('cat_stat_mod_bonus.food_luck_modified' , 30) + heroism1.setIntAttribute('cat_stat_mod_bonus.food_precision_modified' , 30) + heroism1.setIntAttribute('cat_stat_mod_bonus.food_strength_modified' , 30) + + + inventory = object.getSlottedObject('inventory') + if not inventory: + return + inventory.add(heroism1) + + heroism2 = core.objectService.createObject('object/tangible/wearables/bracelet/shared_bracelet_s03_r.iff', object.getPlanet()) + heroism2.setStfFilename('static_item_n') + heroism2.setStfName('item_bracelet_r_set_hero_01_01') + heroism2.setDetailFilename('static_item_d') + heroism2.setDetailName('item_bracelet_r_set_hero_01_01') + heroism2.setStringAttribute('@set_bonus:piece_bonus_count_2', '@set_bonus:set_bonus_hero_1') + heroism2.setStringAttribute('@set_bonus:piece_bonus_count_3', '@set_bonus:set_bonus_hero_2') + heroism2.setStringAttribute('@set_bonus:piece_bonus_count_5', '@set_bonus:set_bonus_hero_3') + heroism2.setIntAttribute('cat_stat_mod_bonus.food_luck_modified' , 30) + heroism2.setIntAttribute('cat_stat_mod_bonus.food_precision_modified' , 30) + heroism2.setIntAttribute('cat_stat_mod_bonus.food_strength_modified' , 30) + + + inventory = object.getSlottedObject('inventory') + if not inventory: + return + inventory.add(heroism2) return def addProfessionAbilities(core, object, profession): @@ -67,6 +103,8 @@ def addProfessionAbilities(core, object, profession): object.addAbility('fs_sh_3') object.addAbility('fs_dm_cc_6') object.addAbility('fs_dm_7') + object.addAbility('fs_buff_def_1_1') + object.addAbility('fs_buff_ca_1') elif profession == 'medic_1a': object.addAbility('me_bacta_bomb_5') object.addAbility('me_bacta_grenade_5') diff --git a/scripts/object/building/corellia/cloning_corellia.py b/scripts/object/building/corellia/cloning_corellia.py index ccad8904..487b8163 100644 --- a/scripts/object/building/corellia/cloning_corellia.py +++ b/scripts/object/building/corellia/cloning_corellia.py @@ -1,4 +1,25 @@ import sys +from java.util import Vector +from resources.common import SpawnPoint def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(2) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(1), float(-0.05), float(2.5), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(1), float(-0.05), float(-1.35), float(1), float(0)) + + spawnPoints = Vector() + spawnPoints.add(SpawnPoint(-16.6514, -4.29167, -10.4976, 0.709453, 0.704753, 4)) + spawnPoints.add(SpawnPoint(-16.5965, -4.29167, -14.1652, 0.721346, 0.692575, 4)) + spawnPoints.add(SpawnPoint(16.5771, -4.29167, -14.2091, 0.71195, -0.702231, 4)) + spawnPoints.add(SpawnPoint(16.6876, -4.29167, -10.5391, -0.6972, 0.716877, 4)) + spawnPoints.add(SpawnPoint(6.32992, -4.79167, 0.613332, 0.999992, 0.00405023, 4)) + spawnPoints.add(SpawnPoint(1.58067, -4.79167, 0.582775, 0.989691, 0.0143216, 4)) + spawnPoints.add(SpawnPoint(-2.84125, -4.79167, 0.657588, -0.0356012, 0.999366, 4)) + + object.setAttachment('spawnPoints', spawnPoints) + + return + \ No newline at end of file diff --git a/scripts/object/building/corellia/starport_corellia.py b/scripts/object/building/corellia/starport_corellia.py index ccad8904..e71c9121 100644 --- a/scripts/object/building/corellia/starport_corellia.py +++ b/scripts/object/building/corellia/starport_corellia.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(4) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(3.1), float(0.6), float(49), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-2.7), float(0.6), float(49), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) + + core.mapService.addLocation(object.getPlanet(), 'Starport', object.getPosition().x, object.getPosition().z, 15, 0, 0) + return + \ No newline at end of file diff --git a/scripts/object/building/general/cloning_facility_general.py b/scripts/object/building/general/cloning_facility_general.py index ccad8904..b7879b33 100644 --- a/scripts/object/building/general/cloning_facility_general.py +++ b/scripts/object/building/general/cloning_facility_general.py @@ -1,4 +1,6 @@ import sys def setup(core, object): - return \ No newline at end of file + + return + \ No newline at end of file diff --git a/scripts/object/building/military/outpost_cloning_facility.py b/scripts/object/building/military/outpost_cloning_facility.py index ccad8904..781c25a2 100644 --- a/scripts/object/building/military/outpost_cloning_facility.py +++ b/scripts/object/building/military/outpost_cloning_facility.py @@ -1,4 +1,17 @@ import sys +from java.util import Vector +from resources.common import SpawnPoint def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(3) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(0.0387871), float(0.125265), float(-6), float(-0.0595427), float(0.998226)) + + spawnPoints = Vector() + spawnPoints.add(SpawnPoint(3.2408, 0.125266, -3.59732, 0.707641, -0.706572, 5)) + + object.setAttachment('spawnPoints', spawnPoints) + + return diff --git a/scripts/object/building/military/outpost_cloning_facility_s02.py b/scripts/object/building/military/outpost_cloning_facility_s02.py index ccad8904..8d5a2475 100644 --- a/scripts/object/building/military/outpost_cloning_facility_s02.py +++ b/scripts/object/building/military/outpost_cloning_facility_s02.py @@ -1,4 +1,20 @@ import sys +from java.util import Vector +from resources.common import SpawnPoint def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(6) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-5.5), float(0.125265), float(-3.43841), float(0.699512), float(0.714621)) + + spawnPoints = Vector() + spawnPoints.add(SpawnPoint(4.44727, 0.125266, -3.80136, -0.706468, 0.707745, 5)) + spawnPoints.add(SpawnPoint(4.65395, 0.125266, 1.49466, 0.714548, -0.699587, 4)) + spawnPoints.add(SpawnPoint(-3.99569, 0.125266, -3.51553, 0.70407, 0.710131, 6)) + + object.setAttachment('spawnPoints', spawnPoints) + + return + \ No newline at end of file diff --git a/scripts/object/building/military/outpost_cloning_facility_s03.py b/scripts/object/building/military/outpost_cloning_facility_s03.py index ccad8904..48330e4c 100644 --- a/scripts/object/building/military/outpost_cloning_facility_s03.py +++ b/scripts/object/building/military/outpost_cloning_facility_s03.py @@ -1,4 +1,20 @@ import sys +from java.util import Vector +from resources.common import SpawnPoint def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(3) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-0.134662), float(0.125265), float(-5.80915), float(-0.0238176), float(0.998716)) + + spawnPoints = Vector() + spawnPoints.add(SpawnPoint(4.42891, 0.125266, -3.717, 0.712528, -0.701643, 5)) + spawnPoints.add(SpawnPoint(4.45469, 0.125266, 1.18026, 0.72696, -0.68668, 4)) + spawnPoints.add(SpawnPoint(4.73, 0.125266, 3.02662, 0.717716, -0.696336, 4)) + + object.setAttachment('spawnPoints', spawnPoints) + + return + \ No newline at end of file diff --git a/scripts/object/building/naboo/cloning_facility_naboo.py b/scripts/object/building/naboo/cloning_facility_naboo.py index ccad8904..487b8163 100644 --- a/scripts/object/building/naboo/cloning_facility_naboo.py +++ b/scripts/object/building/naboo/cloning_facility_naboo.py @@ -1,4 +1,25 @@ import sys +from java.util import Vector +from resources.common import SpawnPoint def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(2) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(1), float(-0.05), float(2.5), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(1), float(-0.05), float(-1.35), float(1), float(0)) + + spawnPoints = Vector() + spawnPoints.add(SpawnPoint(-16.6514, -4.29167, -10.4976, 0.709453, 0.704753, 4)) + spawnPoints.add(SpawnPoint(-16.5965, -4.29167, -14.1652, 0.721346, 0.692575, 4)) + spawnPoints.add(SpawnPoint(16.5771, -4.29167, -14.2091, 0.71195, -0.702231, 4)) + spawnPoints.add(SpawnPoint(16.6876, -4.29167, -10.5391, -0.6972, 0.716877, 4)) + spawnPoints.add(SpawnPoint(6.32992, -4.79167, 0.613332, 0.999992, 0.00405023, 4)) + spawnPoints.add(SpawnPoint(1.58067, -4.79167, 0.582775, 0.989691, 0.0143216, 4)) + spawnPoints.add(SpawnPoint(-2.84125, -4.79167, 0.657588, -0.0356012, 0.999366, 4)) + + object.setAttachment('spawnPoints', spawnPoints) + + return + \ No newline at end of file diff --git a/scripts/object/building/naboo/starport_naboo.py b/scripts/object/building/naboo/starport_naboo.py index ccad8904..e71c9121 100644 --- a/scripts/object/building/naboo/starport_naboo.py +++ b/scripts/object/building/naboo/starport_naboo.py @@ -1,4 +1,15 @@ import sys def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(4) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(3.1), float(0.6), float(49), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-2.7), float(0.6), float(49), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) + + core.mapService.addLocation(object.getPlanet(), 'Starport', object.getPosition().x, object.getPosition().z, 15, 0, 0) + return + \ No newline at end of file diff --git a/scripts/object/building/player/city/cantina_corellia.py b/scripts/object/building/player/city/cantina_corellia.py index ccad8904..f1033f3f 100644 --- a/scripts/object/building/player/city/cantina_corellia.py +++ b/scripts/object/building/player/city/cantina_corellia.py @@ -1,4 +1,12 @@ import sys def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(4) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/terminal_player_structure.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.28604), float(-2.110639), float(-6.443224), float(0.707107), float(0.707107)) + stcSvc.spawnObject('object/tangible/terminal/terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.57625), float(-2.5), float(3.1), float(0.707107), float(0.707107)) + + return + \ No newline at end of file diff --git a/scripts/object/building/player/city/cloning_corellia.py b/scripts/object/building/player/city/cloning_corellia.py index ccad8904..b5143164 100644 --- a/scripts/object/building/player/city/cloning_corellia.py +++ b/scripts/object/building/player/city/cloning_corellia.py @@ -1,4 +1,19 @@ import sys +from java.util import Vector +from resources.common import SpawnPoint def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(4) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_player_structure.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.28604), float(-2.110639), float(-6.443224), float(0.707107), float(0.707107)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.57625), float(-2.5), float(3.1), float(0.707107), float(0.707107)) + + spawnPoints = Vector() + spawnPoints.add(SpawnPoint(-9.7, -1.2, -6.2, 0, 1, 4)) + + object.setAttachment('spawnPoints', spawnPoints) + + return + \ No newline at end of file diff --git a/scripts/object/building/player/city/cloning_naboo.py b/scripts/object/building/player/city/cloning_naboo.py index ccad8904..bd659fb3 100644 --- a/scripts/object/building/player/city/cloning_naboo.py +++ b/scripts/object/building/player/city/cloning_naboo.py @@ -1,4 +1,19 @@ import sys +from java.util import Vector +from resources.common import SpawnPoint def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(4) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_player_structure.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.28604), float(-2.110639), float(-6.443224), float(0.707107), float(0.707107)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.57625), float(-2.5), float(3.1), float(0.707107), float(0.707107)) + + spawnPoints = Vector() + spawnPoints.add(SpawnPoint(-9.6, -1.2, -6.4, 0, 1, 4)) + + object.setAttachment('spawnPoints', spawnPoints) + + return + \ No newline at end of file diff --git a/scripts/object/building/player/city/cloning_tatooine.py b/scripts/object/building/player/city/cloning_tatooine.py index ccad8904..1958ef0d 100644 --- a/scripts/object/building/player/city/cloning_tatooine.py +++ b/scripts/object/building/player/city/cloning_tatooine.py @@ -1,4 +1,19 @@ import sys +from java.util import Vector +from resources.common import SpawnPoint def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(4) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_player_structure.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.28604), float(-2.110639), float(-6.443224), float(0.707107), float(0.707107)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.57625), float(-2.5), float(3.1), float(0.707107), float(0.707107)) + + spawnPoints = Vector() + spawnPoints.add(SpawnPoint(-9.8, -1.2, -6.6, 0, 1, 4)) + + object.setAttachment('spawnPoints', spawnPoints) + + return + \ No newline at end of file diff --git a/scripts/object/building/tatooine/cloning_facility_tatooine.py b/scripts/object/building/tatooine/cloning_facility_tatooine.py index 10c20b1b..7673e657 100644 --- a/scripts/object/building/tatooine/cloning_facility_tatooine.py +++ b/scripts/object/building/tatooine/cloning_facility_tatooine.py @@ -1,7 +1,27 @@ import sys +from java.util import Vector +from resources.common import SpawnPoint def setup(core, object): + stcSvc = core.staticService + cell = object.getCellByCellNumber(2) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(1), float(-0.05), float(2.5), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(1), float(-0.05), float(-1.35), float(1), float(0)) + + spawnPoints = Vector() + spawnPoints.add(SpawnPoint(-16.6514, -4.29167, -10.4976, 0.709453, 0.704753, 4)) + spawnPoints.add(SpawnPoint(-16.5965, -4.29167, -14.1652, 0.721346, 0.692575, 4)) + spawnPoints.add(SpawnPoint(16.5771, -4.29167, -14.2091, 0.71195, -0.702231, 4)) + spawnPoints.add(SpawnPoint(16.6876, -4.29167, -10.5391, -0.6972, 0.716877, 4)) + spawnPoints.add(SpawnPoint(6.32992, -4.79167, 0.613332, 0.999992, 0.00405023, 4)) + spawnPoints.add(SpawnPoint(1.58067, -4.79167, 1.00877, 0.989691, -0.143217, 4)) + spawnPoints.add(SpawnPoint(-2.84125, -4.79167, 1.26153, -0.0356012, 0.999366, 4)) + + object.setAttachment('spawnPoints', spawnPoints) core.mapService.addLocation(object.getPlanet(), 'Cloning Facility', object.getPosition().x, object.getPosition().z, 5, 0, 0) + return \ No newline at end of file diff --git a/scripts/object/building/tatooine/cloning_facility_tatooine_small.py b/scripts/object/building/tatooine/cloning_facility_tatooine_small.py index ccad8904..2994a68a 100644 --- a/scripts/object/building/tatooine/cloning_facility_tatooine_small.py +++ b/scripts/object/building/tatooine/cloning_facility_tatooine_small.py @@ -1,4 +1,18 @@ import sys +from java.util import Vector +from resources.common import SpawnPoint def setup(core, object): - return \ No newline at end of file + stcSvc = core.staticService + cell = object.getCellByCellNumber(10) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_cloning.iff', object.getPlanet().getName(), cell.getObjectID(), float(-0.42), float(-0.38), float(-0.4), float(1), float(0)) + + spawnPoints = Vector() + spawnPoints.add(SpawnPoint(0.445015, 0.271775, 1.39199, 0.707038, 0.707176, 9)) + + object.setAttachment('spawnPoints', spawnPoints) + + return + \ No newline at end of file diff --git a/scripts/object/building/tatooine/starport_tatooine.py b/scripts/object/building/tatooine/starport_tatooine.py index 6235a453..e71c9121 100644 --- a/scripts/object/building/tatooine/starport_tatooine.py +++ b/scripts/object/building/tatooine/starport_tatooine.py @@ -1,7 +1,15 @@ import sys def setup(core, object): - + stcSvc = core.staticService + cell = object.getCellByCellNumber(4) + + if cell: + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(3.1), float(0.6), float(49), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-2.7), float(0.6), float(49), float(0), float(1)) + stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', object.getPlanet().getName(), cell.getObjectID(), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) + core.mapService.addLocation(object.getPlanet(), 'Starport', object.getPosition().x, object.getPosition().z, 15, 0, 0) return \ No newline at end of file diff --git a/scripts/object/tangible/wearables/bracelet/bracelet_s03_r.py b/scripts/object/tangible/wearables/bracelet/bracelet_s03_r.py index ccad8904..bc8f4ae5 100644 --- a/scripts/object/tangible/wearables/bracelet/bracelet_s03_r.py +++ b/scripts/object/tangible/wearables/bracelet/bracelet_s03_r.py @@ -1,4 +1,25 @@ import sys def setup(core, object): + return + +def equip(core, actor, object): + + + ##Heroism + if object.getStfName() == ('item_bracelet_r_set_hero_01_01'): + core.skillModService.addSkillMod(actor, 'strength_modified', 30) + core.skillModService.addSkillMod(actor, 'precision_modified', 30) + core.skillModService.addSkillMod(actor, 'luck_modified', 30) + return + return + +def unequip(core, actor, object): + + ##Heroism + if object.getStfName() == ('item_bracelet_r_set_hero_01_01'): + core.skillModService.deductSkillMod(actor, 'strength_modified', 30) + core.skillModService.deductSkillMod(actor, 'precision_modified', 30) + core.skillModService.deductSkillMod(actor, 'luck_modified', 30) + return return \ No newline at end of file diff --git a/scripts/object/tangible/wearables/necklace/necklace_s01.py b/scripts/object/tangible/wearables/necklace/necklace_s01.py index ccad8904..767c6be7 100644 --- a/scripts/object/tangible/wearables/necklace/necklace_s01.py +++ b/scripts/object/tangible/wearables/necklace/necklace_s01.py @@ -1,4 +1,11 @@ import sys def setup(core, object): - return \ No newline at end of file + return + +def equip(core, actor, target): + return + +def unequip(core, actor, target): + return + diff --git a/scripts/object/tangible/wearables/necklace/necklace_s10.py b/scripts/object/tangible/wearables/necklace/necklace_s10.py index ccad8904..c55ced68 100644 --- a/scripts/object/tangible/wearables/necklace/necklace_s10.py +++ b/scripts/object/tangible/wearables/necklace/necklace_s10.py @@ -1,4 +1,25 @@ import sys def setup(core, object): + return + +def equip(core, actor, object): + + + ##Heroism + if object.getStfName() == ('item_necklace_set_hero_01_01'): + core.skillModService.addSkillMod(actor, 'strength_modified', 30) + core.skillModService.addSkillMod(actor, 'precision_modified', 30) + core.skillModService.addSkillMod(actor, 'luck_modified', 30) + return + return + +def unequip(core, actor, object): + + ##Heroism + if object.getStfName() == ('item_necklace_set_hero_01_01'): + core.skillModService.deductSkillMod(actor, 'strength_modified', 30) + core.skillModService.deductSkillMod(actor, 'precision_modified', 30) + core.skillModService.deductSkillMod(actor, 'luck_modified', 30) + return return \ No newline at end of file diff --git a/scripts/object/tangible/wearables/robe/robe_jedi_dark_s05.py b/scripts/object/tangible/wearables/robe/robe_jedi_dark_s05.py index ccad8904..8ef0b4ac 100644 --- a/scripts/object/tangible/wearables/robe/robe_jedi_dark_s05.py +++ b/scripts/object/tangible/wearables/robe/robe_jedi_dark_s05.py @@ -1,4 +1,31 @@ import sys def setup(core, object): - return \ No newline at end of file + return + +def equip(core, actor, target): + core.skillModService.addSkillMod(actor, 'constitution_modified', 250) + core.skillModService.addSkillMod(actor, 'precision_modified', 250) + core.skillModService.addSkillMod(actor, 'luck_modified', 250) + + Buff = actor.getBuffByName('proc_old_dark_jedi_gift') + if actor.getBuffList().contains(Buff): + core.buffService.removeBuffFromCreature(actor, Buff) + return + + if actor: + core.buffService.addBuffToCreature(actor, 'proc_old_dark_jedi_gift') + return + + +def unequip(core, actor, target): + core.skillModService.deductSkillMod(actor, 'constitution_modified', 250) + core.skillModService.deductSkillMod(actor, 'precision_modified', 250) + core.skillModService.deductSkillMod(actor, 'luck_modified', 250) + + Buff = actor.getBuffByName('proc_old_dark_jedi_gift') + if actor.getBuffList().contains(Buff): + core.buffService.removeBuffFromCreature(actor, Buff) + return + return + diff --git a/scripts/skillMods/expertise_stance.py b/scripts/skillMods/expertise_stance.py new file mode 100644 index 00000000..ee7769e2 --- /dev/null +++ b/scripts/skillMods/expertise_stance.py @@ -0,0 +1,10 @@ +import sys + +def add(core, actor, name, base): + actor.addSkillMod(name, base) + return + +def deduct(core, actor, name, base): + actor.deductSkillMod(name, base) + return + \ No newline at end of file diff --git a/scripts/static_map_locations.py b/scripts/static_map_locations.py index dad930c8..098d0ebf 100644 --- a/scripts/static_map_locations.py +++ b/scripts/static_map_locations.py @@ -66,8 +66,8 @@ def nabooLocations(core, planet): mapService.addLocation(planet, 'Theed', -5488, 4380, 17, 0, 0) mapService.addLocation(planet, 'Keren', 1888, 2700, 17, 0, 0) - mapService.addLocation(planet, 'Moeina', 4836, -4830.5, 17, 0, 0) - mapService.addLocation(planet, 'Deeja Park', -4686, -1375, 17, 0, 0) + mapService.addLocation(planet, 'Moenia', 4836, -4830.5, 17, 0, 0) + mapService.addLocation(planet, 'Deeja Peek', -4686, -1375, 17, 0, 0) mapService.addLocation(planet, 'Kaadara', 5288, 6687, 17, 0, 0) def roriLocations(core, planet): @@ -78,7 +78,7 @@ def roriLocations(core, planet): mapService.addLocation(planet, 'Narmle', -5140, -2368, 17, 0, 0) mapService.addLocation(planet, 'Restuss', 5318, 5680, 17, 0, 0) - mapService.addLocation(planet, 'a Rebel outpost', 3677, -6447, 17, 0, 0) + mapService.addLocation(planet, 'Rebel outpost', 3677, -6447, 17, 0, 0) def endorLocations(core, planet): @@ -96,7 +96,7 @@ def talusLocations(core, planet): mapService.addLocation(planet, 'Dearic', 422, -3004, 17, 0, 0) mapService.addLocation(planet, 'Nashal', 4163, 5220, 17, 0, 0) - mapService.addLocation(planet, 'an Imperial outpost', -2178, 2300, 17, 0, 0) + mapService.addLocation(planet, 'Imperial outpost', -2178, 2300, 17, 0, 0) def yavin4Locations(core, planet): @@ -113,9 +113,9 @@ def dantooineLocations(core, planet): # Cities - mapService.addLocation(planet, 'a mining outpost', -640, 2486, 17, 0, 0) - mapService.addLocation(planet, 'a pirate outpost', 1588, -6399, 17, 0, 0) - mapService.addLocation(planet, 'an Imperial outpost', -4224, -2400, 17, 0, 0) + mapService.addLocation(planet, 'Mining outpost', -640, 2486, 17, 0, 0) + mapService.addLocation(planet, 'Pirate outpost', 1588, -6399, 17, 0, 0) + mapService.addLocation(planet, 'Imperial outpost', -4224, -2400, 17, 0, 0) def dathomirLocations(core, planet): @@ -134,6 +134,6 @@ def lokLocations(core, planet): # Cities mapService.addLocation(planet, 'Nym\'s Stronghold', 440, 5029, 17, 0, 0) - mapService.addLocation(planet, 'an Imperial outpost', -1920, -3084, 17, 0, 0) + mapService.addLocation(planet, 'Imperial outpost', -1920, -3084, 17, 0, 0) \ No newline at end of file diff --git a/scripts/static_spawns/naboo.py b/scripts/static_spawns/naboo.py index 91c3c44b..ac5d19ca 100644 --- a/scripts/static_spawns/naboo.py +++ b/scripts/static_spawns/naboo.py @@ -24,18 +24,6 @@ def addPlanetSpawns(core, planet): stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(0), float(2028.5), float(19.6), float(2515.6), float(-0.710457), float(0.703739)) # keren shuttleport b stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(0), float(5339.3), float(327.6), float(-1586.7), float(-0.710457), float(0.703739)) # deeja peek shuttleport stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(0), float(4969.4), float(4.4), float(-4902.6), float(-0.710457), float(0.703739)) # moenia shuttleport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(1741539), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) # kaadara starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(1741539), float(3.1), float(0.6), float(49), float(0), float(1)) # kaadara starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(1741539), float(-2.7), float(0.6), float(49), float(0), float(1)) # kaadara starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(1741539), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) # kaadara starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(2125382), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) # keren starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(2125382), float(3.1), float(0.6), float(49), float(0), float(1)) # keren starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(2125382), float(-2.7), float(0.6), float(49), float(0), float(1)) # keren starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(2125382), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) # keren starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(4215410), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) # moenia starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(4215410), float(3.1), float(0.6), float(49), float(0), float(1)) # moenia starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(4215410), float(-2.7), float(0.6), float(49), float(0), float(1)) # moenia starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'naboo', long(4215410), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) # moenia starport diff --git a/scripts/static_spawns/rori.py b/scripts/static_spawns/rori.py index 4b876f94..0ebd4454 100644 --- a/scripts/static_spawns/rori.py +++ b/scripts/static_spawns/rori.py @@ -11,10 +11,6 @@ def addPlanetSpawns(core, planet): stcSvc.spawnObject('object/tangible/travel/ticket_collector/shared_ticket_collector.iff', 'rori', long(0), float(-5257.2), float(81.3), float(-2150.3), float(-0.924076), float(0.382209)) # narmle shuttleport stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'rori', long(0), float(-5243), float(81.3), float(-2163.5), float(-0.924076), float(0.382209)) # narmle shuttleport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'rori', long(4635437), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) # narmle starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'rori', long(4635437), float(3.1), float(0.6), float(49), float(0), float(1)) # narmle starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'rori', long(4635437), float(-2.7), float(0.6), float(49), float(0), float(1)) # narmle starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'rori', long(4635437), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) # narmle starport stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'rori', long(4505530), float(-3.5), float(0.1), float(-17.5), float(-0.69182), float(0.72207)) # rebel outpost diff --git a/scripts/static_spawns/tatooine.py b/scripts/static_spawns/tatooine.py index 69f27bdd..4b3981c7 100644 --- a/scripts/static_spawns/tatooine.py +++ b/scripts/static_spawns/tatooine.py @@ -30,24 +30,5 @@ def addPlanetSpawns(core, planet): stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(0), float(1739), float(7.6), float(3192.1), float(1), float(0)) # mos entha shuttleport b stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(0), float(3418.4), float(5.6), float(-4659.3), float(-0.485545), float(0.874212)) # mos eisley shuttleport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(1106372), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) # mos eisley starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(1106372), float(3.1), float(0.6), float(49), float(0), float(1)) # mos eisley starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(1106372), float(-2.7), float(0.6), float(49), float(0), float(1)) # mos eisley starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(1106372), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) # mos eisley starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(1026828), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) # bestine starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(1026828), float(3.1), float(0.6), float(49), float(0), float(1)) # bestine starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(1026828), float(-2.7), float(0.6), float(49), float(0), float(1)) # bestine starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(1026828), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) # bestine starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(1261655), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) # mos espa starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(1261655), float(3.1), float(0.6), float(49), float(0), float(1)) # mos espa starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(1261655), float(-2.7), float(0.6), float(49), float(0), float(1)) # mos espa starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(1261655), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) # mos espa starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(4005520), float(11.5), float(0.6), float(51.3), float(0.195405), float(-0.980722)) # mos entha starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(4005520), float(3.1), float(0.6), float(49), float(0), float(1)) # mos entha starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(4005520), float(-2.7), float(0.6), float(49), float(0), float(1)) # mos entha starport - stcSvc.spawnObject('object/tangible/terminal/shared_terminal_travel.iff', 'tatooine', long(4005520), float(-13.2), float(0.6), float(51.3), float(-0.195405), float(-0.980722)) # mos entha starport - - - - - return \ No newline at end of file + return + \ No newline at end of file diff --git a/src/main/NGECore.java b/src/main/NGECore.java index 4077409c..2a7fc4e0 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -198,6 +198,7 @@ public class NGECore { zoneServer = new MINAServer(zoneDispatch, config.getInt("ZONE.PORT")); zoneServer.start(); + staticService = new StaticService(this); // Planets terrainService.addPlanet(1, "tatooine", "terrain/tatooine.trn", true); @@ -219,7 +220,6 @@ public class NGECore { zoneDispatch.addService(simulationService); // Static Spawns - staticService = new StaticService(this); staticService.spawnStatics(); diff --git a/src/protocol/swg/PlayClientEffectLocMessage.java b/src/protocol/swg/PlayClientEffectLocMessage.java new file mode 100644 index 00000000..fd71b8a7 --- /dev/null +++ b/src/protocol/swg/PlayClientEffectLocMessage.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package protocol.swg; + +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import engine.resources.scene.Point3D; + +public class PlayClientEffectLocMessage extends SWGMessage { + + private String effectFile; + private String planet; + private Point3D position; + + public PlayClientEffectLocMessage(String effectFile, String planet, Point3D position) { + + this.effectFile = effectFile; + this.planet = planet; + this.position = position; + + } + + @Override + public IoBuffer serialize() { + + IoBuffer result = IoBuffer.allocate(36 + effectFile.length() + planet.length()).order(ByteOrder.LITTLE_ENDIAN); + + result.putShort((short) 9); + result.putInt(0x02949E74); + result.put(getAsciiString(effectFile)); + result.put(getAsciiString(planet)); + result.putFloat(position.x); + result.putFloat(position.y); + result.putFloat(position.z); + result.putLong(0); + result.putInt(0); // unks seem to be always 0 + result.putShort((short) 0); + + return result.flip(); + + } + + @Override + public void deserialize(IoBuffer data) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/protocol/swg/UpdatePVPStatusMessage.java b/src/protocol/swg/UpdatePVPStatusMessage.java index c5704b61..3af8b527 100644 --- a/src/protocol/swg/UpdatePVPStatusMessage.java +++ b/src/protocol/swg/UpdatePVPStatusMessage.java @@ -25,6 +25,8 @@ import java.nio.ByteOrder; import org.apache.mina.core.buffer.IoBuffer; +import engine.resources.common.CRC; + import protocol.swg.SWGMessage; public class UpdatePVPStatusMessage extends SWGMessage { @@ -37,6 +39,13 @@ public class UpdatePVPStatusMessage extends SWGMessage { this.objectId = objectId; } + public UpdatePVPStatusMessage(long objectId, int pvpStatus, String faction) { + this.objectId = objectId; + this.pvpStatus = pvpStatus; + this.faction = CRC.StringtoCRC(faction); + } + + public void deserialize(IoBuffer data) { } diff --git a/src/protocol/swg/objectControllerObjects/CombatSpam.java b/src/protocol/swg/objectControllerObjects/CombatSpam.java index f83d7744..75eaf9cd 100644 --- a/src/protocol/swg/objectControllerObjects/CombatSpam.java +++ b/src/protocol/swg/objectControllerObjects/CombatSpam.java @@ -101,7 +101,8 @@ public class CombatSpam extends ObjControllerObject{ result.putInt(0x20); // unk result.putInt(0); // unk result.putInt(0); // unk - result.putInt(armorAbsorbed); // damage absorbed by armor + //result.putInt(armorAbsorbed); // damage absorbed by armor + result.putInt(damage); result.putInt(damage); // total damage done after armor without elemental result.putInt(0); // punishing blow for all values result.putInt(0); // unk diff --git a/src/resources/common/SpawnPoint.java b/src/resources/common/SpawnPoint.java new file mode 100644 index 00000000..0053d5d3 --- /dev/null +++ b/src/resources/common/SpawnPoint.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.common; + +import com.sleepycat.persist.model.Persistent; + +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; + +@Persistent +public class SpawnPoint { + + private Point3D position; + private Quaternion orientation; + private int cellNumber; + + public SpawnPoint() { } + + public SpawnPoint(Point3D position, Quaternion orientation) { + this.setPosition(position); + this.setOrientation(orientation); + } + + public SpawnPoint(float x, float y, float z, float oY, float oW) { + this.setPosition(new Point3D(x, y, z)); + this.setOrientation(new Quaternion(oW, 0, oY, 0)); + } + + public SpawnPoint(float x, float y, float z, float oY, float oW, int cellNumber) { + this.setPosition(new Point3D(x, y, z)); + this.setOrientation(new Quaternion(oW, 0, oY, 0)); + this.setCellNumber(cellNumber); + } + + public Point3D getPosition() { + return position; + } + + public void setPosition(Point3D position) { + this.position = position; + } + + public Quaternion getOrientation() { + return orientation; + } + + public void setOrientation(Quaternion orientation) { + this.orientation = orientation; + } + + public int getCellNumber() { + return cellNumber; + } + + public void setCellNumber(int cellNumber) { + this.cellNumber = cellNumber; + } + +} diff --git a/src/resources/objects/Buff.java b/src/resources/objects/Buff.java index bcad87ef..20a2dc73 100644 --- a/src/resources/objects/Buff.java +++ b/src/resources/objects/Buff.java @@ -33,11 +33,13 @@ import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; import engine.resources.common.CRC; -@Persistent(version=3) +@Persistent(version=5) public class Buff implements IListObject { @NotPersistent private SimpleBufferAllocator bufferPool = new SimpleBufferAllocator(); + private String group1; + private int priority; private float duration; private String buffName; private long ownerId; @@ -54,6 +56,7 @@ public class Buff implements IListObject { private boolean decayOnPvPDeath; private long startTime; private int totalPlayTime; + private byte decayCounter; public Buff(String buffName, long ownerId) { @@ -70,6 +73,8 @@ public class Buff implements IListObject { if(visitor.getObject(i, 0) != null) if(((String) visitor.getObject(i, 0)).equalsIgnoreCase(buffName)) { + group1 = (String) visitor.getObject(i, 1); + priority = (int) visitor.getObject(i, 4); duration = (Float) visitor.getObject(i, 6); effect1Name = (String) visitor.getObject(i, 7); effect1Value = (Float) visitor.getObject(i, 8); @@ -111,15 +116,15 @@ public class Buff implements IListObject { IoBuffer buffer = bufferPool.allocate(28, false).order(ByteOrder.LITTLE_ENDIAN); - buffer.putInt(CRC.StringtoCRC(buffName)); + buffer.putInt(CRC.StringtoCRC(buffName.toLowerCase())); if(duration > 0) { buffer.putInt((int) (totalPlayTime + getRemainingDuration())); buffer.putInt(0); buffer.putInt((int) duration); } else { buffer.putInt(-1); + buffer.putInt(0); buffer.putInt(0); - buffer.putInt(-1); } buffer.putLong(ownerId); buffer.putInt(1); // unk @@ -130,6 +135,22 @@ public class Buff implements IListObject { } + public String getGroup1() { + return group1; + } + + public void setGroup1(String group1) { + this.group1 = group1; + } + + public float getPriority() { + return priority; + } + + public void setPriority(int priority) { + this.priority = priority; + } + public float getDuration() { return duration; } @@ -315,7 +336,9 @@ public class Buff implements IListObject { long currentTime = System.currentTimeMillis(); long timeDiff = (currentTime - startTime) / 1000; int remaining = (int) (duration - timeDiff); - System.out.println("Buff remaining: " + remaining); + for(int i = 0; i < decayCounter; i++) { + remaining /= 2; + } return remaining; } @@ -328,4 +351,12 @@ public class Buff implements IListObject { this.totalPlayTime = totalPlayTime; } + public byte getDecayCounter() { + return decayCounter; + } + + public void incDecayCounter(byte decayCounter) { + this.decayCounter++; + } + } diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index c16cf929..a1267703 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -23,9 +23,14 @@ package resources.objects.building; +import java.util.concurrent.atomic.AtomicReference; + +import resources.objects.cell.CellObject; + import com.sleepycat.persist.model.Entity; import engine.clients.Client; +import engine.resources.container.Traverser; import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; @@ -47,6 +52,26 @@ public class BuildingObject extends SWGObject { // TODO Auto-generated method stub } + + public CellObject getCellByCellNumber(final int cellNumber) { + + final AtomicReference ref = new AtomicReference(); + + this.viewChildren(this, true, false, new Traverser() { + + @Override + public void process(SWGObject obj) { + + if(obj instanceof CellObject && ((CellObject) obj).getCellNumber() == cellNumber) + ref.set((CellObject) obj); + + } + + }); + + return ref.get(); + + } } diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index 114b11be..379882b0 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -269,9 +269,9 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.putInt(6); // Max HAM buffer.putInt(0); - buffer.putInt(20000); + buffer.putInt(creature.getMaxHealth()); buffer.putInt(0); - buffer.putInt(12500); + buffer.putInt(creature.getMaxAction()); buffer.putInt(0); buffer.putInt(0x2C01); buffer.putInt(0); @@ -320,7 +320,9 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { } } + buffer.putShort((short) 0); + //buffer.put(getAsciiString("appearance/gungan_m.sat")); buffer.put((byte) 1); if(creature.getBuffList().isEmpty()) { @@ -637,6 +639,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { IoBuffer buffer = bufferPool.allocate(15, false).order(ByteOrder.LITTLE_ENDIAN); buffer.putInt(1); buffer.putInt(creature.getHamListCounter()); + System.out.println("HAM list counter: " + creature.getHamListCounter()); buffer.put((byte) 2); buffer.putShort((short) 0); buffer.putInt(health); @@ -655,6 +658,7 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { IoBuffer buffer = bufferPool.allocate(15, false).order(ByteOrder.LITTLE_ENDIAN); buffer.putInt(1); buffer.putInt(creature.getHamListCounter()); + System.out.println("HAM list counter: " + creature.getHamListCounter()); buffer.put((byte) 2); buffer.putShort((short) 2); buffer.putInt(action); @@ -738,6 +742,26 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { } + public IoBuffer buildUpdateBuffDelta(Buff buff) { + + CreatureObject creature = (CreatureObject) object; + PlayerObject player = (PlayerObject) creature.getSlottedObject("ghost"); + + IoBuffer buffer = bufferPool.allocate(37, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.putInt(1); + buffer.putInt(creature.getBuffListCounter()); + buff.setTotalPlayTime((int) (player.getTotalPlayTime() + (System.currentTimeMillis() - player.getLastPlayTimeUpdate()) / 1000)); + buffer.put((byte) 2); + buffer.put(buff.getBytes()); + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x1A, buffer, size + 4); + + return buffer; + + } + + public IoBuffer buildGroupInviteDelta(long inviteSenderId, long inviteCounter, String leaderName) { IoBuffer buffer = bufferPool.allocate(18 + leaderName.length(), false).order(ByteOrder.LITTLE_ENDIAN); @@ -868,6 +892,54 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { } + public IoBuffer buildResetHAMListDelta() { + + CreatureObject creature = (CreatureObject) object; + + IoBuffer buffer = bufferPool.allocate(35, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putInt(1); + buffer.putInt(creature.getHamListCounter()); + buffer.put((byte) 3); + buffer.putShort((short) 6); + buffer.putInt(creature.getHealth()); + buffer.putInt(0); + buffer.putInt(creature.getAction()); + buffer.putInt(0); + buffer.putInt(0x2C01); + buffer.putInt(0); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x15, buffer, size + 4); + + return buffer; + + } + + public IoBuffer buildUpdateHAMListDelta() { + + CreatureObject creature = (CreatureObject) object; + + IoBuffer buffer = bufferPool.allocate(22, false).order(ByteOrder.LITTLE_ENDIAN); + + buffer.putInt(2); + buffer.putInt(creature.getHamListCounter()); + buffer.put((byte) 2); + buffer.putShort((short) 0); + buffer.putInt(creature.getHealth()); + buffer.put((byte) 2); + buffer.putShort((short) 2); + buffer.putInt(creature.getAction()); + + int size = buffer.position(); + buffer.flip(); + buffer = createDelta("CREO", (byte) 6, (short) 1, (short) 0x15, buffer, size + 4); + + return buffer; + + } + @Override public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { // TODO Auto-generated method stub diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index e3289f15..31608c77 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -134,7 +134,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { // non-baseline vars @NotPersistent - private List duelList = Collections.synchronizedList(new ArrayList()); + private List duelList = Collections.synchronizedList(new ArrayList()); @NotPersistent private CreatureMessageBuilder messageBuilder; @@ -820,7 +820,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { return appearanceEquipmentList; } - public List getDuelList() { + public List getDuelList() { return duelList; } @@ -912,15 +912,43 @@ public class CreatureObject extends TangibleObject implements IPersistent { } public void setHealth(int health) { + + synchronized(objectMutex) { + if(getPosture() == 13) { + if(health > maxHealth) + health = maxHealth; + this.health = health; + notifyObservers(messageBuilder.buildUpdateHAMListDelta(), true); + setPosture((byte) 0); + setTurnRadius(1); + setSpeedMultiplierBase(1); + return; + } + } + IoBuffer delta; + // IoBuffer delta2; + int counter; synchronized(objectMutex) { if(health > maxHealth) health = maxHealth; this.health = health; + counter = getHamListCounter() + 1; setHamListCounter(getHamListCounter() + 1); - delta = messageBuilder.buildHealthDelta(health); + delta = messageBuilder.buildUpdateHAMListDelta(); + /*if(health == 1) + delta2 = messageBuilder.buildHealthDelta(0); + else + delta2 = delta;*/ + + notifyObservers(delta, true); + + /*if(getClient() != null) + getClient().getSession().write(delta2);*/ } - notifyObservers(delta, true); + if(counter != getHamListCounter()) + System.out.println("test"); + } public int getAction() { @@ -931,14 +959,18 @@ public class CreatureObject extends TangibleObject implements IPersistent { public void setAction(int action) { IoBuffer delta; + int counter; synchronized(objectMutex) { if(action > maxAction) action = maxAction; this.action = action; + counter = getHamListCounter() + 1; setHamListCounter(getHamListCounter() + 1); - delta = messageBuilder.buildActionDelta(action); + delta = messageBuilder.buildUpdateHAMListDelta(); + notifyObservers(delta, true); } - notifyObservers(delta, true); + if(counter != getHamListCounter()) + System.out.println("test"); } public int getHamListCounter() { @@ -1041,6 +1073,13 @@ public class CreatureObject extends TangibleObject implements IPersistent { getClient().getSession().write(messageBuilder.buildGroupInviteDelta(getInviteSenderId(), getInviteCounter(), getInviteSenderName())); } + + public void resetHAMList() { + synchronized(objectMutex) { + setHamListCounter(getHamListCounter() + 1); + notifyObservers(messageBuilder.buildResetHAMListDelta(), true); + } + } } diff --git a/src/resources/objects/staticobject/StaticMessageBuilder.java b/src/resources/objects/staticobject/StaticMessageBuilder.java index 7271a915..be3afa20 100644 --- a/src/resources/objects/staticobject/StaticMessageBuilder.java +++ b/src/resources/objects/staticobject/StaticMessageBuilder.java @@ -21,6 +21,73 @@ ******************************************************************************/ package resources.objects.staticobject; -public class StaticMessageBuilder { +import java.nio.ByteOrder; + +import org.apache.mina.core.buffer.IoBuffer; + +import resources.objects.ObjectMessageBuilder; +import resources.objects.tangible.TangibleObject; + +public class StaticMessageBuilder extends ObjectMessageBuilder { + + public StaticMessageBuilder(StaticObject staticObject) { + setObject(staticObject); + } + + + public IoBuffer buildBaseline3() { + + IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + + buffer.putShort((short) 4); + buffer.putInt(0); + + buffer.put(getAsciiString(object.getStfFilename())); + buffer.putInt(0); + buffer.put(getAsciiString(object.getStfName())); + buffer.putInt(0); + buffer.putInt(0xFF); + + int size = buffer.position(); + buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); + + buffer.flip(); + buffer = createBaseline("STAO", (byte) 3, buffer, size); + + return buffer; + } + + public IoBuffer buildBaseline6() { + + IoBuffer buffer = bufferPool.allocate(100, false).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + buffer.putShort((short) 2); + buffer.putInt(0x92); + buffer.put(getAsciiString(object.getDetailFilename())); + buffer.putInt(0); + buffer.put(getAsciiString(object.getDetailName())); + + int size = buffer.position(); + buffer = bufferPool.allocate(size, false).put(buffer.array(), 0, size); + + buffer.flip(); + buffer = createBaseline("STAO", (byte) 6, buffer, size); + + return buffer; + } + + @Override + public void sendListDelta(byte viewType, short updateType, IoBuffer buffer) { + // TODO Auto-generated method stub + + } + + @Override + public void sendBaselines() { + // TODO Auto-generated method stub + + } + } diff --git a/src/resources/objects/staticobject/StaticObject.java b/src/resources/objects/staticobject/StaticObject.java index 27c97db5..1bb2380c 100644 --- a/src/resources/objects/staticobject/StaticObject.java +++ b/src/resources/objects/staticobject/StaticObject.java @@ -21,25 +21,43 @@ ******************************************************************************/ package resources.objects.staticobject; +import com.sleepycat.persist.model.NotPersistent; +import com.sleepycat.persist.model.Persistent; + import engine.clients.Client; import engine.resources.objects.SWGObject; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; +@Persistent public class StaticObject extends SWGObject { + @NotPersistent + private StaticMessageBuilder messageBuilder; + public StaticObject() { super(); + messageBuilder = new StaticMessageBuilder(this); } public StaticObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) { super(objectID, planet, position, orientation, Template); + messageBuilder = new StaticMessageBuilder(this); } @Override - public void sendBaselines(Client client) { - // TODO Auto-generated method stub + public void sendBaselines(Client destination) { + + + if(destination == null || destination.getSession() == null) { + System.out.println("NULL destination"); + return; + } + destination.getSession().write(messageBuilder.buildBaseline3()); + destination.getSession().write(messageBuilder.buildBaseline6()); + + } } diff --git a/src/services/BuffService.java b/src/services/BuffService.java index aab4120d..5673e37a 100644 --- a/src/services/BuffService.java +++ b/src/services/BuffService.java @@ -34,6 +34,7 @@ import resources.objects.player.PlayerObject; import main.NGECore; +import engine.resources.common.CRC; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -65,40 +66,54 @@ public class BuffService implements INetworkDispatch { final Buff buff = new Buff(buffName, creature.getObjectID()); buff.setTotalPlayTime(((PlayerObject) creature.getSlottedObject("ghost")).getTotalPlayTime()); - if(creature.getBuffByName(buffName) != null) { + + + for (Buff otherBuff : creature.getBuffList()) { + if (buff.getGroup1().equals(otherBuff.getGroup1())) + if (buff.getPriority() >= otherBuff.getPriority()) { + if (buff.getBuffName().equals(otherBuff.getBuffName())) { + if (otherBuff.getRemainingDuration() > buff.getDuration()) { + return; + } + } + + removeBuffFromCreature(creature, otherBuff); System.out.println("buff removed " + buffName); + break; + } else { + System.out.println("buff not added:" + buffName); + return; + } + } - Buff otherBuff = creature.getBuffByName(buffName); - if(otherBuff.getRemainingDuration() > buff.getDuration()) { - return; - } else { - removeBuffFromCreature(creature, otherBuff); - } - - } - - core.scriptService.callScript("scripts/buffs", "setup", buffName, core, creature, buff); + + core.scriptService.callScript("scripts/buffs/", "setup", buffName, core, creature, buff); creature.addBuff(buff); - scheduler.schedule(new Runnable() { - - @Override - public void run() { - - removeBuffFromCreature(creature, buff); - - } - - }, (long) buff.getDuration(), TimeUnit.SECONDS); - } + if(buff.getDuration() > 0) { + + scheduler.schedule(new Runnable() { + + @Override + public void run() { + + removeBuffFromCreature(creature, buff); + + + } + + }, (long) buff.getDuration(), TimeUnit.SECONDS); + } + + } public void removeBuffFromCreature(CreatureObject creature, Buff buff) { - if(!creature.getBuffList().contains(buff)) - return; - - core.scriptService.callScript("scripts/buffs", "removeBuff", buff.getBuffName(), core, creature, buff); - creature.removeBuff(buff); + if(!creature.getBuffList().contains(buff)) + return; + + core.scriptService.callScript("scripts/buffs/", "removeBuff", buff.getBuffName(), core, creature, buff); + creature.removeBuff(buff); } @@ -108,7 +123,7 @@ public class BuffService implements INetworkDispatch { for(final Buff buff : creature.getBuffList().get().toArray(new Buff[] { })) { - if(buff.getRemainingDuration() > 0) { + if(buff.getRemainingDuration() > 0 && buff.getDuration() > 0) { scheduler.schedule(new Runnable() { @Override diff --git a/src/services/CharacterService.java b/src/services/CharacterService.java index 97f16a06..de94db65 100644 --- a/src/services/CharacterService.java +++ b/src/services/CharacterService.java @@ -264,7 +264,7 @@ public class CharacterService implements INetworkDispatch { object._add(weapon); object.setWeaponId(weapon.getObjectID()); - core.scriptService.callScript("scripts/", "demo", "CreateStartingCharacter", object); + core.scriptService.callScript("scripts/", "demo", "CreateStartingCharacter", core, object); diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index 8fb698af..c592b091 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -22,7 +22,11 @@ package services; import java.nio.ByteOrder; +import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Random; +import java.util.Vector; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -35,12 +39,20 @@ import protocol.swg.ExpertiseRequestMessage; import protocol.swg.ServerTimeMessage; import resources.common.FileUtilities; import resources.common.Opcodes; +import resources.common.SpawnPoint; +import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; +import services.sui.SUIService.ListBoxType; +import services.sui.SUIWindow; +import services.sui.SUIWindow.Trigger; +import services.sui.SUIWindow.SUICallback; import main.NGECore; import engine.clients.Client; +import engine.resources.objects.SWGObject; +import engine.resources.scene.Point3D; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -91,24 +103,37 @@ public class PlayerService implements INetworkDispatch { @Override public void run() { - if(creature.getAction() < creature.getMaxAction()) + if(creature.getAction() < creature.getMaxAction() && creature.getPosture() != 14) creature.setAction(creature.getAction() + 200); } - }, 0, 1, TimeUnit.SECONDS); + }, 0, 1000, TimeUnit.MILLISECONDS); scheduler.scheduleAtFixedRate(new Runnable() { @Override public void run() { - if(creature.getHealth() < creature.getMaxHealth() && creature.getCombatFlag() == 0) + if(creature.getHealth() < creature.getMaxHealth() && creature.getCombatFlag() == 0 && creature.getPosture() != 13 && creature.getPosture() != 14) creature.setHealth(creature.getHealth() + 300); } - }, 0, 1, TimeUnit.SECONDS); + }, 0, 1100, TimeUnit.MILLISECONDS); + + /*scheduler.scheduleAtFixedRate(new Runnable() { + + @Override + public void run() { + + if(creature.getCombatFlag() == 1) + creature.resetHAMList(); + + } + + }, 0, 10, TimeUnit.SECONDS);*/ + } @@ -164,7 +189,65 @@ public class PlayerService implements INetworkDispatch { if(!FileUtilities.doesFileExist("scripts/expertise/" + expertiseBox + ".py")) return; - core.scriptService.callScript("scripts/expertise", "addExpertisePoint", expertiseBox, core, creature); + core.scriptService.callScript("scripts/expertise/", "addExpertisePoint", expertiseBox, core, creature); + + } + + public void sendCloningWindow(CreatureObject creature) { + + //if(creature.getPosture() != 14) + // return; + + List cloners = core.staticService.getCloningFacilitiesByPlanet(creature.getPlanet()); + Map cloneData = new HashMap(); + Point3D position = creature.getWorldPosition(); + + for(SWGObject cloner : cloners) { + + cloneData.put(cloner.getObjectID(), core.mapService.getClosestCityName(cloner) /*+ " (" + String.valueOf(position.getDistance2D(cloner.getPosition())) + "m)"*/); + + } + + final SUIWindow window = core.suiService.createListBox(ListBoxType.LIST_BOX_OK_CANCEL, "@base_player:revive_title", "Select the desired option and click OK.", + cloneData, creature, null, 0); + Vector returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + + // if(((CreatureObject)owner).getPosture() != 14) + // return; + + int index = Integer.parseInt(returnList.get(0)); + + if(window.getObjectIdByIndex(index) == 0 || core.objectService.getObject(window.getObjectIdByIndex(index)) == null) + return; + + + SWGObject cloner = core.objectService.getObject(window.getObjectIdByIndex(index)); + + if(cloner.getAttachment("spawnPoints") == null) + return; + + Vector spawnPoints = (Vector) cloner.getAttachment("spawnPoints"); + + SpawnPoint spawnPoint = spawnPoints.get(new Random().nextInt(spawnPoints.size())); + + handleCloneRequest((CreatureObject) owner, (BuildingObject) cloner, spawnPoint); + + } + + }); + + core.suiService.openSUIWindow(window); + + } + + public void handleCloneRequest(CreatureObject creature, BuildingObject cloner, SpawnPoint spawnPoint) { + } diff --git a/src/services/ScriptService.java b/src/services/ScriptService.java index 6277904a..beac5ff5 100644 --- a/src/services/ScriptService.java +++ b/src/services/ScriptService.java @@ -39,50 +39,66 @@ public class ScriptService { } public void callScript(String path, String module, String method) { - PythonInterpreter interpreter = new PythonInterpreter(); + /*PythonInterpreter interpreter = new PythonInterpreter(); + interpreter.cleanup(); interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method); PyObject func = interpreter.get(method); - func.__call__(Py.java2py(core)); - interpreter.cleanup(); + func.__call__(Py.java2py(core));*/ + PythonInterpreter python = new PythonInterpreter(); + python.execfile(path + module + ".py"); + python.get(method).__call__(); } public void callScript(String path, String module, String method, Object arg1) { - PythonInterpreter interpreter = new PythonInterpreter(); + /*PythonInterpreter interpreter = new PythonInterpreter(); + interpreter.cleanup(); interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method); PyObject func = interpreter.get(method); - func.__call__(Py.java2py(core), Py.java2py(arg1)); - interpreter.cleanup(); + func.__call__(Py.java2py(core), Py.java2py(arg1));*/ + PythonInterpreter python = new PythonInterpreter(); + python.execfile(path + module + ".py"); + python.get(method).__call__(Py.java2py(arg1)); } public void callScript(String path, String method, String module, Object arg1, Object arg2) { - PythonInterpreter interpreter = new PythonInterpreter(); + /*PythonInterpreter interpreter = new PythonInterpreter(); + interpreter.cleanup(); interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method); PyObject func = interpreter.get(method); - func.__call__(Py.java2py(arg1), Py.java2py(arg2)); - interpreter.cleanup(); + func.__call__(Py.java2py(arg1), Py.java2py(arg2));*/ + PythonInterpreter python = new PythonInterpreter(); + python.execfile(path + module + ".py"); + python.get(method).__call__(Py.java2py(arg1), Py.java2py(arg2)); } public void callScript(String path, String method, String module, Object arg1, Object arg2, Object arg3) { - PythonInterpreter interpreter = new PythonInterpreter(); + /*PythonInterpreter interpreter = new PythonInterpreter(); + interpreter.cleanup(); interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method); PyObject func = interpreter.get(method); - func.__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3)); - interpreter.cleanup(); + func.__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3));*/ + PythonInterpreter python = new PythonInterpreter(); + python.execfile(path + module + ".py"); + python.get(method).__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3)); + } public void callScript(String path, String module, String method, Object arg1, Object arg2, Object arg3, Object arg4) { - PythonInterpreter interpreter = new PythonInterpreter(); + /*PythonInterpreter interpreter = new PythonInterpreter(); + interpreter.cleanup(); interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method); PyObject func = interpreter.get(method); - func.__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3), Py.java2py(arg4)); - interpreter.cleanup(); + func.__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3), Py.java2py(arg4));*/ + PythonInterpreter python = new PythonInterpreter(); + python.execfile(path + module + ".py"); + python.get(method).__call__(Py.java2py(arg1), Py.java2py(arg2), Py.java2py(arg3), Py.java2py(arg4)); } public PyObject getMethod(String path, String module, String method) { PythonInterpreter interpreter = new PythonInterpreter(); + interpreter.cleanup(); interpreter.exec("import sys\nsys.path.append('" + path + "')\nfrom " + module + " import " + method); PyObject func = interpreter.get(method); - interpreter.cleanup(); return func; } diff --git a/src/services/SimulationService.java b/src/services/SimulationService.java index 6cfaab36..c6c6bd2e 100644 --- a/src/services/SimulationService.java +++ b/src/services/SimulationService.java @@ -103,12 +103,11 @@ public class SimulationService implements INetworkDispatch { quadTrees.put(terrainService.getPlanetList().get(i).getName(), new QuadTree(-8192, -8192, 8192, 8192)); } - List objectList = core.objectService.getObjectList(); - synchronized(objectList) { - for(SWGObject obj : objectList) { - if(obj.getParentId() == 0 && obj.isInSnapshot()) { - add(obj, obj.getPosition().x, obj.getPosition().z); - } + List objectList = new ArrayList(core.objectService.getObjectList()); + for(SWGObject obj : objectList) { + if(obj.getParentId() == 0 && obj.isInSnapshot()) { + core.objectService.loadServerTemplate(obj); + add(obj, obj.getPosition().x, obj.getPosition().z); } } core.commandService.registerCommand("opencontainer"); @@ -136,6 +135,10 @@ public class SimulationService implements INetworkDispatch { core.commandService.registerCommand("addfriend"); core.commandService.registerCommand("removefriend"); core.commandService.registerCommand("getfriendlist"); + core.commandService.registerCommand("deathblow"); + core.commandService.registerCommand("endduel"); + core.commandService.registerCommand("duel"); + } public void add(SWGObject object, int x, int y) { @@ -254,7 +257,6 @@ public class SimulationService implements INetworkDispatch { for(int i = 0; i < newAwareObjects.size(); i++) { SWGObject obj = newAwareObjects.get(i); if(!updateAwareObjects.contains(obj) && obj != object && !object.getAwareObjects().contains(obj) && obj.getWorldPosition().getDistance2D(newPos) <= 200 && obj.getContainer() != object && obj.isInQuadtree()) { - System.out.println(obj.getTemplate()); object.makeAware(obj); if(obj.getClient() != null) obj.makeAware(object); @@ -546,6 +548,7 @@ public class SimulationService implements INetworkDispatch { } } } + } public void transferToPlanet(SWGObject object, Planet planet, Point3D newPos, Quaternion newOrientation) { @@ -663,7 +666,7 @@ public class SimulationService implements INetworkDispatch { if(object == obj1 || object == obj2) continue; - if(object.getTemplateData().getAttribute("collisionActionBlockFlags") != null) { + if(object.getTemplateData() != null && object.getTemplateData().getAttribute("collisionActionBlockFlags") != null) { int bit = (Integer) object.getTemplateData().getAttribute("collisionActionBlockFlags") & 255; if(bit == (Integer) object.getTemplateData().getAttribute("collisionActionBlockFlags")) continue; diff --git a/src/services/SkillModService.java b/src/services/SkillModService.java index 8a68c282..8e4ec7c4 100644 --- a/src/services/SkillModService.java +++ b/src/services/SkillModService.java @@ -40,13 +40,13 @@ public class SkillModService implements INetworkDispatch { public void addSkillMod(CreatureObject creature, String skillMod, int value) { - core.scriptService.callScript("scripts/skillMods", skillMod, "add", core, creature, skillMod, value); + core.scriptService.callScript("scripts/skillMods/", skillMod, "add", core, creature, skillMod, value); } public void deductSkillMod(CreatureObject creature, String skillMod, int value) { - core.scriptService.callScript("scripts/skillMods", skillMod, "deduct", core, creature, skillMod, value); + core.scriptService.callScript("scripts/skillMods/", skillMod, "deduct", core, creature, skillMod, value); } diff --git a/src/services/StaticService.java b/src/services/StaticService.java index 645b85d1..e4531ba1 100644 --- a/src/services/StaticService.java +++ b/src/services/StaticService.java @@ -21,8 +21,12 @@ ******************************************************************************/ package services; +import java.util.ArrayList; +import java.util.List; import java.util.Map; +import resources.objects.building.BuildingObject; + import main.NGECore; import engine.resources.objects.SWGObject; @@ -58,7 +62,7 @@ public class StaticService implements INetworkDispatch { public void spawnPlanetStaticObjs(String planet) { Planet planetObj = (Planet) core.terrainService.getPlanetByName(planet); - core.scriptService.callScript("scripts/static_spawns", "addPlanetSpawns", planetObj.getName(), core, planetObj); + core.scriptService.callScript("scripts/static_spawns/", "addPlanetSpawns", planetObj.getName(), core, planetObj); System.out.println("Loaded static objs for " + planetObj.getName()); } @@ -95,5 +99,20 @@ public class StaticService implements INetworkDispatch { } } + + public List getCloningFacilitiesByPlanet(Planet planet) { + + List objects = core.simulationService.get(planet, 0, 0, 8300); + List cloners = new ArrayList(); + + for(SWGObject obj : objects) { + if(obj instanceof BuildingObject && (obj.getTemplate().contains("cloning_facility") || obj.getTemplate().contains("cloning_tatooine") || obj.getTemplate().contains("cloning_naboo") || obj.getTemplate().contains("cloning_corellia"))) { + if(!obj.getTemplate().equals("object/building/general/shared_cloning_facility_general.iff")) + cloners.add(obj); + } + } + return cloners; + + } } diff --git a/src/services/combat/CombatCommands.java b/src/services/combat/CombatCommands.java index 2cdb7bd9..1a30be6a 100644 --- a/src/services/combat/CombatCommands.java +++ b/src/services/combat/CombatCommands.java @@ -187,6 +187,8 @@ public class CombatCommands { core.commandService.registerCombatCommand("fs_sh_1"); core.commandService.registerCombatCommand("fs_sh_2"); core.commandService.registerCombatCommand("fs_sh_3"); + core.commandService.registerCommand("fs_buff_def_1_1"); + core.commandService.registerCommand("fs_buff_ca_1"); // Commando diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 87a9f7a8..79adfc10 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -24,28 +24,39 @@ package services.combat; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.ObjControllerMessage; +import protocol.swg.PlayClientEffectLocMessage; +import protocol.swg.UpdatePVPStatusMessage; import protocol.swg.objectControllerObjects.CombatAction; import protocol.swg.objectControllerObjects.CombatSpam; import protocol.swg.objectControllerObjects.CommandEnqueueRemove; import protocol.swg.objectControllerObjects.StartTask; import resources.common.FileUtilities; +import resources.objects.cell.CellObject; import resources.objects.creature.CreatureObject; import resources.objects.tangible.TangibleObject; +import resources.objects.waypoint.WaypointObject; import resources.objects.weapon.WeaponObject; import services.command.CombatCommand; import main.NGECore; import engine.resources.common.CRC; import engine.resources.objects.SWGObject; +import engine.resources.scene.Point3D; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; public class CombatService implements INetworkDispatch { private NGECore core; + private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); public CombatService(NGECore core) { this.core = core; @@ -63,7 +74,7 @@ public class CombatService implements INetworkDispatch { } - public void doCombat(CreatureObject attacker, TangibleObject target, WeaponObject weapon, CombatCommand command, int actionCounter) { + public void doCombat(final CreatureObject attacker, final TangibleObject target, final WeaponObject weapon, final CombatCommand command, final int actionCounter) { if(!applySpecialCost(attacker, weapon, command)) @@ -72,14 +83,82 @@ public class CombatService implements INetworkDispatch { if((command.getAttackType() == 0 || command.getAttackType() == 1 || command.getAttackType() == 3) && !attemptCombat(attacker, target)) return; - // use preRun for delayed effects like officer orbital strike, grenades etc. + /* // use preRun for delayed effects like officer orbital strike, grenades etc. if(FileUtilities.doesFileExist("scripts/commands/combat" + command.getCommandName() + ".py")) - core.scriptService.callScript("scripts/commands/combat", command.getCommandName(), "preRun", core, attacker, target, command); + core.scriptService.callScript("scripts/commands/combat", command.getCommandName(), "preRun", core, attacker, target, command);*/ + final Point3D targetPos = target.getPosition(); + final SWGObject targetParent = target.getContainer(); - if(command.getAttackType() == 1) - doSingleTargetCombat(attacker, target, weapon, command, actionCounter); - else if(command.getAttackType() == 0 || command.getAttackType() == 2 || command.getAttackType() == 3) - doAreaCombat(attacker, target, weapon, command, actionCounter); + if(command.getDelayAttackParticle().length() > 0 || command.getInitialAttackDelay() > -1) { + + if(command.getInitialAttackDelay() > 0) { + + if(command.getDelayAttackParticle().length() > 0) + target.notifyObservers(new PlayClientEffectLocMessage(command.getDelayAttackParticle(), target.getPlanet().getName(), target.getWorldPosition()), true); + + try { + Thread.sleep((long) command.getInitialAttackDelay()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + } else if(command.getInitialAttackDelay() <= 0 && command.getDelayAttackInterval() > 0 && command.getDelayAttackLoops() <= 1) { + + try { + Thread.sleep((long) command.getDelayAttackInterval()); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + if(command.getDelayAttackParticle().length() > 0) + target.notifyObservers(new PlayClientEffectLocMessage(command.getDelayAttackParticle(), target.getPlanet().getName(), target.getWorldPosition()), true); + + } + + if(command.getDelayAttackLoops() > 1) { + final ScheduledFuture task = scheduler.scheduleAtFixedRate(new Runnable() { + + @Override + public void run() { + + if(command.getDelayAttackParticle().length() > 0) + target.notifyObservers(new PlayClientEffectLocMessage(command.getDelayAttackParticle(), target.getPlanet().getName(), target.getWorldPosition()), true); + + if(command.getAttackType() == 1) + doSingleTargetCombat(attacker, target, weapon, command, actionCounter); + else if(command.getAttackType() == 0 || command.getAttackType() == 2 || command.getAttackType() == 3) + doAreaCombat(attacker, targetPos, weapon, command, actionCounter, targetParent); + + } + + }, 0, (long) (command.getDelayAttackInterval() * 1000), TimeUnit.MILLISECONDS); + + scheduler.schedule(new Runnable() { + + @Override + public void run() { + task.cancel(true); + } + + }, (long) ((command.getDelayAttackInterval() * 1000) * command.getDelayAttackLoops()), TimeUnit.MILLISECONDS); + + return; + + } else { + if(command.getAttackType() == 1) + doSingleTargetCombat(attacker, target, weapon, command, actionCounter); + else if(command.getAttackType() == 0 || command.getAttackType() == 2 || command.getAttackType() == 3) + doAreaCombat(attacker, targetPos, weapon, command, actionCounter, targetParent); + } + + } else { + + if(command.getAttackType() == 1) + doSingleTargetCombat(attacker, target, weapon, command, actionCounter); + else if(command.getAttackType() == 0 || command.getAttackType() == 2 || command.getAttackType() == 3) + doAreaCombat(attacker, target, weapon, command, actionCounter); + + } } @@ -89,6 +168,53 @@ public class CombatService implements INetworkDispatch { return; } } + + private void doAreaCombat(CreatureObject attacker, Point3D targetPos, WeaponObject weapon, CombatCommand command, int actionCounter, SWGObject targetCell) { + + float x = attacker.getWorldPosition().x; + float z = attacker.getWorldPosition().z; + + SWGObject fakeTargetObject = new WaypointObject(0, attacker.getPlanet(), targetPos); + + if(targetCell != null) + targetCell._add(fakeTargetObject); + + float dirX = fakeTargetObject.getWorldPosition().x - x; + float dirZ = fakeTargetObject.getWorldPosition().z - z; + + float range = command.getConeLength(); + + List inRangeObjects = core.simulationService.get(attacker.getPlanet(), fakeTargetObject.getWorldPosition().x, fakeTargetObject.getWorldPosition().z, (int) range); + + + for(SWGObject obj : inRangeObjects) { + + if(!(obj instanceof TangibleObject) || obj == attacker) + continue; + + if(obj instanceof CreatureObject && (((CreatureObject) obj).getPosture() == 13 || ((CreatureObject) obj).getPosture() == 14)) + continue; + + if(command.getAttackType() == 0 && !isInConeAngle(attacker, obj, (int) command.getConeLength(), (int) command.getConeWidth(), dirX, dirZ)) + continue; + + if(!core.simulationService.checkLineOfSight(fakeTargetObject, obj)) + continue; + + if(!attemptCombat(attacker, (TangibleObject) obj)) + continue; + + doSingleTargetCombat(attacker, (TangibleObject) obj, weapon, command, actionCounter); + + } + + if(targetCell != null) + targetCell._remove(fakeTargetObject); + + core.objectService.destroyObject(fakeTargetObject); + + } + private void doSingleTargetCombat(CreatureObject attacker, TangibleObject target, WeaponObject weapon, CombatCommand command, int actionCounter) { if(target instanceof CreatureObject) { @@ -168,7 +294,6 @@ public class CombatService implements INetworkDispatch { damage *= 0.4f; } else if(mitigationType == HitType.EVASION) { float evasionValue = (attacker.getSkillMod("combat_evasion_value").getBase() / 4) / 100; - damage *= (1 - evasionValue); } @@ -189,8 +314,8 @@ public class CombatService implements INetworkDispatch { sendCombatPackets(attacker, target, weapon, command, actionCounter, damage, armorAbsorbed, hitType); - if(FileUtilities.doesFileExist("scripts/commands/combat" + command.getCommandName() + ".py")) - core.scriptService.callScript("scripts/commands/combat", command.getCommandName(), "run", core, attacker, target, null); + if(FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) + core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "run", core, attacker, target, null); } @@ -281,7 +406,7 @@ public class CombatService implements INetworkDispatch { } private boolean attemptCombat(CreatureObject attacker, TangibleObject target) { - + if(target.getDefendersList().contains(attacker) && attacker.getDefendersList().contains(target)) return true; @@ -422,27 +547,26 @@ public class CombatService implements INetworkDispatch { public byte getHitType(CreatureObject attacker, CreatureObject target, WeaponObject weapon, CombatCommand command) { - Random rand = new Random(); float r; // negation rolls(parry, miss and dodge) can only roll on single target attacks, strikethrough also only rolls on single target attacks if(command.getAttackType() == 1) { if(weapon.isRanged()) { - float missChance = 0.5f; + float missChance = 0.05f; if(attacker.getSkillMod("strength_modified").getBase() > 0) { float missNegation = (float) ((attacker.getSkillMod("strength_modified").getBase() / 100) * 0.1); - if(missNegation > 0.4f) - missNegation = 0.4f; + if(missNegation > 0.04f) + missNegation = 0.04f; missChance -= missNegation; } - r = rand.nextFloat(); + r = new Random().nextFloat(); if(r <= missChance) return HitType.MISS; } - float dodgeChance = target.getSkillMod("display_only_dodge").getBase() / 10000; + float dodgeChance = (float) target.getSkillMod("display_only_dodge").getBase() / 10000; - r = rand.nextFloat(); + r = new Random().nextFloat(); if(r <= dodgeChance) return HitType.DODGE; @@ -450,25 +574,24 @@ public class CombatService implements INetworkDispatch { WeaponObject weapon2 = (WeaponObject) core.objectService.getObject(((CreatureObject) target).getWeaponId()); if(weapon2 != null && weapon2.isMelee()) { - float parryChance = target.getSkillMod("display_only_parry").getBase() / 10000; + float parryChance = (float) target.getSkillMod("display_only_parry").getBase() / 10000; - r = rand.nextFloat(); + r = new Random().nextFloat(); if(r <= parryChance) return HitType.PARRY; } - float stChance = attacker.getSkillMod("display_only_strikethrough").getBase() / 10000; + float stChance = (float) attacker.getSkillMod("display_only_strikethrough").getBase() / 10000; - r = rand.nextFloat(); + r = new Random().nextFloat(); if(r <= stChance) return HitType.STRIKETHROUGH; } - float critChance = attacker.getSkillMod("display_only_critical").getBase() / 10000; - - r = rand.nextFloat(); + float critChance = (float) attacker.getSkillMod("display_only_critical").getBase() / 10000; + r = new Random().nextFloat(); if(r <= critChance) return HitType.CRITICAL; @@ -480,20 +603,19 @@ public class CombatService implements INetworkDispatch { public byte doMitigationRolls(CreatureObject attacker, CreatureObject target, WeaponObject weapon, CombatCommand command, byte hitType) { - Random rand = new Random(); float r; - float blockChance = target.getSkillMod("display_only_block").getBase() / 10000; + float blockChance = (float) target.getSkillMod("display_only_block").getBase() / 10000; - r = rand.nextFloat(); + r = new Random().nextFloat(); if(r <= blockChance) return HitType.BLOCK; if(command.getAttackType() == 0 || command.getAttackType() == 2 || command.getAttackType() == 3) { - float evasionChance = target.getSkillMod("display_only_evasion").getBase() / 10000; + float evasionChance = (float) target.getSkillMod("display_only_evasion").getBase() / 10000; - r = rand.nextFloat(); + r = new Random().nextFloat(); if(r <= evasionChance) return HitType.EVASION; @@ -501,9 +623,9 @@ public class CombatService implements INetworkDispatch { if(hitType == HitType.HIT) { - float glanceChance = target.getSkillMod("display_only_glancing_blow").getBase() / 10000; + float glanceChance = (float) target.getSkillMod("display_only_glancing_blow").getBase() / 10000; - r = rand.nextFloat(); + r = new Random().nextFloat(); if(r <= glanceChance) return HitType.GLANCE; @@ -514,16 +636,45 @@ public class CombatService implements INetworkDispatch { } - public void applyDamage(CreatureObject attacker, CreatureObject target, int damage) { + public void applyDamage(CreatureObject attacker, final CreatureObject target, int damage) { if(target.getHealth() - damage <= 0) { - target.setHealth(1); - target.setPosture((byte) 13); + synchronized(target.getMutex()) { + target.setHealth(1); + target.setPosture((byte) 13); + target.setTurnRadius(0); + target.setSpeedMultiplierBase(0); + //target.resetHAMList(); + } + //attacker.resetHAMList(); + scheduler.schedule(new Runnable() { + + @Override + public void run() { + + synchronized(target.getMutex()) { + + if(target.getPosture() != 13) + return; + + //target.resetHAMList(); + target.setPosture((byte) 0); + target.setTurnRadius(1); + target.setSpeedMultiplierBase(1); + + } + + } + + }, target.getIncapTimer(), TimeUnit.SECONDS); + core.buffService.addBuffToCreature(target, "incapWeaken"); if(target.getSlottedObject("ghost") != null) attacker.sendSystemMessage("You incapacitate " + target.getCustomName() + ".", (byte) 0); return; } - target.setHealth(target.getHealth() - damage); + synchronized(target.getMutex()) { + target.setHealth(target.getHealth() - damage); + } } @@ -602,7 +753,9 @@ public class CombatService implements INetworkDispatch { healAmount += (healAmount * (healPotency / 100)); } - target.setHealth(target.getHealth() + healAmount); + synchronized(target.getMutex()) { + target.setHealth(target.getHealth() + healAmount); + } if(FileUtilities.doesFileExist("scripts/commands/combat" + command.getCommandName() + ".py")) core.scriptService.callScript("scripts/commands/combat", command.getCommandName(), "run", core, healer, target, null); @@ -633,9 +786,65 @@ public class CombatService implements INetworkDispatch { } - } + public void deathblowPlayer(CreatureObject attacker, CreatureObject target) { + + target.setPosture((byte) 14); + attacker.sendSystemMessage("You have killed " + target.getCustomName() + ".", (byte) 0); + attacker.removeDefender(target); + target.removeDefender(attacker); + + // TODO: Create Clone SUI Window + + } + + public boolean areInDuel(CreatureObject creature1, CreatureObject creature2) { + + if(creature1.getDuelList().contains(creature2) && creature2.getDuelList().contains(creature1)) + return true; + + return false; + + } + + public void handleDuel(CreatureObject requester, CreatureObject target) { + + if(!target.getDuelList().contains(requester)) { + + requester.getDuelList().add(target); + requester.sendSystemMessage("You challenge " + target.getCustomName() + " to a duel.", (byte) 0); + target.sendSystemMessage(requester.getCustomName() + " challenges you to a duel.", (byte) 0); + return; + + } else { + + requester.getDuelList().add(target); + requester.sendSystemMessage("You accept " + target.getCustomName() + "'s challenge.", (byte) 0); + target.sendSystemMessage(requester.getCustomName() + " accepts your challenge.", (byte) 0); + target.getClient().getSession().write(new UpdatePVPStatusMessage(requester.getObjectID(), 55, requester.getFaction()).serialize()); + requester.getClient().getSession().write(new UpdatePVPStatusMessage(target.getObjectID(), 55, target.getFaction()).serialize()); + + } + + + } + + public void handleEndDuel(CreatureObject requester, CreatureObject target) { + + requester.getDuelList().remove(target); + target.getDuelList().remove(requester); + + target.removeDefender(requester); + requester.removeDefender(target); + + target.getClient().getSession().write(new UpdatePVPStatusMessage(requester.getObjectID(), 0x16, requester.getFaction()).serialize()); + requester.getClient().getSession().write(new UpdatePVPStatusMessage(target.getObjectID(), 0x16, target.getFaction()).serialize()); + + requester.sendSystemMessage("You end your duel with " + target.getCustomName() + ".", (byte) 0); + target.sendSystemMessage(requester.getCustomName() + " ends your duel.", (byte) 0); + + } public enum HitType{; diff --git a/src/services/command/CombatCommand.java b/src/services/command/CombatCommand.java index cd77a79d..dd838491 100644 --- a/src/services/command/CombatCommand.java +++ b/src/services/command/CombatCommand.java @@ -68,6 +68,13 @@ public class CombatCommand extends BaseSWGCommand { private String performanceSpam; private byte hitSpam; private float cooldown; + private String delayAttackEggTemplate; + private String delayAttackParticle; + private float initialAttackDelay; + private float delayAttackInterval; + private int delayAttackLoops; + private int delayAttackEggPosition; + public CombatCommand(String commandName) { super(commandName); @@ -81,6 +88,12 @@ public class CombatCommand extends BaseSWGCommand { validTargetType = ((Integer) visitor.getObject(i, 5)).byteValue(); hitType = ((Integer) visitor.getObject(i, 6)).byteValue(); healType = ((Integer) visitor.getObject(i, 7)).byteValue(); + delayAttackEggTemplate = (String) visitor.getObject(i, 12); + delayAttackParticle = (String) visitor.getObject(i, 13); + initialAttackDelay = (Float) visitor.getObject(i, 14); + delayAttackInterval = (Float) visitor.getObject(i, 15); + delayAttackLoops = (Integer) visitor.getObject(i, 16); + delayAttackEggPosition = (Integer) visitor.getObject(i, 17); String defaultAnims = (String) visitor.getObject(i, 21); setDefaultAnimations(defaultAnims.split(",")); String unarmedAnims = (String) visitor.getObject(i, 22); @@ -593,6 +606,54 @@ public class CombatCommand extends BaseSWGCommand { public void setCooldown(float cooldown) { this.cooldown = cooldown; } + + public String getDelayAttackEggTemplate() { + return delayAttackEggTemplate; + } + + public void setDelayAttackEggTemplate(String delayAttackEggTemplate) { + this.delayAttackEggTemplate = delayAttackEggTemplate; + } + + public String getDelayAttackParticle() { + return delayAttackParticle; + } + + public void setDelayAttackParticle(String delayAttackParticle) { + this.delayAttackParticle = delayAttackParticle; + } + + public float getInitialAttackDelay() { + return initialAttackDelay; + } + + public void setInitialAttackDelay(float initialAttackDelay) { + this.initialAttackDelay = initialAttackDelay; + } + + public float getDelayAttackInterval() { + return delayAttackInterval; + } + + public void setDelayAttackInterval(float delayAttackInterval) { + this.delayAttackInterval = delayAttackInterval; + } + + public int getDelayAttackEggPosition() { + return delayAttackEggPosition; + } + + public void setDelayAttackEggPosition(int delayAttackEggPosition) { + this.delayAttackEggPosition = delayAttackEggPosition; + } + + public int getDelayAttackLoops() { + return delayAttackLoops; + } + + public void setDelayAttackLoops(int delayAttackLoops) { + this.delayAttackLoops = delayAttackLoops; + } diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 413ca1bf..3eaebc7c 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -95,12 +95,12 @@ public class CommandService implements INetworkDispatch { if(command instanceof CombatCommand) { CombatCommand command2 = (CombatCommand) command.clone(); - core.scriptService.callScript("scripts/commands/combat", command.getCommandName(), "setup", core, actor, target, command2); + if(FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) + core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "setup", core, actor, target, command2); processCombatCommand(actor, target, command2, commandEnqueue.getActionCounter(), commandEnqueue.getCommandArguments()); return; } - core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandEnqueue.getCommandArguments()); } diff --git a/src/services/gcw/GCWService.java b/src/services/gcw/GCWService.java index 96062aee..e89c7e48 100644 --- a/src/services/gcw/GCWService.java +++ b/src/services/gcw/GCWService.java @@ -78,7 +78,7 @@ public class GCWService implements INetworkDispatch { private void afterInitialisation() { try { - core.scriptService.callScript("scripts/", "gcwzones", "addZones"); + core.scriptService.callScript("scripts/", "gcwzones", "addZones", core); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/services/map/MapService.java b/src/services/map/MapService.java index 029a4f31..d6a0f821 100644 --- a/src/services/map/MapService.java +++ b/src/services/map/MapService.java @@ -41,6 +41,7 @@ import engine.clients.Client; import engine.resources.objects.SWGObject; import engine.resources.scene.Grid2D; import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -113,4 +114,27 @@ public class MapService implements INetworkDispatch { locationMap.get(planet).add(location); } + public String getClosestCityName(SWGObject object) { + + Vector locations = locationMap.get(object.getPlanet()); + float closestDistance = Float.MAX_VALUE; + String closestName = ""; + Point3D objPos = object.getWorldPosition(); + + for(MapLocation location : locations) { + + if(location.getCategory() == 17) { + Point3D position = new Point3D(location.getX(), 0, location.getY()); + if(position.getDistance2D(objPos) < closestDistance) { + closestDistance = position.getDistance2D(objPos); + closestName = location.getName(); + } + } + + } + + return closestName; + + } + } diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index 0ac051ca..ee2afd70 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -187,33 +187,39 @@ public class ObjectService implements INetworkDispatch { return null; } + object.setPlanetId(planet.getID()); + + loadServerTemplate(object); + + objectList.add(object); - String serverTemplate = Template.replace(".iff", ""); + return object; + } + + public void loadServerTemplate(SWGObject object) { + + String template = object.getTemplate(); + String serverTemplate = template.replace(".iff", ""); // check if template is empty(4 default lines) to reduce RAM usage(saves about 500 MB of RAM) try { int numberOfLines = FileUtilities.getNumberOfLines("scripts/" + serverTemplate.split("shared_" , 2)[0].replace("shared_", "") + serverTemplate.split("shared_" , 2)[1] + ".py"); if(numberOfLines > 4) { - if(serverTemplates.containsKey(Template)) { - PyObject func = serverTemplates.get(Template); + if(serverTemplates.containsKey(template)) { + PyObject func = serverTemplates.get(template); func.__call__(Py.java2py(core), Py.java2py(object)); } else { PyObject func = core.scriptService.getMethod("scripts/" + serverTemplate.split("shared_" , 2)[0].replace("shared_", ""), serverTemplate.split("shared_" , 2)[1], "setup"); func.__call__(Py.java2py(core), Py.java2py(object)); - serverTemplates.put(Template, func); + serverTemplates.put(template, func); } } } catch (IOException e) { e.printStackTrace(); } - - //core.scriptService.callScript("scripts/" + serverTemplate.split("shared_" , 2)[0].replace("shared_", ""), "setup", serverTemplate.split("shared_" , 2)[1], core, object); - - objectList.add(object); - return object; } public SWGObject createObject(String Template, Planet planet) { diff --git a/src/services/sui/SUIListBoxItem.java b/src/services/sui/SUIListBoxItem.java new file mode 100644 index 00000000..b73fce9f --- /dev/null +++ b/src/services/sui/SUIListBoxItem.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package services.sui; + +public class SUIListBoxItem { + + private String name; + private long objectId; + + public SUIListBoxItem(String name, long objectId) { + this.name = name; + this.objectId = objectId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public long getObjectId() { + return objectId; + } + + public void setObjectId(long objectId) { + this.objectId = objectId; + } + +} diff --git a/src/services/sui/SUIService.java b/src/services/sui/SUIService.java index 8cccd2cc..5d1c494a 100644 --- a/src/services/sui/SUIService.java +++ b/src/services/sui/SUIService.java @@ -23,6 +23,7 @@ package services.sui; import java.nio.ByteOrder; import java.util.Map; +import java.util.Map.Entry; import java.util.Random; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; @@ -46,6 +47,7 @@ import protocol.swg.objectControllerObjects.ObjectMenuResponse; import resources.common.ObjControllerOpcodes; import resources.common.Opcodes; import resources.common.RadialOptions; +import services.sui.SUIWindow.SUICallback; import engine.clients.Client; import engine.resources.objects.SWGObject; @@ -147,10 +149,13 @@ public class SUIService implements INetworkDispatch { PyObject func = window.getFunctionByEventId(suiEvent.getEventType()); - if(func == null) - return; + if(func != null) + func.__call__(Py.java2py(core), Py.java2py(owner), Py.java2py(suiEvent.getEventType()), Py.java2py(suiEvent.getReturnList())); - func.__call__(Py.java2py(core), Py.java2py(owner), Py.java2py(suiEvent.getEventType()), Py.java2py(suiEvent.getReturnList())); + SUICallback callback = window.getCallbackByEventId(suiEvent.getEventType()); + + if(callback != null) + callback.process(owner, suiEvent.getEventType(), suiEvent.getReturnList()); windowMap.remove(window.getWindowId()); @@ -215,7 +220,7 @@ public class SUIService implements INetworkDispatch { } - public SUIWindow createListBox(int type, String title, String promptText, Vector data, SWGObject owner, SWGObject rangeObject, float maxDistance) { + public SUIWindow createListBox(int type, String title, String promptText, Map cloneData, SWGObject owner, SWGObject rangeObject, float maxDistance) { SUIWindow window = createSUIWindow("Script.listBox", owner, rangeObject, maxDistance); @@ -240,15 +245,17 @@ public class SUIService implements INetworkDispatch { window.clearDataSource("List.dataList"); - int index = 0; + //int index = 0; - for(String string : data) { + for(Entry e : cloneData.entrySet()) { - window.addDataItem("List.dataList:Name", String.valueOf(index)); + /*window.addDataItem("List.dataList:Name", String.valueOf(index)); - window.setProperty("List.dataList" + index + ":Text", string); + window.setProperty("List.dataList." + index + ":Text", string); - ++index; + ++index;*/ + + window.addListBoxMenuItem(e.getValue(), e.getKey()); } diff --git a/src/services/sui/SUIWindow.java b/src/services/sui/SUIWindow.java index 1c547b47..dd256ae2 100644 --- a/src/services/sui/SUIWindow.java +++ b/src/services/sui/SUIWindow.java @@ -38,7 +38,8 @@ public class SUIWindow { private float maxDistance = 0; private Vector components = new Vector(); private Map callbacks = new ConcurrentHashMap(); - + private Map javaCallbacks = new ConcurrentHashMap(); + private Vector menuItems = new Vector(); public SUIWindow(String script, SWGObject owner, int windowId, SWGObject rangeObject, float maxDistance) { @@ -114,6 +115,30 @@ public class SUIWindow { } + public void addHandler(int eventId, String source, byte trigger, Vector returnParams, SUICallback handleFunc) { + + SUIWindowComponent component = new SUIWindowComponent(); + component.setType((byte) 5); + + component.getNarrowParams().add(source); + + component.getNarrowParams().add(new String(new byte[] { trigger })); + component.getNarrowParams().add("handleSUI"); + + for(String returnParam : returnParams) { + + for(String str : returnParam.split(":")) { + component.getNarrowParams().add(str); + } + + } + + components.add(component); + javaCallbacks.put(eventId, handleFunc); + + } + + public void addDataSource(String name, String value) { SUIWindowComponent component = new SUIWindowComponent(); @@ -128,6 +153,17 @@ public class SUIWindow { components.add(component); } + + public void addListBoxMenuItem(String itemName, long objectId) { + SUIListBoxItem menuItem = new SUIListBoxItem(itemName, objectId); + + int index = menuItems.size(); + + addDataItem("List.dataList:Name", String.valueOf(index)); + setProperty("List.dataList." + index + ":Text", itemName); + + menuItems.add(menuItem); + } public int getWindowId() { @@ -178,12 +214,39 @@ public class SUIWindow { return callbacks.get(eventId); } + public Map getJavaCallbacks() { + return javaCallbacks; + } + + public SUICallback getCallbackByEventId(int eventId) { + return javaCallbacks.get(eventId); + } + + public Vector getMenuItems() { + return menuItems; + } + + public long getObjectIdByIndex(int index) { + SUIListBoxItem item = getMenuItems().get(index); + + if(item != null) + return item.getObjectId(); + + return 0; + } + public enum Trigger {; public static byte TRIGGER_UPDATE = 4; public static byte TRIGGER_OK = 9; public static byte TRIGGER_CANCEL = 10; } + + public interface SUICallback { + + public void process(SWGObject owner, int eventType, Vector returnList); + + } } diff --git a/src/services/trade/TradeService.java b/src/services/trade/TradeService.java index 95bc6e5f..06100d90 100644 --- a/src/services/trade/TradeService.java +++ b/src/services/trade/TradeService.java @@ -23,6 +23,8 @@ import protocol.swg.objectControllerObjects.SecureTrade; import resources.common.ObjControllerOpcodes; import resources.objects.creature.CreatureObject; import engine.clients.Client; +import engine.resources.container.AllPermissions; +import engine.resources.container.CreatureContainerPermissions; import engine.resources.objects.SWGObject; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -370,11 +372,15 @@ public class TradeService implements INetworkDispatch{ { cleanTradeSession(client, tradePartner.getClient()); } - //actingTraderInventory.transferTo(tradePartner, tradePartnerInventory, tradeObject); + actingTraderInventory.setContainerPermissions(AllPermissions.ALL_PERMISSIONS); + tradePartnerInventory.setContainerPermissions(AllPermissions.ALL_PERMISSIONS); + actingTraderInventory.transferTo(tradePartner, tradePartnerInventory, tradeObject); + actingTraderInventory.setContainerPermissions(CreatureContainerPermissions.CREATURE_CONTAINER_PERMISSIONS); + tradePartnerInventory.setContainerPermissions(CreatureContainerPermissions.CREATURE_CONTAINER_PERMISSIONS); - actingTraderInventory._remove(tradeObject); - actingTrader.makeUnaware(tradeObject); - tradePartnerInventory.add(tradeObject); + //actingTraderInventory._remove(tradeObject); + //actingTrader.makeUnaware(tradeObject); + //tradePartnerInventory.add(tradeObject); itr.remove(); }