home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2006 April / SGP.iso / dema / Keepsake-Demo-en-li-v1.0.exe / res / scripts / tools.tcl < prev    next >
Text File  |  2005-12-07  |  13KB  |  610 lines

  1. proc checkConversation { name code } {
  2.   if { [ozGet $name] != "ok" } {
  3.     ozSet $name "ok"
  4.     eval $code
  5.   }
  6. }
  7.  
  8.  
  9. proc checkPreReq { name } {
  10.   if { [ozGet $name] != "ok" } {
  11.     return break
  12.   }
  13.   return continue
  14. }
  15.  
  16.  
  17. proc checkTime { time } {
  18.   if { [ozGet "sysTimeSinceLastEvent"] < $time } {
  19.     return queue
  20.   }
  21.   return continue
  22. }
  23.  
  24.  
  25. proc standardFadeout { } {
  26.   cameraFadeout 500
  27.   delay 500
  28. }
  29.  
  30.  
  31. proc standardFadein { } {
  32.   cameraFadein 500
  33.   delay 500
  34. }
  35.  
  36.  
  37. ## ===================================================== ##
  38. ##   Set the Event Priority                              ##
  39. ## ===================================================== ##
  40.  
  41. proc setEventPriority { event priority } {
  42.   set list [ozGet "$priority"]
  43.   append list " $event"
  44.   ozSet "$priority" $list
  45. }
  46.  
  47.  
  48. ## ===================================================== ##
  49. ##   Check the Event Priority                            ##
  50. ## ===================================================== ##
  51.  
  52. proc checkEventPriority { } {
  53.   set emergencyList [ozGet "emergency"]
  54.   set shortList [ozGet "short"]
  55.   set mediumList [ozGet "medium"]
  56.   set longList [ozGet "long"]
  57.  
  58.   if { [ozGet "emergencyTime"] == "" } {ozSet "emergencyTime" [expr 1500   + [random 15000]]}
  59.   if { [ozGet "shortTime"]     == "" } {ozSet "shortTime"     [expr 30000  + [random 30000]]}
  60.   if { [ozGet "mediumTime"]    == "" } {ozSet "mediumTime"    [expr 60000  + [random 60000]]}
  61.   if { [ozGet "longTime"]      == "" } {ozSet "longTime"      [expr 90000  + [random 90000]]}
  62.  
  63.   if { [llength $emergencyList] > 0 && [ozGet "sysTimeSinceLastClose"] > [ozGet "emergencyTime"] } {
  64.     ozSet "emergencyTime" ""
  65.     set index [ random [llength $emergencyList] ]
  66.     set event [lindex $emergencyList $index]
  67.     set emergencyList [ldelete $emergencyList $event]
  68.     callEvent $event
  69.     ozSet "emergency" $emergencyList
  70.     return continue
  71.  
  72.   } elseif { [llength $shortList] > 0 && [ozGet "sysTimeSinceLastClose"] > [ozGet "shortTime"] } {
  73.     ozSet "shortTime" ""
  74.     set index [ random [llength $shortList] ]
  75.     set event [lindex $shortList $index]
  76.     set shortList [ldelete $shortList $event]
  77.     callEvent $event
  78.     ozSet "short" $shortList
  79.     return continue
  80.  
  81.   } elseif { [llength $mediumList] > 0 && [ozGet "sysTimeSinceLastClose"] > [ozGet "mediumTime"] } {
  82.     ozSet "mediumTime" ""
  83.     set index [ random [llength $mediumList] ]
  84.     set event [lindex $mediumList $index]
  85.     set mediumList [ldelete $mediumList $event]
  86.     callEvent $event
  87.     ozSet "medium" $mediumList
  88.     return continue
  89.  
  90.   } elseif { [llength $longList] > 0 && [ozGet "sysTimeSinceLastClose"] > [ozGet "longTime"] } {
  91.     ozSet "longTime" ""
  92.     set index [ random [llength $longList] ]
  93.     set event [lindex $longList $index]
  94.     set longList [ldelete $longList $event]
  95.     callEvent $event
  96.     ozSet "long" $longList
  97.     return continue
  98.   }
  99.  
  100.   return queue
  101. }
  102.  
  103.  
  104. proc deleteEventPriority {event priority} {
  105.   set list [ozGet "$priority"]
  106.  
  107.   set list [ldelete $list $event]
  108.   ozSet $priority $list
  109. }
  110.  
  111.  
  112. ###########################################
  113. ## PROC ITEM NAME
  114. ###########################################
  115.  
  116.  
  117. proc GetObjectName {obj} {
  118.   switch -exact $obj {
  119.     wineBottle {
  120.       return $::lng::wineBottleName
  121.     }
  122.       
  123.     caretakerTools {
  124.       return $::lng::caretakerToolsName
  125.     }
  126.     
  127.     figurine {
  128.       return $::lng::figurineName
  129.     }
  130.     
  131.     circlet {
  132.       return $::lng::circletName
  133.     }
  134.  
  135.     pendant {
  136.       return $::lng::pendantName
  137.     }
  138.  
  139.     brokenPendant {
  140.       return $::lng::pendantName
  141.     }
  142.  
  143.     noteBook {
  144.       return $::lng::noteBookName
  145.     }
  146.  
  147.     wineCaveClue {
  148.       return $::lng::wineCaveClueName
  149.     }
  150.  
  151.     magicalStaff {
  152.       return $::lng::magicalStaffName
  153.     }
  154.  
  155.     doll {
  156.       return $::lng::dollName
  157.     }
  158.  
  159.     caretakerNote {
  160.       return $::lng::caretakerNoteName
  161.     }
  162.  
  163.     caretakerKey {
  164.       return $::lng::caretakerKeyName
  165.     }
  166.  
  167.     keyRing {
  168.       return $::lng::keyRingName
  169.     }
  170.  
  171.     headenFlowerPage {
  172.       return $::lng::headenFlowerPageName
  173.     }
  174.  
  175.     yewlockLeavesPage {
  176.       return $::lng::yewlockLeavesPageName
  177.     }
  178.  
  179.     nigilisPage {
  180.       return $::lng::nigilisPageName
  181.     }
  182.  
  183.     headenFlower {
  184.       return $::lng::headenFlowerName
  185.     }
  186.  
  187.     yewlockLeavesBlue {
  188.       return $::lng::yewlockLeavesName
  189.     }
  190.  
  191.     yewlockLeavesRed {
  192.       return $::lng::yewlockLeavesName
  193.     }
  194.  
  195.     yewlockLeavesWhite {
  196.       return $::lng::yewlockLeavesName
  197.     }
  198.  
  199.     yewlockLeavesYellow {
  200.       return $::lng::yewlockLeavesName
  201.     }
  202.  
  203.     nigilisSeed {
  204.       return $::lng::nigilisSeedName
  205.     }
  206.  
  207.     nigilisFruit {
  208.       return $::lng::nigilisFruitName
  209.     }
  210.  
  211.     catHair {
  212.       return $::lng::catHairName
  213.     }
  214.       
  215.     wolfDrool {
  216.       return $::lng::wolfDribbleName
  217.     }
  218.       
  219.     dragonClaw {
  220.       return $::lng::dragonClawName
  221.     }
  222.  
  223.     celeste {
  224.       return $::lng::celestePortraitName
  225.     }
  226.  
  227.     aleunderRoot {
  228.       return $::lng::aleunderName
  229.     }
  230.       
  231.     oracleMoss {
  232.       return $::lng::oracleMossName
  233.     }
  234.     
  235.     eternalFlame {
  236.       return $::lng::eternalFlameName
  237.     }
  238.       
  239.     pearl {
  240.       return $::lng::pearlName
  241.     }
  242.     
  243.     starFragment {
  244.       return $::lng::meteoriteName
  245.     }
  246.       
  247.     soulDust {
  248.       return $::lng::soulDustName
  249.     }
  250.       
  251.     
  252.       
  253.     orbNotes {
  254.       return $::lng::orbNotesName
  255.     }
  256.       
  257.     handWrittenNotes {
  258.       return $::lng::nathanielNoteName
  259.     }
  260.       
  261.     tapestryObservatory {
  262.       return $::lng::clueObservatoryName
  263.     }
  264.       
  265.     tapestryForge {
  266.       return $::lng::clueForgeName
  267.     }
  268.       
  269.     tapestryArtRoom {
  270.       return $::lng::clueArtRoomName
  271.     }
  272.       
  273.     tapestrySolarium {
  274.       return $::lng::clueSolariumName
  275.     }
  276.       
  277.     spellbook {
  278.       return $::lng::spellbookName
  279.     }
  280.       
  281.     libraryBallEntrance {
  282.       return $::lng::libraryBallName
  283.     }
  284.  
  285.     libraryBallPink {
  286.       return $::lng::libraryBallName
  287.     }
  288.     
  289.     libraryBallAqua {
  290.       return $::lng::libraryBallName
  291.     }
  292.  
  293.     libraryBallBrown {
  294.       return $::lng::libraryBallName
  295.     }
  296.   }
  297. }
  298.  
  299.  
  300. ###########################################
  301. ## PROC ITEM DESC
  302. ###########################################
  303.  
  304.  
  305. proc GetObjectDesc {obj} {
  306.   switch -exact $obj {
  307.     wineBottle {
  308.       return $::lng::wineBottleDesc
  309.     }
  310.       
  311.     figurine {
  312.       return $::lng::figurineDesc
  313.     }
  314.     
  315.     caretakerTools {
  316.       return $::lng::caretakerToolsDesc
  317.     }
  318.     
  319.     circlet {
  320.       return $::lng::circletDesc
  321.     }
  322.  
  323.     pendant {
  324.       return $::lng::pendantDesc
  325.     }
  326.     
  327.     brokenPendant {
  328.       return $::lng::pendantBrokenDesc
  329.     }
  330.  
  331.     wineCaveClue {
  332.       return $::lng::wineCaveClueDesc
  333.     }
  334.  
  335.     magicalStaff {
  336.       return $::lng::magicalStaffDesc
  337.     }
  338.  
  339.     doll {
  340.       return $::lng::dollDesc
  341.     }
  342.  
  343.     caretakerNote {
  344.       return $::lng::caretakerNoteDesc
  345.     }
  346.  
  347.     caretakerKey {
  348.       return [subst [subst {$::lng::caretakerKeyDesc}]]
  349.     }
  350.  
  351.     keyRing {
  352.       return $::lng::keyRingDesc
  353.     }
  354.  
  355.     noteBook {
  356.       return $::lng::noteBookDesc
  357.     }
  358.  
  359.     headenFlowerPage {
  360.       if { [ozGet "itemCirclet"] == "pickedUp" } {
  361.         return $::lng::headenFlowerPageWithCircletDesc
  362.       } else {
  363.         return $::lng::headenFlowerPageNoCircletDesc
  364.       }
  365.     }
  366.  
  367.     yewlockLeavesPage {
  368.       if { [ozGet "itemCirclet"] == "pickedUp" } {
  369.         return $::lng::yewlockLeavesPageWithCircletDesc
  370.       } else {
  371.         return $::lng::yewlockLeavesPageNoCircletDesc
  372.       }
  373.     }
  374.  
  375.     nigilisPage {
  376.       if { [ozGet "itemCirclet"] == "pickedUp" } {
  377.         return $::lng::nigilisPageWithCircletDesc
  378.       } else {
  379.         return $::lng::nigilisPageNoCircletDesc
  380.       }
  381.     }
  382.  
  383.     headenFlower {
  384.       return $::lng::headenFlowerDesc
  385.     }
  386.  
  387.     yewlockLeavesBlue {
  388.       return $::lng::yewlockLeavesDesc
  389.     }
  390.  
  391.     yewlockLeavesRed {
  392.       return $::lng::yewlockLeavesDesc
  393.     }
  394.  
  395.     yewlockLeavesWhite {
  396.       return $::lng::yewlockLeavesDesc
  397.     }
  398.  
  399.     yewlockLeavesYellow {
  400.       return $::lng::yewlockLeavesDesc
  401.     }
  402.  
  403.     nigilisSeed {
  404.       if { [ozGet "itemCirclet"] == "pickedUp" && [ozGet "itemPagesNigilis"] == "pickedUp" } {
  405.         return $::lng::nigilisSeedDesc
  406.       } else {
  407.         return $::lng::nigilisSeedUnknownDesc
  408.       }
  409.     }
  410.  
  411.     nigilisFruit {
  412.       return $::lng::nigilisFruitDesc
  413.     }
  414.  
  415.     catHair {
  416.       return $::lng::catHairDesc
  417.     }
  418.       
  419.     wolfDrool {
  420.       return $::lng::wolfDribbleDesc
  421.     }
  422.       
  423.     dragonClaw {
  424.       return $::lng::dragonClawDesc
  425.     }
  426.  
  427.     celeste {
  428.       return $::lng::celestePortraitDesc
  429.     }
  430.  
  431.     aleunderRoot {
  432.       return $::lng::aleunderDesc
  433.     }
  434.       
  435.     oracleMoss {
  436.       return $::lng::oracleMossDesc
  437.     }
  438.       
  439.     eternalFlame {
  440.       return $::lng::eternalFlameDesc
  441.     }
  442.       
  443.     pearl {
  444.       return $::lng::pearlDesc
  445.     }
  446.     
  447.     starFragment {
  448.       return $::lng::meteoriteDesc
  449.     }
  450.       
  451.     soulDust {
  452.       return $::lng::soulDustDesc
  453.     }
  454.       
  455.     orbNotes {
  456.       return $::lng::orbNotesDesc
  457.     }
  458.       
  459.     handWrittenNotes {
  460.       return $::lng::nathanielNoteDesc
  461.     }
  462.       
  463.     tapestryObservatory {
  464.       return $::lng::clueObservatoryDesc
  465.     }
  466.       
  467.     tapestryForge {
  468.       return $::lng::clueForgeDesc
  469.     }
  470.       
  471.     tapestryArtRoom {
  472.       return $::lng::clueArtRoomDesc
  473.     }
  474.       
  475.     tapestrySolarium {
  476.       return $::lng::clueSolariumDesc
  477.     }
  478.       
  479.     spellbook {
  480.       return $::lng::spellbookDesc
  481.     }
  482.       
  483.     libraryBallEntrance {
  484.       return $::lng::libraryBallDesc
  485.     }
  486.  
  487.     libraryBallPink {
  488.       return $::lng::libraryBallDesc
  489.     }
  490.  
  491.     libraryBallAqua {
  492.       return $::lng::libraryBallDesc
  493.     }
  494.  
  495.     libraryBallBrown {
  496.       return $::lng::libraryBallDesc
  497.     }
  498.   }
  499. }
  500.  
  501.  
  502. proc canZakTalk {} {
  503.     # Zoomin!
  504.     if {[ozGet "interface.backevent"] != ""} {
  505.         return 0
  506.     }
  507.  
  508.     # Interface?
  509.     if [oz'widget::visible? $::itf::sidebar] {
  510.         return 0
  511.     }
  512.     if [oz'widget::visible? $::itf::desc]    {
  513.         return 0
  514.     }
  515.  
  516.     # Zak Away from Lydia
  517.     if {[ozGet "zakPresence"] == "away"}      {
  518.         return 0
  519.     }
  520.     if {[ozGet "zakHide"]     == "initiated"} {
  521.         return 0
  522.     }
  523.  
  524.     # Char 3D hidden
  525.     if {![ozEntityLydia isvisible]} {
  526.         return 0
  527.     }
  528.     if {![ozEntityZak isvisible]}   {
  529.         return 0
  530.     }
  531.  
  532.     # Lydia speak with another NPC
  533.     if {[ozGet "npcDiscussion"] == "initiated"} {
  534.         return 0
  535.     }
  536.     if [ozIConv isVisible] {
  537.         return 0
  538.     }
  539.     if [ozITalk isVisible] {
  540.         return 0
  541.     }
  542.  
  543.     # Playing Zak
  544.     if {[ozGet "characterControlled"] == "Zak"}       {
  545.         return 0
  546.     }
  547.     if {[ozGet "mainCharacter"]       == "zak"}       {
  548.         return 0
  549.     }
  550.     if {[ozGet "sanctuaryZakSwitch"]  == "initiated"} {
  551.         return 0
  552.     }
  553.  
  554.     # Game is loading
  555.     if {!$::isGameReady} {
  556.         return 0
  557.     }
  558.  
  559.     # Lydia is Walking
  560.     if {![ozEntityLydia isidle]} {
  561.         return 0
  562.     }
  563.    
  564.     return 1
  565. }
  566.  
  567.  
  568. proc TooFarAway {} {
  569.     # FIXME: Text not in language!
  570.     wizqTalkOpen
  571.     if [expr int(rand() * 2)] {
  572.         wizqTalkSay Lydia "I am too far away to use this!" ""
  573.     } else {
  574.         wizqTalkSay Zak "You should get a little closer before using this." ""
  575.     }
  576.     wizqTalkClose
  577. }
  578.  
  579. proc CrashPlanB {} {
  580.     # FIXME: Text not in language!
  581.     if {[ozGet "puzzleMidgard"] != "complete"} {
  582.         oz'event {
  583.             ozEntityLydia set position 337 -19.7 -365
  584.             ozEntityZak set position 337 -19.7 -365
  585.             setScene dragonvaleAcademy world
  586.         }
  587.     } else {
  588.         oz'event {
  589.             ozEntityLydia set position 347 734 262
  590.             ozEntityZak set position 347 734 262
  591.             setScene mainBuilding world
  592.         }
  593.     }
  594.         
  595.     oz'event {showInterface}
  596.     oz'event {showMouse}
  597.     wizqTalkOpen
  598.     wizqTalkSay Unknown "Sorry, to prevent an unexpected error, we have teleported you to this location..." ""
  599.     wizqTalkClose
  600. }
  601.  
  602. proc CloseAllSounds {} {
  603.     oz'track::stop $::music_track
  604.  
  605.     foreach v [info vars ::sfx::*] {
  606.         oz'sound::fadeto [set $v] 0 5
  607.         set $v 0
  608.     }
  609. }
  610.