diff options
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/cbottoken.cpp | 5 | ||||
-rw-r--r-- | src/script/script.cpp | 50 | ||||
-rw-r--r-- | src/script/script.h | 2 |
3 files changed, 56 insertions, 1 deletions
diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index c56482f..b5e99f5 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -255,6 +255,7 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "retobject" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/retobj.txt"); if ( strcmp(token, "busy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/busy.txt"); if ( strcmp(token, "factory" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt"); + if ( strcmp(token, "destroy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/destroy.txt"); if ( strcmp(token, "search" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/search.txt"); if ( strcmp(token, "radar" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/radar.txt"); if ( strcmp(token, "direction" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/direct.txt"); @@ -379,6 +380,7 @@ bool IsFunction(const char *token) if ( strcmp(token, "retobject" ) == 0 ) return true; if ( strcmp(token, "busy" ) == 0 ) return true; if ( strcmp(token, "factory" ) == 0 ) return true; + if ( strcmp(token, "destroy" ) == 0 ) return true; if ( strcmp(token, "search" ) == 0 ) return true; if ( strcmp(token, "radar" ) == 0 ) return true; if ( strcmp(token, "detect" ) == 0 ) return true; @@ -467,8 +469,9 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "getresearchdone" ) == 0 ) return "getresearchdone ( );"; if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( rank );"; if ( strcmp(token, "retobjectbyid") == 0 ) return "retobjectbyid ( rank );"; - if ( strcmp(token, "busy" ) == 0 ) return "object.busy ( cat );"; + if ( strcmp(token, "busy" ) == 0 ) return "object.busy ( );"; if ( strcmp(token, "factory" ) == 0 ) return "object.factory ( cat );"; + if ( strcmp(token, "destroy" ) == 0 ) return "object.destroy ( );"; if ( strcmp(token, "search" ) == 0 ) return "search ( );"; if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens );"; if ( strcmp(token, "detect" ) == 0 ) return "detect ( cat );"; diff --git a/src/script/script.cpp b/src/script/script.cpp index 0271eb6..527da93 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -70,6 +70,11 @@ CBotTypResult CScript::cNull(CBotVar* &var, void* user) return CBotTypResult(CBotTypFloat); } +CBotTypResult CScript::cClassNull(CBotVar* thisclass, CBotVar* &var) +{ + return CScript::cNull(var, nullptr); +} + // Compiling a procedure with a single real number. CBotTypResult CScript::cOneFloat(CBotVar* &var, void* user) @@ -538,6 +543,51 @@ bool CScript::rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exce return true; } +bool CScript::rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception) +{ + exception = 0; + Error err; + + CBotVar* classVars = thisclass->GetItemList(); // "category" + ObjectType thisType = static_cast<ObjectType>(classVars->GetValInt()); + classVars = classVars->GetNext(); // "position" + classVars = classVars->GetNext(); // "orientation" + classVars = classVars->GetNext(); // "pitch" + classVars = classVars->GetNext(); // "roll" + classVars = classVars->GetNext(); // "energyLevel" + classVars = classVars->GetNext(); // "shieldLevel" + classVars = classVars->GetNext(); // "temperature" + classVars = classVars->GetNext(); // "altitude" + classVars = classVars->GetNext(); // "lifeTime" + classVars = classVars->GetNext(); // "material" + classVars = classVars->GetNext(); // "energyCell" + classVars = classVars->GetNext(); // "load" + classVars = classVars->GetNext(); // "id" + int rank = classVars->GetValInt(); + CObject* obj = CObjectManager::GetInstancePointer()->SearchInstance(rank); + CAuto* automat = obj->GetAuto(); + + if ( thisType == OBJECT_DESTROYER ) + { + err = automat->StartAction(0); + } else + err = ERR_MANIP_VEH; + + if ( err != ERR_OK ) + { + result->SetValInt(err); // return error +//TODO: if ( script->m_errMode == ERM_STOP ) + if( true ) + { + exception = err; + return false; + } + return true; + } + + return true; +} + // Instruction "object.factory(cat)" bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception) diff --git a/src/script/script.h b/src/script/script.h index ae9011b..75f0d72 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -193,9 +193,11 @@ private: public: static CBotTypResult cBusy(CBotVar* thisclass, CBotVar* &var); static CBotTypResult cClassOneFloat(CBotVar* thisclass, CBotVar* &var); + static CBotTypResult cClassNull(CBotVar* thisclass, CBotVar* &var); static bool rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); static bool rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); + static bool rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception); private: static bool Process(CScript* script, CBotVar* result, int &exception); |