Add auto object detection for takeoff, destroy, camerafocus
parent
0b36bdf37f
commit
94aa76e7a1
|
@ -406,7 +406,12 @@ bool CScriptFunctions::rDestroy(CBotVar* var, CBotVar* result, int& exception, v
|
|||
exception = 0;
|
||||
Error err;
|
||||
|
||||
CObject* obj = static_cast<CObject*>(var->GetUserPtr());
|
||||
CObject* obj;
|
||||
if (var == nullptr)
|
||||
obj = CObjectManager::GetInstancePointer()->FindNearest(pThis, OBJECT_DESTROYER);
|
||||
else
|
||||
obj = static_cast<CObject*>(var->GetUserPtr());
|
||||
|
||||
if (obj == nullptr)
|
||||
{
|
||||
exception = ERR_WRONG_OBJ;
|
||||
|
@ -660,7 +665,12 @@ bool CScriptFunctions::rTakeOff(CBotVar* var, CBotVar* result, int& exception, v
|
|||
Error err;
|
||||
|
||||
exception = 0;
|
||||
CObject* base = static_cast<CObject*>(var->GetUserPtr());
|
||||
CObject* base;
|
||||
if (var == nullptr)
|
||||
base = CObjectManager::GetInstancePointer()->FindNearest(pThis, OBJECT_BASE);
|
||||
else
|
||||
base = static_cast<CObject*>(var->GetUserPtr());
|
||||
|
||||
if (base == nullptr)
|
||||
{
|
||||
exception = ERR_WRONG_OBJ;
|
||||
|
@ -3015,20 +3025,29 @@ bool CScriptFunctions::rPenWidth(CBotVar* var, CBotVar* result, int& exception,
|
|||
|
||||
CBotTypResult CScriptFunctions::cOneObject(CBotVar* &var, void* user)
|
||||
{
|
||||
if ( var == nullptr ) return CBotTypResult(CBotErrLowParam);
|
||||
var = var->GetNext();
|
||||
if ( var == nullptr ) return CBotTypResult(CBotTypFloat);
|
||||
|
||||
if ( var != nullptr )
|
||||
{
|
||||
var = var->GetNext();
|
||||
if ( var == nullptr ) return CBotTypResult(CBotTypFloat);
|
||||
}
|
||||
else
|
||||
return CBotTypResult(CBotTypFloat);
|
||||
|
||||
return CBotTypResult(CBotErrOverParam);
|
||||
|
||||
}
|
||||
|
||||
// Instruction "camerafocus(object)".
|
||||
|
||||
bool CScriptFunctions::rCameraFocus(CBotVar* var, CBotVar* result, int& exception, void* user)
|
||||
{
|
||||
CScript* script = static_cast<CScript*>(user);
|
||||
CScript* script = static_cast<CScript*>(user);
|
||||
|
||||
CObject* object = static_cast<CObject*>(var->GetUserPtr());
|
||||
CObject* object;
|
||||
if (var == nullptr)
|
||||
object = script->m_object;
|
||||
else
|
||||
object = static_cast<CObject*>(var->GetUserPtr());
|
||||
|
||||
script->m_main->SelectObject(object, false);
|
||||
|
||||
|
|
Loading…
Reference in New Issue