global.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  1. /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
  2. //
  3. // Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
  4. // All rights reserved.
  5. //
  6. // This file is part of SDLPAL.
  7. //
  8. // SDLPAL is free software: you can redistribute it and/or modify
  9. // it under the terms of the GNU General Public License as published by
  10. // the Free Software Foundation, either version 3 of the License, or
  11. // (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. //
  21. // Modified by Lou Yihua <louyihua@21cn.com> with Unicode support, 2015
  22. //
  23. #ifndef GLOBAL_H
  24. #define GLOBAL_H
  25. #include "common.h"
  26. #include "palcommon.h"
  27. #include "map.h"
  28. #include "ui.h"
  29. #ifdef __cplusplus
  30. extern "C"
  31. {
  32. #endif
  33. //
  34. // SOME NOTES ON "AUTO SCRIPT" AND "TRIGGER SCRIPT":
  35. //
  36. // Auto scripts are executed automatically in each frame.
  37. //
  38. // Trigger scripts are only executed when the event is triggered (player touched
  39. // an event object, player triggered an event script by pressing Spacebar).
  40. //
  41. // maximum number of players in party
  42. #define MAX_PLAYERS_IN_PARTY 3
  43. // total number of possible player roles
  44. #define MAX_PLAYER_ROLES 6
  45. // totally number of playable player roles
  46. #define MAX_PLAYABLE_PLAYER_ROLES 5
  47. // maximum entries of inventory
  48. #define MAX_INVENTORY 256
  49. // maximum items in a store
  50. #define MAX_STORE_ITEM 9
  51. // total number of magic attributes
  52. #define NUM_MAGIC_ELEMENTAL 5
  53. // maximum number of enemies in a team
  54. #define MAX_ENEMIES_IN_TEAM 5
  55. // maximum number of equipments for a player
  56. #define MAX_PLAYER_EQUIPMENTS 6
  57. // maximum number of magics for a player
  58. #define MAX_PLAYER_MAGICS 32
  59. // maximum number of scenes
  60. #define MAX_SCENES 300
  61. // maximum number of objects
  62. #define MAX_OBJECTS 600
  63. // maximum number of event objects (should be somewhat more than the original,
  64. // as there are some modified versions which has more)
  65. #define MAX_EVENT_OBJECTS 5500
  66. // maximum number of effective poisons to players
  67. #define MAX_POISONS 16
  68. // maximum number of level
  69. #define MAX_LEVELS 99
  70. #define OBJECT_ITEM_START 0x3D
  71. #define OBJECT_ITEM_END 0x126
  72. #define OBJECT_MAGIC_START 0x127
  73. #define OBJECT_MAGIC_END 0x18D
  74. // status of characters
  75. typedef enum tagSTATUS
  76. {
  77. kStatusConfused = 0, // attack friends randomly
  78. #ifdef PAL_CLASSIC
  79. kStatusParalyzed, // paralyzed
  80. #else
  81. kStatusSlow, // slower
  82. #endif
  83. kStatusSleep, // not allowed to move
  84. kStatusSilence, // cannot use magic
  85. kStatusPuppet, // for dead players only, continue attacking
  86. kStatusBravery, // more power for physical attacks
  87. kStatusProtect, // more defense value
  88. kStatusHaste, // faster
  89. kStatusDualAttack, // dual attack
  90. kStatusAll
  91. } STATUS;
  92. #ifndef PAL_CLASSIC
  93. #define kStatusParalyzed kStatusSleep
  94. #endif
  95. // body parts of equipments
  96. typedef enum tagBODYPART
  97. {
  98. kBodyPartHead = 0,
  99. kBodyPartBody,
  100. kBodyPartShoulder,
  101. kBodyPartHand,
  102. kBodyPartFeet,
  103. kBodyPartWear,
  104. kBodyPartExtra,
  105. } BODYPART;
  106. // state of event object, used by the sState field of the EVENTOBJECT struct
  107. typedef enum tagOBJECTSTATE
  108. {
  109. kObjStateHidden = 0,
  110. kObjStateNormal = 1,
  111. kObjStateBlocker = 2
  112. } OBJECTSTATE, *LPOBJECTSTATE;
  113. typedef enum tagTRIGGERMODE
  114. {
  115. kTriggerNone = 0,
  116. kTriggerSearchNear = 1,
  117. kTriggerSearchNormal = 2,
  118. kTriggerSearchFar = 3,
  119. kTriggerTouchNear = 4,
  120. kTriggerTouchNormal = 5,
  121. kTriggerTouchFar = 6,
  122. kTriggerTouchFarther = 7,
  123. kTriggerTouchFarthest = 8
  124. } TRIGGERMODE;
  125. typedef struct tagEVENTOBJECT
  126. {
  127. SHORT sVanishTime; // vanish time (?)
  128. WORD x; // X coordinate on the map
  129. WORD y; // Y coordinate on the map
  130. SHORT sLayer; // layer value
  131. WORD wTriggerScript; // Trigger script entry
  132. WORD wAutoScript; // Auto script entry
  133. SHORT sState; // state of this object
  134. WORD wTriggerMode; // trigger mode
  135. WORD wSpriteNum; // number of the sprite
  136. USHORT nSpriteFrames; // total number of frames of the sprite
  137. WORD wDirection; // direction
  138. WORD wCurrentFrameNum; // current frame number
  139. USHORT nScriptIdleFrame; // count of idle frames, used by trigger script
  140. WORD wSpritePtrOffset; // FIXME: ???
  141. USHORT nSpriteFramesAuto; // total number of frames of the sprite, used by auto script
  142. WORD wScriptIdleFrameCountAuto; // count of idle frames, used by auto script
  143. } EVENTOBJECT, *LPEVENTOBJECT;
  144. typedef struct tagSCENE
  145. {
  146. WORD wMapNum; // number of the map
  147. WORD wScriptOnEnter; // when entering this scene, execute script from here
  148. WORD wScriptOnTeleport; // when teleporting out of this scene, execute script from here
  149. WORD wEventObjectIndex; // event objects in this scene begins from number wEventObjectIndex + 1
  150. } SCENE, *LPSCENE;
  151. // object including system strings, players, items, magics, enemies and poison scripts.
  152. // system strings and players
  153. typedef struct tagOBJECT_PLAYER
  154. {
  155. WORD wReserved[2]; // always zero
  156. WORD wScriptOnFriendDeath; // when friends in party dies, execute script from here
  157. WORD wScriptOnDying; // when dying, execute script from here
  158. } OBJECT_PLAYER;
  159. typedef enum tagITEMFLAG
  160. {
  161. kItemFlagUsable = (1 << 0),
  162. kItemFlagEquipable = (1 << 1),
  163. kItemFlagThrowable = (1 << 2),
  164. kItemFlagConsuming = (1 << 3),
  165. kItemFlagApplyToAll = (1 << 4),
  166. kItemFlagSellable = (1 << 5),
  167. kItemFlagEquipableByPlayerRole_First = (1 << 6)
  168. } ITEMFLAG;
  169. // items
  170. typedef struct tagOBJECT_ITEM_DOS
  171. {
  172. WORD wBitmap; // bitmap number in BALL.MKF
  173. WORD wPrice; // price
  174. WORD wScriptOnUse; // script executed when using this item
  175. WORD wScriptOnEquip; // script executed when equipping this item
  176. WORD wScriptOnThrow; // script executed when throwing this item to enemy
  177. WORD wFlags; // flags
  178. } OBJECT_ITEM_DOS;
  179. // items
  180. typedef struct tagOBJECT_ITEM
  181. {
  182. WORD wBitmap; // bitmap number in BALL.MKF
  183. WORD wPrice; // price
  184. WORD wScriptOnUse; // script executed when using this item
  185. WORD wScriptOnEquip; // script executed when equipping this item
  186. WORD wScriptOnThrow; // script executed when throwing this item to enemy
  187. WORD wScriptDesc; // description script
  188. WORD wFlags; // flags
  189. } OBJECT_ITEM;
  190. typedef enum tagMAGICFLAG
  191. {
  192. kMagicFlagUsableOutsideBattle = (1 << 0),
  193. kMagicFlagUsableInBattle = (1 << 1),
  194. kMagicFlagUsableToEnemy = (1 << 3),
  195. kMagicFlagApplyToAll = (1 << 4),
  196. } MAGICFLAG;
  197. // magics
  198. typedef struct tagOBJECT_MAGIC_DOS
  199. {
  200. WORD wMagicNumber; // magic number, according to DATA.MKF #3
  201. WORD wReserved1; // always zero
  202. WORD wScriptOnSuccess; // when magic succeed, execute script from here
  203. WORD wScriptOnUse; // when use this magic, execute script from here
  204. WORD wReserved2; // always zero
  205. WORD wFlags; // flags
  206. } OBJECT_MAGIC_DOS;
  207. // magics
  208. typedef struct tagOBJECT_MAGIC
  209. {
  210. WORD wMagicNumber; // magic number, according to DATA.MKF #3
  211. WORD wReserved1; // always zero
  212. WORD wScriptOnSuccess; // when magic succeed, execute script from here
  213. WORD wScriptOnUse; // when use this magic, execute script from here
  214. WORD wScriptDesc; // description script
  215. WORD wReserved2; // always zero
  216. WORD wFlags; // flags
  217. } OBJECT_MAGIC;
  218. // enemies
  219. typedef struct tagOBJECT_ENEMY
  220. {
  221. WORD wEnemyID; // ID of the enemy, according to DATA.MKF #1.
  222. // Also indicates the bitmap number in ABC.MKF.
  223. WORD wResistanceToSorcery; // resistance to sorcery and poison (0 min, 10 max)
  224. WORD wScriptOnTurnStart; // script executed when turn starts
  225. WORD wScriptOnBattleEnd; // script executed when battle ends
  226. WORD wScriptOnReady; // script executed when the enemy is ready
  227. } OBJECT_ENEMY;
  228. // poisons (scripts executed in each round)
  229. typedef struct tagOBJECT_POISON
  230. {
  231. WORD wPoisonLevel; // level of the poison
  232. WORD wColor; // color of avatars
  233. WORD wPlayerScript; // script executed when player has this poison (per round)
  234. WORD wReserved; // always zero
  235. WORD wEnemyScript; // script executed when enemy has this poison (per round)
  236. } OBJECT_POISON;
  237. typedef union tagOBJECT_DOS
  238. {
  239. WORD rgwData[6];
  240. OBJECT_PLAYER player;
  241. OBJECT_ITEM_DOS item;
  242. OBJECT_MAGIC_DOS magic;
  243. OBJECT_ENEMY enemy;
  244. OBJECT_POISON poison;
  245. } OBJECT_DOS, *LPOBJECT_DOS;
  246. typedef union tagOBJECT
  247. {
  248. WORD rgwData[7];
  249. OBJECT_PLAYER player;
  250. OBJECT_ITEM item;
  251. OBJECT_MAGIC magic;
  252. OBJECT_ENEMY enemy;
  253. OBJECT_POISON poison;
  254. } OBJECT, *LPOBJECT;
  255. typedef struct tagSCRIPTENTRY
  256. {
  257. WORD wOperation; // operation code
  258. WORD rgwOperand[3]; // operands
  259. } SCRIPTENTRY, *LPSCRIPTENTRY;
  260. typedef struct tagINVENTORY
  261. {
  262. WORD wItem; // item object code
  263. USHORT nAmount; // amount of this item
  264. USHORT nAmountInUse; // in-use amount of this item
  265. } INVENTORY, *LPINVENTORY;
  266. typedef struct tagSTORE
  267. {
  268. WORD rgwItems[MAX_STORE_ITEM];
  269. } STORE, *LPSTORE;
  270. typedef struct tagENEMY
  271. {
  272. WORD wIdleFrames; // total number of frames when idle
  273. WORD wMagicFrames; // total number of frames when using magics
  274. WORD wAttackFrames; // total number of frames when doing normal attack
  275. WORD wIdleAnimSpeed; // speed of the animation when idle
  276. WORD wActWaitFrames; // FIXME: ???
  277. WORD wYPosOffset;
  278. WORD wAttackSound; // sound played when this enemy uses normal attack
  279. WORD wActionSound; // FIXME: ???
  280. WORD wMagicSound; // sound played when this enemy uses magic
  281. WORD wDeathSound; // sound played when this enemy dies
  282. WORD wCallSound; // sound played when entering the battle
  283. WORD wHealth; // total HP of the enemy
  284. WORD wExp; // How many EXPs we'll get for beating this enemy
  285. WORD wCash; // how many cashes we'll get for beating this enemy
  286. WORD wLevel; // this enemy's level
  287. WORD wMagic; // this enemy's magic number
  288. WORD wMagicRate; // chance for this enemy to use magic
  289. WORD wAttackEquivItem; // equivalence item of this enemy's normal attack
  290. WORD wAttackEquivItemRate;// chance for equivalence item
  291. WORD wStealItem; // which item we'll get when stealing from this enemy
  292. USHORT nStealItem; // total amount of the items which can be stolen
  293. WORD wAttackStrength; // normal attack strength
  294. WORD wMagicStrength; // magical attack strength
  295. WORD wDefense; // resistance to all kinds of attacking
  296. WORD wDexterity; // dexterity
  297. WORD wFleeRate; // chance for successful fleeing
  298. WORD wPoisonResistance; // resistance to poison
  299. WORD wElemResistance[NUM_MAGIC_ELEMENTAL]; // resistance to elemental magics
  300. WORD wPhysicalResistance; // resistance to physical attack
  301. WORD wDualMove; // whether this enemy can do dual move or not
  302. WORD wCollectValue; // value for collecting this enemy for items
  303. } ENEMY, *LPENEMY;
  304. typedef struct tagENEMYTEAM
  305. {
  306. WORD rgwEnemy[MAX_ENEMIES_IN_TEAM];
  307. } ENEMYTEAM, *LPENEMYTEAM;
  308. typedef WORD PLAYERS[MAX_PLAYER_ROLES];
  309. typedef struct tagPLAYERROLES
  310. {
  311. PLAYERS rgwAvatar; // avatar (shown in status view)
  312. PLAYERS rgwSpriteNumInBattle; // sprite displayed in battle (in F.MKF)
  313. PLAYERS rgwSpriteNum; // sprite displayed in normal scene (in MGO.MKF)
  314. PLAYERS rgwName; // name of player class (in WORD.DAT)
  315. PLAYERS rgwAttackAll; // whether player can attack everyone in a bulk or not
  316. PLAYERS rgwUnknown1; // FIXME: ???
  317. PLAYERS rgwLevel; // level
  318. PLAYERS rgwMaxHP; // maximum HP
  319. PLAYERS rgwMaxMP; // maximum MP
  320. PLAYERS rgwHP; // current HP
  321. PLAYERS rgwMP; // current MP
  322. WORD rgwEquipment[MAX_PLAYER_EQUIPMENTS][MAX_PLAYER_ROLES]; // equipments
  323. PLAYERS rgwAttackStrength; // normal attack strength
  324. PLAYERS rgwMagicStrength; // magical attack strength
  325. PLAYERS rgwDefense; // resistance to all kinds of attacking
  326. PLAYERS rgwDexterity; // dexterity
  327. PLAYERS rgwFleeRate; // chance of successful fleeing
  328. PLAYERS rgwPoisonResistance; // resistance to poison
  329. WORD rgwElementalResistance[NUM_MAGIC_ELEMENTAL][MAX_PLAYER_ROLES]; // resistance to elemental magics
  330. PLAYERS rgwUnknown2; // FIXME: ???
  331. PLAYERS rgwUnknown3; // FIXME: ???
  332. PLAYERS rgwUnknown4; // FIXME: ???
  333. PLAYERS rgwCoveredBy; // who will cover me when I am low of HP or not sane
  334. WORD rgwMagic[MAX_PLAYER_MAGICS][MAX_PLAYER_ROLES]; // magics
  335. PLAYERS rgwWalkFrames; // walk frame (???)
  336. PLAYERS rgwCooperativeMagic; // cooperative magic
  337. PLAYERS rgwUnknown5; // FIXME: ???
  338. PLAYERS rgwUnknown6; // FIXME: ???
  339. PLAYERS rgwDeathSound; // sound played when player dies
  340. PLAYERS rgwAttackSound; // sound played when player attacks
  341. PLAYERS rgwWeaponSound; // weapon sound (???)
  342. PLAYERS rgwCriticalSound; // sound played when player make critical hits
  343. PLAYERS rgwMagicSound; // sound played when player is casting a magic
  344. PLAYERS rgwCoverSound; // sound played when player cover others
  345. PLAYERS rgwDyingSound; // sound played when player is dying
  346. } PLAYERROLES, *LPPLAYERROLES;
  347. typedef enum tagMAGIC_TYPE
  348. {
  349. kMagicTypeNormal = 0,
  350. kMagicTypeAttackAll = 1, // draw the effect on each of the enemies
  351. kMagicTypeAttackWhole = 2, // draw the effect on the whole enemy team
  352. kMagicTypeAttackField = 3, // draw the effect on the battle field
  353. kMagicTypeApplyToPlayer = 4, // the magic is used on one player
  354. kMagicTypeApplyToParty = 5, // the magic is used on the whole party
  355. kMagicTypeTrance = 8, // trance the player
  356. kMagicTypeSummon = 9, // summon
  357. } MAGIC_TYPE;
  358. typedef struct tagMAGIC
  359. {
  360. WORD wEffect; // effect sprite
  361. WORD wType; // type of this magic
  362. WORD wXOffset;
  363. WORD wYOffset;
  364. WORD wSummonEffect; // summon effect sprite (in F.MKF)
  365. WORD wSpeed; // speed of the effect
  366. WORD wKeepEffect; // FIXME: ???
  367. WORD wSoundDelay; // delay of the SFX
  368. WORD wEffectTimes; // total times of effect
  369. WORD wShake; // shake screen
  370. WORD wWave; // wave screen
  371. WORD wUnknown; // FIXME: ???
  372. WORD wCostMP; // MP cost
  373. WORD wBaseDamage; // base damage
  374. WORD wElemental; // elemental (0 = No Elemental, last = poison)
  375. WORD wSound; // sound played when using this magic
  376. } MAGIC, *LPMAGIC;
  377. typedef struct tagBATTLEFIELD
  378. {
  379. WORD wScreenWave; // level of screen waving
  380. SHORT rgsMagicEffect[NUM_MAGIC_ELEMENTAL]; // effect of attributed magics
  381. } BATTLEFIELD, *LPBATTLEFIELD;
  382. // magics learned when level up
  383. typedef struct tagLEVELUPMAGIC
  384. {
  385. WORD wLevel; // level reached
  386. WORD wMagic; // magic learned
  387. } LEVELUPMAGIC, *LPLEVELUPMAGIC;
  388. typedef struct tagLEVELUPMAGIC_ALL
  389. {
  390. LEVELUPMAGIC m[MAX_PLAYABLE_PLAYER_ROLES];
  391. } LEVELUPMAGIC_ALL, *LPLEVELUPMAGIC_ALL;
  392. typedef struct tagENEMYPOS
  393. {
  394. struct {
  395. WORD x;
  396. WORD y;
  397. } pos[MAX_ENEMIES_IN_TEAM][MAX_ENEMIES_IN_TEAM];
  398. } ENEMYPOS, *LPENEMYPOS;
  399. // Exp. points needed for the next level
  400. typedef WORD LEVELUPEXP, *LPLEVELUPEXP;
  401. // game data which is available in data files.
  402. typedef struct tagGAMEDATA
  403. {
  404. LPEVENTOBJECT lprgEventObject;
  405. int nEventObject;
  406. SCENE rgScene[MAX_SCENES];
  407. OBJECT rgObject[MAX_OBJECTS];
  408. LPSCRIPTENTRY lprgScriptEntry;
  409. int nScriptEntry;
  410. LPSTORE lprgStore;
  411. int nStore;
  412. LPENEMY lprgEnemy;
  413. int nEnemy;
  414. LPENEMYTEAM lprgEnemyTeam;
  415. int nEnemyTeam;
  416. PLAYERROLES PlayerRoles;
  417. LPMAGIC lprgMagic;
  418. int nMagic;
  419. LPBATTLEFIELD lprgBattleField;
  420. int nBattleField;
  421. LPLEVELUPMAGIC_ALL lprgLevelUpMagic;
  422. int nLevelUpMagic;
  423. ENEMYPOS EnemyPos;
  424. LEVELUPEXP rgLevelUpExp[MAX_LEVELS + 1];
  425. WORD rgwBattleEffectIndex[10][2];
  426. } GAMEDATA, *LPGAMEDATA;
  427. typedef struct tagFILES
  428. {
  429. FILE *fpFBP; // battlefield background images
  430. FILE *fpMGO; // sprites in scenes
  431. FILE *fpBALL; // item bitmaps
  432. FILE *fpDATA; // misc data
  433. FILE *fpF; // player sprites during battle
  434. FILE *fpFIRE; // fire effect sprites
  435. FILE *fpRGM; // character face bitmaps
  436. FILE *fpSSS; // script data
  437. } FILES, *LPFILES;
  438. // player party
  439. typedef struct tagPARTY
  440. {
  441. WORD wPlayerRole; // player role
  442. SHORT x, y; // position
  443. WORD wFrame; // current frame number
  444. WORD wImageOffset; // FIXME: ???
  445. } PARTY, *LPPARTY;
  446. // player trail, used for other party members to follow the main party member
  447. typedef struct tagTRAIL
  448. {
  449. WORD x, y; // position
  450. WORD wDirection; // direction
  451. } TRAIL, *LPTRAIL;
  452. typedef struct tagEXPERIENCE
  453. {
  454. WORD wExp; // current experience points
  455. WORD wReserved;
  456. WORD wLevel; // current level
  457. WORD wCount;
  458. } EXPERIENCE, *LPEXPERIENCE;
  459. typedef struct tagALLEXPERIENCE
  460. {
  461. EXPERIENCE rgPrimaryExp[MAX_PLAYER_ROLES];
  462. EXPERIENCE rgHealthExp[MAX_PLAYER_ROLES];
  463. EXPERIENCE rgMagicExp[MAX_PLAYER_ROLES];
  464. EXPERIENCE rgAttackExp[MAX_PLAYER_ROLES];
  465. EXPERIENCE rgMagicPowerExp[MAX_PLAYER_ROLES];
  466. EXPERIENCE rgDefenseExp[MAX_PLAYER_ROLES];
  467. EXPERIENCE rgDexterityExp[MAX_PLAYER_ROLES];
  468. EXPERIENCE rgFleeExp[MAX_PLAYER_ROLES];
  469. } ALLEXPERIENCE, *LPALLEXPERIENCE;
  470. typedef struct tagPOISONSTATUS
  471. {
  472. WORD wPoisonID; // kind of the poison
  473. WORD wPoisonScript; // script entry
  474. } POISONSTATUS, *LPPOISONSTATUS;
  475. typedef enum tagMUSICTYPE
  476. {
  477. MUSIC_RIX,
  478. MUSIC_MIDI,
  479. MUSIC_MP3,
  480. MUSIC_OGG,
  481. MUSIC_SDLCD
  482. } MUSICTYPE, *LPMUSICTYPE;
  483. typedef enum tagOPLTYPE
  484. {
  485. OPL_DOSBOX_OLD,
  486. OPL_DOSBOX,
  487. OPL_MAME
  488. } OPLTYPE, *LPOPLTYPE;
  489. typedef struct tagGLOBALVARS
  490. {
  491. FILES f;
  492. GAMEDATA g;
  493. BYTE bCurrentSaveSlot; // current save slot (1-5)
  494. int iCurMainMenuItem; // current main menu item number
  495. int iCurSystemMenuItem; // current system menu item number
  496. int iCurInvMenuItem; // current inventory menu item number
  497. int iCurPlayingRNG; // current playing RNG animation
  498. BOOL fGameStart; // TRUE if the has just started
  499. BOOL fEnteringScene; // TRUE if entering a new scene
  500. BOOL fNeedToFadeIn; // TRUE if need to fade in when drawing scene
  501. BOOL fInBattle; // TRUE if in battle
  502. BOOL fAutoBattle; // TRUE if auto-battle
  503. #ifndef PAL_CLASSIC
  504. BYTE bBattleSpeed; // Battle Speed (1 = Fastest, 5 = Slowest)
  505. #endif
  506. WORD wLastUnequippedItem; // last unequipped item
  507. PLAYERROLES rgEquipmentEffect[MAX_PLAYER_EQUIPMENTS + 1]; // equipment effects
  508. WORD rgPlayerStatus[MAX_PLAYER_ROLES][kStatusAll]; // player status
  509. PAL_POS viewport; // viewport coordination
  510. PAL_POS partyoffset;
  511. WORD wLayer;
  512. WORD wMaxPartyMemberIndex;// max index of members in party (0 to MAX_PLAYERS_IN_PARTY - 1)
  513. PARTY rgParty[MAX_PLAYABLE_PLAYER_ROLES]; // player party
  514. TRAIL rgTrail[MAX_PLAYABLE_PLAYER_ROLES]; // player trail
  515. WORD wPartyDirection; // direction of the party
  516. WORD wNumScene; // current scene number
  517. WORD wNumPalette; // current palette number
  518. BOOL fNightPalette; // TRUE if use the darker night palette
  519. WORD wNumMusic; // current music number
  520. WORD wNumBattleMusic; // current music number in battle
  521. WORD wNumBattleField; // current battle field number
  522. WORD wCollectValue; // value of "collected" items
  523. WORD wScreenWave; // level of screen waving
  524. SHORT sWaveProgression;
  525. WORD wChaseRange;
  526. WORD wChasespeedChangeCycles;
  527. USHORT nFollower;
  528. DWORD dwCash; // amount of cash
  529. ALLEXPERIENCE Exp; // experience status
  530. POISONSTATUS rgPoisonStatus[MAX_POISONS][MAX_PLAYABLE_PLAYER_ROLES]; // poison status
  531. INVENTORY rgInventory[MAX_INVENTORY]; // inventory status
  532. LPOBJECTDESC lpObjectDesc;
  533. DWORD dwFrameNum;
  534. /* Configurable options */
  535. #if USE_RIX_EXTRA_INIT
  536. uint32_t *pExtraFMRegs;
  537. uint8_t *pExtraFMVals;
  538. uint32_t dwExtraLength;
  539. #endif
  540. CODEPAGE iCodePage;
  541. DWORD dwWordLength;
  542. DWORD dwExtraMagicDescLines;
  543. DWORD dwExtraItemDescLines;
  544. double dSurroundOPLOffset;
  545. INT iAudioChannels;
  546. INT iSampleRate;
  547. INT iOPLSampleRate;
  548. INT iResampleQuality;
  549. INT iVolume;
  550. MUSICTYPE eMusicType;
  551. MUSICTYPE eCDType;
  552. OPLTYPE eOPLType;
  553. WORD wAudioBufferSize;
  554. BOOL fIsWIN95;
  555. BOOL fUseEmbeddedFonts;
  556. BOOL fUseSurroundOPL;
  557. } GLOBALVARS, *LPGLOBALVARS;
  558. extern LPGLOBALVARS gpGlobals;
  559. INT
  560. PAL_InitGlobals(
  561. VOID
  562. );
  563. VOID
  564. PAL_FreeGlobals(
  565. VOID
  566. );
  567. VOID
  568. PAL_SaveGame(
  569. LPCSTR szFileName,
  570. WORD wSavedTimes
  571. );
  572. VOID
  573. PAL_InitGameData(
  574. INT iSaveSlot
  575. );
  576. BOOL
  577. PAL_AddItemToInventory(
  578. WORD wObjectID,
  579. INT iNum
  580. );
  581. BOOL
  582. PAL_IncreaseHPMP(
  583. WORD wPlayerRole,
  584. SHORT sHP,
  585. SHORT sMP
  586. );
  587. INT
  588. PAL_GetItemAmount(
  589. WORD wItem
  590. );
  591. VOID
  592. PAL_UpdateEquipments(
  593. VOID
  594. );
  595. VOID
  596. PAL_CompressInventory(
  597. VOID
  598. );
  599. VOID
  600. PAL_RemoveEquipmentEffect(
  601. WORD wPlayerRole,
  602. WORD wEquipPart
  603. );
  604. VOID
  605. PAL_AddPoisonForPlayer(
  606. WORD wPlayerRole,
  607. WORD wPoisonID
  608. );
  609. VOID
  610. PAL_CurePoisonByKind(
  611. WORD wPlayerRole,
  612. WORD wPoisonID
  613. );
  614. VOID
  615. PAL_CurePoisonByLevel(
  616. WORD wPlayerRole,
  617. WORD wMaxLevel
  618. );
  619. BOOL
  620. PAL_IsPlayerPoisonedByLevel(
  621. WORD wPlayerRole,
  622. WORD wMinLevel
  623. );
  624. BOOL
  625. PAL_IsPlayerPoisonedByKind(
  626. WORD wPlayerRole,
  627. WORD wPoisonID
  628. );
  629. WORD
  630. PAL_GetPlayerAttackStrength(
  631. WORD wPlayerRole
  632. );
  633. WORD
  634. PAL_GetPlayerMagicStrength(
  635. WORD wPlayerRole
  636. );
  637. WORD
  638. PAL_GetPlayerDefense(
  639. WORD wPlayerRole
  640. );
  641. WORD
  642. PAL_GetPlayerDexterity(
  643. WORD wPlayerRole
  644. );
  645. WORD
  646. PAL_GetPlayerFleeRate(
  647. WORD wPlayerRole
  648. );
  649. WORD
  650. PAL_GetPlayerPoisonResistance(
  651. WORD wPlayerRole
  652. );
  653. WORD
  654. PAL_GetPlayerElementalResistance(
  655. WORD wPlayerRole,
  656. INT iAttrib
  657. );
  658. WORD
  659. PAL_GetPlayerBattleSprite(
  660. WORD wPlayerRole
  661. );
  662. WORD
  663. PAL_GetPlayerCooperativeMagic(
  664. WORD wPlayerRole
  665. );
  666. BOOL
  667. PAL_PlayerCanAttackAll(
  668. WORD wPlayerRole
  669. );
  670. BOOL
  671. PAL_AddMagic(
  672. WORD wPlayerRole,
  673. WORD wMagic
  674. );
  675. VOID
  676. PAL_RemoveMagic(
  677. WORD wPlayerRole,
  678. WORD wMagic
  679. );
  680. VOID
  681. PAL_SetPlayerStatus(
  682. WORD wPlayerRole,
  683. WORD wStatusID,
  684. WORD wNumRound
  685. );
  686. VOID
  687. PAL_RemovePlayerStatus(
  688. WORD wPlayerRole,
  689. WORD wStatusID
  690. );
  691. VOID
  692. PAL_ClearAllPlayerStatus(
  693. VOID
  694. );
  695. VOID
  696. PAL_PlayerLevelUp(
  697. WORD wPlayerRole,
  698. WORD wNumLevel
  699. );
  700. #ifdef __cplusplus
  701. }
  702. #endif
  703. #endif