summaryrefslogtreecommitdiffstats
path: root/src/script/script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/script.cpp')
-rw-r--r--src/script/script.cpp165
1 files changed, 7 insertions, 158 deletions
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 05e2626..fbf7276 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -1870,52 +1870,10 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
}
}
- if ( type == OBJECT_FRET ||
- type == OBJECT_STONE ||
- type == OBJECT_URANIUM ||
- type == OBJECT_METAL ||
- type == OBJECT_POWER ||
- type == OBJECT_ATOMIC ||
- type == OBJECT_BULLET ||
- type == OBJECT_BBOX ||
- type == OBJECT_KEYa ||
- type == OBJECT_KEYb ||
- type == OBJECT_KEYc ||
- type == OBJECT_KEYd ||
- type == OBJECT_TNT ||
- type == OBJECT_SCRAP1 ||
- type == OBJECT_SCRAP2 ||
- type == OBJECT_SCRAP3 ||
- type == OBJECT_SCRAP4 ||
- type == OBJECT_SCRAP5 ||
- type == OBJECT_BOMB ||
- type == OBJECT_WAYPOINT ||
- type == OBJECT_SHOW ||
- type == OBJECT_WINFIRE ||
- type == OBJECT_BAG ||
- type == OBJECT_MARKPOWER ||
- type == OBJECT_MARKSTONE ||
- type == OBJECT_MARKURANIUM ||
- type == OBJECT_MARKKEYa ||
- type == OBJECT_MARKKEYb ||
- type == OBJECT_MARKKEYc ||
- type == OBJECT_MARKKEYd ||
- type == OBJECT_EGG )
- {
- object = new CObject();
- if ( !object->CreateResource(pos, angle, type) )
- {
- delete object;
- result->SetValInt(1); // error
- return true;
- }
- object->SetActivity(false);
- }
- else if ( type == OBJECT_MOTHER ||
- type == OBJECT_ANT ||
- type == OBJECT_SPIDER ||
- type == OBJECT_BEE ||
- type == OBJECT_WORM )
+ if ( type == OBJECT_ANT ||
+ type == OBJECT_SPIDER ||
+ type == OBJECT_BEE ||
+ type == OBJECT_WORM )
{
CObject* egg;
@@ -1933,124 +1891,15 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
delete egg;
}
object->SetActivity(false);
- }
- else if ( type == OBJECT_PORTICO ||
- type == OBJECT_BASE ||
- type == OBJECT_DERRICK ||
- type == OBJECT_FACTORY ||
- type == OBJECT_STATION ||
- type == OBJECT_CONVERT ||
- type == OBJECT_REPAIR ||
- type == OBJECT_DESTROYER||
- type == OBJECT_TOWER ||
- type == OBJECT_NEST ||
- type == OBJECT_RESEARCH ||
- type == OBJECT_RADAR ||
- type == OBJECT_INFO ||
- type == OBJECT_ENERGY ||
- type == OBJECT_LABO ||
- type == OBJECT_NUCLEAR ||
- type == OBJECT_PARA ||
- type == OBJECT_SAFE ||
- type == OBJECT_HUSTON ||
- type == OBJECT_TARGET1 ||
- type == OBJECT_TARGET2 ||
- type == OBJECT_START ||
- type == OBJECT_END )
- {
- object = new CObject();
- if ( !object->CreateBuilding(pos, angle, 0, type) )
+ } else {
+ object = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, type, power);
+ if ( object == nullptr )
{
- delete object;
result->SetValInt(1); // error
return true;
}
- object->SetActivity(true);
-
- CAuto* automat = object->GetAuto();
- if (automat != nullptr)
- {
- automat->Init();
- }
-
script->m_main->CreateShortcuts();
}
- else if ( type == OBJECT_FLAGb ||
- type == OBJECT_FLAGr ||
- type == OBJECT_FLAGg ||
- type == OBJECT_FLAGy ||
- type == OBJECT_FLAGv )
- {
- object = new CObject();
- if ( !object->CreateFlag(pos, angle, type) )
- {
- delete object;
- result->SetValInt(1); // error
- return true;
- }
- object->SetActivity(false);
- }
- else if ( type == OBJECT_HUMAN ||
- type == OBJECT_TECH ||
- type == OBJECT_TOTO ||
- type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEwa ||
- type == OBJECT_MOBILEia ||
- type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEwc ||
- type == OBJECT_MOBILEic ||
- type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEwi ||
- type == OBJECT_MOBILEii ||
- type == OBJECT_MOBILEfs ||
- type == OBJECT_MOBILEts ||
- type == OBJECT_MOBILEws ||
- type == OBJECT_MOBILEis ||
- type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs ||
- type == OBJECT_MOBILEsa ||
- type == OBJECT_MOBILEtg ||
- type == OBJECT_MOBILEft ||
- type == OBJECT_MOBILEtt ||
- type == OBJECT_MOBILEwt ||
- type == OBJECT_MOBILEit ||
- type == OBJECT_MOBILEdr ||
- type == OBJECT_APOLLO2 )
- {
- object = new CObject();
- if ( !object->CreateVehicle(pos, angle, type, power, false, false) )
- {
- delete object;
- result->SetValInt(1); // error
- return true;
- }
- object->UpdateMapping();
- object->SetRange(30.0f);
- object->SetZoom(0, 1.0f);
- CPhysics* physics = object->GetPhysics();
- if ( physics != 0 )
- {
- physics->SetFreeze(false); // can move
- }
- object->SetLock(false); // vehicle useable
- // SetManual will affect bot speed
- if (type == OBJECT_MOBILEdr)
- {
- object->SetManual(true);
- }
- object->SetActivity(true);
- script->m_main->CreateShortcuts();
- }
- else
- {
- result->SetValInt(1); // impossible
- return true;
- }
if (name[0] != 0)
{