home *** CD-ROM | disk | FTP | other *** search
/ hobbes.nmsu.edu 2008 / 2008-06-02_hobbes.nmsu.edu.zip / new / scummc-0.2.0-os2.zip / ScummC / examples / road / road.scc < prev    next >
Encoding:
Text File  |  2006-12-01  |  13.6 KB  |  469 lines

  1. /* ScummC
  2.  * Copyright (C) 2006  Alban Bedel
  3.  *
  4.  * This program is free software; you can redistribute it and/or
  5.  * modify it under the terms of the GNU General Public License
  6.  * as published by the Free Software Foundation; either version 2
  7.  * of the License, or (at your option) any later version.
  8.  
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  17.  *
  18.  */
  19.  
  20. // include all the vars used by the engine itself
  21. #include <scummVars6.s>
  22. #include "common.sch"
  23.  
  24. bit welcomed,lost,santaHello,santaPlace,santaReal;
  25. actor santa;
  26. #define SANTA_COLOR 14
  27.  
  28. // our room
  29. room Road {
  30.     // first we define the room parameters
  31.     // the background picture
  32.     image = "road.bmp";
  33.     // the zplanes
  34.     zplane = { "road_mask1.bmp", "road_mask2.bmp" };
  35.  
  36.     boxd = "road.box";
  37.     trans = 0;
  38.  
  39.     //cycle testCycl = { 60, 0, 103, 111 };
  40.     cost santaCost = "santa.cost";
  41.  
  42.     voice letsgothere = { "letsgothere.voc", 500 };
  43.     voice welcome = { "welcome.voc" };
  44.     voice tv = { "file.voc" };
  45.  
  46.     object axe;
  47.  
  48.     object leftDoor {
  49.         x = 152;
  50.         y = 35;
  51.         dir = NORTH;
  52.         name = "the door";
  53.         class = { Openable };
  54.         states = { 
  55.             { 8, 40, "door_left.bmp", { "", "" } }
  56.         };
  57.         state = 0;
  58.  
  59.         verb(int vrb,int objA, int objB) {
  60.         case SetBoxes:
  61.             if(vrb == Open)
  62.                 setBoxFlags( [ openDoor ], 0x80);
  63.             else
  64.                 setBoxFlags( [ openDoor ], 0);
  65.             createBoxMatrix();
  66.             return;
  67.  
  68.         case WalkTo:
  69.             if(getObjectState(objA))
  70.                 egoSay("Even open, this door is way too small for me.");
  71.             else
  72.                 egoSay("It's closed.");
  73.             return;
  74.  
  75.         case Use:
  76.             if(objB) {
  77.                 if(objB == axe)
  78.                     egoSay("I don't want to destroy this door.");
  79.                 else
  80.                     egoSay("That doesn't make much sense.");
  81.                 return;
  82.             }
  83.             if(getObjectState(objA))
  84.                 doSentence(Close,objA,0,0);
  85.             else
  86.                 doSentence(Open,objA,0,0);
  87.         }
  88.     }
  89.  
  90.     object window {
  91.         x = 112;
  92.         y = 46;
  93.         w = 32;
  94.         h = 16;
  95.         hs_x = 16;
  96.         hs_y = 30;
  97.         dir = NORTH;
  98.         name = "the window";
  99.     }
  100.  
  101.     object river {
  102.         x = 0;
  103.         y = 0;
  104.         w = 48;
  105.         h = 20;
  106.         hs_x = 33;
  107.         hs_y = 15;
  108.         dir = WEST;
  109.         name = "the river";
  110.  
  111.         verb(int vrb,int objA, int objB) {
  112.         case LookAt:
  113.             cutscene() {
  114.                 egoSay("Wa _ Water ??\wI hate that stuff.");
  115.                 waitForMessage();
  116.             }
  117.  
  118.         case Use:
  119.             if(objB == axe)
  120.                 egoSay("A axe is not that great to fish.");
  121.             else
  122.                 egoSay("Don't even think about it.");
  123.             return;
  124.         
  125.         case PickUp:
  126.             egoSay("I need something to put the water in.");
  127.             return;
  128.         }
  129.     }
  130.  
  131.     object axe {
  132.         x = 320;
  133.         y = 27;
  134.         w = 16;
  135.         h = 8;
  136.         class = { Pickable };
  137.         states = {
  138.             { 0, 16, "axe.bmp",
  139.               { "", "axe_mask2.bmp" } }
  140.         };
  141.         name = "the axe";
  142.         dir = EAST;
  143.  
  144.         
  145.         verb(int vrb,int objA,int objB) {
  146.         case Icon:
  147.             startScript2(vrb, [ ResRoom::axe, objA, objB ]);
  148.             return;
  149.         case Preposition:
  150.             if(vrb == Give)
  151.                 sntcPrepo[0] = "to";
  152.             else
  153.                 sntcPrepo[0] = "on";
  154.             return;
  155.  
  156.         case LookAt:
  157.             if(getObjectOwner(objA) == VAR_EGO)
  158.                 egoSay("It's really sharp.");
  159.             else
  160.                 egoSay("Look nice !");
  161.             return;
  162.  
  163.         case PickUp:
  164.             egoSay("Cool");
  165.             pickupObject(objA,VAR_ROOM);
  166.         }
  167.     }
  168.  
  169.     object santaObj {
  170.         name = "Santa";
  171.         verb(int vrb,int objA,int objB) {
  172.             char* sentence;
  173.             int asked;
  174.         case TalkTo:
  175.             cutscene(1) {
  176.                 egoSay("Hey Santa!");
  177.                 waitForMessage();
  178.                 unless(santaHello) {
  179.                     actorSay(santa,"Yes, and you are ?");
  180.                     waitForMessage();
  181.                 }
  182.             }
  183.             unless(santaHello) {
  184.                 santaHello = 1;
  185.                 sentence[0] = "Beasty, a fearsome fighter from the Evil!";
  186.                 ResRoom::dialogAdd(sentence);
  187.                 // This is needed otherwise the next asignement would
  188.                 // just realloc the array.
  189.                 sentence = 0;
  190.                 sentence[0] = "Beasty, from the Kingdom Der Evil.";
  191.                 ResRoom::dialogAdd(sentence);
  192.                 sentence = 0;
  193.                 sentence[0] = "Beasty, an OS mascot.";
  194.                 ResRoom::dialogAdd(sentence);
  195.                 sentence = 0;
  196.                 sentence[0] = "Beasty, a red guy with a trident.";
  197.                 ResRoom::dialogAdd(sentence);
  198.                 sentence = 0;
  199.                 sentence[0] = "Beasty, a poor chap who lost his way.";
  200.                 ResRoom::dialogAdd(sentence);
  201.                 sentence = 0;
  202.                 sentence[0] = "Beasty, a deamon.";
  203.                 ResRoom::dialogAdd(sentence);
  204.                 sentence = 0;
  205.                 sentence[0] = "Beasty, ready to bring you hell.";
  206.                 ResRoom::dialogAdd(sentence);
  207.                 sentence = 0;
  208.                 ResRoom::dialogStart(BEASTY_DIM_COLOR,BEASTY_COLOR);
  209.                 do breakScript() while(selectedSentence < 0);
  210.                 ResRoom::dialogHide();
  211.                 cutscene() {
  212.                     sentence = dialogList[selectedSentence];
  213.                     egoSay("%s{sentence}");
  214.                     waitForMessage();
  215.                     switch(selectedSentence) {
  216.                     case 0:
  217.                         actorSay(santa,"That sure sound very impressing.");
  218.                         break;
  219.                     case 1:
  220.                         actorSay(santa,"Isn't that the place where everything is named K-something?");
  221.                         break;
  222.                     case 2:
  223.                         actorSay(santa,"Can't be worse than beeing a children mascot.");
  224.                         break;
  225.                     }
  226.                     waitForMessage();
  227.                 }
  228.                 ResRoom::dialogClear(1);
  229.  
  230.                 if(selectedSentence == 1) {
  231.                     sentence[0] = "Indeed, and we like it this way!";
  232.                     ResRoom::dialogAdd(sentence);
  233.                     sentence = 0;
  234.                     sentence[0] = "That's the place, anything against Ks?";
  235.                     ResRoom::dialogAdd(sentence);
  236.                     sentence = 0;
  237.                     ResRoom::dialogStart(BEASTY_DIM_COLOR,BEASTY_COLOR);
  238.                     do breakScript() while(selectedSentence < 0);
  239.                     ResRoom::dialogHide();
  240.                     cutscene() {
  241.                         sentence = dialogList[selectedSentence];
  242.                         egoSay("%s{sentence}");
  243.                         waitForMessage();
  244.                         if(selectedSentence == 1) {
  245.                             actorSay(santa,"Not really.\wI just tend to prefer Gs.");
  246.                             waitForMessage();
  247.                         }
  248.                     }
  249.                     ResRoom::dialogClear(1);
  250.                 }
  251.             }
  252.             cutscene() {
  253.                 actorSay(santa,"What do you want?");
  254.                 waitForMessage();
  255.             }
  256.             dialogLoop: while(1) {
  257.                 unless(santaPlace)
  258.                     sentence[0] = "What is this place?";
  259.                 else
  260.                     sentence = 0;
  261.                 ResRoom::dialogAdd(sentence);
  262.                 sentence = 0;
  263.                 unless(santaReal)
  264.                     sentence[0] = "Are you really Santa, or just some guy in a red coat?";
  265.                 ResRoom::dialogAdd(sentence);
  266.                 sentence = 0;
  267.                 if(asked)
  268.                     sentence[0] = "Have a nice day.";
  269.                 else
  270.                     sentence[0] = "Nothing. Have a nice day.";
  271.                 ResRoom::dialogAdd(sentence);
  272.                 sentence = 0;
  273.                 asked = 1;
  274.                 ResRoom::dialogStart(BEASTY_DIM_COLOR,BEASTY_COLOR);
  275.                 do breakScript() while(selectedSentence < 0);
  276.                 ResRoom::dialogHide();
  277.                 cutscene() {
  278.                     sentence = dialogList[selectedSentence];
  279.                     egoSay("%s{sentence}");
  280.                     waitForMessage();
  281.                     switch(selectedSentence) {
  282.                     case 0:
  283.                         actorSay(santa,"It's the Grand Nation Of Maximum Eccentricity.");
  284.                         santaPlace = 1;
  285.                         break;
  286.                     case 1:
  287.                         actorSay(santa,"I'am the real Santa.\wBut not on duty so don't expect presents or anything.");
  288.                         santaReal = 1;
  289.                         break;
  290.                     case 2:
  291.                         actorSay(santa,"Bye.");
  292.                         break;
  293.                     }
  294.                     waitForMessage();
  295.                 }
  296.                 ResRoom::dialogClear(1);
  297.                 if(selectedSentence == 2) break dialogLoop;
  298.             }
  299.             ResRoom::dialogEnd();
  300.             return;
  301.  
  302.         case Use:
  303.             if(objB == axe)
  304.                 egoSay("Killing him won't help us.");
  305.             else
  306.                 egoSay("I can't just *use* someone.");
  307.         }
  308.     }
  309.  
  310.     local script walkOut(int eff) {
  311.         screenEffect(eff);
  312.         startRoom(Road);
  313.     }
  314.  
  315.     object exitSouth {
  316.         x = 0;
  317.         y = 128;
  318.         w = 108;
  319.         h = 16;
  320.         hs_x = 50;
  321.         hs_y = 4;
  322.         name = "the road going out";
  323.         dir = SOUTH;
  324.  
  325.         verb(int vrb, int objA, int objB) {
  326.         case WalkTo:
  327.         case Use:
  328.             walkOut(0x8787);
  329.         }
  330.  
  331.     }
  332.  
  333.     object exitEast {
  334.         x = 472;
  335.         y = 72;
  336.         w = 16;
  337.         h = 48;
  338.         hs_x = 5;
  339.         hs_y = 24;
  340.         name = "the road going out";
  341.         dir = EAST;
  342.  
  343.         verb(int vrb, int objA, int objB) {
  344.         case WalkTo:
  345.         case Use:
  346.             walkOut(0x8686);
  347.         }
  348.  
  349.     }
  350.  
  351.     object exitNorth {
  352.         x = 410;
  353.         y = 0;
  354.         w = 72;
  355.         h = 16;
  356.         hs_x = 36;
  357.         hs_y = 8;
  358.         name = "the road going out";
  359.         dir = NORTH;
  360.  
  361.         verb(int vrb, int objA, int objB) {
  362.         case WalkTo:
  363.         case Use:
  364.             walkOut(0x8080);
  365.         }
  366.  
  367.     }
  368.  
  369.     // This script is executed when the room is loaded
  370.     local script entry() {
  371.  
  372.         dbgPrintBegin();
  373.         dbgPrint("Entry");
  374.         dbgPrintEnd();
  375.  
  376.         // our palette is buggy, fix it
  377.         setRoomColor(0,0,0,0);
  378.  
  379.         // Setup the santa
  380.         setCurrentActor(santa);
  381.         initActor();
  382.         setActorCostume(santaCost);
  383.         setActorTalkPos(-60,-60);
  384.         setActorName("Santa");
  385.         setActorTalkColor(SANTA_COLOR);
  386.         setActorAnimSpeed(2);
  387.         actorObject[santa] = santaObj;
  388.         // allow it to be outside of the walk boxes
  389.         setActorIgnoreBoxes();
  390.         putActorAt(santa,20,90,Road);
  391.         // run the "standing" anim
  392.         setActorStanding();
  393.         setCurrentActor(VAR_EGO);
  394.  
  395.         // init the print slot
  396.         egoPrintBegin();
  397.         actorPrintOverhead();
  398.         actorPrintEnd();
  399.         
  400.  
  401.         unless(welcomed) {
  402.             putActorAt(VAR_EGO,440,0,Road);
  403.             try {
  404.                 setCameraAt(0);
  405.                 panCameraTo(440);
  406.                 waitForCamera();
  407.                 cameraFollowActor(VAR_EGO);
  408.                 walkActorTo(hero,430,80);
  409.                 waitForActor(hero);
  410.                 
  411.                 egoSay("Hello mortal.");
  412.                 waitForMessage();
  413.                 egoSay("Welcome to the first GPL Scumm game !!!");
  414.                 waitForMessage();
  415.             } override {
  416.                 if(VAR_OVERRIDE) {
  417.                     setCameraAt(440);
  418.                     putActorAt(VAR_EGO,430,80,Road);
  419.                     setActorStanding();
  420.                     cameraFollowActor(VAR_EGO);
  421.                 }
  422.             }
  423.             welcomed = 1;
  424.         } else {
  425.      
  426.             switch(getRandomNumber(2)) {
  427.             case 0:
  428.                 putActorAt(VAR_EGO,488,90,Road);
  429.                 setCurrentActor(VAR_EGO);
  430.                 setActorDirection(WEST);
  431.                 cameraFollowActor(VAR_EGO);
  432.                 walkActorTo(hero,420,90);
  433.                 break;
  434.             case 1:
  435.                 putActorAt(VAR_EGO,460,0,Road);
  436.                 cameraFollowActor(VAR_EGO);
  437.                 walkActorTo(hero,450,40);
  438.                 break;
  439.             case 2:
  440.                 putActorAt(VAR_EGO,60,144,Road);
  441.                 setCurrentActor(VAR_EGO);
  442.                 setActorDirection(NORTH);
  443.                 cameraFollowActor(VAR_EGO);
  444.                 walkActorTo(hero,80,120);
  445.                 break;
  446.             }
  447.  
  448.             unless(lost) {
  449.                 waitForActor(hero);
  450.                 egoSay("I think I'm lost.");
  451.                 lost = 1;
  452.             }
  453.         }
  454.  
  455.         ResRoom::showVerbs(1);
  456.         ResRoom::showCursor();
  457.     }
  458.  
  459.     local script exit() {
  460.         dbgPrintBegin();
  461.         dbgPrint("Exit");
  462.         dbgPrintEnd();
  463.  
  464.         ResRoom::hideCursor();
  465.     }
  466.  
  467.  
  468. }
  469.