3#include "menu_misc.hpp"
9#include "battlemenu.hpp"
10#include "bt_shot_effect.hpp"
11#include "btactstatus.hpp"
15#include "dataalloc.hpp"
17#include "dngstatusdata.hpp"
18#include "dun/gameloop.hpp"
19#include "editloop.hpp"
23#include "mainselect.hpp"
25#include "menu_draw.hpp"
26#include "menu_dungeon.hpp"
27#include "menu_inventory.hpp"
28#include "menu_manual.hpp"
29#include "menuitemstep.hpp"
33#include "shot_effect.hpp"
36#include "userstatus.hpp"
37#include "weapon_buildup.hpp"
39#include "weaponlevelup.hpp"
41static int defWeapon[6] = {ITEM_WEAPON_DAGGER_BROKEN, ITEM_WEAPON_WOODENSLINGSHOT_BROKEN, ITEM_WEAPON_MALLET_BROKEN, ITEM_WEAPON_GOLD_RING_BROKEN, ITEM_WEAPON_FIGHTING_STICK_BROKEN, ITEM_WEAPON_MACHINE_GUN_BROKEN};
43int MenuWeaponModelData[42];
44int MenuWeaponModelInfo[10][2];
45float MenuCharaOldAmbient[4];
49u_long128 *WeaponRead_Buf;
50s16 MenuCharaEffectReadFlag;
51s16 MenuCharaOldEffect;
53u_long128 *WepEffectMenuReadBuf;
54u_long128 *MenuWeaponModelBuildBuffer;
57u_long128 *CharaChangeBaseBuf;
58u_long128 *menucharReadbuf;
59u_long128 *menud0wepReadBuf;
60u_long128 *menud1wepReadBuf;
61u_long128 *menud2wepReadBuf;
62u_long128 *MenuWepIconCharaChangePtr;
63u_long128 *MenuVoiceLoadPtr;
73int MenuWeaponTestCase = 1;
76s16 DngEscapeAlpha = 0x80;
81s16 DngEscapeSelect = 1;
90int NowGetGameFlagForBtlMenu(
int game_flag) {
92 case MENU_MOVE_DUNGEON_ESCAPE:
94 case MENU_MOVE_WORLD_MAP_DIRECT:
95 case MENU_MOVE_WORLD_MAP:
96 if (EdInteriorFlag == 1) {
97 game_flag = MENU_MOVE_INTERIOR_OUT;
100 game_flag = MENU_MOVE_LOCKED;
102 game_flag = MENU_MOVE_FIRST_DUNGEON;
112int GetMenuHebikiriFlag() {
123void EquipDefaultWeapon(
int chara_no) {
126 int default_weapon_no = GetDefaultWeaponNo(chara_no);
128 for (
int slot = 0; slot < 10; slot++) {
129 if (weapons[slot].item_no == default_weapon_no || weapons[slot].item_no == default_weapon_no + 1) {
143void DrawMenuNothing(
int x,
int y,
int width,
int height,
char *name,
int custom,
int alpha) {
144 CTexture *texture = TexManager.GetTexture(name, -1);
145 int inner_w = width - 0x24;
146 int inner_h = height - 0x24;
157 DrawMenu2DSprite(texture,
CRect_i_(x, y, 0x12, 0x12),
CRect_i_(u, v, 0x12, 0x12), alpha);
158 DrawMenu2DSprite(texture,
CRect_i_(x + 0x12, y, inner_w, 0x12),
CRect_i_(u + 0x10, v, 4, 0x12), alpha);
159 DrawMenu2DSprite(texture,
CRect_i_(x + 0x12 + inner_w, y, 0x12, 0x12),
CRect_i_(u + 0x12, v, 0x12, 0x12), alpha);
160 DrawMenu2DSprite(texture,
CRect_i_(x, y + 0x12, 0x12, inner_h),
CRect_i_(u, v + 0xE, 0x12, 4), alpha);
161 DrawMenu2DSprite(texture,
CRect_i_(x + 0x12 + inner_w, y + 0x12, 0x12, inner_h),
CRect_i_(u + 0x12, v + 0xE, 0x12, 4), alpha);
162 DrawMenu2DSprite(texture,
CRect_i_(x, y + 0x12 + inner_h, 0x12, 0x12),
CRect_i_(u, v + 0x12, 0x12, 0x12), alpha);
163 DrawMenu2DSprite(texture,
CRect_i_(x + 0x12, y + 0x12 + inner_h, inner_w, 0x12),
CRect_i_(u + 0x10, v + 0x12, 4, 0x12), alpha);
164 DrawMenu2DSprite(texture,
CRect_i_(x + 0x12 + inner_w, y + 0x12 + inner_h, 0x12, 0x12),
CRect_i_(u + 0x12, v + 0x12, 0x12, 0x12), alpha);
165 DrawMenu2DSprite(texture,
CRect_i_(x - 0x33 + (inner_w >> 1), y - 1 + (inner_h >> 1), 0x86, 0x22),
CRect_i_(0xFA, 0x1D2, 0x86, 0x22), alpha);
168int GetMenuItemUseVolume() {
169 return MenuItemUseVolume;
176 MenuItemUseVolume = 0;
177 int now_hp = status->
hp[chara];
178 int max_hp = status->
max_hp[chara];
179 int now_water = (int) status->
water_now[chara];
180 float max_water = status->
water_max[chara];
181 int old_condition = status->
ailments[chara];
182 printf(
"trueNo = %d\n", item_no);
191 if (item_no != ITEM_MELLOW_BANANA) {
193 int add = (&data->
vol)[value_no];
200 int add = (&data->
vol)[value_no];
214 }
else if (now_hp > 0 && now_hp < max_hp) {
223 if (chara == item_no - ITEM_FLUFFY_DOUGHNUT) {
224 int old = status->
defense[chara];
232 int add = data->
vol + rand() % range;
233 MenuItemUseVolume = add;
248 if (target == ITEM_USE_ON_CHARA) {
258 pack->
num += (&data->
vol)[value_no];
259 MenuItemUseVolume = pack->
num;
261 if (pack->
num > 100) {
265 for (i = num; i < pack->
num; i++) {
266 if (pack->
item[i] < ITEM_DUNGEON_START) {
276 case ITEM_FRUIT_OF_EDEN: {
277 s16 limit[6] = {0xAA, 0x8C, 0xAA, 0x8C, 0xB4, 0xA0};
279 if ((old_condition & AILMENT_KNOCKED_OUT) || now_hp <= 0 || !((s16) max_hp < limit[chara])) {
282 status->
max_hp[chara] = max_hp + (&data->
vol)[value_no];
283 s16 next = status->
max_hp[chara];
285 if (next >= limit[chara]) {
287 status->
max_hp[chara] = limit[chara];
297 if (max_water <= 90.0f) {
298 float next = max_water + (&data->
vol)[value_no];
308 printf(
"prev status = %d\n", old_condition);
311 if ((old_condition & AILMENT_KNOCKED_OUT) || now_hp <= 0) {
312 if (item_no == ITEM_REVIVAL_POWDER) {
314 status->
hp[chara] = max_hp >> 1;
318 if ((flags & 0x4000) && (old_condition & AILMENT_FREEZE)) {
319 status->
ailments[chara] ^= AILMENT_FREEZE;
323 if ((data->
use_flags & 0x8000) && (old_condition & AILMENT_POISON)) {
324 status->
ailments[chara] ^= AILMENT_POISON;
328 if ((data->
use_flags & 0x10000) && (old_condition & AILMENT_CURSE)) {
329 status->
ailments[chara] ^= AILMENT_CURSE;
333 if ((data->
use_flags & 0x20000) && (old_condition & AILMENT_GOO)) {
334 status->
ailments[chara] ^= AILMENT_GOO;
338 if (item_no == ITEM_MIGHTY_HEALING && (old_condition & (AILMENT_FREEZE | AILMENT_POISON | AILMENT_CURSE | AILMENT_GOO))) {
339 if (status->
ailments[chara] & AILMENT_STAMINA) {
341 status->
ailments[chara] |= AILMENT_STAMINA;
349 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON && (data->
use_flags & 0x1000)) {
352 if (!(now & AILMENT_FREEZE)) {
353 status->
ailments[chara] = now | AILMENT_STAMINA;
361 if (target == ITEM_USE_ON_BOARD_WEAPON || target == ITEM_USE_ON_EQUIP_WEAPON) {
362 if (weapon == NULL) {
366 int default_no = GetDefaultWeaponNo(chara);
368 if (item_no == ITEM_REPAIR_POWDER) {
369 if (weapon->durability_f < weapon->durability) {
370 weapon->durability_f = weapon->durability;
371 int weapon_no = weapon->item_no;
373 if (weapon_no == default_no) {
374 weapon->item_no = weapon_no + 1;
375 WepDataListToHaveCopy(weapon->item_no, weapon);
382 if (item_no == ITEM_POWERUP_POWDER) {
383 if (weapon->item_no == ITEM_WEAPON_SERPENT_SWORD && GetMenuHebikiriFlag() == 0) {
387 if (weapon->level >= 99) {
391 if (weapon->item_no != default_no) {
392 int exp = weapon->experience;
394 if (exp < GetWeaponMaxExp(weapon)) {
395 WeaponLevelUpValueCalc(weapon, &level_up, 1, 0);
398 memset(weapon->attach, 0,
sizeof(weapon->attach));
406 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON && !(old_condition & AILMENT_KNOCKED_OUT) && now_hp > 0 && (data->
kind_flags & 2) && target == ITEM_USE_ON_CHARA) {
407 int before = status->
ailments[chara];
410 if (old_condition & AILMENT_FREEZE) {
411 status->
ailments[chara] = before ^ AILMENT_FREEZE;
413 status->
ailments[chara] = before | AILMENT_FREEZE;
414 status->
ailments[chara] &= ~(AILMENT_STAMINA | AILMENT_POISON | AILMENT_GOO);
418 ComMenuSePlay(SE_STATUS_AILMENT);
424 if (!(now & (AILMENT_FREEZE | AILMENT_STAMINA))) {
425 status->
ailments[chara] = now | AILMENT_POISON;
426 status->
ailments[chara] &= ~AILMENT_GOO;
427 ComMenuSePlay(SE_STATUS_AILMENT);
432 status->
ailments[chara] |= AILMENT_CURSE;
433 ComMenuSePlay(SE_STATUS_AILMENT);
439 if (!(now & (AILMENT_FREEZE | AILMENT_STAMINA | AILMENT_POISON))) {
440 status->
ailments[chara] = now | AILMENT_GOO;
441 ComMenuSePlay(SE_STATUS_AILMENT);
445 if (before != status->
ailments[chara]) {
473 if (weapon == NULL) {
479 if (weapon->
level >= 5) {
493int WeaponStatusBuildUp(
WEAPON_HAVE *weapon,
int &enabled_count) {
494 if (weapon == NULL) {
499 EnableBuildUpModel(build_info, weapon);
503 while (build_info[total].weapon_no != -1 && total < 5) {
507 for (
int i = 0; i < total; i++) {
508 if (build_info[i].enabled == 1) {
517 if (chara == NULL || weapon == NULL) {
521 if (weapon->
item_no != ITEM_WEAPON_LAMB_S_SWORD) {
526 CFrame *broken = chara->
frame->SearchFrame(
"w15b");
528 if (whole == NULL || broken == NULL) {
547void SetMenuCharaEffectReadFlag(
int flag) {
548 MenuCharaEffectReadFlag = flag;
551int GetMenuCharaEffectReadFlag() {
552 return MenuCharaEffectReadFlag;
556 return WepEffectMenuPt;
559u_long128 *GetWepEffectMenuReadBuf() {
560 return WepEffectMenuReadBuf;
563void SetOldEffectKind(
int kind) {
564 MenuCharaOldEffect = kind;
574static void SetWepEffectMenuReadBuf(u_long128 *buffer) {
575 WepEffectMenuReadBuf = buffer;
587 WepEffectMenuPt = Get_Main_EffectPtr(chara, equipped->
best_elem);
588 sprintf(path,
"dun/mainchara/wep_eff/%s.chr", WepEffectMenuPt);
589 WepEffectMenuReadBuf = GetWepEffectMenuReadBuf();
590 WepEffectMenuReadBuf = MenuCalcBufAlignment(WepEffectMenuReadBuf);
591 LoadFileBG(path, (u_long128 *) WepEffectMenuReadBuf, &size);
592 SetMenuCharaEffectReadFlag(1);
593 return GetDngWepEffectPointer();
596void MenuWeaponEffectSet(
int effect_no) {
597 SetMenuCharaEffectReadFlag(0);
598 MainChara_Effect((
BT_SHOT_EFFECT *) WepEffectMenuPt, (
unsigned int *) WepEffectMenuReadBuf, effect_no);
602 return MenuWeaponTestCase;
605int StartReadWepMDS(u_long128 *buffer,
int chara) {
606 if (ReadBGSync() == 1) {
610 char path[64] =
"commenu/c";
611 char *numbers[6] = {
"01",
"04",
"06",
"05",
"10",
"18"};
615 strcat(path, numbers[chara]);
616 strcat(path,
"wtes.chr");
617 WeaponRead_Buf = MenuCalcBufAlignment(buffer);
620 if (LoadFileBG(path, buffer, &size) == 0) {
624 buffer += (size >> 4) + 1;
625 buffer = MenuCalcBufAlignment(buffer);
626 GetPathReadDifferntLang(image);
627 char *names[6] = {
"kgetoan",
"kgesyao",
"kgegoro",
"kgeruby",
"kgeunga",
"kgeozu"};
628 strcat(image, names[chara]);
629 strcat(image,
"2.img");
631 if (LoadFileBG(image, buffer, &size) == 0) {
635 if (BtlMenuMode == BATTLE_MENU_MODE_DUNGEON) {
636 buffer += (size >> 4) + 1;
637 SetWepEffectMenuReadBuf(buffer);
638 DngWepEffectReadStart();
651static int *GetMenuWeaponModelData(
int index) {
652 return &MenuWeaponModelData[index];
662static void InitMenuWeaponModelData() {
663 memset(MenuWeaponModelData, 0,
sizeof(MenuWeaponModelData));
673static int *GetMenuWeaponModelInfo(
int index) {
674 return MenuWeaponModelInfo[index];
677void InitMenuWeaponModelReference() {
678 for (
int i = 0; i < 12; i++) {
679 int *entry = GetMenuWeaponModelInfo(i);
685void SetMenuWeaponModelReference(
int index,
int frame_no,
int value) {
686 int *entry = GetMenuWeaponModelInfo(index);
691int GetMenuWeaponModelFrameNo(
int index) {
692 return MenuWeaponModelInfo[index][0];
702int EnterWeaponModel(
int chara,
int texture_block,
int weapon_slot) {
707 char *shadows[6] = {
"kagetoan",
"kagesyao",
"kagegoro",
"kageruby",
"kageunga",
"kageozu"};
708 char *shadow_name = shadows[chara];
709 s16 weapon_max = MenuCharaWeaponMax[chara];
710 char *names[6] = {
"c01",
"c04",
"c06",
"c05",
"c10",
"c18"};
716 switch (GetNowTestNo()) {
721 {
"#frame_menuwep_dmy#640#" SCREEN_HEIGHT_STR
"#4", 0, 0},
725 texture[0].
block_no = MenuShadowReadBlock;
726 texture[1].
block_no = MenuShadowReadBlock;
728 TexManager.DeleteTextureBlock(MenuShadowReadBlock);
729 TexManager.CleanUpTextureList();
730 TexManager.LoadTextureBlockEX(-1, texture);
731 WepIcon = TexManager.GetTexture(
"wepicon", MenuShadowReadBlock);
733 for (
int i = 0; i < weapon_max; i++) {
737 InitMenuWeaponModelData();
739 for (
int i = 0; i < weapon_max; i++) {
740 char *name = names[chara];
744 int weapon_no = order[i];
746 if (0 <= weapon_no && weapon_no <= 9) {
748 sprintf(chr, chr, weapon_no);
749 strcat(image,
"w0%d");
750 sprintf(image, image, weapon_no);
751 strcat(model,
"w0%d");
752 sprintf(model, model, weapon_no);
753 }
else if (weapon_no >= 10) {
755 sprintf(chr, chr, weapon_no);
756 strcat(image,
"w%d");
757 sprintf(image, image, weapon_no);
758 strcat(model,
"w%d");
759 sprintf(model, model, weapon_no);
762 strcat(image,
"w01");
763 strcat(model,
"w01d");
767 strcat(image,
".img");
768 strcat(model,
".mds");
769 u_int *file = GetPackFile((u_int *) pack->
buffer, chr, NULL);
772 *GetMenuWeaponModelData(i) = (int) file;
778 if (effect != NULL) {
779 SetWepEffectMenuReadBuf(effect->
buffer);
780 build = effect->
buffer + 0x2D01;
782 build = shadow->
buffer + (shadow->
size >> 4) + 1;
785 MenuWeaponModelBuildBuffer = build;
786 WeaponModelBuildFunc(chara, texture_block);
794void WeaponModelBuildFunc(
int chara,
int texture_block) {
795 printf(
"weapon model build func start\n");
796 InitMenuWeaponModelReference();
798 {(
char *)
"#frame_menuwep#640#" SCREEN_HEIGHT_STR
"#4", texture_block, 0},
803 TexManager.DeleteTextureBlock(texture_block);
804 TexManager.CleanUpTextureList();
805 TexManager.LoadTextureBlockEX(-1, textures);
806 printf(
"modelbuildbuffer = %p\n", MenuWeaponModelBuildBuffer);
807 MenuExCashBuffer.
base = (u_char *) MenuWeaponModelBuildBuffer;
808 MenuExCashBuffer.
limit = 0xEC00;
809 MenuExCashBuffer.
used = 0;
812 default_no = GetDefaultWeaponNo(chara);
814 u_int **data = (u_int **) GetMenuWeaponModelData(0);
815 BtGetWeaponNamePath2(name, cfg, chara, 0);
816 DngWeaponFrm[0].
LoadPackData3(*data, cfg, &MenuExCashBuffer, texture_block, &MenuExCashBuffer, 1, 0);
817 data = (u_int **) GetMenuWeaponModelData(1);
818 BtGetWeaponNamePath2(name, cfg, chara, 1);
819 DngWeaponFrm[1].
LoadPackData3(*data, cfg, &MenuExCashBuffer, texture_block, &MenuExCashBuffer, 1, 0);
821 for (
int i = 0; i < 10; i++) {
824 if (weapon == NULL) {
825 SetMenuWeaponModelReference(i, -2, -1);
831 if (item_no < ITEM_WEAPON_START) {
832 SetMenuWeaponModelReference(i, -2, -1);
836 unsigned int kind = item_no - default_no;
839 SetMenuWeaponModelReference(i, kind, kind);
845 for (
int j = 0; j < 10; j++) {
846 int *info = GetMenuWeaponModelInfo(j);
848 if (info[1] == kind) {
850 SetMenuWeaponModelReference(i, info[0], info[1]);
856 u_int **pack = (u_int **) GetMenuWeaponModelData(kind);
859 printf(
"%d pack data is NULL\n", kind);
861 BtGetWeaponNamePath2(name, cfg, chara, kind);
862 DngWeaponFrm[next].
LoadPackData3(*pack, cfg, &MenuExCashBuffer, texture_block, &MenuExCashBuffer, 1, 0);
863 SetMenuWeaponModelReference(i, next, kind);
869 WepMenuEffectReadBuf = (
CWeaponLevelUp *) (MenuWeaponModelBuildBuffer + 0xEC01);
870 WepMenuEffectReadBuf = (
CWeaponLevelUp *) MenuCalcBufAlignment((u_long128 *) WepMenuEffectReadBuf);
871 printf(
"read buffer = %p\n", read_buffer);
872 printf(
"model build buffer = %p\n", MenuWeaponModelBuildBuffer);
873 printf(
"WeaponBuffer Size = %d\n", (
int) MenuExCashBuffer.
limit);
874 printf(
"WeaponBuffer address = %p\n", MenuExCashBuffer.
base + MenuExCashBuffer.
used * 16);
875 printf(
"WepMenuEffectReadBuf = %p\n", WepMenuEffectReadBuf);
878int DngWeaponEquipModelBuild(
int chara,
int texture_block, u_long128 *read_buffer) {
879 TexManager.DeleteTextureBlock(texture_block);
880 u_int **first = (u_int **) GetMenuWeaponModelData(0);
881 u_int **second = (u_int **) GetMenuWeaponModelData(1);
884 if (UserStatus != NULL) {
886 kind -= GetDefaultWeaponNo(chara);
889 u_int **equipped = (u_int **) GetMenuWeaponModelData(kind);
891 if (equipped == NULL) {
893 }
else if (*equipped == NULL) {
897 LoadWeapon2(*first, *second, *equipped, chara, 1);
898 MenuWeaponEffectSet(1);
909static int GetNowMotionStepCnt(
int status) {
916 if ((status & 4) || (status & 2)) {
930int GetNowActiveCharaStatus(
int chara_no) {
931 if (BtlMenuStatusPt == NULL) {
938void SetNowCharaMotionNo(
int chara) {
939 int status = GetNowActiveCharaStatus(chara);
941 float max_hp = user_status->
max_hp[chara];
942 float hp = user_status->
hp[chara];
944 float speed[3] = {0.1f, 0.05f, 0.0f};
947 if (!(hp < 0.3f * max_hp)) {
951 if ((status & 0x10) || (status & 2) || hp < 0.3f * max_hp) {
955 if (next != motion) {
961 info->
speed = speed[GetNowMotionStepCnt(status)];
971void SetItemMenuColor(
int chara) {
978 MGGetAmbient(MenuCharaOldAmbient);
979 status = GetNowActiveCharaStatus(chara);
1003 if (status & 0x20) {
1017 if (should_tint == 1) {
1022 ambient[3] = 128.0f;
1023 MGSetAmbient(ambient);
1027void SetItemMenuOldAmbient() {
1028 MGSetAmbient(MenuCharaOldAmbient);
1031int StartLoadCharaMDS(u_long128 *buffer,
int chara,
int read_no) {
1036 strcpy(path, GetMenuTextureDir());
1037 strcat(path,
"dungeon/");
1038 sprintf(name,
"c0%dmodel.pak", chara + 1);
1040 buffer = MenuCalcBufAlignment(buffer);
1041 CharaFileBGReadNo = read_no;
1047 if (LoadFileBG(path, buffer, &size) == 0) {
1054void MenuCharaMDSBuild2(
int chara,
int texture_block) {
1058 sprintf(name,
"c0%ddmenu.img", chara + 1);
1060 {
"#frame_menu_chara#640#" SCREEN_HEIGHT_STR
"#4", 0, 0},
1064 textures[0].
block_no = texture_block;
1065 textures[1].
block_no = texture_block;
1067 textures[1].
name = (
char *) GetPackFile((u_int *) file->
buffer, name, &size);
1068 TexManager.DeleteTextureBlock(texture_block);
1069 TexManager.CleanUpTextureList();
1070 TexManager.LoadTextureBlockEX(-1, textures);
1071 u_int *pack = (u_int *) file->
buffer;
1072 u_char *model = (u_char *) ((u_long128 *) pack + (file->
size >> 4) + 1);
1073 sprintf(name,
"c0%ddmenu.cfg", chara + 1);
1075 MenuExCashBuffer.
base = model;
1076 MenuExCashBuffer.
limit = 0xDC00;
1077 MenuExCashBuffer.
used = 0;
1078 MenuCharaFrame.
LoadPackData(pack, name, &MenuExCashBuffer, &MenuExCashBuffer, NULL);
1084 if (MenuCharaFrame.
frame != NULL) {
1085 MenuCharaFrame.
frame->SetAttr(attr, 1, 4);
1088 sceVu0FVECTOR position[6] = {
1089 {-4.8f, -13.0f, 0.0f, 1.0f},
1090 {-5.2f, -12.8f, 0.0f, 1.0f},
1091 {-5.0f, -11.4f, 0.0f, 1.0f},
1092 {-5.0f, -15.0f, 0.0f, 1.0f},
1093 {-5.0f, -16.0f, 0.0f, 1.0f},
1094 {-5.0f, -15.0f, 0.0f, 1.0f}
1096 float scale[6][3] = {
1105 SetNowCharaMotionNo(chara);
1106 MenuCharaFrame.
SetScale(scale[chara]);
1107 MenuCharaFrame.
Step();
1122static void GetCharaChangeReadCharaFilePath(
char *path,
int chara_no) {
1123 strcpy(path, readFilePath);
1124 strcat(path, charaFile[chara_no]);
1125 strcat(path, CharaFileExtension);
1128const char MenuWepDir[64] =
"commenu/weapon/";
1130char readFilePath[0x40] =
"dun/mainchara/c";
1132const char *charaFile[6] = {
"01d",
"04b",
"06b",
"05a",
"10b",
"18a"};
1134int CharaChangeInitToGL(u_long128 *buffer,
int chara) {
1141 CharaChangeBaseBuf = buffer;
1142 charachangeid = chara;
1143 GetCharaChangeReadCharaFilePath(MenureadFile, chara);
1144 CharaChangeBaseBuf = MenuCalcBufAlignment(CharaChangeBaseBuf);
1145 menucharReadbuf = CharaChangeBaseBuf;
1147 LoadFileBG(MenureadFile, menucharReadbuf, &size);
1148 menud0wepReadBuf = menucharReadbuf + (size >> 4) + 1;
1149 menud0wepReadBuf = MenuCalcBufAlignment(menud0wepReadBuf);
1150 BtGetWeaponNamePath2(name, cfg, chara, 0);
1151 strcpy(path, MenuWepDir);
1153 LoadFileBG(path, menud0wepReadBuf, &size);
1154 menud1wepReadBuf = menud0wepReadBuf + (size >> 4) + 1;
1155 menud1wepReadBuf = MenuCalcBufAlignment(menud1wepReadBuf);
1156 BtGetWeaponNamePath2(name, cfg, chara, 1);
1157 strcpy(path, MenuWepDir);
1159 LoadFileBG(path, menud1wepReadBuf, &size);
1160 menud2wepReadBuf = menud1wepReadBuf + (size >> 4) + 1;
1161 menud2wepReadBuf = MenuCalcBufAlignment(menud2wepReadBuf);
1163 int kind = equipped->
item_no - (int) defWeapon[chara];
1169 BtGetWeaponNamePath2(name, cfg, chara, kind);
1170 strcpy(path, MenuWepDir);
1172 LoadFileBG(path, menud2wepReadBuf, &size);
1173 WepEffectMenuReadBuf = menud2wepReadBuf + (size >> 4) + 1;
1174 WepEffectMenuReadBuf = MenuCalcBufAlignment(WepEffectMenuReadBuf);
1176 if (UserStatus == NULL) {
1177 printf(
"USerStatus is NULL\n", UserStatus);
1184 WepEffectMenuPt = Get_Main_EffectPtr(charachangeid, weapon->
best_elem);
1185 sprintf(effect,
"dun/mainchara/wep_eff/%s.chr", WepEffectMenuPt);
1186 LoadFileBG(effect, (u_long128 *) WepEffectMenuReadBuf, &size);
1190void CharaChangeInitToGL2(
int load_icon) {
1193 MenuWepIconCharaChangePtr = CharaChangeBaseBuf;
1195 if (load_icon != 0) {
1196 MenuWepIconCharaChangePtr = MenuCalcBufAlignment(MenuWepIconCharaChangePtr);
1197 size = LoadFileBGMenuData(
"wepicon.img", (u_long128 *) MenuWepIconCharaChangePtr);
1198 MenuWepIconCharaChangePtr = MenuWepIconCharaChangePtr + (size >> 4) + 1;
1201 MenuVoiceLoadPtr = MenuWepIconCharaChangePtr;
1202 MenuVoiceLoadPtr = MenuCalcBufAlignment(MenuVoiceLoadPtr);
1204 if (SndVoiceLoadBG(charachangeid, (u_int *) MenuVoiceLoadPtr, &size) == 0) {
1205 printf(
"*** voice read err \n");
1209void BtMenuLoadChara() {
1210 s8 chara = charachangeid;
1213 LoadChara2((s16) charachangeid, 0, (u_int *) menucharReadbuf, (u_int *) menud0wepReadBuf, (u_int *) menud1wepReadBuf, (u_int *) menud2wepReadBuf);
1214 SetWeaponAttachStatus(NowWeaponHave);
1217 MainChara_Effect(WepEffectMenuPt, (u_int *) WepEffectMenuReadBuf, 0);
1220void BtMenuLoad2(
int load_texture) {
1221 if (load_texture != 0) {
1224 {(
char *)
"#frame_image#640#" SCREEN_HEIGHT_STR
"#4", MenuShadowReadBlock, 0},
1225 {(
char *) file->
buffer, MenuShadowReadBlock, 0},
1228 TexManager.DeleteTextureBlock(MenuShadowReadBlock);
1229 TexManager.LoadTextureBlockEX(-1, textures);
1230 MenuTextureReload(MenuShadowReadBlock);
1231 DngActiveWeaponTextureCopy();
1247int EastKingCheckComplete() {
1248 if (SaveData == NULL) {
1254 for (
int i = 0; i < 12; i++) {
1263void SetMonsterNameDrawFlag(
int flag) {
1264 CharaNameDrawFlag = flag;
1267int GetMonsterNameDrawFlag() {
1268 return CharaNameDrawFlag;
1271void MonsterNameInit(
ClsMes *mes,
short *message_buffer,
unsigned char *texture_buffer) {
1272 CharaNameMes = NULL;
1275 printf(
"cls init failed\n");
1301 for (
int i = 0; i < 10; i++) {
1305 for (
int i = 0; i < 8; i++) {
1319 for (
int i = 0; i < 10; i++) {
1324 CharaNameMes->
Preset(MES_PRESET_NAME);
1326 CharaNameMes->
tex_buff = texture_buffer;
1327 CharaNameMes->
rows = 1;
1328 CharaNameMes->
SetBuff(message_buffer);
1330 CharaNameDrawFlag = 1;
1333 if (config != NULL) {
1334 CharaNameDrawFlag = !config[8];
1337 CharaNameDrawCase = 0;
1340void MonsterNameMake(
int mes_no) {
1341 if (CharaNameMes != NULL) {
1342 int mes = mes_no + 3000;
1344 if (CharaNameMes->
mes_made != mes) {
1356void MonsterNamePosSet(
int x,
int y) {
1357 if (CharaNameMes != NULL) {
1359 CharaNameMes->
text_x = x - columns * 14 / 2;
1365 CharaNameMes->
text_y = y;
1369void MonsterNameDraw() {
1370 if (CharaNameMes == NULL || GetMonsterNameDrawFlag() == 0) {
1375 ClsMes *mes = CharaNameMes;
1381 if (mes->
text_x < 0x22 || mes->
text_x >= 0x26D || mes->
text_y < 0x1E || mes->
text_y >= 0x199 || width >= 0xFB || width < 10) {
1382 SetMonsterNameDrawFlag(0);
1387 MenuTextureReload(CharaNameMes->
tex_block);
1389 CharaNameMes->
Step();
1402void DngEscapeMsgInit(
ClsMes *title,
ClsMes *choice,
int dungeon) {
1406 if (title == NULL || choice == NULL) {
1410 if (UserStatus == NULL) {
1415 strcpy(path, GetMenuTextureDir());
1416 strcat(path,
"d0%do.img");
1417 sprintf(path, path, georama_no);
1418 LoadFile(path, read_buffer, &file_size);
1420 char *image = (
char *) read_buffer;
1422 {(
char *) FrameImageTexture, block, 0},
1427 TexManager.DeleteTextureBlock(block);
1428 TexManager.CleanUpTextureList();
1429 TexManager.LoadTextureBlockEX(-1, texture);
1432 char name[8] =
"d0%do";
1433 sprintf(name, name, georama_no);
1434 DngEscapeTex = TexManager.GetTexture(name, -1);
1435 CharaNameMes = title;
1436 DngMenuMes = choice;
1437 int lang = GetMenuLangFlag();
1438 u_char title_x[7] = {0xB4, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0};
1439 CharaNameMes->
text_x = title_x[lang];
1440 CharaNameMes->
text_y = 0x8C;
1444 s16 choice_x[7] = {0x154, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0};
1450 DngMenuMes->
text_x = right - 0x26;
1451 DngMenuMes->
text_y = 0x140;
1452 DngEscapeSelect = 1;
1453 DngEscapeEndFlag = 0;
1454 DngEscapeAlpha = 0x80;
1455 DngEscapeBlock = block;
1458void DngEscapeMsgDraw() {
1459 AllFadeForMenu(0x80);
1461 if (CharaNameMes == NULL || DngMenuMes == NULL) {
1465 MenuTextureReload(DngEscapeBlock);
1466 DrawFullSizePicture(DngEscapeTex, 0, 0, 0x80);
1467 MenuTextureReload(CharaNameMes->
tex_block);
1470 CharaNameMes->
Step();
1475 if (DngEscapeEndFlag != 0) {
1476 DngEscapeAlpha += 3;
1478 if (DngEscapeAlpha > 0x80) {
1479 DngEscapeAlpha = 0x80;
1482 DngEscapeAlpha -= 3;
1484 if (DngEscapeAlpha < 0) {
1489 AllFadeForMenu(DngEscapeAlpha);
1492int DngEscapeMsgLoop() {
1495 if (DngEscapeEndFlag == 0) {
1496 if (GamePad.
Down(PAD_UP | PAD_DOWN) != 0) {
1497 if (DngEscapeSelect == 2) {
1498 DngEscapeSelect = 1;
1499 }
else if (DngEscapeSelect == 1) {
1500 DngEscapeSelect = 2;
1503 ComMenuSePlay(MENU_SOUND_CURSOR);
1506 int row = DngEscapeSelect - 1;
1507 ClsMes *mes = CharaNameMes;
1510 if (GamePad.
Down(PAD_CROSS) != 0) {
1511 DngEscapeEndFlag = 1;
1512 ComMenuSePlay(MENU_SOUND_CONFIRM);
1515 if (GamePad.
Down(PAD_CIRCLE) != 0) {
1516 ComMenuSePlay(MENU_SOUND_REFUSE);
1518 }
else if (DngEscapeAlpha >= 0x80) {
1519 result = DngEscapeSelect;
1523 ClsMes *mes = CharaNameMes;
1532int CheckItemThrow(
int *items,
int *values) {
1541 pack = &((
CUserStatus *) BtlMenuStatusPt)->item_pack;
1543 for (i = 0; i < 3; i++) {
1544 item_no = pack->
item[pack->
num + i];
1546 if (item_no >= ITEM_DUNGEON_START) {
1549 if (items != NULL) {
1553 if (values != NULL) {
1559 for (i = 0; i < 6; i++) {
1560 weapons = ((
CUserStatus *) BtlMenuStatusPt)->chara_weapons[i];
1561 item_no = weapons[10].
item_no;
1563 if (item_no >= ITEM_WEAPON_START) {
1566 if (items != NULL) {
1570 if (values != NULL) {
1571 values[3] = weapons[10].
level;
1580 for (i = 0; i < 3; i++) {
1581 item_no = attachments[i + 40].
item_no;
1583 if (item_no >= ITEM_ATTACH_START) {
1586 if (items != NULL) {
1587 items[i + 4] = item_no;
1590 if (values != NULL && item_no >= ITEM_ATTACH_STAT_START && item_no < ITEM_ATTACH_GEM_START) {
1591 values[i + 4] = (&attachments[i + 40].
item_no)[item_no - ITEM_ATTACH_STAT_START + 4];
1594 if (values != NULL && item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
1614 for (
int i = 1; i < 5; i++) {
1615 if (weapon->
elem[i] > weapon->
elem[best]) {
1623int CheckWeaponOptionStatus(
int options) {
1625 if ((options & 2) && (options & 4)) {
1629 if ((options & 8) && (options & 0x10)) {
1633 if ((options & 0x100) && (options & 0x200)) {
1637 if ((options & 0x400) && (options & 0x800)) {
1644int IsWeaponOptionGoodOrBad(
int option) {
1646 s16 good_or_bad[14] = {0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1};
1647 return good_or_bad[option];
1650int DefaultWeaponOptionSet(
int weapon_no) {
1660void WeaponOptionStatusDraw(
WEAPON_HAVE *weapon,
int x,
int y,
int alpha) {
1663 int flags = weapon->
flags;
1665 for (
int i = 0; i < 6; i++) {
1668 if (option != 0 && option != 1) {
1673 flags = CheckWeaponOptionStatus(flags);
1674 CTexture *texture = TexManager.GetTexture(
"charaface", -1);
1676 if (texture == NULL) {
1681 CRect_i_ source(0xEC, 0x50, 0x14, 0x14);
1683 for (
int bit = 1; bit <= 13; bit++) {
1685 source.x -= source.width;
1688 if (flags & (1 << bit)) {
1695 if (bit == 8 && row == 1) {
1699 if (bit == 9 && row == 2) {
1703 source.y = source.height * (row - 1) + 0x50;
1704 DrawMenu2DSprite(texture,
CRect_i_(draw_x, draw_y, 0x14, 0x15), source, alpha);
1705 draw_x += source.width;
1710 draw_y += source.height;
1716void WeaponStarDraw(
int x,
int y,
WEAPON_HAVE *weapon,
int alpha) {
1717 if (weapon == NULL) {
1721 CTexture *texture = TexManager.GetTexture(
"wepstatus", -1);
1728 int draw_x = x + 0x4C;
1729 CRect_i_ big_star(0x108, 0x176, 0x18, 0x18);
1731 for (
int i = 0; i < stars / 10; i++, draw_x += big_star.width) {
1732 DrawMenu2DSprite(texture,
CRect_i_(draw_x, y, big_star.width, big_star.height), big_star, alpha);
1737 for (
int i = 0; i < stars % 10; i++, x += 0x14) {
1738 DrawMenu2DSprite(texture,
CRect_i_(x, y + 0x16, 0x14, 0x14),
CRect_i_(0x10A, 0x162, 0x14, 0x14), alpha);
1749static void LocalWeaponDataChange(
char *values,
int count,
int base,
int range) {
1750 if (values == NULL) {
1751 printf(
"target is NULL\n");
1755 int selected = rand() % count;
1756 int reduction = base + rand() % range;
1757 char *value = values;
1761 if (i == selected) {
1762 *value -= reduction;
1776int WeaponDataChangeByRGate(
WEAPON_HAVE *weapon,
int kind) {
1777 if (weapon == NULL) {
1784 for (i = 0; i < 6; i++) {
1785 if (weapon->
item_no == defWeapon[i]) {
1791 case RGATE_ABS_FULL:
1792 printf(
"abs full\n");
1794 if (is_default == 1) {
1795 printf(
"this weapon default\n");
1797 weapon->
experience = GetWeaponMaxExp(weapon);
1801 case RGATE_STAT_DOWN:
1802 if (IsDefaultWeapon(weapon->
item_no) >= 0) {
1803 printf(
"default Weapon\n");
1805 int stat = rand() % 4;
1806 int loss = rand() % 3 + 2;
1812 if (weapon->
attack <= 0) {
1826 weapon->
speed -= loss;
1828 if (weapon->
speed < 0) {
1834 weapon->
magic -= loss;
1836 if (weapon->
magic < 0) {
1843 LocalWeaponDataChange(weapon->
elem, 5, 2, 3);
1844 LocalWeaponDataChange(weapon->
vs_monster, 3, 2, 2);
1845 LocalWeaponDataChange(&weapon->
vs_monster[3], 3, 2, 2);
1846 LocalWeaponDataChange(&weapon->
vs_monster[6], 4, 2, 2);
1851 if (IsDefaultWeapon(weapon->
item_no) >= 0) {
1852 printf(
"this weapon No.%d is default\n", weapon->
item_no);
1854 int add = rand() % 3 + 3;
1861 printf(
"WHp up is %d\n", add);
1862 printf(
"now MaxWHp is %d\n", weapon->
durability);
1866 case RGATE_WHP_DOWN:
1867 if (IsDefaultWeapon(weapon->
item_no) < 0) {
1868 int loss = rand() % 3 + 3;
1872 if (durability < weapon->durability_f) {
1880 printf(
"WHp down is %d\n", loss);
1881 printf(
"now MaxWHp is %d\n", weapon->
durability);
1885 case RGATE_WHP_CURE:
1886 printf(
"whp cure\n");
1888 if (is_default == 1) {
1889 if (UserStatus != NULL) {
1891 EquipWeaponFrame(&DefaultWeapon, chara, CharaMainHandViewFlag);
1894 NowMainEffect = &CharaMainEffectCrash;
1900 MenuWeaponSpSet(&MainWeapon, &weapons[slot]);
1901 printf(
"equip default Weapon\n");
1908 case RGATE_WHP_QUARTER: {
1912 if (durability < 1.0f) {
1919 printf(
"now %d ??? \n");
void SetMotion(int no, int mode, float speed=-1.0f)
MOTION_INFO * GetMotionInfo(int motion_no)
virtual void LoadPackData(unsigned int *pack, char *name, CDataAlloc2< 1 > *model_alloc, CDataAlloc2< 1 > *texture_alloc)
virtual void SetScale(float x, float y, float z)
virtual void LoadPackData3(unsigned int *pack, char *name, CDataAlloc2< 1 > *alloc, int texture_block_no, CDataAlloc2< 1 > *image_alloc, int keep_textures, int visual_type)
virtual void Initialize()
virtual void SetPosition(float x, float y, float z)
virtual void ClothStep(int step)
s32 GetActiveCharaStatus(int chara_no)
void MenuModeOn(int threshold)
void SetAutoRepeat(int mask, int initial_delay, int repeat_delay)
CDngStatusData * GetDngStatus()
int QuestDungeon(int dungeon_no, int add)
int GetGameFlag(int flag_no)
void SetNextLife(int chara_no, s16 value, float ratio)
void AddDrink(int chara_no, s16 amount, float ratio)
WEAPON_HAVE chara_weapons[6][11]
s8 equipped_weapon_slot[6]
void InitSet(CFrame *frame, char *root_name, char *tip_name)
void NeedMesWinWH(int mes_no, int *out)
void SetBuff(short *buff)
MES_LINE_POS line_pos[10]
int MakeMesWin(int mes_no)
void SetBuff_system(short *buff)