Files
oboe/osx/classes/monster.h
Celtic Minstrel c413d292a9 Tear out most of the legacy code in the game - see below for details
(PC Editor and Scenario Editor are unaffected by this commit.)

Things removed:
- All references to Carbon and QuickDraw are gone.
- No more Resource Manager; the game no longer relies on old resource files at all
- The old dialog framework (from dlogtool.c, functions usually prefixed with cd_) is no longer used.
- Files that weren't being compiled
- Boost libraries that are now in the C++ library (function, shared_ptr)
- Obsolete build settings

Replacement dependencies:
- Boost Filesystem replaces references to things like FSSpec
- SFML replaces all the QuickDraw code and most window management
- Cocoa replaces AppleEvent management, menu management, and some window management
- I wrote a resource manager interface to mimick the important aspects of the behaviour of the Mac Resource Manager
- I had to rewrite some functions that QuickDraw provided natively, such as clipping regions; not all of these are tested

Things added:
- Every referenced dialog has been converted from a DITL resource into the new XML-based dialog format.
- All referenced STR# resources have been extracted into simple text files
- Now compiles against Mac OSX 10.7 SDK and libc++
- The first item in the Help menu opens the docs on Sylae's website
- It seems all the constants for soundtool vanished somewhere, so I added them back from the original Mac source

