//later this could be more complicated void Game::AdvanceTime(ieDword add) { ieDword h = GameTime/(300*AI_UPDATE_TIME); GameTime+=add; if (h!=GameTime/(300*AI_UPDATE_TIME)) { //asking for a new weather when the hour changes WeatherBits&=~WB_HASWEATHER; //update clock display core->GetGUIScriptEngine()->RunFunction("GUICommonWindows", "UpdateClock"); } Ticks+=add*interval; //change the tileset if needed Map *map = GetCurrentArea(); if (map && map->ChangeMap(IsDay())) { //play the daylight transition movie appropriate for the area //it is needed to play only when the area truly changed its tileset //this is signalled by ChangeMap int areatype = (area->AreaType&(AT_FOREST|AT_CITY|AT_DUNGEON))>>3; ieResRef *res; if (IsDay()) { res=&nightmovies[areatype]; } else { res=&daymovies[areatype]; } if (*res[0]!='*') { core->PlayMovie(*res); } }
//later this could be more complicated void Game::AdvanceTime(ieDword add) { ieDword h = GameTime/(300*AI_UPDATE_TIME); GameTime+=add; if (h!=GameTime/(300*AI_UPDATE_TIME)) { //asking for a new weather when the hour changes WeatherBits&=~WB_HASWEATHER; } Ticks+=add*interval; //change the tileset if needed Map *map = GetCurrentArea(); if (map && map->ChangeMap(IsDay())) { //play the daylight transition movie appropriate for the area //it is needed to play only when the area truly changed its tileset //this is signalled by ChangeMap int areatype = (area->AreaType&(AT_FOREST|AT_CITY|AT_DUNGEON))>>3; ieResRef *res; printMessage("Game","Switching DayLight\n",GREEN); if (IsDay()) { res=&nightmovies[areatype]; } else { res=&daymovies[areatype]; } if (*res[0]!='*') { core->PlayMovie(*res); } }
Map *Game::GetMap(const char *areaname, bool change) { int index = LoadMap(areaname, change); if (index >= 0) { if (change) { MapIndex = index; area = GetMap(index); memcpy (CurrentArea, areaname, 8); area->SetupAmbients(); //change the tileset if needed area->ChangeMap(IsDay()); ChangeSong(false, true); Infravision(); //call area customization script for PST //moved here because the current area is set here ScriptEngine *sE = core->GetGUIScriptEngine(); if (core->HasFeature(GF_AREA_OVERRIDE) && sE) { //area ResRef is accessible by GemRB.GetGameString (STR_AREANAME) sE->RunFunction("Maze", "CustomizeArea"); } return area; } return GetMap(index); } return NULL; }
/* Loads an area */ int Game::LoadMap(const char* ResRef, bool loadscreen) { unsigned int i; Map *newMap; PluginHolder<MapMgr> mM(IE_ARE_CLASS_ID); ScriptEngine *sE = core->GetGUIScriptEngine(); //this shouldn't happen if (!mM) { return -1; } int index = FindMap(ResRef); if (index>=0) { return index; } bool hide = false; if (loadscreen && sE) { hide = core->HideGCWindow(); sE->RunFunction("LoadScreen", "StartLoadScreen"); sE->RunFunction("LoadScreen", "SetLoadScreen"); } DataStream* ds = gamedata->GetResource( ResRef, IE_ARE_CLASS_ID ); if (!ds) { goto failedload; } if(!mM->Open(ds)) { goto failedload; } newMap = mM->GetMap(ResRef, IsDay()); if (!newMap) { goto failedload; } core->LoadProgress(100); for (i = 0; i < PCs.size(); i++) { if (stricmp( PCs[i]->Area, ResRef ) == 0) { newMap->AddActor( PCs[i] ); } } for (i = 0; i < NPCs.size(); i++) { if (stricmp( NPCs[i]->Area, ResRef ) == 0) { newMap->AddActor( NPCs[i] ); } } if (hide) { core->UnhideGCWindow(); } return AddMap( newMap ); failedload: if (hide) core->UnhideGCWindow(); core->LoadProgress(100); return -1; }
bool CDayNNightProc::PushEffect( CEffect* pEffect ) { if( pEffect == NULL ) return false; /// 이미 들어가 있는 이펙트 이다. if( std::find( m_EffectList.begin(), m_EffectList.end(), pEffect ) != m_EffectList.end() ) return false; m_EffectList.push_back( pEffect ); if( IsDay() ) pEffect->UnlinkNODE(); return true; }
/* Loads an area */ int Game::LoadMap(const char* ResRef, bool loadscreen) { unsigned int i, ret; Map *newMap; PluginHolder<MapMgr> mM(IE_ARE_CLASS_ID); ScriptEngine *sE = core->GetGUIScriptEngine(); //this shouldn't happen if (!mM) { return -1; } int index = FindMap(ResRef); if (index>=0) { return index; } bool hide = false; if (loadscreen && sE) { hide = core->HideGCWindow(); sE->RunFunction("LoadScreen", "StartLoadScreen"); sE->RunFunction("LoadScreen", "SetLoadScreen"); } DataStream* ds = gamedata->GetResource( ResRef, IE_ARE_CLASS_ID ); if (!ds) { goto failedload; } if(!mM->Open(ds)) { goto failedload; } newMap = mM->GetMap(ResRef, IsDay()); if (!newMap) { goto failedload; } core->LoadProgress(100); ret = AddMap( newMap ); //spawn creatures on a map already in the game //this feature exists in all blackisle games but not in bioware games if (core->HasFeature(GF_SPAWN_INI)) { newMap->LoadIniSpawn(); } for (i = 0; i < PCs.size(); i++) { if (stricmp( PCs[i]->Area, ResRef ) == 0) { newMap->AddActor( PCs[i], false ); } } PlacePersistents(newMap, ResRef); if (hide) { core->UnhideGCWindow(); } newMap->InitActors(); return ret; failedload: if (hide) { core->UnhideGCWindow(); } core->LoadProgress(100); return -1; }
//Начать загрузку монстров в локацию bool LEnc_MonstersLoginStart(ref location) { float monkeys, skeletons; LEnc_MonstersLoginObject.type = "dungeon"; if(CheckAttribute(location, "type")) { if(location.type == "jungle") { LEnc_MonstersLoginObject.type = "jungle"; } } LEnc_MonstersLoginObject.current = ""; if(LEnc_MonstersLoginObject.type == "jungle") { if(IsDay()) { //Днём либо бандиты, либо олухи, либо никто if(rand(100) > 20) { if(rand(100) < 30) { //Выбрали олухов LEnc_MonstersLoginObject.bandit = "0"; LEnc_MonstersLoginObject.skeleton = "0"; LEnc_MonstersLoginObject.monkey = "0"; LEnc_MonstersLoginObject.mummy = "0"; LEnc_MonstersLoginObject.vagabond = "1"; }else{ return false; } }else{ LEnc_MonstersLoginObject.bandit = "1"; LEnc_MonstersLoginObject.skeleton = "0"; LEnc_MonstersLoginObject.monkey = "0"; LEnc_MonstersLoginObject.mummy = "0"; LEnc_MonstersLoginObject.vagabond = "0"; } }else{ //Ночью либо бандиты, либо скелеты, либо олухи, либо никто if(rand(100) < 40) { if(rand(100) < 20) { //Выбрали олухов LEnc_MonstersLoginObject.bandit = "0"; LEnc_MonstersLoginObject.skeleton = "0"; LEnc_MonstersLoginObject.monkey = "0"; LEnc_MonstersLoginObject.mummy = "0"; LEnc_MonstersLoginObject.vagabond = "1"; }else{ return false; } }else{ if(rand(100) < 40) { //Выбрали бандитов LEnc_MonstersLoginObject.bandit = "1"; LEnc_MonstersLoginObject.skeleton = "0"; LEnc_MonstersLoginObject.monkey = "0"; LEnc_MonstersLoginObject.mummy = "0"; LEnc_MonstersLoginObject.vagabond = "0"; }else{ //Выбрали скелетов LEnc_MonstersLoginObject.bandit = "0"; monkeys = 0.4 + (rand(100)*0.01)*0.6; skeletons = 1.0 - monkeys; LEnc_MonstersLoginObject.skeleton = skeletons; LEnc_MonstersLoginObject.monkey = monkeys; LEnc_MonstersLoginObject.mummy = "0"; LEnc_MonstersLoginObject.vagabond = "0"; } } } }else{ if(LEnc_MonstersLoginObject.type == "inca_temple") { LEnc_MonstersLoginObject.bandit = "0"; LEnc_MonstersLoginObject.skeleton = "0.2"; LEnc_MonstersLoginObject.monkey = "0.3"; LEnc_MonstersLoginObject.mummy = "0.5"; LEnc_MonstersLoginObject.vagabond = "0"; }else{ if(rand(100) < 90) { LEnc_MonstersLoginObject.bandit = "0"; LEnc_MonstersLoginObject.skeleton = "1"; LEnc_MonstersLoginObject.monkey = "0"; LEnc_MonstersLoginObject.mummy = "0"; LEnc_MonstersLoginObject.vagabond = "0"; }else{ skeletons = 0.8 + (rand(100)*0.01)*0.2; monkeys = 1.0 - skeletons; LEnc_MonstersLoginObject.bandit = "0"; LEnc_MonstersLoginObject.skeleton = skeletons; LEnc_MonstersLoginObject.monkey = monkeys; LEnc_MonstersLoginObject.mummy = "0"; LEnc_MonstersLoginObject.vagabond = "0"; } } } return true; }
/// \brief /// Modifies the current time of day. /// /// \param fTimeDiff /// Time difference to apply (-1..+1, mapped to -24h..+24h). /// EFFECTS_IMPEXP virtual void IncDayTime(float fTimeDiff) { bool bIsDay = IsDay(); SetDayTime(GetDayTime() + fTimeDiff); m_bDayNightSwitch = (bIsDay != IsDay()); }