Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc @ 10953

Last change on this file since 10953 was 10953, checked in by gania, 10 years ago

converted hack to a legal class

File size: 25.1 KB
RevLine 
[10864]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
[10885]23 *      Gani Aliguzhinov
[10864]24 *   Co-authors:
[10885]25 *      ...
[10864]26 *
27 */
28
29#include "ActionpointController.h"
30
31#include "core/XMLPort.h"
[10875]32#include <algorithm>
[10877]33#include "worldentities/Actionpoint.h"
[10864]34namespace orxonox
35{
36
37    RegisterClass(ActionpointController);
38
[10871]39    ActionpointController::ActionpointController(Context* context) : FightingController(context)
[10864]40    {
[10923]41        this->ticks_ = 0;
[10915]42        this->bPatrolling_ = false;
[10877]43        this->bInLoop_ = false;
[10864]44        this->bLoop_ = false;
45        this->bEndLoop_ = false;
[10888]46        loopActionpoints_.clear();
47        parsedActionpoints_.clear();
48        actionpoints_.clear();
[10864]49        this->bTakenOver_ = false;
50        this->action_ = Action::NONE;
51        this->squaredaccuracy_ = 2500;
[10906]52        this->bStartedDodging_ = false;
[10912]53        this->bDefaultPatrol_ = true;
54        this->bDefaultFightAll_ = true;
55        this->stop_ = false;
[10864]56        RegisterObject(ActionpointController);
57
58    }
59    void ActionpointController::XMLPort( Element& xmlelement, XMLPort::Mode mode )
60    {
61        SUPER( ActionpointController, XMLPort, xmlelement, mode );
[10912]62
[10864]63        XMLPortObject(ActionpointController, WorldEntity, "actionpoints", addActionpoint, getActionpoint,  xmlelement, mode);
[10912]64        XMLPortParam(ActionpointController, "defaultFightAll", setDefaultFightAll, getDefaultFightAll, xmlelement, mode).defaultValues(true);
65        XMLPortParam(ActionpointController, "defaultPatrol", setDefaultPatrol, getDefaultPatrol, xmlelement, mode).defaultValues(true);
[10864]66    }
[10912]67
[10886]68    ActionpointController::~ActionpointController()
69    {
70        loopActionpoints_.clear();
71        parsedActionpoints_.clear();
72        actionpoints_.clear();
[10935]73
[10886]74    }
75    void ActionpointController::tick(float dt)
76    {
[10935]77        if (!this || !this->getControllableEntity() || !this->isActive() || this->stop_)
[10915]78            return;
[10953]79
[10923]80        ++this->ticks_;
[10953]81        if (this->ticks_ == 1)
[10885]82        {
[10923]83            std::reverse(parsedActionpoints_.begin(), parsedActionpoints_.end());
84            std::reverse(actionpoints_.begin(), actionpoints_.end());
85            if (this->parsedActionpoints_.empty())
[10906]86            {
[10923]87                this->action_ = Action::FIGHTALL;
[10906]88            }
89        }
[10935]90
[10923]91        if (!this || !this->getControllableEntity())
92            return;
93       
[10886]94        if (this->bHasTargetPosition_)
[10864]95        {
96            this->moveToTargetPosition(dt);
97        }
98        else if (this->bLookAtTarget_)
99        {
100            this->lookAtTarget(dt);
101        }
[10925]102       
[10923]103
104        if (!this || !this->getControllableEntity())
105            return;
[10934]106
[10923]107        if (timeout_ <= 0)
[10953]108        {   
[10923]109            this->bFiredRocket_ = false;
[10953]110        }
111        else if (this->bFiredRocket_)
[10925]112        {
[10934]113            --this->timeout_;
[10925]114        }
115
[10924]116        if (!this || !this->getControllableEntity())
117            return;
[10953]118
119        if (this->ticks_ % 80 <= 10)
[10927]120        {
121            this->bDodge_ = false;
122        }
123        else
124        {
125            this->bDodge_ = true;
126        }
[10925]127
[10924]128        if (!this || !this->getControllableEntity())
129            return;
[10953]130     
131        if (this->bShooting_)
[10924]132        {
[10953]133            this->doFire();
[10906]134        }
[10886]135        SUPER(ActionpointController, tick, dt);
136    }
[10912]137     
[10910]138
139
[10886]140    void ActionpointController::action()
141    {
[10953]142        if (!this || !this->getControllableEntity() || !this->isActive())
[10886]143            return;
[10935]144
[10953]145        this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
146        this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
[10912]147        if (this->bDefaultPatrol_ || (this->action_ != Action::FLY && this->action_ != Action::NONE))
148        {
149            this->startAttackingEnemiesThatAreClose();
150        }
[10923]151        if (!this || !this->getControllableEntity())
152            return;
153
[10886]154        //No action -> pop one from stack
155        if (this->action_ == Action::NONE || this->bTakenOver_)
156        {
[10912]157            if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty() && this->bDefaultFightAll_)
[10886]158            {
[10946]159                if (!this || !this->getControllableEntity())
160                    return;
[10886]161                Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
162                this->parsedActionpoints_.push_back (p);
163            }
[10946]164            if (!this || !this->getControllableEntity())
165                return;
[10886]166            this->executeActionpoint();
[10946]167            if (!this || !this->getControllableEntity())
168                return;
[10886]169            this->bTakenOver_ = false;
[10879]170        }
[10923]171        if (!this || !this->getControllableEntity())
172            return;
173
[10886]174        //Action fightall -> fight till nobody alive
175        if (this->action_ == Action::FIGHTALL)
176        {
[10903]177
[10886]178            if (!this->hasTarget())
179            {
180                ControllableEntity* newTarget = this->closestTarget();   
181                if (newTarget)
182                {
[10946]183                    if (!this || !this->getControllableEntity())
184                        return;
[10886]185                    this->setAction (Action::FIGHTALL, newTarget);
186                }
187                else
188                {
[10946]189                    if (!this || !this->getControllableEntity())
190                        return;
[10886]191                    this->nextActionpoint();
[10946]192                    if (!this || !this->getControllableEntity())
193                        return;
[10915]194                    this->executeActionpoint();
195   
[10886]196                }
197            }
198        }
199        //Action fight -> fight as long as enemies in range
200        else if (this->action_ == Action::FIGHT)
201        {
[10903]202            if (!this->hasTarget() )
[10886]203            {
204                //----find a target----
[10946]205                ControllableEntity* newTarget = this->closestTarget(); 
206                if (!this || !this->getControllableEntity())
207                    return; 
[10886]208                if (newTarget && 
209                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
210                {
[10946]211                    if (!this || !this->getControllableEntity())
212                        return;
[10886]213                    this->setAction (Action::FIGHT, newTarget);
214                }
215                else
216                {
[10946]217                    if (!this || !this->getControllableEntity())
218                        return;
[10886]219                    this->nextActionpoint();
[10946]220                    if (!this || !this->getControllableEntity())
221                        return;
[10915]222                    this->executeActionpoint();
[10886]223                }
224            }
225            else if (this->hasTarget())
226            {
227                //----fly in formation if far enough----
228                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
229                   
230                if (diffVector.length() > this->attackRange_)
231                {
232                    ControllableEntity* newTarget = this->closestTarget();
[10946]233                    if (!this || !this->getControllableEntity())
234                        return;
[10886]235                    if (newTarget && 
236                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
237                    {
[10946]238                        if (!this || !this->getControllableEntity())
239                            return;
[10886]240                        this->setAction (Action::FIGHT, newTarget);
241                    }
242                    else
243                    {
[10946]244                        if (!this || !this->getControllableEntity())
245                            return;
[10886]246                        this->nextActionpoint();
[10946]247                        if (!this || !this->getControllableEntity())
248                            return;
[10915]249                        this->executeActionpoint();
[10886]250                    }
251                }
252            }
253        }
254        else if (this->action_ == Action::FLY)
255        {
256            if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
257            {
[10946]258                if (!this || !this->getControllableEntity())
259                    return;
[10886]260                this->nextActionpoint();   
[10946]261                if (!this || !this->getControllableEntity())
262                    return;
[10915]263                this->executeActionpoint();
[10886]264            }
265        }
266        else if (this->action_ == Action::PROTECT)
267        {
268            if (!this->getProtect())
269            {
[10946]270                if (!this || !this->getControllableEntity())
271                    return;
[10886]272                this->nextActionpoint();
[10946]273                if (!this || !this->getControllableEntity())
274                    return;
[10915]275                this->executeActionpoint(); 
[10886]276            }
[10946]277            if (!this || !this->getControllableEntity())
278                return;
[10886]279            this->stayNearProtect();
280        }
281        else if (this->action_ == Action::ATTACK)
282        {   
[10946]283            if (!this || !this->getControllableEntity())
284                return;
[10886]285            if (!this->hasTarget())
286            {
[10946]287                if (!this || !this->getControllableEntity())
288                    return;
[10886]289                this->nextActionpoint();
[10946]290                if (!this || !this->getControllableEntity())
291                    return;
[10915]292                this->executeActionpoint();
[10886]293            }
294        }
[10906]295
[10888]296
[10864]297    }
298    void ActionpointController::setProtect (ControllableEntity* protect)
299    {
[10946]300
[10864]301        this->protect_ = protect;
302    }
303    ControllableEntity* ActionpointController::getProtect ()
304    {
[10946]305
[10864]306        return this->protect_;
307    }
308    void ActionpointController::addActionpoint(WorldEntity* actionpoint)
309    {
310        std::string actionName;
311        Vector3 position;
312        std::string targetName;
313        bool inLoop = false;
314        Point p;
[10888]315        if (actionpoint->getIdentifier()->getName() == "Actionpoint")
[10864]316        {
[10888]317            Actionpoint* ap = orxonox_cast<Actionpoint*> (actionpoint);
[10864]318            actionName = ap->getActionXML();
319            targetName = ap->getName();
320            position = ap->getWorldPosition();
321
322            if (this->bEndLoop_)
323            {
324                this->bInLoop_ = false;
325            }
326            if (!this->bInLoop_ && ap->getLoopStart())
327            {
328                this->bInLoop_ = true;
329            }
330            if (this->bInLoop_ && ap->getLoopEnd())
331            {
332                this->bEndLoop_ = true;
333            }
334            inLoop = this->bInLoop_;
335
336            Action::Value value;
337           
338            if ( actionName == "FIGHT" )
339            { value = Action::FIGHT; }
340            else if ( actionName == "FLY" )
341            { value = Action::FLY; }
342            else if ( actionName == "PROTECT" )
343            { value = Action::PROTECT; }
344            else if ( actionName == "NONE" )
345            { value = Action::NONE; }
346            else if ( actionName == "FIGHTALL" )
347            { value = Action::FIGHTALL; }
348            else if ( actionName == "ATTACK" )
349            { value = Action::ATTACK; }
350            else
351                ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ actionName + "'." );
352            p.action = value; p.name = targetName; p.position = position; p.inLoop = inLoop;
353        }
354        else
355        {
[10888]356            inLoop = true;
[10864]357            p.action = Action::FLY; p.name = ""; p.position = actionpoint->getWorldPosition(); p.inLoop = inLoop;
358        }
359            parsedActionpoints_.push_back(p);
360            this->actionpoints_.push_back(actionpoint);
361    }
362    WorldEntity* ActionpointController::getActionpoint(unsigned int index) const
363    {
364        if (index < this->actionpoints_.size())
365            return this->actionpoints_[index];
366        else
367            return 0;
368    }
369
[10888]370    Action::Value ActionpointController::getAction ()
[10864]371    {
372        return this->action_;
373    }
374    std::string ActionpointController::getActionName()
375    {
376        switch ( this->action_ )
377        {
378            case Action::FIGHT:
[10923]379            { return "FIGHT"; }
[10864]380            case Action::FLY:
[10923]381            { return "FLY"; }
[10864]382            case Action::PROTECT:
[10923]383            { return "PROTECT"; }
[10864]384            case Action::NONE:
[10923]385            { return "NONE"; }
[10864]386            case Action::FIGHTALL:
[10923]387            { return "FIGHTALL"; }
[10864]388            case Action::ATTACK:
[10923]389            { return "ATTACK"; }
[10864]390            default:
391                return "NONE";
392                break;
393        }
394    }
395    void ActionpointController::setAction (Action::Value action)
396    {
397        this->action_ = action;
398    }
399    void ActionpointController::setAction (Action::Value action, ControllableEntity* target)
400    {
[10946]401        if (!this || !this->getControllableEntity())
402            return;
[10864]403        this->action_ = action;
404        if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK)
405        {   
406            if (target)
407                this->setTarget (target);
408        }
409        else if (action == Action::PROTECT)
410        {
411            if (target)
412                this->setProtect (target);
413        }
414    }
415    void ActionpointController::setAction (Action::Value action, const Vector3& target)
416    {
[10946]417        if (!this || !this->getControllableEntity())
418            return;
[10864]419        this->action_ = action;
420        if (action == Action::FLY)
421        {
422            this->setTargetPosition (target);
423        }
424    }
425    void ActionpointController::setAction (Action::Value action, const Vector3& target,  const Quaternion& orient )
426    {
[10946]427        if (!this || !this->getControllableEntity())
428            return;
[10864]429        this->action_ = action;
430        if (action == Action::FLY)
431        {
432            this->setTargetPosition (target);
433            this->setTargetOrientation (orient);
434        } 
435    }
436   
437    //------------------------------------------------------------------------------
438    //------------------------------Actionpoint methods-----------------------------
439    //------------------------------------------------------------------------------
440
441    //POST: this starts doing what was asked by the last element of parsedActionpoints_,
442    //if last element was failed to be parsed, next element will be executed.
443    void ActionpointController::executeActionpoint()
444    {
[10923]445        if (!this || !this->getControllableEntity())
446            return;
447
[10872]448        Point p;
449        if (this->bLoop_ && !loopActionpoints_.empty())
[10864]450        {
[10872]451            p = loopActionpoints_.back();
452        }
453        else if (this->bLoop_)
454        {
455            this->bLoop_ = false;
456            return;
457        }
458        else if (!this->bLoop_ && !parsedActionpoints_.empty())
459        {
460            p = parsedActionpoints_.back();
461        }
462        else
463        {
[10923]464            if (!this || !this->getControllableEntity())
465                return;
466
[10872]467            this->setTarget(0);
468            this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
469            this->action_ = Action::NONE;
470            return;
471        }
[10946]472        if (!this || !this->getControllableEntity())
473            return;
[10872]474        if (!this->bLoop_ && this->parsedActionpoints_.back().inLoop)
475        {
476            //MOVES all points that are in loop to a loop vector
477            this->fillLoop();
[10946]478            if (!this || !this->getControllableEntity())
479                return;
[10872]480            this->bLoop_ = true;
481            executeActionpoint();
482            return;
483        }
[10946]484        if (!this || !this->getControllableEntity())
485            return;
[10886]486        this->setAction (p.action);
[10925]487        if (!this || !this->getControllableEntity())
488            return;
489
[10886]490        switch (this->action_)
[10872]491        {
492            case Action::FIGHT:
[10864]493            {
[10872]494                std::string targetName = p.name;
495                if (targetName == "")
496                    break;
497                for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
498                {
[10946]499                    if (!this || !this->getControllableEntity())
500                        return;
[10872]501                    if (CommonController::getName(*itP) == targetName)
[10864]502                    {
[10872]503                        this->setTarget (static_cast<ControllableEntity*>(*itP));
[10864]504                    }
[10886]505                }
[10872]506                break;
507            }
508            case Action::FLY:
509            {
510                this->setTargetPosition( p.position );
[10946]511                if (!this || !this->getControllableEntity())
512                    return;
[10872]513                if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
514                {
[10946]515                    if (!this || !this->getControllableEntity())
516                        return;
[10872]517                    this->nextActionpoint();
[10946]518                    if (!this || !this->getControllableEntity())
519                        return;
[10872]520                    this->executeActionpoint();
521                }
522                break;
523            }
524            case Action::PROTECT:
525            {
[10923]526                if (!this || !this->getControllableEntity())
527                    return;
528
[10872]529                std::string protectName = p.name;
530                if (protectName == "reservedKeyword:human")
531                {
532                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
[10864]533                    {
[10875]534                        if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && ((*itP)->getController()->getIdentifier()->getName() == "NewHumanController"))
[10864]535                        {
[10872]536                            this->setProtect (static_cast<ControllableEntity*>(*itP));
[10864]537                        }
538                    }
[10872]539                }
540                else
541                {
542                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
[10864]543                    {
[10872]544                        if (CommonController::getName(*itP) == protectName)
[10864]545                        {
[10872]546                            this->setProtect (static_cast<ControllableEntity*>(*itP));
[10864]547                        }
[10872]548                    }                           
[10864]549                }
[10872]550                if (!this->getProtect())
551                {
552                    this->nextActionpoint();
553                    this->executeActionpoint();
554                }
555                break;
[10864]556            }
[10872]557            case Action::NONE:
[10864]558            {
[10872]559                break;
[10864]560            }
[10872]561            case Action::FIGHTALL:
[10864]562            {
[10872]563                break;
564            }
565            case Action::ATTACK:
566            {
567                std::string targetName = p.name;
568
569                for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
[10864]570                {
[10872]571                    if (CommonController::getName(*itP) == targetName)
[10864]572                    {
[10946]573                        if (!this || !this->getControllableEntity())
574                            return;
[10872]575                        this->setTarget (static_cast<ControllableEntity*>(*itP));
[10864]576                    }
577                }
[10872]578                if (!this->hasTarget())
579                {
580                    this->nextActionpoint();
[10946]581                    if (!this || !this->getControllableEntity())
582                        return;
[10872]583                    this->executeActionpoint();
584                }
585                break;
[10864]586            }
[10872]587            default:
588                break;
[10886]589        }   
[10872]590    }
[10864]591
592   
593    void ActionpointController::stayNearProtect()
594    {
[10923]595        if (!this || !this->getControllableEntity())
596            return;
597
[10886]598        Vector3 targetRelativePosition(0, 300, 300);
599        if (!this->getProtect())
600        {
601            this->nextActionpoint();
602            return;
603        } 
[10864]604        Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) + 
[10880]605            (this->getProtect()->getWorldOrientation()* (targetRelativePosition)));
[10864]606        this->setTargetPosition(targetAbsolutePosition);
[10886]607        if (!this->getProtect())
608        {
609            this->nextActionpoint();
610            return;
611        } 
[10909]612        this->setTargetOrientation(this->getProtect()->getWorldOrientation());
[10864]613    }
614    void ActionpointController::nextActionpoint()
615    {
616        if (!this || !this->getControllableEntity())
617            return;
618        if (this->bLoop_)
619        {
[10915]620            if (this->bPatrolling_)
[10864]621            {
[10915]622                this->loopActionpoints_.pop_back();
623                this->bPatrolling_ = false;
624            }
625            else if (!this->loopActionpoints_.empty())
626            {
[10864]627                this->moveBackToTop();
628            }
629        }
630        else
631        {
632            if (!this->parsedActionpoints_.empty())
633            {
634                this->parsedActionpoints_.pop_back();
635            }           
636        }
637        this->setAction(Action::NONE);
[10882]638        this->bHasTargetPosition_ = false;
[10864]639    }
640    void ActionpointController::moveBackToTop()
641    {
[10925]642        if (!this || !this->getControllableEntity())
643            return;
644
[10864]645        Point temp = loopActionpoints_.back();
646        loopActionpoints_.pop_back();
647        std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
648        loopActionpoints_.push_back(temp);
649        std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
650    }
651    void ActionpointController::fillLoop()
652    {
653        loopActionpoints_.clear();
654        fillLoopReversed();
655        std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
656    }
657    void ActionpointController::fillLoopReversed()
658    {
659        if (parsedActionpoints_.back().inLoop)
660        {
661            loopActionpoints_.push_back(parsedActionpoints_.back());
662            parsedActionpoints_.pop_back();
663        }
664        if (parsedActionpoints_.back().inLoop)
665        {
666            fillLoopReversed();
667        }
668    }
[10886]669   
[10885]670    void ActionpointController::takeActionpoints (const std::vector<Point>& vector, const std::vector<Point>& loop, bool b)
[10864]671    {
[10946]672        if (!this || !this->getControllableEntity())
673            return;
674        this->parsedActionpoints_ = vector;
675        if (!this || !this->getControllableEntity())
676            return;
677        this->loopActionpoints_ = loop;
678        this->bLoop_ = b;
679        this->bTakenOver_ = true;
[10864]680    }
681    void ActionpointController::setClosestTarget()
682    {
683        this->setTarget (static_cast<ControllableEntity*>( closestTarget() ) ); 
684    }
685    Pawn* ActionpointController::closestTarget()
686    {
[10923]687        if (!this || !this->getControllableEntity())
[10864]688            return 0;
689
690        Pawn* closestTarget = 0;
691        float minDistance =  std::numeric_limits<float>::infinity();
692        Gametype* gt = this->getGametype();
693        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
694        {
[10946]695            if (!this || !this->getControllableEntity())
696                return 0;
[10864]697            if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) )
698                continue;
699
700            float distance = CommonController::distance (*itP, this->getControllableEntity());
701            if (distance < minDistance)
702            {
703                closestTarget = *itP;
704                minDistance = distance;
705            }
706        }
707        if (closestTarget)
708        {
709           return closestTarget;
710        } 
711        return 0; 
712    }
713    void ActionpointController::startAttackingEnemiesThatAreClose()
714    {
[10923]715        if (!this || !this->getControllableEntity())
716            return;
717
[10903]718        //if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
[10864]719        {
[10880]720            if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_))
[10864]721            {
[10946]722                if (!this || !this->getControllableEntity())
723                    return;
[10864]724                Pawn* newTarget = this->closestTarget();
725                if ( newTarget && 
[10877]726                    CommonController::distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
[10864]727                        <= this->attackRange_ )
728                {
[10923]729                    if (!this || !this->getControllableEntity())
730                        return;
[10915]731                    this->setTarget(newTarget);
732                    if (this->bLoop_ && !this->bPatrolling_)
[10888]733                    {
[10915]734                        Point p = { Action::FIGHT, "", Vector3::ZERO, true };
[10888]735                        this->loopActionpoints_.push_back(p);
736                    }
[10915]737                    else if (!this->bPatrolling_)
[10888]738                    {
[10903]739                        //orxout (internal_error) << "found new target " << CommonController::getName(newTarget) <<endl;
[10915]740                        Point p = { Action::FIGHT, "", Vector3::ZERO, false };
[10888]741                        this->parsedActionpoints_.push_back(p);
742                    }
[10915]743                    this->bPatrolling_ = true;
[10864]744                    this->executeActionpoint();
745                }
746            }
747        }
748    }
[10923]749}   
Note: See TracBrowser for help on using the repository browser.