home *** CD-ROM | disk | FTP | other *** search
/ Singles (French) / Singles-FrenchVersion-Win95.iso / data1.cab / Statemachine / questHoneymoon.lua < prev    next >
Text File  |  2004-03-05  |  8KB  |  269 lines

  1. beginStateMachine()
  2.  
  3.     -- called when questor builds up all known questScripts
  4.     onEnter(function(msg)
  5.         print("questMarriage entered");
  6.         setState("initial");
  7.     end )
  8.     
  9.     -- on game over: relationship conditions get reset to 0 and all quests are reset to initial
  10.     onMsg("questreset", function(msg)
  11.         setState("initial");
  12.     end ) 
  13. ---------------------------------------------------------------------------------------------------------------------------------------    
  14.     
  15.     onDefault( function(msg) 
  16.         print("++++++++++++ "..getState().. "got msg:" .. msg.name);
  17.         --setState("initial");
  18.     end )
  19.  
  20.  
  21.     -- on forced or failsafe-marry me-antrag ( see initgame.lua:canMarry() )
  22.     onMsg("queueInteraction", function(msg)
  23.         local mike = getParent().getParent().getCharacter(MIKE);
  24.         local elaine = getParent().getParent().getCharacter(ELAINE);
  25.         
  26.         if (msg.data == "talkMarryMe") then -- adam muss das noch einbauen
  27.             --mike.cancelAllActivities();
  28.             --elaine.cancelAllActivities();
  29.             
  30.             mike.pushCommand("pm_talkCutscene", "talkCutscene", elaine, "questHoneymoon");
  31.             setState("willYouMarryMe");
  32.         end
  33.     end )
  34.     
  35.     
  36.     
  37.     
  38.     state("initial") 
  39.         onMsg("checkCondition", function(msg)
  40.  
  41.             local mike = getParent().getParent().getCharacter(MIKE);
  42.             local elaine = getParent().getParent().getCharacter(ELAINE);
  43.  
  44.             local friendship = min(mike.getRelationshipCondition(ELAINE, REL_FRIENDSHIP),
  45.                 elaine.getRelationshipCondition(MIKE, REL_FRIENDSHIP));
  46.             local romantic = min(mike.getRelationshipCondition(ELAINE, REL_ROMANTIC),
  47.                 elaine.getRelationshipCondition(MIKE, REL_ROMANTIC));
  48.             local erotic = min(mike.getRelationshipCondition(ELAINE, REL_EROTIC),
  49.                 elaine.getRelationshipCondition(MIKE, REL_EROTIC));
  50.             
  51.             if ( -- condition here
  52.                 max(max(friendship, romantic), erotic) >= 10
  53.                 and
  54.                 min(min(friendship, romantic), erotic) >= 5
  55.                 --and
  56.                 --getParent()["questGottaWork"].getState() == "done"
  57.             )
  58.             then
  59.                 setState("waitTillWorkingOut");
  60.             end
  61.         end )
  62.         
  63.     state("waitTillWorkingOut")
  64.         onMsg("checkCondition", function(msg)
  65.             local mike = getParent().getParent().getCharacter(MIKE);
  66.             if ( mike.getAtWork() ) then
  67.                 setState("waitTillWorkIsOut");
  68.             end
  69.         end )
  70.     
  71.     state("waitTillWorkIsOut")
  72.         onMsg("checkCondition", function(msg)
  73.             local mike = getParent().getParent().getCharacter(MIKE);
  74.             if ( not mike.getAtWork() ) then
  75.                 setState("weveGotMail");
  76.             end
  77.         end )
  78.         
  79.         
  80.     state("weveGotMail")
  81.         onMsg("checkCondition", function(msg)
  82.             local mike = getParent().getParent().getCharacter(MIKE);
  83.             local elaine = getParent().getParent().getCharacter(ELAINE);
  84.             
  85.             if (mike.getAtHome() and elaine.getAtHome()) then
  86.                 mike.queueCommand("pm_talkCutscene", "talkCutscene", elaine, "questHoneymoon");
  87.                 setState("talktome");
  88.             end
  89.         end )
  90.     
  91.     
  92.     state("talktome")
  93.         -- as soon as arrived - start dialog (interaction.talkCutscene sends talking)
  94.         onMsg("talking", function(msg)
  95.             if (msg.data == "questHoneymoon" ) then
  96.                 popupConversation("dialogHoneymoonInParadise");
  97.                 setState("donetalktome");
  98.             end 
  99.         end )
  100.         
  101.         -- if the talk was canceled before it started, queue it againe after a while
  102.         onMsg("talkingCancelled", function(msg)
  103.             if ( msg.data == "questHoneymoon" ) then
  104.                 print("--------------------> talktome onMsg talkingCancelled " .. msg.data);
  105.                 sendDelayedMsgThis("timeout", QUEST_REQUEUE_TIME)
  106.                 talkingCancelled(ELAINE, "questHoneymoon"); -- notify passive
  107.             end
  108.         end )
  109.  
  110.         onMsg("timeout", function(msg)
  111.             setState("weveGotMail");
  112.         end )
  113.         
  114.         
  115.         
  116.     state("donetalktome")
  117.         -- last dialog box clicked away
  118.         onMsg("yes", function(msg)
  119.             -- cancel
  120.             local mike = getParent().getParent().getCharacter(MIKE);
  121.             local elaine = getParent().getParent().getCharacter(ELAINE);
  122.  
  123.             mike.cancelCurrentActivity();
  124.             elaine.cancelCurrentActivity();
  125.             
  126.             -- enable piemenu-marryme-here
  127.             setState("waitForMarriage");
  128.         end )
  129.  
  130.  
  131.     state("waitForMarriage")
  132.         onMsg("queueInteraction", function(msg)
  133.             local mike = getParent().getParent().getCharacter(MIKE);
  134.             local elaine = getParent().getParent().getCharacter(ELAINE);
  135.             
  136.             if (msg.data == "talkMarryMe") then -- adam muss das noch einbauen
  137.                 mike.cancelAllActivities();
  138.                 elaine.cancelAllActivities();
  139.                 
  140.                 mike.pushCommand("pm_talkCutscene", "talkCutscene", elaine, "questHoneymoon");
  141.                 setState("willYouMarryMe");
  142.             end
  143.         end )
  144.     
  145.     state("willYouMarryMe");
  146.         onMsg("talking", function(msg)
  147.             if ( msg.data == "questHoneymoon") then
  148.                 popupConversation("dialogElainePleaseMarryMe");
  149.                 setState("doneWillYouMarryMe");
  150.             end
  151.         end )
  152.         
  153.         -- if the talk was canceled before it started, queue it againe after a while
  154.         onMsg("talkingCancelled", function(msg)
  155.             -- waitForMarriage waits itself for queueInteraction, no need to go to wait
  156.             talkingCancelled(ELAINE, "questHoneymoon"); -- notify passive
  157.             setState("waitForMarriage");
  158.         end )
  159.         
  160.         
  161.         
  162.     state("doneWillYouMarryMe");
  163.         onMsg("yes", function(msg)
  164.             local mike = getParent().getParent().getCharacter(MIKE);
  165.             local elaine = getParent().getParent().getCharacter(ELAINE);
  166.             
  167.             mike.cancelAllActivities();
  168.             elaine.cancelAllActivities();
  169.             
  170.             local friendship = min(mike.getRelationshipCondition(ELAINE, REL_FRIENDSHIP),
  171.                 elaine.getRelationshipCondition(MIKE, REL_FRIENDSHIP));
  172.             local romantic = min(mike.getRelationshipCondition(ELAINE, REL_ROMANTIC),
  173.                 elaine.getRelationshipCondition(MIKE, REL_ROMANTIC));
  174.             local erotic = min(mike.getRelationshipCondition(ELAINE, REL_EROTIC),
  175.                 elaine.getRelationshipCondition(MIKE, REL_EROTIC));
  176.         
  177.             if ( -- condition here
  178.                 min(min(friendship, romantic), erotic) >= 10
  179.             )
  180.             then
  181.                 print("!!!!!!!!!!!!!!!! OK Heirate mich");
  182.                 popupConversation("dialogElaineMarryMeNow");
  183.                 
  184.                 setState("victory");
  185.             else 
  186.                 print("========================= nee, du:");
  187.                 
  188.                 -- Wenn genug Romantik da ist
  189.                 if romantic >= 10 then
  190.                     print("!!! GENUG ROMANTIK");
  191.                     
  192.                     -- .. und genug Freundschaft
  193.                     if friendship >= 10 then
  194.                         
  195.                         print("!!! GENUG FREUNDSCHAFT");
  196.                         -- fehlt Erotik
  197.                         popupConversation("dialogElaineMarryMeWithoutErotic");
  198.                     else
  199.                         print("!!! WENIG FREUNDSCHAFT");
  200.                         -- ... nicht genug Freundschaft
  201.                         -- aber genug Erotik
  202.                         if erotic >= 10 then
  203.                             print("!!! GENUG EROTIK");
  204.                             -- fehlt Freundschaft
  205.                             popupConversation("dialogElaineMarryMeWithoutFriendship");
  206.                         else
  207.                             print("!!! WENIG EROTIK");
  208.                             -- fehlt Freundschaft und Erotik
  209.                             popupConversation("dialogElaineMarryMeWithoutFriendshipErotic");
  210.                         end 
  211.                     end
  212.                 else
  213.                     print("!!! WENIG ROMANTIK");
  214.                     -- ... nicht genug Romantik
  215.                     
  216.                     if friendship >= 10 then
  217.                         print("!!! GENUG FREUNDSCHAFT");
  218.                         -- .. aber genug Freundschaft
  219.                         
  220.                         if erotic >= 10 then
  221.                             print("!!! GENUG EROTIK");
  222.                             -- und erotic, dann fehlt nur Romantik
  223.                             popupConversation("dialogElaineMarryMeWithoutRomance");
  224.                         else
  225.                             print("!!! WENIG EROTIK");
  226.                             popupConversation("dialogElaineMarryMeWithoutEroticRomance");
  227.                         end 
  228.  
  229.                     else
  230.                         print("!!! WENIG FREUNDSCHAFT");
  231.                         -- ... nicht genug Freundschaft
  232.                         popupConversation("dialogElaineMarryMeWithoutRomanceFriendship");                    
  233.                     end
  234.                 end
  235.                 
  236.                 setState("waitForMarriage");
  237.             end
  238.             
  239.             
  240.         end )
  241. ---------------------------------------------------------------------------------------------------------------------------------------    
  242.             
  243.     state("victory")
  244.         onMsg("yes", function(msg)
  245.             getParent().getParent().getCharacter(MIKE).cancelCurrentActivity();
  246.             getParent().getParent().getCharacter(ELAINE).cancelCurrentActivity();
  247.             
  248.             writeConfig("Game", "cottageEnabled", "true");
  249.             
  250.             -- popup marriage chapter
  251.             popupChapter("guiStoryChapterGroup4");        
  252. --############################################
  253. ------ ende - credits here
  254. --############################################
  255.  
  256.             -- disable questor
  257.             getParent().setState("done");
  258.             
  259.             setState("done");
  260.         end )
  261.     
  262.     
  263.     state("done")
  264.     -- sackgasse hier
  265.         
  266.         
  267.         
  268. endStateMachine()
  269.