summaryrefslogtreecommitdiffstats
path: root/src/script
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2013-12-26 18:50:05 +0100
committerkrzys-h <krzys_h@interia.pl>2013-12-26 18:50:05 +0100
commit0d31f59b124658155bf93ca78eb427a98c664572 (patch)
treea5046a80ede9829d1c82a23808c1522fcbac1581 /src/script
parentbd4f77986a025132b2b335ee34a6681c469439b1 (diff)
downloadcolobot-0d31f59b124658155bf93ca78eb427a98c664572.tar.gz
colobot-0d31f59b124658155bf93ca78eb427a98c664572.tar.bz2
colobot-0d31f59b124658155bf93ca78eb427a98c664572.zip
.takeoff() for SpaceShip (#265)
Diffstat (limited to 'src/script')
-rw-r--r--src/script/cbottoken.cpp9
-rw-r--r--src/script/script.cpp49
-rw-r--r--src/script/script.h1
3 files changed, 56 insertions, 3 deletions
diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp
index 505228e..9f99752 100644
--- a/src/script/cbottoken.cpp
+++ b/src/script/cbottoken.cpp
@@ -253,10 +253,11 @@ std::string GetHelpFilename(const char *token)
if ( strcmp(token, "getresearchenable" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresen.txt");
if ( strcmp(token, "getresearchdone" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresdo.txt");
if ( strcmp(token, "retobject" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/retobj.txt");
- if ( strcmp(token, "progfunc" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.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, "progfunc" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt");
+ if ( strcmp(token, "busy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/busy.txt");
+ if ( strcmp(token, "takeoff" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/takeoff.txt");
if ( strcmp(token, "research" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/research.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");
@@ -384,6 +385,7 @@ bool IsFunction(const char *token)
if ( strcmp(token, "busy" ) == 0 ) return true;
if ( strcmp(token, "factory" ) == 0 ) return true;
if ( strcmp(token, "research" ) == 0 ) return true;
+ if ( strcmp(token, "takeoff" ) == 0 ) return true;
if ( strcmp(token, "destroy" ) == 0 ) return true;
if ( strcmp(token, "search" ) == 0 ) return true;
if ( strcmp(token, "radar" ) == 0 ) return true;
@@ -477,6 +479,7 @@ const char* GetHelpText(const char *token)
if ( strcmp(token, "busy" ) == 0 ) return "object.busy ( );";
if ( strcmp(token, "factory" ) == 0 ) return "object.factory ( cat, program );";
if ( strcmp(token, "research" ) == 0 ) return "object.research ( type );";
+ if ( strcmp(token, "takeoff" ) == 0 ) return "object.takeoff ( );";
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 );";
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)
diff --git a/src/script/script.h b/src/script/script.h
index 3641dd9..9d8d372 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -200,6 +200,7 @@ public:
static bool rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
static bool rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
static bool rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
+ static bool rTakeOff(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
static bool rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
private: