Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 1, 2013, 12:17:59 AM (11 years ago)
Author:
jo
Message:

Merged trunk into branch levelElias to add new features.

Location:
code/branches/levelElias
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/levelElias

  • code/branches/levelElias/src/orxonox/controllers/WaypointPatrolController.cc

    r9667 r9732  
    4242        RegisterObject(WaypointPatrolController);
    4343
    44         this->alertnessradius_ = 500;
     44        this->alertnessradius_ = 500.0f;
     45        this->attackradius_ = 1000.0f;
    4546
    4647        this->patrolTimer_.setTimer(rnd(), true, createExecutor(createFunctor(&WaypointPatrolController::searchEnemy, this)));
     
    5253
    5354        XMLPortParam(WaypointPatrolController, "alertnessradius", setAlertnessRadius, getAlertnessRadius, xmlelement, mode).defaultValues(500.0f);
     55        XMLPortParam(WaypointPatrolController, "attackradius", setAttackRadius, getAttackRadius, xmlelement, mode).defaultValues(1000.0f);
    5456    }
    5557
     
    5961            return;
    6062
    61         if (this->target_)
     63        if (this->target_) //if there is a target, follow it and shoot it, if it is close enough
    6264        {
    6365            this->aimAtTarget();
     
    6668                this->moveToTargetPosition();
    6769
    68             if (this->getControllableEntity() && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f))
     70            if (this->getControllableEntity() && this->isCloseAtTarget(this->attackradius_) && this->isLookingAtTarget(math::pi / 20.0f))
    6971                this->getControllableEntity()->fire(0);
    7072        }
  • code/branches/levelElias/src/orxonox/controllers/WaypointPatrolController.h

    r9667 r9732  
    5050            inline float getAlertnessRadius() const
    5151                { return this->alertnessradius_; }
     52               
     53            inline void setAttackRadius(float distance)
     54                { this->attackradius_ = distance; }
     55            inline float getAttackRadius() const
     56                { return this->attackradius_; }
    5257
    5358        protected:
    5459            void searchEnemy();
    5560
    56             float alertnessradius_;
     61            float alertnessradius_; //!< Enemies within this radius are being followed and shot.
     62            float attackradius_;    //!< Enemies only get shot, if they are within the attackradius_.
    5763            Timer patrolTimer_;
    5864    };
  • code/branches/levelElias/src/orxonox/gametypes/Mission.cc

    r9667 r9732  
    3232
    3333#include "core/CoreIncludes.h"
     34#include "core/command/ConsoleCommand.h"
     35#include "infos/PlayerInfo.h"
    3436#include "network/Host.h"
    3537#include "worldentities/pawns/Pawn.h"
    3638
     39
    3740namespace orxonox
    3841{
     42    SetConsoleCommand("Mission", "endMission", &Mission::endMission);
     43    SetConsoleCommand("Mission", "setLives", &Mission::setLivesWrapper);
    3944    RegisterUnloadableClass(Mission);
    4045
     
    5661            this->end();
    5762        }
     63        else if (this->lives_ == 0)
     64        {
     65            this->missionAccomplished_ = false;
     66            this->end();
     67        }
    5868    }
    5969
    6070    void Mission::pawnKilled(Pawn* victim, Pawn* killer)
    6171    {
    62         if (victim && victim->getPlayer() && this->lives_ == 1)
     72        if (victim && victim->getPlayer() && victim->getPlayer()->isHumanPlayer() )
    6373        {
    64             this->missionAccomplished_ = false;
    65             this->end();
     74            this->lives_--;
    6675        }
    6776    }
     
    7887    {
    7988        Gametype::end();
    80         /*if (this->missionAccomplished_)
     89        if (this->missionAccomplished_)
    8190            this->gtinfo_->sendAnnounceMessage("Mission accomplished!");
    8291        else
    8392            this->gtinfo_->sendAnnounceMessage("Mission failed!");
    84         */
    8593    }
    8694
     
    94102        }
    95103    }
    96 
     104    void Mission::endMission(bool accomplished)
     105    {
     106        for (ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)
     107        {//TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would end ALL missions!
     108            it->setMissionAccomplished(accomplished);
     109            it->end();
     110        }
     111    }
     112   
     113    void Mission::setLivesWrapper(unsigned int amount)
     114    {
     115        for (ObjectList<Mission>::iterator it = ObjectList<Mission>::begin(); it != ObjectList<Mission>::end(); ++it)
     116        {//TODO: make sure that only the desired mission is ended !! This is a dirty HACK, that would affect ALL missions!
     117            it->setLives(amount);
     118        }
     119    }
    97120
    98121
  • code/branches/levelElias/src/orxonox/gametypes/Mission.h

    r9667 r9732  
    5252            inline unsigned int getLives()
    5353                {return this->lives_;}
     54            inline void setMissionAccomplished(bool acc)
     55                {this->missionAccomplished_ = acc;}
     56            static void endMission(bool accomplished);
     57            static void setLivesWrapper(unsigned int amount);
    5458
    5559        protected:
     
    5761            bool missionAccomplished_; //<! indicates if player successfully finsihed the mission;
    5862            int lives_; //<! amount of player's lives <-> nr. of retries
    59 
     63            //<! If the lives_ are set negative -> unlimited lives.
    6064    };
    6165}
Note: See TracChangeset for help on using the changeset viewer.