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.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.