ucmachine.h

Go to the documentation of this file.
00001 /*
00002  *  ucmachine.cc - Interpreter for usecode.
00003  *
00004  *  Copyright (C) 1999  Jeffrey S. Freedman
00005  *  Copyright (C) 2000-2001  The Exult Team
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00020  */
00021 
00022 #ifndef UCMACHINE_H
00023 #define UCMACHINE_H
00024 
00025 #ifndef ALPHA_LINUX_CXX
00026 #  include <iosfwd>
00027 #endif
00028 
00029 class Game_window;
00030 class Usecode_machine;
00031 class Conversation;
00032 class Keyring;
00033 class Game_object;
00034 class Actor;
00035 
00036 #include "exceptions.h"
00037 #include "singles.h"
00038 
00039 /*
00040  *  Here's our virtual machine for running usecode.  The actual internals
00041  *  are in Usecode_internal.
00042  */
00043 class Usecode_machine : public Game_singletons
00044   {
00045   UNREPLICATABLE_CLASS(Usecode_machine);
00046 protected:
00047   unsigned char gflags[1024]; // Global flags.
00048   Keyring* keyring;
00049   Conversation *conv;   // Handles conversations
00050 public:
00051   friend class Usecode_script;
00052           // Create Usecode_internal.
00053   static Usecode_machine *create();
00054   Usecode_machine();
00055   virtual ~Usecode_machine();
00056           // Read in usecode functions.
00057   virtual void read_usecode(std::istream& file, bool patch = false) = 0;
00058           // Possible events:
00059   enum Usecode_events {
00060     npc_proximity = 0,
00061     double_click = 1,
00062     internal_exec = 2,  // Internal call via intr. 1 or 2.
00063     egg_proximity = 3,
00064     weapon = 4,   // From weapons.dat.
00065     readied = 5,    // Wear an item.
00066     unreadied = 6,    // Removed an item.
00067     died = 7,   // In SI only, I think.
00068     chat = 9  // When a NPC wants to talk to you in SI
00069     };
00070   enum Global_flag_names {
00071     did_first_scene = 0x3b, // Went through 1st scene with Iolo.
00072     have_trinsic_password = 0x3d,
00073     found_stable_key = 0x48,
00074     left_trinsic = 0x57,
00075     avatar_is_thief = 0x2eb
00076     };
00077   int get_global_flag(int i)  // Get/set ith flag.
00078     { return gflags[i]; }
00079   void set_global_flag(int i, int val = 1)
00080     { gflags[i] = (val == 1); }
00081           // Start speech, or show text.
00082   virtual void do_speech(int num) = 0;
00083   virtual int in_usecode() = 0; // Currently in a usecode function?
00084   Keyring* getKeyring() const { return keyring; }
00085           // Call desired function.
00086   virtual int call_usecode(int id, Game_object *obj, 
00087             Usecode_events event) = 0;
00088   virtual void write() = 0; // Write out 'gamedat/usecode.dat'.
00089   virtual void read() = 0;  // Read in 'gamedat/usecode.dat'.
00090 
00091   void init_conversation();
00092   int get_num_faces_on_screen() const;
00093 
00094   // intercept the next click_on_item intrinsic
00095   virtual void intercept_click_on_item(Game_object *obj) = 0;
00096 
00097   };
00098 
00099 #endif  /* INCL_USECODE */

Generated on Mon Jul 9 14:42:52 2007 for ExultEngine by  doxygen 1.5.1