1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
|
/*
* Copyright (C) 1998-1999 Jeffrey S. Freedman
* Copyright (C) 2000-2001 The Exult Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef INCL_EGG
#define INCL_EGG 1
class Egg_object;
class Animated_egg_object;
class Animator;
class Monster_actor;
class Missile_launcher;
#include "iregobjs.h"
/*
* Here's a class for eggs and paths; i.e., objects that generally aren't
* visible.
*/
class Egglike_game_object : public Ireg_game_object
{
public:
Egglike_game_object(int shapenum, int framenum,
unsigned int tilex,
unsigned int tiley, unsigned int lft = 0)
: Ireg_game_object(shapenum, framenum, tilex, tiley, lft)
{ }
// Render.
virtual void paint();
// Can this be clicked on?
virtual int is_findable();
};
/*
* An "egg" is a special object that activates under certain
* circumstances.
*/
class Egg_object : public Egglike_game_object
{
static Egg_object *editing; // Egg being edited by ExultStudio.
protected:
unsigned char type; // One of the below types.
unsigned char probability; // 1-100, chance of egg activating.
unsigned char criteria:3; // How it's activated. See below.
unsigned distance:6; // Distance for activation (0-31).
unsigned flags:4; // Formed from below flags.
unsigned short data1, data2; // More data, depending on type.
Rectangle area; // Active area.
unsigned char solid_area; // 1 if area is solid, 0 if outline.
Missile_launcher *launcher; // For missile eggs.
void init_field(unsigned char ty);
void activate_teleport(Game_object *obj); // Handle teleport egg.
public:
enum Egg_types { // Types of eggs:
monster = 1,
jukebox = 2,
soundsfx = 3,
voice = 4,
usecode = 5,
missile = 6,
teleport = 7,
weather = 8,
path = 9,
button = 10,
// Our own:
fire_field = 128,
sleep_field = 129,
poison_field = 130,
caltrops_field = 131,
mirror_object = 132
};
enum Egg_flag_shifts {
nocturnal = 0,
once = 1,
hatched = 2,
auto_reset = 3
};
enum Egg_criteria {
cached_in = 0, // Activated when chunk read in?
party_near = 1,
avatar_near = 2, // Avatar steps into area.
avatar_far = 3, // Avatar steps outside area.
avatar_footpad = 4, // Avatar must step on it.
party_footpad = 5,
something_on = 6, // Something placed on/near it.
external_criteria = 7 // Appears on Isle of Avatar. Guessing
// these set off all nearby.
};
// Create normal eggs.
Egg_object(int shapenum, int framenum, unsigned int tilex,
unsigned int tiley, unsigned int lft,
unsigned short itype,
unsigned char prob, short d1, short d2);
// Ctor. for fields:
Egg_object(int shapenum, int framenum, unsigned int tilex,
unsigned int tiley, unsigned int lft,
unsigned char ty);
virtual ~Egg_object();
virtual void set_area(); // Set up active area.
int get_distance() const
{ return distance; }
int get_criteria() const
{ return criteria; }
int get_type() const
{ return type; }
// Can it be activated?
virtual int is_active(Game_object *obj,
int tx, int ty, int tz, int from_tx, int from_ty);
Rectangle get_area() const // Get active area.
{ return area; }
int is_solid_area() const
{ return solid_area; }
// Render.
virtual void paint();
// Run usecode function.
virtual void activate(int event = 1);
virtual bool edit(); // Edit in ExultStudio.
// Saved from ExultStudio.
static void update_from_studio(unsigned char *data, int datalen);
virtual void activate(Game_object *obj, bool must = false);
void print_debug();
static void set_weather(int weather, int len = 15,
Game_object *egg = 0);
// Move to new abs. location.
virtual void move(int newtx, int newty, int newlift);
// Remove/delete this object.
virtual void remove_this(int nodel = 0);
virtual int is_egg() const // An egg?
{ return 1; }
// Write out to IREG file.
virtual void write_ireg(DataSource* out);
// Get size of IREG. Returns -1 if can't write to buffer
virtual int get_ireg_size();
virtual void reset()
{ flags &= ~(1 << hatched); }
virtual Egg_object *as_egg() { return this; }
};
/*
* An object that cycles through its frames, or wiggles if just one
* frame.
*/
class Animated_egg_object : public Egg_object
{
protected:
Animator *animator; // Controls animation.
public:
Animated_egg_object(int shapenum, int framenum,
unsigned int tilex,
unsigned int tiley, unsigned int lft,
unsigned short itype,
unsigned char prob, short d1, short d2);
Animated_egg_object(int shapenum, int framenum, unsigned int tilex,
unsigned int tiley, unsigned int lft,
unsigned char ty);
virtual ~Animated_egg_object();
// Render.
virtual void paint();
// Can this be clicked on?
virtual int is_findable()
{ return Ireg_game_object::is_findable(); }
// Run usecode function.
virtual void activate(int event = 1);
void stop_animation();
};
/*
* Fields are activated like eggs.
*/
class Field_object : public Animated_egg_object
{
bool field_effect(Actor *actor);// Apply field.
public:
Field_object(int shapenum, int framenum, unsigned int tilex,
unsigned int tiley, unsigned int lft, unsigned char ty)
: Animated_egg_object(shapenum, framenum, tilex, tiley,
lft, ty)
{ }
// Run usecode function.
virtual void activate(int event = 1);
virtual void activate(Game_object *obj, bool must = false);
// Write out to IREG file.
virtual void write_ireg(DataSource* out);
// Get size of IREG. Returns -1 if can't write to buffer
virtual int get_ireg_size();
};
/*
* Mirrors are handled like eggs.
*/
class Mirror_object : public Egg_object
{
public:
Mirror_object(int shapenum, int framenum, unsigned int tilex,
unsigned int tiley, unsigned int lft);
// Run usecode function.
virtual void activate(int event = 1);
virtual void activate(Game_object *obj, bool must = false);
// Can it be activated?
virtual int is_active(Game_object *obj,
int tx, int ty, int tz, int from_tx, int from_ty);
virtual void set_area(); // Set up active area.
// Render.
virtual void paint();
// Can this be clicked on?
virtual int is_findable()
{ return Ireg_game_object::is_findable(); }
virtual void write_ireg(DataSource* out);
// Get size of IREG. Returns -1 if can't write to buffer
virtual int get_ireg_size();
};
#endif
|