Other changes:
- Updated to XCode 4(?) project format
- Added the xcschemes created by XCode 4; I'm not sure how important these are, but they seem like they might be important
- Added document on converting dialogs to the XML format.
- Make string formatting mismatches into errors instead of warnings
- Disable error limit
- Graphics sheets that previously used masking now have alpha transparency
- Converted all graphics sheets to 8-bit PNG
- Trimmed white border from intro image
- Converted dialogs in the resource file have their resource name set to the name of the XML file of the converted version
- Referenced string resources in the resource file have their resource name set to the name of the text file of the extracted version
- Add the black-and-white patterns from the PAT resources to the pixpats.png; at least one of them is used somewhere in the game
- Recreated the menu.xib as a Cocoa xib file instead of a Carbon xib file
- Disable GNU C++ extensions; maybe this'll make it easier to compile with cl.exe later
- Add marks to the enormous handle_action function to make it easier to navigate\
- A build step to validate the XML dialogs using xmllint (doesn't quite work properly yet but does at least catch dialogs that are not well-formed)- Fix a lot of warnings about assigning string constants to non-const char pointers
- Fixed the file and application icons (which had somehow become corrupted at some point)
- Lots of additional functions in the custom location and rectangle classes, including implicit conversion to and from SFML rects and vectors; also they now store coordinates as int instead of char
- A new enum for encounter note types
- Much tweaking of the encounter note recording mechanisms
- To ease porting, I added a simple function that converts from classic Mac ticks (about 1/60 of a second) to the SFML time type
- Python script to convert STR# resources to txt files, replacing newlines with vertical bars
- Extracted the Mac font (Dungeon Bold) from the resource file and also added the Windows font (MaidenWord)

XML Dialog Framework changes:
- Remove the static initialization object in favour of manually calling cDialog::init()
- {set,get}Format() no longer used for colour; there's a dedicated {set,get}Colour() instead
- draw() methods unprotected in the control classes so that controls can be drawn in the main window
- There's no longer a friend relationship between the dialogs and the controls
- Fixed buttons duplicating the "depressed" boolean
- Buttons now properly offset the label for tiny and push buttons, and for LEDs
- Buttons no longer assume that either none or both of "width" and "height" are given in the XML
- Add {get,set}BtnType() to cButton
- cLedGroup now overrides handleClick(), which has also been made virtual; this was necessary for LEDs within a group to properly hilite while being clicked
- Add addChoice() to cLedGroup to insert additional LED choices
- Moved the key enums and cKey to a separate file
- Add a method to get a control's attached key
- Add methods to get and set a control's rect and position
- Controls can now directly take a window as a parent rather than a dialog
- Add addLabelFor() method to cDialog which adds a static text control as a label for another control
- Remove hack for storing a dialog result of arbitrary type in favour of boost::any
- Add method to get default text colour for a dialog
- Add method to get a dialog's rect
- Add method to add the same event handler to multiple controls in a dialog
- Add concept of default button to dialogs
- Add enum for text field type (currently either number or text)
- Implement the text field without use of native controls, including somewhat decent text input and a flashing insertion point
- cPict no longer stores references to every sheet; it fetches them as needed from the resource manager
- The many draw functions in cPict are no longer static, since they need to access the window containing the pict (before they could only be static due to QuickDraw's global state)
- Add setPict() without a type argument to change the graphic without changing the type, which is a common operation
- Add a scrollbar control; the specifics aren't implemented yet
- Change signature of the record callback for cStrDlog; it will no longer be passed the strings
- Publicize the no-button constructor of cChoiceDlog; it'll assume "okay" is the only button
- Add operator-> to cPictChoice for accessing the underlying dialog
- Add constructor to cPictChoice that takes a starting and ending pic num
- Remove err parameter from giveError
- Many more keys handled, plus support for catching copy, paste, cut, and select all keyboard shortcuts
- Text input fields take priority, overriding any other keyboard shortcuts in the dialog, but they never catch help (F1), escape, or enter
- Some changes to the format itself:
-> keys go in the "def-key" attribute, but modifiers go in "key-mod"
-> "clickable" is no longer a recognized attribute
-> "title" is now a recognized text size (18pt, even larger than "large" at 12pt)
-> "defbtn" attribute on the root element
2014-04-14 13:52:01 -04:00

188 lines
5.9 KiB
C++

/*
* monster.h
* BoE
*
* Created by Celtic Minstrel on 20/04/09.
*
*/
#ifndef MONSTER_H
#define MONSTER_H
#include <string>
#include <iosfwd>
#include "soundtool.h"
#include "simpletypes.h"
#include "graphtool.h"
namespace legacy {
struct monster_record_type;
struct creature_data_type;
struct creature_start_type;
};
/* Attack Types */
#define MONSTER_ATTACK_SWINGS 0
#define MONSTER_ATTACK_CLAWS 1
#define MONSTER_ATTACK_BITES 2
#define MONSTER_ATTACK_SLIMES 3
#define MONSTER_ATTACK_PUNCHES 4
#define MONSTER_ATTACK_STINGS 5
#define MONSTER_ATTACK_CLUBS 6
#define MONSTER_ATTACK_BURNS 7
#define MONSTER_ATTACK_HARMS 8
#define MONSTER_ATTACK_STABS 9
#define MONSTER_NO_SPECIAL_ABILITY 0
#define MONSTER_THROWS_DARTS 1 //1-6
#define MONSTER_SHOOTS_ARROWS 2 //2-12
#define MONSTER_THROWS_SPEARS 3 //3-18
#define MONSTER_THROWS_ROCKS1 4 //4-24 damages
#define MONSTER_THROWS_ROCKS2 5 //5-30 damages
#define MONSTER_THROWS_ROCKS3 6 //6-36 damages
#define MONSTER_THROWS_RAZORDISKS 7 //4-24
#define MONSTER_PETRIFICATION_RAY 8
#define MONSTER_SP_DRAIN_RAY 9 //spell points drain ray
#define MONSTER_HEAT_RAY 10
#define MONSTER_INVISIBLE 11
#define MONSTER_SPLITS 12
#define MONSTER_MINDLESS 13
#define MONSTER_BREATHES_STINKING_CLOUDS 14
#define MONSTER_ICY_TOUCH 15
#define MONSTER_XP_DRAINING_TOUCH 16
#define MONSTER_ICY_AND_DRAINING_TOUCH 17
#define MONSTER_SLOWING_TOUCH 18
#define MONSTER_SHOOTS_WEB 19
#define MONSTER_GOOD_ARCHER 20 //7-42
#define MONSTER_STEALS_FOOD 21
#define MONSTER_PERMANENT_MARTYRS_SHIELD 22
#define MONSTER_PARALYSIS_RAY 23
#define MONSTER_DUMBFOUNDING_TOUCH 24
#define MONSTER_DISEASE_TOUCH 25
#define MONSTER_ABSORB_SPELLS 26
#define MONSTER_WEB_TOUCH 27
#define MONSTER_SLEEP_TOUCH 28
#define MONSTER_PARALYSIS_TOUCH 29
#define MONSTER_PETRIFICATION_TOUCH 30
#define MONSTER_ACID_TOUCH 31
#define MONSTER_BREATHES_SLEEP_CLOUDS 32
#define MONSTER_ACID_SPIT 33
#define MONSTER_SHOOTS_SPINES 34 //7-42
#define MONSTER_DEATH_TOUCH 35
#define MONSTER_INVULNERABILITY 36
#define MONSTER_GUARD 37
/* Create Monsters/Fields */
#define MONSTER_NO_RADIATE 0
#define MONSTER_RADIATE_FIRE_FIELDS 1
#define MONSTER_RADIATE_ICE_FIELDS 2
#define MONSTER_RADIATE_SHOCK_FIELDS 3
#define MONSTER_RADIATE_ANTIMAGIC_FIELDS 4
#define MONSTER_RADIATE_SLEEP_FIELDS 5
#define MONSTER_RADIATE_STINKING_CLOUDS 6
//as said 7,8 and 9 are unused
#define MONSTER_SUMMON1 10 //5 percent chance
#define MONSTER_SUMMON2 11 //20 percent chance
#define MONSTER_SUMMON3 12 //50 percent chance
//as said 13 and 14 are unused
#define MONSTER_DEATH_TRIGGERS 15 //death triggers global special
class cMonster {
public:
struct cAttack{
unsigned char dice, sides, type;
// TODO: Remove the need for these operators by changing the code that uses them
operator int();
cAttack& operator=(int n);
};
struct cAbility{
eMonstAbil abil;
unsigned char extra1, extra2;
operator std::string();
};
m_num_t m_num; // TODO: This probably shouldn't be necessary. Consider why it is, and determine if it can be removed
unsigned char level;
std::string m_name;
short health; // TODO: Move health, mp and max_mp to cCreature
short m_health;
short mp;
short max_mp;
unsigned char armor;
unsigned char skill;
cAttack a[3];
unsigned char a1_type,a23_type; // TODO: Delete in favour of type field of cAttack
eMonsterType m_type;
unsigned char speed;
unsigned char ap; // TODO: Move ap to cCreature
unsigned char mu;
unsigned char cl;
unsigned char breath;
unsigned char breath_type;
unsigned char treasure;
unsigned char spec_skill; // TODO: Delete in favour of cAbility
unsigned char poison;
short morale,m_morale; // TODO: Move to cCreature (since these are calculated in-game based on the level)
item_num_t corpse_item;
short corpse_item_chance;
short status[15]; // TODO: Move to cCreature
unsigned char direction; // TODO: Move direction to cCreature
unsigned char immunities;
unsigned char x_width,y_width;
unsigned char radiate_1; // TODO: Delete in favour of cAbility
unsigned short radiate_2; // I THINK this is the extra field for the second ability TODO: Delete in favour of cAbility
unsigned char default_attitude;
unsigned char summon_type;
pic_num_t default_facial_pic;
pic_num_t picture_num;
str_num_t see_str1, see_str2;
snd_num_t see_sound, ambient_sound; // ambient_sound has a chance of being played every move
spec_num_t see_spec;
private:
cAbility abil1, abil2;
public:
std::string getAbil1Name();
std::string getAbil2Name();
bool hasAbil(eMonstAbil what, unsigned char* x1 = NULL, unsigned char* x2 = NULL);
cMonster& operator = (legacy::monster_record_type& old);
cMonster();
void writeTo(std::ostream& file, std::string prefix);
};
class cCreature : public cMonster {
public:
using cMonster::operator=;
unsigned long id;
m_num_t number; // TODO: This appears to be a duplicate of cMonster::m_num (ie it's used for the same thing)
short active, attitude;
unsigned char start_attitude;
location start_loc, cur_loc;
unsigned char mobility; // Was a bool, but am making it a char to allow for additional mobility states
unsigned char time_flag;
short summoned;
unsigned char extra1, extra2;
short spec1, spec2;
char spec_enc_code, time_code;
short monster_time, personality;
short special_on_kill, facial_pic;
short target;
location targ_loc;
cCreature();
cCreature& operator = (legacy::creature_data_type old);
cCreature& operator = (legacy::creature_start_type old);
cCreature& operator = (const cCreature& other);
//cCreature& operator = (const cMonster& other);
};
std::ostream& operator << (std::ostream& out, eStatus& e);
std::istream& operator >> (std::istream& in, eStatus& e);
std::ostream& operator << (std::ostream& out, eRace& e);
std::istream& operator >> (std::istream& in, eRace& e);
std::ostream& operator << (std::ostream& out, eMonstAbil& e);
std::istream& operator >> (std::istream& in, eMonstAbil& e);
#endif