void Scene_House_Out::Init()
{
   _lpSceneDirector->ChangeMusic(DIRECTOR_MUSIC_NONE, true);
   _lpSceneDirector->ShowIHM(true);

   // Glit sur la portière
   if (TaskResolved("car_box_map") && TaskResolved("car_box_key")) {
      GetObjectImageByName("out_car_zone")->EnableGlitch(false);
   }
   
   if (!TaskResolved("task_out_firstvisit")) {
      ResolveTask("task_out_firstvisit");
      AddObjective("house","getmap");
      AddHint("house","getmap","how");
      _lpSceneDirector->getSequencer()->Callback(NULL, "tutoask");
      _lpSceneDirector->getDiaryPtr()->beginCreatePage();
      _lpSceneDirector->getDiaryPtr()->addImageToPage("diary_out.png");
      _lpSceneDirector->getDiaryPtr()->addStringToPage("DIARY_OUT", FONT_DIARY_1, 0, 0);
      _lpSceneDirector->getDiaryPtr()->endCreatePage();
   }
   
   if (TaskResolved("out_house_zeps")) {
      GetObjectImageByName("out_house_zeps")->EnableGlitch(false);
   }
         
   if (getAdditionalName() == "gotohouse") {
      AddObjective("house","enterhouse");
      AddHint("house","enterhouse","how");
      if (TestGlobal("__tutorial__")) {
         _lpSceneDirector->getSequencer()->Tutobox(NULL, KStr("HOUSE_OUT_TUTO_ENTERHOUSE"), 273, 204, 180, 200);
      }
   }

   _lpSceneDirector->getSequencer()->PreloadVideo("videos/zeppelins.ogv");
}
void Scene_House_Basement_Grid::Init()
{
   // 1ère visite de la grille
   if (!TaskResolved("task_house_basement_visitgrid")) {
      ResolveTask("task_house_basement_visitgrid");
      AddObjective("house","basementgrid");
      AddHint("house","basementgrid","how");
   }
   
   // Grille ouverte ?
   if (TaskResolved("task_house_basement_opengrid")) {
      SetVisible("basement_grid_gridclosed", false, true);
      SetVisible("basement_grid_gridopen", true, true);
      // La vis
      SetVisible("basement_grid_bolt", TestGlobal("basement_grid_bolt") == false, true);
   } else {
      SetVisible("basement_grid_gridclosed", true, true);
      SetVisible("basement_grid_gridopen", false, true);
   }

   // Le charbon
   if (TaskResolved("task_house_basement_reversecoal")) {
      SetVisible("basement_grid_coal", true, true);
      // Le fusain
      SetVisible("basement_grid_charcoal", TestGlobal("basement_grid_charcoal") == false, true);
   }
}
void SkinnedHints::AddHint( Widget *hint_owner, int skin_no, int   font_no,    const Text &t)
{
    Hint hint( skin_no,
        font_no, Rect::HALIGNCENTER|Rect::VALIGNCENTER,
        t);
        
    AddHint( hint_owner, hint);
}
void Scene_Inca_Mainscreen::Init()
{
   StartAnimation("bg2_anim");
   StartAnimation("clouds_anim");

   if (!TaskResolved("inca_ashleytalkintro")) {
      ResolveTask("inca_ashleytalkintro");
      _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_DIALOG, true);
      _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("INCA_DIALOGBOX_INTRO1"), "", false, true);
      _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("INCA_DIALOGBOX_INTRO2"), "", false, true);
      _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("INCA_DIALOGBOX_INTRO3"), "", false, true);
      _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_DIALOG, false);
      AddTask("task_inca_findspear");
      AddObjective("inca","spear");
      AddHint("inca","spear","where");
   }
   
   // Ajout de la statuette à l'inventaire si elle n'y est pas déjà
   if (_lpSceneDirector->getInventory()->getItemFromInventory("inv_inca_statuette") == NULL) {
      _lpSceneDirector->getInventory()->AddItem("inca","inv_inca_statuette");
   }
   
   // Morceaux de lance
   SetupItem("inca_spear[1]");
   SetupItem("inca_spear[2]");
   SetupItem("inca_spear[3]");
   SetupItem("inca_spear[4]");   
   SetupItem("inca_spear[5]");
   if (TaskResolved("task_inca_opencube")) {
      SetupItem("inca_spear[6]");
   }
   
   // Bloc de pierre
   if (TaskResolved("task_inca_opencube")) {
      SetVisible("inca_main_cubesclosed", false, true);
      SetVisible("inca_main_cubesopen", true, true);
   }
   else {
      SetVisible("inca_main_cubesclosed", true, true);
      SetVisible("inca_main_cubesopen", false, true);
   }
   
   // Le garde
   // Il n'a pas encore sa lance
   if (!TaskResolved("task_inca_givespear")) {
      SetVisible("inca_main_guard_nospear", true);
   }
   // Il a eu sa lance
   else {
      SetVisible("inca_main_guard_spear", true);
   }
   
   // La porte est ouverte
   if (TaskResolved("task_inca_opendoor")) {
      SetVisible("inca_main_door", false, false);
   }
}
void Scene_House_IncaBook::Init()
{
   if (!TaskResolved("task_house_incabook_discover")) {
      ResolveTask("task_house_incabook_discover");
      AddObjective("house","living_buildbase");
      AddHint("house","living_buildbase","fire");
   }
   
	PageSet(_nCurrentPage);
}
void Scene_Inca_Mainscreen::Draw()
{
   double fElapsed = MyGame::getGame()->getKWindow()->getFrameTime();
   if (_bAnimDoor) {
      _lpAnimDoor->move(fElapsed);
      // Déplace la porte
      RestorePosition("inca_main_door");
      MovePosition("inca_main_door", GetRandom(-1.0, 1.0), _lpAnimDoor->getCurrentValue());
      if (_lpAnimDoor->isCompleted()) {
         _bAnimDoor = false;
         ResolveTask("task_inca_opendoor");
         AddObjective("inca","4artefacts");
         AddHint("inca","4artefacts","where");
         AddHint("inca","4artefacts","light");
         _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_CINEMATIC, false);
      }
   }
   
   EScene::Draw();
}
void Scene_Inca_Passage::Init()
{
   if (!_bEffect) {
      if (!TaskResolved("__say_deathpassage__")) {
         ResolveTask("__say_deathpassage__");
         _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("INCA_YUMANCO_DEATHPASSAGE"), "", true, false);
         AddHint("inca","4artefacts","cross");
      }
   }
   SetupItem("inca_cartouche1_ground");
   SetupItem("inca_cartouche2_ground");
   
   // Blocs au plafond ou au sol ?
   if (!_bEffect) {
      if (TaskResolved("task_inca_fillhole")) {
         SetVisible("inca_passage_blocks_ground", true, true);
         SetVisible("inca_final_zone", true, true);
      }
      else {
         AddTask("task_inca_fillhole");
         SetVisible("inca_passage_blocks_ceiling", true, true);
      }
   }
   
   // Artefacts
   if (!TaskResolved("task_inca_repairfresco3")) {
      AddTask("task_inca_repairfresco3");
   }
   if (!TaskResolved("task_inca_repairfresco4")) {
      AddTask("task_inca_repairfresco4");
   }
   
   // artefact découverts
   if (TaskResolved("task_inca_repairfresco3")) {
      SetupItem("inca_artefact3");
      SetVisible("inca_stairsfresco3_zone", false);
      SetVisible("inca_cartouche1_wall", true, true);
   }
   if (TaskResolved("task_inca_repairfresco4")) {
      SetupItem("inca_artefact4");
      SetVisible("inca_stairsfresco4_zone", false);
      SetVisible("inca_cartouche2_wall", true, true);
   }
}
void SkinnedHints::AddHint( Widget *hint_owner, const Skin &skin, const Font &font, const Text &t)
{
    SkinMixer::Mix( (int)hint_owner, skin );
    AddHint( hint_owner, (int)hint_owner, _fonts.Insert(font), t );
}
void SkinnedHints::AddHint( Widget *hint_owner, const Skin &skin, int   font_no,    const Text &t)
{
    SkinMixer::Mix( (int)hint_owner, skin );
    AddHint( hint_owner, (int)hint_owner, font_no, t);
}
void SkinnedHints::AddHint( Widget *hint_owner, int skin_no, const Font &font, const Text &t)
{
    AddHint( hint_owner, skin_no, _fonts.Insert(font), t );
}
void SceneMenu::Check()
{
   EScene::Check();
#ifndef DEBUG
   if (KInput::isPressed(K_VK_M)) {
      _nCheatCode = 1;
   }
   
   if (KInput::isPressed(K_VK_I) && _nCheatCode == 1) {
      _nCheatCode++;
   }

   if (KInput::isPressed(K_VK_L) && (_nCheatCode == 2 || _nCheatCode == 3)) {
      _nCheatCode++;
   }

   if (KInput::isPressed(K_VK_I) && _nCheatCode == 4) {
      _nCheatCode++;
   }

   if (KInput::isPressed(K_VK_O) && _nCheatCode == 5) {
      _nCheatCode++;
   }

   if (KInput::isPressed(K_VK_N) && _nCheatCode == 6) {
      _nCheatCode++;
   }
#else
   _nCheatCode = 7;
#endif
   if (_nCheatCode >= 7) {
      if (KInput::isPressed(K_VK_L_SHIFT))
      {
         if (KInput::isPressed(K_VK_1)) {
            _lpSceneDirector->getSequencer()->GoToScene(NULL, "vignette_hands", "island", false);
            return;
         }
      }
      if (KInput::isPressed(K_VK_L_SHIFT))
      {
         if (KInput::isPressed(K_VK_2)) {
            _lpSceneDirector->getSequencer()->GoToScene(NULL, "vignette_hands", "japan", false);
            return;
         }
      }
      if (KInput::isPressed(K_VK_L_SHIFT))
      {
         if (KInput::isPressed(K_VK_3)) {
            _lpSceneDirector->getSequencer()->GoToScene(NULL, "vignette_hands", "inca", false);
            return;
         }
      }
      if (KInput::isPressed(K_VK_L_SHIFT))
      {
         if (KInput::isPressed(K_VK_4)) {
            _lpSceneDirector->getSequencer()->GoToScene(NULL, "vignette_hands", "middleage", false);
            return;
         }
      }
      if (KInput::isPressed(K_VK_L_SHIFT))
      {
         if (KInput::isPressed(K_VK_5)) {
            _lpSceneDirector->getSequencer()->GoToScene(NULL, "vignette_hands", "egypt", false);
            return;
         }
      }
      
      if (KInput::isPressed(K_VK_0))
      {
         _lpSceneDirector->SetHexagramme(false);
         EInventoryItem::CleanUp(NULL);
         EGlobalBank::CleanUp();
         _lpSceneDirector->getDiaryPtr()->Clean();
         _lpSceneDirector->getMap()->Clean();
         _lpSceneDirector->OpenDialogbox("Clean up done");
      }
      if (KInput::isPressed(K_VK_1))
      {
         _lpSceneDirector->getSequencer()->GoToScene(NULL, "vignette_hands", "island", false);
      }
      if (KInput::isPressed(K_VK_2))
      {
         AddObjective("house","helpnatsumi");
         AddHint("house","helpnatsumi","where");
         if (!_lpSceneDirector->getInventory()->getItemFromInventory("inv_basementkey")) {
            _lpSceneDirector->getInventory()->AddItem("house","inv_basementkey");
         }
         _lpSceneDirector->GoToScene("corridor");
      }
      if (KInput::isPressed(K_VK_3))
      {
         _lpSceneDirector->getSequencer()->GoToScene(NULL, "vignette_hands", "japan", false);
      }
      if (KInput::isPressed(K_VK_4))
      {
         ResolveTask("task_gethexagramme");
         _lpSceneDirector->getSequencer()->GoToScene(NULL, "firstfloor", "house", false);      
      }
      if (KInput::isPressed(K_VK_5))
      {
         _lpSceneDirector->getSequencer()->GoToScene(NULL, "vignette_hands", "middleage", false);
      }
      if (KInput::isPressed(K_VK_6))
      {
         _lpSceneDirector->getSequencer()->GoToScene(NULL, "vignette_hands", "inca", false);
      }
      if (KInput::isPressed(K_VK_7))
      {
         _lpSceneDirector->getSequencer()->GoToScene(NULL, "vignette_hands", "egypt", false);
      }
      if (KInput::isPressed(K_VK_8))
      {
         _lpSceneDirector->getSequencer()->GoToScene(NULL, "hell_mainscreen", "", false);
      }
      if (KInput::isPressed(K_VK_9))
      {
         _lpSceneDirector->getSequencer()->GoToScene(NULL, "house_attic", "", false);
      }
      if (KInput::isPressed(K_VK_RIGHT))
      {
         ResolveTask("task_gethexagramme");
         ResolveObjective("house","helpnatsumi");
         ResolveTask("task_living_discover");
         _lpSceneDirector->getSequencer()->GoToScene(NULL, "house_diningroom", "", false);
      }
      if (KInput::isPressed(K_VK_LEFT))
      {
         _lpSceneDirector->getSequencer()->GoToScene(NULL, "debug_david", "", false);
      }
      if (KInput::isPressed(K_VK_UP))
      {
         _lpSceneDirector->getSequencer()->GoToScene(NULL, "debug_preload", "", false);
      }
   }   
}
bool Scene_Inca_Mainscreen::ItemUsed(const char *szItemName, const char *szObjectName)
{
   // Le joueur donne la lance réparée au garde
   if (strcmp(szItemName, "inv_inca_spearrepaired") == 0) {
      if (strcmp(szObjectName, "inca_main_guard_nospear") == 0) {
         _lpSceneDirector->DropItem(szItemName);
         ESoundBank::getSound("success")->playSample();
         ResolveTask("task_inca_givespear");
         int x,y;
         GetObjectPosition("inca_main_guard_spear", x, y, true, false);
         // Le garde reçoit la lance
         _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_CINEMATIC, true);
         _lpSceneDirector->getSequencer()->SwitchImage(NULL, "inca_main_guard_nospear", "inca_main_guard_spear");
         if (TestGlobal("__mode_adventure__")) _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("INCA_GUARD_RITUAL1"), "", false);
         _lpSceneDirector->getSequencer()->SwitchImage(NULL, "inca_main_guard_spear", "inca_main_guard_prey");
         _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("INCA_GUARD_RITUAL2"), "", false);
         _lpSceneDirector->getSequencer()->SwitchImage(NULL, "inca_main_guard_prey", "inca_main_guard_spear");
         if (TestGlobal("__mode_adventure__")) _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_CINEMATIC, false);
         if (TestGlobal("__mode_adventure__")) _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_DIALOG, true);
         _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("INCA_GUARD_RITUAL3"), "", false);
         if (TestGlobal("__mode_adventure__")) _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("INCA_GUARD_RITUAL4"), "", false);
         if (TestGlobal("__mode_adventure__")) _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("INCA_GUARD_RITUAL5"), "", false);
         _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("INCA_GUARD_RITUAL6"), "", false);
         if (TestGlobal("__mode_adventure__")) _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("INCA_YUMANCO_HOWENTER"), "", false, true);
         if (TestGlobal("__mode_adventure__")) _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("INCA_GUARD_RITUAL7"), "", false);
         if (TestGlobal("__mode_adventure__")) _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("INCA_GUARD_RITUAL8"), "", false);
         if (TestGlobal("__mode_adventure__")) _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_DIALOG, false);
         _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_CINEMATIC, false);
         AddTask("task_inca_opendoor");
         AddTask("task_inca_getartefacts");
         ResolveObjective("inca","spear");
         AddObjective("inca","enter");
         AddHint("inca","enter","how");
         return true;
      }
   }

   // Le joueur donne la lance réparée au garde
   if (strcmp(szItemName, "inv_inca_spearbroken") == 0) {
      if (strcmp(szObjectName, "inca_main_guard_nospear") == 0) {
         int x,y;
         GetObjectPosition("inca_main_guard_spear", x, y, true, false);
         // Le garde n'en veut pas
         _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("INCA_GUARD_SPEARBROKEN"), "", false);
         return true;
      }
   }

   // Le joueur utilise la statuette
   if (strcmp(szItemName, "inv_inca_statuette") == 0) {
      if (strcmp(szObjectName, "inca_main_door") == 0) {
         if (!TaskResolved("task_inca_givespear")) {
            int x,y;
            GetObjectPosition("inca_main_guard_nospear", x, y, true, false);
            _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("INCA_GUARD_REFUSE"), "", true);
         }
         else {
            // Ouverture de la vignette
            ESoundBank::getSound("success")->playSample();
            _lpSceneDirector->GoToVignette("vignette_inca_statuette", szObjectName, true);
         }
         return true;
      }
   }
   
   // Le joueur utilise un effet de la statuette
   if (strcmp(szItemName, "statuette_effect_raise") == 0) {
      if (strcmp(szObjectName, "inca_main_door") == 0) {
         // Lancement de l'effet
         StartEffect("raise_door");
         return true;
      }
   }

   char *effectprefix = "statuette_effect_";
   if (strncmp(szItemName, effectprefix,strlen(effectprefix)) == 0) {
         _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("INCA_MAIN_YUMANCO_STATUETTE_NOEFFECT"), "", true, false);
		 return true;
   }
   return false;
}
bool SceneBasement::ItemUsed(const char *szItemName, const char *szObjectName)
{
   // Le joueur donne quelque chose au fantôme debout
   if (strcmp(szObjectName, "basement_ghostup") == 0)
   {
      int x,y;
      bool bGiven = false;
      GetObjectPosition("basement_ghostup", x, y);
      if (strcmp(szItemName, "inv_house_basement_paper") == 0) {
         ResolveTask("task_house_basement_givepaper");
         RemoveHint("house","helpnatsumi","nextpaper");
         // On peut maintenant retirer l'objet de l'inventaire
         _lpSceneDirector->DropItem("inv_house_basement_paper");
         _lpSceneDirector->getSequencer()->PlaySound(NULL, "success");
         _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("HOUSE_BASEMENT_NATSUMI_THANKYOU"), "", true, false, _lpGhostVoice);
         if (!TaskResolved("task_house_basement_givecharcoal")) {
            AddHint("house","helpnatsumi","nextcharcoal");
         }
         bGiven = true;
      }
      else
      if (strcmp(szItemName, "inv_house_basement_grid_charcoal") == 0) {
         ResolveTask("task_house_basement_givecharcoal");
         RemoveHint("house","helpnatsumi","nextcharcoal");
         // On peut maintenant retirer l'objet de l'inventaire
         _lpSceneDirector->DropItem("inv_house_basement_grid_charcoal");
         _lpSceneDirector->getSequencer()->PlaySound(NULL, "success");
         _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("HOUSE_BASEMENT_NATSUMI_THANKYOU"), "", true, false, _lpGhostVoice);
         bGiven = true;
      }
      else {
         _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("HOUSE_BASEMENT_NATSUMI_IDONTNEED"), "", true, false, _lpGhostVoice);
      }
      
      // On teste si on a donné les 2 objets attendus par le fantôme
      if (bGiven) {
         if (TaskResolved("task_house_basement_givepaper") && TaskResolved("task_house_basement_givecharcoal")) {
            _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_DIALOG, true);
            _lpSceneDirector->getSequencer()->ShowEmitter(NULL, "creeping_static_up", false);
            _lpSceneDirector->getSequencer()->ShowImage(NULL,"basement_ghostup",false);
            _lpSceneDirector->getSequencer()->ShowImage(NULL,"basement_ghostdrawing1",true);
            _lpSceneDirector->getSequencer()->SwitchImage(NULL, "basement_ghostdrawing1", "basement_ghostdrawing2");
            _lpSceneDirector->getSequencer()->SwitchImage(NULL, "basement_ghostdrawing2", "basement_ghostdrawing1");
            _lpSceneDirector->getSequencer()->SwitchImage(NULL, "basement_ghostdrawing1", "basement_ghostdrawing2");
            _lpSceneDirector->getSequencer()->SwitchImage(NULL, "basement_ghostdrawing2", "basement_ghostdrawing1");
            _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("HOUSE_BASEMENT_ASHLEY_SHEDRAW"), "", false, true);
            _lpSceneDirector->getSequencer()->SwitchImage(NULL, "basement_ghostdrawing1", "basement_ghostdrawing2");
            _lpSceneDirector->getSequencer()->SwitchImage(NULL, "basement_ghostdrawing2", "basement_ghostdrawing1");
            _lpSceneDirector->getSequencer()->ShowImage(NULL,"basement_ghostdrawing1",false);
            _lpSceneDirector->getSequencer()->ShowEmitter(NULL, "creeping_static_hidden", true);
            _lpSceneDirector->getSequencer()->ShowImage(NULL,"basement_ghosthidden",true);
            _lpSceneDirector->getSequencer()->PlaySound(NULL, "success");
            _lpSceneDirector->getSequencer()->ShowImage(NULL,"basement_sketch",true);
            _lpSceneDirector->getSequencer()->Animation(NULL, "sketchanimp2p", true);
            _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_DIALOG, false);
            _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("HOUSE_BASEMENT_ASHLEY_SHEDRAW2"), "", true);
            ResolveTask("task_house_basement_natsumineed");
            AddTask("task_house_basement_bonzai");
            RemoveHint("house","helpnatsumi","what");
            AddObjective("house","bonzai");
            AddHint("house","bonzai","how");
            AddHint("house","bonzai","grip");
         }
      }
      return true;
   }
   // Le joueur donne quelque chose au fantôme caché
   if (strcmp(szObjectName, "basement_ghosthidden") == 0)
   {
      _lpSceneDirector->getSequencer()->PlaySound(NULL, "ghostappear");
      int x,y;
      GetObjectPosition("basement_ghostup", x, y);
      _lpSceneDirector->getSequencer()->ShowImage(NULL,"basement_ghosthidden",false);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL, "creeping_static_hidden", false);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL, "creeping_static_up", true);
      _lpSceneDirector->getSequencer()->ShowImage(NULL,"basement_ghostup",true);
      _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("HOUSE_BASEMENT_NATSUMI_DOYOUWANT2GIVE"), "", false, false, _lpGhostVoice);
      _lpTimerGhost->startCounter(0.0f, 1.0f, 0, 10000, K_COUNTER_LINEAR);
      return true;
   }
   // Le joueur utilise l'ampoule sur le bulbe cassé
   if ( strcmp(szItemName, "inv_house_basement_bulb") == 0 ) {
      if (strcmp(szObjectName, "bulbbroken") == 0)
      {
         _lpSceneDirector->getSequencer()->VoiceOver(NULL, KStr("HOUSE_BASEMENT_ASHLEY_IMPOBULB"),"");
         return true;
      }
   }
   // Le joueur utilise le torchon sur le bulbe cassé
   if ( strcmp(szItemName, "inv_house_basement_rag") == 0 ) {
      if (strcmp(szObjectName, "bulbbroken") == 0)
      {
         ESoundBank::getSound("success")->playSample();
         // On peut maintenant retirer l'objet de l'inventaire
         _lpSceneDirector->DropItem("inv_house_basement_rag");
         // On enlève la douille cassée
         SetVisible("bulbbroken", false);
         SetVisible("nobulb", true);
         // Tache résolue : enlever le bulbe brisé
         ResolveTask("task_house_basement_removebulb");
         return true;
      }
   }
   // Le joueur utilise l'ampoule neuve sur la douille vide
   if ( strcmp(szItemName, "inv_house_basement_bulb") == 0 ) {
      if (strcmp(szObjectName, "nobulb") == 0)
      {
         ESoundBank::getSound("success")->playSample();
         // On peut maintenant retirer l'objet de l'inventaire
         _lpSceneDirector->DropItem("inv_house_basement_bulb");
         // On met l'ampoule
         SetVisible("bulboff", true);
         SetVisible("nobulb", false);
         // Tache résolue : enlever le bulbe brisé
         ResolveTask("task_house_basement_changebulb");
         return true;
      }
   }
   // Le joueur utilise le marteau sur le vase
   if ( strcmp(szItemName, "inv_house_basement_hammer") == 0 ) {
      if (strcmp(szObjectName, "basement_vase") == 0)
      {
         ESoundBank::getSound("success")->playSample();
         // On peut maintenant retirer l'objet de l'inventaire
         _lpSceneDirector->DropItem("inv_house_basement_hammer");
         SetVisible("basement_vase", false);
         SetVisible("basement_vasebroken", true);
         SetVisible("basement_paper", true);
         _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("HOUSE_BASEMENT_VASEBROKEN_INFO"), "", true);
         // Tache résolue
         ResolveTask("task_house_basement_brokevase");
         return true;
      }
   }
   
   // Le joueur utilise la pince cassée sur le bonzai
   if ( strcmp(szItemName, "inv_house_basement_gripbroken") == 0 ) {
      _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("HOUSE_BASEMENT_ASHLEY_CANNOTWRIST"), "", true);
   }
   // Le joueur utilise la pince sur le bonzai
   if ( strcmp(szItemName, "inv_house_basement_grip") == 0 ) {
      // On doit avoir le modèle pour faire le mini jeu !
      if (_lpSceneDirector->getInventory()->getItemFromInventory("inv_house_basement_sketch")) {
         if (strcmp(szObjectName, "basement_bonzai") == 0)
         {
            EMiniJeuBase *lpMiniJeu = new EMinijeuBonzai();
            _lpSceneDirector->GoToMiniGame("bonzai", lpMiniJeu);
            return true;
         }
      }
      else {
         _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("HOUSE_BASEMENT_ASHLEY_INEEDMODEL"), "", true);
         return true;
      }
   }
   return false;
}
void SceneBasement::Init()
{
   StartAnimation("basement_ghostup_anim");
   SetVisible("basement_ghostup", false, true);
   SetupItem("envelope_basement");
   
   // 1ère visite
   if (!TaskResolved("task_house_basementvisit")) {
      ResolveTask("task_house_basementvisit");
      AddObjective("house","basementlight");
      AddHint("house","basementlight","how");
      RemoveHint("house","helpnatsumi","where");
      AddHint("house","helpnatsumi","what");
      AddHint("house","helpnatsumi","nextpaper");
   }
   
   // Lumière éteinte
   if (!TaskResolved("task_house_basement_light")) {
      AddTask("task_house_basement_light");
      SetVisible("darkness", true);
      // Ampoule non réparée
      if (TaskResolved("task_house_basement_changebulb")) {
         SetVisible("bulboff", true);
      }
      else {
         // Bulbe cassé retiré ?
         if (TaskResolved("task_house_basement_removebulb")) {
            SetVisible("bulbbroken", false);
            SetVisible("nobulb", true);
         }else {
            SetVisible("bulbbroken", true);
         }
      }
   }
   else {
      SetVisible("darkness", false);
      SetVisible("lightning", true);
      SetVisible("bulboff", false, true);
      SetVisible("bulbon", true, true);
   }
   
   if (TaskResolved("task_japan_universeresolved")) {
      SetVisible("basement_ghosthidden", false, true);
      SetupItem("basement_rope");
      if (isVisible("basement_rope")) {
         StartEmitter("flake_rope");
      }
   }         

   // La clé
   SetVisible("basement_screwdriver", TestGlobal("basement_screwdriver") == false);
   // La pince
   SetVisible("basement_grip", TestGlobal("basement_grip") == false);
   // Le bonzaï
   if (TaskResolved("task_house_basement_bonzai")) {
      SetVisible("basement_bonzairesolved", true, true);
   } else {
      SetVisible("basement_bonzai", true, true);
   }
   
   // La grille
   if (TaskResolved("task_house_basement_opengrid")) {
      SetVisible("basement_gridopen", true);
   } else {
      SetVisible("basement_gridclosed", true);
   }
   
   // Le charbon
   if (!TaskResolved("task_house_basement_reversecoal")) {
      SetVisible("basement_coalbucketup", true, true);
   } else {
      SetVisible("basement_coalbucketdown", true, true);
   }
   
   // Le vase
   if (!TaskResolved("task_house_basement_brokevase")) {
      SetVisible("basement_vase", true, true);
   } else {
      SetVisible("basement_vasebroken", true, true);
      // Le papier
      SetVisible("basement_paper", TestGlobal("basement_paper") == false);
   }
   
   // La boite à outils
   if (!TaskResolved("task_house_basement_opentoolbox")) {
      SetVisible("basement_toolboxclosed", true, true);
   } else {
      SetVisible("basement_toolboxopen", true, true);
      // Le marteau
      SetVisible("basement_hammer", TestGlobal("basement_hammer") == false);
   }
   
   // Le fantôme
   if (!TaskResolved("task_house_basement_light")) {
      int x,y;
      GetObjectPosition("basement_ghostup", x, y);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL, "creeping_static_up", true);
      _lpSceneDirector->getSequencer()->PlaySound(NULL, "ghostcreep");
      _lpSceneDirector->getSequencer()->Wait(NULL, 2500);
      _lpSceneDirector->getSequencer()->PlaySound(NULL, "ghostappear");
      _lpSceneDirector->getSequencer()->ShowImage(NULL,"basement_ghostup",true);
      _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("HOUSE_BASEMENT_NATSUMI_LETME"), "", false, false, _lpGhostVoice);
      _lpSceneDirector->getSequencer()->ShowImage(NULL,"basement_ghostup",false);
      _lpSceneDirector->getSequencer()->ShowImage(NULL,"basement_ghosthidden",true);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL, "creeping_static_up", false);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL, "creeping_static_hidden", true);
   } else {
      if (!TaskResolved("task_japan_universeresolved")) {
         _lpSceneDirector->getSequencer()->ShowEmitter(NULL, "creeping_static_hidden", true);
         _lpSceneDirector->getSequencer()->ShowImage(NULL,"basement_ghosthidden",true);
      }
   }
   
   // Le croquis
   if (TaskResolved("task_house_basement_givepaper") && TaskResolved("task_house_basement_givecharcoal")) {
      SetVisible("basement_sketch", TestGlobal("basement_sketch") == false);
   }
   
   // On revient de l'univers
   if (getAdditionalName() == "backfrombeyond") {
      int x,y;
      x = 1024/2;
      y = 768/2;
      SetVisible("black", true, true);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL, "creeping_static_up", true);
      _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_CINEMATIC, true);
      _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("JAPAN_NATSUMI_HOUSEEPILOG1"), "", false, false, _lpGhostVoice);
      _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("JAPAN_NATSUMI_HOUSEEPILOG2"), "", false, false, _lpGhostVoice);
      _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("JAPAN_NATSUMI_HOUSEEPILOG3"), "", false, false, _lpGhostVoice);
      _lpSceneDirector->getSequencer()->PlaySound(NULL, "ghostgone");
      _lpSceneDirector->getSequencer()->GotoVideo(NULL, "videos/reveil.ogv","frombeyond");
      SetupItem("basement_rope");
      StartEmitter("flake_rope");
      _lpSceneDirector->getSequencer()->ShowImage(NULL, "black", false);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL, "creeping_static_up", false);
      _lpSceneDirector->getSequencer()->Wait(NULL, 2000);
      _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_CINEMATIC, false);
      ResolveTask("task_freeghost_done_japan");
      AddObjective("house","freemurray");
      AddHint("house","freemurray","where");
      _lpSceneDirector->getDiaryPtr()->beginCreatePage();
      _lpSceneDirector->getDiaryPtr()->addImageToPage("diary_basement2.png");
      _lpSceneDirector->getDiaryPtr()->addStringToPage("DIARY_BASEMENT2", FONT_DIARY_1, 0, 0);
      _lpSceneDirector->getDiaryPtr()->endCreatePage();
      return;
   }
   
   // Allumage
   if (getAdditionalName() == "light") {
      // On provoque l'apparition de Natsumi
      ObjectClicked("basement_ghosthidden", 0, 0);
      _lpSceneDirector->getDiaryPtr()->beginCreatePage();
      _lpSceneDirector->getDiaryPtr()->addImageToPage("diary_basement1.png");
      _lpSceneDirector->getDiaryPtr()->addStringToPage("DIARY_BASEMENT1", FONT_DIARY_1, 0, 0);
      _lpSceneDirector->getDiaryPtr()->endCreatePage();
   }
   
   if (getAdditionalName() == "completed") {
      BasementGoforUniverse();
      return;
   }   
   
   // On force le passage à l'univers, en cas de plantage/quit prématuré entre la scène et l'univers
   if (TaskResolved("task_japan_prologcompleted") && !TaskResolved("task_japan_universeresolved")) {
      BasementGoforUniverse();
      return;
   }
   
   // On a tout terminé
   if ( TaskResolved("task_japan_universeresolved") && TestGlobal("basement_rope")) {
      _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("GLOBAL_ASHLEY_FINISHED"), "", true);
      return;
   }
}
void Scene_House_Hall::Init()
{
   SetupItem("house_score");

   _lpSceneDirector->getMap()->renameZone("hall", "house_hall");
   _lpSceneDirector->getMap()->setVisited("house_hall");
      
   if (getAdditionalName() == "start") {
      _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_LOCKMOUSE, true);
      int x, y;
      GetObjectPosition("nathan_shadow", x, y, true, false);
      ResolveTask("task_house_openliving");
      SetVisible("nathan_shadow",true, true);
      StartEmitter("creeping_nathan_shadow");
      _lpSceneDirector->getSequencer()->EarthQuake("earthquakehall",false,"hall_earthquake");
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL, "creeping_fragments", false);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL, "creeping_plaster", false);
      _lpSceneDirector->getSequencer()->PlaySound(NULL, "hall_earthquakeout");
      _lpSceneDirector->getSequencer()->SwitchImage(NULL, "nathan9", "nathan14");
      _lpSceneDirector->getSequencer()->SwitchImage(NULL, "nathan14", "nathan15");
      _lpSceneDirector->getSequencer()->SwitchImage(NULL, "nathan15", "hall_isaac_waiting");

