summaryrefslogtreecommitdiffstats
path: root/src/script/script.cpp
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2013-05-18 17:38:44 +0200
committerkrzys-h <krzys_h@interia.pl>2013-05-18 18:04:48 +0200
commit796cb92ffc7dc03f9cc7107cac5ddb81795d0549 (patch)
treec53eddc06665e251956773f290fdb89440b52ac2 /src/script/script.cpp
parentd0de6a88ba5095c4d485e281e6fb3e804b0c21b6 (diff)
downloadcolobot-796cb92ffc7dc03f9cc7107cac5ddb81795d0549.tar.gz
colobot-796cb92ffc7dc03f9cc7107cac5ddb81795d0549.tar.bz2
colobot-796cb92ffc7dc03f9cc7107cac5ddb81795d0549.zip
Added object.destroy()
Diffstat (limited to 'src/script/script.cpp')
-rw-r--r--src/script/script.cpp50
1 files changed, 50 insertions, 0 deletions
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)