Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 31, 2013, 10:18:39 PM (11 years ago)
Author:
jo
Message:

Creating new console command to set the lives in a mission.

Location:
code/trunk/src/orxonox/gametypes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/gametypes/Mission.cc

    r9728 r9729  
    3333#include "core/CoreIncludes.h"
    3434#include "core/command/ConsoleCommand.h"
     35#include "infos/PlayerInfo.h"
    3536#include "network/Host.h"
    3637#include "worldentities/pawns/Pawn.h"
     38
    3739
    3840namespace orxonox
    3941{
    4042    SetConsoleCommand("Mission", "endMission", &Mission::endMission);
     43    SetConsoleCommand("Mission", "setLives", &Mission::setLivesWrapper);
    4144    RegisterUnloadableClass(Mission);
    4245
     
    6265    void Mission::pawnKilled(Pawn* victim, Pawn* killer)
    6366    {
    64         if (victim && victim->getPlayer() && this->lives_ == 1)
     67        if (victim && victim->getPlayer() && victim->getPlayer()->isHumanPlayer() )
    6568        {
    66             this->missionAccomplished_ = false;
    67             this->end();
     69            this->lives_--;
     70            if (this->lives_ == 0)
     71            {
     72                this->missionAccomplished_ = false;
     73                this->end();
     74            }
    6875        }
    6976    }
     
    103110        }
    104111    }
     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    }
    105120
    106121
  • code/trunk/src/orxonox/gametypes/Mission.h

    r9728 r9729  
    5555                {this->missionAccomplished_ = acc;}
    5656            static void endMission(bool accomplished);
     57            static void setLivesWrapper(unsigned int amount);
    5758
    5859        protected:
     
    6061            bool missionAccomplished_; //<! indicates if player successfully finsihed the mission;
    6162            int lives_; //<! amount of player's lives <-> nr. of retries
    62             //Make end() a callback function to the event "END"
    63             //or create a console command.
    64 
     63            //<! If the lives_ are set negative -> unlimited lives.
    6564    };
    6665}
Note: See TracChangeset for help on using the changeset viewer.