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