void TestBedSetupMods() { g_modSystem->DeActivateAllMods(); if( AppRandom() % 10 > 3 && g_modSystem->m_mods.Size() > 0 ) { // Pick a random Mod to run with int modIndex = AppRandom() % g_modSystem->m_mods.Size(); InstalledMod *mod = g_modSystem->m_mods[modIndex]; g_modSystem->ActivateMod( mod->m_name, mod->m_version ); } g_modSystem->Commit(); g_app->RestartAmbienceMusic(); }
void Authentication_GenerateKey( char *_key, bool _demoKey ) { int counter = 0; int total = 0; for( int i = 0; i < AUTHENTICATION_KEYLEN; ++i ) { if( i == AUTHENTICATION_KEYLEN-1 ) { // Terminator _key[i] = '\x0'; } else if( i == AUTHENTICATION_KEYLEN-2 ) { // The last byte is a checking byte _key[i] = 'A' + (total % 26); } else if( counter == 6 ) { // Every 6th letter is a dash for easy reading _key[i] = '-'; counter = 0; } else if( _demoKey && i < 4 ) { // This is a DEMO key, so put DEMO at the start static char demoMarker[5] = "DEMO"; _key[i] = demoMarker[i]; ++counter; } else { // Every other letter is random _key[i] = 'A' + (AppRandom() % 26); ++counter; } total += _key[i]; } }
// _gradient=1 means flat, _gradient=0 means vertical // x and z are only passed in as a means to get predicatable noise void LandscapeRenderer::GetLandscapeColour( float _height, float _gradient, unsigned int _x, unsigned int _y, RGBAColour *_colour ) { float heightAboveSea = _height; float u = iv_pow(1.0 - _gradient, 0.4); float v = 1.0 - heightAboveSea / m_highest; AppSeedRandom(_x | _y + AppRandom()); if (heightAboveSea < 0.0) heightAboveSea = 0.0; v += sfrand(0.45 / (heightAboveSea + 2.0)); int x = u * m_landscapeColour->m_width; int y = v * m_landscapeColour->m_height; if( x < 0 ) x = 0; if( x > m_landscapeColour->m_width - 1) x = m_landscapeColour->m_width - 1; if( y < 0 ) y = 0; if( y > m_landscapeColour->m_height - 1) y = m_landscapeColour->m_height - 1; *_colour = m_landscapeColour->GetPixel(x, y); if( g_app->m_negativeRenderer ) _colour->a = 0; }
void SoulDestroyer::Attack( Vector3 const &_pos ) { int numFound; g_app->m_location->m_entityGrid->GetEnemies( s_neighbours, _pos.x, _pos.z, SOULDESTROYER_DAMAGERANGE, &numFound, m_id.GetTeamId() ); for( int i = 0; i < numFound; ++i ) { WorldObjectId id = s_neighbours[i]; Entity *entity = (Entity *) g_app->m_location->GetEntity( id ); bool killed = false; Vector3 pushVector = ( entity->m_pos - _pos ); double distance = pushVector.Mag(); if( distance < SOULDESTROYER_DAMAGERANGE ) { g_app->m_soundSystem->TriggerEntityEvent( this, "Attack" ); pushVector.SetLength( SOULDESTROYER_DAMAGERANGE - distance ); g_app->m_location->m_entityGrid->RemoveObject( id, entity->m_pos.x, entity->m_pos.z, entity->m_radius ); entity->m_pos += pushVector; g_app->m_location->m_entityGrid->AddObject( id, entity->m_pos.x, entity->m_pos.z, entity->m_radius ); bool dead = entity->m_dead; entity->ChangeHealth( (SOULDESTROYER_DAMAGERANGE - distance) * -50.0 ); if( !dead && entity->m_dead ) killed = true; } if( killed ) { // Eat the spirit int spiritIndex = g_app->m_location->GetSpirit( id ); if( spiritIndex != -1 ) { g_app->m_location->m_spirits.RemoveData( spiritIndex ); if( m_spirits.NumUsed() < SOULDESTROYER_MAXSPIRITS ) { m_spirits.PutData( (double) GetHighResTime() ); } else { // Doesnt need to be sync safe int index = AppRandom() % SOULDESTROYER_MAXSPIRITS; m_spirits.PutData( (double) GetHighResTime(), index ); } } if(entity->m_type == TypeDarwinian ) { // Create a zombie Zombie *zombie = new Zombie(); zombie->m_pos = entity->m_pos; zombie->m_front = entity->m_front; zombie->m_up = g_upVector; zombie->m_up.RotateAround( zombie->m_front * syncsfrand(1) ); zombie->m_vel = m_vel * 0.5; zombie->m_vel.y = 20.0 + syncfrand(25.0); int index = g_app->m_location->m_effects.PutData( zombie ); zombie->m_id.Set( id.GetTeamId(), UNIT_EFFECTS, index, -1 ); zombie->m_id.GenerateUniqueId(); } } } }
void EclRegisterWindow ( EclWindow *window, EclWindow *parent ) { // DebugAssert( window ); if ( EclGetWindow ( window->m_name ) ) { } if( parent && window->m_x == 0 && window->m_y == 0 ) { // We should place the window in a decent location int left = screenW / 2 - parent->m_x; int above = screenH / 2 - parent->m_y; if( left > window->m_w / 2 ) window->m_x = int( parent->m_x + parent->m_w * (float) AppRandom() / (float) APP_RAND_MAX ); else window->m_x = int( parent->m_x - window->m_w * (float) AppRandom() / (float) APP_RAND_MAX ); if( above > window->m_h / 2 ) window->m_y = int( parent->m_y + parent->m_h * (float) AppRandom() / (float) APP_RAND_MAX ); else window->m_y = int( parent->m_y - window->m_h/2 * (float) AppRandom() / (float) APP_RAND_MAX ); } window->MakeAllOnScreen(); windows.PutDataAtStart ( window ); window->Create(); EclDirtyWindow( window ); }