Instructions Jenkins Doxygen

[Changed] /kill does not work on pets 44/1144/2
authorIvojedi <ivojedi@swgemu.com>
Fri, 22 Nov 2013 21:47:30 +0000 (13:47 -0800)
committergerrit <gerrit@review.swgemu.com>
Sat, 23 Nov 2013 07:12:29 +0000 (07:12 +0000)
[Changed] /killplayer now works on pets
[changed] /gmrevive can now revive pets or buff creature pets

Change-Id: I70ca2136e3451283db7c2db7e4b09a66d1e95c9d

MMOCoreORB/src/server/zone/managers/creature/CreatureManagerImplementation.cpp
MMOCoreORB/src/server/zone/managers/player/PlayerManagerImplementation.cpp
MMOCoreORB/src/server/zone/objects/creature/commands/GmReviveCommand.h
MMOCoreORB/src/server/zone/objects/creature/commands/KillCommand.h
MMOCoreORB/src/server/zone/objects/creature/commands/KillPlayerCommand.h

index 37b1dc9..78a4018 100644 (file)
@@ -500,6 +500,8 @@ int CreatureManagerImplementation::notifyDestruction(TangibleObject* destructor,
                shouldRescheduleCorpseDestruction = playerManager->shouldRescheduleCorpseDestruction(player, destructedObject);
 
                if (pet) {
+                       destructedObject->clearBuffs(true);
+
                        ManagedReference<PetControlDevice*> petControlDevice = destructedObject->getControlDevice().get().castTo<PetControlDevice*>();
 
                        if (petControlDevice != NULL && petControlDevice->getPetType() != PetControlDevice::DROIDPET)
index 1cde9fc..2a6c7c2 100644 (file)
@@ -3530,6 +3530,6 @@ void PlayerManagerImplementation::enhanceCharacter(CreatureObject* player) {
        message = message && doEnhanceCharacter(0x2E77F586, player, performanceBuff, performanceDuration, BuffType::PERFORMANCE, 7); // performance_enhance_music_focus
        message = message && doEnhanceCharacter(0x3EC6FCB6, player, performanceBuff, performanceDuration, BuffType::PERFORMANCE, 8); // performance_enhance_music_willpower
 
-       if (message)
+       if (message && player->isPlayerCreature())
                player->sendSystemMessage("An unknown force strengthens you for battles yet to come.");
 }
index 64ded62..825e2dc 100755 (executable)
@@ -64,7 +64,7 @@ public:
 
                try {
                        StringTokenizer args(arguments.toString());
-                       ManagedReference<CreatureObject*> player = NULL;
+                       ManagedReference<CreatureObject*> patient = NULL;
 
                        ManagedReference<SceneObject*> object = server->getZoneServer()->getObject(creature->getTargetID());
 
@@ -72,15 +72,15 @@ public:
 
                        if (!args.hasMoreTokens()) { // No arguments passed
 
-                               if (object != NULL && object->isPlayerCreature()) { // Target is a player, rez target
-                                       player = cast<CreatureObject*>( object.get());
-                                       revivePlayer(creature, player);
+                               if (object != NULL && (object->isPlayerCreature() || object->isPet())) { // Target is a player or pet, rez target
+                                       patient = cast<CreatureObject*>( object.get());
+                                       revivePatient(creature, patient);
 
                                } else if (object == NULL) { // No target, rez self
-                                       player = creature;
-                                       revivePlayer(creature, player);
+                                       patient = creature;
+                                       revivePatient(creature, patient);
 
-                               } else { // Target is not a player
+                               } else { // Target is not a player or pet
                                        creature->sendSystemMessage("Syntax: /gmrevive [buff] [ [<name>] | [area [<range>] [imperial | rebel | neutral]] ]");
                                        return INVALIDTARGET;
                                }
@@ -145,18 +145,24 @@ public:
                                                for (int i = 0; i < closeObjects.size(); ++i) {
                                                        SceneObject* sceneObject = cast<SceneObject*>(closeObjects.get(i).get());
 
-                                                       if (sceneObject->isPlayerCreature() && creature->isInRange(sceneObject, range)) {
-                                                               ManagedReference<CreatureObject*> playerObject = cast<CreatureObject*>(sceneObject);
+                                                       if ((sceneObject->isPlayerCreature() || sceneObject->isPet()) && creature->isInRange(sceneObject, range)) {
+                                                               ManagedReference<CreatureObject*> patientObject = cast<CreatureObject*>(sceneObject);
 
-                                                               if (playerObject != NULL) {
-                                                                       if (faction == "" || faction.hashCode() == playerObject->getFaction() || (faction == "neutral" && playerObject->getFaction() == 0)) {
+                                                               if (patientObject != NULL) {
+                                                                       if (faction == "" || faction.hashCode() == patientObject->getFaction() || (faction == "neutral" && patientObject->getFaction() == 0)) {
                                                                                if (buff) {
-                                                                                       Locker clocker(playerObject, creature);
-                                                                                       pm->enhanceCharacter(playerObject);
-                                                                                       creature->sendSystemMessage(playerObject->getFirstName() + " has been enhanced.");
+                                                                                       Locker clocker(patientObject, creature);
+
+                                                                                       if (patientObject->isPlayerCreature()) {
+                                                                                               pm->enhanceCharacter(patientObject);
+                                                                                               creature->sendSystemMessage(patientObject->getFirstName() + " has been enhanced.");
+                                                                                       } else if (patientObject->isCreature()) {
+                                                                                               pm->enhanceCharacter(patientObject);
+                                                                                               creature->sendSystemMessage(patientObject->getDisplayedName() + " has been enhanced.");
+                                                                                       }
 
                                                                                } else {
-                                                                                       revivePlayer(creature, playerObject);
+                                                                                       revivePatient(creature, patientObject);
                                                                                }
                                                                        }
                                                                }
@@ -164,32 +170,38 @@ public:
                                                }
 
                                        } else { // Not area
-                                               player = server->getZoneServer()->getChatManager()->getPlayer(firstName);
+                                               patient = server->getZoneServer()->getChatManager()->getPlayer(firstName);
 
-                                               if (player != NULL) {
+                                               if (patient != NULL) {
                                                        if (buff) {
-                                                               Locker clocker(player, creature);
-                                                               pm->enhanceCharacter(player);
-                                                               creature->sendSystemMessage(player->getFirstName() + " has been enhanced.");
+                                                               Locker clocker(patient, creature);
+                                                               pm->enhanceCharacter(patient);
+                                                               creature->sendSystemMessage(patient->getFirstName() + " has been enhanced.");
 
                                                        } else {
-                                                               revivePlayer(creature, player);
+                                                               revivePatient(creature, patient);
                                                        }
                                                }
                                        }
 
                                } else if (buff) {  // Buff was the only argument
 
-                                       if (object != NULL && object->isPlayerCreature()) { // Target is a player, buff target
-                                               player = cast<CreatureObject*>( object.get());
-                                               Locker clocker(player, creature);
-                                               pm->enhanceCharacter(player);
-                                               creature->sendSystemMessage(player->getFirstName() + " has been enhanced.");
+                                       if (object != NULL && (object->isPlayerCreature() || object->isPet())) { // Target is a player or pet, buff target
+                                               patient = cast<CreatureObject*>( object.get());
+                                               Locker clocker(patient, creature);
+
+                                               if (patient->isPlayerCreature()) {
+                                                       pm->enhanceCharacter(patient);
+                                                       creature->sendSystemMessage(patient->getFirstName() + " has been enhanced.");
+                                               } else if (patient->isCreature()) {
+                                                       pm->enhanceCharacter(patient);
+                                                       creature->sendSystemMessage(patient->getDisplayedName() + " has been enhanced.");
+                                               }
 
                                        } else if (object == NULL) { // No target, buff self
                                                pm->enhanceCharacter(creature);
 
-                                       } else { // Target is not a player
+                                       } else { // Target is not a player or pet
                                                creature->sendSystemMessage("Syntax: /gmrevive [buff] [ [<name>] | [area [<range>] [imperial | rebel | neutral]] ]");
                                                return INVALIDTARGET;
                                        }
@@ -207,26 +219,29 @@ public:
                return SUCCESS;
        }
 
-       void revivePlayer(CreatureObject* creature, CreatureObject* player) {
-               Locker clocker(player, creature);
+       void revivePatient(CreatureObject* creature, CreatureObject* patient) {
+               Locker clocker(patient, creature);
 
-               player->healDamage(creature, CreatureAttribute::HEALTH, 5000);
-               player->healDamage(creature, CreatureAttribute::ACTION, 5000);
-               player->healDamage(creature, CreatureAttribute::MIND, 5000);
+               patient->healDamage(creature, CreatureAttribute::HEALTH, 5000);
+               patient->healDamage(creature, CreatureAttribute::ACTION, 5000);
+               patient->healDamage(creature, CreatureAttribute::MIND, 5000);
 
                for (int i = 0; i < 9; ++i) {
-                       player->setWounds(i, 0);
+                       patient->setWounds(i, 0);
                }
 
-               player->setShockWounds(0);
+               patient->setShockWounds(0);
 
-               player->setPosture(CreaturePosture::UPRIGHT);
+               patient->setPosture(CreaturePosture::UPRIGHT);
 
-               player->broadcastPvpStatusBitmask();
+               patient->broadcastPvpStatusBitmask();
 
-               player->sendSystemMessage("You have been restored.");
-
-               creature->sendSystemMessage(player->getFirstName() + " has been restored.");
+               if (patient->isPlayerCreature()) {
+                       patient->sendSystemMessage("You have been restored.");
+                       creature->sendSystemMessage(patient->getFirstName() + " has been restored.");
+               } else {
+                       creature->sendSystemMessage(patient->getDisplayedName() + " has been restored.");
+               }
        }
 };
 
index 6ad0c70..1c831cc 100755 (executable)
@@ -203,8 +203,8 @@ public:
                                        targetCreature = cast<CreatureObject*>(targetObject);
 
                                        Locker locker(targetCreature, creature);
-                                       //Deal damage if target is an attackable creature, in range, and not a player
-                                       if (targetCreature->isAttackableBy(creature) && creature->isInRange(targetObject, range) && !targetObject->isPlayerCreature()) {
+                                       //Deal damage if target is an attackable creature, in range, and not a player or pet
+                                       if (targetCreature->isAttackableBy(creature) && creature->isInRange(targetObject, range) && !targetObject->isPlayerCreature() && !targetObject->isPet()) {
                                                targetCreature->inflictDamage(creature, 0, healthDamage, true, true);
                                                targetCreature->inflictDamage(creature, 3, actionDamage, true, true);
                                                targetCreature->inflictDamage(creature, 6, mindDamage, true, true);
@@ -216,9 +216,9 @@ public:
 
                //Deal damage to selected target
                else {
-                       //Deal damage if target is not a player
+                       //Deal damage if target is not a player or pet
                        if (targetCreature != NULL) {
-                               if (!targetCreature->isPlayerCreature()) {
+                               if (!targetCreature->isPlayerCreature() && !targetObject->isPet()) {
                                        Locker locker(targetCreature, creature);
 
                                        targetCreature->inflictDamage(creature, 0, healthDamage, true, true);
index ed979b6..6760ba2 100755 (executable)
@@ -82,7 +82,7 @@ public:
                PlayerManager* playerManager = server->getZoneServer()->getPlayerManager();
 
                if (targetObject != NULL) {
-                       if (targetObject->isPlayerCreature())
+                       if (targetObject->isPlayerCreature() || targetObject->isPet())
                                targetPlayer = cast<CreatureObject*>(targetObject.get());
                        else {
                                creature->sendSystemMessage("Invalid target.");
@@ -211,16 +211,18 @@ public:
                        if (damage) {
                                for (int i = 0; i < closeObjects.size(); i++) {
                                        SceneObject* targetObject = cast<SceneObject*>(closeObjects.get(i).get());
-                                       if (targetObject->isPlayerCreature()) {
+                                       if (targetObject->isPlayerCreature() || targetObject->isPet()) {
                                                targetPlayer = cast<CreatureObject*>(targetObject);
 
                                                Locker locker(targetPlayer, creature);
-                                               //Deal damage if target is in range, a player
-                                               if (creature->isInRange(targetPlayer, range) && targetPlayer->isPlayerCreature() && targetPlayer != creature) {
+                                               //Deal damage if target is in range and is a player or pet
+                                               if (creature->isInRange(targetPlayer, range) && (targetPlayer->isPlayerCreature() || targetPlayer->isPet()) && targetPlayer != creature) {
                                                        targetPlayer->inflictDamage(creature, 0, healthDamage, true, true);
                                                        targetPlayer->inflictDamage(creature, 3, actionDamage, true, true);
                                                        targetPlayer->inflictDamage(creature, 6, mindDamage, true, true);
-                                                       targetPlayer->sendSystemMessage("You have been damaged!");
+
+                                                       if (targetPlayer->isPlayerCreature())
+                                                               targetPlayer->sendSystemMessage("You have been damaged!");
 
                                                        ++count;
                                                }
@@ -234,7 +236,7 @@ public:
                        else {
                                for (int i = 0; i < closeObjects.size(); i++) {
                                        SceneObject* targetObject = cast<SceneObject*>(closeObjects.get(i).get());
-                                       if (targetObject->isPlayerCreature()) {
+                                       if (targetObject->isPlayerCreature() || targetObject->isPet()) {
                                                targetPlayer = cast<CreatureObject*>(targetObject);
 
                                                if (targetPlayer->isPlayerCreature() && targetPlayer != creature) {
@@ -243,10 +245,16 @@ public:
                                                        playerManager->killPlayer(creature, targetPlayer, 1);
 
                                                        ++count;
+                                               } else if (targetPlayer->isPet()) {
+                                                       Locker locker(targetPlayer, creature);
+
+                                                       targetPlayer->notifyObjectDestructionObservers(creature, 0);
+
+                                                       ++count;
                                                }
                                        }
                                }
-                               creature->sendSystemMessage(String::valueOf(count) + " players killed.");
+                               creature->sendSystemMessage(String::valueOf(count) + " players and/or pets killed.");
                                return SUCCESS;
                        }
                }
@@ -254,14 +262,18 @@ public:
                //Deal damage to single target
                else if (damage) {
                        if (targetPlayer != NULL) {
-                               if (targetPlayer->isPlayerCreature()) {
+                               if (targetPlayer->isPlayerCreature() || targetPlayer->isPet()) {
                                        Locker locker(targetPlayer, creature);
 
                                        targetPlayer->inflictDamage(creature, 0, healthDamage, true, true);
                                        targetPlayer->inflictDamage(creature, 3, actionDamage, true, true);
                                        targetPlayer->inflictDamage(creature, 6, mindDamage, true, true);
 
-                                       creature->sendSystemMessage(targetPlayer->getFirstName() + " damaged.");
+                                       if (targetPlayer->isPlayerCreature())
+                                               creature->sendSystemMessage(targetPlayer->getFirstName() + " damaged.");
+                                       else
+                                               creature->sendSystemMessage(targetPlayer->getDisplayedName() + " damaged.");
+
                                        return SUCCESS;
                                }
                        }
@@ -278,6 +290,10 @@ public:
                                        Locker locker(targetPlayer, creature);
 
                                        playerManager->killPlayer(creature, targetPlayer, 1);
+                               } else if (targetPlayer->isPet()) {
+                                       Locker locker(targetPlayer, creature);
+
+                                       targetPlayer->notifyObjectDestructionObservers(creature, 0);
                                }
                        }
                        else {