Instructions Jenkins Doxygen

[Added] PetGroupCommand, PetRechargeOtherCommand, and PetStayCommand 81/1281/1
authorIvojedi <ivojedi@swgemu.com>
Thu, 19 Dec 2013 18:14:17 +0000 (10:14 -0800)
committerIvojedi <ivojedi@swgemu.com>
Thu, 19 Dec 2013 18:14:17 +0000 (10:14 -0800)
classes
[Moved] group, recharge other, and stay pet commands to use creo queue
command framework

Change-Id: I6209e1f380875ce7f323b02a2d7135c3f8dd3617

MMOCoreORB/src/server/zone/managers/objectcontroller/command/CommandConfigManager.cpp
MMOCoreORB/src/server/zone/objects/creature/commands/pet/PetGroupCommand.h [new file with mode: 0644]
MMOCoreORB/src/server/zone/objects/creature/commands/pet/PetRechargeOtherCommand.h [new file with mode: 0644]
MMOCoreORB/src/server/zone/objects/creature/commands/pet/PetStayCommand.h [new file with mode: 0644]
MMOCoreORB/src/server/zone/objects/intangible/PetControlDevice.idl
MMOCoreORB/src/server/zone/objects/intangible/PetControlDeviceImplementation.cpp

index e8c061c..7da8196 100644 (file)
@@ -48,6 +48,9 @@ which carries forward this exception.
 #include "server/zone/objects/creature/commands/effect/DotEffect.h"
 #include "server/zone/objects/creature/commands/effect/CommandEffect.h"
 
+#include "server/zone/objects/creature/commands/pet/PetGroupCommand.h"
+#include "server/zone/objects/creature/commands/pet/PetRechargeOtherCommand.h"
+#include "server/zone/objects/creature/commands/pet/PetStayCommand.h"
 #include "server/zone/objects/creature/commands/pet/PetTrickCommand.h"
 #include "server/zone/objects/creature/commands/pet/PetTransferCommand.h"
 
@@ -340,6 +343,9 @@ void CommandConfigManager::registerSpecialCommands(CommandList* sCommands) {
        createCommand(String("defaultDroidAttack").toLowerCase())->setCommandGroup(0xe1c9a54a);
 
        //Pet commands
+       createCommand(String("petGroup").toLowerCase())->setCommandGroup(0xe1c9a54a);
+       createCommand(String("petRechargeOther").toLowerCase())->setCommandGroup(0xe1c9a54a);
+       createCommand(String("petStay").toLowerCase())->setCommandGroup(0xe1c9a54a);
        createCommand(String("petTransfer").toLowerCase())->setCommandGroup(0xe1c9a54a);
        createCommand(String("petTrick").toLowerCase())->setCommandGroup(0xe1c9a54a);
 }
@@ -1497,6 +1503,9 @@ void CommandConfigManager::registerCommands() {
        commandFactory.registerCommand<RequestSpaceTrainerCommand>(String("requestSpaceTrainer").toLowerCase());
 
        //pet commands
+       commandFactory.registerCommand<PetGroupCommand>(String("petGroup").toLowerCase());
+       commandFactory.registerCommand<PetRechargeOtherCommand>(String("petRechargeOther").toLowerCase());
+       commandFactory.registerCommand<PetStayCommand>(String("petStay").toLowerCase());
        commandFactory.registerCommand<PetTransferCommand>(String("petTransfer").toLowerCase());
        commandFactory.registerCommand<PetTrickCommand>(String("petTrick").toLowerCase());
 }
