Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10906 was 10906, checked in by gania, 9 years ago

tried to fix fighting whn fps is low

File size: 27.3 KB
Line 
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:
23 *      Gani Aliguzhinov
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "ActionpointController.h"
30
31#include "core/XMLPort.h"
32#include <algorithm>
33#include "worldentities/Actionpoint.h"
34namespace orxonox
35{
36
37    RegisterClass(ActionpointController);
38
39    ActionpointController::ActionpointController(Context* context) : FightingController(context)
40    {
41        this->actionCounter_ = 0;
42        this->bInLoop_ = false;
43        this->bLoop_ = false;
44        this->bEndLoop_ = false;
45        loopActionpoints_.clear();
46        parsedActionpoints_.clear();
47        actionpoints_.clear();
48        healthSpawners_.clear();
49        damageSpawners_.clear();
50        speedSpawners_.clear();
51        this->bTakenOver_ = false;
52        this->action_ = Action::NONE;
53        this->squaredaccuracy_ = 2500;
54        this->bFirstTick_ = true;
55        this->bStartedDodging_ = false;
56        this->timeDodged_ = 0;
57        RegisterObject(ActionpointController);
58
59    }
60    void ActionpointController::XMLPort( Element& xmlelement, XMLPort::Mode mode )
61    {
62        SUPER( ActionpointController, XMLPort, xmlelement, mode );
63        XMLPortObject(ActionpointController, WorldEntity, "actionpoints", addActionpoint, getActionpoint,  xmlelement, mode);
64    }
65    ActionpointController::~ActionpointController()
66    {
67        loopActionpoints_.clear();
68        parsedActionpoints_.clear();
69        actionpoints_.clear();
70        healthSpawners_.clear();
71        damageSpawners_.clear();
72        speedSpawners_.clear();
73    }
74    void ActionpointController::tick(float dt)
75    {
76
77        if (this->timeout_ > 0 && this->bFiredRocket_)
78        {
79            this->timeout_ -= dt;
80        }
81        if (this->bStartedDodging_)
82        {
83            this->timeDodged_ += dt;
84            if (this->timeDodged_ > 2.0f)
85            {
86                this->bStartedDodging_ = false;
87                this->timeDodged_ = 0;
88            }
89        }
90        maneuverCounter_ += dt;
91        if (maneuverCounter_ > 6.0f)
92            maneuverCounter_ = 0;
93        if (timeout_ <= 0)
94            this->bFiredRocket_ = false;
95
96        if (this->bHasTargetPosition_)
97        {
98            this->moveToTargetPosition(dt);
99        }
100        else if (this->bLookAtTarget_)
101        {
102            this->lookAtTarget(dt);
103        }
104        if (this->bShooting_)
105        {
106            this->doFire();
107        }
108        if (this->bFirstTick_)
109        {
110            std::reverse(parsedActionpoints_.begin(), parsedActionpoints_.end());
111            std::reverse(actionpoints_.begin(), actionpoints_.end());
112            if (this->parsedActionpoints_.empty())
113            {
114                this->action_ = Action::FIGHTALL;
115            }
116        }
117        if (this->bFirstTick_)
118        {   
119            setSpawners();
120            // orxout(internal_error) << "health spawners size = " << this->healthSpawners_.size() <<
121            // ", damage spawners size = " << this->damageSpawners_.size() <<
122            // ", speed spawners size = " << this->speedSpawners_.size() << endl;       
123            this->bFirstTick_ = false;
124        }
125        if (this->hasTarget())
126        {
127            this->maneuver();
128            if (static_cast<int>(this->maneuverCounter_*100) % 3 == 0)
129                this->bShooting_ = this->canFire();
130        }
131        SUPER(ActionpointController, tick, dt);
132    }
133    void ActionpointController::action()
134    {
135        if (!this || !this->getControllableEntity())
136            return;
137        if (!this->getControllableEntity() || !orxonox_cast<Pawn*> (this->getControllableEntity()))
138            return;
139            this->startAttackingEnemiesThatAreClose();
140
141        this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
142        this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
143
144        // if (this->actionCounter_ % 2 == 0)
145        //No action -> pop one from stack
146        if (this->action_ == Action::NONE || this->bTakenOver_)
147        {
148            // Point point = closestPickup(PickupType::HEALTH);
149            // if (point.action != Action::NONE)
150            // {
151            //     orxout(internal_error) << "found health" << endl;
152            //     this->parsedActionpoints_.push_back(point);
153            // }
154
155            if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())
156            {
157                Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
158                this->parsedActionpoints_.push_back (p);
159            }
160            this->executeActionpoint();
161            this->bTakenOver_ = false;
162            this->action();
163        }
164        //Action fightall -> fight till nobody alive
165        if (this->action_ == Action::FIGHTALL)
166        {
167
168            if (!this->hasTarget())
169            {
170                ControllableEntity* newTarget = this->closestTarget();   
171                if (newTarget)
172                {
173                    this->setAction (Action::FIGHTALL, newTarget);
174                    this->action();
175                }
176                else
177                {
178                    this->nextActionpoint();
179                    if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
180                    {
181                        this->action();
182                    }
183                    else
184                    {
185                    }     
186                }
187            }
188        }
189        //Action fight -> fight as long as enemies in range
190        else if (this->action_ == Action::FIGHT)
191        {
192
193            if (!this->hasTarget() )
194            {
195                //----find a target----
196                ControllableEntity* newTarget = this->closestTarget();   
197                if (newTarget && 
198                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
199                {
200                    this->setAction (Action::FIGHT, newTarget);
201                    this->action();
202                }
203                else
204                {
205                    this->nextActionpoint();
206                    this->action();
207                }
208            }
209            else if (this->hasTarget())
210            {
211                //----fly in formation if far enough----
212                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
213                   
214                if (diffVector.length() > this->attackRange_)
215                {
216                    ControllableEntity* newTarget = this->closestTarget();
217                   
218                    if (newTarget && 
219                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
220                    {
221                        this->setAction (Action::FIGHT, newTarget);
222                    }
223                    else
224                    {
225                        this->nextActionpoint();
226                        this->action();
227                    }
228                }
229            }
230        }
231        else if (this->action_ == Action::FLY)
232        {
233            if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
234            {
235                this->nextActionpoint();   
236                this->action();
237            }
238        }
239        else if (this->action_ == Action::PROTECT)
240        {
241            if (!this->getProtect())
242            {
243                this->nextActionpoint();
244                this->action(); 
245            }
246            this->stayNearProtect();
247        }
248        else if (this->action_ == Action::ATTACK)
249        {   
250
251            if (!this->hasTarget())
252            {
253                this->nextActionpoint();
254                this->action();
255            }
256        }
257
258            // Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length());
259            // if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_)
260            // {
261            //     //----choose where to go----
262            //     this->maneuver();
263            // }
264            // else
265            // {
266            //     this->dodgeTowards(healthPosition);
267            // }
268            // //----fire if you can----
269            // this->bShooting_ = this->canFire(); 
270         
271        this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
272
273    }
274    void ActionpointController::setProtect (ControllableEntity* protect)
275    {
276        this->protect_ = protect;
277    }
278    ControllableEntity* ActionpointController::getProtect ()
279    {
280        return this->protect_;
281    }
282    void ActionpointController::addActionpoint(WorldEntity* actionpoint)
283    {
284        std::string actionName;
285        Vector3 position;
286        std::string targetName;
287        bool inLoop = false;
288        Point p;
289        if (actionpoint->getIdentifier()->getName() == "Actionpoint")
290        {
291            Actionpoint* ap = orxonox_cast<Actionpoint*> (actionpoint);
292            actionName = ap->getActionXML();
293            targetName = ap->getName();
294            position = ap->getWorldPosition();
295
296            if (this->bEndLoop_)
297            {
298                this->bInLoop_ = false;
299            }
300            if (!this->bInLoop_ && ap->getLoopStart())
301            {
302                this->bInLoop_ = true;
303            }
304            if (this->bInLoop_ && ap->getLoopEnd())
305            {
306                this->bEndLoop_ = true;
307            }
308            inLoop = this->bInLoop_;
309
310            Action::Value value;
311           
312            if ( actionName == "FIGHT" )
313            { value = Action::FIGHT; }
314            else if ( actionName == "FLY" )
315            { value = Action::FLY; }
316            else if ( actionName == "PROTECT" )
317            { value = Action::PROTECT; }
318            else if ( actionName == "NONE" )
319            { value = Action::NONE; }
320            else if ( actionName == "FIGHTALL" )
321            { value = Action::FIGHTALL; }
322            else if ( actionName == "ATTACK" )
323            { value = Action::ATTACK; }
324            else
325                ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ actionName + "'." );
326            p.action = value; p.name = targetName; p.position = position; p.inLoop = inLoop;
327        }
328        else
329        {
330            inLoop = true;
331            p.action = Action::FLY; p.name = ""; p.position = actionpoint->getWorldPosition(); p.inLoop = inLoop;
332        }
333            parsedActionpoints_.push_back(p);
334            this->actionpoints_.push_back(actionpoint);
335    }
336    WorldEntity* ActionpointController::getActionpoint(unsigned int index) const
337    {
338        if (index < this->actionpoints_.size())
339            return this->actionpoints_[index];
340        else
341            return 0;
342    }
343
344    Action::Value ActionpointController::getAction ()
345    {
346        return this->action_;
347    }
348    std::string ActionpointController::getActionName()
349    {
350        switch ( this->action_ )
351        {
352            case Action::FIGHT:
353            { return "FIGHT"; break; }
354            case Action::FLY:
355            { return "FLY"; break; }
356            case Action::PROTECT:
357            { return "PROTECT"; break; }
358            case Action::NONE:
359            { return "NONE"; break; }
360            case Action::FIGHTALL:
361            { return "FIGHTALL"; break; }
362            case Action::ATTACK:
363            { return "ATTACK"; break; }
364            default:
365                return "NONE";
366                break;
367        }
368    }
369    void ActionpointController::setAction (Action::Value action)
370    {
371        this->action_ = action;
372    }
373    void ActionpointController::setAction (Action::Value action, ControllableEntity* target)
374    {
375        this->action_ = action;
376        if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK)
377        {   
378            if (target)
379                this->setTarget (target);
380        }
381        else if (action == Action::PROTECT)
382        {
383            if (target)
384                this->setProtect (target);
385        }
386    }
387    void ActionpointController::setAction (Action::Value action, const Vector3& target)
388    {
389        this->action_ = action;
390        if (action == Action::FLY)
391        {
392            this->setTargetPosition (target);
393        }
394    }
395    void ActionpointController::setAction (Action::Value action, const Vector3& target,  const Quaternion& orient )
396    {
397        this->action_ = action;
398        if (action == Action::FLY)
399        {
400            this->setTargetPosition (target);
401            this->setTargetOrientation (orient);
402        } 
403    }
404   
405    //------------------------------------------------------------------------------
406    //------------------------------Actionpoint methods-----------------------------
407    //------------------------------------------------------------------------------
408
409    //POST: this starts doing what was asked by the last element of parsedActionpoints_,
410    //if last element was failed to be parsed, next element will be executed.
411    void ActionpointController::executeActionpoint()
412    {
413        Point p;
414        if (this->bLoop_ && !loopActionpoints_.empty())
415        {
416            p = loopActionpoints_.back();
417        }
418        else if (this->bLoop_)
419        {
420            this->bLoop_ = false;
421            return;
422        }
423        else if (!this->bLoop_ && !parsedActionpoints_.empty())
424        {
425            p = parsedActionpoints_.back();
426        }
427        else
428        {
429            this->setTarget(0);
430            this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
431            this->action_ = Action::NONE;
432            return;
433        }
434        if (!this->bLoop_ && this->parsedActionpoints_.back().inLoop)
435        {
436            //MOVES all points that are in loop to a loop vector
437            this->fillLoop();
438            this->bLoop_ = true;
439            executeActionpoint();
440            return;
441        }
442        this->setAction (p.action);
443        switch (this->action_)
444        {
445            case Action::FIGHT:
446            {
447                std::string targetName = p.name;
448                if (targetName == "")
449                    break;
450                for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
451                {
452                    if (CommonController::getName(*itP) == targetName)
453                    {
454                        this->setTarget (static_cast<ControllableEntity*>(*itP));
455                    }
456                }
457                break;
458            }
459            case Action::FLY:
460            {
461                this->setTargetPosition( p.position );
462                if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
463                {
464                    this->nextActionpoint();
465                    this->executeActionpoint();
466                }
467                break;
468            }
469            case Action::PROTECT:
470            {
471               
472                std::string protectName = p.name;
473                if (protectName == "reservedKeyword:human")
474                {
475                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
476                    {
477                        if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && ((*itP)->getController()->getIdentifier()->getName() == "NewHumanController"))
478                        {
479                            this->setProtect (static_cast<ControllableEntity*>(*itP));
480                        }
481                    }
482                }
483                else
484                {
485                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
486                    {
487                        if (CommonController::getName(*itP) == protectName)
488                        {
489                            this->setProtect (static_cast<ControllableEntity*>(*itP));
490                        }
491                    }                           
492                }
493                if (!this->getProtect())
494                {
495                    this->nextActionpoint();
496                    this->executeActionpoint();
497                }
498                break;
499            }
500            case Action::NONE:
501            {
502                break;
503            }
504            case Action::FIGHTALL:
505            {
506                break;
507            }
508            case Action::ATTACK:
509            {
510                std::string targetName = p.name;
511
512                for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
513                {
514                    if (CommonController::getName(*itP) == targetName)
515                    {
516                        this->setTarget (static_cast<ControllableEntity*>(*itP));
517                    }
518                }
519                if (!this->hasTarget())
520                {
521                    this->nextActionpoint();
522                    this->executeActionpoint();
523                }
524                break;
525            }
526            default:
527                break;
528        }   
529    }
530
531   
532    void ActionpointController::stayNearProtect()
533    {
534        Vector3 targetRelativePosition(0, 300, 300);
535        if (!this->getProtect())
536        {
537            this->nextActionpoint();
538            return;
539        } 
540        Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) + 
541            (this->getProtect()->getWorldOrientation()* (targetRelativePosition)));
542        this->setTargetPosition(targetAbsolutePosition);
543        if (!this->getProtect())
544        {
545            this->nextActionpoint();
546            return;
547        } 
548        if (this->actionCounter_ % 3 == 0)
549            this->setTargetOrientation(this->getProtect()->getWorldOrientation());
550    }
551    void ActionpointController::nextActionpoint()
552    {
553        if (!this || !this->getControllableEntity())
554            return;
555        if (this->bLoop_)
556        {
557            if (!this->loopActionpoints_.empty())
558            {
559                this->moveBackToTop();
560            }
561        }
562        else
563        {
564            if (!this->parsedActionpoints_.empty())
565            {
566                this->parsedActionpoints_.pop_back();
567            }           
568        }
569        this->setAction(Action::NONE);
570        this->bHasTargetPosition_ = false;
571    }
572    void ActionpointController::moveBackToTop()
573    {
574        Point temp = loopActionpoints_.back();
575        loopActionpoints_.pop_back();
576        std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
577        loopActionpoints_.push_back(temp);
578        std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
579    }
580    void ActionpointController::fillLoop()
581    {
582        loopActionpoints_.clear();
583        fillLoopReversed();
584        std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
585    }
586    void ActionpointController::fillLoopReversed()
587    {
588        if (parsedActionpoints_.back().inLoop)
589        {
590            loopActionpoints_.push_back(parsedActionpoints_.back());
591            parsedActionpoints_.pop_back();
592        }
593        if (parsedActionpoints_.back().inLoop)
594        {
595            fillLoopReversed();
596        }
597    }
598   
599    void ActionpointController::takeActionpoints (const std::vector<Point>& vector, const std::vector<Point>& loop, bool b)
600    {
601      this->parsedActionpoints_ = vector;
602      this->loopActionpoints_ = loop;
603      this->bLoop_ = b;
604      this->bTakenOver_ = true;
605    }
606    void ActionpointController::setClosestTarget()
607    {
608        this->setTarget (static_cast<ControllableEntity*>( closestTarget() ) ); 
609    }
610    Pawn* ActionpointController::closestTarget()
611    {
612        if (!this->getControllableEntity())
613            return 0;
614
615        Pawn* closestTarget = 0;
616        float minDistance =  std::numeric_limits<float>::infinity();
617        Gametype* gt = this->getGametype();
618        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
619        {
620            if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) )
621                continue;
622
623            float distance = CommonController::distance (*itP, this->getControllableEntity());
624            if (distance < minDistance)
625            {
626                closestTarget = *itP;
627                minDistance = distance;
628            }
629        }
630        if (closestTarget)
631        {
632           return closestTarget;
633        } 
634        return 0; 
635    }
636    void ActionpointController::startAttackingEnemiesThatAreClose()
637    {
638        //if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
639        {
640            if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_))
641            {
642                Pawn* newTarget = this->closestTarget();
643                if ( newTarget && 
644                    CommonController::distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
645                        <= this->attackRange_ )
646                {
647                    if (this->bLoop_)
648                    {
649                        Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, true };
650                        this->loopActionpoints_.push_back(p);
651                    }
652                    else
653                    {
654                        //orxout (internal_error) << "found new target " << CommonController::getName(newTarget) <<endl;
655                        Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, false };
656                        this->parsedActionpoints_.push_back(p);
657                    }
658                    this->executeActionpoint();
659                }
660            }
661        }
662    }
663    Vector3 ActionpointController::bestHealthPickup(float searchRadius)
664    {
665
666        //1000000/distance^2 * 1/index+1
667        float maxUse = 0;
668        float tempUse = -1;
669        int index = 0;
670        float distance = 0;
671        Vector3 bestPosition = this->getControllableEntity()->getWorldPosition();
672
673        for (std::multimap<int, std::pair<PickupSpawner*, bool> >::iterator it=healthSpawners_.begin(); it!=healthSpawners_.end(); ++it)
674        {
675            distance = (this->getControllableEntity()->getWorldPosition() - (*it).second.first->getWorldPosition()).length();
676            if (distance < this->tolerance_ || !(*it).second.second)
677            {
678                (*it).second.second = false;
679                continue;
680            }
681            if (distance > searchRadius)
682                continue;
683            index = (*it).first;
684            tempUse = 1000000*1/(1+distance*distance) * 1/((index/2.0f)+1);
685            if (tempUse > maxUse)
686            {
687                bestPosition = (*it).second.first->getWorldPosition();
688                maxUse = tempUse;
689            }
690        }
691        //std::multimap<int, std::pair<PickupSpawner*, bool> >::iterator it = this->healthSpawners_.find(index);
692        //P.S. check if it == ... .end()
693        //orxout (internal_error) << "best position = " << bestPosition << endl;
694        return  bestPosition;
695    }
696    void ActionpointController::setSpawners()
697    {
698        std::vector<std::string> damagePickups;
699        std::vector<std::string> healthPickups;
700        std::vector<std::string> speedPickups;       
701        int index = 0;
702
703
704        damagePickups.push_back("largedamageboostpickup");
705        damagePickups.push_back("dronepickup");           
706        damagePickups.push_back("mediumdamageboostpickup");
707        damagePickups.push_back("smalldamageboostpickup");
708
709        healthPickups.push_back("triplehealthspeedinvisibilitypickup");           
710        healthPickups.push_back("crazyhealthpickup");
711        healthPickups.push_back("hugehealthpickup");
712        healthPickups.push_back("hugeshieldpickup");
713        healthPickups.push_back("hugeinvisiblepickup");
714        healthPickups.push_back("hugeshrinkpickup");
715        healthPickups.push_back("mediumhealthpickup");
716        healthPickups.push_back("mediumshieldpickup");
717        healthPickups.push_back("mediuminvisiblepickup");
718        healthPickups.push_back("mediumshrinkpickup"); 
719        healthPickups.push_back("smallhealthpickup");                   
720        healthPickups.push_back("smallshieldpickup");
721        healthPickups.push_back("smallinvisiblepickup");
722        healthPickups.push_back("smallshrinkpickup");
723
724        speedPickups.push_back("triplehealthspeedinvisibilitypickup");
725        speedPickups.push_back("hugespeedpickup");
726        speedPickups.push_back("smalljumppickup");
727        speedPickups.push_back("mediumspeedpickup");
728        speedPickups.push_back("smallspeedpickup");
729       
730
731
732        for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it; ++it)
733        {
734            if ((*it)->getIdentifier()->getName() != "PickupSpawner")
735                continue;
736            PickupSpawner* spawner = static_cast<PickupSpawner*>(*it);
737            std::string name = spawner->getPickupTemplateName();
738            //float distance = ((*it)->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length();
739            // if (distance < 50.0f)
740            //     continue;           
741            for (unsigned int i = 0; i < healthPickups.size(); ++i)
742            {
743                if (name == healthPickups.at(i))
744                {
745                    index = i;
746                    this->healthSpawners_.insert(std::make_pair(index, std::make_pair(spawner, true)));
747                    break;
748                }
749            }
750            for (unsigned int i = 0; i < damagePickups.size(); ++i)
751            {
752                if (name == damagePickups.at(i))
753                {
754                    //tempUse = 1000000*1/(1+distance*distance) * 1/((i/2.0f)+1);
755                    index = i;
756                    this->damageSpawners_.insert(std::make_pair(index, std::make_pair(spawner, true)));
757                    break;
758                }
759            }
760            for (unsigned int i = 0; i < speedPickups.size(); ++i)
761            {
762                if (name == speedPickups.at(i))
763                {
764                    //tempUse = 1000000*1/(1+distance*distance) * 1/((i/2.0f)+1);
765                    index = i;
766                    this->speedSpawners_.insert(std::make_pair(index, std::make_pair(spawner, true)));
767                    break;
768                }
769            }
770            // if (tempUse > maxUse)
771            // {
772            //     Point p = { Action::FLY, "", (*it)->getWorldPosition(), false };
773            //     maxUse = tempUse;
774            //     maxPoint = p;
775            // }
776            // else
777            // {
778            //     tempUse = -1;
779            //     continue;
780            // }
781            // orxout(internal_error) << "resp time  = " << static_cast<PickupSpawner*>(*it)->getRespawnTime() << endl;
782        } 
783    }
784}
Note: See TracBrowser for help on using the repository browser.