예제 #1
0
void CasualtiesWindow::Render( bool hasFocus )
{
    InterfaceWindow::Render( hasFocus );
    
    g_renderer->SetClip( m_x, m_y+20, m_w, m_h-20 );

    int x = m_x + 10;
    int y = m_y + 30;
    int titleSize = 18;
    int textSize = 13;

    y-= m_scrollbar->m_currentValue;
    
    g_renderer->TextSimple( x, y, White, titleSize, LANGUAGEPHRASE("dialog_casualties_city") );
    g_renderer->TextSimple( x+200, y, White, titleSize, LANGUAGEPHRASE("dialog_casualties_strikes") );
    g_renderer->TextSimple( x+300, y, White, titleSize, LANGUAGEPHRASE("dialog_casualties_deaths") );

    y+=20;

    int numEntries = 0;

    for( int i = 0; i < g_app->GetWorld()->m_cities.Size(); ++i )
    {
        if( g_app->GetWorld()->m_cities.ValidIndex(i) )
        {
            City *city = g_app->GetWorld()->m_cities[i];
            if( city->m_dead > 0 )
            {
                char strikes[64];
                char deaths[64];

                sprintf( strikes, "%d", city->m_numStrikes );
				sprintf( deaths, LANGUAGEPHRASE("dialog_casualties_in_million") );
				char number[32];
				sprintf( number, "%.1f", city->m_dead / 1000000.0f );
				LPREPLACESTRINGFLAG( 'C', number, deaths );

                g_renderer->TextSimple( x, y+=18, White, textSize, LANGUAGEPHRASEADDITIONAL(city->m_name) );
                g_renderer->TextSimple( x+200, y, White, textSize, strikes );
                g_renderer->TextSimple( x+300, y, White, textSize, deaths );

                ++numEntries;
            }
        }
    }

    g_renderer->ResetClip();

    m_scrollbar->SetNumRows( (numEntries+1) * 18 );
}
예제 #2
0
파일: city.cpp 프로젝트: BITINT/DEFCON2
bool City::NuclearStrike( int causedBy, Fixed intensity, Fixed range, bool directHitPossible )
{
    if( range <= intensity/50 )
    {
        Fixed intensityEffect = (intensity/100) / 2;
        Fixed rangeEffect = 1 - range / (intensity/50);
        int deaths = ( m_population * intensityEffect * rangeEffect ).IntValue();
        m_dead += deaths;
        m_population -= deaths;
        m_numStrikes ++;

        Team *owner = g_app->GetWorld()->GetTeam(m_teamId);
        Team *guilty = g_app->GetWorld()->GetTeam(causedBy);

		bool trackedStat = false;

        if( causedBy == g_app->GetWorld()->m_myTeamId ||
			m_teamId == g_app->GetWorld()->m_myTeamId )
		{
			// We shot this nuke, or it was shot at us, so record the deaths
            trackedStat = true;
		}
        
        if( owner ) owner->m_friendlyDeaths += deaths;        
        if( !owner && guilty ) guilty->m_collatoralDamage += deaths;
        
        if( guilty )
        {
            if( g_app->GetWorld()->IsFriend(m_teamId,causedBy) )
            {
                guilty->m_collatoralDamage += deaths;
            }
            else
            {
                guilty->m_enemyKills += deaths;
            }
        }

        bool directHit = false;
        char caption[256];
        if( rangeEffect >= Fixed::Hundredths(75) && directHitPossible )
        {
            if( deaths > 1000000 )
            {
                bool messageFound = false;
                for( int i = 0; i < g_app->GetWorld()->m_messages.Size(); ++i )
                {
                    WorldMessage *wm = g_app->GetWorld()->m_messages[i];
                    if( wm->m_messageType == WorldMessage::TypeDirectHit &&
                        wm->m_longitude == m_longitude &&
                        wm->m_latitude == m_latitude )
                    {
                        char dead[16];
                        sprintf( dead, "%.1f", (deaths + wm->m_deaths) / 1000000.0f );
                        sprintf( caption, "%s", LANGUAGEPHRASE("message_directhit") );
                        LPREPLACESTRINGFLAG( 'D', dead, caption );
                        LPREPLACESTRINGFLAG( 'C', LANGUAGEPHRASEADDITIONAL(m_name), caption );
                        wm->SetMessage( caption );

                        wm->m_deaths += deaths;
                        wm->m_renderFull = true;
                        wm->m_timer += 5;
                        if( wm->m_timer > 15 )
                        {
                            wm->m_timer = 15;
                        }
                        messageFound = true;
                        break;
                    }
                }
                if( !messageFound )
                {
                    char dead[16];
                    sprintf( dead, "%.1f", deaths / 1000000.0f );
                    sprintf( caption, "%s", LANGUAGEPHRASE("message_directhit") );
                    LPREPLACESTRINGFLAG( 'D', dead, caption );
                    LPREPLACESTRINGFLAG( 'C', LANGUAGEPHRASEADDITIONAL(m_name), caption );

                    g_app->GetWorld()->AddWorldMessage( m_longitude, m_latitude, m_teamId, caption, WorldMessage::TypeDirectHit );
                    g_app->GetWorld()->m_messages[ g_app->GetWorld()->m_messages.Size() -1 ]->m_deaths = deaths;
                }
            }
            directHit = true;
        }
        
        if( !directHit && deaths > 1000000 )
        {
            char dead[16];
            sprintf( dead, "%.1f", deaths / 1000000.0f );
            sprintf( caption, "%s", LANGUAGEPHRASE("message_fallout") );
            LPREPLACESTRINGFLAG( 'D', dead, caption );
            LPREPLACESTRINGFLAG( 'C', LANGUAGEPHRASEADDITIONAL(m_name), caption );
            g_app->GetInterface()->ShowMessage( m_longitude, m_latitude, m_teamId, caption );
        }

        return directHit;
    }

    return false;
}