From 8658d6da8060cdb741c668d4be1b571ef064d01d Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 13 Feb 2013 16:57:59 +0100 Subject: Added Destroyer from Ceebot-Teen. We need a new icon for it. --- src/common/event.h | 3 +- src/common/global.h | 1 + src/common/restext.cpp | 1 + src/object/auto/autodestroyer.cpp | 90 ++++++++++++++++++++++++++++++++++----- src/object/brain.cpp | 10 +++-- src/object/task/taskbuild.cpp | 3 ++ src/script/cmdtoken.cpp | 1 + 7 files changed, 94 insertions(+), 15 deletions(-) diff --git a/src/common/event.h b/src/common/event.h index 169f0d0..cba167e 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -411,7 +411,8 @@ enum EventType EVENT_OBJECT_BNUCLEAR = 1060, EVENT_OBJECT_BPARA = 1061, EVENT_OBJECT_BINFO = 1062, - EVENT_OBJECT_BXXXX = 1063, + EVENT_OBJECT_BDESTROYER = 1063, + //EVENT_OBJECT_BXXXX = 1063, EVENT_OBJECT_GFLAT = 1070, EVENT_OBJECT_FCREATE = 1071, EVENT_OBJECT_FDELETE = 1072, diff --git a/src/common/global.h b/src/common/global.h index 0b2d8ec..7a5fdfd 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -213,6 +213,7 @@ enum BuildType BUILD_LABO = (1<<10), //! < laboratory BUILD_PARA = (1<<11), //! < lightning protection BUILD_INFO = (1<<12), //! < information terminal + BUILD_DESTROYER = (1<<13), //! < Destroyer BUILD_GFLAT = (1<<16), //! < flat floor BUILD_FLAG = (1<<17) //! < puts / removes colored flag }; diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 4c56ae5..4768aed 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -308,6 +308,7 @@ void InitializeRestext() stringsEvent[EVENT_OBJECT_BNUCLEAR] = "Build a nuclear power plant"; stringsEvent[EVENT_OBJECT_BPARA] = "Build a lightning conductor"; stringsEvent[EVENT_OBJECT_BINFO] = "Build a exchange post"; + stringsEvent[EVENT_OBJECT_BDESTROYER] = "Build a destroyer"; stringsEvent[EVENT_OBJECT_GFLAT] = "Show if the ground is flat"; stringsEvent[EVENT_OBJECT_FCREATE] = "Plant a flag"; stringsEvent[EVENT_OBJECT_FDELETE] = "Remove a flag"; diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp index ecf7c94..644071c 100644 --- a/src/object/auto/autodestroyer.cpp +++ b/src/object/auto/autodestroyer.cpp @@ -111,18 +111,39 @@ bool CAutoDestroyer::EventProcess(const Event &event) if ( SearchVehicle() ) { - m_phase = ADEP_WAIT; // still waiting ... - m_progress = 0.0f; - m_speed = 1.0f/0.5f; + if ( m_progress < 20.0f ) { + m_phase = ADEP_WAIT; // still waiting ... + //m_progress = 0.0f; + m_speed = 1.0f/0.5f; + } else { + if ( m_object->GetLock() ) { // If still building... + m_phase = ADEP_WAIT; // still waiting ... + m_progress = 0.0f; + m_speed = 1.0f/0.5f; + } else { + m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f); + + m_phase = ADEP_DOWN; + m_progress = 0.0f; + m_speed = 1.0f/1.0f; + m_bExplo = false; + } + } } else { - m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f); - - m_phase = ADEP_DOWN; - m_progress = 0.0f; - m_speed = 1.0f/1.0f; - m_bExplo = false; + if ( m_object->GetLock() ) { // If still building... + m_phase = ADEP_WAIT; // still waiting ... + m_progress = 0.0f; + m_speed = 1.0f/0.5f; + } else { + m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f); + + m_phase = ADEP_DOWN; + m_progress = 0.0f; + m_speed = 1.0f/1.0f; + m_bExplo = false; + } } } } @@ -243,8 +264,55 @@ CObject* CAutoDestroyer::SearchPlastic() if ( pObj == nullptr ) break; type = pObj->GetType(); - if ( type != OBJECT_SCRAP4 && - type != OBJECT_SCRAP5 ) continue; + //if ( type != OBJECT_SCRAP4 && + // type != OBJECT_SCRAP5 ) continue; + if ( type != OBJECT_FRET && + type != OBJECT_STONE && + type != OBJECT_URANIUM && + type != OBJECT_METAL && + type != OBJECT_POWER && + type != OBJECT_ATOMIC && + type != OBJECT_TNT && + type != OBJECT_SCRAP1 && + type != OBJECT_SCRAP2 && + type != OBJECT_SCRAP3 && + type != OBJECT_SCRAP4 && + type != OBJECT_SCRAP5 && + // Robots: + type != OBJECT_HUMAN && + type != OBJECT_MOBILEfa && + type != OBJECT_MOBILEta && + type != OBJECT_MOBILEwa && + type != OBJECT_MOBILEia && + type != OBJECT_MOBILEfc && + type != OBJECT_MOBILEtc && + type != OBJECT_MOBILEwc && + type != OBJECT_MOBILEic && + type != OBJECT_MOBILEfi && + type != OBJECT_MOBILEti && + type != OBJECT_MOBILEwi && + type != OBJECT_MOBILEii && + type != OBJECT_MOBILEfs && + type != OBJECT_MOBILEts && + type != OBJECT_MOBILEws && + type != OBJECT_MOBILEis && + type != OBJECT_MOBILErt && + type != OBJECT_MOBILErc && + type != OBJECT_MOBILErr && + type != OBJECT_MOBILErs && + type != OBJECT_MOBILEsa && + type != OBJECT_MOBILEtg && + type != OBJECT_MOBILEft && + type != OBJECT_MOBILEtt && + type != OBJECT_MOBILEwt && + type != OBJECT_MOBILEit && + type != OBJECT_MOBILEdr && + type != OBJECT_MOTHER && + type != OBJECT_ANT && + type != OBJECT_SPIDER && + type != OBJECT_BEE && + type != OBJECT_WORM ) continue; + oPos = pObj->GetPosition(0); dist = Math::Distance(oPos, sPos); diff --git a/src/object/brain.cpp b/src/object/brain.cpp index bc47cb3..1405201 100644 --- a/src/object/brain.cpp +++ b/src/object/brain.cpp @@ -528,6 +528,10 @@ bool CBrain::EventProcess(const Event &event) { err = StartTaskBuild(OBJECT_INFO); } + if ( action == EVENT_OBJECT_BDESTROYER ) + { + err = StartTaskBuild(OBJECT_DESTROYER); + } if ( action == EVENT_OBJECT_GFLAT ) { @@ -1454,8 +1458,8 @@ bool CBrain::CreateInterface(bool bSelect) pos.x = ox+sx*5.4f; pos.y = oy+sy*0.1f; - pw->CreateButton(pos, ddim, 128+56, EVENT_OBJECT_BXXXX); - DeadInterface(pw, EVENT_OBJECT_BXXXX, false); + pw->CreateButton(pos, ddim, 128+41, EVENT_OBJECT_BDESTROYER); + DeadInterface(pw, EVENT_OBJECT_BDESTROYER, g_build&BUILD_DESTROYER); if ( g_build&BUILD_GFLAT ) { @@ -2181,7 +2185,7 @@ void CBrain::UpdateInterface() EnableInterface(pw, EVENT_OBJECT_BNUCLEAR, bEnable); EnableInterface(pw, EVENT_OBJECT_BPARA, bEnable); EnableInterface(pw, EVENT_OBJECT_BINFO, bEnable); - EnableInterface(pw, EVENT_OBJECT_BXXXX, bEnable); + EnableInterface(pw, EVENT_OBJECT_BDESTROYER,bEnable); } pb = static_cast< Ui::CButton* >(pw->SearchControl(EVENT_OBJECT_GFLAT)); diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp index d82874c..5673ea4 100644 --- a/src/object/task/taskbuild.cpp +++ b/src/object/task/taskbuild.cpp @@ -98,6 +98,7 @@ bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle) if ( m_type == OBJECT_NUCLEAR ) m_buildingHeight = 40.0f; if ( m_type == OBJECT_PARA ) m_buildingHeight = 68.0f; if ( m_type == OBJECT_INFO ) m_buildingHeight = 19.0f; + if ( m_type == OBJECT_DESTROYER) m_buildingHeight = 35.0f; m_buildingHeight *= 0.25f; m_buildingPos = m_building->GetPosition(0); @@ -578,6 +579,7 @@ Error CTaskBuild::FlatFloor() if ( m_type == OBJECT_NUCLEAR ) radius = 20.0f; if ( m_type == OBJECT_PARA ) radius = 20.0f; if ( m_type == OBJECT_INFO ) radius = 5.0f; + if ( m_type == OBJECT_DESTROYER) radius = 20.0f; if ( radius == 0.0f ) return ERR_GENERIC; center = m_metal->GetPosition(0); @@ -666,6 +668,7 @@ Error CTaskBuild::FlatFloor() type == OBJECT_ENERGY || type == OBJECT_LABO || type == OBJECT_NUCLEAR || + type == OBJECT_DESTROYER|| type == OBJECT_START || type == OBJECT_END || type == OBJECT_INFO || diff --git a/src/script/cmdtoken.cpp b/src/script/cmdtoken.cpp index e44f82d..ab0528b 100644 --- a/src/script/cmdtoken.cpp +++ b/src/script/cmdtoken.cpp @@ -708,6 +708,7 @@ int GetBuild(char *line, int rank) if ( Cmd(p, "AutoLab" ) ) return BUILD_LABO; if ( Cmd(p, "PowerCaptor" ) ) return BUILD_PARA; if ( Cmd(p, "ExchangePost" ) ) return BUILD_INFO; + if ( Cmd(p, "Destroyer" ) ) return BUILD_DESTROYER; if ( Cmd(p, "FlatGround" ) ) return BUILD_GFLAT; if ( Cmd(p, "Flag" ) ) return BUILD_FLAG; -- cgit v1.2.3-1-g7c22