Instructions Jenkins Doxygen

[Fixed] droids can now be called and store in public buildings 24/1024/1
authorIvojedi <ivojedi@swgemu.com>
Tue, 29 Oct 2013 16:35:06 +0000 (09:35 -0700)
committerIvojedi <ivojedi@swgemu.com>
Tue, 29 Oct 2013 16:35:06 +0000 (09:35 -0700)
Change-Id: Idcd10bcc5a3af1e25a7637a0145b001fda9f3eae

MMOCoreORB/src/server/zone/objects/intangible/DroidControlDevice.idl
MMOCoreORB/src/server/zone/objects/intangible/DroidControlDeviceImplementation.cpp

index 278e0fd..bdd57f9 100644 (file)
@@ -48,13 +48,14 @@ import engine.lua.LuaObject;
 import server.zone.objects.intangible.IntangibleObject;
 import server.zone.objects.intangible.ControlDevice;
 import server.zone.objects.creature.CreatureObject;
+import server.zone.objects.creature.AiAgent;
+import server.zone.objects.player.PlayerObject;
 import server.zone.objects.tangible.TangibleObject;
 import server.zone.objects.scene.SceneObject;
 import server.zone.packets.scene.AttributeListMessage;
 import server.zone.Zone;
 import system.lang.System;
 include server.zone.managers.radial.RadialOptions;
