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 / openquest / inventoryitems.scc < prev    next >
Encoding:
Text File  |  2008-04-06  |  8.6 KB  |  286 lines

  1. /* ScummC
  2.  * Copyright (C) 2007  Alban Bedel, Gerrit Karius
  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 <scummVars6.s>
  21. #include "common.sch"
  22. #include "inventoryitems.sch"
  23. #include "actors.sch"
  24. #include "secretroom.sch"
  25.  
  26. #include "zob_anim.sch"
  27.  
  28. room InventoryItems {
  29.  
  30.     voice loadingGunSnd = { "sounds/loading_gun.voc" };
  31.     // the inventory icons
  32.     
  33.     
  34.     object axe {
  35.         w = 40;
  36.         h = 16;
  37.         x = 0;
  38.         name = "the axe";
  39.         states = {
  40.             { 0, 0, "graphics/inventory_items/inv_axe.bmp" }
  41.         };
  42.         state = 1;
  43.  
  44.         verb(int vrb,int objA,int objB) {
  45.         case Icon:
  46.             startScript2(vrb, [ InventoryItems::axe, objA, objB ]);
  47.             return;
  48.         }
  49.     }
  50.     
  51.     object gun {
  52.         name = "gun";
  53.         states = {
  54.             { 0, 0, "graphics/inventory_items/gun_40.bmp" }
  55.         };
  56.         state = 0;
  57.  
  58.         verb(int vrb,int objA,int objB) {
  59.         case LookAt:
  60.             egoSay("A crude ballistic firearm fashioned from a primitive alloy.");
  61.             return;
  62.         case Preposition:
  63.             if(vrb == Give)
  64.                 sntcPrepo[0] = "to";
  65.             else
  66.                 sntcPrepo[0] = "on";
  67.             return;
  68.         case Use:
  69.             switch(objB) {
  70.             case carol:
  71.                 egoSay("Terminating this lifeform could attract unwarranted attention.");
  72.                 if(getObjectState(gun) < 2) {
  73.                     waitForMessage();
  74.                     egoSay("And the weapon is not loaded anyway.");
  75.                 }
  76.                 break;
  77.             default:
  78.                 ResRoom::defaultAction(vrb,objA,objB);
  79.             }
  80.             return;
  81.         case Give:
  82.             switch(objB) {
  83.             case commanderZif:
  84.                 if( ! SecretRoom::hasShotAtNode ) {
  85.                     egoSay("And lose my advantage?");
  86.                     return;
  87.                 }
  88.                 SecretRoom::outro();
  89.                 break;
  90.             default:
  91.                 egoSay("I might need this.");
  92.             }
  93.             return;
  94.         }
  95.     }
  96.  
  97.     // This is in a separate script because calling setObjectOwner()
  98.     // kill the object's script
  99.     script loadGun() {
  100.         setObjectState( gun, 2 );
  101.         setObjectOwner( bullets, 0 );
  102.         dbgPrint("%V{loadingGunSnd}");
  103.         egoSay("The weapon has been loaded.");
  104.     }
  105.  
  106.     object bullets {
  107.         name = "ammunition";
  108.         states = {
  109.             { 0, 0, "graphics/inventory_items/bullets.bmp" }
  110.         };
  111.         verb(int vrb,int objA,int objB) {
  112.         case LookAt:
  113.             egoSay("This ammunition may be compatible with a projectile weapon.");
  114.             return;
  115.         case Preposition:
  116.             if(vrb == Give)
  117.                 sntcPrepo[0] = "to";
  118.             else
  119.                 sntcPrepo[0] = "with";
  120.             return;
  121.         case UsedWith:
  122.         case Use:
  123.             switch(objB) {
  124.             case gun:
  125.                 loadGun();
  126.                 break;
  127.             default:
  128.                 ResRoom::defaultAction(vrb,objA,objB);
  129.             }
  130.             return;
  131.         }
  132.     }
  133.  
  134.     object card {
  135.         name = "card";
  136.         states = {
  137.             { 0, 0, "graphics/inventory_items/card.bmp" }
  138.         };
  139.         verb(int vrb,int objA,int objB) {
  140.         case LookAt:
  141.             egoSay("This device could be used to interact with some form of hardware.");
  142.             return;
  143.         case Preposition:
  144.             if(vrb == Give)
  145.                 sntcPrepo[0] = "to";
  146.             else
  147.                 sntcPrepo[0] = "on";
  148.             return;
  149.         case Use:
  150.             switch(objB) {
  151.             case scanner:
  152.                 egoSay("The key isn't compatible with this model.");
  153.                 break;
  154.             default:
  155.                 ResRoom::defaultAction(vrb,objA,objB);
  156.                 break;
  157.             }
  158.             return;
  159.         case Give:
  160.             switch(objB) {
  161.             case carol:
  162.                 actorSay(carol,"I see you've got mainframe clearance.\w"
  163.                          "I'm gonna be dusting in there soon.\w"
  164.                          "Try and keep it tidy.");
  165.                 break;
  166.             case commanderZif:
  167.                 Actors::pauseRoaming(commanderZif);
  168.                 actorSay(commanderZif,"Excellent work Zob, a key.\w"
  169.                          "Keep this, use it to infiltrate the mainframe.");
  170.                 waitForMessage();
  171.                 Actors::resumeRoaming(commanderZif);
  172.                 break;
  173.             default:
  174.                 ResRoom::defaultAction(vrb,objA,objB);
  175.                 break;
  176.             }
  177.             return;
  178.         }
  179.     }
  180.  
  181.     object batteries {
  182.         name = "batteries";
  183.         states = {
  184.             { 0, 0, "graphics/inventory_items/batteries.bmp" }
  185.         };
  186.  
  187.         verb(int vrb,int objA,int objB) {
  188.         case LookAt:
  189.             egoSay("They used to power the hand scanner.");
  190.             return;
  191.         case Preposition:
  192.             if(vrb == Give)
  193.                 sntcPrepo[0] = "to";
  194.             else
  195.                 sntcPrepo[0] = "with";
  196.             return;
  197.         case Use:
  198.             switch(objB) {
  199.             case scanner:
  200.                 egoSay("They won't go back in.");
  201.                 break;
  202.             default:
  203.                 ResRoom::defaultAction(vrb,objA,objB);
  204.                 break;
  205.             }
  206.         }
  207.     }
  208.  
  209.     object scanner {
  210.         w = 40;
  211.         h = 16;
  212.         x = 0;
  213.         name = "scanner";
  214.         states = {
  215.             { 0, 0, "graphics/inventory_items/scanner_40.bmp" },
  216.             { 0, 0, "graphics/inventory_items/scanner_dead_40.bmp" }
  217.         };
  218.         state = 1;
  219.  
  220.         verb(int vrb,int objA,int objB) {
  221.         case LookAt:
  222.             egoSay("Standard issue hand scanner.");
  223.             waitForMessage();
  224.             egoSay("Detects most of the EM spectrum.");
  225.             return;
  226.         case Use:
  227.             if( getObjectState( scanner ) == 2 ) {
  228.                 egoSay("The scanner no longer functions.");
  229.                 return;
  230.             }
  231.             egoSay("I'll scan the area.");
  232.             waitForMessage();
  233.             animateActor(VAR_EGO, zob_anim_scan);
  234.             delay(30);
  235.             animateActor(VAR_EGO, zob_anim_scan);
  236.             delay(30);
  237.             animateActor(VAR_EGO, zob_anim_scan);
  238.             delay(30);
  239.             if( getActorRoom(VAR_EGO) == SecretRoom )
  240.                 egoSay("The artifact is in this room.");
  241.             else
  242.                 egoSay("I am detecting the artifact near this location.");
  243.             return;
  244.         case Preposition:
  245.             if(vrb == Give)
  246.                 sntcPrepo[0] = "to";
  247.             return;
  248.         case Give:
  249.             switch(objB) {
  250.             case commanderZif:
  251.                 Actors::pauseRoaming(commanderZif);
  252.                 actorSay(commanderZif,"You're the scientist on this team, you use it.");
  253.                 waitForMessage();
  254.                 Actors::resumeRoaming(commanderZif);
  255.                 break;
  256.             default:
  257.                 ResRoom::defaultAction(vrb,objA,objB);
  258.             }
  259.             return;
  260.         case Open:
  261.             if( getObjectState( scanner ) == 2 ) {
  262.                 egoSay("The casing appears to be broken.");
  263.                 return;
  264.             }
  265.             egoSay("I'll open up the housing.");
  266.             waitForMessage();
  267.             pickupObject( batteries, InventoryItems );
  268.             /*
  269.             pickupObject( InventoryItems::batteries2, InventoryItems );
  270.             pickupObject( InventoryItems::batteries3, InventoryItems );
  271.             pickupObject( InventoryItems::batteries4, InventoryItems );
  272.             pickupObject( InventoryItems::batteries5, InventoryItems );
  273.             pickupObject( InventoryItems::batteries6, InventoryItems );
  274.             pickupObject( InventoryItems::batteries7, InventoryItems );
  275.             pickupObject( InventoryItems::batteries8, InventoryItems );
  276.             */
  277.             setObjectState( objA, 2 );
  278.             drawObject( objA, 2 );
  279.             egoSay("The batteries have fallen out.");
  280.  
  281.             return;
  282.         }
  283.     }
  284.  
  285. }
  286.