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

  1. -- shower character state machine
  2. beginStateMachine()
  3.     
  4.     onEnter(function(msg)
  5.         local shower = getStateObjectFromID(msg.sender);
  6.         storeStateObject("shower", shower);
  7.         storeData("initOutfit", getParent().getOutfit());
  8.         
  9.         if (shower) then
  10.             -- shower does exist
  11.             local actionPointName = retrieveData("actionPointName");
  12.             if exitIfWrongPosition(getParent(), shower, actionPointName) then return end;                
  13.  
  14.             if (getParent().isOneActionPointLocked(shower)) then
  15.                 -- action point is locked
  16.                 getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  17.                 sendMsg("emoThink", getParent().walkSO);
  18.                 exitStateMachine();
  19.             else
  20.                 getParent().lockActionPoints(shower);
  21.             end
  22.         else
  23.             -- shower does not exist anymore
  24.             getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
  25.             sendMsg("emoThink", getParent().walkSO);
  26.             exitStateMachine();
  27.         end
  28.         
  29.         freeHands(getParent());
  30.         
  31.         
  32.     end )
  33.     
  34.     onExit(function(msg)
  35. --        local shower = retrieveStateObject("shower");
  36. --        getParent().stopAllActivities(shower);
  37. --        getParent().unlockActionPoints(shower);
  38. --        removeStateObject("shower");
  39.         
  40.         unlockAll("shower");
  41.         
  42.         getParent().stopAllActivities();        
  43.     end )
  44.     
  45.     
  46.     onMsg("startShowerLoopSound", function(msg)
  47.         print("startShowerLoopSound");
  48.         local shower = retrieveStateObject("shower");
  49.         shower.loopSound("showerLoop");                    
  50.     end )
  51.     
  52.     
  53.     -- undress outside the shower
  54.     state("undressOutside")
  55.     
  56.         onEnter(function(msg)
  57.             print("undressOutside onEnter");
  58.         
  59.             local character = getParent();        
  60.             local other, result = getDisturbingChar(character, "showNaked");
  61.             if (other) then
  62.                 exitStateMachine();
  63.                 character.setEmoticon(EMOTICON_SHY, EMOTICON_DELAY);
  64.                 other.sendMsg("emoShameChar", character.walkSO);        
  65.                 return    
  66.             end;
  67.         
  68.         
  69. --            local character = getParent();
  70. --            local others = character.getCharactersInRoom();
  71. --                    
  72. --            for c = 1, getn(others) do
  73. --                local other = others[c];
  74. --                --print("checkShyness other found");
  75. --                if (not activityPossible(character, "showInUnderwear", other)) then
  76. --                    exitStateMachine();
  77. --                    --print("checkShyness sendMsg emoShame");
  78. --                    character.setEmoticon(EMOTICON_SHY, EMOTICON_DELAY);
  79. --                    other.sendMsg("emoShameChar", character.walkSO);        
  80. --                    return    
  81. --                end;
  82. --            end;
  83.                 
  84.         
  85.             --startAnimation("ausziehen2");
  86.             startAnimation(getChangeOutfitAnim(getParent()));
  87.             sendDelayedMsgThis("underwear", 1600);
  88.  
  89.             local shower = retrieveStateObject("shower");
  90.             shower.playSound("showerFadein");
  91.             sendDelayedMsg("startShowerLoopSound", this, 4100);                        
  92.             shower.setChildEnable("damp", true);
  93.         end )
  94.         
  95.         onMsg("underwear", function(msg)
  96.             if (not hasOutfit(getParent(), UNDERWEAR) and not hasOutfit(getParent(), NOTHING)) then
  97.                 getParent().changeOutfit(UNDERWEAR);
  98.             end
  99.         end )
  100.         
  101. --        onMsg("startLoopSound", function(msg)
  102. --            print("undressOutside startLoopSound");
  103. --            local shower = retrieveStateObject("shower");
  104. --            shower.loopSound("showerLoop");                    
  105. --        end )
  106.         
  107.     
  108.         onMsg("end", function(msg)
  109.             print("undressOutside end");
  110.             if testCancel() then
  111.                 local shower = retrieveStateObject("shower");
  112.                 shower.stopSound("showerLoop");
  113.                 shower.playSound("showerFadeout");            
  114.                 shower.setChildEnable("damp", false);
  115.                 local initOutfit = retrieveData("initOutfit");        
  116.                 getParent().changeOutfit(initOutfit);
  117.                 exitStateMachine();
  118.             else
  119.                 setState("enterShower");
  120.                 sendDelayedMsgThis("act", 5000);
  121.             end
  122.         end )    
  123.  
  124.     
  125.     -- enter the shower
  126.     state("enterShower")
  127.     
  128.         onEnter(function(msg)
  129.             startAnimation("enterShowerElaine");
  130.             local shower = retrieveStateObject("shower");
  131.             --shower.playSound("enterShower");
  132.             sendDelayedMsgThis("playEnterShowerSound", 500);
  133.             --shower.startAnimation("showerDesignEnter");
  134.             playShowerAnim(shower, "Enter");
  135.  
  136.         end )
  137.         
  138.         onMsg("playEnterShowerSound", function(msg)
  139.             local shower = retrieveStateObject("shower");
  140.             shower.playSound("enterShower");                    
  141.         end )
  142.         
  143.         
  144.     
  145.         onMsg("end", function(msg)
  146.             if testCancel() then
  147.                 setState("exitShower")
  148.             else
  149.                 setState("undressShower");
  150.             end
  151.         end )
  152.     
  153.     -- undress in the shower
  154.     state("undressShower")
  155.     
  156.         onEnter(function(msg)
  157.             local shower = retrieveStateObject("shower");
  158.             local takeShower = getParent().startActivity("shower", shower);
  159.             -- storeData("takeShower", takeShower);
  160.             local takeShowerLength, scale = getActivityLength(takeShower);
  161.             storeData("takeShowerLength", takeShowerLength);
  162.             
  163.             startAnimation("undressShowerElaine");
  164.             sendDelayedMsgThis("hideCloth", 4000);
  165.         end )
  166.         
  167.         onMsg("hideCloth", function(msg)
  168.             getParent().changeOutfit(NOTHING);
  169.             --getParent().enableBlend(true);
  170.             --print("outfit NOTHING", getParent().getOutfit());
  171.         end )
  172.     
  173.         onMsg("end", function(msg)
  174.             if testCancel() then
  175.                 setState("exitShower")
  176.             else
  177.                 setState("shower");
  178.                 sendDelayedMsgThis("act", 5000);
  179.             end
  180.         end )    
  181.     
  182.     -- take a shower
  183.     state("shower")
  184.     
  185.         onEnter(function(msg)
  186.             --local shower = retrieveStateObject("shower");
  187.             --shower = getParent().startActivity("shower", shower);
  188.             
  189.             -- local takeShower = retrieveData("takeShower");            
  190.             -- local length, scale = getActivityLength(takeShower);
  191.             
  192.             local length = retrieveData("takeShowerLength");
  193.             
  194.             startAnimation("showerElaine");
  195.             -- to make quick abort on queue            
  196.             sendDelayedMsgThis("endShower", length);
  197.             --this.actionComplete();    
  198.                     
  199.             sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
  200.         end )
  201.                 
  202.         onMsg("queue", function(msg)
  203.             sendMsgThis("endShower");
  204.         end )
  205.         
  206.         onMsg("endShower", function(msg)
  207.             print("endShower")
  208.             local shower = retrieveStateObject("shower");
  209.             shower.stopSound("showerLoop");
  210.             shower.playSound("showerFadeout");            
  211.             getParent().stopAllActivities(shower);
  212.             setState("exitShower")
  213.         end )
  214.                     
  215.         onMsg("testCancel", function(msg)
  216.             if testCancel() or (not this.getParent().getCurrentActivityGain()) then
  217.                 sendMsgThis("endShower");
  218.             else
  219.                 sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
  220.             end
  221.         end )
  222.  
  223.         onMsg("end", function(msg)
  224.             if testCancel() then
  225.                 sendMsgThis("endShower");
  226.             else
  227.                 startAnimation("showerElaine");
  228.             end
  229.         end )    
  230.         
  231.     -- exit the shower
  232.     state("exitShower")
  233.     
  234.         onEnter(function(msg)
  235.             -- show clothes
  236.             startAnimation("exitShowerElaine");
  237.             
  238.             local shower = retrieveStateObject("shower");
  239.             shower.stopSound("showerLoop");
  240.             playShowerAnim(shower, "Exit");
  241.             --shower.startAnimation("showerDesignEnter", -1);
  242.             --shower.startAnimation("showerDesignExit");
  243.             sendDelayedMsgThis("playTakeTowelSound", 500);
  244.             sendDelayedMsgThis("showTowel", 3800);
  245.             sendDelayedMsgThis("playExitSound", 4440);
  246.             
  247.         end )
  248.         
  249.         onMsg("playTakeTowelSound", function(msg)
  250.             local shower = retrieveStateObject("shower");
  251.             shower.playSound("showerTakeTowel");            
  252.         end )
  253.         
  254.         onMsg("showTowel", function(msg)
  255.             getParent().changeOutfit(TOWEL);
  256.             --getParent().enableBlend(false);
  257.         end )
  258.         
  259.  
  260.         onMsg("playExitSound", function(msg)
  261.             local shower = retrieveStateObject("shower");
  262.             shower.playSound("showerExit");    
  263.             shower.setChildEnable("damp", false);        
  264.         end )
  265.         
  266.     
  267.         onMsg("end", function(msg)
  268.             exitStateMachine();
  269.         end )    
  270.             
  271. endStateMachine()