Merge pull request #1 from ProjectSWGCore/master

updating my fork, hopefully i am doing this right
This commit is contained in:
zingzing175
2013-09-19 18:39:06 -07:00
71 changed files with 1656 additions and 218 deletions
+2
View File
@@ -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/
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
import sys
def setup(core, actor, buff):
return
def removeBuff(core, actor, buff):
return
+11
View File
@@ -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
+11
View File
@@ -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
+8
View File
@@ -0,0 +1,8 @@
import sys
def setup(core, actor, buff):
return
def removeBuff(core, actor, buff):
return
+28
View File
@@ -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
+29
View File
@@ -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
+25
View File
@@ -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
+9
View File
@@ -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
+9
View File
@@ -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
+4
View File
@@ -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)
+4
View File
@@ -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)
+1
View File
@@ -5,5 +5,6 @@ def setup():
def run(core, actor, target, commandString):
actor.setSpeedMultiplierBase(float(commandString))
core.buffService.addBuffToCreature(actor, 'bh_prescience')
return
+3
View File
@@ -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])
+3
View File
@@ -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)
+29 -15
View File
@@ -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
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
+38
View File
@@ -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')
@@ -1,4 +1,25 @@
import sys
from java.util import Vector
from resources.common import SpawnPoint
def setup(core, object):
return
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
@@ -1,4 +1,15 @@
import sys
def setup(core, object):
return
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
@@ -1,4 +1,6 @@
import sys
def setup(core, object):
return
return
@@ -1,4 +1,17 @@
import sys
from java.util import Vector
from resources.common import SpawnPoint
def setup(core, object):
return
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
@@ -1,4 +1,20 @@
import sys
from java.util import Vector
from resources.common import SpawnPoint
def setup(core, object):
return
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
@@ -1,4 +1,20 @@
import sys
from java.util import Vector
from resources.common import SpawnPoint
def setup(core, object):
return
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
@@ -1,4 +1,25 @@
import sys
from java.util import Vector
from resources.common import SpawnPoint
def setup(core, object):
return
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
@@ -1,4 +1,15 @@
import sys
def setup(core, object):
return
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
@@ -1,4 +1,12 @@
import sys
def setup(core, object):
return
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
@@ -1,4 +1,19 @@
import sys
from java.util import Vector
from resources.common import SpawnPoint
def setup(core, object):
return
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
@@ -1,4 +1,19 @@
import sys
from java.util import Vector
from resources.common import SpawnPoint
def setup(core, object):
return
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
@@ -1,4 +1,19 @@
import sys
from java.util import Vector
from resources.common import SpawnPoint
def setup(core, object):
return
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
@@ -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
@@ -1,4 +1,18 @@
import sys
from java.util import Vector
from resources.common import SpawnPoint
def setup(core, object):
return
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
@@ -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
@@ -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
@@ -1,4 +1,11 @@
import sys
def setup(core, object):
return
return
def equip(core, actor, target):
return
def unequip(core, actor, target):
return
@@ -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
@@ -1,4 +1,31 @@
import sys
def setup(core, object):
return
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
+10
View File
@@ -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
+8 -8
View File
@@ -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)
-12
View File
@@ -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
-4
View File
@@ -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
+2 -21
View File
@@ -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
return
+1 -1
View File
@@ -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();
@@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* 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 <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
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
}
}
@@ -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) {
}
@@ -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
+78
View File
@@ -0,0 +1,78 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* 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 <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
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;
}
}
+35 -4
View File
@@ -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++;
}
}
@@ -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<CellObject> ref = new AtomicReference<CellObject>();
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();
}
}
@@ -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
@@ -134,7 +134,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
// non-baseline vars
@NotPersistent
private List<Long> duelList = Collections.synchronizedList(new ArrayList<Long>());
private List<CreatureObject> duelList = Collections.synchronizedList(new ArrayList<CreatureObject>());
@NotPersistent
private CreatureMessageBuilder messageBuilder;
@@ -820,7 +820,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
return appearanceEquipmentList;
}
public List<Long> getDuelList() {
public List<CreatureObject> 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);
}
}
}
@@ -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
}
}
@@ -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());
}
}
+43 -28
View File
@@ -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
+1 -1
View File
@@ -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);
+88 -5
View File
@@ -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<SWGObject> cloners = core.staticService.getCloningFacilitiesByPlanet(creature.getPlanet());
Map<Long, String> cloneData = new HashMap<Long, String>();
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<String> returnList = new Vector<String>();
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<String> 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<SpawnPoint> spawnPoints = (Vector<SpawnPoint>) 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) {
}
+32 -16
View File
@@ -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;
}
+11 -8
View File
@@ -103,12 +103,11 @@ public class SimulationService implements INetworkDispatch {
quadTrees.put(terrainService.getPlanetList().get(i).getName(), new QuadTree<SWGObject>(-8192, -8192, 8192, 8192));
}
List<SWGObject> 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<SWGObject> objectList = new ArrayList<SWGObject>(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;
+2 -2
View File
@@ -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);
}
+20 -1
View File
@@ -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<SWGObject> getCloningFacilitiesByPlanet(Planet planet) {
List<SWGObject> objects = core.simulationService.get(planet, 0, 0, 8300);
List<SWGObject> cloners = new ArrayList<SWGObject>();
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;
}
}
+2
View File
@@ -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
+247 -38
View File
@@ -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<SWGObject> 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{;
+61
View File
@@ -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;
}
+2 -2
View File
@@ -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());
}
+1 -1
View File
@@ -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();
}
+24
View File
@@ -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<MapLocation> 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;
}
}
+15 -9
View File
@@ -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) {
+50
View File
@@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright (c) 2013 <Project SWG>
*
* 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 <http://www.gnu.org/licenses/>.
*
* Using NGEngine to work with NGECore2 is making a combined work based on NGEngine.
* Therefore all terms and conditions of the GNU Lesser General Public License cover the combination.
******************************************************************************/
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;
}
}
+16 -9
View File
@@ -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<String> data, SWGObject owner, SWGObject rangeObject, float maxDistance) {
public SUIWindow createListBox(int type, String title, String promptText, Map<Long, String> 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<Long, String> 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());
}
+64 -1
View File
@@ -38,7 +38,8 @@ public class SUIWindow {
private float maxDistance = 0;
private Vector<SUIWindowComponent> components = new Vector<SUIWindowComponent>();
private Map<Integer, PyObject> callbacks = new ConcurrentHashMap<Integer, PyObject>();
private Map<Integer, SUICallback> javaCallbacks = new ConcurrentHashMap<Integer, SUICallback>();
private Vector<SUIListBoxItem> menuItems = new Vector<SUIListBoxItem>();
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<String> 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<Integer, SUICallback> getJavaCallbacks() {
return javaCallbacks;
}
public SUICallback getCallbackByEventId(int eventId) {
return javaCallbacks.get(eventId);
}
public Vector<SUIListBoxItem> 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<String> returnList);
}
}
+10 -4
View File
@@ -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();
}