//      _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_CINEMATIC, true);
//      _lpSceneDirector->getSequencer()->PickupItem(NULL,"inv_hexagramme", 1024/2, 768/2, 1);
//      _lpSceneDirector->getSequencer()->ShowImage(NULL, "neckless", true, false);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL,"creeping_nathan_shadow",false);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL,"creeping_nathan_show",true);
      _lpSceneDirector->getSequencer()->ShowImage(NULL,"nathan_show",true);
      _lpSceneDirector->getSequencer()->ShowImage(NULL,"nathan_shadow",false);
      _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("HALL_NATHAN_STARTHERE"), "nathan_hall_starthere", false);
      _lpSceneDirector->getSequencer()->PlaySound(NULL, "opendoor");
      _lpSceneDirector->getSequencer()->ShowImage(NULL,"house_hall_livingdooropen", true, true);
      _lpSceneDirector->getSequencer()->Wait(NULL, 500);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL,"creeping_nathan_souls1",true);
      _lpSceneDirector->getSequencer()->PlaySound(NULL, "ghostgone");
      _lpSceneDirector->getSequencer()->ShowImage(NULL, "nathan_show", false, false);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL,"creeping_nathan_show",false);
      _lpSceneDirector->getSequencer()->Callback(NULL,"inv_hexagramme");
      _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_CINEMATIC, false);

      _lpSceneDirector->getDiaryPtr()->beginCreatePage();
      _lpSceneDirector->getDiaryPtr()->addImageToPage("diary_hall.png");
      _lpSceneDirector->getDiaryPtr()->addStringToPage("DIARY_HALL1", FONT_DIARY_1, 0, 0);
      _lpSceneDirector->getDiaryPtr()->endCreatePage();
      _lpSceneDirector->getDiaryPtr()->beginCreatePage();
      _lpSceneDirector->getDiaryPtr()->addStringToPage("DIARY_HALL2", FONT_DIARY_1, 0, 0);
      _lpSceneDirector->getDiaryPtr()->addImageToPage("diary_medaillon.png");
      _lpSceneDirector->getDiaryPtr()->endCreatePage();

      _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_LOCKMOUSE, false);

      AddObjective("house","contactyumanco");
      AddHint("house","contactyumanco","where");
   }
   
   // Plante
   if (!TaskResolved("task_house_getbrushwood")) {
      SetVisible("house_hall_plant", true, true);
   }
   else {
      SetVisible("house_hall_plant_done", true, true);
   }
   
   // Isaac
   if (!TaskResolved("task_house_hall_groundfloor") && getAdditionalName()=="") {
      _lpSceneDirector->getSequencer()->PlaySound(NULL, "hall_dog_cry");
      SetVisible("hall_isaac_waiting", true, true);
   }

   // Porte du salon
   if (TaskResolved("task_house_openliving") && getAdditionalName() == "") {
      SetVisible("house_hall_livingdooropen", true, true);
   }
   
   // Porte de la salle à manger ouverte ou fermée ?
   if (ObjectiveResolved("house","helpnatsumi")) {
      SetVisible("diningroom", false);
      SetVisible("house_hall_diningdooropen", true, true);
   }
   else {
      SetVisible("diningroom", true);
      SetVisible("house_hall_diningdooropen", false);
   }

   // Etage résolu
   if (TaskResolved("task_house_hall_groundfloor")) {
      ResolveGroundFloor();
   }
   
   // Premier retour dans le hall après avoir sauvé l'inca
   if (TaskResolved("task_inca_universeresolved") && !TaskResolved("task_meetnathan2")) {
      int x, y;
      GetObjectPosition("nathan_corridor", x, y, true, false);
      ResolveTask("task_meetnathan2");
      _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_CINEMATIC, true);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL,"creeping_nathan_souls2",true);
      _lpSceneDirector->getSequencer()->Wait(NULL, 2000);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL,"creeping_nathan_corridor",true);
      _lpSceneDirector->getSequencer()->Wait(NULL, 2000);
      _lpSceneDirector->getSequencer()->PlaySound(NULL, "attic_nathanappear");
      _lpSceneDirector->getSequencer()->ShowImage(NULL, "nathan_corridor", true);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL,"creeping_nathan_souls2",false);
      _lpSceneDirector->getSequencer()->Wait(NULL, 1500);
      _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("HALL_NATHAN_MEET2_1"), "HALL_NATHAN_MEET2_1", false);
      _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_CINEMATIC, false);
      _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_DIALOG, true);
      _lpSceneDirector->getSequencer()->Talk(NULL, CHARACTER_POSX, CHARACTER_POSY, KStr("HALL_ASHLEY_MEET2"),"hall_ashley_meet2",false,true);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL,"creeping_nathan_souls2",true);
      _lpSceneDirector->getSequencer()->Talk(NULL, x, y, KStr("HALL_NATHAN_MEET2_3"), "HALL_NATHAN_MEET2_3", false);
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL,"creeping_nathan_souls2",true);
      _lpSceneDirector->getSequencer()->PlaySound(NULL, "ghostgone");
      _lpSceneDirector->getSequencer()->ShowEmitter(NULL,"creeping_nathan_corridor",false);
      _lpSceneDirector->getSequencer()->ShowImage(NULL, "nathan_corridor", false);
      _lpSceneDirector->getSequencer()->NarrationMode(NULL, SEQUENCE_NARRATION_DIALOG, false);
      _lpSceneDirector->getDiaryPtr()->beginCreatePage();
      _lpSceneDirector->getDiaryPtr()->addImageToPage("diary_hall.png");
      _lpSceneDirector->getDiaryPtr()->addStringToPage("DIARY_NATHAN2", FONT_DIARY_1, 0, 0);
      _lpSceneDirector->getDiaryPtr()->endCreatePage();
   }
   else {
      if (!TaskResolved("hall_tuto_guide") && getAdditionalName() != "start") {
         ResolveTask("hall_tuto_guide");
         if (TestGlobal("__tutorial__")) {
            _lpSceneDirector->getSequencer()->Tutobox(NULL, KStr("HOUSE_OUT_TUTO_TASK"), 70, 740, -90, 200);
         }
      }
   }
}