From a52d01652c240f57f4a73106bd11be6c234b2ead Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Sun, 17 Aug 2014 13:28:23 +0200 Subject: [PATCH 1/2] Fixed broken command service --- scripts/mobiles/forage/goon.py | 10 +++---- src/services/ai/states/AttackState.java | 3 +++ src/services/combat/CombatService.java | 1 + src/services/command/CommandService.java | 33 +++++++++++++++++------- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/scripts/mobiles/forage/goon.py b/scripts/mobiles/forage/goon.py index 2ce75838..67637f5d 100644 --- a/scripts/mobiles/forage/goon.py +++ b/scripts/mobiles/forage/goon.py @@ -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/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('rangedShotrifle') + mobileTemplate.setDefaultAttack('rangedShot') mobileTemplate.setAttacks(attacks) core.spawnService.addMobileTemplate('forage_goon', mobileTemplate) diff --git a/src/services/ai/states/AttackState.java b/src/services/ai/states/AttackState.java index 203b490b..f3b19447 100644 --- a/src/services/ai/states/AttackState.java +++ b/src/services/ai/states/AttackState.java @@ -261,13 +261,16 @@ public class AttackState extends AIState { if (attacks==null) { //if(attacks.size() == 0) { + System.out.println("AI calls default attack1" + actor.getMobileTemplate().getDefaultAttack()); core.commandService.callCommand(creature, actor.getMobileTemplate().getDefaultAttack(), target, ""); } else { Random rand = new Random(); if(rand.nextFloat() <= 0.33f) { + System.out.println("AI calls special attack"); if(attacks.size() > 0) core.commandService.callCommand(creature, attacks.get(rand.nextInt(attacks.size())), target, ""); } else { + System.out.println("AI calls default attack2 " + actor.getMobileTemplate().getDefaultAttack()); core.commandService.callCommand(creature, actor.getMobileTemplate().getDefaultAttack(), target, ""); } } diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index beb6d6c0..b61e2a0d 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -1301,6 +1301,7 @@ public class CombatService implements INetworkDispatch { return; } synchronized(target.getMutex()) { + System.out.println("THIS SHOULD BE RUN!!! " + (target.getHealth() - damage)); target.setHealth(target.getHealth() - damage); } diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 4126b474..80620cd5 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -76,7 +76,7 @@ public class CommandService implements INetworkDispatch { } public boolean callCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { - + if (actor == null) return false; @@ -87,14 +87,20 @@ public class CommandService implements INetworkDispatch { if (command == null) return false; - if (command.getCharacterAbility().length() > 0 && !actor.hasAbility(command.getCharacterAbility())) + if (actor.isPlayer() && command.getCharacterAbility().length() > 0 && !actor.hasAbility(command.getCharacterAbility())){ + System.out.println("RETURN 1! " + command.getCharacterAbility()); return false; + } - if (command.isDisabled()) + if (command.isDisabled()){ + System.out.println("RETURN 2!"); return false; + } - if (actor.hasCooldown(command.getCooldownGroup()) || actor.hasCooldown(command.getCommandName())) + if (actor.hasCooldown(command.getCooldownGroup()) || actor.hasCooldown(command.getCommandName())){ + System.out.println("RETURN 3!"); return false; + } // Causes this service method to return with false after equipping a rifle, not allowing to unequip it anymore @@ -114,10 +120,11 @@ public class CommandService implements INetworkDispatch { for (byte locomotion : command.getInvalidLocomotions()) { if (actor.getLocomotion() == locomotion) { + System.out.println("RETURN 4!"); return false; } } - + System.out.println("IN CALLCOMMAND!"); switch (command.getTargetType()) { case 0: // Target Not Used For This Command break; @@ -253,7 +260,7 @@ public class CommandService implements INetworkDispatch { default: break; } - + System.out.println("IN CALLCOMMAND2!"); switch (command.getTarget()) { case 0: // Ally Only if (target == null) { @@ -302,7 +309,7 @@ public class CommandService implements INetworkDispatch { default: break; } - + System.out.println("IN CALLCOMMAND! processCommand55"); if (command.shouldCallOnTarget()) { if (target == null || !(target instanceof CreatureObject)) { return false; @@ -323,13 +330,16 @@ public class CommandService implements INetworkDispatch { if(command instanceof CombatCommand) { try { + System.out.println("IN CALLCOMMAND! processCommand"); processCommand(actor, target, (BaseSWGCommand) command.clone(), actionCounter, commandArgs); } catch (CloneNotSupportedException e) { e.printStackTrace(); } } - else + else { + System.out.println("IN CALLCOMMAND! No combat cmdprocessCommand"); processCommand(actor, target, command, actionCounter, commandArgs); + } return true; @@ -635,6 +645,7 @@ public class CommandService implements INetworkDispatch { for (BaseSWGCommand command : commands) { if (command.getCommandName().equalsIgnoreCase(name)) { + System.out.println("commmand " + command.getCommandName()); return command; } } @@ -654,10 +665,12 @@ public class CommandService implements INetworkDispatch { if (commandName.equalsIgnoreCase(name)) { if (isCombatCommand(commandName)) { CombatCommand command = new CombatCommand(commandName); + System.out.println("commmand " + command.getCommandName()); commandLookup.add(command); return command; } else { BaseSWGCommand command = new BaseSWGCommand(commandName); + System.out.println("commmand " + command.getCommandName()); commandLookup.add(command); return command; } @@ -689,7 +702,7 @@ public class CommandService implements INetworkDispatch { } public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { - + System.out.println("NPC command name1 " + command.getCommandName()); if (command.getGodLevel() > 0 || command.getCommandName().equals("setgodmode") || command.getCommandName().equals("server") || command.getCommandName().equals("teleport") || command.getCommandName().equals("teleportto") || command.getCommandName().equals("teleporttarget") ) { String accessLevel = core.adminService.getAccessLevelFromDB(actor.getClient().getAccountId()); @@ -710,6 +723,7 @@ public class CommandService implements INetworkDispatch { } if (!levelHasCommand) { + System.out.println("I am an NPC and can't sendSystemMessages " + actor.getCustomName()); actor.sendSystemMessage(" \\#FE2EF7 [GM] \\#FFFFFF " + command.getCommandName() + ": You do not have permission to use this command.", (byte) 0); return; } @@ -727,6 +741,7 @@ public class CommandService implements INetworkDispatch { } if (command instanceof CombatCommand) { + System.out.println("NPC command name2 " + command.getCommandName()); processCombatCommand(actor, target, (CombatCommand) command, actionCounter, commandArgs); } else if (FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName().toLowerCase() + ".py")) { From cb6bbe37ea2cd96249dfe7786fbc47a42b1f36a2 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Sun, 17 Aug 2014 14:35:17 +0200 Subject: [PATCH 2/2] Removed debug messages --- src/main/NGECore.java | 12 ++++++------ src/services/ai/states/AttackState.java | 4 ---- src/services/combat/CombatService.java | 1 - src/services/command/CommandService.java | 18 ++++-------------- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/main/NGECore.java b/src/main/NGECore.java index d68e1493..cd3208c1 100644 --- a/src/main/NGECore.java +++ b/src/main/NGECore.java @@ -266,6 +266,12 @@ public class NGECore { config = DefaultConfig.getConfig(); } + DevLogQueuer devLogQueuer = new DevLogQueuer(); + + CharonPacketLogger packetLogger; + if (PACKET_DEBUG) + packetLogger = new CharonPacketLogger(); + options = new Config(); options.setFilePath("options.cfg"); if (!(options.loadConfigFile())) { @@ -573,12 +579,6 @@ public class NGECore { //battlefieldService = new BattlefieldService(this); adminService = new AdminService(this); - DevLogQueuer devLogQueuer = new DevLogQueuer(); - - CharonPacketLogger packetLogger; - if (PACKET_DEBUG) - packetLogger = new CharonPacketLogger(); - didServerCrash = false; System.out.println("Started Server."); cleanupCreatureODB(); diff --git a/src/services/ai/states/AttackState.java b/src/services/ai/states/AttackState.java index 087905b7..e5d64038 100644 --- a/src/services/ai/states/AttackState.java +++ b/src/services/ai/states/AttackState.java @@ -262,17 +262,13 @@ public class AttackState extends AIState { creature.setIntendedTarget(target.getObjectId()); if (attacks==null) { - //if(attacks.size() == 0) { - System.out.println("AI calls default attack1" + actor.getMobileTemplate().getDefaultAttack()); core.commandService.callCommand(creature, actor.getMobileTemplate().getDefaultAttack(), target, ""); } else { Random rand = new Random(); if(rand.nextFloat() <= 0.33f) { - System.out.println("AI calls special attack"); if(attacks.size() > 0) core.commandService.callCommand(creature, attacks.get(rand.nextInt(attacks.size())), target, ""); } else { - System.out.println("AI calls default attack2 " + actor.getMobileTemplate().getDefaultAttack()); core.commandService.callCommand(creature, actor.getMobileTemplate().getDefaultAttack(), target, ""); } } diff --git a/src/services/combat/CombatService.java b/src/services/combat/CombatService.java index 5979be39..fbd5fedf 100644 --- a/src/services/combat/CombatService.java +++ b/src/services/combat/CombatService.java @@ -1301,7 +1301,6 @@ public class CombatService implements INetworkDispatch { return; } synchronized(target.getMutex()) { - System.out.println("THIS SHOULD BE RUN!!! " + (target.getHealth() - damage)); target.setHealth(target.getHealth() - damage); } diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 25bebcf1..72dbb552 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -85,17 +85,14 @@ public class CommandService implements INetworkDispatch { return false; if (actor.isPlayer() && command.getCharacterAbility().length() > 0 && !actor.hasAbility(command.getCharacterAbility())){ - System.out.println("RETURN 1! " + command.getCharacterAbility()); return false; } if (command.isDisabled()){ - System.out.println("RETURN 2!"); return false; } if (actor.hasCooldown(command.getCooldownGroup()) || actor.hasCooldown(command.getCommandName())){ - System.out.println("RETURN 3!"); return false; } @@ -117,11 +114,10 @@ public class CommandService implements INetworkDispatch { for (byte locomotion : command.getInvalidLocomotions()) { if (actor.getLocomotion() == locomotion) { - System.out.println("RETURN 4!"); return false; } } - System.out.println("IN CALLCOMMAND!"); + switch (command.getTargetType()) { case 0: // Target Not Used For This Command break; @@ -257,7 +253,7 @@ public class CommandService implements INetworkDispatch { default: break; } - System.out.println("IN CALLCOMMAND2!"); + switch (command.getTarget()) { case 0: // Ally Only if (target == null) { @@ -306,7 +302,7 @@ public class CommandService implements INetworkDispatch { default: break; } - System.out.println("IN CALLCOMMAND! processCommand55"); + if (command.shouldCallOnTarget()) { if (target == null || !(target instanceof CreatureObject)) { return false; @@ -327,14 +323,12 @@ public class CommandService implements INetworkDispatch { if(command instanceof CombatCommand) { try { - System.out.println("IN CALLCOMMAND! processCommand"); processCommand(actor, target, (BaseSWGCommand) command.clone(), actionCounter, commandArgs); } catch (CloneNotSupportedException e) { e.printStackTrace(); } } else { - System.out.println("IN CALLCOMMAND! No combat cmdprocessCommand"); processCommand(actor, target, command, actionCounter, commandArgs); } @@ -643,7 +637,6 @@ public class CommandService implements INetworkDispatch { for (BaseSWGCommand command : commands) { if (command.getCommandName().equalsIgnoreCase(name)) { - System.out.println("commmand " + command.getCommandName()); return command; } } @@ -663,12 +656,10 @@ public class CommandService implements INetworkDispatch { if (commandName.equalsIgnoreCase(name)) { if (isCombatCommand(commandName)) { CombatCommand command = new CombatCommand(commandName); - System.out.println("commmand " + command.getCommandName()); commandLookup.add(command); return command; } else { BaseSWGCommand command = new BaseSWGCommand(commandName); - System.out.println("commmand " + command.getCommandName()); commandLookup.add(command); return command; } @@ -700,7 +691,7 @@ public class CommandService implements INetworkDispatch { } public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { - System.out.println("NPC command name1 " + command.getCommandName()); + if (command.getGodLevel() > 0 || command.getCommandName().equals("setgodmode") || command.getCommandName().equals("server") || command.getCommandName().equals("teleport") || command.getCommandName().equals("teleportto") || command.getCommandName().equals("teleporttarget") ) { String accessLevel = core.adminService.getAccessLevelFromDB(actor.getClient().getAccountId()); @@ -739,7 +730,6 @@ public class CommandService implements INetworkDispatch { } if (command instanceof CombatCommand) { - System.out.println("NPC command name2 " + command.getCommandName()); processCombatCommand(actor, target, (CombatCommand) command, actionCounter, commandArgs); } else if (FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName().toLowerCase() + ".py")) {