-import server.zone.objects.creature.CreatureObject;
 import server.zone.objects.intangible.DroidControlObserver;
 
 class DroidControlDevice extends ControlDevice {
@@ -78,22 +79,28 @@ class DroidControlDevice extends ControlDevice {
        public int handleObjectMenuSelect(CreatureObject player, byte selectedID) {
                Logger.info("selected call");
                
-               TangibleObject controlledObject = super.controlledObject;
+               TangibleObject strongRef = super.controlledObject;
+
+               if (strongRef == null)
+                       return 1;
+
+               AiAgent droid = (AiAgent) strongRef;
+               PlayerObject ghost = player.getPlayerObject();
                        
                if (selectedID == 44) {
                        
-                       if (controlledObject == null) {
+                       if (droid == null) {
                                Logger.error("null controlled object in pet control device");
                                return 1;
                        } else {
                                this.callObject(player);
                        }
                } else if (selectedID == 59) {
-                       if (controlledObject == null) {
+                       if (droid == null) {
                                Logger.error("null controlled object in pet control device");
                                return 1;
                        } else {
-                               if (super.status == 1 && !controlledObject.isInQuadTree()) {
+                               if (super.status == 1 && !ghost.hasActivePet(droid)) {
                                        this.callObject(player);
                                } else {
                                        this.storeObject(player);
index a6a2168..3fb5c6b 100644 (file)
 
 void DroidControlDeviceImplementation::callObject(CreatureObject* player) {
 
-       if (player->getParent() != NULL){
-               player->sendSystemMessage( "You must be outside to call this droid" );
-               return;
+       if (player->getParent() != NULL) {
+               ManagedReference<SceneObject*> strongRef = player->getParentRecursively(SceneObjectType::BUILDING);
+               ManagedReference<BuildingObject*> building;
+
+               if (strongRef != NULL)
+                       building = strongRef.castTo<BuildingObject*>();
+
+               if (building == NULL || building->isPrivateStructure()) {
+                       player->sendSystemMessage("@pet/pet_menu:private_house"); // You cannot call pets in a private building.
+                       return;
+               }
        }
 
        if (!isASubChildOf(player)){
@@ -26,13 +34,15 @@ void DroidControlDeviceImplementation::callObject(CreatureObject* player) {
        }
 
        ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
-       if (controlledObject == NULL){
+       if (controlledObject == NULL || !controlledObject->isAiAgent()){
                return;
        }
 
-       if (controlledObject->isInQuadTree()){
+       ManagedReference<AiAgent*> droid = cast<AiAgent*>(controlledObject.get());
+       ManagedReference<PlayerObject*> ghost = player->getPlayerObject();
+
+       if (ghost->hasActivePet(droid))
                return;
-       }
 
        if (player->isInCombat() || player->isDead() || player->isIncapacitated()) {
                player->sendSystemMessage("@pet/pet_menu:cant_call"); // You cannot call this pet right now.
@@ -44,17 +54,6 @@ void DroidControlDeviceImplementation::callObject(CreatureObject* player) {
                return;
        }
 
-       ManagedReference<TradeSession*> tradeContainer = player->getActiveSession(SessionFacadeType::TRADE).castTo<TradeSession*>();
-       if (tradeContainer != NULL) {
-               server->getZoneServer()->getPlayerManager()->handleAbortTradeMessage(player);
-       }
-
-       if (!controlledObject->isAiAgent()){
-               return;
-       }
-
-       ManagedReference<AiAgent*> droid = cast<AiAgent*>(controlledObject.get());
-
        if(player->getPendingTask("call_droid") != NULL) {
                StringIdChatParameter waitTime("pet/pet_menu", "call_delay_finish_pet"); // Already calling a Pet: Call will be finished in %DI seconds.
                Time nextExecution;
@@ -66,36 +65,29 @@ void DroidControlDeviceImplementation::callObject(CreatureObject* player) {
                return;
        }
 
-       ManagedReference<SceneObject*> datapad = player->getSlottedObject("datapad");
-
-       if (datapad == NULL){
-               return;
-       }
-
        int currentlySpawned = 0;
 
        int maxDroids = 1;
 
-       for (int i = 0; i < datapad->getContainerObjectsSize(); ++i) {
-               ManagedReference<SceneObject*> object = datapad->getContainerObject(i);
-
-               if (object->isDroidControlDevice()) {
-                       DroidControlDevice* device = cast<DroidControlDevice*>( object.get());
-
-                       ManagedReference<AiAgent*> object = cast<AiAgent*>(device->getControlledObject());
+       for (int i = 0; i < ghost->getActivePetsSize(); ++i) {
+               ManagedReference<AiAgent*> object = ghost->getActivePet(i);
 
-                       if (object != NULL && object->isInQuadTree()) {
-                               if ( object->isDroidObject()) {
-                                       if (++currentlySpawned >= maxDroids) {
-                                               player->sendSystemMessage("@pet/pet_menu:at_max"); // You already have the maximum number of pets of this type that you can call.
-                                               return;
-                                       }
+               if (object != NULL) {
+                       if ( object->isDroidObject()) {
+                               if (++currentlySpawned >= maxDroids) {
+                                       player->sendSystemMessage("@pet/pet_menu:at_max"); // You already have the maximum number of pets of this type that you can call.
+                                       return;
                                }
-
                        }
+
                }
        }
 
+       ManagedReference<TradeSession*> tradeContainer = player->getActiveSession(SessionFacadeType::TRADE).castTo<TradeSession*>();
+       if (tradeContainer != NULL) {
+               server->getZoneServer()->getPlayerManager()->handleAbortTradeMessage(player);
+       }
+
        if(player->getCurrentCamp() == NULL && player->getCityRegion() == NULL) {
 
                Reference<CallDroidTask*> callDroid = new CallDroidTask(_this.get(), player, "call_droid");
@@ -154,7 +146,12 @@ void DroidControlDeviceImplementation::spawnObject(CreatureObject* player) {
        if (zone == NULL)
                return;
 
-       zone->transferObject(controlledObject, -1, true);
+       ManagedReference<SceneObject*> parent = player->getParent();
+
+       if (parent != NULL && parent->isCellObject())
+               parent->transferObject(controlledObject, -1, true);
+       else
+               zone->transferObject(controlledObject, -1, true);
 
        updateStatus(1);
 
@@ -166,6 +163,9 @@ void DroidControlDeviceImplementation::spawnObject(CreatureObject* player) {
        if( droid == NULL )
                return;
 
+       ManagedReference<PlayerObject*> ghost = player->getPlayerObject();
+       ghost->addToActivePets(droid);
+
        // Sanity check that there isn't another power task outstanding
        droid->removePendingTask( "droid_power" );
 
@@ -198,10 +198,10 @@ void DroidControlDeviceImplementation::cancelSpawnObject(CreatureObject* player)
 void DroidControlDeviceImplementation::storeObject(CreatureObject* player) {
        ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
 
-       if (controlledObject == NULL || !controlledObject->isCreatureObject())
+       if (controlledObject == NULL || !controlledObject->isAiAgent())
                return;
 
-       ManagedReference<CreatureObject*> droid = cast<CreatureObject*>(controlledObject.get());
+       ManagedReference<AiAgent*> droid = cast<AiAgent*>(controlledObject.get());
 
        if (droid->isInCombat())
                return;
@@ -213,6 +213,9 @@ void DroidControlDeviceImplementation::storeObject(CreatureObject* player) {
        droid->setCreatureLink(NULL);
 
        updateStatus(0);
+
+       ManagedReference<PlayerObject*> ghost = player->getPlayerObject();
+       ghost->removeFromActivePets(droid);
 }
 
 
@@ -228,10 +231,11 @@ void DroidControlDeviceImplementation::destroyObjectFromDatabase(bool destroyCon
 }
 
 int DroidControlDeviceImplementation::canBeDestroyed(CreatureObject* player) {
-       ManagedReference<TangibleObject*> controlledObject = this->controlledObject.get();
+       ManagedReference<AiAgent*> controlledObject = cast<AiAgent*>(this->controlledObject.get().get());
 
        if (controlledObject != NULL) {
-               if (controlledObject->isInQuadTree())
+               ManagedReference<PlayerObject*> ghost = player->getPlayerObject();
+               if (ghost->hasActivePet(controlledObject))
                        return 1;
        }