diff --git a/.gitignore b/.gitignore index f3461be1..e8069d37 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,9 @@ CMakeLists.txt.user.* # Ignore Visual Studio Code files /.vscode +# Ignore CLion files +/.idea + # Ignore Visual Studio files /CMakeSettings.json /.vs diff --git a/data b/data index c467bd99..d1c52c9c 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit c467bd994e60fb54cf977fbe8583f92957330695 +Subproject commit d1c52c9cdb763ed127e89e51b0c921f85d8760b6 diff --git a/po/colobot.pot b/po/colobot.pot index 7cbb92d7..c3e68eba 100644 --- a/po/colobot.pot +++ b/po/colobot.pot @@ -817,6 +817,18 @@ msgstr "" msgid "Build a legged sniffer" msgstr "" +msgid "Build a winged builder" +msgstr "" + +msgid "Build a tracked builder" +msgstr "" + +msgid "Build a wheeled builder" +msgstr "" + +msgid "Build a legged builder" +msgstr "" + msgid "Build a thumper" msgstr "" @@ -832,6 +844,9 @@ msgstr "" msgid "Build a subber" msgstr "" +msgid "Build a target bot" +msgstr "" + msgid "Run research program for tracked bots" msgstr "" @@ -862,6 +877,12 @@ msgstr "" msgid "Run research program for orga shooter" msgstr "" +msgid "Run research program for builder" +msgstr "" + +msgid "Run research program for target bot" +msgstr "" + msgid "Return to start" msgstr "" @@ -877,6 +898,9 @@ msgstr "" msgid "Explode (\\key action;)" msgstr "" +msgid "Build (\\key action;)" +msgstr "" + msgid "Recycle (\\key action;)" msgstr "" @@ -1255,6 +1279,18 @@ msgstr "" msgid "Legged grabber" msgstr "" +msgid "Winged builder" +msgstr "" + +msgid "Tracked builder" +msgstr "" + +msgid "Wheeled builder" +msgstr "" + +msgid "Legged builder" +msgstr "" + msgid "Winged shooter" msgstr "" @@ -1471,7 +1507,7 @@ msgstr "" msgid "Nothing to analyze" msgstr "" -msgid "Analyzes only organic matter" +msgid "Inappropriate sample" msgstr "" msgid "Analysis already performed" @@ -1570,6 +1606,9 @@ msgstr "" msgid "Plans for nuclear power plant available" msgstr "" +msgid "Plans for builder available" +msgstr "" + msgid "New bot available" msgstr "" diff --git a/src/common/error.h b/src/common/error.h index e344d04c..91dc0022 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -138,6 +138,7 @@ enum Error INFO_RESEARCHPHAZER = 10035, //! < research ended INFO_RESEARCHSHIELD = 10036, //! < research ended INFO_RESEARCHATOMIC = 10037, //! < research ended + INFO_RESEARCHBUILDER = 10038, //! < research ended INFO_WIN = 10040, //! < win INFO_LOST = 10041, //! < lost INFO_LOSTq = 10042, //! < lost immediately diff --git a/src/common/event.cpp b/src/common/event.cpp index 302c2702..c405f4bc 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -424,11 +424,16 @@ void InitializeEventTypeTexts() EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYts] = "EVENT_OBJECT_FACTORYts"; EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfs] = "EVENT_OBJECT_FACTORYfs"; EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYis] = "EVENT_OBJECT_FACTORYis"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYwb] = "EVENT_OBJECT_FACTORYwb"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYtb] = "EVENT_OBJECT_FACTORYtb"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYfb] = "EVENT_OBJECT_FACTORYfb"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYib] = "EVENT_OBJECT_FACTORYib"; EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrt] = "EVENT_OBJECT_FACTORYrt"; EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrc] = "EVENT_OBJECT_FACTORYrc"; EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrr] = "EVENT_OBJECT_FACTORYrr"; EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYrs] = "EVENT_OBJECT_FACTORYrs"; EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYsa] = "EVENT_OBJECT_FACTORYsa"; + EVENT_TYPE_TEXT[EVENT_OBJECT_FACTORYtg] = "EVENT_OBJECT_FACTORYtg"; EVENT_TYPE_TEXT[EVENT_OBJECT_SEARCH] = "EVENT_OBJECT_SEARCH"; EVENT_TYPE_TEXT[EVENT_OBJECT_TERRAFORM] = "EVENT_OBJECT_TERRAFORM"; EVENT_TYPE_TEXT[EVENT_OBJECT_FIRE] = "EVENT_OBJECT_FIRE"; @@ -524,6 +529,10 @@ void InitializeEventTypeTexts() EVENT_TYPE_TEXT[EVENT_CODE_BATTLE_START] = "EVENT_CODE_BATTLE_START"; EVENT_TYPE_TEXT[EVENT_CODE_BATTLE_SPECTATOR] = "EVENT_CODE_BATTLE_SPECTATOR"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RBUILDER] = "EVENT_OBJECT_RBUILDER"; + EVENT_TYPE_TEXT[EVENT_OBJECT_BUILD] = "EVENT_OBJECT_BUILD"; + EVENT_TYPE_TEXT[EVENT_OBJECT_RTARGET] = "EVENT_OBJECT_RTARGET"; + EVENT_TYPE_TEXT[EVENT_VIEWPOINT0] = "EVENT_VIEWPOINT0"; EVENT_TYPE_TEXT[EVENT_VIEWPOINT1] = "EVENT_VIEWPOINT1"; EVENT_TYPE_TEXT[EVENT_VIEWPOINT2] = "EVENT_VIEWPOINT2"; diff --git a/src/common/event.h b/src/common/event.h index a9353e5e..fe92bf05 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -493,6 +493,11 @@ enum EventType EVENT_OBJECT_FACTORYrr = 1098, EVENT_OBJECT_FACTORYrs = 1099, EVENT_OBJECT_FACTORYsa = 1100, + EVENT_OBJECT_FACTORYwb = 1101, + EVENT_OBJECT_FACTORYtb = 1102, + EVENT_OBJECT_FACTORYfb = 1103, + EVENT_OBJECT_FACTORYib = 1104, + EVENT_OBJECT_FACTORYtg = 1105, EVENT_OBJECT_SEARCH = 1200, EVENT_OBJECT_TERRAFORM = 1201, EVENT_OBJECT_FIRE = 1202, @@ -595,6 +600,10 @@ enum EventType EVENT_CODE_BATTLE_START = 2200, //!< button that starts the code battle EVENT_CODE_BATTLE_SPECTATOR = 2201, //!< button that controls the code battle spectator camera + EVENT_OBJECT_RBUILDER = 2300, + EVENT_OBJECT_BUILD = 2301, + EVENT_OBJECT_RTARGET = 2302, + //! Buttons that switch viewpoints EVENT_VIEWPOINT0 = 3000, EVENT_VIEWPOINT1 = 3001, diff --git a/src/common/restext.cpp b/src/common/restext.cpp index a79f3f55..5728b774 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -362,11 +362,16 @@ void InitializeRestext() stringsEvent[EVENT_OBJECT_FACTORYts] = TR("Build a tracked sniffer"); stringsEvent[EVENT_OBJECT_FACTORYws] = TR("Build a wheeled sniffer"); stringsEvent[EVENT_OBJECT_FACTORYis] = TR("Build a legged sniffer"); + stringsEvent[EVENT_OBJECT_FACTORYfb] = TR("Build a winged builder"); + stringsEvent[EVENT_OBJECT_FACTORYtb] = TR("Build a tracked builder"); + stringsEvent[EVENT_OBJECT_FACTORYwb] = TR("Build a wheeled builder"); + stringsEvent[EVENT_OBJECT_FACTORYib] = TR("Build a legged builder"); stringsEvent[EVENT_OBJECT_FACTORYrt] = TR("Build a thumper"); stringsEvent[EVENT_OBJECT_FACTORYrc] = TR("Build a phazer shooter"); stringsEvent[EVENT_OBJECT_FACTORYrr] = TR("Build a recycler"); stringsEvent[EVENT_OBJECT_FACTORYrs] = TR("Build a shielder"); stringsEvent[EVENT_OBJECT_FACTORYsa] = TR("Build a subber"); + stringsEvent[EVENT_OBJECT_FACTORYtg] = TR("Build a target bot"); stringsEvent[EVENT_OBJECT_RTANK] = TR("Run research program for tracked bots"); stringsEvent[EVENT_OBJECT_RFLY] = TR("Run research program for winged bots"); stringsEvent[EVENT_OBJECT_RTHUMP] = TR("Run research program for thumper"); @@ -377,11 +382,14 @@ void InitializeRestext() stringsEvent[EVENT_OBJECT_RATOMIC] = TR("Run research program for nuclear power"); stringsEvent[EVENT_OBJECT_RiPAW] = TR("Run research program for legged bots"); stringsEvent[EVENT_OBJECT_RiGUN] = TR("Run research program for orga shooter"); + stringsEvent[EVENT_OBJECT_RBUILDER] = TR("Run research program for builder"); + stringsEvent[EVENT_OBJECT_RTARGET] = TR("Run research program for target bot"); stringsEvent[EVENT_OBJECT_RESET] = TR("Return to start"); stringsEvent[EVENT_OBJECT_SEARCH] = TR("Sniff (\\key action;)"); stringsEvent[EVENT_OBJECT_TERRAFORM] = TR("Thump (\\key action;)"); stringsEvent[EVENT_OBJECT_FIRE] = TR("Shoot (\\key action;)"); stringsEvent[EVENT_OBJECT_SPIDEREXPLO] = TR("Explode (\\key action;)"); + stringsEvent[EVENT_OBJECT_BUILD] = TR("Build (\\key action;)"); stringsEvent[EVENT_OBJECT_RECOVER] = TR("Recycle (\\key action;)"); stringsEvent[EVENT_OBJECT_BEGSHIELD] = TR("Extend shield (\\key action;)"); stringsEvent[EVENT_OBJECT_ENDSHIELD] = TR("Withdraw shield (\\key action;)"); @@ -518,10 +526,16 @@ void InitializeRestext() stringsObject[OBJECT_MOBILEtt] = TR("Practice bot"); stringsObject[OBJECT_MOBILEwt] = TR("Practice bot"); stringsObject[OBJECT_MOBILEit] = TR("Practice bot"); + stringsObject[OBJECT_MOBILErp] = TR("Practice bot"); + stringsObject[OBJECT_MOBILEst] = TR("Practice bot"); stringsObject[OBJECT_MOBILEfa] = TR("Winged grabber"); stringsObject[OBJECT_MOBILEta] = TR("Tracked grabber"); stringsObject[OBJECT_MOBILEwa] = TR("Wheeled grabber"); stringsObject[OBJECT_MOBILEia] = TR("Legged grabber"); + stringsObject[OBJECT_MOBILEfb] = TR("Winged builder"); + stringsObject[OBJECT_MOBILEtb] = TR("Tracked builder"); + stringsObject[OBJECT_MOBILEwb] = TR("Wheeled builder"); + stringsObject[OBJECT_MOBILEib] = TR("Legged builder"); stringsObject[OBJECT_MOBILEfc] = TR("Winged shooter"); stringsObject[OBJECT_MOBILEtc] = TR("Tracked shooter"); stringsObject[OBJECT_MOBILEwc] = TR("Wheeled shooter"); @@ -621,7 +635,7 @@ void InitializeRestext() stringsErr[ERR_BASE_DLOCK] = TR("Doors blocked by a robot or another object"); stringsErr[ERR_BASE_DHUMAN] = TR("You must get on the spaceship to take off"); stringsErr[ERR_LABO_NULL] = TR("Nothing to analyze"); - stringsErr[ERR_LABO_BAD] = TR("Analyzes only organic matter"); + stringsErr[ERR_LABO_BAD] = TR("Inappropriate sample"); stringsErr[ERR_LABO_ALREADY] = TR("Analysis already performed"); stringsErr[ERR_NUCLEAR_EMPTY] = TR("No uranium to transform"); stringsErr[ERR_NUCLEAR_BAD] = TR("Transforms only uranium"); @@ -659,6 +673,7 @@ void InitializeRestext() stringsErr[INFO_RESEARCHPHAZER] = TR("Plans for phazer shooter available"); stringsErr[INFO_RESEARCHSHIELD] = TR("Plans for shielder available"); stringsErr[INFO_RESEARCHATOMIC] = TR("Plans for nuclear power plant available"); + stringsErr[INFO_RESEARCHBUILDER]= TR("Plans for builder available"); stringsErr[INFO_FACTORY] = TR("New bot available"); stringsErr[INFO_LABO] = TR("Analysis performed"); stringsErr[INFO_ENERGY] = TR("Power cell available"); diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 348514bb..ea7a9ebb 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -2310,6 +2310,7 @@ bool CEngine::LoadAllTextures() LoadTexture("textures/interface/button1.png"); LoadTexture("textures/interface/button2.png"); LoadTexture("textures/interface/button3.png"); + LoadTexture("textures/interface/button4.png"); LoadTexture("textures/effect00.png"); LoadTexture("textures/effect01.png"); LoadTexture("textures/effect02.png"); diff --git a/src/graphics/engine/oldmodelmanager.cpp b/src/graphics/engine/oldmodelmanager.cpp index e7ac426b..086db9f5 100644 --- a/src/graphics/engine/oldmodelmanager.cpp +++ b/src/graphics/engine/oldmodelmanager.cpp @@ -193,6 +193,7 @@ void COldModelManager::ChangeVariant(std::vector& triangles, int triangles[i].tex1Name == "factory.png" || triangles[i].tex1Name == "lemt.png" || triangles[i].tex1Name == "roller.png" || + triangles[i].tex1Name == "rollert.png" || triangles[i].tex1Name == "search.png" || triangles[i].tex1Name == "drawer.png" || triangles[i].tex1Name == "subm.png" ) diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp index effbaff5..00a1d863 100644 --- a/src/graphics/engine/particle.cpp +++ b/src/graphics/engine/particle.cpp @@ -67,7 +67,6 @@ static bool IsAlien(ObjectType type) type == OBJECT_NEST || type == OBJECT_BULLET || type == OBJECT_EGG || - type == OBJECT_MOBILEtg || type == OBJECT_TEEN28 || type == OBJECT_TEEN31 ); } diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp index c4d31dd9..2813db56 100644 --- a/src/graphics/engine/pyro.cpp +++ b/src/graphics/engine/pyro.cpp @@ -1268,6 +1268,10 @@ void CPyro::DisplayError(PyroType type, CObject* obj) oType == OBJECT_MOBILEta || oType == OBJECT_MOBILEfa || oType == OBJECT_MOBILEia || + oType == OBJECT_MOBILEwb || + oType == OBJECT_MOBILEtb || + oType == OBJECT_MOBILEfb || + oType == OBJECT_MOBILEib || oType == OBJECT_MOBILEwc || oType == OBJECT_MOBILEtc || oType == OBJECT_MOBILEfc || @@ -1289,6 +1293,8 @@ void CPyro::DisplayError(PyroType type, CObject* obj) oType == OBJECT_MOBILEtt || oType == OBJECT_MOBILEft || oType == OBJECT_MOBILEit || + oType == OBJECT_MOBILErp || + oType == OBJECT_MOBILEst || oType == OBJECT_MOBILEdr ) { err = ERR_DELETEMOBILE; @@ -1729,6 +1735,7 @@ void CPyro::BurnStart() angle.z = (Math::Rand()-0.5f)*0.4f; } else if ( m_burnType == OBJECT_MOBILEwa || + m_burnType == OBJECT_MOBILEwb || m_burnType == OBJECT_MOBILEwc || m_burnType == OBJECT_MOBILEwi || m_burnType == OBJECT_MOBILEws || @@ -1933,6 +1940,20 @@ void CPyro::BurnStart() BurnAddPart(1, pos, angle); // down the insect-cannon } + if ( m_burnType == OBJECT_MOBILEfb || + m_burnType == OBJECT_MOBILEtb || + m_burnType == OBJECT_MOBILEwb || + m_burnType == OBJECT_MOBILEib ) + { + pos.x = -1.5f; + pos.y = -5.0f; + pos.z = 0.0f; + angle.x = (Math::Rand()-0.5f)*0.2f; + angle.y = (Math::Rand()-0.5f)*0.2f; + angle.z = -25.0f*Math::PI/180.0f; + BurnAddPart(1, pos, angle); // down the neutron gun + } + if ( m_burnType == OBJECT_MOBILErt || m_burnType == OBJECT_MOBILErc ) { @@ -2019,6 +2040,7 @@ void CPyro::BurnStart() } if ( m_burnType == OBJECT_MOBILEwa || + m_burnType == OBJECT_MOBILEwb || m_burnType == OBJECT_MOBILEwc || m_burnType == OBJECT_MOBILEwi || m_burnType == OBJECT_MOBILEws || @@ -2041,14 +2063,18 @@ void CPyro::BurnStart() } if ( m_burnType == OBJECT_MOBILEta || + m_burnType == OBJECT_MOBILEtb || m_burnType == OBJECT_MOBILEtc || m_burnType == OBJECT_MOBILEti || m_burnType == OBJECT_MOBILEts || + m_burnType == OBJECT_MOBILEtt || m_burnType == OBJECT_MOBILErt || m_burnType == OBJECT_MOBILErc || m_burnType == OBJECT_MOBILErr || m_burnType == OBJECT_MOBILErs || + m_burnType == OBJECT_MOBILErp || m_burnType == OBJECT_MOBILEsa || + m_burnType == OBJECT_MOBILEst || m_burnType == OBJECT_MOBILEdr ) // caterpillars? { pos.x = 0.0f; @@ -2069,6 +2095,7 @@ void CPyro::BurnStart() } if ( m_burnType == OBJECT_MOBILEfa || + m_burnType == OBJECT_MOBILEfb || m_burnType == OBJECT_MOBILEfc || m_burnType == OBJECT_MOBILEfi || m_burnType == OBJECT_MOBILEfs || @@ -2089,9 +2116,11 @@ void CPyro::BurnStart() } if ( m_burnType == OBJECT_MOBILEia || + m_burnType == OBJECT_MOBILEib || m_burnType == OBJECT_MOBILEic || m_burnType == OBJECT_MOBILEii || - m_burnType == OBJECT_MOBILEis ) // legs? + m_burnType == OBJECT_MOBILEis || + m_burnType == OBJECT_MOBILEit ) // legs? { for (int i = 0; i < 6; i++) { @@ -2214,6 +2243,7 @@ void CPyro::BurnTerminate() { m_object->SetType(OBJECT_RUINmobilew1); // Wreck (recoverable by Recycler) } + dynamic_cast(m_object)->SetDying(DeathType::Alive); m_object->SetLock(false); } diff --git a/src/graphics/engine/water.cpp b/src/graphics/engine/water.cpp index a890e377..0057876e 100644 --- a/src/graphics/engine/water.cpp +++ b/src/graphics/engine/water.cpp @@ -566,6 +566,10 @@ float CWater::GetLevel(CObject* object) type == OBJECT_MOBILEta || type == OBJECT_MOBILEwa || type == OBJECT_MOBILEia || + type == OBJECT_MOBILEfb || + type == OBJECT_MOBILEtb || + type == OBJECT_MOBILEwb || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEfc || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEwc || @@ -588,6 +592,8 @@ float CWater::GetLevel(CObject* object) type == OBJECT_MOBILEtt || type == OBJECT_MOBILEwt || type == OBJECT_MOBILEit || + type == OBJECT_MOBILErp || + type == OBJECT_MOBILEst || type == OBJECT_MOBILEdr ) { return m_level-2.0f; diff --git a/src/level/parser/parserparam.cpp b/src/level/parser/parserparam.cpp index c4ee9b31..515dc717 100644 --- a/src/level/parser/parserparam.cpp +++ b/src/level/parser/parserparam.cpp @@ -340,6 +340,12 @@ ObjectType CLevelParserParam::ToObjectType(std::string value) if (value == "Portico" ) return OBJECT_PORTICO; if (value == "SpaceShip" ) return OBJECT_BASE; if (value == "PracticeBot" ) return OBJECT_MOBILEwt; + if (value == "WingedTrainer" ) return OBJECT_MOBILEft; + if (value == "TrackedTrainer" ) return OBJECT_MOBILEtt; + if (value == "WheeledTrainer" ) return OBJECT_MOBILEwt; + if (value == "LeggedTrainer" ) return OBJECT_MOBILEit; + if (value == "HeavyTrainer" ) return OBJECT_MOBILErp; + if (value == "AmphibiousTrainer" ) return OBJECT_MOBILEst; if (value == "WingedGrabber" ) return OBJECT_MOBILEfa; if (value == "TrackedGrabber" ) return OBJECT_MOBILEta; if (value == "WheeledGrabber" ) return OBJECT_MOBILEwa; @@ -356,6 +362,10 @@ ObjectType CLevelParserParam::ToObjectType(std::string value) if (value == "TrackedSniffer" ) return OBJECT_MOBILEts; if (value == "WheeledSniffer" ) return OBJECT_MOBILEws; if (value == "LeggedSniffer" ) return OBJECT_MOBILEis; + if (value == "WingedBuilder" ) return OBJECT_MOBILEfb; + if (value == "TrackedBuilder" ) return OBJECT_MOBILEtb; + if (value == "WheeledBuilder" ) return OBJECT_MOBILEwb; + if (value == "LeggedBuilder" ) return OBJECT_MOBILEib; if (value == "Thumper" ) return OBJECT_MOBILErt; if (value == "PhazerShooter" ) return OBJECT_MOBILErc; if (value == "Recycler" ) return OBJECT_MOBILErr; @@ -540,7 +550,12 @@ const std::string CLevelParserParam::FromObjectType(ObjectType value) { if (value == OBJECT_PORTICO ) return "Portico"; if (value == OBJECT_BASE ) return "SpaceShip"; - if (value == OBJECT_MOBILEwt ) return "PracticeBot"; + if (value == OBJECT_MOBILEwt ) return "WheeledTrainer"; + if (value == OBJECT_MOBILEft ) return "WingedTrainer"; + if (value == OBJECT_MOBILEtt ) return "TrackedTrainer"; + if (value == OBJECT_MOBILEit ) return "LeggedTrainer"; + if (value == OBJECT_MOBILErp ) return "HeavyTrainer"; + if (value == OBJECT_MOBILEst ) return "AmphibiousTrainer"; if (value == OBJECT_MOBILEfa ) return "WingedGrabber"; if (value == OBJECT_MOBILEta ) return "TrackedGrabber"; if (value == OBJECT_MOBILEwa ) return "WheeledGrabber"; @@ -557,6 +572,10 @@ const std::string CLevelParserParam::FromObjectType(ObjectType value) if (value == OBJECT_MOBILEts ) return "TrackedSniffer"; if (value == OBJECT_MOBILEws ) return "WheeledSniffer"; if (value == OBJECT_MOBILEis ) return "LeggedSniffer"; + if (value == OBJECT_MOBILEfb ) return "WingedBuilder"; + if (value == OBJECT_MOBILEtb ) return "TrackedBuilder"; + if (value == OBJECT_MOBILEwb ) return "WheeledBuilder"; + if (value == OBJECT_MOBILEib ) return "LeggedBuilder"; if (value == OBJECT_MOBILErt ) return "Thumper"; if (value == OBJECT_MOBILErc ) return "PhazerShooter"; if (value == OBJECT_MOBILErr ) return "Recycler"; @@ -750,12 +769,13 @@ ObjectType CLevelParserParam::AsObjectType(ObjectType def) DriveType CLevelParserParam::ToDriveType(std::string value) { - if (value == "Wheeled") return DriveType::Wheeled; - if (value == "Tracked") return DriveType::Tracked; - if (value == "Winged" ) return DriveType::Winged; - if (value == "Legged" ) return DriveType::Legged; - if (value == "BigTracked") return DriveType::BigTracked; - if (value == "Other" ) return DriveType::Other; + if (value == "Wheeled" ) return DriveType::Wheeled; + if (value == "Tracked" ) return DriveType::Tracked; + if (value == "Winged" ) return DriveType::Winged; + if (value == "Legged" ) return DriveType::Legged; + if (value == "Heavy" ) return DriveType::Heavy; + if (value == "Amphibious") return DriveType::Amphibious; + if (value == "Other" ) return DriveType::Other; return static_cast(Cast(value, "drive")); } @@ -780,6 +800,7 @@ ToolType CLevelParserParam::ToToolType(std::string value) if (value == "Sniffer" ) return ToolType::Sniffer; if (value == "Shooter" ) return ToolType::Shooter; if (value == "OrgaShooter") return ToolType::OrganicShooter; + if (value == "Builder" ) return ToolType::Builder; if (value == "Other" ) return ToolType::Other; return static_cast(Cast(value, "tool")); } @@ -900,6 +921,8 @@ int CLevelParserParam::ToResearchFlag(std::string value) if (value == "RECYCLER") return RESEARCH_RECYCLER; if (value == "SUBBER" ) return RESEARCH_SUBM; if (value == "SNIFFER" ) return RESEARCH_SNIFFER; + if (value == "BUILDER" ) return RESEARCH_BUILDER; + if (value == "TARGET" ) return RESEARCH_TARGET; /* /9j/4AAQSkZJRgABAQEAYABgAAD//gATQ3JlYXRlZCB3aXRoIEdJTVD/2wBDACAWGBwYFCAcGhwk * IiAmMFA0MCwsMGJGSjpQdGZ6eHJmcG6AkLicgIiuim5woNqirr7EztDOfJri8uDI8LjKzsb/2wBD diff --git a/src/level/research_type.h b/src/level/research_type.h index add78a56..8cb9fdfb 100644 --- a/src/level/research_type.h +++ b/src/level/research_type.h @@ -38,5 +38,7 @@ enum ResearchType RESEARCH_iGUN = (1<<9), //! < cannon of insects RESEARCH_RECYCLER = (1<<10), //! < recycler RESEARCH_SUBM = (1<<11), //! < submarine - RESEARCH_SNIFFER = (1<<12) //! < sniffer + RESEARCH_SNIFFER = (1<<12), //! < sniffer + RESEARCH_BUILDER = (1<<13), //! < builder + RESEARCH_TARGET = (1<<14) //! < target bot }; diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index dea86bcb..d554e232 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -1830,6 +1830,10 @@ void CRobotMain::SelectOneObject(CObject* obj, bool displayError) type == OBJECT_MOBILEta || type == OBJECT_MOBILEwa || type == OBJECT_MOBILEia || + type == OBJECT_MOBILEfb || + type == OBJECT_MOBILEtb || + type == OBJECT_MOBILEwb || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEfc || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEwc || @@ -1851,6 +1855,8 @@ void CRobotMain::SelectOneObject(CObject* obj, bool displayError) type == OBJECT_MOBILEtt || type == OBJECT_MOBILEwt || type == OBJECT_MOBILEit || + type == OBJECT_MOBILErp || + type == OBJECT_MOBILEst || type == OBJECT_MOBILEdr || type == OBJECT_APOLLO2 ) { @@ -2211,6 +2217,10 @@ void CRobotMain::ChangeCamera() oType != OBJECT_MOBILEta && oType != OBJECT_MOBILEwa && oType != OBJECT_MOBILEia && + oType != OBJECT_MOBILEfb && + oType != OBJECT_MOBILEtb && + oType != OBJECT_MOBILEwb && + oType != OBJECT_MOBILEib && oType != OBJECT_MOBILEfc && oType != OBJECT_MOBILEtc && oType != OBJECT_MOBILEwc && @@ -2233,6 +2243,8 @@ void CRobotMain::ChangeCamera() oType != OBJECT_MOBILEtt && oType != OBJECT_MOBILEwt && oType != OBJECT_MOBILEit && + oType != OBJECT_MOBILErp && + oType != OBJECT_MOBILEst && oType != OBJECT_MOBILEdr && oType != OBJECT_APOLLO2 ) return; @@ -3971,6 +3983,7 @@ void CRobotMain::ChangeColor() m_engine->ChangeTextureColor("textures/objects/lemt.png"+teamStr, "textures/objects/lemt.png", COLOR_REF_BOT, newColor, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, nullptr, 0, true); m_engine->ChangeTextureColor("textures/objects/roller.png"+teamStr, "textures/objects/roller.png", COLOR_REF_BOT, newColor, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, nullptr, 0, true); m_engine->ChangeTextureColor("textures/objects/search.png"+teamStr, "textures/objects/search.png", COLOR_REF_BOT, newColor, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, nullptr, 0, true); + m_engine->ChangeTextureColor("textures/objects/rollert.png"+teamStr, "textures/objects/rollert.png", COLOR_REF_BOT, newColor, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, nullptr, 0, true); exclu[0] = Math::Point( 0.0f/256.0f, 160.0f/256.0f); exclu[1] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // pencils @@ -5882,17 +5895,20 @@ Error CRobotMain::CanFactoryError(ObjectType type, int team) if (tool == ToolType::Sniffer && !IsResearchDone(RESEARCH_SNIFFER, team)) return ERR_BUILD_RESEARCH; if (tool == ToolType::Shooter && !IsResearchDone(RESEARCH_CANON, team)) return ERR_BUILD_RESEARCH; if (tool == ToolType::OrganicShooter && !IsResearchDone(RESEARCH_iGUN, team)) return ERR_BUILD_RESEARCH; + if (tool == ToolType::Builder && !IsResearchDone(RESEARCH_BUILDER, team)) return ERR_BUILD_RESEARCH; if (drive == DriveType::Tracked && !IsResearchDone(RESEARCH_TANK, team)) return ERR_BUILD_RESEARCH; if (drive == DriveType::Winged && !IsResearchDone(RESEARCH_FLY, team)) return ERR_BUILD_RESEARCH; if (drive == DriveType::Legged && !IsResearchDone(RESEARCH_iPAW, team)) return ERR_BUILD_RESEARCH; - if (drive == DriveType::BigTracked && !IsResearchDone(RESEARCH_TANK, team)) return ERR_BUILD_RESEARCH; // NOTE: Subber is not BigTracked! It currently counts as Other + if (drive == DriveType::Heavy && !IsResearchDone(RESEARCH_TANK, team)) return ERR_BUILD_RESEARCH; if (type == OBJECT_MOBILErt && !IsResearchDone(RESEARCH_THUMP, team)) return ERR_BUILD_RESEARCH; if (type == OBJECT_MOBILErc && !IsResearchDone(RESEARCH_PHAZER, team)) return ERR_BUILD_RESEARCH; if (type == OBJECT_MOBILErr && !IsResearchDone(RESEARCH_RECYCLER, team)) return ERR_BUILD_RESEARCH; if (type == OBJECT_MOBILErs && !IsResearchDone(RESEARCH_SHIELD, team)) return ERR_BUILD_RESEARCH; if (type == OBJECT_MOBILEsa && !IsResearchDone(RESEARCH_SUBM, team)) return ERR_BUILD_DISABLED; // Can be only researched manually in Scene file + if (type == OBJECT_MOBILEst && !IsResearchDone(RESEARCH_SUBM, team)) return ERR_BUILD_DISABLED; + if (type == OBJECT_MOBILEtg && !IsResearchDone(RESEARCH_TARGET, team)) return ERR_BUILD_RESEARCH; return ERR_OK; } diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp index 32b2428b..b1e374da 100644 --- a/src/object/auto/autobase.cpp +++ b/src/object/auto/autobase.cpp @@ -1187,25 +1187,27 @@ bool CAutoBase::CreateInterface(bool bSelect) oy = 3.0f/480.0f; sx = 33.0f/640.0f; sy = 33.0f/480.0f; - - ddim.x = dim.x*1.5f; - ddim.y = dim.y*1.5f; - -//? pos.x = ox+sx*7.25f; -//? pos.y = oy+sy*0.25f; -//? pw->CreateButton(pos, ddim, 63, EVENT_OBJECT_BHELP); - - pos.x = ox+sx*8.00f; - pos.y = oy+sy*0.25f; - pw->CreateButton(pos, ddim, 28, EVENT_OBJECT_BTAKEOFF); - - if ( m_lightning->GetStatus(sleep, delay, magnetic, progress) ) + if( !m_object->GetTrainer() ) { - pos.x = ox+sx*10.2f; - pos.y = oy+sy*0.5f; - ddim.x = dim.x*1.0f; - ddim.y = dim.y*1.0f; - pw->CreateButton(pos, ddim, 41, EVENT_OBJECT_LIMIT); + ddim.x = dim.x*1.5f; + ddim.y = dim.y*1.5f; + + //? pos.x = ox+sx*7.25f; + //? pos.y = oy+sy*0.25f; + //? pw->CreateButton(pos, ddim, 63, EVENT_OBJECT_BHELP); + + pos.x = ox+sx*8.00f; + pos.y = oy+sy*0.25f; + pw->CreateButton(pos, ddim, 28, EVENT_OBJECT_BTAKEOFF); + + if ( m_lightning->GetStatus(sleep, delay, magnetic, progress) ) + { + pos.x = ox+sx*10.2f; + pos.y = oy+sy*0.5f; + ddim.x = dim.x*1.0f; + ddim.y = dim.y*1.0f; + pw->CreateButton(pos, ddim, 41, EVENT_OBJECT_LIMIT); + } } pos.x = ox+sx*0.0f; diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp index 343d57b9..867626ce 100644 --- a/src/object/auto/autofactory.cpp +++ b/src/object/auto/autofactory.cpp @@ -186,11 +186,16 @@ static ObjectType ObjectTypeFromFactoryButton(EventType eventType) if ( eventType == EVENT_OBJECT_FACTORYti ) return OBJECT_MOBILEti; if ( eventType == EVENT_OBJECT_FACTORYfi ) return OBJECT_MOBILEfi; if ( eventType == EVENT_OBJECT_FACTORYii ) return OBJECT_MOBILEii; + if ( eventType == EVENT_OBJECT_FACTORYwb ) return OBJECT_MOBILEwb; + if ( eventType == EVENT_OBJECT_FACTORYtb ) return OBJECT_MOBILEtb; + if ( eventType == EVENT_OBJECT_FACTORYfb ) return OBJECT_MOBILEfb; + if ( eventType == EVENT_OBJECT_FACTORYib ) return OBJECT_MOBILEib; if ( eventType == EVENT_OBJECT_FACTORYrt ) return OBJECT_MOBILErt; if ( eventType == EVENT_OBJECT_FACTORYrc ) return OBJECT_MOBILErc; if ( eventType == EVENT_OBJECT_FACTORYrr ) return OBJECT_MOBILErr; if ( eventType == EVENT_OBJECT_FACTORYrs ) return OBJECT_MOBILErs; if ( eventType == EVENT_OBJECT_FACTORYsa ) return OBJECT_MOBILEsa; + if ( eventType == EVENT_OBJECT_FACTORYtg ) return OBJECT_MOBILEtg; return OBJECT_NULL; } @@ -587,6 +592,10 @@ bool CAutoFactory::NearestVehicle() type != OBJECT_MOBILEta && type != OBJECT_MOBILEwa && type != OBJECT_MOBILEia && + type != OBJECT_MOBILEfb && + type != OBJECT_MOBILEtb && + type != OBJECT_MOBILEwb && + type != OBJECT_MOBILEib && type != OBJECT_MOBILEfc && type != OBJECT_MOBILEtc && type != OBJECT_MOBILEwc && @@ -609,6 +618,8 @@ bool CAutoFactory::NearestVehicle() type != OBJECT_MOBILEtt && type != OBJECT_MOBILEwt && type != OBJECT_MOBILEit && + type != OBJECT_MOBILErp && + type != OBJECT_MOBILEst && type != OBJECT_MOBILEdr && type != OBJECT_MOTHER && type != OBJECT_ANT && @@ -653,6 +664,7 @@ bool CAutoFactory::CreateVehicle() params.angle = angle; params.type = m_type; params.team = m_object->GetTeam(); + params.trainer = m_object->GetTrainer(); CObject* vehicle = CObjectManager::GetInstancePointer()->CreateObject(params); vehicle->SetLock(true); // not usable @@ -718,66 +730,80 @@ bool CAutoFactory::CreateInterface(bool bSelect) oy = 3.0f/480.0f; sx = 33.0f/640.0f; sy = 33.0f/480.0f; + if( !m_object->GetTrainer() ) + { + pos.x = 0.0f; + pos.y = oy+sy*2.6f; + ddim.x = 138.0f/640.0f; + ddim.y = 258.0f/480.0f; + pw->CreateGroup(pos, ddim, 6, EVENT_WINDOW3); - pos.x = 0.0f; - pos.y = oy+sy*2.6f; - ddim.x = 138.0f/640.0f; - ddim.y = 222.0f/480.0f; - pw->CreateGroup(pos, ddim, 6, EVENT_WINDOW3); + pos.x = ox+sx*0.0f; + pos.y = oy+sy*9.3f; + pw->CreateButton(pos, dim, 128+9, EVENT_OBJECT_FACTORYwa); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+10, EVENT_OBJECT_FACTORYta); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+11, EVENT_OBJECT_FACTORYfa); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+22, EVENT_OBJECT_FACTORYia); - pos.x = ox+sx*0.0f; - pos.y = oy+sy*8.2f; - pw->CreateButton(pos, dim, 128+9, EVENT_OBJECT_FACTORYwa); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+10, EVENT_OBJECT_FACTORYta); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+11, EVENT_OBJECT_FACTORYfa); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+22, EVENT_OBJECT_FACTORYia); + pos.x = ox+sx*0.0f; + pos.y = oy+sy*8.2f; + pw->CreateButton(pos, dim, 128+12, EVENT_OBJECT_FACTORYws); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+13, EVENT_OBJECT_FACTORYts); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+14, EVENT_OBJECT_FACTORYfs); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+24, EVENT_OBJECT_FACTORYis); - pos.x = ox+sx*0.0f; - pos.y = oy+sy*7.1f; - pw->CreateButton(pos, dim, 128+12, EVENT_OBJECT_FACTORYws); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+13, EVENT_OBJECT_FACTORYts); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+14, EVENT_OBJECT_FACTORYfs); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+24, EVENT_OBJECT_FACTORYis); + pos.x = ox+sx*0.0f; + pos.y = oy+sy*7.1f; + pw->CreateButton(pos, dim, 128+15, EVENT_OBJECT_FACTORYwc); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+16, EVENT_OBJECT_FACTORYtc); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+17, EVENT_OBJECT_FACTORYfc); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+23, EVENT_OBJECT_FACTORYic); - pos.x = ox+sx*0.0f; - pos.y = oy+sy*6.0f; - pw->CreateButton(pos, dim, 128+15, EVENT_OBJECT_FACTORYwc); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+16, EVENT_OBJECT_FACTORYtc); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+17, EVENT_OBJECT_FACTORYfc); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+23, EVENT_OBJECT_FACTORYic); + pos.x = ox+sx*0.0f; + pos.y = oy+sy*6.0f; + pw->CreateButton(pos, dim, 128+25, EVENT_OBJECT_FACTORYwi); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+26, EVENT_OBJECT_FACTORYti); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+27, EVENT_OBJECT_FACTORYfi); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+28, EVENT_OBJECT_FACTORYii); - pos.x = ox+sx*0.0f; - pos.y = oy+sy*4.9f; - pw->CreateButton(pos, dim, 128+25, EVENT_OBJECT_FACTORYwi); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+26, EVENT_OBJECT_FACTORYti); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+27, EVENT_OBJECT_FACTORYfi); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+28, EVENT_OBJECT_FACTORYii); + pos.x = ox+sx*0.0f; + pos.y = oy+sy*4.9f; + pw->CreateButton(pos, dim, 192+0, EVENT_OBJECT_FACTORYwb); + pos.x += dim.x; + pw->CreateButton(pos, dim, 192+1, EVENT_OBJECT_FACTORYtb); + pos.x += dim.x; + pw->CreateButton(pos, dim, 192+2, EVENT_OBJECT_FACTORYfb); + pos.x += dim.x; + pw->CreateButton(pos, dim, 192+3, EVENT_OBJECT_FACTORYib); - pos.x = ox+sx*0.0f; - pos.y = oy+sy*3.8f; - pw->CreateButton(pos, dim, 128+18, EVENT_OBJECT_FACTORYrt); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+19, EVENT_OBJECT_FACTORYrc); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+20, EVENT_OBJECT_FACTORYrr); - pos.x += dim.x; - pw->CreateButton(pos, dim, 128+29, EVENT_OBJECT_FACTORYrs); + pos.x = ox+sx*0.0f; + pos.y = oy+sy*3.8f; + pw->CreateButton(pos, dim, 128+18, EVENT_OBJECT_FACTORYrt); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+19, EVENT_OBJECT_FACTORYrc); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+20, EVENT_OBJECT_FACTORYrr); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+29, EVENT_OBJECT_FACTORYrs); - pos.x = ox+sx*0.0f; - pos.y = oy+sy*2.7f; - pw->CreateButton(pos, dim, 128+21, EVENT_OBJECT_FACTORYsa); + pos.x = ox+sx*0.0f; + pos.y = oy+sy*2.7f; + pw->CreateButton(pos, dim, 128+21, EVENT_OBJECT_FACTORYsa); + pos.x += dim.x; + pw->CreateButton(pos, dim, 128+45, EVENT_OBJECT_FACTORYtg); + } pos.x = ox+sx*0.0f; pos.y = oy+sy*0; @@ -817,11 +843,16 @@ void CAutoFactory::UpdateInterface() UpdateButton(pw, EVENT_OBJECT_FACTORYti, m_bBusy); UpdateButton(pw, EVENT_OBJECT_FACTORYfi, m_bBusy); UpdateButton(pw, EVENT_OBJECT_FACTORYii, m_bBusy); + UpdateButton(pw, EVENT_OBJECT_FACTORYwb, m_bBusy); + UpdateButton(pw, EVENT_OBJECT_FACTORYtb, m_bBusy); + UpdateButton(pw, EVENT_OBJECT_FACTORYfb, m_bBusy); + UpdateButton(pw, EVENT_OBJECT_FACTORYib, m_bBusy); UpdateButton(pw, EVENT_OBJECT_FACTORYrt, m_bBusy); UpdateButton(pw, EVENT_OBJECT_FACTORYrc, m_bBusy); UpdateButton(pw, EVENT_OBJECT_FACTORYrr, m_bBusy); UpdateButton(pw, EVENT_OBJECT_FACTORYrs, m_bBusy); UpdateButton(pw, EVENT_OBJECT_FACTORYsa, m_bBusy); + UpdateButton(pw, EVENT_OBJECT_FACTORYtg, m_bBusy); } // Updates the status of one interface button. diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp index 39fb5245..a766aca9 100644 --- a/src/object/auto/autolabo.cpp +++ b/src/object/auto/autolabo.cpp @@ -136,7 +136,11 @@ Error CAutoLabo::StartAction(int param) { return ERR_LABO_NULL; } - if ( power->GetType() != OBJECT_BULLET ) + if ( m_research != RESEARCH_TARGET && power->GetType() != OBJECT_BULLET ) + { + return ERR_LABO_BAD; + } + if ( m_research == RESEARCH_TARGET && power->GetType() != OBJECT_TNT ) { return ERR_LABO_BAD; } @@ -177,6 +181,7 @@ bool CAutoLabo::EventProcess(const Event &event) if ( m_object->GetSelect() ) // center selected? { Error err = ERR_UNKNOWN; + if ( event.type == EVENT_OBJECT_RTARGET ) err = StartAction(RESEARCH_TARGET); if ( event.type == EVENT_OBJECT_RiPAW ) err = StartAction(RESEARCH_iPAW); if ( event.type == EVENT_OBJECT_RiGUN ) err = StartAction(RESEARCH_iGUN); @@ -455,7 +460,7 @@ Error CAutoLabo::GetError() CObject* obj = m_object->GetPower(); if (obj == nullptr) return ERR_LABO_NULL; ObjectType type = obj->GetType(); - if ( type != OBJECT_BULLET ) return ERR_LABO_BAD; + if ( type != OBJECT_BULLET && type != OBJECT_TNT ) return ERR_LABO_BAD; return ERR_OK; } @@ -482,14 +487,20 @@ bool CAutoLabo::CreateInterface(bool bSelect) oy = 3.0f/480.0f; sx = 33.0f/640.0f; sy = 33.0f/480.0f; + if( !m_object->GetTrainer() ) + { + pos.x = ox+sx*6.0f; + pos.y = oy+sy*0.5f; + pw->CreateButton(pos, dim, 192+8, EVENT_OBJECT_RTARGET); - pos.x = ox+sx*7.0f; - pos.y = oy+sy*0.5f; - pw->CreateButton(pos, dim, 64+45, EVENT_OBJECT_RiPAW); + pos.x = ox+sx*7.0f; + pos.y = oy+sy*0.5f; + pw->CreateButton(pos, dim, 64+45, EVENT_OBJECT_RiPAW); - pos.x = ox+sx*8.0f; - pos.y = oy+sy*0.5f; - pw->CreateButton(pos, dim, 64+46, EVENT_OBJECT_RiGUN); + pos.x = ox+sx*8.0f; + pos.y = oy+sy*0.5f; + pw->CreateButton(pos, dim, 64+46, EVENT_OBJECT_RiGUN); + } pos.x = ox+sx*0.0f; pos.y = oy+sy*0; @@ -515,14 +526,17 @@ void CAutoLabo::UpdateInterface() pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0)); if ( pw == nullptr ) return; - DeadInterface(pw, EVENT_OBJECT_RiPAW, m_main->IsResearchEnabled(RESEARCH_iPAW)); - DeadInterface(pw, EVENT_OBJECT_RiGUN, m_main->IsResearchEnabled(RESEARCH_iGUN)); + DeadInterface(pw, EVENT_OBJECT_RTARGET, m_main->IsResearchEnabled(RESEARCH_TARGET)); + DeadInterface(pw, EVENT_OBJECT_RiPAW, m_main->IsResearchEnabled(RESEARCH_iPAW)); + DeadInterface(pw, EVENT_OBJECT_RiGUN, m_main->IsResearchEnabled(RESEARCH_iGUN)); + OkayButton(pw, EVENT_OBJECT_RTARGET); OkayButton(pw, EVENT_OBJECT_RiPAW); OkayButton(pw, EVENT_OBJECT_RiGUN); - VisibleInterface(pw, EVENT_OBJECT_RiPAW, !m_bBusy); - VisibleInterface(pw, EVENT_OBJECT_RiGUN, !m_bBusy); + VisibleInterface(pw, EVENT_OBJECT_RTARGET, !m_bBusy); + VisibleInterface(pw, EVENT_OBJECT_RiPAW, !m_bBusy); + VisibleInterface(pw, EVENT_OBJECT_RiGUN, !m_bBusy); } // Indicates the research conducted for a button. @@ -542,8 +556,9 @@ void CAutoLabo::OkayButton(Ui::CWindow *pw, EventType event) bool CAutoLabo::TestResearch(EventType event) { - if ( event == EVENT_OBJECT_RiPAW ) return m_main->IsResearchDone(RESEARCH_iPAW, m_object->GetTeam()); - if ( event == EVENT_OBJECT_RiGUN ) return m_main->IsResearchDone(RESEARCH_iGUN, m_object->GetTeam()); + if ( event == EVENT_OBJECT_RTARGET ) return m_main->IsResearchDone(RESEARCH_TARGET, m_object->GetTeam()); + if ( event == EVENT_OBJECT_RiPAW ) return m_main->IsResearchDone(RESEARCH_iPAW, m_object->GetTeam()); + if ( event == EVENT_OBJECT_RiGUN ) return m_main->IsResearchDone(RESEARCH_iGUN, m_object->GetTeam()); return m_main; } diff --git a/src/object/auto/automush.cpp b/src/object/auto/automush.cpp index acff24fc..5cc441e0 100644 --- a/src/object/auto/automush.cpp +++ b/src/object/auto/automush.cpp @@ -236,6 +236,10 @@ bool CAutoMush::SearchTarget() type != OBJECT_MOBILEta && type != OBJECT_MOBILEwa && type != OBJECT_MOBILEia && + type != OBJECT_MOBILEfb && + type != OBJECT_MOBILEtb && + type != OBJECT_MOBILEwb && + type != OBJECT_MOBILEib && type != OBJECT_MOBILEfc && type != OBJECT_MOBILEtc && type != OBJECT_MOBILEwc && @@ -258,6 +262,8 @@ bool CAutoMush::SearchTarget() type != OBJECT_MOBILEtt && type != OBJECT_MOBILEwt && type != OBJECT_MOBILEit && + type != OBJECT_MOBILErp && + type != OBJECT_MOBILEst && type != OBJECT_MOBILEdr && type != OBJECT_DERRICK && type != OBJECT_STATION && diff --git a/src/object/auto/autonuclearplant.cpp b/src/object/auto/autonuclearplant.cpp index a341c45f..7d091819 100644 --- a/src/object/auto/autonuclearplant.cpp +++ b/src/object/auto/autonuclearplant.cpp @@ -345,6 +345,10 @@ bool CAutoNuclearPlant::SearchVehicle() type != OBJECT_MOBILEta && type != OBJECT_MOBILEwa && type != OBJECT_MOBILEia && + type != OBJECT_MOBILEfb && + type != OBJECT_MOBILEtb && + type != OBJECT_MOBILEwb && + type != OBJECT_MOBILEib && type != OBJECT_MOBILEfc && type != OBJECT_MOBILEtc && type != OBJECT_MOBILEwc && @@ -367,6 +371,8 @@ bool CAutoNuclearPlant::SearchVehicle() type != OBJECT_MOBILEtt && type != OBJECT_MOBILEwt && type != OBJECT_MOBILEit && + type != OBJECT_MOBILErp && + type != OBJECT_MOBILEst && type != OBJECT_MOBILEdr && type != OBJECT_MOTHER && type != OBJECT_ANT && diff --git a/src/object/auto/autopowerplant.cpp b/src/object/auto/autopowerplant.cpp index d7294b93..17fc9f04 100644 --- a/src/object/auto/autopowerplant.cpp +++ b/src/object/auto/autopowerplant.cpp @@ -410,6 +410,10 @@ bool CAutoPowerPlant::SearchVehicle() type != OBJECT_MOBILEta && type != OBJECT_MOBILEwa && type != OBJECT_MOBILEia && + type != OBJECT_MOBILEfb && + type != OBJECT_MOBILEtb && + type != OBJECT_MOBILEwb && + type != OBJECT_MOBILEib && type != OBJECT_MOBILEfc && type != OBJECT_MOBILEtc && type != OBJECT_MOBILEwc && @@ -432,6 +436,8 @@ bool CAutoPowerPlant::SearchVehicle() type != OBJECT_MOBILEtt && type != OBJECT_MOBILEwt && type != OBJECT_MOBILEit && + type != OBJECT_MOBILErp && + type != OBJECT_MOBILEst && type != OBJECT_MOBILEdr && type != OBJECT_MOTHER && type != OBJECT_ANT && diff --git a/src/object/auto/autopowerstation.cpp b/src/object/auto/autopowerstation.cpp index 667c8324..2c96d981 100644 --- a/src/object/auto/autopowerstation.cpp +++ b/src/object/auto/autopowerstation.cpp @@ -253,6 +253,10 @@ CObject* CAutoPowerStation::SearchVehicle() type != OBJECT_MOBILEta && type != OBJECT_MOBILEwa && type != OBJECT_MOBILEia && + type != OBJECT_MOBILEfb && + type != OBJECT_MOBILEtb && + type != OBJECT_MOBILEwb && + type != OBJECT_MOBILEib && type != OBJECT_MOBILEfc && type != OBJECT_MOBILEtc && type != OBJECT_MOBILEwc && @@ -274,6 +278,9 @@ CObject* CAutoPowerStation::SearchVehicle() type != OBJECT_MOBILEtt && type != OBJECT_MOBILEwt && type != OBJECT_MOBILEit && + type != OBJECT_MOBILErp && + type != OBJECT_MOBILEst && + type != OBJECT_MOBILEtg && type != OBJECT_MOBILEdr ) continue; Math::Vector oPos = obj->GetPosition(); diff --git a/src/object/auto/autoresearch.cpp b/src/object/auto/autoresearch.cpp index a1c98b69..16b8beee 100644 --- a/src/object/auto/autoresearch.cpp +++ b/src/object/auto/autoresearch.cpp @@ -179,6 +179,7 @@ bool CAutoResearch::EventProcess(const Event &event) if ( event.type == EVENT_OBJECT_RPHAZER ) err = StartAction(RESEARCH_PHAZER); if ( event.type == EVENT_OBJECT_RSHIELD ) err = StartAction(RESEARCH_SHIELD); if ( event.type == EVENT_OBJECT_RATOMIC ) err = StartAction(RESEARCH_ATOMIC); + if ( event.type == EVENT_OBJECT_RBUILDER ) err = StartAction(RESEARCH_BUILDER); if( err != ERR_OK && err != ERR_UNKNOWN ) m_main->DisplayError(err, m_object); @@ -268,6 +269,7 @@ bool CAutoResearch::EventProcess(const Event &event) if ( m_research == RESEARCH_PHAZER ) message = INFO_RESEARCHPHAZER; if ( m_research == RESEARCH_SHIELD ) message = INFO_RESEARCHSHIELD; if ( m_research == RESEARCH_ATOMIC ) message = INFO_RESEARCHATOMIC; + if ( m_research == RESEARCH_BUILDER ) message = INFO_RESEARCHBUILDER; if ( message != ERR_OK ) { m_main->DisplayError(message, m_object); @@ -339,38 +341,44 @@ bool CAutoResearch::CreateInterface(bool bSelect) oy = 3.0f/480.0f; sx = 33.0f/640.0f; sy = 33.0f/480.0f; + if( !m_object->GetTrainer() ) + { + pos.x = ox+sx*3.0f; + pos.y = oy+sy*0.5f; + pw->CreateButton(pos, dim, 64+0, EVENT_OBJECT_RTANK); - pos.x = ox+sx*7.0f; - pos.y = oy+sy*1.0f; - pw->CreateButton(pos, dim, 64+0, EVENT_OBJECT_RTANK); + pos.x = ox+sx*4.0f; + pos.y = oy+sy*0.5f; + pw->CreateButton(pos, dim, 64+1, EVENT_OBJECT_RFLY); - pos.x = ox+sx*8.0f; - pos.y = oy+sy*1.0f; - pw->CreateButton(pos, dim, 64+1, EVENT_OBJECT_RFLY); + pos.x = ox+sx*5.0f; + pos.y = oy+sy*0.5f; + pw->CreateButton(pos, dim, 64+3, EVENT_OBJECT_RCANON); - pos.x = ox+sx*9.0f; - pos.y = oy+sy*1.0f; - pw->CreateButton(pos, dim, 64+3, EVENT_OBJECT_RCANON); + pos.x = ox+sx*6.0f; + pos.y = oy+sy*0.5f; + pw->CreateButton(pos, dim, 64+4, EVENT_OBJECT_RTOWER); - pos.x = ox+sx*10.0f; - pos.y = oy+sy*1.0f; - pw->CreateButton(pos, dim, 64+4, EVENT_OBJECT_RTOWER); + pos.x = ox+sx*7.0f; + pos.y = oy+sy*0.5f; + pw->CreateButton(pos, dim, 64+7, EVENT_OBJECT_RATOMIC); - pos.x = ox+sx*7.0f; - pos.y = oy+sy*0.0f; - pw->CreateButton(pos, dim, 64+7, EVENT_OBJECT_RATOMIC); + pos.x = ox+sx*8.0f; + pos.y = oy+sy*0.5f; + pw->CreateButton(pos, dim, 64+2, EVENT_OBJECT_RTHUMP); - pos.x = ox+sx*8.0f; - pos.y = oy+sy*0.0f; - pw->CreateButton(pos, dim, 64+2, EVENT_OBJECT_RTHUMP); + pos.x = ox+sx*9.0f; + pos.y = oy+sy*0.5f; + pw->CreateButton(pos, dim, 64+6, EVENT_OBJECT_RSHIELD); - pos.x = ox+sx*9.0f; - pos.y = oy+sy*0.0f; - pw->CreateButton(pos, dim, 64+6, EVENT_OBJECT_RSHIELD); + pos.x = ox+sx*10.0f; + pos.y = oy+sy*0.5f; + pw->CreateButton(pos, dim, 64+5, EVENT_OBJECT_RPHAZER); - pos.x = ox+sx*10.0f; - pos.y = oy+sy*0.0f; - pw->CreateButton(pos, dim, 64+5, EVENT_OBJECT_RPHAZER); + pos.x = ox+sx*11.0f; + pos.y = oy+sy*0.5f; + pw->CreateButton(pos, dim, 192+4, EVENT_OBJECT_RBUILDER); + } pos.x = ox+sx*14.5f; pos.y = oy+sy*0; @@ -410,6 +418,7 @@ void CAutoResearch::UpdateInterface() DeadInterface(pw, EVENT_OBJECT_RPHAZER, m_main->IsResearchEnabled(RESEARCH_PHAZER)); DeadInterface(pw, EVENT_OBJECT_RSHIELD, m_main->IsResearchEnabled(RESEARCH_SHIELD)); DeadInterface(pw, EVENT_OBJECT_RATOMIC, m_main->IsResearchEnabled(RESEARCH_ATOMIC)); + DeadInterface(pw, EVENT_OBJECT_RBUILDER, m_main->IsResearchEnabled(RESEARCH_BUILDER)); OkayButton(pw, EVENT_OBJECT_RTANK); OkayButton(pw, EVENT_OBJECT_RFLY); @@ -419,6 +428,7 @@ void CAutoResearch::UpdateInterface() OkayButton(pw, EVENT_OBJECT_RPHAZER); OkayButton(pw, EVENT_OBJECT_RSHIELD); OkayButton(pw, EVENT_OBJECT_RATOMIC); + OkayButton(pw, EVENT_OBJECT_RBUILDER); VisibleInterface(pw, EVENT_OBJECT_RTANK, !m_bBusy); VisibleInterface(pw, EVENT_OBJECT_RFLY, !m_bBusy); @@ -428,6 +438,7 @@ void CAutoResearch::UpdateInterface() VisibleInterface(pw, EVENT_OBJECT_RPHAZER, !m_bBusy); VisibleInterface(pw, EVENT_OBJECT_RSHIELD, !m_bBusy); VisibleInterface(pw, EVENT_OBJECT_RATOMIC, !m_bBusy); + VisibleInterface(pw, EVENT_OBJECT_RBUILDER, !m_bBusy); } // Updates the state of all buttons on the interface, @@ -478,6 +489,7 @@ bool CAutoResearch::TestResearch(EventType event) if ( event == EVENT_OBJECT_RPHAZER ) return m_main->IsResearchDone(RESEARCH_PHAZER, m_object->GetTeam()); if ( event == EVENT_OBJECT_RSHIELD ) return m_main->IsResearchDone(RESEARCH_SHIELD, m_object->GetTeam()); if ( event == EVENT_OBJECT_RATOMIC ) return m_main->IsResearchDone(RESEARCH_ATOMIC, m_object->GetTeam()); + if ( event == EVENT_OBJECT_RBUILDER ) return m_main->IsResearchDone(RESEARCH_BUILDER, m_object->GetTeam()); return false; } diff --git a/src/object/drive_type.cpp b/src/object/drive_type.cpp index 7083f35e..5b2e5229 100644 --- a/src/object/drive_type.cpp +++ b/src/object/drive_type.cpp @@ -28,6 +28,7 @@ DriveType GetDriveFromObject(ObjectType type) case OBJECT_MOBILEwc: case OBJECT_MOBILEwi: case OBJECT_MOBILEws: + case OBJECT_MOBILEwb: return DriveType::Wheeled; case OBJECT_MOBILEtt: @@ -35,6 +36,7 @@ DriveType GetDriveFromObject(ObjectType type) case OBJECT_MOBILEtc: case OBJECT_MOBILEti: case OBJECT_MOBILEts: + case OBJECT_MOBILEtb: return DriveType::Tracked; case OBJECT_MOBILEft: @@ -42,6 +44,7 @@ DriveType GetDriveFromObject(ObjectType type) case OBJECT_MOBILEfc: case OBJECT_MOBILEfi: case OBJECT_MOBILEfs: + case OBJECT_MOBILEfb: return DriveType::Winged; case OBJECT_MOBILEit: @@ -49,14 +52,18 @@ DriveType GetDriveFromObject(ObjectType type) case OBJECT_MOBILEic: case OBJECT_MOBILEii: case OBJECT_MOBILEis: + case OBJECT_MOBILEib: return DriveType::Legged; + case OBJECT_MOBILErp: case OBJECT_MOBILErt: case OBJECT_MOBILErc: case OBJECT_MOBILErr: case OBJECT_MOBILErs: - // NOTE: Subber is not BigTracked! - return DriveType::BigTracked; + return DriveType::Heavy; + + case OBJECT_MOBILEsa: + return DriveType::Amphibious; default: return DriveType::Other; diff --git a/src/object/drive_type.h b/src/object/drive_type.h index 9b8ca80a..7bf88e9b 100644 --- a/src/object/drive_type.h +++ b/src/object/drive_type.h @@ -28,7 +28,8 @@ enum class DriveType : unsigned int Tracked, Winged, Legged, - BigTracked, + Heavy, + Amphibious }; DriveType GetDriveFromObject(ObjectType type); diff --git a/src/object/motion/motiontoto.cpp b/src/object/motion/motiontoto.cpp index ee7a685f..6c33b7b2 100644 --- a/src/object/motion/motiontoto.cpp +++ b/src/object/motion/motiontoto.cpp @@ -335,6 +335,10 @@ bool CMotionToto::EventFrame(const Event &event) type == OBJECT_MOBILEta || type == OBJECT_MOBILEfa || type == OBJECT_MOBILEia || + type == OBJECT_MOBILEwb || + type == OBJECT_MOBILEtb || + type == OBJECT_MOBILEfb || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEwc || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEfc || @@ -356,6 +360,9 @@ bool CMotionToto::EventFrame(const Event &event) type == OBJECT_MOBILEtt || type == OBJECT_MOBILEft || type == OBJECT_MOBILEit || + type == OBJECT_MOBILErp || + type == OBJECT_MOBILEst || + type == OBJECT_MOBILEtg || type == OBJECT_MOBILEdr ) ) // vehicle? { m_clownTime += event.rTime; diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp index fa631fde..b34f5be2 100644 --- a/src/object/motion/motionvehicle.cpp +++ b/src/object/motion/motionvehicle.cpp @@ -100,49 +100,128 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICLE); // this is a moving object m_object->SetObjectRank(0, rank); + if ((m_object->GetTrainer() && type == OBJECT_MOBILEsa) || type == OBJECT_MOBILEst) + { + modelManager->AddModelReference("trainers.mod", false, rank, m_object->GetTeam()); + } + else if ((m_object->GetTrainer() && + ( type == OBJECT_MOBILErt || + type == OBJECT_MOBILErc || + type == OBJECT_MOBILErr || + type == OBJECT_MOBILErs)) || type == OBJECT_MOBILErp) + { + modelManager->AddModelReference("trainerr.mod", false, rank, m_object->GetTeam()); + } + else if (m_object->GetTrainer() || + type == OBJECT_MOBILEwt || + type == OBJECT_MOBILEtt || + type == OBJECT_MOBILEft || + type == OBJECT_MOBILEit) + { + modelManager->AddModelReference("trainer.mod", false, rank, m_object->GetTeam()); + } + if (type == OBJECT_MOBILEfa || + type == OBJECT_MOBILEfb || type == OBJECT_MOBILEfc || type == OBJECT_MOBILEfi || type == OBJECT_MOBILEfs) { - modelManager->AddModelReference("lem1f.mod", false, rank, m_object->GetTeam()); + if (!m_object->GetTrainer()) + modelManager->AddModelReference("lem1f.mod", false, rank, m_object->GetTeam()); + else + { + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(28, rank); + m_object->SetObjectParent(28, 0); + modelManager->AddModelReference("trainerf.mod", false, rank, m_object->GetTeam()); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(29, rank); + m_object->SetObjectParent(29, 0); + modelManager->AddModelReference("trainera.mod", false, rank, m_object->GetTeam()); + } } else if (type == OBJECT_MOBILEta || + type == OBJECT_MOBILEtb || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEti || type == OBJECT_MOBILEts) { - modelManager->AddModelReference("lem1t.mod", false, rank, m_object->GetTeam()); + if (!m_object->GetTrainer()) + modelManager->AddModelReference("lem1t.mod", false, rank, m_object->GetTeam()); + else + { + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(28, rank); + m_object->SetObjectParent(28, 0); + modelManager->AddModelReference("trainert.mod", false, rank, m_object->GetTeam()); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(29, rank); + m_object->SetObjectParent(29, 0); + modelManager->AddModelReference("trainera.mod", false, rank, m_object->GetTeam()); + } } else if (type == OBJECT_MOBILEwa || + type == OBJECT_MOBILEwb || type == OBJECT_MOBILEwc || type == OBJECT_MOBILEwi || type == OBJECT_MOBILEws) { - if (m_object->GetTrainer()) - { - modelManager->AddModelReference("lem1wt.mod", false, rank, m_object->GetTeam()); - } + if (!m_object->GetTrainer()) + modelManager->AddModelReference("lem1w.mod", false, rank, m_object->GetTeam()); else { - modelManager->AddModelReference("lem1w.mod", false, rank, m_object->GetTeam()); + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(28, rank); + m_object->SetObjectParent(28, 0); + modelManager->AddModelReference("trainerw.mod", false, rank, m_object->GetTeam()); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(29, rank); + m_object->SetObjectParent(29, 0); + modelManager->AddModelReference("trainera.mod", false, rank, m_object->GetTeam()); } } else if (type == OBJECT_MOBILEia || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEic || type == OBJECT_MOBILEii || type == OBJECT_MOBILEis) { - modelManager->AddModelReference("lem1i.mod", false, rank, m_object->GetTeam()); + if (!m_object->GetTrainer()) + modelManager->AddModelReference("lem1i.mod", false, rank, m_object->GetTeam()); + else + { + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(28, rank); + m_object->SetObjectParent(28, 0); + modelManager->AddModelReference("traineri.mod", false, rank, m_object->GetTeam()); + + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(29, rank); + m_object->SetObjectParent(29, 0); + modelManager->AddModelReference("trainera.mod", false, rank, m_object->GetTeam()); + } } - else if (type == OBJECT_MOBILErt || + else if (!m_object->GetTrainer() && + (type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs) + type == OBJECT_MOBILErs)) { modelManager->AddModelReference("roller1.mod", false, rank, m_object->GetTeam()); } - else if (type == OBJECT_MOBILEsa) + else if (type == OBJECT_MOBILEsa && !m_object->GetTrainer()) { modelManager->AddModelReference("subm1.mod", false, rank, m_object->GetTeam()); } @@ -152,18 +231,34 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, } else if (type == OBJECT_MOBILEwt) { + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(28, rank); + m_object->SetObjectParent(28, 0); modelManager->AddModelReference("trainerw.mod", false, rank, m_object->GetTeam()); } else if (type == OBJECT_MOBILEft) { + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(28, rank); + m_object->SetObjectParent(28, 0); modelManager->AddModelReference("trainerf.mod", false, rank, m_object->GetTeam()); } else if (type == OBJECT_MOBILEtt) { + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(28, rank); + m_object->SetObjectParent(28, 0); modelManager->AddModelReference("trainert.mod", false, rank, m_object->GetTeam()); } else if (type == OBJECT_MOBILEit) { + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(28, rank); + m_object->SetObjectParent(28, 0); modelManager->AddModelReference("traineri.mod", false, rank, m_object->GetTeam()); } else if (type == OBJECT_MOBILEdr) @@ -183,12 +278,14 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, if (type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs) + type == OBJECT_MOBILErs || + type == OBJECT_MOBILErp) { m_object->AddCrashSphere(CrashSphere(Math::Vector(0.0f, 4.0f, 0.0f), 6.5f, SOUND_BOUMm, 0.45f)); m_object->SetCameraCollisionSphere(Math::Sphere(Math::Vector(0.0f, 3.0f, 0.0f), 7.0f)); } - else if (type == OBJECT_MOBILEsa) + else if (type == OBJECT_MOBILEsa || + type == OBJECT_MOBILEst) { m_object->AddCrashSphere(CrashSphere(Math::Vector(0.0f, 3.0f, 0.0f), 4.5f, SOUND_BOUMm, 0.45f)); m_object->SetCameraCollisionSphere(Math::Sphere(Math::Vector(0.0f, 3.0f, 0.0f), 6.0f)); @@ -332,7 +429,24 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetPartRotationZ(2, 0.0f); } + if (type == OBJECT_MOBILEfb || + type == OBJECT_MOBILEtb || + type == OBJECT_MOBILEwb || + type == OBJECT_MOBILEib) + { + // Creates the neutron gun. + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(1, rank); + m_object->SetObjectParent(1, 0); + modelManager->AddModelReference("neutron.mod", false, rank, m_object->GetTeam()); +//? m_object->SetPartPosition(1, Math::Vector(0.0f, 5.3f, 0.0f)); + m_object->SetPartPosition(1, Math::Vector(0.0f, 5.3f, 0.0f)); + m_object->SetPartRotationZ(1, 0.0f); + } + if (type == OBJECT_MOBILEwa || + type == OBJECT_MOBILEwb || type == OBJECT_MOBILEwc || type == OBJECT_MOBILEws || type == OBJECT_MOBILEwi || @@ -411,9 +525,11 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, } if (type == OBJECT_MOBILEta || + type == OBJECT_MOBILEtb || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEti || - type == OBJECT_MOBILEts) // caterpillars? + type == OBJECT_MOBILEts || + type == OBJECT_MOBILEtt) // caterpillars? { // Creates the right caterpillar. rank = m_engine->CreateObject(); @@ -421,7 +537,13 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetObjectRank(6, rank); m_object->SetObjectParent(6, 0); modelManager->AddModelCopy("lem2t.mod", false, rank, m_object->GetTeam()); - m_object->SetPartPosition(6, Math::Vector(0.0f, 2.0f, -3.0f)); + if (m_object->GetTrainer() || type == OBJECT_MOBILEtt) + { + m_object->SetPartPosition(6, Math::Vector(0.0f, 2.0f, -3.55f)); + m_object->SetPartScaleZ(6, 0.725f); + } + else + m_object->SetPartPosition(6, Math::Vector(0.0f, 2.0f, -3.0f)); // Creates the left caterpillar. rank = m_engine->CreateObject(); @@ -429,13 +551,20 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetObjectRank(7, rank); m_object->SetObjectParent(7, 0); modelManager->AddModelCopy("lem3t.mod", false, rank, m_object->GetTeam()); - m_object->SetPartPosition(7, Math::Vector(0.0f, 2.0f, 3.0f)); + if (m_object->GetTrainer() || type == OBJECT_MOBILEtt) + { + m_object->SetPartPosition(7, Math::Vector(0.0f, 2.0f, 3.55f)); + m_object->SetPartScaleZ(7, 0.725f); + } + else + m_object->SetPartPosition(7, Math::Vector(0.0f, 2.0f, 3.0f)); } if (type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs) // large caterpillars? + type == OBJECT_MOBILErs || + type == OBJECT_MOBILErp) // large caterpillars? { // Creates the right caterpillar. rank = m_engine->CreateObject(); @@ -454,7 +583,8 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetPartPosition(7, Math::Vector(0.0f, 2.0f, 3.0f)); } - if (type == OBJECT_MOBILEsa) // underwater caterpillars? + if (type == OBJECT_MOBILEsa || + type == OBJECT_MOBILEst) // underwater caterpillars? { // Creates the right caterpillar. rank = m_engine->CreateObject(); @@ -493,6 +623,7 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, } if (type == OBJECT_MOBILEfa || + type == OBJECT_MOBILEfb || type == OBJECT_MOBILEfc || type == OBJECT_MOBILEfs || type == OBJECT_MOBILEfi || @@ -526,9 +657,11 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, } if (type == OBJECT_MOBILEia || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEic || type == OBJECT_MOBILEis || - type == OBJECT_MOBILEii) // insect legs? + type == OBJECT_MOBILEii || + type == OBJECT_MOBILEit) // insect legs? { float table[] = { @@ -725,6 +858,15 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, m_object->SetObjectParent(3, 1); modelManager->AddModelReference("subm3.mod", true, rank, m_object->GetTeam()); m_object->SetPartPosition(3, Math::Vector(0.5f, 0.0f, 1.5f)); + + if (m_object->GetTrainer()) + { + rank = m_engine->CreateObject(); + m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT); + m_object->SetObjectRank(4, rank); + m_object->SetObjectParent(4, 0); + modelManager->AddModelReference("trainerg.mod", true, rank, m_object->GetTeam()); + } } if (type == OBJECT_MOBILEdr) @@ -862,15 +1004,19 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, if (type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs) + type == OBJECT_MOBILErs || + type == OBJECT_MOBILErp) { m_object->CreateShadowCircle(6.0f, 1.0f); } else if (type == OBJECT_MOBILEta || + type == OBJECT_MOBILEtb || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEti || type == OBJECT_MOBILEts || - type == OBJECT_MOBILEsa) + type == OBJECT_MOBILEtt || + type == OBJECT_MOBILEsa || + type == OBJECT_MOBILEst) { m_object->CreateShadowCircle(5.0f, 1.0f); } @@ -888,6 +1034,7 @@ void CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type, } if (type == OBJECT_MOBILEfa || + type == OBJECT_MOBILEfb || type == OBJECT_MOBILEfc || type == OBJECT_MOBILEfi || type == OBJECT_MOBILEfs || @@ -948,6 +1095,7 @@ void CMotionVehicle::CreatePhysics(ObjectType type) character = m_object->GetCharacter(); if ( type == OBJECT_MOBILEwa || + type == OBJECT_MOBILEwb || type == OBJECT_MOBILEwc || type == OBJECT_MOBILEwi || type == OBJECT_MOBILEws || @@ -1004,9 +1152,11 @@ void CMotionVehicle::CreatePhysics(ObjectType type) } if ( type == OBJECT_MOBILEta || + type == OBJECT_MOBILEtb || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEti || - type == OBJECT_MOBILEts ) // caterpillars? + type == OBJECT_MOBILEts || + type == OBJECT_MOBILEtt ) // caterpillars? { character->wheelFront = 4.0f; character->wheelBack = 4.0f; @@ -1033,9 +1183,11 @@ void CMotionVehicle::CreatePhysics(ObjectType type) } if ( type == OBJECT_MOBILEia || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEic || type == OBJECT_MOBILEii || - type == OBJECT_MOBILEis ) // legs? + type == OBJECT_MOBILEis || + type == OBJECT_MOBILEit) // legs? { character->wheelFront = 4.0f; character->wheelBack = 4.0f; @@ -1063,6 +1215,7 @@ void CMotionVehicle::CreatePhysics(ObjectType type) } if ( type == OBJECT_MOBILEfa || + type == OBJECT_MOBILEfb || type == OBJECT_MOBILEfc || type == OBJECT_MOBILEfi || type == OBJECT_MOBILEfs || @@ -1100,7 +1253,8 @@ void CMotionVehicle::CreatePhysics(ObjectType type) if ( type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs ) // large caterpillars? + type == OBJECT_MOBILErs || + type == OBJECT_MOBILErp) // large caterpillars? { character->wheelFront = 5.0f; character->wheelBack = 5.0f; @@ -1126,7 +1280,8 @@ void CMotionVehicle::CreatePhysics(ObjectType type) m_physics->SetCirMotionY(MO_STOACCEL, 4.0f); } - if ( type == OBJECT_MOBILEsa ) + if ( type == OBJECT_MOBILEsa || + type == OBJECT_MOBILEst ) { character->wheelFront = 4.0f; character->wheelBack = 4.0f; @@ -1240,6 +1395,7 @@ bool CMotionVehicle::EventFrame(const Event &event) type = m_object->GetType(); if ( type == OBJECT_MOBILEwa || + type == OBJECT_MOBILEwb || type == OBJECT_MOBILEwc || type == OBJECT_MOBILEwi || type == OBJECT_MOBILEws || @@ -1406,14 +1562,18 @@ bool CMotionVehicle::EventFrame(const Event &event) } if ( type == OBJECT_MOBILEta || + type == OBJECT_MOBILEtb || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEti || type == OBJECT_MOBILEts || + type == OBJECT_MOBILEtt || type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || type == OBJECT_MOBILErs || + type == OBJECT_MOBILErp || type == OBJECT_MOBILEsa || + type == OBJECT_MOBILEst || type == OBJECT_MOBILEdr ) // caterpillars? { s = m_physics->GetLinMotionX(MO_MOTSPEED)*0.7f; @@ -1439,12 +1599,14 @@ bool CMotionVehicle::EventFrame(const Event &event) if ( type == OBJECT_MOBILEta || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEti || - type == OBJECT_MOBILEts ) + type == OBJECT_MOBILEts || + type == OBJECT_MOBILEtt ) { limit[0] = 8.0f*Math::PI/180.0f; limit[1] = -12.0f*Math::PI/180.0f; } - else if ( type == OBJECT_MOBILEsa ) + else if ( type == OBJECT_MOBILEsa || + type == OBJECT_MOBILEst ) { limit[0] = 15.0f*Math::PI/180.0f; limit[1] = -15.0f*Math::PI/180.0f; @@ -1524,6 +1686,7 @@ bool CMotionVehicle::EventFrame(const Event &event) } if ( type == OBJECT_MOBILEfa || + type == OBJECT_MOBILEfb || type == OBJECT_MOBILEfc || type == OBJECT_MOBILEfi || type == OBJECT_MOBILEfs || @@ -1533,9 +1696,11 @@ bool CMotionVehicle::EventFrame(const Event &event) } if ( type == OBJECT_MOBILEia || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEic || type == OBJECT_MOBILEii || - type == OBJECT_MOBILEis ) // legs? + type == OBJECT_MOBILEis || + type == OBJECT_MOBILEit ) // legs? { EventFrameInsect(event); } diff --git a/src/object/object_factory.cpp b/src/object/object_factory.cpp index 25b0e9ed..0048d756 100644 --- a/src/object/object_factory.cpp +++ b/src/object/object_factory.cpp @@ -284,6 +284,10 @@ CObjectUPtr CObjectFactory::CreateObject(const ObjectCreateParams& params) case OBJECT_MOBILEta: case OBJECT_MOBILEwa: case OBJECT_MOBILEia: + case OBJECT_MOBILEfb: + case OBJECT_MOBILEtb: + case OBJECT_MOBILEwb: + case OBJECT_MOBILEib: case OBJECT_MOBILEfc: case OBJECT_MOBILEtc: case OBJECT_MOBILEwc: @@ -305,6 +309,8 @@ CObjectUPtr CObjectFactory::CreateObject(const ObjectCreateParams& params) case OBJECT_MOBILEtt: case OBJECT_MOBILEwt: case OBJECT_MOBILEit: + case OBJECT_MOBILErp: + case OBJECT_MOBILEst: case OBJECT_MOBILEdr: case OBJECT_APOLLO2: case OBJECT_CONTROLLER: diff --git a/src/object/object_type.h b/src/object/object_type.h index d8c3c8de..a6174bc4 100644 --- a/src/object/object_type.h +++ b/src/object/object_type.h @@ -101,10 +101,12 @@ enum ObjectType OBJECT_TREE3 = 93, //!< Tree3 OBJECT_TREE4 = 94, //!< Tree4 OBJECT_TREE5 = 95, //!< Tree5 - OBJECT_MOBILEwt = 100, //!< PracticeBot - OBJECT_MOBILEtt = 101, //!< track-trainer (unused) - OBJECT_MOBILEft = 102, //!< fly-trainer (unused) - OBJECT_MOBILEit = 103, //!< insect-trainer (unused) + OBJECT_MOBILEwt = 100, //!< WheeledTrainer (PracticeBot) + OBJECT_MOBILEtt = 101, //!< TrackedTrainer + OBJECT_MOBILEft = 102, //!< WingedTrainer + OBJECT_MOBILEit = 103, //!< LeggedTrainer + OBJECT_MOBILErp = 104, //!< HeavyTrainer + OBJECT_MOBILEst = 105, //!< AmphibiousTrainer OBJECT_MOBILEwa = 110, //!< WheeledGrabber OBJECT_MOBILEta = 111, //!< TrackedGrabber OBJECT_MOBILEfa = 112, //!< WingedGrabber @@ -129,6 +131,11 @@ enum ObjectType OBJECT_MOBILEtg = 211, //!< TargetBot OBJECT_MOBILEdr = 212, //!< Scribbler OBJECT_CONTROLLER = 213, //!< MissionController + OBJECT_MOBILEwb = 220, //!< WheeledBuilder + OBJECT_MOBILEtb = 221, //!< TrackedBuilder + OBJECT_MOBILEfb = 222, //!< WingedBuilder + OBJECT_MOBILEib = 223, //!< LeggedBuilder + OBJECT_MOBILEpr = 224, //!< PracticeBot (alias) OBJECT_WAYPOINT = 250, //!< WayPoint OBJECT_FLAGb = 260, //!< BlueFlag OBJECT_FLAGr = 261, //!< RedFlag diff --git a/src/object/old_object.cpp b/src/object/old_object.cpp index 3ecbb0e8..c11247d2 100644 --- a/src/object/old_object.cpp +++ b/src/object/old_object.cpp @@ -363,7 +363,18 @@ bool COldObject::DamageObject(DamageType type, float force, CObject* killer) } else if ( Implements(ObjectInterfaceType::Fragile) ) { - if ( m_type == OBJECT_BOMB && type != DamageType::Explosive ) return false; // Mine can't be destroyed by shooting + if ((m_type == OBJECT_BOMB || + m_type == OBJECT_RUINmobilew1 || + m_type == OBJECT_RUINmobilew2 || + m_type == OBJECT_RUINmobilet1 || + m_type == OBJECT_RUINmobilet2 || + m_type == OBJECT_RUINmobiler1 || + m_type == OBJECT_RUINmobiler2 || + m_type == OBJECT_RUINfactory || + m_type == OBJECT_RUINdoor || + m_type == OBJECT_RUINsupport || + m_type == OBJECT_RUINradar || + m_type == OBJECT_RUINconvert ) && type != DamageType::Explosive ) return false; // Mines and ruins can't be destroyed by shooting if ( m_type == OBJECT_URANIUM && (type == DamageType::Fire || type == DamageType::Organic) ) return false; // UraniumOre is not destroyable by shooting or aliens (see #777) if ( m_type == OBJECT_STONE && (type == DamageType::Fire || type == DamageType::Organic) ) return false; // TitaniumOre is not destroyable either // PowerCell, NuclearCell and Titanium are destroyable by shooting, but not by collisions! @@ -505,7 +516,12 @@ void COldObject::DestroyObject(DestructionType type, CObject* killer) m_type == OBJECT_SAFE || m_type == OBJECT_HUSTON || m_type == OBJECT_START || - m_type == OBJECT_END ) // building? + m_type == OBJECT_END || + m_type == OBJECT_RUINfactory || + m_type == OBJECT_RUINdoor || + m_type == OBJECT_RUINsupport || + m_type == OBJECT_RUINradar || + m_type == OBJECT_RUINconvert ) // building? { pyroType = Gfx::PT_FRAGT; } @@ -694,10 +710,11 @@ void COldObject::SetType(ObjectType type) // TODO: Temporary hack if ( m_type == OBJECT_MOBILEfa || // WingedGrabber + m_type == OBJECT_MOBILEfb || // WingedBuilder m_type == OBJECT_MOBILEfs || // WingedSniffer m_type == OBJECT_MOBILEfc || // WingedShooter m_type == OBJECT_MOBILEfi || // WingedOrgaShooter - m_type == OBJECT_MOBILEft || // winged PracticeBot (unused) + m_type == OBJECT_MOBILEft || // WingedTrainer m_type == OBJECT_HUMAN || // Me m_type == OBJECT_TECH || // Tech m_type == OBJECT_CONTROLLER) @@ -721,6 +738,10 @@ void COldObject::SetType(ObjectType type) m_type == OBJECT_MOBILEta || m_type == OBJECT_MOBILEwa || m_type == OBJECT_MOBILEia || + m_type == OBJECT_MOBILEfb || + m_type == OBJECT_MOBILEtb || + m_type == OBJECT_MOBILEwb || + m_type == OBJECT_MOBILEib || m_type == OBJECT_MOBILEfc || m_type == OBJECT_MOBILEtc || m_type == OBJECT_MOBILEwc || @@ -743,6 +764,8 @@ void COldObject::SetType(ObjectType type) m_type == OBJECT_MOBILEtt || m_type == OBJECT_MOBILEwt || m_type == OBJECT_MOBILEit || + m_type == OBJECT_MOBILErp || + m_type == OBJECT_MOBILEst || m_type == OBJECT_TOWER || m_type == OBJECT_RESEARCH || m_type == OBJECT_ENERGY || @@ -783,6 +806,10 @@ void COldObject::SetType(ObjectType type) m_type == OBJECT_MOBILEta || m_type == OBJECT_MOBILEwa || m_type == OBJECT_MOBILEia || + m_type == OBJECT_MOBILEfb || + m_type == OBJECT_MOBILEtb || + m_type == OBJECT_MOBILEwb || + m_type == OBJECT_MOBILEib || m_type == OBJECT_MOBILEfc || m_type == OBJECT_MOBILEtc || m_type == OBJECT_MOBILEwc || @@ -804,6 +831,8 @@ void COldObject::SetType(ObjectType type) m_type == OBJECT_MOBILEtt || m_type == OBJECT_MOBILEwt || m_type == OBJECT_MOBILEit || + m_type == OBJECT_MOBILErp || + m_type == OBJECT_MOBILEst || m_type == OBJECT_FACTORY || m_type == OBJECT_REPAIR || m_type == OBJECT_DESTROYER|| @@ -833,6 +862,23 @@ void COldObject::SetType(ObjectType type) m_implementedInterfaces[static_cast(ObjectInterfaceType::Fragile)] = false; m_implementedInterfaces[static_cast(ObjectInterfaceType::Shielded)] = false; } + else if (m_type == OBJECT_RUINmobilew1 || + m_type == OBJECT_RUINmobilew2 || + m_type == OBJECT_RUINmobilet1 || + m_type == OBJECT_RUINmobilet2 || + m_type == OBJECT_RUINmobiler1 || + m_type == OBJECT_RUINmobiler2 || + m_type == OBJECT_RUINfactory || + m_type == OBJECT_RUINdoor || + m_type == OBJECT_RUINsupport || + m_type == OBJECT_RUINradar || + m_type == OBJECT_RUINconvert ) + { + m_implementedInterfaces[static_cast(ObjectInterfaceType::Damageable)] = true; + m_implementedInterfaces[static_cast(ObjectInterfaceType::Destroyable)] = true; + m_implementedInterfaces[static_cast(ObjectInterfaceType::Fragile)] = true; + m_implementedInterfaces[static_cast(ObjectInterfaceType::Shielded)] = false; + } else { m_implementedInterfaces[static_cast(ObjectInterfaceType::Damageable)] = false; @@ -872,6 +918,10 @@ void COldObject::SetType(ObjectType type) m_type == OBJECT_MOBILEta || m_type == OBJECT_MOBILEwa || m_type == OBJECT_MOBILEia || + m_type == OBJECT_MOBILEfb || + m_type == OBJECT_MOBILEtb || + m_type == OBJECT_MOBILEwb || + m_type == OBJECT_MOBILEib || m_type == OBJECT_MOBILEfc || m_type == OBJECT_MOBILEtc || m_type == OBJECT_MOBILEwc || @@ -893,6 +943,9 @@ void COldObject::SetType(ObjectType type) m_type == OBJECT_MOBILEtt || m_type == OBJECT_MOBILEwt || m_type == OBJECT_MOBILEit || + m_type == OBJECT_MOBILErp || + m_type == OBJECT_MOBILEst || + m_type == OBJECT_MOBILEtg || m_type == OBJECT_MOBILEdr || m_type == OBJECT_APOLLO2 || m_type == OBJECT_BASE || @@ -2297,7 +2350,8 @@ void COldObject::AdjustCamera(Math::Vector &eye, float &dirH, float &dirV, } else if ( m_type == OBJECT_MOBILErt || m_type == OBJECT_MOBILErr || - m_type == OBJECT_MOBILErs ) + m_type == OBJECT_MOBILErs || + m_type == OBJECT_MOBILErp ) { eye.x = -1.1f; // on the cap eye.y = 7.9f; @@ -2339,7 +2393,8 @@ void COldObject::AdjustCamera(Math::Vector &eye, float &dirH, float &dirV, eye.y = 11.0f; eye.z = 0.0f; } - else if ( m_type == OBJECT_MOBILEsa ) + else if ( m_type == OBJECT_MOBILEsa || + m_type == OBJECT_MOBILEst ) { eye.x = 3.0f; eye.y = 4.5f; @@ -2744,7 +2799,11 @@ void COldObject::SetGunGoalV(float gunGoal) if ( m_type == OBJECT_MOBILEfc || m_type == OBJECT_MOBILEtc || m_type == OBJECT_MOBILEwc || - m_type == OBJECT_MOBILEic ) // fireball? + m_type == OBJECT_MOBILEic || + m_type == OBJECT_MOBILEfb || + m_type == OBJECT_MOBILEtb || + m_type == OBJECT_MOBILEwb || + m_type == OBJECT_MOBILEib) // fireball? { if ( gunGoal > 10.0f*Math::PI/180.0f ) gunGoal = 10.0f*Math::PI/180.0f; if ( gunGoal < -20.0f*Math::PI/180.0f ) gunGoal = -20.0f*Math::PI/180.0f; @@ -2778,7 +2837,11 @@ void COldObject::SetGunGoalH(float gunGoal) if ( m_type == OBJECT_MOBILEfc || m_type == OBJECT_MOBILEtc || m_type == OBJECT_MOBILEwc || - m_type == OBJECT_MOBILEic ) // fireball? + m_type == OBJECT_MOBILEic || + m_type == OBJECT_MOBILEfb || + m_type == OBJECT_MOBILEtb || + m_type == OBJECT_MOBILEwb || + m_type == OBJECT_MOBILEib) // fireball? { if ( gunGoal > 40.0f*Math::PI/180.0f ) gunGoal = 40.0f*Math::PI/180.0f; if ( gunGoal < -40.0f*Math::PI/180.0f ) gunGoal = -40.0f*Math::PI/180.0f; @@ -2852,6 +2915,10 @@ void COldObject::CreateSelectParticle() m_type == OBJECT_MOBILEta || m_type == OBJECT_MOBILEwa || m_type == OBJECT_MOBILEia || + m_type == OBJECT_MOBILEfb || + m_type == OBJECT_MOBILEtb || + m_type == OBJECT_MOBILEwb || + m_type == OBJECT_MOBILEib || m_type == OBJECT_MOBILEfc || m_type == OBJECT_MOBILEtc || m_type == OBJECT_MOBILEwc || @@ -2874,6 +2941,8 @@ void COldObject::CreateSelectParticle() m_type == OBJECT_MOBILEtt || m_type == OBJECT_MOBILEwt || m_type == OBJECT_MOBILEit || + m_type == OBJECT_MOBILErp || + m_type == OBJECT_MOBILEst || m_type == OBJECT_MOBILEdr ) // vehicle? { pos = Math::Vector(0.0f, 0.0f, 0.0f); @@ -2910,24 +2979,16 @@ void COldObject::UpdateSelectParticle() if ( m_type == OBJECT_MOBILErt || m_type == OBJECT_MOBILErc || m_type == OBJECT_MOBILErr || - m_type == OBJECT_MOBILErs ) // large caterpillars? + m_type == OBJECT_MOBILErs || + m_type == OBJECT_MOBILErp ) // large caterpillars? { pos[0] = Math::Vector(4.2f, 2.8f, 1.5f); pos[1] = Math::Vector(4.2f, 2.8f, -1.5f); dim[0].x = 1.5f; dim[1].x = 1.5f; } - else if ( m_type == OBJECT_MOBILEwt || - m_type == OBJECT_MOBILEtt || - m_type == OBJECT_MOBILEft || - m_type == OBJECT_MOBILEit ) // trainer ? - { - pos[0] = Math::Vector(4.2f, 2.5f, 1.2f); - pos[1] = Math::Vector(4.2f, 2.5f, -1.2f); - dim[0].x = 1.5f; - dim[1].x = 1.5f; - } - else if ( m_type == OBJECT_MOBILEsa ) // submarine? + else if ( m_type == OBJECT_MOBILEsa || + m_type == OBJECT_MOBILEst ) // submarine? { pos[0] = Math::Vector(3.6f, 4.0f, 2.0f); pos[1] = Math::Vector(3.6f, 4.0f, -2.0f); @@ -2942,6 +3003,17 @@ void COldObject::UpdateSelectParticle() pos[0] = Math::Vector(4.9f, 3.5f, 2.5f); pos[1] = Math::Vector(4.9f, 3.5f, -2.5f); } + else if ( m_type == OBJECT_MOBILEwt || + m_type == OBJECT_MOBILEtt || + m_type == OBJECT_MOBILEft || + m_type == OBJECT_MOBILEit || + GetTrainer()) // trainer ? + { + pos[0] = Math::Vector(4.2f, 2.5f, 1.2f); + pos[1] = Math::Vector(4.2f, 2.5f, -1.2f); + dim[0].x = 1.5f; + dim[1].x = 1.5f; + } else { pos[0] = Math::Vector(4.2f, 2.5f, 1.5f); @@ -2949,57 +3021,72 @@ void COldObject::UpdateSelectParticle() } // Red back lens - if ( m_type == OBJECT_MOBILEfa || - m_type == OBJECT_MOBILEfc || - m_type == OBJECT_MOBILEfi || - m_type == OBJECT_MOBILEfs || - m_type == OBJECT_MOBILEft ) // flying? + if ( m_type == OBJECT_MOBILEwt || + m_type == OBJECT_MOBILEtt || + m_type == OBJECT_MOBILEft || + m_type == OBJECT_MOBILEit || + GetTrainer()) // trainer? + { + pos[2] = Math::Vector(-4.0f, 2.5f, 2.2f); + pos[3] = Math::Vector(-4.0f, 2.5f, -2.2f); + } + else if ( m_type == OBJECT_MOBILEfa || + m_type == OBJECT_MOBILEfb || + m_type == OBJECT_MOBILEfc || + m_type == OBJECT_MOBILEfi || + m_type == OBJECT_MOBILEfs ) // flying? { pos[2] = Math::Vector(-4.0f, 3.1f, 4.5f); pos[3] = Math::Vector(-4.0f, 3.1f, -4.5f); dim[2].x = 0.6f; dim[3].x = 0.6f; } - if ( m_type == OBJECT_MOBILEwa || - m_type == OBJECT_MOBILEwc || - m_type == OBJECT_MOBILEwi || - m_type == OBJECT_MOBILEws ) // wheels? + else if ( m_type == OBJECT_MOBILEwa || + m_type == OBJECT_MOBILEwb || + m_type == OBJECT_MOBILEwc || + m_type == OBJECT_MOBILEwi || + m_type == OBJECT_MOBILEws ) // wheels? { pos[2] = Math::Vector(-4.5f, 2.7f, 2.8f); pos[3] = Math::Vector(-4.5f, 2.7f, -2.8f); } - if ( m_type == OBJECT_MOBILEwt ) // wheels? - { - pos[2] = Math::Vector(-4.0f, 2.5f, 2.2f); - pos[3] = Math::Vector(-4.0f, 2.5f, -2.2f); - } - if ( m_type == OBJECT_MOBILEia || - m_type == OBJECT_MOBILEic || - m_type == OBJECT_MOBILEii || - m_type == OBJECT_MOBILEis || - m_type == OBJECT_MOBILEit ) // legs? + else if ( m_type == OBJECT_MOBILEia || + m_type == OBJECT_MOBILEib || + m_type == OBJECT_MOBILEic || + m_type == OBJECT_MOBILEii || + m_type == OBJECT_MOBILEis ) // legs? { pos[2] = Math::Vector(-4.5f, 2.7f, 2.8f); pos[3] = Math::Vector(-4.5f, 2.7f, -2.8f); } - if ( m_type == OBJECT_MOBILEta || - m_type == OBJECT_MOBILEtc || - m_type == OBJECT_MOBILEti || - m_type == OBJECT_MOBILEts || - m_type == OBJECT_MOBILEtt ) // caterpillars? + else if ( m_type == OBJECT_MOBILEta || + m_type == OBJECT_MOBILEtb || + m_type == OBJECT_MOBILEtc || + m_type == OBJECT_MOBILEti || + m_type == OBJECT_MOBILEts ) // caterpillars? { pos[2] = Math::Vector(-3.6f, 4.2f, 3.0f); pos[3] = Math::Vector(-3.6f, 4.2f, -3.0f); } - if ( m_type == OBJECT_MOBILErt || - m_type == OBJECT_MOBILErc || - m_type == OBJECT_MOBILErr || - m_type == OBJECT_MOBILErs ) // large caterpillars? + else if ( m_type == OBJECT_MOBILErt || + m_type == OBJECT_MOBILErc || + m_type == OBJECT_MOBILErr || + m_type == OBJECT_MOBILErs ) // large caterpillars? { pos[2] = Math::Vector(-5.0f, 5.2f, 2.5f); pos[3] = Math::Vector(-5.0f, 5.2f, -2.5f); } - if ( m_type == OBJECT_MOBILEsa ) // submarine? + if ( m_type == OBJECT_MOBILErp || ( GetTrainer() && + ( m_type == OBJECT_MOBILErt || + m_type == OBJECT_MOBILErc || + m_type == OBJECT_MOBILErr || + m_type == OBJECT_MOBILErs))) // large caterpillars (trainer)? + { + pos[2] = Math::Vector(-4.6f, 5.2f, 2.6f); + pos[3] = Math::Vector(-4.6f, 5.2f, -2.6f); + } + if ( m_type == OBJECT_MOBILEsa || + m_type == OBJECT_MOBILEst ) // submarine? { pos[2] = Math::Vector(-3.6f, 4.0f, 2.0f); pos[3] = Math::Vector(-3.6f, 4.0f, -2.0f); @@ -3218,6 +3305,10 @@ float COldObject::GetLightningHitProbability() m_type == OBJECT_MOBILEta || m_type == OBJECT_MOBILEwa || m_type == OBJECT_MOBILEia || + m_type == OBJECT_MOBILEfb || + m_type == OBJECT_MOBILEtb || + m_type == OBJECT_MOBILEwb || + m_type == OBJECT_MOBILEib || m_type == OBJECT_MOBILEfc || m_type == OBJECT_MOBILEtc || m_type == OBJECT_MOBILEwc || @@ -3239,6 +3330,9 @@ float COldObject::GetLightningHitProbability() m_type == OBJECT_MOBILEtt || m_type == OBJECT_MOBILEwt || m_type == OBJECT_MOBILEit || + m_type == OBJECT_MOBILErp || + m_type == OBJECT_MOBILEst || + m_type == OBJECT_MOBILEtg || m_type == OBJECT_MOBILEdr ) // robot? { return 0.5f; @@ -3252,8 +3346,7 @@ bool COldObject::IsSelectableByDefault(ObjectType type) type == OBJECT_ANT || type == OBJECT_SPIDER || type == OBJECT_BEE || - type == OBJECT_WORM || - type == OBJECT_MOBILEtg ) + type == OBJECT_WORM ) { return false; } diff --git a/src/object/subclass/base_building.cpp b/src/object/subclass/base_building.cpp index 38faea1b..9c15b06d 100644 --- a/src/object/subclass/base_building.cpp +++ b/src/object/subclass/base_building.cpp @@ -64,6 +64,7 @@ std::unique_ptr CBaseBuilding::Create( { auto obj = MakeUnique(params.id, params.type); + obj->SetTrainer(params.trainer); obj->SetTeam(params.team); float height = params.height; diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp index 76df10d2..d9b6da83 100644 --- a/src/object/task/taskbuild.cpp +++ b/src/object/task/taskbuild.cpp @@ -86,7 +86,7 @@ CTaskBuild::~CTaskBuild() // Creates a building. -void CTaskBuild::CreateBuilding(Math::Vector pos, float angle) +void CTaskBuild::CreateBuilding(Math::Vector pos, float angle, bool trainer) { ObjectCreateParams params; params.pos = pos; @@ -94,6 +94,7 @@ void CTaskBuild::CreateBuilding(Math::Vector pos, float angle) params.type = m_type; params.power = 0.0f; params.team = m_object->GetTeam(); + params.trainer = trainer; m_building = CObjectManager::GetInstancePointer()->CreateObject(params); m_building->SetLock(true); // not yet usable @@ -202,9 +203,9 @@ void CTaskBuild::BlackLight() bool CTaskBuild::EventProcess(const Event &event) { Math::Matrix* mat; - Math::Vector pos, dir, speed; + Math::Vector pos, dir, speed, pv, pm, tilt; Math::Point dim; - float a, g, cirSpeed, dist, linSpeed; + float a, g, cirSpeed, dist, linSpeed, diff; if ( m_engine->GetPause() ) return true; if ( event.type != EVENT_FRAME ) return true; @@ -246,8 +247,16 @@ bool CTaskBuild::EventProcess(const Event &event) { dist = Math::Distance(m_object->GetPosition(), m_metal->GetPosition()); linSpeed = 0.0f; - if ( dist > 30.0f ) linSpeed = 1.0f; - if ( dist < 30.0f ) linSpeed = -1.0f; + if ( m_physics->GetLand() ) + { + if ( dist > 30.0f ) linSpeed = 1.0f; + if ( dist < 30.0f ) linSpeed = -1.0f; + } + else + { + if ( dist > 55.0f ) linSpeed = 0.5f; + if ( dist < 35.0f ) linSpeed = -0.5f; + } m_physics->SetMotorSpeedX(linSpeed); // forward/backward return true; } @@ -279,7 +288,7 @@ bool CTaskBuild::EventProcess(const Event &event) pos = m_metal->GetPosition(); a = m_object->GetRotationY(); - CreateBuilding(pos, a+Math::PI); + CreateBuilding(pos, a+Math::PI, m_object->GetTrainer()); CreateLight(); } @@ -321,11 +330,12 @@ bool CTaskBuild::EventProcess(const Event &event) mat = m_object->GetWorldMatrix(14); break; - case OBJECT_MOBILEfa: - case OBJECT_MOBILEta: - case OBJECT_MOBILEwa: - case OBJECT_MOBILEia: - mat = m_object->GetWorldMatrix(3); + case OBJECT_MOBILEfb: + case OBJECT_MOBILEtb: + case OBJECT_MOBILEwb: + case OBJECT_MOBILEib: + mat = m_object->GetWorldMatrix(1); + pos.y += 2.0f; break; default: @@ -347,6 +357,16 @@ bool CTaskBuild::EventProcess(const Event &event) } } + if(m_object->GetType() == OBJECT_MOBILEfb && m_object->GetReactorRange()<0.2f && m_phase != TBP_MOVE) + { + pv = m_object->GetPosition(); + pm = m_metal->GetPosition(); + dist = Math::Distance(pv, pm); + diff = pm.y - 8.0f - pv.y; + tilt = m_object->GetRotation(); + m_object->StartTaskGunGoal(asin(diff/dist)-tilt.z, 0.0f); + } + return true; } @@ -372,7 +392,7 @@ Error CTaskBuild::Start(ObjectType type) pos = m_object->GetPosition(); if ( pos.y < m_water->GetLevel() ) return ERR_BUILD_WATER; - if ( !m_physics->GetLand() ) return ERR_BUILD_FLY; + if ( !m_physics->GetLand() && m_object->GetType()!=OBJECT_MOBILEfb) return ERR_BUILD_FLY; speed = m_physics->GetMotorSpeed(); if ( speed.x != 0.0f || @@ -392,15 +412,17 @@ Error CTaskBuild::Start(ObjectType type) err = FlatFloor(); if ( err != ERR_OK ) return err; + pv = m_object->GetPosition(); + pm = m_metal->GetPosition(); + if(!m_physics->GetLand() && fabs(pm.y-pv.y)>8.0f) return ERR_BUILD_METALAWAY; + m_metal->SetLock(true); // not usable m_camera->StartCentering(m_object, Math::PI*0.15f, 99.9f, 0.0f, 1.0f); m_phase = TBP_TURN; // rotation necessary preliminary m_angleY = oAngle; // angle was reached - pv = m_object->GetPosition(); pv.y += 8.3f; - pm = m_metal->GetPosition(); m_angleZ = Math::RotateAngle(Math::DistanceProjected(pv, pm), fabs(pv.y-pm.y)); m_physics->SetFreeze(true); // it does not move @@ -415,7 +437,8 @@ Error CTaskBuild::Start(ObjectType type) Error CTaskBuild::IsEnded() { CAuto* automat; - float angle, dist, time; + float angle, dist, time, diff; + Math::Vector pv, pm, tilt; if ( m_engine->GetPause() ) return ERR_CONTINUE; if ( m_bError ) return ERR_STOP; @@ -450,7 +473,19 @@ Error CTaskBuild::IsEnded() { dist = Math::Distance(m_object->GetPosition(), m_metal->GetPosition()); - if ( dist >= 25.0f && dist <= 35.0f ) + if ( !m_physics->GetLand()) + { + if(dist >= 35.0f && dist <= 55.0f) + { + m_physics->SetMotorSpeedX(0.0f); + m_motion->SetAction(MHS_GUN); // takes gun + + m_phase = TBP_TAKE; + m_speed = 1.0f/1.0f; + m_progress = 0.0f; + } + } + else if ( dist >= 25.0f && dist <= 35.0f) { m_physics->SetMotorSpeedX(0.0f); m_motion->SetAction(MHS_GUN); // takes gun @@ -482,6 +517,19 @@ Error CTaskBuild::IsEnded() m_object->SetPartPosition(14, Math::Vector(0.6f, 0.1f, 0.3f)); m_object->SetPartRotationZ(14, 0.0f); } + if (m_object->GetType() == OBJECT_MOBILEfb || + m_object->GetType() == OBJECT_MOBILEib || + m_object->GetType() == OBJECT_MOBILEtb || + m_object->GetType() == OBJECT_MOBILEwb) + { + m_object->SetObjectParent(1, 0); + pv = m_object->GetPosition(); + pm = m_metal->GetPosition(); + dist = Math::Distance(pv, pm); + diff = pm.y - 8.0f - pv.y; + tilt = m_object->GetRotation(); + if(dist) m_object->StartTaskGunGoal(asin(diff/dist)-tilt.z, 0.0f); + } m_phase = TBP_PREP; m_speed = 1.0f/1.0f; @@ -542,6 +590,8 @@ Error CTaskBuild::IsEnded() m_object->SetPartPosition(14, Math::Vector(-1.5f, 0.3f, -1.35f)); m_object->SetPartRotationZ(14, Math::PI); } + else + m_object->StartTaskGunGoal(0.0f, 0.0f); if ( m_type == OBJECT_FACTORY || m_type == OBJECT_RESEARCH || diff --git a/src/object/task/taskbuild.h b/src/object/task/taskbuild.h index 977da0f2..ad7f09ee 100644 --- a/src/object/task/taskbuild.h +++ b/src/object/task/taskbuild.h @@ -61,7 +61,7 @@ public: protected: Error FlatFloor(); - void CreateBuilding(Math::Vector pos, float angle); + void CreateBuilding(Math::Vector pos, float angle, bool trainer); void CreateLight(); void BlackLight(); CObject* SearchMetalObject(float &angle, float dMin, float dMax, float aLimit, Error &err); diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp index e1b39540..50808e2c 100644 --- a/src/object/task/taskgoto.cpp +++ b/src/object/task/taskgoto.cpp @@ -556,6 +556,10 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact) oType != OBJECT_MOBILEta && oType != OBJECT_MOBILEwa && oType != OBJECT_MOBILEia && + oType != OBJECT_MOBILEfb && + oType != OBJECT_MOBILEtb && + oType != OBJECT_MOBILEwb && + oType != OBJECT_MOBILEib && oType != OBJECT_MOBILEfc && oType != OBJECT_MOBILEtc && oType != OBJECT_MOBILEwc && @@ -578,6 +582,8 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact) oType != OBJECT_MOBILEtt && oType != OBJECT_MOBILEwt && oType != OBJECT_MOBILEit && + oType != OBJECT_MOBILErp && + oType != OBJECT_MOBILEst && oType != OBJECT_MOBILEdr && oType != OBJECT_DERRICK && oType != OBJECT_STATION && @@ -721,7 +727,8 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude, type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs ) + type == OBJECT_MOBILErs || + type == OBJECT_MOBILErp ) { m_bApprox = true; } @@ -1164,6 +1171,10 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance) type == OBJECT_MOBILEta || type == OBJECT_MOBILEwa || type == OBJECT_MOBILEia || + type == OBJECT_MOBILEfb || + type == OBJECT_MOBILEtb || + type == OBJECT_MOBILEwb || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEfs || type == OBJECT_MOBILEts || type == OBJECT_MOBILEws || @@ -1186,6 +1197,8 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance) type == OBJECT_MOBILEtt || type == OBJECT_MOBILEwt || type == OBJECT_MOBILEit || + type == OBJECT_MOBILErp || + type == OBJECT_MOBILEst || type == OBJECT_MOBILEdr ) { assert(pObj->Implements(ObjectInterfaceType::Powered)); @@ -1432,6 +1445,7 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir) fac = 2.0f; if ( iType == OBJECT_MOBILEwa || + iType == OBJECT_MOBILEwb || iType == OBJECT_MOBILEwc || iType == OBJECT_MOBILEwi || iType == OBJECT_MOBILEws || @@ -1441,6 +1455,7 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir) fac = 1.5f; } if ( iType == OBJECT_MOBILEta || + iType == OBJECT_MOBILEtb || iType == OBJECT_MOBILEtc || iType == OBJECT_MOBILEti || iType == OBJECT_MOBILEts || @@ -1451,6 +1466,7 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir) fac = 1.5f; } if ( iType == OBJECT_MOBILEfa || + iType == OBJECT_MOBILEfb || iType == OBJECT_MOBILEfc || iType == OBJECT_MOBILEfi || iType == OBJECT_MOBILEfs || @@ -1468,6 +1484,7 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir) } } if ( iType == OBJECT_MOBILEia || + iType == OBJECT_MOBILEib || iType == OBJECT_MOBILEic || iType == OBJECT_MOBILEii || iType == OBJECT_MOBILEis || @@ -1962,6 +1979,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy) type = m_object->GetType(); if ( type == OBJECT_MOBILEwa || + type == OBJECT_MOBILEwb || type == OBJECT_MOBILEwc || type == OBJECT_MOBILEws || type == OBJECT_MOBILEwi || @@ -1972,6 +1990,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy) } if ( type == OBJECT_MOBILEta || + type == OBJECT_MOBILEtb || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEti || type == OBJECT_MOBILEts ) // caterpillars? @@ -1982,12 +2001,14 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy) if ( type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs ) // large caterpillars? + type == OBJECT_MOBILErs || + type == OBJECT_MOBILErp ) // large caterpillars? { aLimit = 35.0f*Math::PI/180.0f; } - if ( type == OBJECT_MOBILEsa ) // submarine caterpillars? + if ( type == OBJECT_MOBILEsa || + type == OBJECT_MOBILEst ) // submarine caterpillars? { aLimit = 35.0f*Math::PI/180.0f; bAcceptWater = true; @@ -1999,6 +2020,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy) } if ( type == OBJECT_MOBILEfa || + type == OBJECT_MOBILEfb || type == OBJECT_MOBILEfc || type == OBJECT_MOBILEfs || type == OBJECT_MOBILEfi || @@ -2009,6 +2031,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy) } if ( type == OBJECT_MOBILEia || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEic || type == OBJECT_MOBILEis || type == OBJECT_MOBILEii ) // insect legs? diff --git a/src/object/task/tasktake.cpp b/src/object/task/tasktake.cpp index e8a27021..a05828b2 100644 --- a/src/object/task/tasktake.cpp +++ b/src/object/task/tasktake.cpp @@ -354,6 +354,10 @@ CObject* CTaskTake::SearchFriendObject(float &angle, type != OBJECT_MOBILEta && type != OBJECT_MOBILEwa && type != OBJECT_MOBILEia && + type != OBJECT_MOBILEfb && + type != OBJECT_MOBILEtb && + type != OBJECT_MOBILEwb && + type != OBJECT_MOBILEib && type != OBJECT_MOBILEfc && type != OBJECT_MOBILEtc && type != OBJECT_MOBILEwc && @@ -376,6 +380,8 @@ CObject* CTaskTake::SearchFriendObject(float &angle, type != OBJECT_MOBILEtt && type != OBJECT_MOBILEwt && type != OBJECT_MOBILEit && + type != OBJECT_MOBILErp && + type != OBJECT_MOBILEst && type != OBJECT_TOWER && type != OBJECT_RESEARCH && type != OBJECT_ENERGY && diff --git a/src/object/tool_type.cpp b/src/object/tool_type.cpp index 3a06e455..b10cfc5f 100644 --- a/src/object/tool_type.cpp +++ b/src/object/tool_type.cpp @@ -47,6 +47,12 @@ ToolType GetToolFromObject(ObjectType type) case OBJECT_MOBILEii: return ToolType::OrganicShooter; + case OBJECT_MOBILEwb: + case OBJECT_MOBILEtb: + case OBJECT_MOBILEfb: + case OBJECT_MOBILEib: + return ToolType::Builder; + default: return ToolType::Other; } diff --git a/src/object/tool_type.h b/src/object/tool_type.h index 627f8307..26784d92 100644 --- a/src/object/tool_type.h +++ b/src/object/tool_type.h @@ -28,6 +28,7 @@ enum class ToolType : unsigned int Sniffer, Shooter, OrganicShooter, + Builder, }; ToolType GetToolFromObject(ObjectType type); diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index 7e30a8e4..753881cf 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -988,9 +988,11 @@ void CPhysics::MotorUpdate(float aTime, float rTime) { factor = 1.0f; if ( type == OBJECT_MOBILEia || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEis || type == OBJECT_MOBILEic || - type == OBJECT_MOBILEii ) factor = 0.5f; + type == OBJECT_MOBILEii || + type == OBJECT_MOBILEit ) factor = 0.5f; energy = power->GetEnergy(); energy -= fabs(motorSpeed.x)*rTime*factor*0.005f; @@ -1148,6 +1150,7 @@ void CPhysics::EffectUpdate(float aTime, float rTime) } if ( type == OBJECT_MOBILEwa || + type == OBJECT_MOBILEwb || type == OBJECT_MOBILEwc || type == OBJECT_MOBILEwi || type == OBJECT_MOBILEws || @@ -1193,6 +1196,7 @@ void CPhysics::EffectUpdate(float aTime, float rTime) } if ( type == OBJECT_MOBILEfa || + type == OBJECT_MOBILEfb || type == OBJECT_MOBILEfc || type == OBJECT_MOBILEfi || type == OBJECT_MOBILEfs || @@ -1800,6 +1804,10 @@ void CPhysics::WaterFrame(float aTime, float rTime) type == OBJECT_MOBILEta || type == OBJECT_MOBILEwa || type == OBJECT_MOBILEia || + type == OBJECT_MOBILEfb || + type == OBJECT_MOBILEtb || + type == OBJECT_MOBILEwb || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEfc || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEwc || @@ -1820,6 +1828,8 @@ void CPhysics::WaterFrame(float aTime, float rTime) type == OBJECT_MOBILEtt || type == OBJECT_MOBILEwt || type == OBJECT_MOBILEit || + type == OBJECT_MOBILErp || + type == OBJECT_MOBILEtg || type == OBJECT_MOBILEdr || type == OBJECT_APOLLO2 ) { @@ -1838,9 +1848,11 @@ void CPhysics::SoundMotorFull(float rTime, ObjectType type) float amplitude, time, freq; if ( type == OBJECT_MOBILEia || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEic || type == OBJECT_MOBILEii || - type == OBJECT_MOBILEis ) + type == OBJECT_MOBILEis || + type == OBJECT_MOBILEit ) { if ( m_soundChannel == -1 ) { @@ -1867,7 +1879,8 @@ void CPhysics::SoundMotorFull(float rTime, ObjectType type) return; } - if ( type == OBJECT_MOBILEsa ) + if ( type == OBJECT_MOBILEsa || + type == OBJECT_MOBILEst ) { sound = SOUND_MOTORs; amplitude = 0.6f; @@ -1876,7 +1889,8 @@ void CPhysics::SoundMotorFull(float rTime, ObjectType type) else if ( type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs ) + type == OBJECT_MOBILErs || + type == OBJECT_MOBILErp ) { sound = SOUND_MOTORr; amplitude = 1.0f; @@ -1885,7 +1899,8 @@ void CPhysics::SoundMotorFull(float rTime, ObjectType type) else if ( type == OBJECT_MOBILEta || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEti || - type == OBJECT_MOBILEts ) + type == OBJECT_MOBILEts || + type == OBJECT_MOBILEtt ) { sound = SOUND_MOTORt; amplitude = 1.0f; @@ -1953,9 +1968,11 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type) int i, max; if ( type == OBJECT_MOBILEia || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEic || type == OBJECT_MOBILEii || - type == OBJECT_MOBILEis ) + type == OBJECT_MOBILEis || + type == OBJECT_MOBILEit ) { if ( m_soundChannel != -1 ) // engine is running? { @@ -1966,7 +1983,8 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type) return; } - if ( type == OBJECT_MOBILEsa ) + if ( type == OBJECT_MOBILEsa || + type == OBJECT_MOBILEst ) { sound = SOUND_MOTORs; amplitude = 0.4f; @@ -1974,15 +1992,18 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type) else if ( type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs ) + type == OBJECT_MOBILErs || + type == OBJECT_MOBILErp ) { sound = SOUND_MOTORr; amplitude = 0.9f; } else if ( type == OBJECT_MOBILEta || + type == OBJECT_MOBILEtb || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEti || - type == OBJECT_MOBILEts ) + type == OBJECT_MOBILEts || + type == OBJECT_MOBILEtt ) { sound = SOUND_MOTORt; amplitude = 0.7f; @@ -2031,7 +2052,8 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type) if ( type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs ) + type == OBJECT_MOBILErs || + type == OBJECT_MOBILErp ) { m_soundTimePshhh -= rTime; @@ -2074,9 +2096,11 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type) void CPhysics::SoundMotorStop(float rTime, ObjectType type) { if ( type == OBJECT_MOBILEia || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEic || type == OBJECT_MOBILEii || - type == OBJECT_MOBILEis ) + type == OBJECT_MOBILEis || + type == OBJECT_MOBILEit ) { if ( m_soundChannel != -1 ) // engine is running? { @@ -2501,7 +2525,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle) { if ( pObj == m_object ) continue; // yourself? if (IsObjectBeingTransported(pObj)) continue; - if ( pObj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast(pObj)->IsDying() ) continue; // is burning or exploding? + //if ( pObj->Implements(ObjectInterfaceType::Destroyable) && dynamic_cast(pObj)->IsDying() ) continue; // is burning or exploding? oType = pObj->GetType(); if ( oType == OBJECT_TOTO ) continue; @@ -2696,7 +2720,7 @@ bool CPhysics::ExploOther(ObjectType iType, if (pObj->GetType() == OBJECT_STONE ) { destructionForce = 25.0f; } // TitaniumOre if (pObj->GetType() == OBJECT_URANIUM ) { destructionForce = 25.0f; } // UraniumOre if (pObj->GetType() == OBJECT_MOBILEtg) { destructionForce = 10.0f; damageType = DamageType::Explosive; } // TargetBot (something running into it) - if (iType == OBJECT_MOBILEtg) { destructionForce = 10.0f; damageType = DamageType::Explosive; } // TargetBot (it running into something) + if (iType == OBJECT_MOBILEtg) { destructionForce = 0.0f; damageType = DamageType::Explosive; } // TargetBot (it running into something) if (pObj->GetType() == OBJECT_TNT ) { destructionForce = 10.0f; damageType = DamageType::Explosive; } // TNT if (pObj->GetType() == OBJECT_BOMB ) { destructionForce = 0.0f; damageType = DamageType::Explosive; } // Mine @@ -2736,6 +2760,10 @@ bool CPhysics::ExploOther(ObjectType iType, oType == OBJECT_MOBILEta || oType == OBJECT_MOBILEfa || oType == OBJECT_MOBILEia || + oType == OBJECT_MOBILEwb || + oType == OBJECT_MOBILEtb || + oType == OBJECT_MOBILEfb || + oType == OBJECT_MOBILEib || oType == OBJECT_MOBILEwc || oType == OBJECT_MOBILEtc || oType == OBJECT_MOBILEfc || @@ -2756,7 +2784,9 @@ bool CPhysics::ExploOther(ObjectType iType, oType == OBJECT_MOBILEwt || oType == OBJECT_MOBILEtt || oType == OBJECT_MOBILEft || - oType == OBJECT_MOBILEit ) // vehicle? + oType == OBJECT_MOBILEit || + oType == OBJECT_MOBILErp || + oType == OBJECT_MOBILEst ) // vehicle? { assert(pObj->Implements(ObjectInterfaceType::Damageable)); // TODO: implement "killer"? @@ -2780,7 +2810,7 @@ int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force) float destructionForce = -1.0f; // minimal force required to destroy an object using this explosive, default: not explosive if ( oType == OBJECT_TNT ) destructionForce = 10.0f; // TNT if ( oType == OBJECT_MOBILEtg ) destructionForce = 10.0f; // TargetBot (something running into it) - if ( iType == OBJECT_MOBILEtg ) destructionForce = 10.0f; // TargetBot (it running into something) + if ( iType == OBJECT_MOBILEtg ) destructionForce = 0.0f; // TargetBot (it running into something) if ( oType == OBJECT_BOMB ) destructionForce = 0.0f; // Mine if ( force > destructionForce && destructionForce >= 0.0f ) @@ -2797,6 +2827,10 @@ int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force) iType == OBJECT_MOBILEta || iType == OBJECT_MOBILEfa || iType == OBJECT_MOBILEia || + iType == OBJECT_MOBILEwb || + iType == OBJECT_MOBILEtb || + iType == OBJECT_MOBILEfb || + iType == OBJECT_MOBILEib || iType == OBJECT_MOBILEwc || iType == OBJECT_MOBILEtc || iType == OBJECT_MOBILEfc || @@ -2818,6 +2852,8 @@ int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force) iType == OBJECT_MOBILEtt || iType == OBJECT_MOBILEft || iType == OBJECT_MOBILEit || + iType == OBJECT_MOBILErp || + iType == OBJECT_MOBILEst || iType == OBJECT_MOBILEdr || iType == OBJECT_APOLLO2 ) // vehicle? { @@ -3019,9 +3055,11 @@ void CPhysics::MotorParticle(float aTime, float rTime) type = m_object->GetType(); if ( type == OBJECT_MOBILEia || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEic || type == OBJECT_MOBILEii || - type == OBJECT_MOBILEis || // legs? + type == OBJECT_MOBILEis || + type == OBJECT_MOBILEit || // legs? type == OBJECT_MOBILEdr || type == OBJECT_MOTHER || type == OBJECT_ANT || @@ -3124,9 +3162,11 @@ void CPhysics::MotorParticle(float aTime, float rTime) } if ( type == OBJECT_MOBILEta || + type == OBJECT_MOBILEtb || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEti || - type == OBJECT_MOBILEts ) // caterpillars? + type == OBJECT_MOBILEts || + type == OBJECT_MOBILEtt ) // caterpillars? { if ( aTime-m_lastSlideParticle >= m_engine->ParticleAdapt(0.05f) ) { @@ -3153,7 +3193,8 @@ void CPhysics::MotorParticle(float aTime, float rTime) if ( type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs ) // large caterpillars? + type == OBJECT_MOBILErs || + type == OBJECT_MOBILErp ) // large caterpillars? { if ( aTime-m_lastSlideParticle >= m_engine->ParticleAdapt(0.05f) ) { @@ -3427,7 +3468,7 @@ void CPhysics::MotorParticle(float aTime, float rTime) } } - if ( type == OBJECT_MOBILEsa && m_bSwim ) + if ( (type == OBJECT_MOBILEsa || type == OBJECT_MOBILEst) && m_bSwim ) { h = Math::Mod(aTime, 3.0f); if ( h < 1.5f && ( h < 0.5f || h > 0.9f ) ) return; @@ -3461,7 +3502,8 @@ void CPhysics::MotorParticle(float aTime, float rTime) if ( type == OBJECT_MOBILErt || type == OBJECT_MOBILErc || type == OBJECT_MOBILErr || - type == OBJECT_MOBILErs ) + type == OBJECT_MOBILErs || + type == OBJECT_MOBILErp ) { if ( !m_bMotor ) return; diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index 02bc4525..60707e07 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -82,7 +82,12 @@ const char* GetObjectName(ObjectType type) if ( type == OBJECT_MARKKEYb ) return "KeyBSpot"; if ( type == OBJECT_MARKKEYc ) return "KeyCSpot"; if ( type == OBJECT_MARKKEYd ) return "KeyDSpot"; - if ( type == OBJECT_MOBILEwt ) return "PracticeBot"; + if ( type == OBJECT_MOBILEwt ) return "WheeledTrainer"; + if ( type == OBJECT_MOBILEtt ) return "TrackedTrainer"; + if ( type == OBJECT_MOBILEft ) return "WingedTrainer"; + if ( type == OBJECT_MOBILEit ) return "LeggedTrainer"; + if ( type == OBJECT_MOBILErp ) return "HeavyTrainer"; + if ( type == OBJECT_MOBILEst ) return "AmphibiousTrainer"; if ( type == OBJECT_MOBILEwa ) return "WheeledGrabber"; if ( type == OBJECT_MOBILEta ) return "TrackedGrabber"; if ( type == OBJECT_MOBILEfa ) return "WingedGrabber"; @@ -99,6 +104,10 @@ const char* GetObjectName(ObjectType type) if ( type == OBJECT_MOBILEts ) return "TrackedSniffer"; if ( type == OBJECT_MOBILEfs ) return "WingedSniffer"; if ( type == OBJECT_MOBILEis ) return "LeggedSniffer"; + if ( type == OBJECT_MOBILEwb ) return "WheeledBuilder"; + if ( type == OBJECT_MOBILEtb ) return "TrackedBuilder"; + if ( type == OBJECT_MOBILEfb ) return "WingedBuilder"; + if ( type == OBJECT_MOBILEib ) return "LeggedBuilder"; if ( type == OBJECT_MOBILErt ) return "Thumper"; if ( type == OBJECT_MOBILErc ) return "PhazerShooter"; if ( type == OBJECT_MOBILErr ) return "Recycler"; @@ -106,6 +115,7 @@ const char* GetObjectName(ObjectType type) if ( type == OBJECT_MOBILEsa ) return "Subber"; if ( type == OBJECT_MOBILEtg ) return "TargetBot"; if ( type == OBJECT_MOBILEdr ) return "Scribbler"; + if ( type == OBJECT_MOBILEpr ) return "PracticeBot"; if ( type == OBJECT_HUMAN ) return "Me"; if ( type == OBJECT_TECH ) return "Tech"; if ( type == OBJECT_MOTHER ) return "AlienQueen"; @@ -196,14 +206,24 @@ std::string GetHelpFilename(ObjectType type) if ( type == OBJECT_MOBILEtc ) helpfile = "object/botfc"; if ( type == OBJECT_MOBILEfc ) helpfile = "object/botfj"; if ( type == OBJECT_MOBILEic ) helpfile = "object/botfs"; + if ( type == OBJECT_MOBILEwb ) helpfile = "object/botbr"; + if ( type == OBJECT_MOBILEtb ) helpfile = "object/botbc"; + if ( type == OBJECT_MOBILEfb ) helpfile = "object/botbj"; + if ( type == OBJECT_MOBILEib ) helpfile = "object/botbs"; if ( type == OBJECT_MOBILErt ) helpfile = "object/bottump"; if ( type == OBJECT_MOBILErc ) helpfile = "object/botphaz"; if ( type == OBJECT_MOBILErr ) helpfile = "object/botrecy"; if ( type == OBJECT_MOBILErs ) helpfile = "object/botshld"; if ( type == OBJECT_MOBILEsa ) helpfile = "object/botsub"; if ( type == OBJECT_MOBILEwt ) helpfile = "object/bottr"; + if ( type == OBJECT_MOBILEtt ) helpfile = "object/bottr"; + if ( type == OBJECT_MOBILEft ) helpfile = "object/bottr"; + if ( type == OBJECT_MOBILEit ) helpfile = "object/bottr"; + if ( type == OBJECT_MOBILErp ) helpfile = "object/bottr"; + if ( type == OBJECT_MOBILEst ) helpfile = "object/bottr"; if ( type == OBJECT_MOBILEtg ) helpfile = "object/bottarg"; if ( type == OBJECT_MOBILEdr ) helpfile = "object/botdraw"; + if ( type == OBJECT_MOBILEpr ) helpfile = "object/bottr"; if ( type == OBJECT_APOLLO2 ) helpfile = "object/lrv"; if ( type == OBJECT_HUMAN ) helpfile = "object/human"; if ( type == OBJECT_MOTHER ) helpfile = "object/mother"; @@ -270,7 +290,7 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "trunc" ) == 0 ) helpfile = "cbot/trunc"; if ( strcmp(token, "retobject" ) == 0 ) helpfile = "cbot/retobj"; if ( strcmp(token, "errmode" ) == 0 ) helpfile = "cbot/errmode"; - if ( strcmp(token, "busy" ) == 0 ) helpfile = "cbot/busy"; + if ( strcmp(token, "isbusy" ) == 0 ) helpfile = "cbot/isbusy"; if ( strcmp(token, "takeoff" ) == 0 ) helpfile = "cbot/takeoff"; if ( strcmp(token, "research" ) == 0 ) helpfile = "cbot/research"; if ( strcmp(token, "factory" ) == 0 ) helpfile = "cbot/factory"; @@ -429,7 +449,7 @@ bool IsFunction(const char *token) if ( strcmp(token, "trunc" ) == 0 ) return true; if ( strcmp(token, "retobjectbyid") == 0 ) return true; if ( strcmp(token, "retobject" ) == 0 ) return true; - if ( strcmp(token, "busy" ) == 0 ) return true; + if ( strcmp(token, "isbusy" ) == 0 ) return true; if ( strcmp(token, "factory" ) == 0 ) return true; if ( strcmp(token, "research" ) == 0 ) return true; if ( strcmp(token, "takeoff" ) == 0 ) return true; @@ -535,11 +555,11 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( rank );"; if ( strcmp(token, "retobjectbyid") == 0 ) return "retobjectbyid ( rank );"; if ( strcmp(token, "progfunc" ) == 0 ) return "progfunc ( funcname );"; - 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, "isbusy" ) == 0 ) return "isbusy ( object );"; + if ( strcmp(token, "factory" ) == 0 ) return "factory ( cat, program, object );"; + if ( strcmp(token, "research" ) == 0 ) return "research ( type, object );"; + if ( strcmp(token, "takeoff" ) == 0 ) return "takeoff ( object );"; + if ( strcmp(token, "destroy" ) == 0 ) return "destroy ( object );"; if ( strcmp(token, "search" ) == 0 ) return "search ( cat, pos, min, max, sens, filter );"; if ( strcmp(token, "searchall" ) == 0 ) return "searchall ( cat, pos, min, max, sens, filter );"; if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens, filter );"; diff --git a/src/script/scriptfunc.cpp b/src/script/scriptfunc.cpp index 0816cce8..661a4946 100644 --- a/src/script/scriptfunc.cpp +++ b/src/script/scriptfunc.cpp @@ -344,22 +344,30 @@ bool CScriptFunctions::rGetObject(CBotVar* var, CBotVar* result, int& exception, return true; } -// Compilation of instruction "object.busy()" -CBotTypResult CScriptFunctions::cBusy(CBotVar* thisclass, CBotVar* &var) +// Compilation of instruction "isbusy( object )" + +CBotTypResult CScriptFunctions::cIsBusy(CBot::CBotVar* &var, void* user) { - if ( var != nullptr ) return CBotTypResult(CBotErrOverParam); + if ( var == nullptr ) return CBotTypResult(CBotErrLowParam); return CBotTypResult(CBotTypBoolean); } -// Instruction "object.busy()" +// Instruction "isbusy( object )" -bool CScriptFunctions::rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception, void* user) +bool CScriptFunctions::rIsBusy(CBotVar* var, CBotVar* result, int& exception, void* user) { CObject* pThis = static_cast(user)->m_object; exception = 0; - CObject* obj = static_cast(thisclass->GetUserPtr()); + CObject* obj = static_cast(var->GetUserPtr()); + if (obj == nullptr) + { + exception = ERR_WRONG_OBJ; + result->SetValInt(ERR_WRONG_OBJ); + return false; + } + CAuto* automat = obj->GetAuto(); if ( pThis->GetTeam() != obj->GetTeam() && obj->GetTeam() != 0 ) @@ -377,7 +385,7 @@ bool CScriptFunctions::rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, return true; } -bool CScriptFunctions::rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception, void* user) +bool CScriptFunctions::rDestroy(CBotVar* var, CBotVar* result, int& exception, void* user) { CScript* script = static_cast(user); CObject* pThis = script->m_object; @@ -385,7 +393,14 @@ bool CScriptFunctions::rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* resul exception = 0; Error err; - CObject* obj = static_cast(thisclass->GetUserPtr()); + CObject* obj = static_cast(var->GetUserPtr()); + if (obj == nullptr) + { + exception = ERR_WRONG_OBJ; + result->SetValInt(ERR_WRONG_OBJ); + return false; + } + CAuto* automat = obj->GetAuto(); if ( pThis->GetTeam() != obj->GetTeam() && obj->GetTeam() != 0 ) @@ -414,26 +429,30 @@ bool CScriptFunctions::rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* resul return true; } +// Compilation of instruction "factory(cat[, program , object])" -// Compilation of instruction "object.factory(cat, program)" - -CBotTypResult CScriptFunctions::cFactory(CBotVar* thisclass, CBotVar* &var) +CBotTypResult CScriptFunctions::cFactory(CBotVar* &var, void* user) { if ( var == nullptr ) return CBotTypResult(CBotErrLowParam); if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); var = var->GetNext(); if ( var != nullptr ) { - if ( var->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadNum); + if ( var->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadParam); var = var->GetNext(); - if ( var != nullptr ) return CBotTypResult(CBotErrOverParam); + if ( var != nullptr ) + { + if ( var->GetType() != CBotTypPointer ) return CBotTypResult(CBotErrBadParam); + var = var->GetNext(); + if ( var != nullptr ) return CBotTypResult(CBotErrOverParam); + } } return CBotTypResult(CBotTypFloat); } -// Instruction "object.factory(cat, program)" +// Instruction "factory(cat[, program , object])" -bool CScriptFunctions::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception, void* user) +bool CScriptFunctions::rFactory(CBotVar* var, CBotVar* result, int& exception, void* user) { CScript* script = static_cast(user); CObject* pThis = script->m_object; @@ -444,18 +463,26 @@ bool CScriptFunctions::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* resul ObjectType type = static_cast(var->GetValInt()); var = var->GetNext(); + std::string program; if ( var != nullptr ) + { program = var->GetValString(); + var = var->GetNext(); + } else program = ""; - CObject* factory = static_cast(thisclass->GetUserPtr()); + CObject* factory; + if (var == nullptr) + factory = CObjectManager::GetInstancePointer()->FindNearest(pThis, OBJECT_FACTORY); + else + factory = static_cast(var->GetUserPtr()); + if (factory == nullptr) { - exception = ERR_UNKNOWN; - result->SetValInt(ERR_UNKNOWN); - GetLogger()->Error("in object.factory() - factory is nullptr"); + exception = ERR_WRONG_OBJ; + result->SetValInt(ERR_WRONG_OBJ); return false; } @@ -473,7 +500,7 @@ bool CScriptFunctions::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* resul { exception = ERR_UNKNOWN; result->SetValInt(ERR_UNKNOWN); - GetLogger()->Error("in object.factory() - automat is nullptr"); + GetLogger()->Error("in factory() - automat is nullptr"); return false; } @@ -507,9 +534,24 @@ bool CScriptFunctions::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* resul return true; } -// Instruction "object.research(type)" +// Compilation of instruction "research(type[, object])" -bool CScriptFunctions::rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception, void* user) +CBotTypResult CScriptFunctions::cResearch(CBotVar* &var, void* user) +{ + if ( var == nullptr ) return CBotTypResult(CBotErrLowParam); + if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); + var = var->GetNext(); + if ( var != nullptr ) + { + if ( var->GetType() != CBotTypPointer ) return CBotTypResult(CBotErrBadParam); + var = var->GetNext(); + if ( var != nullptr ) return CBotTypResult(CBotErrOverParam); + } + return CBotTypResult(CBotTypFloat); +} +// Instruction "research(type[, object])" + +bool CScriptFunctions::rResearch(CBotVar* var, CBotVar* result, int& exception, void* user) { CScript* script = static_cast(user); CObject* pThis = script->m_object; @@ -519,8 +561,21 @@ bool CScriptFunctions::rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* resu exception = 0; ResearchType type = static_cast(var->GetValInt()); + var = var->GetNext(); + + CObject* center; + if (var == nullptr) + center = CObjectManager::GetInstancePointer()->FindNearest(pThis, OBJECT_RESEARCH); + else + center = static_cast(var->GetUserPtr()); + + if (center == nullptr) + { + exception = ERR_WRONG_OBJ; + result->SetValInt(ERR_WRONG_OBJ); + return false; + } - CObject* center = static_cast(thisclass->GetUserPtr()); CAuto* automat = center->GetAuto(); if ( pThis->GetTeam() != center->GetTeam() && center->GetTeam() != 0 ) @@ -582,9 +637,9 @@ bool CScriptFunctions::rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* resu return true; } -// Instruction "object.takeoff()" +// Instruction "takeoff(object)" -bool CScriptFunctions::rTakeOff(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception, void* user) +bool CScriptFunctions::rTakeOff(CBotVar* var, CBotVar* result, int& exception, void* user) { CScript* script = static_cast(user); CObject* pThis = script->m_object; @@ -592,8 +647,14 @@ bool CScriptFunctions::rTakeOff(CBotVar* thisclass, CBotVar* var, CBotVar* resul Error err; exception = 0; + CObject* base = static_cast(var->GetUserPtr()); + if (base == nullptr) + { + exception = ERR_WRONG_OBJ; + result->SetValInt(ERR_WRONG_OBJ); + return false; + } - CObject* base = static_cast(thisclass->GetUserPtr()); CAuto* automat = base->GetAuto(); if ( pThis->GetTeam() != base->GetTeam() && base->GetTeam() != 0 ) @@ -796,16 +857,34 @@ static bool runSearch(CBotVar* var, Math::Vector pos, int& exception, std::funct { while ( array != nullptr ) { + if (array->GetValInt() == OBJECT_MOBILEpr) + { + type_v.push_back(OBJECT_MOBILEwt); + type_v.push_back(OBJECT_MOBILEtt); + type_v.push_back(OBJECT_MOBILEft); + type_v.push_back(OBJECT_MOBILEit); + type_v.push_back(OBJECT_MOBILErp); + type_v.push_back(OBJECT_MOBILEst); + } type_v.push_back(static_cast(array->GetValInt())); array = array->GetNext(); } } else { - if (type != OBJECT_NULL) + if (type != OBJECT_NULL && type != OBJECT_MOBILEpr) { type_v.push_back(static_cast(type)); } + else if (type == OBJECT_MOBILEpr) + { + type_v.push_back(OBJECT_MOBILEwt); + type_v.push_back(OBJECT_MOBILEtt); + type_v.push_back(OBJECT_MOBILEft); + type_v.push_back(OBJECT_MOBILEit); + type_v.push_back(OBJECT_MOBILErp); + type_v.push_back(OBJECT_MOBILEst); + } } return code(type_v, pos, minDist, maxDist, sens < 0, filter); @@ -971,16 +1050,34 @@ static bool runRadar(CBotVar* var, std::function, f { while ( array != nullptr ) { + if (array->GetValInt() == OBJECT_MOBILEpr) + { + type_v.push_back(OBJECT_MOBILEwt); + type_v.push_back(OBJECT_MOBILEtt); + type_v.push_back(OBJECT_MOBILEft); + type_v.push_back(OBJECT_MOBILEit); + type_v.push_back(OBJECT_MOBILErp); + type_v.push_back(OBJECT_MOBILEst); + } type_v.push_back(static_cast(array->GetValInt())); array = array->GetNext(); } } else { - if (type != OBJECT_NULL) + if (type != OBJECT_NULL && type != OBJECT_MOBILEpr) { type_v.push_back(static_cast(type)); } + else if (type == OBJECT_MOBILEpr) + { + type_v.push_back(OBJECT_MOBILEwt); + type_v.push_back(OBJECT_MOBILEtt); + type_v.push_back(OBJECT_MOBILEft); + type_v.push_back(OBJECT_MOBILEit); + type_v.push_back(OBJECT_MOBILErp); + type_v.push_back(OBJECT_MOBILEst); + } } return code(type_v, angle, focus, minDist, maxDist, sens < 0, filter); @@ -1142,16 +1239,34 @@ bool CScriptFunctions::rDetect(CBotVar* var, CBotVar* result, int& exception, vo { while ( array != nullptr ) { + if (array->GetValInt() == OBJECT_MOBILEpr) + { + type_v.push_back(OBJECT_MOBILEwt); + type_v.push_back(OBJECT_MOBILEtt); + type_v.push_back(OBJECT_MOBILEft); + type_v.push_back(OBJECT_MOBILEit); + type_v.push_back(OBJECT_MOBILErp); + type_v.push_back(OBJECT_MOBILEst); + } type_v.push_back(static_cast(array->GetValInt())); array = array->GetNext(); } } else { - if (type != OBJECT_NULL) + if (type != OBJECT_NULL && type != OBJECT_MOBILEpr) { type_v.push_back(static_cast(type)); } + else if (type == OBJECT_MOBILEpr) + { + type_v.push_back(OBJECT_MOBILEwt); + type_v.push_back(OBJECT_MOBILEtt); + type_v.push_back(OBJECT_MOBILEft); + type_v.push_back(OBJECT_MOBILEit); + type_v.push_back(OBJECT_MOBILErp); + type_v.push_back(OBJECT_MOBILEst); + } } pBest = CObjectManager::GetInstancePointer()->Radar(pThis, type_v, 0.0f, 45.0f*Math::PI/180.0f, 0.0f, 20.0f, false, FILTER_NONE, true); @@ -1278,10 +1393,10 @@ bool CScriptFunctions::rBuild(CBotVar* var, CBotVar* result, int& exception, voi oType = pThis->GetType(); - if ( oType != OBJECT_MOBILEfa && // allowed only for grabber bots && humans - oType != OBJECT_MOBILEta && - oType != OBJECT_MOBILEwa && - oType != OBJECT_MOBILEia && + if ( oType != OBJECT_MOBILEfb && // allowed only for builder bots && humans + oType != OBJECT_MOBILEtb && + oType != OBJECT_MOBILEwb && + oType != OBJECT_MOBILEib && oType != OBJECT_HUMAN && oType != OBJECT_TECH ) { @@ -3255,6 +3370,8 @@ void CScriptFunctions::Init() CBotProgram::DefineNum("ResearchRecycler", RESEARCH_RECYCLER); CBotProgram::DefineNum("ResearchSubber", RESEARCH_SUBM); CBotProgram::DefineNum("ResearchSniffer", RESEARCH_SNIFFER); + CBotProgram::DefineNum("ResearchBuilder", RESEARCH_BUILDER); + CBotProgram::DefineNum("ResearchTarget", RESEARCH_TARGET); CBotProgram::DefineNum("PolskiPortalColobota", 1337); @@ -3284,11 +3401,6 @@ void CScriptFunctions::Init() bc->AddItem("id", CBotTypResult(CBotTypInt), CBotVar::ProtectionLevel::ReadOnly); bc->AddItem("team", CBotTypResult(CBotTypInt), CBotVar::ProtectionLevel::ReadOnly); bc->AddItem("velocity", CBotTypResult(CBotTypClass, "point"), CBotVar::ProtectionLevel::ReadOnly); - bc->AddFunction("busy", rBusy, cBusy); - bc->AddFunction("factory", rFactory, cFactory); - bc->AddFunction("research", rResearch, cClassOneFloat); - bc->AddFunction("takeoff", rTakeOff, cClassNull); - bc->AddFunction("destroy", rDestroy, cClassNull); CBotProgram::AddFunction("endmission",rEndMission,cEndMission); CBotProgram::AddFunction("playmusic", rPlayMusic ,cPlayMusic); @@ -3352,8 +3464,12 @@ void CScriptFunctions::Init() CBotProgram::AddFunction("penup", rPenUp, cNull); CBotProgram::AddFunction("pencolor", rPenColor, cOneFloat); CBotProgram::AddFunction("penwidth", rPenWidth, cOneFloat); - + CBotProgram::AddFunction("factory", rFactory, cFactory); CBotProgram::AddFunction("camerafocus", rCameraFocus, cOneObject); + CBotProgram::AddFunction("takeoff", rTakeOff, cOneObject); + CBotProgram::AddFunction("isbusy", rIsBusy, cIsBusy); + CBotProgram::AddFunction("research", rResearch, cResearch); + CBotProgram::AddFunction("destroy", rDestroy, cOneObject); SetFileAccessHandler(MakeUnique()); } diff --git a/src/script/scriptfunc.h b/src/script/scriptfunc.h index 9121ef7c..d11f90b4 100644 --- a/src/script/scriptfunc.h +++ b/src/script/scriptfunc.h @@ -80,6 +80,9 @@ private: static CBot::CBotTypResult cTopo(CBot::CBotVar* &var, void* user); static CBot::CBotTypResult cMessage(CBot::CBotVar* &var, void* user); static CBot::CBotTypResult cPenDown(CBot::CBotVar* &var, void* user); + static CBot::CBotTypResult cIsBusy(CBot::CBotVar* &var, void* user); + static CBot::CBotTypResult cFactory(CBot::CBotVar* &var, void* user); + static CBot::CBotTypResult cResearch(CBot::CBotVar* &var, void* user); static CBot::CBotTypResult cOnePoint(CBot::CBotVar* &var, void* user); static CBot::CBotTypResult cOneObject(CBot::CBotVar* &var, void* user); @@ -143,19 +146,15 @@ private: static bool rPenColor(CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); static bool rPenWidth(CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); static bool rCameraFocus(CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); + static bool rIsBusy(CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); + static bool rTakeOff(CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); + static bool rFactory(CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); + static bool rResearch(CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); + static bool rDestroy(CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); - - static CBot::CBotTypResult cBusy(CBot::CBotVar* thisclass, CBot::CBotVar* &var); - static CBot::CBotTypResult cFactory(CBot::CBotVar* thisclass, CBot::CBotVar* &var); static CBot::CBotTypResult cClassNull(CBot::CBotVar* thisclass, CBot::CBotVar* &var); static CBot::CBotTypResult cClassOneFloat(CBot::CBotVar* thisclass, CBot::CBotVar* &var); - static bool rBusy(CBot::CBotVar* thisclass, CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); - static bool rFactory(CBot::CBotVar* thisclass, CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); - static bool rResearch(CBot::CBotVar* thisclass, CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); - static bool rTakeOff(CBot::CBotVar* thisclass, CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); - static bool rDestroy(CBot::CBotVar* thisclass, CBot::CBotVar* var, CBot::CBotVar* result, int& exception, void* user); - static CBot::CBotTypResult cPointConstructor(CBot::CBotVar* pThis, CBot::CBotVar* &var); static bool rPointConstructor(CBot::CBotVar* pThis, CBot::CBotVar* var, CBot::CBotVar* pResult, int& Exception, void* user); diff --git a/src/ui/controls/map.cpp b/src/ui/controls/map.cpp index 03cee9a1..e120faf5 100644 --- a/src/ui/controls/map.cpp +++ b/src/ui/controls/map.cpp @@ -830,63 +830,87 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, if ( bHilite ) { - icon = -1; - if ( type == OBJECT_FACTORY ) icon = 32; - if ( type == OBJECT_DERRICK ) icon = 33; - if ( type == OBJECT_CONVERT ) icon = 34; - if ( type == OBJECT_RESEARCH ) icon = 35; - if ( type == OBJECT_STATION ) icon = 36; - if ( type == OBJECT_TOWER ) icon = 37; - if ( type == OBJECT_LABO ) icon = 38; - if ( type == OBJECT_ENERGY ) icon = 39; - if ( type == OBJECT_RADAR ) icon = 40; - if ( type == OBJECT_INFO ) icon = 44; - if ( type == OBJECT_REPAIR ) icon = 41; - if ( type == OBJECT_DESTROYER) icon = 41; - if ( type == OBJECT_NUCLEAR ) icon = 42; - if ( type == OBJECT_PARA ) icon = 46; - if ( type == OBJECT_SAFE ) icon = 47; - if ( type == OBJECT_HUSTON ) icon = 48; - if ( type == OBJECT_TARGET1 ) icon = 45; - if ( type == OBJECT_BASE ) icon = 43; - if ( type == OBJECT_HUMAN ) icon = 8; - if ( type == OBJECT_MOBILEfa ) icon = 11; - if ( type == OBJECT_MOBILEta ) icon = 10; - if ( type == OBJECT_MOBILEwa ) icon = 9; - if ( type == OBJECT_MOBILEia ) icon = 22; - if ( type == OBJECT_MOBILEfc ) icon = 17; - if ( type == OBJECT_MOBILEtc ) icon = 16; - if ( type == OBJECT_MOBILEwc ) icon = 15; - if ( type == OBJECT_MOBILEic ) icon = 23; - if ( type == OBJECT_MOBILEfi ) icon = 27; - if ( type == OBJECT_MOBILEti ) icon = 26; - if ( type == OBJECT_MOBILEwi ) icon = 25; - if ( type == OBJECT_MOBILEii ) icon = 28; - if ( type == OBJECT_MOBILEfs ) icon = 14; - if ( type == OBJECT_MOBILEts ) icon = 13; - if ( type == OBJECT_MOBILEws ) icon = 12; - if ( type == OBJECT_MOBILEis ) icon = 24; - if ( type == OBJECT_MOBILErt ) icon = 18; - if ( type == OBJECT_MOBILErc ) icon = 19; - if ( type == OBJECT_MOBILErr ) icon = 20; - if ( type == OBJECT_MOBILErs ) icon = 29; - if ( type == OBJECT_MOBILEsa ) icon = 21; - if ( type == OBJECT_MOBILEft ) icon = 30; - if ( type == OBJECT_MOBILEtt ) icon = 30; - if ( type == OBJECT_MOBILEwt ) icon = 30; - if ( type == OBJECT_MOBILEit ) icon = 30; - if ( type == OBJECT_MOBILEtg ) icon = 45; - if ( type == OBJECT_MOBILEdr ) icon = 48; - if ( type == OBJECT_APOLLO2 ) icon = 49; - if ( type == OBJECT_MOTHER ) icon = 31; - if ( type == OBJECT_ANT ) icon = 31; - if ( type == OBJECT_SPIDER ) icon = 31; - if ( type == OBJECT_BEE ) icon = 31; - if ( type == OBJECT_WORM ) icon = 31; - if ( type == OBJECT_TEEN28 ) icon = 48; // bottle - if ( type == OBJECT_TEEN34 ) icon = 48; // stone + switch ( type ) + { + case OBJECT_FACTORY: icon = 32; break; + case OBJECT_DERRICK: icon = 33; break; + case OBJECT_CONVERT: icon = 34; break; + case OBJECT_RESEARCH: icon = 35; break; + case OBJECT_STATION: icon = 36; break; + case OBJECT_TOWER: icon = 37; break; + case OBJECT_LABO: icon = 38; break; + case OBJECT_ENERGY: icon = 39; break; + case OBJECT_RADAR: icon = 40; break; + case OBJECT_INFO: icon = 44; break; + case OBJECT_REPAIR: icon = 41; break; + case OBJECT_DESTROYER: icon = 41; break; + case OBJECT_NUCLEAR: icon = 42; break; + case OBJECT_PARA: icon = 46; break; + case OBJECT_SAFE: icon = 47; break; + case OBJECT_HUSTON: icon = 48; break; + case OBJECT_TARGET1: icon = 45; break; + case OBJECT_BASE: icon = 43; break; + case OBJECT_HUMAN: icon = 8; break; + case OBJECT_MOBILEfa: icon = 11; break; + case OBJECT_MOBILEta: icon = 10; break; + case OBJECT_MOBILEwa: icon = 9; break; + case OBJECT_MOBILEia: icon = 22; break; + case OBJECT_MOBILEfb: icon = 2; break; // button4 + case OBJECT_MOBILEtb: icon = 1; break; + case OBJECT_MOBILEwb: icon = 0; break; + case OBJECT_MOBILEib: icon = 3; break; + case OBJECT_MOBILEfc: icon = 17; break; + case OBJECT_MOBILEtc: icon = 16; break; + case OBJECT_MOBILEwc: icon = 15; break; + case OBJECT_MOBILEic: icon = 23; break; + case OBJECT_MOBILEfi: icon = 27; break; + case OBJECT_MOBILEti: icon = 26; break; + case OBJECT_MOBILEwi: icon = 25; break; + case OBJECT_MOBILEii: icon = 28; break; + case OBJECT_MOBILEfs: icon = 14; break; + case OBJECT_MOBILEts: icon = 13; break; + case OBJECT_MOBILEws: icon = 12; break; + case OBJECT_MOBILEis: icon = 24; break; + case OBJECT_MOBILErt: icon = 18; break; + case OBJECT_MOBILErc: icon = 19; break; + case OBJECT_MOBILErr: icon = 20; break; + case OBJECT_MOBILErs: icon = 29; break; + case OBJECT_MOBILEsa: icon = 21; break; + case OBJECT_MOBILEft: icon = 6; break; + case OBJECT_MOBILEtt: icon = 5; break; + case OBJECT_MOBILEwt: icon = 30; break; + case OBJECT_MOBILEit: icon = 7; break; + case OBJECT_MOBILErp: icon = 9; break; + case OBJECT_MOBILEst: icon = 10; break; + case OBJECT_MOBILEtg: icon = 45; break; + case OBJECT_MOBILEdr: icon = 48; break; + case OBJECT_APOLLO2: icon = 49; break; + case OBJECT_MOTHER: icon = 31; break; + case OBJECT_ANT: icon = 31; break; + case OBJECT_SPIDER: icon = 31; break; + case OBJECT_BEE: icon = 31; break; + case OBJECT_WORM: icon = 31; break; + case OBJECT_TEEN28: icon = 48; break; // bottle + case OBJECT_TEEN34: icon = 48; break; // stone + default: icon = -1; + } if ( icon == -1 ) return; + switch ( type ) + { + case OBJECT_MOBILEfb: + case OBJECT_MOBILEtb: + case OBJECT_MOBILEwb: + case OBJECT_MOBILEib: + case OBJECT_MOBILEft: + case OBJECT_MOBILEtt: + case OBJECT_MOBILEit: + case OBJECT_MOBILErp: + case OBJECT_MOBILEst: + m_engine->SetTexture("textures/interface/button4.png"); break; + default: ; // button3.png + } + m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); uv1.x = (32.0f/256.0f)*(icon%8); uv1.y = (32.0f/256.0f)*(icon/8); @@ -1231,6 +1255,10 @@ void CMap::UpdateObject(CObject* pObj) type == OBJECT_MOBILEta || type == OBJECT_MOBILEfa || type == OBJECT_MOBILEia || + type == OBJECT_MOBILEwb || + type == OBJECT_MOBILEtb || + type == OBJECT_MOBILEfb || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEwc || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEfc || @@ -1253,6 +1281,8 @@ void CMap::UpdateObject(CObject* pObj) type == OBJECT_MOBILEtt || type == OBJECT_MOBILEft || type == OBJECT_MOBILEit || + type == OBJECT_MOBILErp || + type == OBJECT_MOBILEst || type == OBJECT_MOBILEdr || type == OBJECT_APOLLO2 ) // moving vehicle? { diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp index 9017ccd3..ad25425e 100644 --- a/src/ui/mainshort.cpp +++ b/src/ui/mainshort.cpp @@ -182,57 +182,86 @@ int CMainShort::GetShortcutIcon(ObjectType type) int icon = -1; if ( m_bBuilding ) { - if ( type == OBJECT_FACTORY ) icon = 32; - if ( type == OBJECT_DERRICK ) icon = 33; - if ( type == OBJECT_CONVERT ) icon = 34; - if ( type == OBJECT_RESEARCH ) icon = 35; - if ( type == OBJECT_STATION ) icon = 36; - if ( type == OBJECT_TOWER ) icon = 37; - if ( type == OBJECT_LABO ) icon = 38; - if ( type == OBJECT_ENERGY ) icon = 39; - if ( type == OBJECT_RADAR ) icon = 40; - if ( type == OBJECT_INFO ) icon = 44; - if ( type == OBJECT_REPAIR ) icon = 41; - if ( type == OBJECT_DESTROYER) icon = 41; - if ( type == OBJECT_NUCLEAR ) icon = 42; - if ( type == OBJECT_PARA ) icon = 46; - if ( type == OBJECT_SAFE ) icon = 47; - if ( type == OBJECT_HUSTON ) icon = 48; - if ( type == OBJECT_BASE ) icon = 43; + switch ( type ) + { + case OBJECT_FACTORY: icon = 32; break; + case OBJECT_DERRICK: icon = 33; break; + case OBJECT_CONVERT: icon = 34; break; + case OBJECT_RESEARCH: icon = 35; break; + case OBJECT_STATION: icon = 36; break; + case OBJECT_TOWER: icon = 37; break; + case OBJECT_LABO: icon = 38; break; + case OBJECT_ENERGY: icon = 39; break; + case OBJECT_RADAR: icon = 40; break; + case OBJECT_INFO: icon = 44; break; + case OBJECT_REPAIR: icon = 41; break; + case OBJECT_DESTROYER: icon = 41; break; + case OBJECT_NUCLEAR: icon = 42; break; + case OBJECT_PARA: icon = 46; break; + case OBJECT_SAFE: icon = 47; break; + case OBJECT_HUSTON: icon = 48; break; + case OBJECT_BASE: icon = 43; break; + default: return -1; + } } else { - if ( type == OBJECT_HUMAN ) icon = 8; - if ( type == OBJECT_MOBILEfa ) icon = 11; - if ( type == OBJECT_MOBILEta ) icon = 10; - if ( type == OBJECT_MOBILEwa ) icon = 9; - if ( type == OBJECT_MOBILEia ) icon = 22; - if ( type == OBJECT_MOBILEfc ) icon = 17; - if ( type == OBJECT_MOBILEtc ) icon = 16; - if ( type == OBJECT_MOBILEwc ) icon = 15; - if ( type == OBJECT_MOBILEic ) icon = 23; - if ( type == OBJECT_MOBILEfi ) icon = 27; - if ( type == OBJECT_MOBILEti ) icon = 26; - if ( type == OBJECT_MOBILEwi ) icon = 25; - if ( type == OBJECT_MOBILEii ) icon = 28; - if ( type == OBJECT_MOBILEfs ) icon = 14; - if ( type == OBJECT_MOBILEts ) icon = 13; - if ( type == OBJECT_MOBILEws ) icon = 12; - if ( type == OBJECT_MOBILEis ) icon = 24; - if ( type == OBJECT_MOBILErt ) icon = 18; - if ( type == OBJECT_MOBILErc ) icon = 19; - if ( type == OBJECT_MOBILErr ) icon = 20; - if ( type == OBJECT_MOBILErs ) icon = 29; - if ( type == OBJECT_MOBILEsa ) icon = 21; - if ( type == OBJECT_MOBILEft ) icon = 30; - if ( type == OBJECT_MOBILEtt ) icon = 30; - if ( type == OBJECT_MOBILEwt ) icon = 30; - if ( type == OBJECT_MOBILEit ) icon = 30; - if ( type == OBJECT_MOBILEdr ) icon = 48; - if ( type == OBJECT_APOLLO2 ) icon = 49; + switch ( type ) + { + case OBJECT_HUMAN: icon = 8; break; + case OBJECT_MOBILEfa: icon = 11; break; + case OBJECT_MOBILEta: icon = 10; break; + case OBJECT_MOBILEwa: icon = 9; break; + case OBJECT_MOBILEia: icon = 22; break; + case OBJECT_MOBILEfb: icon = 2; break; // button4 + case OBJECT_MOBILEtb: icon = 1; break; + case OBJECT_MOBILEwb: icon = 0; break; + case OBJECT_MOBILEib: icon = 3; break; + case OBJECT_MOBILEfc: icon = 17; break; + case OBJECT_MOBILEtc: icon = 16; break; + case OBJECT_MOBILEwc: icon = 15; break; + case OBJECT_MOBILEic: icon = 23; break; + case OBJECT_MOBILEfi: icon = 27; break; + case OBJECT_MOBILEti: icon = 26; break; + case OBJECT_MOBILEwi: icon = 25; break; + case OBJECT_MOBILEii: icon = 28; break; + case OBJECT_MOBILEfs: icon = 14; break; + case OBJECT_MOBILEts: icon = 13; break; + case OBJECT_MOBILEws: icon = 12; break; + case OBJECT_MOBILEis: icon = 24; break; + case OBJECT_MOBILErt: icon = 18; break; + case OBJECT_MOBILErc: icon = 19; break; + case OBJECT_MOBILErr: icon = 20; break; + case OBJECT_MOBILErs: icon = 29; break; + case OBJECT_MOBILEsa: icon = 21; break; + case OBJECT_MOBILEft: icon = 6; break; + case OBJECT_MOBILEtt: icon = 5; break; + case OBJECT_MOBILEwt: icon = 30; break; + case OBJECT_MOBILEit: icon = 7; break; + case OBJECT_MOBILErp: icon = 9; break; + case OBJECT_MOBILEst: icon = 10; break; + case OBJECT_MOBILEtg: icon = 45; break; + case OBJECT_MOBILEdr: icon = 48; break; + case OBJECT_APOLLO2: icon = 49; break; + default: return -1; + } + } + + switch ( type ) + { + case OBJECT_MOBILEfb: + case OBJECT_MOBILEtb: + case OBJECT_MOBILEwb: + case OBJECT_MOBILEib: + case OBJECT_MOBILEft: + case OBJECT_MOBILEtt: + case OBJECT_MOBILEit: + case OBJECT_MOBILErp: + case OBJECT_MOBILEst: + return 192+icon; + default: + return 128+icon; } - if ( icon == -1 ) return -1; - return 128+icon; } // Updates the interface shortcuts to the units. diff --git a/src/ui/object_interface.cpp b/src/ui/object_interface.cpp index ab1fb088..584b57a1 100644 --- a/src/ui/object_interface.cpp +++ b/src/ui/object_interface.cpp @@ -100,6 +100,8 @@ CObjectInterface::CObjectInterface(COldObject* object) m_manipStyle = EVENT_OBJECT_MFRONT; m_selScript = 0; + + m_buildInterface = false; } // Object's destructor. @@ -621,6 +623,12 @@ bool CObjectInterface::EventProcess(const Event &event) err = m_taskExecutor->StartTaskSpiderExplo(); } + if ( action == EVENT_OBJECT_BUILD ) + { + m_buildInterface = !m_buildInterface; + UpdateInterface(); + } + if ( action == EVENT_OBJECT_PEN0 ) // up { err = m_taskExecutor->StartTaskPen(false); @@ -841,6 +849,10 @@ bool CObjectInterface::CreateInterface(bool bSelect) type == OBJECT_MOBILEta || type == OBJECT_MOBILEwa || type == OBJECT_MOBILEia || + type == OBJECT_MOBILEfb || + type == OBJECT_MOBILEtb || + type == OBJECT_MOBILEwb || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEfc || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEwc || @@ -863,6 +875,8 @@ bool CObjectInterface::CreateInterface(bool bSelect) type == OBJECT_MOBILEtt || type == OBJECT_MOBILEwt || type == OBJECT_MOBILEit || + type == OBJECT_MOBILErp || + type == OBJECT_MOBILEst || type == OBJECT_MOBILEdr || type == OBJECT_MOTHER || type == OBJECT_ANT || @@ -1405,6 +1419,87 @@ bool CObjectInterface::CreateInterface(bool bSelect) pw->CreateGroup(pos, ddim, 16, EVENT_OBJECT_CORNERdr); } + if ( (type == OBJECT_MOBILEfb || + type == OBJECT_MOBILEtb || + type == OBJECT_MOBILEwb || + type == OBJECT_MOBILEib) && // builder? + !m_object->GetTrainer() ) + { + pos.x = ox+sx*7.7f; + pos.y = oy+sy*0.5f; + pb = pw->CreateButton(pos, dim, 192+4, EVENT_OBJECT_BUILD); + pb->SetImmediat(true); + DefaultEnter(pw, EVENT_OBJECT_BUILD); + + pos.x = 0.0f; + pos.y = oy+sy*2.6f; + ddim.x = 214.5f/640.0f; + ddim.y = 66.0f/480.0f; + pw->CreateGroup(pos, ddim, 6, EVENT_WINDOW3); + + ddim.x = dim.x*0.9f; + ddim.y = dim.y*0.9f; + pos.y = oy+sy*3.6f; + + pos.x = ox+sx*0.0f; + pw->CreateButton(pos, ddim, 128+35, EVENT_OBJECT_BRESEARCH); + DeadInterface(pw, EVENT_OBJECT_BRESEARCH, m_main->CanBuild(OBJECT_RESEARCH, m_object->GetTeam())); + + pos.x = ox+sx*0.9f; + pw->CreateButton(pos, ddim, 128+32, EVENT_OBJECT_BFACTORY); + DeadInterface(pw, EVENT_OBJECT_BFACTORY, m_main->CanBuild(OBJECT_FACTORY, m_object->GetTeam())); + + pos.x = ox+sx*1.8f; + pw->CreateButton(pos, ddim, 128+34, EVENT_OBJECT_BCONVERT); + DeadInterface(pw, EVENT_OBJECT_BCONVERT, m_main->CanBuild(OBJECT_CONVERT, m_object->GetTeam())); + + pos.x = ox+sx*2.7f; + pw->CreateButton(pos, ddim, 128+36, EVENT_OBJECT_BSTATION); + DeadInterface(pw, EVENT_OBJECT_BSTATION, m_main->CanBuild(OBJECT_STATION, m_object->GetTeam())); + + pos.x = ox+sx*3.6f; + pw->CreateButton(pos, ddim, 128+40, EVENT_OBJECT_BRADAR); + DeadInterface(pw, EVENT_OBJECT_BRADAR, m_main->CanBuild(OBJECT_RADAR, m_object->GetTeam())); + + pos.x = ox+sx*4.5f; + pw->CreateButton(pos, ddim, 128+41, EVENT_OBJECT_BREPAIR); + DeadInterface(pw, EVENT_OBJECT_BREPAIR, m_main->CanBuild(OBJECT_REPAIR, m_object->GetTeam())); + + pos.x = ox+sx*5.4f; + pw->CreateButton(pos, ddim, 128+44, EVENT_OBJECT_BINFO); + DeadInterface(pw, EVENT_OBJECT_BINFO, m_main->CanBuild(OBJECT_INFO, m_object->GetTeam())); + + pos.y = oy+sy*2.7f; + + pos.x = ox+sx*0.0f; + pw->CreateButton(pos, ddim, 128+37, EVENT_OBJECT_BTOWER); + DeadInterface(pw, EVENT_OBJECT_BTOWER, m_main->CanBuild(OBJECT_TOWER, m_object->GetTeam())); + + pos.x = ox+sx*0.9f; + pw->CreateButton(pos, ddim, 128+39, EVENT_OBJECT_BENERGY); + DeadInterface(pw, EVENT_OBJECT_BENERGY, m_main->CanBuild(OBJECT_ENERGY, m_object->GetTeam())); + + pos.x = ox+sx*1.8f; + pw->CreateButton(pos, ddim, 128+33, EVENT_OBJECT_BDERRICK); + DeadInterface(pw, EVENT_OBJECT_BDERRICK, m_main->CanBuild(OBJECT_DERRICK, m_object->GetTeam())); + + pos.x = ox+sx*2.7f; + pw->CreateButton(pos, ddim, 128+42, EVENT_OBJECT_BNUCLEAR); + DeadInterface(pw, EVENT_OBJECT_BNUCLEAR, m_main->CanBuild(OBJECT_NUCLEAR, m_object->GetTeam())); + + pos.x = ox+sx*3.6f; + pw->CreateButton(pos, ddim, 128+38, EVENT_OBJECT_BLABO); + DeadInterface(pw, EVENT_OBJECT_BLABO, m_main->CanBuild(OBJECT_LABO, m_object->GetTeam())); + + pos.x = ox+sx*4.5f; + pw->CreateButton(pos, ddim, 128+46, EVENT_OBJECT_BPARA); + DeadInterface(pw, EVENT_OBJECT_BPARA, m_main->CanBuild(OBJECT_PARA, m_object->GetTeam())); + + pos.x = ox+sx*5.4f; + pw->CreateButton(pos, ddim, 128+41, EVENT_OBJECT_BDESTROYER); + DeadInterface(pw, EVENT_OBJECT_BDESTROYER, m_main->CanBuild(OBJECT_DESTROYER, m_object->GetTeam())); + + } UpdateInterface(); m_lastUpdateTime = 0.0f; UpdateInterface(0.0f); @@ -1664,6 +1759,7 @@ void CObjectInterface::UpdateInterface() EnableInterface(pw, EVENT_OBJECT_TERRAFORM, bEnable); EnableInterface(pw, EVENT_OBJECT_RECOVER, bEnable); EnableInterface(pw, EVENT_OBJECT_FIRE, bEnable); + EnableInterface(pw, EVENT_OBJECT_BUILD, bEnable); EnableInterface(pw, EVENT_OBJECT_SPIDEREXPLO, bEnable); EnableInterface(pw, EVENT_OBJECT_RESET, bEnable); EnableInterface(pw, EVENT_OBJECT_PEN0, bEnable); @@ -1678,7 +1774,11 @@ void CObjectInterface::UpdateInterface() EnableInterface(pw, EVENT_OBJECT_REC, bEnable); EnableInterface(pw, EVENT_OBJECT_STOP, bEnable); - if ( type == OBJECT_HUMAN ) // builder? + if ( type == OBJECT_HUMAN || // builder? + type == OBJECT_MOBILEfb || + type == OBJECT_MOBILEtb || + type == OBJECT_MOBILEwb || + type == OBJECT_MOBILEib ) { EnableInterface(pw, EVENT_OBJECT_BFACTORY, bEnable); EnableInterface(pw, EVENT_OBJECT_BDERRICK, bEnable); @@ -1730,6 +1830,48 @@ void CObjectInterface::UpdateInterface() } } + if ( (type == OBJECT_MOBILEfb || + type == OBJECT_MOBILEtb || + type == OBJECT_MOBILEwb || + type == OBJECT_MOBILEib) && // builder? + !m_object->GetTrainer() ) + { + if(!bEnable) m_buildInterface = false; + CheckInterface(pw, EVENT_OBJECT_BUILD, m_buildInterface); + + pb = static_cast< CButton* >(pw->SearchControl(EVENT_WINDOW3)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BFACTORY)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BDERRICK)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BCONVERT)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BSTATION)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BREPAIR)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BTOWER)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BRESEARCH)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BRADAR)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BENERGY)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BLABO)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BNUCLEAR)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BPARA)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BDESTROYER)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + pb = static_cast< CButton* >(pw->SearchControl(EVENT_OBJECT_BINFO)); + pb->SetState(STATE_VISIBLE, m_buildInterface); + } + bFly = bEnable; if ( bFly && (type == OBJECT_HUMAN || type == OBJECT_TECH) ) { @@ -1755,6 +1897,10 @@ void CObjectInterface::UpdateInterface() type == OBJECT_MOBILEta || type == OBJECT_MOBILEwa || type == OBJECT_MOBILEia || + type == OBJECT_MOBILEfb || + type == OBJECT_MOBILEtb || + type == OBJECT_MOBILEwb || + type == OBJECT_MOBILEib || type == OBJECT_MOBILEfc || type == OBJECT_MOBILEtc || type == OBJECT_MOBILEwc || @@ -1777,6 +1923,8 @@ void CObjectInterface::UpdateInterface() type == OBJECT_MOBILEtt || type == OBJECT_MOBILEwt || type == OBJECT_MOBILEit || + type == OBJECT_MOBILErp || + type == OBJECT_MOBILEst || type == OBJECT_MOBILEdr || type == OBJECT_MOTHER || type == OBJECT_ANT || diff --git a/src/ui/object_interface.h b/src/ui/object_interface.h index adf44c0d..184c95ce 100644 --- a/src/ui/object_interface.h +++ b/src/ui/object_interface.h @@ -120,6 +120,8 @@ protected: float m_lastAlarmTime; int m_soundChannelAlarm; int m_flagColor; + + bool m_buildInterface; }; } // namespace Ui