Added function endmission()
Works only with MissionFile version=3 Created for MissionController, but works on any bot - 1st parameter: * ResultWin - win mission * ResultLost - lost mission * ResultLostQuick - lost mission (Me died) - 2nd parameter: win/lost delay, like in mission file. Doesn't work for ResultLostQuick. Please don't use for cheating =)dev-ui
parent
a06397d1af
commit
643153d64d
|
@ -811,6 +811,11 @@ CRobotMain::CRobotMain(CApplication* app)
|
|||
CBotProgram::DefineNum("ExploBurn", EXPLO_BURN);
|
||||
CBotProgram::DefineNum("ExploWater", EXPLO_WATER);
|
||||
|
||||
CBotProgram::DefineNum("ResultNotEnded", ERR_MISSION_NOTERM);
|
||||
CBotProgram::DefineNum("ResultLost", INFO_LOST);
|
||||
CBotProgram::DefineNum("ResultLostQuick", INFO_LOSTq);
|
||||
CBotProgram::DefineNum("ResultWin", ERR_OK);
|
||||
|
||||
CBotProgram::DefineNum("PolskiPortalColobota", 1337);
|
||||
|
||||
CBotClass* bc;
|
||||
|
@ -3896,6 +3901,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
|
||||
m_version = 1;
|
||||
m_retroStyle = false;
|
||||
|
||||
m_missionResult = ERR_MISSION_NOTERM;
|
||||
}
|
||||
|
||||
char line[500];
|
||||
|
@ -6727,10 +6734,40 @@ void CRobotMain::UpdateAudio(bool frame)
|
|||
}
|
||||
}
|
||||
|
||||
void CRobotMain::SetEndMission(Error result, float delay)
|
||||
{
|
||||
if (m_version >= 3) {
|
||||
m_endTakeWinDelay = delay;
|
||||
m_endTakeLostDelay = delay;
|
||||
m_missionResult = result;
|
||||
}
|
||||
}
|
||||
|
||||
//! Checks if the mission is over
|
||||
Error CRobotMain::CheckEndMission(bool frame)
|
||||
{
|
||||
if (m_version >= 3) return ERR_MISSION_NOTERM; //disabled. TODO: Control from program
|
||||
if (m_version >= 3) {
|
||||
if (m_missionResult == INFO_LOST) { //mission lost?
|
||||
m_displayText->DisplayError(INFO_LOST, Math::Vector(0.0f,0.0f,0.0f));
|
||||
m_winDelay = 0.0f;
|
||||
if(m_lostDelay == 0) m_lostDelay = m_endTakeLostDelay;
|
||||
m_displayText->SetEnable(false);
|
||||
}
|
||||
if (m_missionResult == INFO_LOSTq) { //mission lost?
|
||||
m_winDelay = 0.0f;
|
||||
if(m_lostDelay == 0) m_lostDelay = 0.1f;
|
||||
m_displayText->SetEnable(false);
|
||||
}
|
||||
if (frame && m_base) return ERR_MISSION_NOTERM;
|
||||
if (m_missionResult == ERR_OK) { //mission win?
|
||||
if (!(frame && m_base)) m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f));
|
||||
if(m_winDelay == 0) m_winDelay = m_endTakeWinDelay;
|
||||
m_lostDelay = 0.0f;
|
||||
m_displayText->SetEnable(false);
|
||||
}
|
||||
if (m_missionResult == ERR_MISSION_NOTERM) m_displayText->SetEnable(true);
|
||||
return m_missionResult;
|
||||
}
|
||||
|
||||
CInstanceManager* iMan = CInstanceManager::GetInstancePointer();
|
||||
|
||||
|
|
|
@ -265,6 +265,7 @@ public:
|
|||
void ResetObject();
|
||||
void ResetCreate();
|
||||
void UpdateAudio(bool frame);
|
||||
void SetEndMission(Error result, float delay);
|
||||
Error CheckEndMission(bool frame);
|
||||
void CheckEndMessage(const char* message);
|
||||
int GetObligatoryToken();
|
||||
|
@ -556,6 +557,8 @@ protected:
|
|||
int m_freeBuild; // constructible buildings
|
||||
int m_freeResearch; // researches possible
|
||||
|
||||
Error m_missionResult;
|
||||
|
||||
ShowLimit m_showLimit[MAXSHOWLIMIT];
|
||||
|
||||
Gfx::Color m_colorRefBot;
|
||||
|
|
|
@ -313,6 +313,35 @@ bool CScript::rAbs(CBotVar* var, CBotVar* result, int& exception, void* user)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Compilation of the instruction "endmission(result)"
|
||||
|
||||
CBotTypResult CScript::cEndMission(CBotVar* &var, void* user)
|
||||
{
|
||||
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
|
||||
if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
|
||||
var = var->GetNext();
|
||||
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
|
||||
if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
|
||||
var = var->GetNext();
|
||||
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
|
||||
return CBotTypResult(CBotTypFloat);
|
||||
}
|
||||
|
||||
// Instruction "endmission(result)"
|
||||
|
||||
bool CScript::rEndMission(CBotVar* var, CBotVar* result, int& exception, void* user)
|
||||
{
|
||||
Error ended;
|
||||
float delay;
|
||||
|
||||
ended = static_cast<Error>(var->GetValFloat());
|
||||
var = var->GetNext();
|
||||
|
||||
delay = var->GetValFloat();
|
||||
|
||||
CRobotMain::GetInstancePointer()->SetEndMission(ended, delay);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Compilation of the instruction "retobject(rank)".
|
||||
|
||||
|
@ -2950,6 +2979,8 @@ void CScript::InitFonctions()
|
|||
CBotProgram::AddFunction("rand", rRand, CScript::cNull);
|
||||
CBotProgram::AddFunction("abs", rAbs, CScript::cOneFloat);
|
||||
|
||||
CBotProgram::AddFunction("endmission",rEndMission,CScript::cEndMission);
|
||||
|
||||
CBotProgram::AddFunction("retobject", rGetObject, CScript::cGetObject);
|
||||
CBotProgram::AddFunction("destroy", rDestroy, CScript::cDestroy);
|
||||
CBotProgram::AddFunction("search", rSearch, CScript::cSearch);
|
||||
|
|
|
@ -99,6 +99,7 @@ private:
|
|||
static CBotTypResult cOneFloat(CBotVar* &var, void* user);
|
||||
static CBotTypResult cTwoFloat(CBotVar* &var, void* user);
|
||||
static CBotTypResult cString(CBotVar* &var, void* user);
|
||||
static CBotTypResult cEndMission(CBotVar* &var, void* user);
|
||||
static CBotTypResult cGetObject(CBotVar* &var, void* user);
|
||||
static CBotTypResult cDestroy(CBotVar* &var, void* user);
|
||||
static CBotTypResult cSearch(CBotVar* &var, void* user);
|
||||
|
@ -134,6 +135,7 @@ private:
|
|||
static bool rPow(CBotVar* var, CBotVar* result, int& exception, void* user);
|
||||
static bool rRand(CBotVar* var, CBotVar* result, int& exception, void* user);
|
||||
static bool rAbs(CBotVar* var, CBotVar* result, int& exception, void* user);
|
||||
static bool rEndMission(CBotVar* var, CBotVar* result, int& exception, void* user);
|
||||
static bool rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user);
|
||||
static bool rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user);
|
||||
static bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user);
|
||||
|
|
Loading…
Reference in New Issue