Instructions Jenkins Doxygen

[added] follow other pet command 01/1201/1
authorKlivian <klivian@hotmail.com>
Fri, 29 Nov 2013 15:56:43 +0000 (15:56 +0000)
committerKlivian <klivian@hotmail.com>
Fri, 29 Nov 2013 15:56:43 +0000 (15:56 +0000)
Change-Id: I6e5c2807578061209de39acfd0e605be1366daaf

MMOCoreORB/src/server/zone/objects/intangible/PetControlDevice.idl
MMOCoreORB/src/server/zone/objects/intangible/PetControlDeviceImplementation.cpp

index d11e342..1b38ecf 100644 (file)
@@ -94,7 +94,7 @@ class PetControlDevice extends ControlDevice {
        @dereferenced 
        protected VectorMap<unsigned int, string> trainedCommands;
        
-       // Command 
+       // Command to be trained
        protected unsigned int trainingCommand;
 
        public PetControlDevice() {
@@ -201,6 +201,15 @@ class PetControlDevice extends ControlDevice {
        public native void follow(CreatureObject player);
        
        /**
+        * Handles followother command
+        * @pre { }
+        * @post { }
+        * @param object player creature commanding
+        */
+       @local
+       public native void followOther(CreatureObject player);  
+       
+       /**
         * Handles stay command
         * @pre { }
         * @post { }
index 6d5fcb5..ad6f713 100644 (file)
@@ -685,7 +685,7 @@ void PetControlDeviceImplementation::handleSpatialChat(CreatureObject* speaker,
                speaker->sendSystemMessage("FRIEND pet command is not yet implemented.");
        }
        else if( trainedCommands.contains(FOLLOWOTHER) && trainedCommands.get(FOLLOWOTHER) == message ){
-               speaker->sendSystemMessage("FOLLOWOTHER pet command is not yet implemented.");
+               followOther(speaker);
        }
        else if( trainedCommands.contains(TRICK1) && trainedCommands.get(TRICK1) == message ){
                speaker->sendSystemMessage("TRICK1 pet command is not yet implemented.");
@@ -837,6 +837,44 @@ void PetControlDeviceImplementation::follow(CreatureObject* player){
 
 }
 
+void PetControlDeviceImplementation::followOther(CreatureObject* player){
+
+       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 player
+       Reference<SceneObject*> target = server->getObject(targetID, true).castTo<SceneObject*>();
+       if (target == NULL || !target->isPlayerCreature() ) {
+               pet->showFlyText("npc_reaction/flytext","confused", 204, 0, 0);  // "?!!?!?!"
+               return;
+       }
+
+       // Check if droid has power
+       if( petType == DROIDPET ){
+               DroidObject* droidPet = cast<DroidObject*>(pet);
+               if( droidPet == NULL )
+                       return;
+
+               if( !droidPet->hasPower() ){
+                       pet->showFlyText("npc_reaction/flytext","low_power", 204, 0, 0);  // "*Low Power*"
+                       return;
+               }
+       }
+
+       pet->setFollowObject(target);
+
+}
+
 void PetControlDeviceImplementation::stay(CreatureObject* player){
 
        ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();