diff options
author | krzys-h <krzys_h@interia.pl> | 2013-12-26 18:50:05 +0100 |
---|---|---|
committer | krzys-h <krzys_h@interia.pl> | 2013-12-26 18:50:05 +0100 |
commit | 0d31f59b124658155bf93ca78eb427a98c664572 (patch) | |
tree | a5046a80ede9829d1c82a23808c1522fcbac1581 /src/script/script.cpp | |
parent | bd4f77986a025132b2b335ee34a6681c469439b1 (diff) | |
download | colobot-0d31f59b124658155bf93ca78eb427a98c664572.tar.gz colobot-0d31f59b124658155bf93ca78eb427a98c664572.tar.bz2 colobot-0d31f59b124658155bf93ca78eb427a98c664572.zip |
.takeoff() for SpaceShip (#265)
Diffstat (limited to 'src/script/script.cpp')
-rw-r--r-- | src/script/script.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/script/script.cpp b/src/script/script.cpp index 1a70699..05e2626 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -38,6 +38,7 @@ #include "object/auto/auto.h" #include "object/auto/autofactory.h" +#include "object/auto/autobase.h" #include "physics/physics.h" @@ -901,6 +902,54 @@ bool CScript::rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& return true; } +// Instruction "object.takeoff()" + +bool CScript::rTakeOff(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception) +{ + Error err; + + exception = 0; + + 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* center = CObjectManager::GetInstancePointer()->SearchInstance(rank); + CAuto* automat = center->GetAuto(); + + if ( thisType == OBJECT_BASE ) + { + err = (static_cast<CAutoBase*>(automat))->TakeOff(false); + } else + err = ERR_WRONG_OBJ; + + 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; +} + // Compilation of the instruction "delete(rank[, exploType[, force]])". CBotTypResult CScript::cDelete(CBotVar* &var, void* user) |