Instructions Jenkins Doxygen

[Added] training creature pets new commands will not always succeed, but 02/1202/2
authorIvojedi <ivojedi@swgemu.com>
Fri, 29 Nov 2013 15:52:10 +0000 (07:52 -0800)
committergerrit <gerrit@review.swgemu.com>
Fri, 29 Nov 2013 18:32:54 +0000 (18:32 +0000)
will grant xp when it does

Change-Id: Ia37a09120db8e43a0d8b7fca846dad10712eb540

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

index ad6f713..b23a65c 100644 (file)
@@ -751,16 +751,44 @@ void PetControlDeviceImplementation::handleCommandTraining(CreatureObject* speak
 
        // Train command
        if (petType == CREATUREPET) {
-               // TODO Implement skill check to train
-               // TODO Reward XP for training
+               bool alreadyTrained = trainedCommands.contains(trainingCommand);
+
+               if (!alreadyTrained) {
+                       bool success = false;
+
+                       int skill = speaker->getSkillMod("tame_level");
+                       int roll = System::random(skill + 30);
+
+                       if (skill > roll)
+                               success = true;
+
+                       if (!success) {
+                               pet->showFlyText("npc_reaction/flytext","confused", 204, 0, 0);  // "?!!?!?!"
+                               speaker->sendSystemMessage("@pet/pet_menu:pet_nolearn"); // Your pet doesn't seem to understand you.
+                               return;
+                       }
+               }
 
                // Success
                trainedCommands.put( trainingCommand, message );
                pet->showFlyText("npc_reaction/flytext","threaten", 204, 0, 0);  // "!"
+               speaker->sendSystemMessage("@pet/pet_menu:pet_learn"); // You teach your pet a new command.
+
+               if (!alreadyTrained) {
+                       CreatureTemplate* creatureTemplate = pet->getCreatureTemplate();
+
+                       if (creatureTemplate == NULL)
+                               return;
+
+                       ZoneServer* zoneServer = speaker->getZoneServer();
+                       PlayerManager* playerManager = zoneServer->getPlayerManager();
+                       playerManager->awardExperience(speaker, "creaturehandler", 10 * creatureTemplate->getLevel());
+               }
        }
        else{
                trainedCommands.put( trainingCommand, message );
                pet->showFlyText("npc_reaction/flytext","threaten", 204, 0, 0);  // "!"
+               speaker->sendSystemMessage("@pet/pet_menu:pet_learn"); // You teach your pet a new command.
        }
 
        // TODO set pet name