Instructions Jenkins Doxygen

(unstable) [added] broadcasting behavior tree interrupts to nearby mobs 39/2039/1
authordannuic <dannuic@swgemu.com>
Sat, 12 Jul 2014 05:39:37 +0000 (23:39 -0600)
committerdannuic <dannuic@swgemu.com>
Sat, 12 Jul 2014 05:39:37 +0000 (23:39 -0600)
Change-Id: I0b2fda68f0774652e98223cc1106883dd1694048

MMOCoreORB/bin/scripts/ai/ai.lua
MMOCoreORB/src/server/zone/objects/creature/AiAgent.idl
MMOCoreORB/src/server/zone/objects/creature/AiAgentImplementation.cpp

index 5ced3a0..2f99e59 100644 (file)
@@ -26,7 +26,7 @@ function Ai:doAction(pAgent)
 end
 
 function Ai:interrupt(pAgent, pObject, msg)
-       if msg == STARTCOMBAT then
+       if msg == STARTCOMBAT and pAgent == pObject then
                self:terminate(pAgent)
                if (pAgent ~= nil) then
                        local agent = LuaAiAgent(pAgent)
index ebe1a4d..6fc136e 100644 (file)
@@ -886,6 +886,9 @@ class AiAgent extends CreatureObject {
        
        @local
        public native int interrupt(SceneObject source, long msg);
+       
+       @local
+       public native void broadcastInterrupt(long msg);
 
        public native void setHomeObject(SceneObject home) {
                homeObject = home;
index db3c9e5..8a44fd6 100644 (file)
@@ -1375,6 +1375,7 @@ void AiAgentImplementation::doMovement() {
 
        //info("Performing action ID: " + currentBehaviorID, true);
        // activate AI
+       Locker locker(&behaviorMutex);
        Behavior* current = behaviors.get(currentBehaviorID);
        if (current != NULL)
                current->doAction();
@@ -2312,11 +2313,40 @@ int AiAgentImplementation::interrupt(SceneObject* source, int64 msg) {
        return b->interrupt(source, msg);
 }
 
+void AiAgentImplementation::broadcastInterrupt(int64 msg) {
+       if (zone == NULL)
+               return;
+
+       SortedVector<ManagedReference<QuadTreeEntry*> > closeAiAgents;
+
+       try {
+               if (closeobjects == NULL) {
+                       zone->getInRangeObjects(getPositionX(), getPositionY(), 192, &closeAiAgents, true);
+               } else {
+                       closeAiAgents.removeAll(closeobjects->size(), 10);
+                       closeobjects->safeCopyTo(closeAiAgents);
+               }
+       } catch (Exception& e) {
+
+       }
+
+       for (int i = 0; i < closeAiAgents.size(); ++i) {
+               AiAgent* agent = cast<AiAgent*>(closeAiAgents.get(i).get());
+
+               if (_this.get() == agent || agent == NULL)
+                       continue;
+
+               agent->interrupt(_this.get(), msg);
+       }
+}
+
 void AiAgentImplementation::setCombatState() {
        CreatureObjectImplementation::setCombatState();
 
        if (homeObject != NULL)
                homeObject->notifyObservers(ObserverEventType::AIMESSAGE, _this.get(), ObserverEventType::STARTCOMBAT);
 
+       broadcastInterrupt(ObserverEventType::STARTCOMBAT);
+
        interrupt(_this.get(), ObserverEventType::STARTCOMBAT);
 }