From 796cb92ffc7dc03f9cc7107cac5ddb81795d0549 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 18 May 2013 17:38:44 +0200 Subject: Added object.destroy() --- src/script/script.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'src/script/script.cpp') 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(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) -- cgit v1.2.3-1-g7c22