Added special mode in scene for bots to build more buildings than they usualy can
Will be used in "Leaving Earth" missions for making decorative bots building basedev-ui
parent
a806d4257c
commit
fbe2bf8bc7
|
@ -276,6 +276,7 @@ CObject::CObject()
|
|||
m_lastVirusParticle = 0.0f;
|
||||
m_totalDesectList = 0;
|
||||
m_bLock = false;
|
||||
m_bIgnoreBuildCheck = false;
|
||||
m_bExplo = false;
|
||||
m_bCargo = false;
|
||||
m_bBurn = false;
|
||||
|
@ -6781,7 +6782,7 @@ float CObject::GetParam()
|
|||
|
||||
// Management of the mode "blocked" of an object.
|
||||
// For example, a cube of titanium is blocked while it is used to make something,
|
||||
//or a vehicle is blocked as its construction is not finished.
|
||||
// or a vehicle is blocked as its construction is not finished.
|
||||
|
||||
void CObject::SetLock(bool bLock)
|
||||
{
|
||||
|
@ -6793,6 +6794,18 @@ bool CObject::GetLock()
|
|||
return m_bLock;
|
||||
}
|
||||
|
||||
// Ignore checks in build() function
|
||||
|
||||
void CObject::SetIgnoreBuildCheck(bool bIgnoreBuildCheck)
|
||||
{
|
||||
m_bIgnoreBuildCheck = bIgnoreBuildCheck;
|
||||
}
|
||||
|
||||
bool CObject::GetIgnoreBuildCheck()
|
||||
{
|
||||
return m_bIgnoreBuildCheck;
|
||||
}
|
||||
|
||||
// Management of the mode "current explosion" of an object.
|
||||
// An object in this mode is not saving.
|
||||
|
||||
|
|
|
@ -582,6 +582,9 @@ public:
|
|||
|
||||
void SetParam(float value);
|
||||
float GetParam();
|
||||
|
||||
void SetIgnoreBuildCheck(bool bIgnoreBuildCheck);
|
||||
bool GetIgnoreBuildCheck();
|
||||
|
||||
void SetExplo(bool bExplo);
|
||||
bool GetExplo();
|
||||
|
@ -720,6 +723,7 @@ protected:
|
|||
bool m_bTrainer; // drive vehicle (without remote)
|
||||
bool m_bToy; // toy key
|
||||
bool m_bManual; // manual control (Scribbler)
|
||||
bool m_bIgnoreBuildCheck;
|
||||
bool m_bFixed;
|
||||
bool m_bClip;
|
||||
bool m_bShowLimit;
|
||||
|
|
|
@ -4593,6 +4593,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
{
|
||||
m_controller = CObjectManager::GetInstancePointer()->CreateObject(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f, OBJECT_CONTROLLER, 100.0f);
|
||||
m_controller->SetMagnifyDamage(100.0f);
|
||||
m_controller->SetIgnoreBuildCheck(true);
|
||||
CBrain* brain = m_controller->GetBrain();
|
||||
if (brain != nullptr)
|
||||
{
|
||||
|
@ -4720,6 +4721,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
|
||||
bool selectable = OpInt(line, "selectable", 1);
|
||||
obj->SetSelectable(selectable);
|
||||
obj->SetIgnoreBuildCheck(OpInt(line, "ignoreBuildCheck", 0));
|
||||
obj->SetEnable(OpInt(line, "enable", 1));
|
||||
obj->SetProxyActivate(OpInt(line, "proxyActivate", 0));
|
||||
obj->SetProxyDistance(OpFloat(line, "proxyDistance", 15.0f)*g_unit);
|
||||
|
@ -6068,6 +6070,9 @@ void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd)
|
|||
|
||||
sprintf(name, " trainer=%d", obj->GetTrainer());
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " ignoreBuildCheck=%d", obj->GetIgnoreBuildCheck());
|
||||
strcat(line, name);
|
||||
|
||||
sprintf(name, " option=%d", obj->GetOption());
|
||||
strcat(line, name);
|
||||
|
@ -6229,6 +6234,7 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank)
|
|||
obj->SetDefRank(objRank);
|
||||
obj->SetPosition(0, pos);
|
||||
obj->SetAngle(0, dir);
|
||||
obj->SetIgnoreBuildCheck(OpInt(line, "ignoreBuildCheck", 0));
|
||||
obj->SetID(id);
|
||||
if (g_id < id) g_id = id;
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle)
|
|||
if ( m_type == OBJECT_PARA ) m_buildingHeight = 68.0f;
|
||||
if ( m_type == OBJECT_INFO ) m_buildingHeight = 19.0f;
|
||||
if ( m_type == OBJECT_DESTROYER) m_buildingHeight = 35.0f;
|
||||
if ( m_type == OBJECT_HUSTON ) m_buildingHeight = 45.0f;
|
||||
m_buildingHeight *= 0.25f;
|
||||
|
||||
m_buildingPos = m_building->GetPosition(0);
|
||||
|
@ -574,7 +575,7 @@ Error CTaskBuild::FlatFloor()
|
|||
if ( m_type == OBJECT_PARA ) radius = 20.0f;
|
||||
if ( m_type == OBJECT_INFO ) radius = 5.0f;
|
||||
if ( m_type == OBJECT_DESTROYER) radius = 20.0f;
|
||||
if ( radius == 0.0f ) return ERR_GENERIC;
|
||||
//if ( radius == 0.0f ) return ERR_GENERIC;
|
||||
|
||||
center = m_metal->GetPosition(0);
|
||||
angle = m_terrain->GetFineSlope(center);
|
||||
|
|
|
@ -1665,7 +1665,7 @@ bool CScript::rCanBuild(CBotVar* var, CBotVar* result, int& exception, void* use
|
|||
(category == OBJECT_DESTROYER && (g_build & BUILD_DESTROYER)))
|
||||
{
|
||||
|
||||
//if we want to build not researched one
|
||||
// if we want to build not researched one
|
||||
if ( (category == OBJECT_TOWER && !(g_researchDone & RESEARCH_TOWER)) ||
|
||||
(category == OBJECT_NUCLEAR && !(g_researchDone & RESEARCH_ATOMIC))
|
||||
)
|
||||
|
@ -1709,7 +1709,7 @@ bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
|
|||
}
|
||||
else
|
||||
{
|
||||
category = static_cast<ObjectType>(var->GetValInt()); //get category parameter
|
||||
category = static_cast<ObjectType>(var->GetValInt()); // get category parameter
|
||||
if ( (category == OBJECT_DERRICK && (g_build & BUILD_DERRICK)) ||
|
||||
(category == OBJECT_FACTORY && (g_build & BUILD_FACTORY)) ||
|
||||
(category == OBJECT_STATION && (g_build & BUILD_STATION)) ||
|
||||
|
@ -1726,7 +1726,7 @@ bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
|
|||
(category == OBJECT_DESTROYER && (g_build & BUILD_DESTROYER)))
|
||||
{
|
||||
|
||||
//if we want to build not researched one
|
||||
// if we want to build not researched one
|
||||
if ( (category == OBJECT_TOWER && !(g_researchDone & RESEARCH_TOWER)) ||
|
||||
(category == OBJECT_NUCLEAR && !(g_researchDone & RESEARCH_ATOMIC))
|
||||
)
|
||||
|
@ -1739,8 +1739,11 @@ bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
if (pThis->GetIgnoreBuildCheck())
|
||||
err = ERR_OK;
|
||||
|
||||
if (err == ERR_OK && script->m_primaryTask == 0) //if we can build and no task is present
|
||||
if (err == ERR_OK && script->m_primaryTask == 0) // if we can build and no task is present
|
||||
{
|
||||
script->m_primaryTask = new CTaskManager(script->m_object);
|
||||
err = script->m_primaryTask->StartTaskBuild(category);
|
||||
|
@ -1751,9 +1754,9 @@ bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
|
|||
script->m_primaryTask = 0;
|
||||
}
|
||||
}
|
||||
//When script is waiting for finishing this task, it sets ERR_OK, and continues executing Process
|
||||
//without creating new task. I think, there was a problem with previous version in release configuration
|
||||
//It did not init error variable in this situation, and code tried to use variable with trash inside
|
||||
// When script is waiting for finishing this task, it sets ERR_OK, and continues executing Process
|
||||
// without creating new task. I think, there was a problem with previous version in release configuration
|
||||
// It did not init error variable in this situation, and code tried to use variable with trash inside
|
||||
}
|
||||
|
||||
if ( err != ERR_OK )
|
||||
|
|
Loading…
Reference in New Issue