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