combat.h

Go to the documentation of this file.
00001 /*
00002  *  combat.h - Combat scheduling.
00003  *
00004  *  Copyright (C) 2000-2001  The Exult Team
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019  */
00020 
00021 #ifndef COMBAT_H
00022 #define COMBAT_H  1
00023 
00024 #include "schedule.h"
00025 #include "lists.h"
00026 
00027 class Actor;
00028 class Spellbook_object;
00029 
00030 /*
00031  *  Combat schedule:
00032  */
00033 class Combat_schedule : public Schedule
00034   {
00035 protected:
00036   static unsigned long battle_time;// Time when battle started.
00037   static unsigned long battle_end_time; // And when it ended.
00038   enum Phase      // We'll be a finite-state-machine.
00039     {
00040     initial = 0,    // Just constructed.
00041     approach = 1,   // Approaching a foe to attack.
00042     retreat = 2,    // Avoiding a foe.
00043     flee = 3,   // Run away!
00044     strike = 4,   // In the process of striking.
00045     fire = 5,   // In process of firing range weapon.
00046     parry = 6,    // In the process of parrying a blow.
00047     stunned = 7,    // Just been hit.
00048     wait_return = 8   // Wait for boomerang.
00049     } state;
00050   Schedule_types prev_schedule; // Before going into combat.
00051   Actor_queue opponents;    // Possible opponents.
00052   Game_object *practice_target; // Only for duel schedule.
00053   int weapon_shape;   // Weapon's shape in shapes.vga.
00054   int ammo_shape;     // If required, else 0.
00055   int projectile_shape;   // For shooting, else 0.
00056   Spellbook_object *spellbook;  // If readied.
00057           // Ranges in tiles.  
00058           //   0 means not applicable.
00059   unsigned char strike_range, projectile_range, max_range;
00060   bool is_thrown;     // Daggers, etc.
00061   bool returns;     // Boomerang, magic axe.
00062   bool no_blocking;   // Weapon/ammo goes through walls.
00063   unsigned char yelled;   // Yell when first opponent targeted.
00064   bool started_battle;    // 1st opponent targeted.
00065   unsigned char fleed;    // Incremented when fleeing.
00066   bool can_yell;
00067   int failures;     // # failures to find opponent.
00068   unsigned int teleport_time; // Next time we can teleport.
00069   void start_battle();    // Play music at start of battle.
00070   bool teleport();    // For monsters that can.
00071   virtual void find_opponents();
00072   Actor *find_protected_attacker();// Find attacker of protected member.
00073   Game_object *find_foe(int mode);// Find a new opponent.
00074   Game_object *find_foe();
00075   void approach_foe();    // Approach foe.
00076   void start_strike();
00077   void run_away();
00078   Spellbook_object *readied_spellbook();
00079 public:
00080   Combat_schedule(Actor *n, Schedule_types prev_sched);
00081   static void monster_died(); // Checks for victory.
00082   virtual void now_what();  // Npc calls this when it's done
00083   virtual void im_dormant();  // Npc calls this when it goes dormant.
00084   virtual void ending(int newtype);// Switching to another schedule.
00085   virtual void set_weapon();  // Set weapon info.
00086   bool has_started_battle() const
00087     { return started_battle; }
00088   };
00089 
00090 /*
00091  *  Dueling is like combat, but nobody gets hurt.
00092  */
00093 
00094 class Duel_schedule : public Combat_schedule
00095   {
00096   Tile_coord start;   // Starting position.
00097   int attacks;      // Count strikes.
00098   virtual void find_opponents();
00099 public:
00100   Duel_schedule(Actor *n);
00101   virtual void now_what();
00102   };
00103 
00104 bool In_ammo_family(int shnum, int family);// Yow, a global function.
00105 
00106 #endif

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