diff --git a/MMOCoreORB/src/server/zone/objects/creature/commands/pet/PetGroupCommand.h b/MMOCoreORB/src/server/zone/objects/creature/commands/pet/PetGroupCommand.h
new file mode 100644 (file)
index 0000000..9955df9
--- /dev/null
@@ -0,0 +1,38 @@
+
+#ifndef PETGROUPCOMMAND_H_
+#define PETGROUPCOMMAND_H_
+
+#include "server/zone/objects/creature/commands/QueueCommand.h"
+#include "server/zone/objects/creature/AiAgent.h"
+
+class PetGroupCommand : public QueueCommand {
+public:
+       PetGroupCommand(const String& name, ZoneProcessServer* server)
+               : QueueCommand(name, server) {
+       }
+
+
+       int doQueueCommand(CreatureObject* creature, const uint64& target, const UnicodeString& arguments) {
+
+               ManagedReference<AiAgent*> pet = cast<AiAgent*>(creature);
+               if( pet == NULL )
+                       return GENERALERROR;
+
+               ManagedReference< CreatureObject*> player = pet->getLinkedCreature().get();
+               if( player == NULL )
+                       return GENERALERROR;
+
+               ManagedReference<GroupObject*> group = pet->getGroup();
+               if (group == NULL) {
+                       Locker clocker(player, pet);
+                       GroupManager::instance()->inviteToGroup(player, pet);
+               } else
+                       GroupManager::instance()->leaveGroup(group, pet);
+
+               return SUCCESS;
+       }
+
+};
+
+
+#endif /* PETGROUPCOMMAND_H_ */
diff --git a/MMOCoreORB/src/server/zone/objects/creature/commands/pet/PetRechargeOtherCommand.h b/MMOCoreORB/src/server/zone/objects/creature/commands/pet/PetRechargeOtherCommand.h
new file mode 100644 (file)
index 0000000..5a071b1
--- /dev/null
@@ -0,0 +1,66 @@
+
+#ifndef PETRECHARGEOTHERCOMMAND_H_
+#define PETRECHARGEOTHERCOMMAND_H_
+
+#include "server/zone/objects/creature/commands/QueueCommand.h"
+#include "server/zone/objects/creature/AiAgent.h"
+#include "server/zone/objects/creature/DroidObject.h"
+
+class PetRechargeOtherCommand : public QueueCommand {
+public:
+       PetRechargeOtherCommand(const String& name, ZoneProcessServer* server)
+               : QueueCommand(name, server) {
+       }
+
+
+       int doQueueCommand(CreatureObject* creature, const uint64& target, const UnicodeString& arguments) {
+
+               ManagedReference<PetControlDevice*> controlDevice = creature->getControlDevice().castTo<PetControlDevice*>();
+
+               if (controlDevice == NULL)
+                       return GENERALERROR;
+
+               // Droid specific command
+               if( controlDevice->getPetType() != PetControlDevice::DROIDPET )
+                       return GENERALERROR;
+
+               ManagedReference<DroidObject*> droidPet = cast<DroidObject*>(creature);
+               if( droidPet == NULL )
+                       return GENERALERROR;
+
+               // Target must be a droid
+               Reference<DroidObject*> targetDroid = server->getZoneServer()->getObject(target, true).castTo<DroidObject*>();
+               if (targetDroid == NULL || !targetDroid->isDroidObject() ) {
+                       droidPet->showFlyText("npc_reaction/flytext","confused", 204, 0, 0);  // "?!!?!?!"
+                       return GENERALERROR;
+               }
+
+               // Check range between droids
+               if (!droidPet->isInRange(targetDroid, 30.0f)){ // Same range as auto-repair
+                       droidPet->showFlyText("npc_reaction/flytext","confused", 204, 0, 0);  // "?!!?!?!"
+                       return GENERALERROR;
+               }
+
+               // Target can't be this droid
+               if (droidPet == targetDroid ) {
+                       droidPet->showFlyText("npc_reaction/flytext","confused", 204, 0, 0);  // "?!!?!?!"
+                       return GENERALERROR;
+               }
+
+               // Check if droid has power
+               if( !droidPet->hasPower() ){
+                       droidPet->showFlyText("npc_reaction/flytext","low_power", 204, 0, 0);  // "*Low Power*"
+                       return GENERALERROR;
+               }
+
+               // Recharge other droid
+               Locker clocker(targetDroid, droidPet);
+               droidPet->rechargeOtherDroid( targetDroid );
+
+               return SUCCESS;
+       }
+
+};
+
+
+#endif /* PETRECHARGEOTHERCOMMAND_H_ */
diff --git a/MMOCoreORB/src/server/zone/objects/creature/commands/pet/PetStayCommand.h b/MMOCoreORB/src/server/zone/objects/creature/commands/pet/PetStayCommand.h
new file mode 100644 (file)
index 0000000..6ed7c90
--- /dev/null
@@ -0,0 +1,29 @@
+
+#ifndef PETSTAYCOMMAND_H_
+#define PETSTAYCOMMAND_H_
+
+#include "server/zone/objects/creature/commands/QueueCommand.h"
+#include "server/zone/objects/creature/AiAgent.h"
+
+class PetStayCommand : public QueueCommand {
+public:
+       PetStayCommand(const String& name, ZoneProcessServer* server)
+               : QueueCommand(name, server) {
+       }
+
+
+       int doQueueCommand(CreatureObject* creature, const uint64& target, const UnicodeString& arguments) {
+
+               ManagedReference<AiAgent*> pet = cast<AiAgent*>(creature);
+               if( pet == NULL )
+                       return GENERALERROR;
+
+               pet->setOblivious();
+
+               return SUCCESS;
+       }
+
+};
+
+
+#endif /* PETSTAYCOMMAND_H_ */
index 6d237c6..5327f02 100644 (file)
@@ -231,33 +231,6 @@ class PetControlDevice extends ControlDevice {
        public native void followOther(CreatureObject player);  
 
        /**
-        * Handles group command
-        * @pre { }
-        * @post { }
-        * @param object player creature commanding
-        */
-       @local
-       public native void group(CreatureObject player);
-
-       /**
-        * Handles stay command
-        * @pre { }
-        * @post { }
-        * @param object player creature commanding
-        */
-       @local
-       public native void stay(CreatureObject player);
-       
-       /**
-        * Handles recharge other command
-        * @pre { }
-        * @post { }
-        * @param object player creature commanding
-        */
-       @local
-       public native void rechargeOther(CreatureObject player);
-       
-       /**
         * Enqueues a pet command
         * @pre { }
         * @post { }
index 8cf3e00..785c484 100644 (file)
@@ -712,7 +712,7 @@ void PetControlDeviceImplementation::handleChat(CreatureObject* speaker, const S
 
        // Handle trained command
        if( trainedCommands.contains(STAY) && trainedCommands.get(STAY) == message ){
-               stay( speaker );
+               enqueuePetCommand(speaker, String("petStay").toLowerCase().hashCode(), "");
        }
        else if( trainedCommands.contains(FOLLOW) && trainedCommands.get(FOLLOW) == message ){
                follow( speaker );
@@ -757,10 +757,10 @@ void PetControlDeviceImplementation::handleChat(CreatureObject* speaker, const S
                speaker->sendSystemMessage("RANGED_ATTACK pet command is not yet implemented.");
        }
        else if( trainedCommands.contains(GROUP) && trainedCommands.get(GROUP) == message ){
-               group(speaker);
+               enqueueOwnerOnlyPetCommand(speaker, String("petGroup").toLowerCase().hashCode(), "");
        }
        else if( trainedCommands.contains(RECHARGEOTHER) && trainedCommands.get(RECHARGEOTHER) == message ){
-               rechargeOther(speaker);
+               enqueuePetCommand(speaker, String("petRechargeOther").toLowerCase().hashCode(), "");
        }
        else if( trainedCommands.contains(TRANSFER) && trainedCommands.get(TRANSFER) == message ){
                enqueueOwnerOnlyPetCommand(speaker, String("petTransfer").toLowerCase().hashCode(), "");
@@ -1000,90 +1000,6 @@ void PetControlDeviceImplementation::followOther(CreatureObject* player){
 
 }
 
-void PetControlDeviceImplementation::group(CreatureObject* player) {
-
-       ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
-       if (controlledObject == NULL || !controlledObject->isAiAgent())
-               return;
-
-       ManagedReference<AiAgent*> pet = cast<AiAgent*>(controlledObject.get());
-       if( pet == NULL )
-               return;
-
-       ManagedReference<GroupObject*> group = pet->getGroup();
-       if (group == NULL)
-               GroupManager::instance()->inviteToGroup(player, pet);
-       else
-               GroupManager::instance()->leaveGroup(group, pet);
-}
-
-void PetControlDeviceImplementation::stay(CreatureObject* player){
-
-       ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
-       if (controlledObject == NULL || !controlledObject->isAiAgent())
-               return;
-
-       ManagedReference<AiAgent*> pet = cast<AiAgent*>(controlledObject.get());
-       if( pet == NULL )
-               return;
-
-       pet->setOblivious();
-}
-
-void PetControlDeviceImplementation::rechargeOther(CreatureObject* player){
-
-       // Droid specific command
-       if( petType != DROIDPET )
-               return;
-
-       ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
-       if (controlledObject == NULL || !controlledObject->isAiAgent())
-               return;
-
-       AiAgent* pet = cast<AiAgent*>(controlledObject.get());
-       if( pet == NULL )
-               return;
-
-       uint64 targetID = player->getTargetID();
-       ZoneServer* server = player->getZoneServer();
-       if (server == NULL)
-               return;
-
-       // Target must be a droid
-       Reference<DroidObject*> target = server->getObject(targetID, true).castTo<DroidObject*>();
-       if (target == NULL || !target->isDroidObject() ) {
-               pet->showFlyText("npc_reaction/flytext","confused", 204, 0, 0);  // "?!!?!?!"
-               return;
-       }
-
-       DroidObject* droidPet = cast<DroidObject*>(pet);
-       if( droidPet == NULL )
-               return;
-
-       // Check range between droids
-       if (!droidPet->isInRange(target, 30.0f)){ // Same range as auto-repair
-               pet->showFlyText("npc_reaction/flytext","confused", 204, 0, 0);  // "?!!?!?!"
-               return;
-       }
-
-       // Target can't be this droid
-       if (droidPet == target ) {
-               pet->showFlyText("npc_reaction/flytext","confused", 204, 0, 0);  // "?!!?!?!"
-               return;
-       }
-
-       // Check if droid has power
-       if( !droidPet->hasPower() ){
-               pet->showFlyText("npc_reaction/flytext","low_power", 204, 0, 0);  // "*Low Power*"
-               return;
-       }
-
-       // Recharge other droid
-       Locker clocker(target, player);
-       droidPet->rechargeOtherDroid( target );
-
-}
-
 void PetControlDeviceImplementation::enqueuePetCommand(CreatureObject* player, uint32 command, const String& args){
 
        ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();