diff --git a/scripts/commands/forage.py b/scripts/commands/forage.py index bce7443e..9fbf9c31 100644 --- a/scripts/commands/forage.py +++ b/scripts/commands/forage.py @@ -12,9 +12,12 @@ def run(core, actor, target, commandString): #if actor.getSkills('Foraging')==0: #actor.sendSystemMessage('@skl_use:sys_forage_noskill'),0) - #if actor.isForaging()==1: - #actor.sendSystemMessage('@skl_use:sys_forage_already',0) - #return + if actor.getAttachment("LastForageTime"): + if actor.getAttachment("LastForageTime")>int(round(time.time() * 1000))-5000: + actor.sendSystemMessage('@skl_use:sys_forage_already',0) + return + + actor.setAttachment("LastForageTime",int(round(time.time() * 1000))) if actor.getCombatFlag()!=0: actor.sendSystemMessage('@skl_use:sys_forage_combatfail',0) diff --git a/scripts/commands/setgodmode.py b/scripts/commands/setgodmode.py index 2206ce23..9927f5a1 100644 --- a/scripts/commands/setgodmode.py +++ b/scripts/commands/setgodmode.py @@ -1,9 +1,298 @@ -# This file will be updated at a later date with a new command. - import sys +from engine.resources.scene import Point3D +from protocol.swg import ObjControllerMessage +#from protocol.swg import UnknownAbilityPacket +from protocol.swg import PlayClientEffectLocMessage +from engine.resources.objects import SWGObject +from java.awt.datatransfer import StringSelection +from java.awt.datatransfer import Clipboard +from java.awt import Toolkit +from resources.datatables import GcwRank +from services.gcw import GCWService + def setup(): - return - + return + def run(core, actor, target, commandString): - return \ No newline at end of file + + playerObject = actor.getSlottedObject('ghost') + + global str + + if not playerObject: + return + + commandArgs = commandString.split(' ') + command = commandArgs[0] + if len(commandArgs) > 1: + arg1 = commandArgs[1] + if len(commandArgs) > 2: + arg2 = commandArgs[2] + if len(commandArgs) > 3: + arg3 = commandArgs[3] + if len(commandArgs) > 4: + arg4 = commandArgs[4] + if len(commandArgs) > 5: + arg5 = commandArgs[5] + + if not command: + return + + #if actor.getClient().isGM() is False: + #return + + #if playerObject.getGodLevel() == 0: + #actor.addAbility("admin") + #playerObject.setGodLevel(50) + + + if command == 'giveExperience' and arg1: + core.playerService.giveExperience(actor, int(arg1)) + + if command == 'level' and arg1: + core.playerService.grantLevel(actor, int(arg1)) + + elif command == 'setSpeed' and arg1: + #actor.sendSystemMessage("Your speed was " + str(actor.getSpeedMultiplierBase()) + ". Don\'t forget to set this back or it\'ll permanently imbalance your speed. Default without buffs or mods is 1.", 2) + actor.setSpeedMultiplierBase(float(arg1)) + actor.sendSystemMessage('Your new speed is ' + arg1 + '.', 2) + + elif command == 'teleport' and arg2 and arg3 and arg4: + position = Point3D(float(arg2), float(arg3), float(arg4)) + core.simulationService.transferToPlanet(actor, core.terrainService.getPlanetByName(arg1), position, actor.getOrientation(), None) + + elif command == 'teleportplayer' and arg1 and arg2 and arg3 and arg4 and arg5: + player = core.chatService.getObjectByFirstName(arg1) + if player: + position = Point3D(float(arg3), float(arg4), float(arg5)) + core.simulationService.transferToPlanet(player, core.terrainService.getPlanetByName(arg2), position, player.getOrientation(), None) + + elif command == 'credits' and arg1: + actor.setCashCredits(actor.getCashCredits() + int(arg1)) + actor.sendSystemMessage('The Galactic Empire has transferred ' + arg1 + ' credits to you for your service.', 0) + + elif command == 'addability' and arg1: + actor.addAbility(str(arg1)) + actor.sendSystemMessage('You have learned ' + arg1 + '.', 0) + + elif command == 'anim' and arg1: + actor.doSkillAnimation(arg1) + actor.sendSystemMessage('Performed ' + arg1 ,0) + + elif command == 'changeBio' and arg1: + actor.getSlottedObject('ghost').setBiography(arg1) + + elif command == 'spawn' and arg1 and arg2: + pos = actor.getWorldPosition() + core.spawnService.spawnCreature(arg1, actor.getPlanet().getName(), 0, pos.x, pos.y, pos.z, 1, 0, 1, 0, int(arg2)) + + elif command == 'instance' and arg1: + core.instanceService.queue(arg1, actor) + + elif command == 'action' and arg1: + actor.setAction(int(arg1)) + + elif command == 'health' and arg1: + actor.setHealth(int(arg1)) + + elif command == 'id': + actor.sendSystemMessage('Your id is: ' + str(actor.getObjectId()), 0) + + elif command == 'cust' and arg1 and arg2 and arg3: + obj = core.objectService.getObject(long(arg1)) + obj.setCustomizationVariable(str(arg2), int(arg3)) + + elif command == 'buff' and arg1: + core.buffService.addBuffToCreature(actor, str(arg1), actor) + + elif command == 'stealth': + if (actor.isInStealth()): + actor.setInStealth(False) + actor.setRadarVisible(True) + else: + actor.setInStealth(True) + actor.setRadarVisible(False) + + elif command == 'holoEmote' and arg1: + playerObject.setHoloEmote('holoemote_' + arg1) + playerObject.setHoloEmoteUses(20) + actor.sendSystemMessage('Holo-Emote Generator set to ' + 'holoemote_' + arg1, 0) + + elif command == 'off': + if playerObject.getGodLevel > 0: + actor.removeAbility("admin") + playerObject.setGodLevel(0) + + elif command == 'setBounty': + if actor.getFaction() == "": + actor.sendSystemMessage('You must be aligned in order to place a bounty on yourself.', 0) + return + core.playerService.sendSetBountyWindow(actor, actor) + return + + elif command == 'genloot': + object = core.lootService.generateLootItem(actor, arg1) + + inventory = actor.getSlottedObject('inventory') + + if inventory: + inventory.add(object) + + elif command == 'spawnobj': + pos = actor.getPosition() + core.staticService.spawnObject(arg1, actor.getPlanet().getName(), 0, pos.x, pos.y, pos.z, 0, 0) + + elif command == 'showpos': + pos = actor.getPosition() + ori = actor.getOrientation() + cellid = 0 + planetName = actor.getPlanet().getName() + + actor.sendSystemMessage('Position.x : %s' % pos.x, 0) + print ('Position.x : %s' % pos.x, 0) + actor.sendSystemMessage('Position.y : %s' % pos.y, 0) + print ('Position.y : %s' % pos.y, 0) + actor.sendSystemMessage('Position.z : %s' % pos.z, 0) + print ('Position.z : %s' % pos.z, 0) + actor.sendSystemMessage('Orientation.w : %s' % ori.w, 0) + print ('Orientation.x : %s' % ori.w, 0) + actor.sendSystemMessage('Orientation.x : %s' % ori.x, 0) + print ('Orientation.w : %s' % ori.x, 0) + actor.sendSystemMessage('Orientation.y : %s' % ori.y, 0) + print ('Orientation.y : %s' % ori.y, 0) + actor.sendSystemMessage('Orientation.z : %s' % ori.z, 0) + print ('Orientation.z : %s' % ori.z, 0) + if (actor.getContainer()): + building_id = actor.getGrandparent().getObjectID() + cid = actor.getContainer().getCellNumber() + cellid = cid + actor.sendSystemMessage('Cell ID : %s' % cid, 0) + actor.sendSystemMessage('Building ID : %s' % building_id, 0) + print('Cell ID : %s' % cid, 0) + print('Building ID : %s' % building_id, 0) + if cellid == 0: + str = " = stcSvc.spawnObject('', '" + planetName + "', long(%s" % cellid + "), float(%.4f" % pos.x + "), float(%.4f" % pos.y + "), float(%.4f" % pos.z + "), float(%.4f" % ori.w + "), float(%.4f" % ori.x + "), float(%.4f" % ori.y + "), float(%.4f" % ori.z + "))" + elif cellid != 0: + str = "\tbuilding = core.objectService.getObject(long(%s" % building_id + "))\n\t = stcSvc.spawnObject('', '" + planetName + "', building.getCellByCellNumber(long(%s" % cellid + ")), float(%.4f" % pos.x + "), float(%.4f" % pos.y + "), float(%.4f" % pos.z + "), float(%.4f" % ori.w + "), float(%.4f" % ori.x + "), float(%.4f" % ori.y + "), float(%.4f" % ori.z + "))" + toolkit = Toolkit.getDefaultToolkit() + clipboard = toolkit.getSystemClipboard() + clipboard.setContents(StringSelection(str), None) + + elif command == 'patrolpoint': + pos = actor.getPosition() + str = "patrolpoints.add(Point3D(float(%.2f" % pos.x + "), float(%.2f" % pos.y + "), float(%.2f" % pos.z + ")))" + toolkit = Toolkit.getDefaultToolkit() + clipboard = toolkit.getSystemClipboard() + clipboard.setContents(StringSelection(str), None) + actor.sendSystemMessage('Patrolpoint copied to clipboard', 0) + + elif command == 'jesus': + actor.setHealth(actor.getMaxHealth()) + actor.setAction(actor.getMaxAction()) + actor.setPosture(0) + actor.setSpeedMultiplierBase(1) + actor.setTurnRadius(1) + + elif command == 'checkai': + latargetID = long(actor.getIntendedTarget()) + latarget = core.objectService.getObject(latargetID) + actor.sendSystemMessage('Checking AI handling for unit ' + latarget.getCustomName(), 0) + core.aiService.setCheckAI(latarget) + + elif command == 'checkaitarget': + latargetID = long(actor.getIntendedTarget()) + latarget = core.objectService.getObject(latargetID) + if latarget.getAttachment('AI'): + if latarget.getAttachment('AI').getFollowObject(): + actor.sendSystemMessage('Checking AI target ' + latarget.getAttachment('AI').getFollowObject().getTemplate(), 0) + + elif command == 'checkaistate': + latargetID = long(actor.getIntendedTarget()) + latarget = core.objectService.getObject(latargetID) + if latarget.getAttachment('AI'): + if latarget.getAttachment('AI').getCurrentState(): + actor.sendSystemMessage('Checking AI state ' + latarget.getAttachment('AI').getCurrentState().getClass().getName(), 0) + + elif command == 'checkairepos': + latargetID = long(actor.getIntendedTarget()) + latarget = core.objectService.getObject(latargetID) + if latarget.getAttachment('AI'): + if latarget.getAttachment('AI').getRepositionStartTime()(): + actor.sendSystemMessage('Checking AI state ' + latarget.getAttachment('AI').getRepositionStartTime(), 0) + + elif command == 'checkaiprog': + latargetID = long(actor.getIntendedTarget()) + latarget = core.objectService.getObject(latargetID) + if latarget.getAttachment('AI'): + actor.sendSystemMessage('Checking AI progression %s' % latarget.getAttachment('AI').getProgressionMarker(), 0) + + elif command == 'checkwithdrawn': + latargetID = long(actor.getIntendedTarget()) + latarget = core.objectService.getObject(latargetID) + if latarget.getAttachment('isWithdrawn'): + actor.sendSystemMessage('Checking AIisWithdrawn %s' % latarget.getAttachment('isWithdrawn'), 0) + + elif command == 'showbitmask': + latargetID = long(actor.getIntendedTarget()) + latarget = core.objectService.getObject(latargetID) + actor.sendSystemMessage('Optionsbitmask for unit ' + latarget.getCustomName() + ' is %s' % latarget.getOptionsBitmask(), 0) + + elif command == 'spawninst': + + #String campTemplate = "object/building/poi/shared_gcw_rebel_clone_tent_small.iff"; // LOL why doesn't this spawn?!?!?! + inst = core.objectService.createObject(arg1, 0, actor.getPlanet(), actor.getWorldPosition(), actor.getOrientation()) + if inst: + #TangibleObject inst = (TangibleObject) core.objectService.createObject(campTemplate, 0, core.terrainService.getPlanetByName("talus"), new Point3D(-890,9, -2994), quaternion) + core.simulationService.add(inst, inst.getPosition().x, inst.getPosition().z, True) + positionY = core.terrainService.getHeight(inst.getPlanetId(), inst.getPosition().x, inst.getPosition().z) + instpos = Point3D(inst.getPosition().x,positionY+2, inst.getPosition().z) + inst.setPosition(instpos) + + elif command == 'los': + latargetID = long(actor.getIntendedTarget()) + latarget = core.objectService.getObject(latargetID) + los = core.simulationService.checkLineOfSight(actor, latarget) + if los: + actor.sendSystemMessage('Line of sight between player and target', 0) + else: + actor.sendSystemMessage('NO Line of sight between player and target', 0) + + elif command == 'playfx': + effectFile = arg1 + cEffMsg = PlayClientEffectLocMessage(effectFile, actor.getPlanet().getName(), actor.getPosition()) + actor.getClient().getSession().write(cEffMsg.serialize()) + + elif command == 'toinvasion': + invasionplanet = core.invasionService.getInvasionPlanetName() + position = Point3D(float(1366), float(13), float(2747)) + if invasionplanet == 'talus': + position = Point3D(float(264), float(4), float(-2950)) + if invasionplanet == 'tatooine': + position = Point3D(float(-1385), float(12), float(-3597)) + + core.simulationService.transferToPlanet(actor, core.terrainService.getPlanetByName(invasionplanet), position, actor.getOrientation(), None) + + #elif command == 'unknownAbilityPacket' and arg1: + #packet = UnknownAbilityPacket(arg1) + #actor.getClient().getSession().write(packet.serialize()) + #actor.sendSystemMessage('Sent UnknownAbilityPacket for ability ' + arg1, 0) + #return + + elif command == 'rank' and arg1: + playerObject.setCurrentRank(int(arg1)) + print (playerObject.getCurrentRank()) + return + + elif command == 'addToFrogAdminList': + frogBuilding = core.objectService.getObject(core.devService.getFrogBuildingId()) + + if frogBuilding is None: + return + + frogBuilding.addPlayerToAdminList(None, actor.getObjectID(), actor.getCustomName().split(' ')[0]) + actor.sendSystemMessage('You were added to the Admin list for the Frog Building.', 0) + return + return + + \ No newline at end of file diff --git a/scripts/mobiles/forage/goon.py b/scripts/mobiles/forage/goon.py index cb3e63af..2ce75838 100644 --- a/scripts/mobiles/forage/goon.py +++ b/scripts/mobiles/forage/goon.py @@ -13,13 +13,13 @@ def addTemplate(core): mobileTemplate.setCreatureName('forage_goon') mobileTemplate.setLevel(1) mobileTemplate.setDifficulty(Difficulty.ELITE) - mobileTemplate.setMinSpawnDistance(4) mobileTemplate.setMaxSpawnDistance(8) - mobileTemplate.setDeathblow(False) + mobileTemplate.setDeathblow(True) mobileTemplate.setScale(1) mobileTemplate.setAssistRange(12) mobileTemplate.setStalker(False) + mobileTemplate.setSocialGroup("tusken raider") mobileTemplate.setOptionsBitmask(Options.AGGRESSIVE | Options.ATTACKABLE) templates = Vector() @@ -33,16 +33,16 @@ def addTemplate(core): mobileTemplate.setTemplates(templates) weaponTemplates = Vector() - weapontemplate = WeaponTemplate('object/weapon/ranged/carbine/shared_carbine_dh17.iff', WeaponType.CARBINE, 0.6, 15, 'kinetic') - weaponTemplates.add(weapontemplate) - weapontemplate = WeaponTemplate('object/weapon/ranged/pistol/shared_pistol_dl44.iff', WeaponType.PISTOL, 0.4, 15, 'kinetic') - weaponTemplates.add(weapontemplate) - weapontemplate = WeaponTemplate('object/weapon/ranged/rifle/shared_rifle_dlt20a.iff', WeaponType.RIFLE, 0.8, 24, 'kinetic') + #weapontemplate = WeaponTemplate('object/weapon/ranged/carbine/shared_carbine_dh17.iff', WeaponType.CARBINE, 0.6, 15, 'kinetic') + #weaponTemplates.add(weapontemplate) + #weapontemplate = WeaponTemplate('object/weapon/ranged/pistol/shared_pistol_dl44.iff', WeaponType.PISTOL, 0.4, 15, 'kinetic') + #weaponTemplates.add(weapontemplate) + weapontemplate = WeaponTemplate('object/weapon/ranged/rifle/shared_rifle_dlt20a.iff', WeaponType.RIFLE, 1.0, 24, 'kinetic') weaponTemplates.add(weapontemplate) mobileTemplate.setWeaponTemplateVector(weaponTemplates) attacks = Vector() - mobileTemplate.setDefaultAttack('rangedShot') + mobileTemplate.setDefaultAttack('rangedShotrifle') mobileTemplate.setAttacks(attacks) core.spawnService.addMobileTemplate('forage_goon', mobileTemplate) diff --git a/src/resources/common/Forager.java b/src/resources/common/Forager.java index 5f693253..17cc0331 100644 --- a/src/resources/common/Forager.java +++ b/src/resources/common/Forager.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Random; import java.util.Vector; +import engine.resources.common.Stf; import engine.resources.objects.SWGObject; import engine.resources.scene.Point3D; import main.NGECore; @@ -250,7 +251,7 @@ public class Forager { adversaryRoll=999; // adversaryRoll=999; // To test TMs - + spawnGoon(forager); if (adversaryRoll<14) { // 14 100 // To test TMs int adversaryTypeRoll = new Random().nextInt(100); if (adversaryTypeRoll<50){ @@ -417,18 +418,17 @@ public class Forager { } - goon.addObserver(forager); +// goon.addObserver(forager); goon.setCustomName(name); goon.setLevel(forager.getLevel()); - goon.setOptions(Options.AGGRESSIVE, true); - goon.setOptions(Options.ATTACKABLE, true); +// goon.setOptions(Options.AGGRESSIVE, true); +// goon.setOptions(Options.ATTACKABLE, true); AIActor actor = (AIActor) goon.getAttachment("AI"); actor.addDefender(forager); forager.sendSystemMessage("@foraging/forage_enemy:" + barkString, DisplayType.Broadcast); - //OutOfBand oob = OutOfBand.ProsePackage("@foraging/forage_enemy:" + barkString)); - OutOfBand oob = OutOfBand.ProsePackage("@jawa_trader:cant_understand"); - forager.sendSystemMessage("@jawa_trader:cant_understand", DisplayType.Broadcast); - NGECore.getInstance().chatService.spatialChat(goon, forager, "", (short)0x0, (short)0x0, 1, oob); + OutOfBand oob = OutOfBand.ProsePackage("@foraging/forage_enemy:" + barkString); + Stf stf = new Stf("@foraging/forage_enemy:" + barkString); + NGECore.getInstance().chatService.spatialChat(goon, forager, stf.getStfValue(), (short)0x0, (short)0x0, 1, oob); } public void handleGuardSpawn(CreatureObject owner, TangibleObject map){ diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index c3c622a8..7efade90 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -80,8 +80,9 @@ public class CommandService implements INetworkDispatch { if (actor == null) return false; - if (actor.getClient() == null) - return false; +// if (actor.getClient() == null) +// return false; + // Please consider that AI is calling callCommand too. Thank you. if (command == null) return false; @@ -95,6 +96,7 @@ public class CommandService implements INetworkDispatch { if (actor.hasCooldown(command.getCooldownGroup()) || actor.hasCooldown(command.getCommandName())) return false; + // Causes this service method to return with false after equipping a rifle, not allowing to unequip it anymore // because the client seems to consider rifles invalidweapons for an unkown reason @@ -115,7 +117,7 @@ public class CommandService implements INetworkDispatch { return false; } } - + switch (command.getTargetType()) { case 0: // Target Not Used For This Command break; @@ -251,7 +253,7 @@ public class CommandService implements INetworkDispatch { default: break; } - + switch (command.getTarget()) { case 0: // Ally Only if (target == null) { @@ -318,7 +320,7 @@ public class CommandService implements INetworkDispatch { e.printStackTrace(); } } - + if(command instanceof CombatCommand) { try { processCommand(actor, target, (BaseSWGCommand) command.clone(), actionCounter, commandArgs); diff --git a/src/services/travel/TravelService.java b/src/services/travel/TravelService.java index 14fe66b7..8ced7a88 100644 --- a/src/services/travel/TravelService.java +++ b/src/services/travel/TravelService.java @@ -329,8 +329,8 @@ public class TravelService implements INetworkDispatch { Planet planet = core.terrainService.getPlanetByName(tp.getPlanetName()); Point3D spawnLocation = SpawnPoint.getRandomPosition(tp.getLocation(), 5, 20, actor.getPlanetId()); - core.simulationService.transferToPlanet(actor, planet, spawnLocation, new Quaternion(0, 0, 0, 0), null); - + float positionY = core.terrainService.getHeight(actor.getPlanetId(), spawnLocation.x, spawnLocation.z); + core.simulationService.transferToPlanet(actor, planet, new Point3D(spawnLocation.x, positionY, spawnLocation.z), new Quaternion(0, 0, 0, 0), null); }