global.h 26 KB

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