1 /** 2 * @file monster.h 3 * 4 * Interface of monster functionality, AI, actions, spawning, loading, etc. 5 */ 6 #ifndef __MONSTER_H__ 7 #define __MONSTER_H__ 8 9 DEVILUTION_BEGIN_NAMESPACE 10 11 #ifdef __cplusplus 12 extern "C" { 13 #endif 14 15 typedef enum MON_MODE { 16 MM_STAND, 17 /** Movement towards N, NW, or NE */ 18 MM_WALK, 19 /** Movement towards S, SW, or SE */ 20 MM_WALK2, 21 /** Movement towards W or E */ 22 MM_WALK3, 23 MM_ATTACK, 24 MM_GOTHIT, 25 MM_DEATH, 26 MM_SATTACK, 27 MM_FADEIN, 28 MM_FADEOUT, 29 MM_RATTACK, 30 MM_SPSTAND, 31 MM_RSPATTACK, 32 MM_DELAY, 33 MM_CHARGE, 34 MM_STONE, 35 MM_HEAL, 36 MM_TALK, 37 } MON_MODE; 38 39 typedef struct CMonster { 40 _monster_id mtype; 41 /** placeflag enum as a flags*/ 42 Uint8 mPlaceFlags; 43 AnimStruct Anims[6]; 44 TSnd *Snds[4][2]; 45 Sint32 width; 46 Sint32 width2; 47 uint16_t mMinHP; 48 uint16_t mMaxHP; 49 bool has_special; 50 Uint8 mAFNum; 51 Sint8 mdeadval; 52 const MonsterData *MData; 53 /** 54 * A TRN file contains a sequence of color transitions, represented 55 * as indexes into a palette. (a 256 byte array of palette indices) 56 */ 57 Uint8 *trans_file; 58 } CMonster; 59 60 typedef struct MonsterStruct { // note: missing field _mAFNum 61 Sint32 _mMTidx; 62 MON_MODE _mmode; 63 Uint8 _mgoal; 64 Sint32 _mgoalvar1; 65 Sint32 _mgoalvar2; 66 Sint32 _mgoalvar3; 67 Uint8 _pathcount; 68 /** Tile X-position of monster */ 69 Sint32 _mx; 70 /** Tile Y-position of monster */ 71 Sint32 _my; 72 /** Future tile X-position of monster. Set at start of walking animation */ 73 Sint32 _mfutx; 74 /** Future tile Y-position of monster. Set at start of walking animation */ 75 Sint32 _mfuty; 76 /** Most recent X-position in dMonster. */ 77 Sint32 _moldx; 78 /** Most recent Y-position in dMonster. */ 79 Sint32 _moldy; 80 /** Monster sprite's pixel X-offset from tile. */ 81 Sint32 _mxoff; 82 /** Monster sprite's pixel Y-offset from tile. */ 83 Sint32 _myoff; 84 /** Pixel X-velocity while walking. Applied to _mxoff */ 85 Sint32 _mxvel; 86 /** Pixel Y-velocity while walking. Applied to _myoff */ 87 Sint32 _myvel; 88 /** Direction faced by monster (direction enum) */ 89 Sint32 _mdir; 90 /** The current target of the mosnter. An index in to either the plr or monster array based on the _meflag value. */ 91 Sint32 _menemy; 92 /** X-coordinate of enemy (usually correspond's to the enemy's futx value) */ 93 Uint8 _menemyx; 94 /** Y-coordinate of enemy (usually correspond's to the enemy's futy value) */ 95 Uint8 _menemyy; 96 Uint8 *_mAnimData; 97 /** Tick length of each frame in the current animation */ 98 Sint32 _mAnimDelay; 99 /** Increases by one each game tick, counting how close we are to _pAnimDelay */ 100 Sint32 _mAnimCnt; 101 /** Number of frames in current animation */ 102 Sint32 _mAnimLen; 103 /** Current frame of animation. */ 104 Sint32 _mAnimFrame; 105 bool _mDelFlag; 106 Sint32 _mVar1; 107 Sint32 _mVar2; 108 Sint32 _mVar3; 109 Sint32 _mVar4; 110 Sint32 _mVar5; 111 /** Used as _mxoff but with a higher range so that we can correctly apply velocities of a smaller number */ 112 Sint32 _mVar6; 113 /** Used as _myoff but with a higher range so that we can correctly apply velocities of a smaller number */ 114 Sint32 _mVar7; 115 /** Value used to measure progress for moving from one tile to another */ 116 Sint32 _mVar8; 117 Sint32 _mmaxhp; 118 Sint32 _mhitpoints; 119 _mai_id _mAi; 120 Uint8 _mint; 121 Uint32 _mFlags; 122 Uint8 _msquelch; 123 Sint32 _lastx; 124 Sint32 _lasty; 125 Sint32 _mRndSeed; 126 Sint32 _mAISeed; 127 Uint8 _uniqtype; 128 Uint8 _uniqtrans; 129 Sint8 _udeadval; 130 Sint8 mWhoHit; 131 Sint8 mLevel; 132 Uint16 mExp; 133 Uint16 mHit; 134 Uint8 mMinDamage; 135 Uint8 mMaxDamage; 136 Uint16 mHit2; 137 Uint8 mMinDamage2; 138 Uint8 mMaxDamage2; 139 Uint8 mArmorClass; 140 Uint16 mMagicRes; 141 Sint32 mtalkmsg; 142 Uint8 leader; 143 Uint8 leaderflag; 144 Uint8 packsize; 145 Sint8 mlid; // BUGFIX -1 is used when not emitting light this should be signed (fixed) 146 const char *mName; 147 CMonster *MType; 148 const MonsterData *MData; 149 } MonsterStruct; 150 151 extern int monstkills[MAXMONSTERS]; 152 extern int monstactive[MAXMONSTERS]; 153 extern int nummonsters; 154 extern BOOLEAN sgbSaveSoundOn; 155 extern MonsterStruct monster[MAXMONSTERS]; 156 extern CMonster Monsters[MAX_LVLMTYPES]; 157 extern int nummtypes; 158 159 void InitLevelMonsters(); 160 void GetLevelMTypes(); 161 void InitMonsterGFX(int monst); 162 void InitMonster(int i, int rd, int mtype, int x, int y); 163 void ClrAllMonsters(); 164 void monster_some_crypt(); 165 void PlaceGroup(int mtype, int num, int leaderf, int leader); 166 void InitMonsters(); 167 void SetMapMonsters(BYTE *pMap, int startx, int starty); 168 void DeleteMonster(int i); 169 int AddMonster(int x, int y, int dir, int mtype, BOOL InMap); 170 void monster_43C785(int i); 171 BOOL M_Talker(int i); 172 void M_StartStand(int i, int md); 173 void M_ClearSquares(int i); 174 void M_GetKnockback(int i); 175 void M_StartHit(int i, int pnum, int dam); 176 void M_StartKill(int i, int pnum); 177 void M_SyncStartKill(int i, int x, int y, int pnum); 178 void M_Teleport(int i); 179 void M_UpdateLeader(int i); 180 void DoEnding(); 181 void PrepDoEnding(); 182 void M_WalkDir(int i, int md); 183 void MAI_Zombie(int i); 184 void MAI_SkelSd(int i); 185 void MAI_Snake(int i); 186 void MAI_Bat(int i); 187 void MAI_SkelBow(int i); 188 void MAI_Fat(int i); 189 void MAI_Sneak(int i); 190 void MAI_Fireman(int i); 191 void MAI_Fallen(int i); 192 void MAI_Cleaver(int i); 193 void MAI_Round(int i, BOOL special); 194 void MAI_GoatMc(int i); 195 void MAI_Ranged(int i, int missile_type, BOOL special); 196 void MAI_GoatBow(int i); 197 void MAI_Succ(int i); 198 void MAI_Lich(int i); 199 void MAI_ArchLich(int i); 200 void MAI_Psychorb(int i); 201 void MAI_Necromorb(int i); 202 void MAI_AcidUniq(int i); 203 void MAI_Firebat(int i); 204 void MAI_Torchant(int i); 205 void MAI_Scav(int i); 206 void MAI_Garg(int i); 207 void MAI_RoundRanged(int i, int missile_type, BOOL checkdoors, int dam, int lessmissiles); 208 void MAI_Magma(int i); 209 void MAI_Storm(int i); 210 void MAI_BoneDemon(int i); 211 void MAI_Acid(int i); 212 void MAI_Diablo(int i); 213 void MAI_Mega(int i); 214 void MAI_Golum(int i); 215 void MAI_SkelKing(int i); 216 void MAI_Rhino(int i); 217 void MAI_HorkDemon(int i); 218 void MAI_Counselor(int i); 219 void MAI_Garbud(int i); 220 void MAI_Zhar(int i); 221 void MAI_SnotSpil(int i); 222 void MAI_Lazurus(int i); 223 void MAI_Lazhelp(int i); 224 void MAI_Lachdanan(int i); 225 void MAI_Warlord(int i); 226 void DeleteMonsterList(); 227 void ProcessMonsters(); 228 void FreeMonsters(); 229 BOOL DirOK(int i, int mdir); 230 BOOL PosOkMissile(int x, int y); 231 BOOL CheckNoSolid(int x, int y); 232 BOOL LineClearF(BOOL (*Clear)(int, int), int x1, int y1, int x2, int y2); 233 BOOL LineClear(int x1, int y1, int x2, int y2); 234 BOOL LineClearF1(BOOL (*Clear)(int, int, int), int monst, int x1, int y1, int x2, int y2); 235 void SyncMonsterAnim(int i); 236 void M_FallenFear(int x, int y); 237 void PrintMonstHistory(int mt); 238 void PrintUniqueHistory(); 239 void MissToMonst(int i, int x, int y); 240 BOOL PosOkMonst(int i, int x, int y); 241 BOOLEAN monster_posok(int i, int x, int y); 242 BOOL PosOkMonst2(int i, int x, int y); 243 BOOL PosOkMonst3(int i, int x, int y); 244 BOOL IsSkel(int mt); 245 BOOL IsGoat(int mt); 246 int M_SpawnSkel(int x, int y, int dir); 247 BOOL SpawnSkeleton(int ii, int x, int y); 248 int PreSpawnSkeleton(); 249 void TalktoMonster(int i); 250 void SpawnGolum(int i, int x, int y, int mi); 251 BOOL CanTalkToMonst(int m); 252 BOOL CheckMonsterHit(int m, BOOL *ret); 253 int encode_enemy(int m); 254 void decode_enemy(int m, int enemy); 255 256 /* data */ 257 258 extern int opposite[8]; 259 extern int offset_x[8]; 260 extern int offset_y[8]; 261 262 #ifdef __cplusplus 263 } 264 #endif 265 266 DEVILUTION_END_NAMESPACE 267 268 #endif /* __MONSTER_H__ */ 269