1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  *
22  * Based on the original sources
23  *   Faery Tale II -- The Halls of the Dead
24  *   (c) 1993-1996 The Wyrmkeep Entertainment Co.
25  */
26 
27 #ifndef SAGA2_OBJPROTO_H
28 #define SAGA2_OBJPROTO_H
29 
30 #include "saga2/idtypes.h"
31 #include "saga2/sprite.h"
32 #include "saga2/spells.h"
33 #include "saga2/effects.h"
34 #include "saga2/tcoords.h"
35 
36 namespace Saga2 {
37 
38 class Actor;
39 class gameObject;
40 
41 /* ===================================================================== *
42    Exports
43  * ===================================================================== */
44 
45 extern const int16 objectCount;  //  Number of elements in the object list
46 extern int16 worldCount;         //  Number of elements in the world list
47 
48 #define Permanent ((uint8)255)
49 
50 /* ===================================================================== *
51    Object ID's
52  * ===================================================================== */
53 
54 //  Various inline tests for object type
55 
isObject(ObjectID id)56 inline bool isObject(ObjectID id) {
57 	return (id < objectCount);
58 }
59 
isActor(ObjectID id)60 inline bool isActor(ObjectID id) {
61 	return (id >= ActorBaseID && id < ActorBaseID + kActorCount);
62 }
63 
isWorld(ObjectID id)64 inline bool isWorld(ObjectID id) {
65 	return (id >= WorldBaseID && id < WorldBaseID + worldCount);
66 }
67 
isActorOrWorld(ObjectID id)68 inline bool isActorOrWorld(ObjectID id) {
69 	return (id >= ActorBaseID);
70 }
71 
72 //  Same as above but use object addresses instead of ID's
73 
74 class GameObject;
75 class IntangibleContainerWindow;
76 class ContainerWindow;
77 class ActiveItem;
78 class ObjectTarget;
79 class Sector;
80 class TimerList;
81 class Timer;
82 struct GameEvent;
83 struct SenseInfo;
84 class SensorList;
85 class Sensor;
86 struct ObjectSoundFXs;
87 
88 bool isObject(GameObject *);
89 bool isActor(GameObject *);
90 bool isWorld(GameObject *);
91 
92 /* ===================================================================== *
93    Location: Describes location of object within world or container
94  * ===================================================================== */
95 
96 struct StaticLocation {
97 	StaticTilePoint tile;
98 	ObjectID context;
99 
setStaticLocation100 	void set(TilePoint t, ObjectID con) {
101 		tile.set(t.u, t.v, t.z);
102 		context = con;
103 	}
104 };
105 
106 class Location : public TilePoint {
107 public:
108 	//  context = the ObjectID of containing context
109 	//  (either a container or a world).
110 	ObjectID        context;
111 
112 	/*
113 	        //  Member functions to translate world coords into
114 	        //  screen coords.
115 	    void screenPos( Point16 &screenCoords );
116 	    int16 screenDepth( void );
117 
118 	        //  returns true if it is within the view area of the current
119 	        //  map.
120 	    bool visible( void );
121 	*/
122 	// assign a position to a location without changing context
123 	Location &operator=(TilePoint pos) {
124 		u = pos.u;
125 		v = pos.v;
126 		z = pos.z;
127 		return *this;
128 	}
129 
Location()130 	Location() : context(0) {}
131 
Location(int16 nu,int16 nv,int16 nz,ObjectID con)132 	Location(int16 nu, int16 nv, int16 nz, ObjectID con) {
133 		u = nu;
134 		v = nv;
135 		z = nz;
136 		context = con;
137 	}
138 
139 	Location(TilePoint p, ObjectID con = 0) {
140 		u = p.u;
141 		v = p.v;
142 		z = p.z;
143 		context = con;
144 	}
145 
Location(StaticLocation l)146 	Location(StaticLocation l) {
147 		u = l.tile.u;
148 		v = l.tile.v;
149 		z = l.tile.z;
150 		context = l.context;
151 	}
152 
153 };
154 
155 /* ===================================================================== *
156    8-way facing directions
157  * ===================================================================== */
158 
isFlipped(Direction d)159 inline bool isFlipped(Direction d) {
160 	return (d > dirDown);
161 }
162 
163 /* ===================================================================== *
164    ProtoObj: Base class for all object prototypes.
165  * ===================================================================== */
166 
167 struct scriptCallFrame;
168 
169 //  Since we want to be able to load prototypes from disk, but
170 //  still use virtual functions, we are going to divide the
171 //  prototype structure into two parts, one which has the data
172 //  and then a subclass which has all the functions.
173 
174 struct ResourceObjectPrototype {
175 
176 	//  General behavior properties
177 
178 	int16           classType;              // which C++ class to use.
179 	uint16          script;                 // script to handle all objs of this type
180 
181 	//  Appearance propertie
182 
183 	int16           nameIndex;              // type name of object
184 	uint16          iconSprite,             // sprite # in inventory
185 	                groundSprite;           // sprite # when on ground
186 
187 	uint8           colorMap[4];          // indirect color map
188 
189 	//  Physical properties
190 
191 	uint8           mass,                   // how heavy it is
192 	                bulk,                   // how bulky it is
193 	                crossSection,           // cross section width,
194 	                height,                 // height it extends above terrain
195 	                toughness,              // how easily broken,
196 	                breakType;              // what it breaks into
197 
198 	//  Container properties
199 
200 	uint16          maxCapacity;            // total space available
201 	uint8           lockType;               // type of key that opens
202 	uint8           acceptableItems;        // type of items that fit within
203 
204 	//  Combat Properties (offensive)
205 
206 	uint8           weaponDamage,
207 	                weaponFireRate,
208 	                maximumRange,
209 	                missileType;
210 
211 	//  Combat Properties (defensive)
212 
213 	uint8           whereWearable;
214 	int8            damageAbsorbtion,
215 	                damageDivider,
216 	                defenseBonus;
217 
218 	//  Magical / Energy properties
219 
220 	uint8           maxCharges,             // max number of charges, or 0=infinity
221 	                chargeType;             // charge type that can be used
222 
223 	//  Packed flags
224 
225 	int16           flags;
226 
227 	//  Flag definitions
228 
229 	enum protoFlags {
230 		objPropMergeable    = (1 << 0),     // merge with similar objects
231 		objPropRound        = (1 << 1),     // rolls easily down stairs
232 		objPropFlammable    = (1 << 2),     // object can burn
233 		objPropWeapon       = (1 << 3),     // can be wielded as weapon
234 		objPropThrownWpn    = (1 << 4),     // it's a throwable weapon
235 		objPropMissileWpn   = (1 << 5),     // it's a missile weapon
236 		objPropCharges      = (1 << 6),     // it's a missile weapon
237 		objPropEdible       = (1 << 7),     // can be eaten
238 		objPropFlipped      = (1 << 8),     // flipped left/right on ground
239 		objPropVisOpen      = (1 << 9),     // Object has seperate "visible" sprite
240 		objPropHidden       = (1 << 10),    // "How not to be seen".
241 		objPropGhosted      = (1 << 11),    // Object permanently ghosted
242 		objPropHardSurface  = (1 << 12),    // Object makes hard sound when struck
243 		objPropNoSurface    = (1 << 13)     // Object makes no sound when struck (may grunt however)
244 	};
245 
246 	int16           price;                  // object's price
247 
248 	union {
249 		int16       heldSpriteBase;         // sprite # when in hand
250 		int16       appearanceType;         // container appearance type
251 		int16       ideaType;               // idea stimulus type
252 	};
253 
254 	int16           resistance;             // resistance bits (see EFFECTS.H)
255 	int16           immunity;               // immunity bits   (see EFFECTS.H)
256 
257 	uint8           soundFXClass;           // index into sound effects table
258 
259 	uint8           reserved[7];
260 
ResourceObjectPrototypeResourceObjectPrototype261 	ResourceObjectPrototype() {
262 		classType = 0;
263 		script = 0;
264 		nameIndex = 0;
265 		iconSprite = 0;
266 		groundSprite = 0;
267 
268 		for (int i = 0; i < 4; ++i)
269 			colorMap[i] = 0;
270 
271 		mass = bulk = crossSection = height = toughness = breakType = 0;
272 		maxCapacity = 0;
273 		lockType = 0;
274 		acceptableItems = 0;
275 		weaponDamage = weaponFireRate = maximumRange = missileType = 0;
276 		whereWearable = 0;
277 		damageAbsorbtion = damageDivider = defenseBonus = 0;
278 		maxCharges = chargeType = 0;
279 		flags = 0;
280 		price = 0;
281 		heldSpriteBase = 0;
282 		resistance = 0;
283 		immunity = 0;
284 		soundFXClass = 0;
285 
286 		for (int i = 0; i < 7; ++i)
287 			reserved[i] = 0;
288 	}
289 
290 	//  Copy constructor
ResourceObjectPrototypeResourceObjectPrototype291 	ResourceObjectPrototype(ResourceObjectPrototype &proto) {
292 		classType = proto.classType;
293 		script = proto.script;
294 		nameIndex = proto.nameIndex;
295 		iconSprite = proto.iconSprite;
296 		groundSprite = proto.groundSprite;
297 
298 		for (int i = 0; i < 4; ++i)
299 			colorMap[i] = proto.colorMap[i];
300 
301 		mass = proto.mass;
302 		bulk = proto.bulk;
303 		crossSection = proto.crossSection;
304 		height = proto.height;
305 		toughness = proto.toughness;
306 		breakType = proto.breakType;
307 		maxCapacity = proto.maxCapacity;
308 		lockType = proto.lockType;
309 		acceptableItems = proto.acceptableItems;
310 		weaponDamage = proto.weaponDamage;
311 		weaponFireRate = proto.weaponFireRate;
312 		maximumRange = proto.maximumRange;
313 		missileType = proto.missileType;
314 		whereWearable = proto.whereWearable;
315 		damageAbsorbtion = proto.damageAbsorbtion;
316 		damageDivider = proto.damageDivider;
317 		defenseBonus = proto.defenseBonus;
318 		maxCharges = proto.maxCharges;
319 		chargeType = proto.chargeType;
320 		flags = proto.flags;
321 		price = proto.price;
322 		heldSpriteBase = proto.heldSpriteBase;
323 		resistance = proto.resistance;
324 		immunity = proto.immunity;
325 		soundFXClass = proto.soundFXClass;
326 
327 		for (int i = 0; i < 7; ++i)
328 			reserved[i] = proto.reserved[i];
329 	}
330 
loadResourceObjectPrototype331 	void load(Common::SeekableReadStream *stream) {
332 		classType = stream->readSint16LE();
333 		script = stream->readUint16LE();
334 		nameIndex = stream->readSint16LE();
335 		iconSprite = stream->readUint16LE();
336 		groundSprite = stream->readUint16LE();
337 
338 		for (int i = 0; i < 4; ++i)
339 			colorMap[i] = stream->readByte();
340 
341 		mass = stream->readByte();
342 		bulk = stream->readByte();
343 		crossSection = stream->readByte();
344 		height = stream->readByte();
345 		toughness = stream->readByte();
346 		breakType = stream->readByte();
347 		maxCapacity = stream->readUint16LE();
348 		lockType = stream->readByte();
349 		acceptableItems = stream->readByte();
350 		weaponDamage = stream->readByte();
351 		weaponFireRate = stream->readByte();
352 		maximumRange = stream->readByte();
353 		missileType = stream->readByte();
354 		whereWearable = stream->readByte();
355 		damageAbsorbtion = stream->readSByte();
356 		damageDivider = stream->readSByte();
357 		defenseBonus = stream->readSByte();
358 		maxCharges = stream->readByte();
359 		chargeType = stream->readByte();
360 		flags = stream->readSint16LE();
361 		price = stream->readSint16LE();
362 		heldSpriteBase = stream->readSint16LE(); // union
363 		resistance = stream->readSint16LE();
364 		immunity = stream->readSint16LE();
365 		soundFXClass = stream->readByte();
366 
367 		for (int i = 0; i < 7; ++i)
368 			reserved[i] = stream->readByte();
369 	}
370 };
371 
372 class ProtoObj : public ResourceObjectPrototype {
373 
374 	static uint8    *nextAvailObj;
375 
376 
377 	// container defines
378 	// getable through virtual functions
379 	// at appropriate subclasses
380 private:
381 	enum {
382 		ViewableRows    = 6,
383 		ViewableCols    = 4,
384 		maxRows         = 8,
385 		maxCols         = 4
386 	};
387 
388 public:
389 
390 	enum containmentType {
391 		isTangible    = (1 << 0),
392 		isContainer   = (1 << 1),
393 		isBottle      = (1 << 2),
394 		isFood        = (1 << 3),
395 		isWearable    = (1 << 4),
396 		isWeapon      = (1 << 5),
397 		isArmor       = (1 << 6),
398 		isDocument    = (1 << 7),
399 		isIntangible  = (1 << 8),
400 		isConcept     = (1 << 9),
401 		isPsych       = (1 << 10),
402 		isSpell       = (1 << 11),
403 		isSkill       = (1 << 12),
404 		isEnchantment = (1 << 13),
405 		isTargetable  = (1 << 14)
406 	};
407 
408 //	kludge: define earlier, incorrectly spelled names to correct spelling
409 //	REM: Later, do a global search and replace...
410 #define isTangable      isTangible
411 #define isIntangable    isIntangible
412 
413 	enum spriteTypes {
414 		objOnGround = 0,
415 		objInContainerView,
416 		objAsMousePtr
417 	};
418 
419 	//  Memeber functions
420 
421 	//  A constructor which takes the data loaded from the file
422 	//  and loads it into the various fields...
ProtoObj(ResourceObjectPrototype & proto)423 	ProtoObj(ResourceObjectPrototype &proto) : ResourceObjectPrototype(proto) {}
~ProtoObj()424 	virtual ~ProtoObj() {}
425 
426 	// returns the containment type flags for this object
427 	virtual uint16 containmentSet(void);
428 
429 	//  returns true if this object can contain another object
430 	virtual bool canContain(ObjectID dObj, ObjectID item);
431 
432 	//  Determine if this object can contain another object at a specified
433 	//  slot
434 	virtual bool canContainAt(
435 	    ObjectID dObj,
436 	    ObjectID item,
437 	    const TilePoint &where);
438 
439 	//  Determine if this type of object is two handed
440 	virtual bool isTwoHanded(ObjectID actor);
441 
442 	//  Determine if this type of object is a missile
443 	virtual bool isMissile(void);
444 
445 	virtual ObjectID placeObject(void);
446 
447 	//  call the object's script
448 	bool invokeScript(scriptCallFrame &);
449 
450 	//  Handle object script in a standard fashion
451 	int16 stdActionScript(int               method,
452 	                      ObjectID        dObj,
453 	                      ObjectID        enactor,
454 	                      ObjectID        indirectObj);
455 
456 	int16 stdActionScript(int               method,
457 	                      ObjectID        dObj,
458 	                      ObjectID        enactor,
459 	                      ObjectID        indirectObj,
460 	                      int16           value);
461 
462 	//  generic actions
463 	//  Use this object
464 	bool use(ObjectID dObj, ObjectID enactor);
465 	virtual bool setUseCursor(ObjectID dObj);
466 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
467 
468 	//  Use this object on another object
469 	bool useOn(ObjectID dObj, ObjectID enactor, ObjectID item);
470 	virtual bool useOnAction(ObjectID dObj, ObjectID enactor, ObjectID item);
471 
472 	//  Use this object on a tile activity instance
473 	bool useOn(ObjectID dObj, ObjectID enactor, ActiveItem *item);
474 	virtual bool useOnAction(ObjectID dObj, ObjectID enactor, ActiveItem *item);
475 
476 	//  Use the object on a location
477 	bool useOn(ObjectID dObj, ObjectID enactor, const Location &loc);
478 	virtual bool useOnAction(ObjectID dObj, ObjectID enactor, const Location &loc);
479 
480 	//  open this object
481 	bool open(ObjectID dObj, ObjectID enactor);
482 	virtual bool canOpen(ObjectID dObj, ObjectID enactor);
483 	virtual bool openAction(ObjectID dObj, ObjectID enactor);
484 
485 	//  close this object
486 	bool close(ObjectID dObj, ObjectID enactor);
487 	virtual bool closeAction(ObjectID dObj, ObjectID enactor);
488 
489 	//  take this object
490 	bool take(ObjectID dObj, ObjectID enactor, int16 num = 1);
491 	virtual bool takeAction(ObjectID dObj, ObjectID enactor);
492 	virtual bool takeAction(ObjectID dObj, ObjectID enactor, int16 num = 1);
493 
494 	//  drop this object
495 	bool drop(ObjectID dObj, ObjectID enactor, const Location &loc, int16 num = 1);
496 	virtual bool canDropAt(
497 	    ObjectID        dObj,
498 	    ObjectID        enactor,
499 	    const Location  &loc);
500 	virtual bool dropAction(
501 	    ObjectID        dObj,
502 	    ObjectID        enactor,
503 	    const Location  &loc,
504 	    int16           num = 1);
505 
506 	//  drop this object onto another object and handle the result.
507 	bool dropOn(ObjectID dObj, ObjectID enactor, ObjectID target, int16 num = 1);
508 	virtual bool dropOnAction(
509 	    ObjectID dObj,
510 	    ObjectID enactor,
511 	    ObjectID target,
512 	    int count);
513 
514 	//  drop this object onto a TAG
515 	bool dropOn(
516 	    ObjectID        dObj,
517 	    ObjectID        enactor,
518 	    ActiveItem      *target,
519 	    const Location  &loc,
520 	    int16           num = 1);
521 	virtual bool dropOnAction(
522 	    ObjectID        dObj,
523 	    ObjectID        enactor,
524 	    ActiveItem      *target,
525 	    const Location  &loc,
526 	    int16           num = 1);
527 
528 	//  Strike another object with this object
529 	bool strike(ObjectID dObj, ObjectID enactor, ObjectID item);
530 	virtual bool strikeAction(
531 	    ObjectID dObj,
532 	    ObjectID enactor,
533 	    ObjectID item);
534 
535 	//  Damage another object with this object
536 	bool damage(ObjectID dObj, ObjectID enactor, ObjectID target);
537 	virtual bool damageAction(
538 	    ObjectID dObj,
539 	    ObjectID enactor,
540 	    ObjectID target);
541 
542 	//  Eat this object
543 	bool eat(ObjectID dObj, ObjectID enactor);
544 	virtual bool eatAction(ObjectID dObj, ObjectID enactor);
545 
546 	//  Insert this object into another object
547 	bool insert(ObjectID dObj, ObjectID enactor, ObjectID item);
548 	virtual bool insertAction(ObjectID dObj, ObjectID enactor, ObjectID item);
549 
550 	//  Remove this object from another object
551 	bool remove(ObjectID dObj, ObjectID enactor);
552 	virtual bool removeAction(ObjectID dObj, ObjectID enactor);
553 
554 	//  Drop another object onto this one.
555 	bool acceptDrop(ObjectID dObj, ObjectID enactor, ObjectID droppedObj, int count);
556 	virtual bool acceptDropAction(
557 	    ObjectID dObj,
558 	    ObjectID enactor,
559 	    ObjectID droppedObj,
560 	    int count);
561 
562 	//  Cause damage to this object directly
563 	bool acceptDamage(
564 	    ObjectID            dObj,
565 	    ObjectID            enactor,
566 	    int8                absDamage,
567 	    effectDamageTypes   dType = kDamageOther,
568 	    int8                dice = 0,
569 	    uint8               sides = 1,
570 	    int8                perDieMod = 0);
571 	virtual bool acceptDamageAction(
572 	    ObjectID            dObj,
573 	    ObjectID            enactor,
574 	    int8                absDamage,
575 	    effectDamageTypes   dType,
576 	    int8                dice,
577 	    uint8               sides,
578 	    int8                perDieMod);
579 
580 	bool acceptHealing(
581 	    ObjectID    dObj,
582 	    ObjectID    enactor,
583 	    int8        absHealing,
584 	    int8        dice = 0,
585 	    uint8       sides = 1,
586 	    int8        perDieMod = 0);
587 	virtual bool acceptHealingAction(
588 	    ObjectID    dObj,
589 	    ObjectID    enactor,
590 	    int8        healing);
591 
592 	//  Accept strike from another object (allows this object to cause
593 	//  damage to the striking object).
594 	bool acceptStrike(
595 	    ObjectID            dObj,
596 	    ObjectID            enactor,
597 	    ObjectID            strikingObj,
598 	    uint8               skillIndex);
599 	virtual bool acceptStrikeAction(
600 	    ObjectID            dObj,
601 	    ObjectID            enactor,
602 	    ObjectID            strikingObj,
603 	    uint8               skillIndex);
604 
605 	//  Unlock or lock this object with a key.
606 	bool acceptLockToggle(ObjectID dObj, ObjectID enactor, uint8 keyCode);
607 	virtual bool canToggleLock(
608 	    ObjectID dObj,
609 	    ObjectID enactor,
610 	    uint8 keyCode);
611 	virtual bool acceptLockToggleAction(ObjectID dObj, ObjectID enactor, uint8 keyCode);
612 
613 	//  Mix this object with another.
614 	bool acceptMix(ObjectID dObj, ObjectID enactor, ObjectID mixObj);
615 	virtual bool acceptMixAction(
616 	    ObjectID dObj,
617 	    ObjectID enactor,
618 	    ObjectID mixObj);
619 
620 	//  Insert another object into this object.
621 	bool acceptInsertion(
622 	    ObjectID dObj,
623 	    ObjectID enactor,
624 	    ObjectID item,
625 	    int16 count);
626 	virtual bool acceptInsertionAction(
627 	    ObjectID dObj,
628 	    ObjectID enactor,
629 	    ObjectID item,
630 	    int16 count);
631 
632 	//  Insert another object into this object at a specified slot
633 	bool acceptInsertionAt(
634 	    ObjectID        dObj,
635 	    ObjectID        enactor,
636 	    ObjectID        item,
637 	    const TilePoint &where,
638 	    int16           num = 1);
639 
640 	virtual bool acceptInsertionAtAction(
641 	    ObjectID        dObj,
642 	    ObjectID        enactor,
643 	    ObjectID        item,
644 	    const TilePoint &where,
645 	    int16           num = 1);
646 
647 	//  Creates a color translation table for this object
648 	virtual void getColorTranslation(ColorTable map);
649 
650 	//  return the sprite data of amount 'count'
651 	virtual ObjectSpriteInfo getSprite(GameObject *obj, enum spriteTypes spr, int16 count = -1);
652 
653 	//  return the address of the sprite when held in hand
654 	virtual Sprite *getOrientedSprite(GameObject *obj, int16 offset);
655 
656 	//  Initiate an attack using this type of object
657 	virtual void initiateAttack(ObjectID attacker, ObjectID target);
658 
659 	//  Initiate a defense using this type of object
660 	virtual void initiateDefense(
661 	    ObjectID defensiveObj,
662 	    ObjectID defender,
663 	    ObjectID attacker);
664 
665 	//  Get a projectile from the missile weapon
666 	virtual GameObject *getProjectile(ObjectID weapon, ObjectID enactor);
667 
668 	//  Get a spell from a magic weapon
669 	virtual GameObject *getSpell(ObjectID obj);
670 
671 	//  Determine if this type of object can block an attack
672 	virtual bool canBlock(void);
673 
674 	//  Return a mask of bits indicating the directions relative to the
675 	//  wielders facing in which this object can defend
676 	virtual uint8 defenseDirMask(void);
677 
678 	//  Compute how much damage this defensive object will absorb
679 	virtual uint8 adjustDamage(uint8 damage);
680 
681 	//  Return the fight stance approriate to this weapon
682 	virtual int16 fightStanceAction(ObjectID actor);
683 
684 	//  Given an object sound effect record, which sound should be made
685 	//  when this object is damaged
686 	virtual uint8 getDamageSound(const ObjectSoundFXs &soundFXs);
687 
688 	//  Do the background processing, if needed, for this object.
689 	//  This will be called approximately once every 10 seconds
690 	//  (or whatever the background refresh period is).
691 	virtual void doBackgroundUpdate(GameObject *obj);
692 
resists(effectResistTypes r)693 	virtual bool resists(effectResistTypes r) {
694 		return resistance & (1 << r);
695 	}
isImmuneTo(effectImmuneTypes r)696 	virtual bool isImmuneTo(effectImmuneTypes r) {
697 		return immunity & (1 << r);
698 	}
699 
makeSavingThrow(void)700 	virtual bool makeSavingThrow(void) {
701 		return false;
702 	}
703 
704 	//  Returns true if object in continuous use.
705 	virtual bool isObjectBeingUsed(GameObject *obj);
706 
707 	//  Determine if the specified object's 'use' slot is available within
708 	//  the specified actor
709 	virtual bool useSlotAvailable(GameObject *obj, Actor *a);
710 
711 	//  Get the value of the user's skill which applies to this
712 	//  object
713 	virtual uint8 getSkillValue(ObjectID enactor);
714 
715 	//  Cause the user's associated skill to grow
716 	virtual void applySkillGrowth(ObjectID enactor, uint8 points = 1);
717 
718 	// this is to determine size of containers
719 public:
getViewableRows(void)720 	virtual uint16 getViewableRows(void) {
721 		return ViewableRows;
722 	}
getViewableCols(void)723 	virtual uint16 getViewableCols(void) {
724 		return ViewableCols;
725 	}
getMaxRows(void)726 	virtual uint16 getMaxRows(void) {
727 		return maxRows;
728 	}
getMaxCols(void)729 	virtual uint16 getMaxCols(void) {
730 		return maxCols;
731 	}
732 
733 	// this returns the type of charge an item can have
getChargeType(void)734 	int16 getChargeType(void) {
735 		return chargeType;
736 	}
737 
738 	virtual bool canFitBulkwise(GameObject *container, GameObject *obj);
739 	virtual bool canFitMasswise(GameObject *container, GameObject *obj);
740 
741 	virtual uint16 massCapacity(GameObject *container);
742 	virtual uint16 bulkCapacity(GameObject *container);
743 };
744 
745 /* ======================================================================== *
746    InventoryProto:  base class for all tangible object prototypes
747  * ======================================================================== */
748 
749 //	hierarchy:
750 //		ProtoObj, InventoryProto
751 
752 class InventoryProto : public ProtoObj {
753 public:
InventoryProto(ResourceObjectPrototype & proto)754 	InventoryProto(ResourceObjectPrototype &proto) : ProtoObj(proto) {}
~InventoryProto()755 	virtual ~InventoryProto() {}
756 
757 	virtual uint16 containmentSet(void);
758 
759 	virtual bool takeAction(ObjectID dObj, ObjectID enactor, int16 num = 1);
760 
761 	virtual bool canDropAt(
762 	    ObjectID        dObj,
763 	    ObjectID        enactor,
764 	    const Location  &loc);
765 	virtual bool dropAction(
766 	    ObjectID        dObj,
767 	    ObjectID        enactor,
768 	    const Location  &loc,
769 	    int16           num = 1);
770 
771 	virtual bool dropOnAction(
772 	    ObjectID        dObj,
773 	    ObjectID        enactor,
774 	    ActiveItem      *target,
775 	    const Location  &loc,
776 	    int16           num = 1);
777 
778 	virtual bool acceptDropAction(
779 	    ObjectID dObj,
780 	    ObjectID enactor,
781 	    ObjectID droppedObj,
782 	    int count);
783 
784 	virtual bool acceptStrikeAction(
785 	    ObjectID            dObj,
786 	    ObjectID            enactor,
787 	    ObjectID            strikingObj,
788 	    uint8               skillIndex);
789 };
790 
791 /* ======================================================================== *
792    PhysicalContainerProto
793  * ======================================================================== */
794 
795 //	hierarchy:
796 //		ProtoObj, InventoryProto, PhysicalContainerProto
797 
798 //  Prototype class for physical object container
799 class PhysicalContainerProto : public InventoryProto {
800 private:
801 	enum {
802 		ViewableRows    = 4,
803 		ViewableCols    = 4,
804 		maxRows         = 8,
805 		maxCols         = 4
806 	};
807 
808 public:
PhysicalContainerProto(ResourceObjectPrototype & proto)809 	PhysicalContainerProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
~PhysicalContainerProto()810 	virtual ~PhysicalContainerProto() {}
811 
812 	virtual uint16 containmentSet(void);
813 
814 	virtual bool canContain(ObjectID dObj, ObjectID item);
815 	virtual bool canContainAt(
816 	    ObjectID        dObj,
817 	    ObjectID        item,
818 	    const TilePoint &where);
819 
820 	//  Call open() if closed, or call close() if open.
821 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
822 
823 	//  Open this object
824 	virtual bool canOpen(ObjectID dObj, ObjectID enactor);
825 	virtual bool openAction(ObjectID dObj, ObjectID enactor);
826 
827 	//  Close this object
828 	virtual bool closeAction(ObjectID dObj, ObjectID enactor);
829 
830 	//  Unlock or lock object if keyCode == lockType
831 	virtual bool canToggleLock(
832 	    ObjectID dObj,
833 	    ObjectID enactor,
834 	    uint8 keyCode);
835 	virtual bool acceptLockToggleAction(ObjectID dObj, ObjectID enactor, uint8 keyCode);
836 
837 	//  Insert another object into this object
838 	bool acceptInsertionAction(
839 	    ObjectID dObj,
840 	    ObjectID enactor,
841 	    ObjectID item,
842 	    int16 num);
843 
844 	//  Insert another object into this object at the specified slot
845 	virtual bool acceptInsertionAtAction(
846 	    ObjectID        dObj,
847 	    ObjectID        enactor,
848 	    ObjectID        item,
849 	    const TilePoint &where,
850 	    int16           num = 1);
851 
852 public:
getViewableRows(void)853 	virtual uint16 getViewableRows(void) {
854 		return ViewableRows;
855 	}
getViewableCols(void)856 	virtual uint16 getViewableCols(void) {
857 		return ViewableCols;
858 	}
getMaxRows(void)859 	virtual uint16 getMaxRows(void) {
860 		return maxRows;
861 	}
getMaxCols(void)862 	virtual uint16 getMaxCols(void) {
863 		return maxCols;
864 	}
865 
866 	virtual bool canFitBulkwise(GameObject *container, GameObject *obj);
867 	virtual bool canFitMasswise(GameObject *container, GameObject *obj);
868 
869 	virtual uint16 massCapacity(GameObject *container);
870 	virtual uint16 bulkCapacity(GameObject *container);
871 };
872 
873 /* ======================================================================== *
874    KeyProto
875  * ======================================================================== */
876 
877 //	hierarchy:
878 //		ProtoObj, InventoryProto, KeyProto
879 
880 //  Prototype class for key objects
881 class KeyProto : public InventoryProto {
882 public:
KeyProto(ResourceObjectPrototype & proto)883 	KeyProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
~KeyProto()884 	virtual ~KeyProto() {}
885 
886 	//  Set up targeting cursor
887 	virtual bool setUseCursor(ObjectID dObj);
888 
889 	//  Use key on lockable container
890 	virtual bool useOnAction(ObjectID dObj, ObjectID enactor, ObjectID withObj);
891 
892 	//  Use key on active terrain
893 	virtual bool useOnAction(ObjectID dObj, ObjectID enactor, ActiveItem *withTAI);
894 };
895 
896 /* ======================================================================== *
897    BottleProto
898  * ======================================================================== */
899 
900 //	hierarchy:
901 //		ProtoObj, InventoryProto, BottleProto
902 
903 class BottleProto : public InventoryProto {
904 public:
BottleProto(ResourceObjectPrototype & proto)905 	BottleProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
~BottleProto()906 	virtual ~BottleProto() {}
907 
908 	virtual uint16 containmentSet(void);
909 
910 	// Drink From Bottle
911 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
912 
913 };
914 
915 /* ======================================================================== *
916    FoodProto
917  * ======================================================================== */
918 
919 //	hierarchy:
920 //		ProtoObj, InventoryProto, FoodProto
921 
922 class FoodProto : public InventoryProto {
923 public:
FoodProto(ResourceObjectPrototype & proto)924 	FoodProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
~FoodProto()925 	virtual ~FoodProto() {}
926 
927 	virtual uint16 containmentSet(void);
928 
929 	// Eat it
930 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
931 
932 };
933 
934 /* ======================================================================== *
935    WearableProto
936  * ======================================================================== */
937 
938 //	hierarchy:
939 //		ProtoObj, InventoryProto, WearbleProto
940 
941 class WearableProto : public InventoryProto {
942 public:
WearableProto(ResourceObjectPrototype & proto)943 	WearableProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
~WearableProto()944 	virtual ~WearableProto() {}
945 
946 	virtual uint16 containmentSet(void);
947 };
948 
949 /* ======================================================================== *
950    WeaponProto
951  * ======================================================================== */
952 
953 //	hierarchy:
954 //		ProtoObj, InventoryProto, WeaponProto
955 
956 class WeaponProto : public InventoryProto {
957 
958 protected:
959 	enum {
960 		inRangeRatingBonus = 4
961 	};
962 
963 public:
WeaponProto(ResourceObjectPrototype & proto)964 	WeaponProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
~WeaponProto()965 	virtual ~WeaponProto() {}
966 
967 	virtual uint16 containmentSet(void);
968 
969 	//  return the address of the sprite when held in hand
970 	virtual Sprite *getOrientedSprite(GameObject *obj, int16 offset);
971 	weaponID getWeaponID(void);
972 
973 	//  Returns true if object in continuous use.
974 	bool isObjectBeingUsed(GameObject *obj);
975 
976 	//  Rate this weapon's goodness for a specified attack situation
977 	virtual uint8 weaponRating(
978 	    ObjectID weaponID,
979 	    ObjectID wielderID,
980 	    ObjectID targetID) = 0;
981 };
982 
983 /* ======================================================================== *
984    MeleeWeaponProto
985  * ======================================================================== */
986 
987 //	hierarchy:
988 //		ProtoObj, InventoryProto, WeaponProto, MeleeWeaponProto
989 
990 class MeleeWeaponProto : public WeaponProto {
991 public:
MeleeWeaponProto(ResourceObjectPrototype & proto)992 	MeleeWeaponProto(ResourceObjectPrototype &proto) : WeaponProto(proto) {}
~MeleeWeaponProto()993 	virtual ~MeleeWeaponProto() {}
994 
995 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
996 	virtual bool useOnAction(ObjectID dObj, ObjectID enactor, ObjectID item);
997 	virtual bool strikeAction(
998 	    ObjectID dObj,
999 	    ObjectID enactor,
1000 	    ObjectID item);
1001 	virtual bool damageAction(
1002 	    ObjectID dObj,
1003 	    ObjectID enactor,
1004 	    ObjectID target);
1005 	virtual bool acceptDamageAction(
1006 	    ObjectID            dObj,
1007 	    ObjectID            enactor,
1008 	    int8                absDamage,
1009 	    effectDamageTypes   dType,
1010 	    int8                dice,
1011 	    uint8               sides,
1012 	    int8                perDieMod);
1013 
1014 	//  Determine if this type of weapon must be wielded with two hands
1015 	//  for the specified actor
1016 	virtual bool isTwoHanded(ObjectID actor);
1017 
1018 	//  Initiate a melee weapon attack motion
1019 	virtual void initiateAttack(ObjectID attacker, ObjectID target);
1020 	//  Initiate a melee weapon parry motion
1021 	virtual void initiateDefense(
1022 	    ObjectID defensiveObj,
1023 	    ObjectID defender,
1024 	    ObjectID attacker);
1025 	//  Melee weapons can block attacks
1026 	virtual bool canBlock(void);
1027 	//  Return a mask of bits indicating the directions relative to the
1028 	//  wielders facing in which this object can defend
1029 	virtual uint8 defenseDirMask(void);
1030 
1031 	//  Determine if the specified object's 'use' slot is available within
1032 	//  the specified actor
1033 	virtual bool useSlotAvailable(GameObject *obj, Actor *a);
1034 
1035 	//  Rate this weapon's goodness for a specified attack situation
1036 	virtual uint8 weaponRating(
1037 	    ObjectID weaponID,
1038 	    ObjectID wielderID,
1039 	    ObjectID targetID);
1040 
1041 	//  Return the fight stance approriate to this weapon
1042 	virtual int16 fightStanceAction(ObjectID actor);
1043 
1044 	//  Given an object sound effect record, which sound should be made
1045 	//  when this object is damaged
1046 	virtual uint8 getDamageSound(const ObjectSoundFXs &soundFXs);
1047 };
1048 
1049 /* ======================================================================== *
1050    BludgeoningWeaponProto
1051  * ======================================================================== */
1052 
1053 //	hierarchy:
1054 //		ProtoObj, InventoryProto, WeaponProto, MeleeWeaponProto,
1055 //		BludgeoningWeaponProto
1056 
1057 class BludgeoningWeaponProto : public MeleeWeaponProto {
1058 public:
BludgeoningWeaponProto(ResourceObjectPrototype & proto)1059 	BludgeoningWeaponProto(ResourceObjectPrototype &proto) : MeleeWeaponProto(proto) {}
~BludgeoningWeaponProto()1060 	virtual ~BludgeoningWeaponProto() {}
1061 
1062 	//  Get the value of the wielder's skill which applies to this
1063 	//  weapon
1064 	virtual uint8 getSkillValue(ObjectID enactor);
1065 
1066 	//  Cause the user's associated skill to grow
1067 	virtual void applySkillGrowth(ObjectID enactor, uint8 points = 1);
1068 };
1069 
1070 /* ======================================================================== *
1071    SlashingWeaponProto
1072  * ======================================================================== */
1073 
1074 //	hierarchy:
1075 //		ProtoObj, InventoryProto, WeaponProto, MeleeWeaponProto,
1076 //		SlashingWeaponProto
1077 
1078 class SlashingWeaponProto : public MeleeWeaponProto {
1079 public:
SlashingWeaponProto(ResourceObjectPrototype & proto)1080 	SlashingWeaponProto(ResourceObjectPrototype &proto) : MeleeWeaponProto(proto) {}
~SlashingWeaponProto()1081 	virtual ~SlashingWeaponProto() {}
1082 
1083 	//  Get the value of the wielder's skill which applies to this
1084 	//  weapon
1085 	virtual uint8 getSkillValue(ObjectID enactor);
1086 
1087 	//  Cause the user's associated skill to grow
1088 	virtual void applySkillGrowth(ObjectID enactor, uint8 points = 1);
1089 };
1090 
1091 /* ======================================================================== *
1092    BowProto
1093  * ======================================================================== */
1094 
1095 //	hierarchy:
1096 //		ProtoObj, InventoryProto, WeaponProto, BowProto
1097 
1098 class BowProto : public WeaponProto {
1099 public:
BowProto(ResourceObjectPrototype & proto)1100 	BowProto(ResourceObjectPrototype &proto) : WeaponProto(proto) {}
~BowProto()1101 	virtual ~BowProto() {}
1102 
1103 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
1104 
1105 	//  Bows are two handed
1106 	virtual bool isTwoHanded(ObjectID actor);
1107 
1108 	//  Initiate a bow firing motion
1109 	virtual void initiateAttack(ObjectID attacker, ObjectID target);
1110 
1111 	//  Grab and arrow from the actor's inventory
1112 	virtual GameObject *getProjectile(ObjectID weapon, ObjectID enactor);
1113 
1114 	//  Determine if the specified object's 'use' slot is available within
1115 	//  the specified actor
1116 	virtual bool useSlotAvailable(GameObject *obj, Actor *a);
1117 
1118 	//  Rate this weapon's goodness for a specified attack situation
1119 	virtual uint8 weaponRating(
1120 	    ObjectID weaponID,
1121 	    ObjectID wielderID,
1122 	    ObjectID targetID);
1123 
1124 	//  Return the fight stance approriate to this weapon
1125 	virtual int16 fightStanceAction(ObjectID actor);
1126 };
1127 
1128 /* ======================================================================== *
1129    WeaponWandProto
1130  * ======================================================================== */
1131 
1132 //	hierarchy:
1133 //		ProtoObj, InventoryProto, WeaponProto, WeaponWandProto
1134 
1135 class WeaponWandProto : public WeaponProto {
1136 public:
WeaponWandProto(ResourceObjectPrototype & proto)1137 	WeaponWandProto(ResourceObjectPrototype &proto) : WeaponProto(proto) {}
~WeaponWandProto()1138 	virtual ~WeaponWandProto() {}
1139 
1140 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
1141 
1142 	//  Wands are two handed
1143 	virtual bool isTwoHanded(ObjectID actor);
1144 
1145 	//  Initiate a bow firing motion
1146 	virtual void initiateAttack(ObjectID attacker, ObjectID target);
1147 
1148 	//  Determine if the specified object's 'use' slot is available within
1149 	//  the specified actor
1150 	virtual bool useSlotAvailable(GameObject *obj, Actor *a);
1151 
1152 	//  Rate this weapon's goodness for a specified attack situation
1153 	virtual uint8 weaponRating(
1154 	    ObjectID weaponID,
1155 	    ObjectID wielderID,
1156 	    ObjectID targetID);
1157 
1158 	//  Return the fight stance approriate to this weapon
1159 	virtual int16 fightStanceAction(ObjectID actor);
1160 };
1161 
1162 /* ======================================================================== *
1163    ProjectileProto
1164  * ======================================================================== */
1165 
1166 //	hierarchy:
1167 //		ProtoObj, InventoryProto, WeaponProto, ProjectileProto
1168 
1169 class ProjectileProto : public WeaponProto {
1170 public:
ProjectileProto(ResourceObjectPrototype & proto)1171 	ProjectileProto(ResourceObjectPrototype &proto) : WeaponProto(proto) {}
~ProjectileProto()1172 	virtual ~ProjectileProto() {}
1173 
1174 	//  return the address of the sprite when held in hand
1175 	virtual Sprite *getOrientedSprite(GameObject *obj, int16 offset);
1176 
1177 	//  Returns true if object in continuous use.
1178 	bool isObjectBeingUsed(GameObject *obj);
1179 
1180 	//  Projectiles are missiles
1181 	virtual bool isMissile(void);
1182 
1183 	//  Rate this weapon's goodness for a specified attack situation
1184 	virtual uint8 weaponRating(
1185 	    ObjectID weaponID,
1186 	    ObjectID wielderID,
1187 	    ObjectID targetID);
1188 };
1189 
1190 /* ======================================================================== *
1191    ArrowProto
1192  * ======================================================================== */
1193 
1194 //	hierarchy:
1195 //		ProtoObj, InventoryProto, WeaponProto, ProjectileProto, ArrowProto
1196 
1197 class ArrowProto : public ProjectileProto {
1198 public:
ArrowProto(ResourceObjectPrototype & proto)1199 	ArrowProto(ResourceObjectPrototype &proto) : ProjectileProto(proto) {}
~ArrowProto()1200 	virtual ~ArrowProto() {}
1201 
1202 	virtual bool useOnAction(ObjectID dObj, ObjectID enactor, ObjectID item);
1203 	virtual bool strikeAction(
1204 	    ObjectID dObj,
1205 	    ObjectID enactor,
1206 	    ObjectID item);
1207 	virtual bool damageAction(
1208 	    ObjectID dObj,
1209 	    ObjectID enactor,
1210 	    ObjectID target);
1211 
1212 	//  Cause the user's associated skill to grow
1213 	virtual void applySkillGrowth(ObjectID enactor, uint8 points = 1);
1214 
1215 };
1216 
1217 /* ======================================================================== *
1218    ArmorProto
1219  * ======================================================================== */
1220 
1221 //	hierarchy:
1222 //		ProtoObj, InventoryProto, ArmorProto
1223 
1224 class ArmorProto : public InventoryProto {
1225 public:
ArmorProto(ResourceObjectPrototype & proto)1226 	ArmorProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
~ArmorProto()1227 	virtual ~ArmorProto() {}
1228 
1229 	virtual uint16 containmentSet(void);
1230 
1231 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
1232 
1233 	//  Compute how much damage this defensive object will absorb
1234 	virtual uint8 adjustDamage(uint8 damage);
1235 
1236 	//  Returns true if object in continuous use.
1237 	bool isObjectBeingUsed(GameObject *obj);
1238 
1239 	//  Determine if the specified object's 'use' slot is available within
1240 	//  the specified actor
1241 	virtual bool useSlotAvailable(GameObject *obj, Actor *a);
1242 };
1243 
1244 /* ======================================================================== *
1245    ShieldProto
1246  * ======================================================================== */
1247 
1248 //	hierarchy:
1249 //		ProtoObj, InventoryProto, ShieldProto
1250 
1251 class ShieldProto : public InventoryProto {
1252 public:
ShieldProto(ResourceObjectPrototype & proto)1253 	ShieldProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
~ShieldProto()1254 	virtual ~ShieldProto() {}
1255 
1256 	virtual uint16 containmentSet(void);
1257 
1258 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
1259 
1260 	virtual bool acceptDamageAction(
1261 	    ObjectID            dObj,
1262 	    ObjectID            enactor,
1263 	    int8                absDamage,
1264 	    effectDamageTypes   dType,
1265 	    int8                dice,
1266 	    uint8               sides,
1267 	    int8                perDieMod);
1268 
1269 	//  return the address of the sprite when held in hand
1270 	virtual Sprite *getOrientedSprite(GameObject *obj, int16 offset);
1271 
1272 	virtual void initiateDefense(
1273 	    ObjectID defensiveObj,
1274 	    ObjectID defender,
1275 	    ObjectID attacker);
1276 	virtual bool canBlock(void);
1277 	//  Return a mask of bits indicating the directions relative to the
1278 	//  wielders facing in which this object can defend
1279 	virtual uint8 defenseDirMask(void);
1280 
1281 	//  Returns true if object in continuous use.
1282 	bool isObjectBeingUsed(GameObject *obj);
1283 
1284 	//  Determine if the specified object's 'use' slot is available within
1285 	//  the specified actor
1286 	virtual bool useSlotAvailable(GameObject *obj, Actor *a);
1287 
1288 	//  Get the value of the user's skill which applies to this
1289 	//  object
1290 	virtual uint8 getSkillValue(ObjectID enactor);
1291 
1292 	//  Cause the user's associated skill to grow
1293 	virtual void applySkillGrowth(ObjectID enactor, uint8 points = 1);
1294 
1295 	//  Given an object sound effect record, which sound should be made
1296 	//  when this object is damaged
1297 	virtual uint8 getDamageSound(const ObjectSoundFXs &soundFXs);
1298 };
1299 
1300 /* ======================================================================== *
1301    ToolProto
1302  * ======================================================================== */
1303 
1304 //	hierarchy:
1305 //		ProtoObj, InventoryProto, ToolProto
1306 
1307 class ToolProto : public InventoryProto {
1308 public:
ToolProto(ResourceObjectPrototype & proto)1309 	ToolProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
~ToolProto()1310 	virtual ~ToolProto() {}
1311 
1312 	//  Set up targeting cursor
1313 	virtual bool setUseCursor(ObjectID dObj);
1314 
1315 	//  Use tool on object
1316 	virtual bool useOnAction(ObjectID dObj, ObjectID enactor, ObjectID withObj);
1317 };
1318 
1319 /* ======================================================================== *
1320    DocumentProto
1321  * ======================================================================== */
1322 
1323 //	hierarchy:
1324 //		ProtoObj, InventoryProto, DocumentProto
1325 
1326 class DocumentProto : public InventoryProto {
1327 public:
DocumentProto(ResourceObjectPrototype & proto)1328 	DocumentProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
~DocumentProto()1329 	virtual ~DocumentProto() {}
1330 
1331 	virtual uint16 containmentSet(void);
1332 
1333 //BookDoc
1334 //ScrollDoc
1335 
1336 //	virtual bool use( ObjectID dObj, ObjectID enactor );
1337 //	Close Floating Window Used For Both Book And Scroll
1338 //	virtual bool close( ObjectID dObj, ObjectID enactor );
1339 
1340 };
1341 
1342 /* ======================================================================== *
1343    BookProto
1344  * ======================================================================== */
1345 
1346 //	hierarchy:
1347 //		ProtoObj, InventoryProto, DocumentProto, BookProto
1348 
1349 class BookProto : public DocumentProto {
1350 public:
BookProto(ResourceObjectPrototype & proto)1351 	BookProto(ResourceObjectPrototype &proto) : DocumentProto(proto) {}
~BookProto()1352 	virtual ~BookProto() {}
1353 	//Read It
1354 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
1355 
1356 };
1357 
1358 /* ======================================================================== *
1359    ScrollProto
1360  * ======================================================================== */
1361 
1362 //	hierarchy:
1363 //		ProtoObj, InventoryProto, DocumentProto, ScrollProto
1364 
1365 class ScrollProto : public DocumentProto {
1366 public:
ScrollProto(ResourceObjectPrototype & proto)1367 	ScrollProto(ResourceObjectPrototype &proto) : DocumentProto(proto) {}
~ScrollProto()1368 	virtual ~ScrollProto() {}
1369 
1370 	//Read It
1371 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
1372 
1373 };
1374 
1375 /* ======================================================================== *
1376    AutoMapProto
1377  * ======================================================================== */
1378 
1379 //	hierarchy:
1380 //		ProtoObj, InventoryProto, AutoMapProto
1381 
1382 class AutoMapProto : public InventoryProto {
1383 public:
AutoMapProto(ResourceObjectPrototype & proto)1384 	AutoMapProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {}
~AutoMapProto()1385 	virtual ~AutoMapProto() {}
1386 
1387 	//Shows Auto Map Display
1388 	virtual bool openAction(ObjectID dObj, ObjectID enactor);
1389 
1390 };
1391 
1392 /* ======================================================================== *
1393    IntagibleObjProto
1394  * ======================================================================== */
1395 
1396 //	hierarchy:
1397 //		ProtoObj, IntangibleObjProto
1398 
1399 class IntangibleObjProto : public ProtoObj {
1400 public:
IntangibleObjProto(ResourceObjectPrototype & proto)1401 	IntangibleObjProto(ResourceObjectPrototype &proto) : ProtoObj(proto) {}
~IntangibleObjProto()1402 	virtual ~IntangibleObjProto() {}
1403 
1404 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
1405 
1406 	virtual bool takeAction(ObjectID dObj, ObjectID enactor, int16);
1407 
1408 	virtual bool canDropAt(
1409 	    ObjectID        dObj,
1410 	    ObjectID        enactor,
1411 	    const Location  &loc);
1412 	virtual bool dropAction(
1413 	    ObjectID        dObj,
1414 	    ObjectID        enactor,
1415 	    const Location  &loc,
1416 	    int16);
1417 
1418 	virtual bool acceptDropAction(
1419 	    ObjectID dObj,
1420 	    ObjectID enactor,
1421 	    ObjectID droppedObj,
1422 	    int count);
1423 
1424 	virtual uint16 containmentSet(void);
1425 	virtual ObjectID placeObject(void);
1426 
1427 	//  Creates a color translation table for this object
1428 	virtual void getColorTranslation(ColorTable map);
1429 
1430 	//  return the sprite data
1431 	virtual ObjectSpriteInfo getSprite(GameObject *obj, enum spriteTypes spr, int16);
1432 };
1433 
1434 /* ======================================================================== *
1435    IdeaProto
1436  * ======================================================================== */
1437 
1438 //	hierarchy:
1439 //		ProtoObj, IntangibleObjProto, IdeaProto
1440 
1441 class IdeaProto : public IntangibleObjProto {
1442 public:
IdeaProto(ResourceObjectPrototype & proto)1443 	IdeaProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {}
~IdeaProto()1444 	virtual ~IdeaProto() {}
1445 
1446 	//Talk To A Person
1447 	uint16 containmentSet(void);
1448 
1449 };
1450 
1451 /* ======================================================================== *
1452    MemoryProto
1453  * ======================================================================== */
1454 
1455 //	hierarchy:
1456 //		ProtoObj, IntangibleObjProto, MemoryProto
1457 
1458 class MemoryProto : public IntangibleObjProto {
1459 public:
MemoryProto(ResourceObjectPrototype & proto)1460 	MemoryProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {}
~MemoryProto()1461 	virtual ~MemoryProto() {}
1462 
1463 	//Get Info On Person Your Talking To
1464 	uint16 containmentSet(void);
1465 
1466 };
1467 
1468 /* ======================================================================== *
1469    PsychProto
1470  * ======================================================================== */
1471 
1472 //	hierarchy:
1473 //		ProtoObj, IntangibleObjProto, PsychProto
1474 
1475 class PsychProto : public IntangibleObjProto {
1476 public:
PsychProto(ResourceObjectPrototype & proto)1477 	PsychProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {}
~PsychProto()1478 	virtual ~PsychProto() {}
1479 
1480 	//Get Explanation Of Icon
1481 	uint16 containmentSet(void);
1482 
1483 };
1484 
1485 /* ======================================================================== *
1486    SkillProto
1487  * ======================================================================== */
1488 
1489 //typedef uint8 SpellID;
1490 
1491 //	hierarchy:
1492 //		ProtoObj, IntagibleObjProto, SkillProto
1493 
1494 class SkillProto : public IntangibleObjProto {
1495 public:
SkillProto(ResourceObjectPrototype & proto)1496 	SkillProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {}
~SkillProto()1497 	virtual ~SkillProto() {}
1498 
1499 	//Perform A Skill or Cast a spell
1500 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
1501 	virtual bool useOnAction(ObjectID dObj, ObjectID enactor, ObjectID withObj);
1502 	virtual bool useOnAction(ObjectID dObj, ObjectID enactor, ActiveItem *item);
1503 	virtual bool useOnAction(ObjectID dObj, ObjectID enactor, const Location &loc);
1504 
1505 	virtual bool canDropAt(
1506 	    ObjectID        dObj,
1507 	    ObjectID        enactor,
1508 	    const Location  &loc);
1509 	virtual bool dropAction(
1510 	    ObjectID        dObj,
1511 	    ObjectID        enactor,
1512 	    const Location  &loc,
1513 	    int16           num = 1);
1514 	virtual bool dropOnAction(
1515 	    ObjectID dObj,
1516 	    ObjectID enactor,
1517 	    ObjectID target,
1518 	    int count);
1519 	virtual bool dropOnAction(
1520 	    ObjectID        dObj,
1521 	    ObjectID        enactor,
1522 	    ActiveItem      *target,
1523 	    const Location  &loc,
1524 	    int16           num = 1);
1525 
1526 	virtual bool implementAction(SpellID dObj, ObjectID enactor, ObjectID withObj);
1527 	virtual bool implementAction(SpellID dObj, ObjectID enactor, ActiveItem *item);
1528 	virtual bool implementAction(SpellID dObj, ObjectID enactor, Location &loc);
1529 	uint16 containmentSet(void);
getSpellID(void)1530 	SpellID getSpellID(void) {
1531 		return (SpellID) lockType;
1532 	}
1533 
1534 };
1535 
1536 /* ======================================================================== *
1537    IntangibleContainerProto
1538  * ======================================================================== */
1539 
1540 //	hierarchy:
1541 //		ProtoObj, IntangibleContainerProto
1542 
1543 class IntangibleContainerProto : public ProtoObj {
1544 public:
IntangibleContainerProto(ResourceObjectPrototype & proto)1545 	IntangibleContainerProto(ResourceObjectPrototype &proto) : ProtoObj(proto) {}
~IntangibleContainerProto()1546 	virtual ~IntangibleContainerProto() {}
1547 
1548 	virtual bool canContain(ObjectID dObj, ObjectID item);
1549 	virtual bool useAction(ObjectID dObj, ObjectID enactor);
1550 	virtual bool canOpen(ObjectID dObj, ObjectID enactor);
1551 	virtual bool openAction(ObjectID dObj, ObjectID enactor);
1552 	virtual bool closeAction(ObjectID dObj, ObjectID enactor);
1553 //	virtual  bool acceptLockToggle( ObjectID dObj, ObjectID enactor, uint8 keyCode );
1554 
1555 //	virtual  ContainerWindow *makeWindow( GameObject *Obj );
1556 	virtual uint16 containmentSet(void);
1557 };
1558 
1559 /* ======================================================================== *
1560    IdeaContainerProto
1561  * ======================================================================== */
1562 
1563 //	hierarchy:
1564 //		ProtoObj, IntangibleContainerProto, IdeaContainerProto
1565 
1566 class IdeaContainerProto : public IntangibleContainerProto {
1567 public:
IdeaContainerProto(ResourceObjectPrototype & proto)1568 	IdeaContainerProto(ResourceObjectPrototype &proto) : IntangibleContainerProto(proto) {}
~IdeaContainerProto()1569 	virtual ~IdeaContainerProto() {}
1570 
1571 	//Holding Idea Objects
1572 //	bool use( ObjectID dObj, ObjectID enactor );
1573 
1574 };
1575 
1576 /* ======================================================================== *
1577    MemoryContainerProto
1578  * ======================================================================== */
1579 
1580 //	hierarchy:
1581 //		ProtoObj, IntangibleContainerProto, MemoryContainerProto
1582 
1583 class MemoryContainerProto : public IntangibleContainerProto {
1584 public:
MemoryContainerProto(ResourceObjectPrototype & proto)1585 	MemoryContainerProto(ResourceObjectPrototype &proto) : IntangibleContainerProto(proto) {}
~MemoryContainerProto()1586 	virtual ~MemoryContainerProto() {}
1587 
1588 	//Holding Memories Of People You Met
1589 //	bool use( ObjectID dObj, ObjectID enactor );
1590 
1591 };
1592 
1593 /* ======================================================================== *
1594    PhychContainerProto
1595  * ======================================================================== */
1596 
1597 //	hierarchy:
1598 //		ProtoObj, IntangibleContainerProto, PsychContainerProto
1599 
1600 class PsychContainerProto : public IntangibleContainerProto {
1601 public:
PsychContainerProto(ResourceObjectPrototype & proto)1602 	PsychContainerProto(ResourceObjectPrototype &proto) : IntangibleContainerProto(proto) {}
~PsychContainerProto()1603 	virtual ~PsychContainerProto() {}
1604 
1605 	//Holding Psychological Objects
1606 //	bool use( ObjectID dObj, ObjectID enactor );
1607 
1608 };
1609 
1610 /* ======================================================================== *
1611    SkillContainerProto
1612  * ======================================================================== */
1613 
1614 //	hierarchy:
1615 //		ProtoObj, IntangibleContainerProto, SkillContainerProto
1616 
1617 class SkillContainerProto : public IntangibleContainerProto {
1618 public:
SkillContainerProto(ResourceObjectPrototype & proto)1619 	SkillContainerProto(ResourceObjectPrototype &proto) : IntangibleContainerProto(proto) {}
~SkillContainerProto()1620 	virtual ~SkillContainerProto() {}
1621 
1622 	//Holding Skills And Spells
1623 //	bool use( ObjectID dObj, ObjectID enactor );
1624 
1625 };
1626 
1627 /* ======================================================================== *
1628    MindContainerProto
1629  * ======================================================================== */
1630 
1631 //	hierarchy:
1632 //		ProtoObj, IntangibleContainerProto, MindContainerProto
1633 
1634 class MindContainerProto : public IntangibleContainerProto {
1635 public:
MindContainerProto(ResourceObjectPrototype & proto)1636 	MindContainerProto(ResourceObjectPrototype &proto) : IntangibleContainerProto(proto) {}
~MindContainerProto()1637 	virtual ~MindContainerProto() {}
1638 
1639 	//Contains Skill Psych Memory And Idea Containers
1640 //	virtual bool use( ObjectID dObj, ObjectID enactor );
1641 
1642 };
1643 
1644 /* ======================================================================== *
1645    EnchantmentProto
1646  * ======================================================================== */
1647 
1648 //	hierarchy:
1649 //		ProtoObj, EnchantmentProto
1650 
1651 class EnchantmentProto : public ProtoObj {
1652 public:
EnchantmentProto(ResourceObjectPrototype & proto)1653 	EnchantmentProto(ResourceObjectPrototype &proto) : ProtoObj(proto) {}
~EnchantmentProto()1654 	virtual ~EnchantmentProto() {}
1655 
1656 	//  Do the background processing, if needed, for this object.
1657 	void doBackgroundUpdate(GameObject *obj);
1658 
1659 	virtual uint16 containmentSet(void);
1660 };
1661 
1662 /* ======================================================================== *
1663    GeneratorProto
1664  * ======================================================================== */
1665 
1666 //	hierarchy:
1667 //		ProtoObj, GeneratorProto
1668 
1669 class GeneratorProto : public ProtoObj {
1670 public:
GeneratorProto(ResourceObjectPrototype & proto)1671 	GeneratorProto(ResourceObjectPrototype &proto) : ProtoObj(proto) {}
~GeneratorProto()1672 	virtual ~GeneratorProto() {}
1673 
1674 	//Base class for monster, encounter, and mission generators
1675 
1676 	virtual uint16 containmentSet(void);
1677 };
1678 
1679 /* ======================================================================== *
1680    MonsterGeneratorProto
1681  * ======================================================================== */
1682 
1683 //	hierarchy:
1684 //		ProtoObj, GeneratorProto, MonsterGeneratorProto
1685 
1686 class MonsterGeneratorProto : public GeneratorProto {
1687 public:
MonsterGeneratorProto(ResourceObjectPrototype & proto)1688 	MonsterGeneratorProto(ResourceObjectPrototype &proto) : GeneratorProto(proto) {}
~MonsterGeneratorProto()1689 	virtual ~MonsterGeneratorProto() {}
1690 
1691 	//Monster generators
1692 	//  REM: We don't want to generate monsters as a background activity, since
1693 	//  we may want more rapid generation that once every 10 seconds, and we only
1694 	//  want to do it while active anyway.
1695 };
1696 
1697 /* ======================================================================== *
1698    EncounterGeneratorProto
1699  * ======================================================================== */
1700 
1701 //	hierarchy:
1702 //		ProtoObj, GeneratorProto, EncounterGeneratorProto
1703 
1704 class EncounterGeneratorProto : public GeneratorProto {
1705 public:
EncounterGeneratorProto(ResourceObjectPrototype & proto)1706 	EncounterGeneratorProto(ResourceObjectPrototype &proto) : GeneratorProto(proto) {}
~EncounterGeneratorProto()1707 	virtual ~EncounterGeneratorProto() {}
1708 
1709 	//Encounter generator
1710 
1711 	//  Generate an encounter at approx. 10-second intervals
1712 	void doBackgroundUpdate(GameObject *obj);
1713 };
1714 
1715 /* ======================================================================== *
1716    MissionGeneratorProto
1717  * ======================================================================== */
1718 
1719 //	hierarchy:
1720 //		ProtoObj, GeneratorProto, MissionGeneratorProto
1721 
1722 class MissionGeneratorProto : public GeneratorProto {
1723 public:
MissionGeneratorProto(ResourceObjectPrototype & proto)1724 	MissionGeneratorProto(ResourceObjectPrototype &proto) : GeneratorProto(proto) {}
~MissionGeneratorProto()1725 	virtual ~MissionGeneratorProto() {}
1726 
1727 	//  Check every 10 seconds to see if we want to generate a mission.
1728 	void doBackgroundUpdate(GameObject *obj);
1729 };
1730 
1731 /*  Subclasses of "ProtoObj" which haven't been defined yet
1732 
1733         InventoryObjectPrototype            // can be dropped on ground
1734             ContainerPrototype              // holds a list of items
1735             BottlePrototype                 // holds 1 liquid
1736             FoodPrototype                   // edible
1737             WearablePrototype               // armor and jewelry
1738             WeaponPrototype                 // does damage efficiently
1739             DocumentPrototype               // expands to document window
1740         IntangableObjectPrototype           // Ideas and Magic
1741             ConceptObjectPrototype          // Basic Ideas (Food, Friend...)
1742             MemoryObjectPrototype           // Memories of game events
1743             PsychObjectPrototype            // I am ... (Brave, Humble...)
1744             SpellObjectPrototype            // Spells to cast
1745             EnchantmentObjectPrototype      // Enchants object that holds it
1746         IntangableContainerPrototype        // Containers for Ideas and Magic
1747             ConceptContainerPrototype       // Containers for Basic Ideas (Food, Friend...)
1748             MemoryContainerPrototype        // Containers for Memories of game events
1749             PsychContainerPrototype         // Containers for I am ... (Brave, Humble...)
1750             SpellContainerPrototype         // Containers for Spells to cast
1751 //          EnchantmentContainerPrototype   // Enchants object that holds it
1752         ProjectilePrototype                 // a missile in flight
1753 **      ActorPrototype
1754 */
1755 
1756 } // end of namespace Saga2
1757 
1758 #endif
1759