DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
weaponlevelup.cpp
1#pragma helper_mask_gpr 0x30
2#pragma helper_mask_fpr 0x1000
3
4#include "weaponlevelup.hpp"
5
6#include <cmath>
7#include <cstdio>
8#include <cstdlib>
9#include <cstring>
10
11#include "battlemenu.hpp"
12#include "clsmes.hpp"
13#include "dataalloc.hpp"
14#include "dataread.hpp"
15#include "dngstatusdata.hpp"
16#include "itemdata.hpp"
17#include "mainselect.hpp"
18#include "menu_draw.hpp"
19#include "menu_inventory.hpp"
20#include "menu_misc.hpp"
21#include "menuitemstep.hpp"
22#include "savedata.hpp"
23#include "shop.hpp"
24#include "snd.hpp"
25#include "texture.hpp"
26#include "weapon_buildup.hpp"
27
28CDataAlloc2<1> MenuEffectCashBuffer(-1);
29
30CWeaponLevelUp MenuWepLevelUp;
31
33CMenuItemStep ItemVolumeStep;
34
35void AttachMentValuePlus(ATTACH_LIST *total, ATTACH_LIST *attach, float scale) {
36 WEAPON_DATA *weapon_data;
37 int i;
38 int sum;
39
40 weapon_data = GetWeaponData(total->sphere_weapon_no);
41
42 int limit[4] = {999, 99, 99, 999};
43
44 if (weapon_data != NULL) {
45 limit[0] = weapon_data->attack_max;
46 limit[3] = weapon_data->magic_max;
47 }
48
49 for (i = 0; i < 4; i++) {
50 sum = total->status[i] + (s16) (int) ((float) attach->status[i] * scale);
51
52 if (sum >= limit[i]) {
53 total->status[i] = limit[i];
54 } else {
55 total->status[i] = sum;
56 }
57 }
58
59 for (i = 0; i < 5; i++) {
60 sum = total->elem[i] + (int) ((float) attach->elem[i] * scale);
61
62 if (sum >= 99) {
63 total->elem[i] = 99;
64 } else {
65 total->elem[i] = sum;
66 }
67 }
68
69 for (i = 0; i < 10; i++) {
70 sum = total->vs_monster[i] + (int) ((float) attach->vs_monster[i] * scale);
71
72 if (sum >= 99) {
73 total->vs_monster[i] = 99;
74 } else {
75 total->vs_monster[i] = sum;
76 }
77 }
78}
79
80void WeaponLevelUpValueCalc(WEAPON_HAVE *src, WEAPON_HAVE *dst, int levels, int unused) {
81 ATTACH_LIST total;
82 int i;
83 int synth_count;
84 int flags;
85 WEAPON_DATA *weapon_data;
86 ATTACH_LIST *attach;
87 int hole;
88 int has_double;
89 int sum;
90 float scale;
91
92 if (src == NULL) {
93 return;
94 }
95
96 memset(&total, 0, 0x20);
97 memset(dst, 0, 0xF8);
98 synth_count = 0;
99 flags = 1;
100 flags |= src->flags;
101 weapon_data = GetWeaponData(src->item_no);
102
103 for (i = 0; i < levels; i++) {
104 for (i = 0; i < 6; i++) {
105 if (weapon_data->hole[i] > 0) {
106 attach = &src->attach[i];
107
108 if (attach->item_no >= ITEM_ATTACH_START) {
109 scale = 1.0f;
110
111 if (src->attach_kind[i] == 3) {
112 scale = 2.0f;
113 }
114
115 AttachMentValuePlus(&total, attach, scale);
116
117 if (attach->item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
118 synth_count++;
119
120 if (attach->sphere_flags != 0 && attach->sphere_flags != 1) {
121 flags |= attach->sphere_flags;
122 }
123 }
124 }
125 }
126 }
127
128 memset(dst->attach, 0, 0xC0);
129 memcpy(dst, src, 0xF8);
130 dst->attack += total.status[0] + 1;
131
132 if (dst->attack > weapon_data->attack_max) {
133 dst->attack = weapon_data->attack_max;
134 }
135
136 dst->endurance += total.status[1] + 1;
137
138 if (dst->endurance >= 99) {
139 dst->endurance = 99;
140 }
141
142 dst->speed += total.status[2] + 1;
143
144 if (dst->speed >= 99) {
145 dst->speed = 99;
146 }
147
148 dst->magic += total.status[3] + 1;
149
150 if (dst->magic >= weapon_data->magic_max) {
151 dst->magic = weapon_data->magic_max;
152 }
153
154 for (i = 0; i < 5; i++) {
155 sum = (s8) dst->elem[i] + total.elem[i];
156
157 if (sum >= 99) {
158 dst->elem[i] = 99;
159 } else {
160 dst->elem[i] = sum;
161 }
162 }
163
164 for (i = 0; i < 10; i++) {
165 sum = dst->vs_monster[i] + total.vs_monster[i];
166
167 if (sum >= 99) {
168 dst->vs_monster[i] = 99;
169 } else {
170 dst->vs_monster[i] = sum;
171 }
172 }
173
174 dst->durability = src->durability + 1 + rand() % 3;
175
176 if (dst->durability > 99) {
177 dst->durability = 99;
178 }
179
180 has_double = 0;
181
182 for (hole = 0; hole < 6; hole++) {
183 if (weapon_data->hole[hole] > 0 && weapon_data->hole[hole] != 2) {
184 if (has_double != 0) {
185 dst->attach_kind[hole] = 0;
186 } else if (rand() % 50 == 5) {
187 dst->attach_kind[hole] = 3;
188 has_double = 1;
189 } else {
190 dst->attach_kind[hole] = 0;
191 }
192 }
193 }
194 }
195
196 dst->flags |= flags;
197 dst->synthesis_count += synth_count;
198}
199
201 int size;
202 int file_no;
203 int se_no;
204
205 effect_buffer = (u_long128 *) load_buffer;
206 effect_buffer = MenuCalcBufAlignment(effect_buffer);
207 {
208 char *file_names[5] = {"wlevelup.pak", "s_break.pak", "buildup.chr", "menu_ex.chr", "w_recover.chr"};
209 char path[0x40] = "commenu/effect/";
210 char file_table[WEP_EFFECT_KIND_COUNT] = {0, 1, 2, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3};
211 s16 se_table[WEP_EFFECT_KIND_COUNT] = {25, 26, 28, -1, -1, -1, -1, 20, 20, -1, 20, 20, 20, 20};
212
213 file_no = file_table[kind];
214 se_no = se_table[kind];
215
216 if (kind == WEP_EFFECT_BUILDUP && IsLastWeapon(buildup_weapon_no) != 0) {
217 se_no = 21;
218 printf("last weapon\n");
219 }
220
221 strcat(path, file_names[file_no]);
222 StartReadBG();
223 LoadFileBG(path, effect_buffer, &size);
224 }
225
226 if (0 <= se_no) {
227 effect_buffer += (size >> 4) + 1;
228 effect_buffer = MenuCalcBufAlignment(effect_buffer);
229 SndSPSeLoadBG(se_no, (u_int *) effect_buffer, &size);
230 printf("effect snd size = %d\n", size);
231 effect_buffer += (size >> 4) + 1;
232 }
233
234 ReadBG();
235}
236
238 memset(this, -1, 0xF8);
239 memset(&status_item_no, 0, 0x20);
240 effect.frame = NULL;
241 effect_buffer = NULL;
242 weapon = NULL;
243 reserved_word = 0;
244 effect_active = false;
245 effect_timer = -1.0f;
246 effect_state = WEP_EFFECT_STATE_IDLE;
247 operation_kind = WEP_EFFECT_NONE;
248 texture_block = -1;
250 message_no = 0;
251 message_value = 0;
252 synthesis_count = 0;
253 reserved_half = 0;
255 lost_default_weapon = false;
256}
257
258void CWeaponLevelUp::SetLevelUpValue(WEAPON_HAVE *have, CCharacter *character, CWeaponLevelUp *load_buffer, int tex_block) {
259 ATTACH_LIST total;
260 int i;
261 WEAPON_DATA *weapon_data;
262 int flags;
263 ATTACH_LIST *attach;
264 int j;
265 int icon_count;
266 int slot;
267 int sum;
268 int has_double;
269 int hole;
270 int option;
271 float scale;
272
273 if (have == NULL) {
274 printf("src is NULL\n");
275 return;
276 }
277
278 texture_block = tex_block;
279 operation_kind = WEP_EFFECT_LEVELUP;
280 effect_motion = 0;
281 CMenuEffectDataLoad(load_buffer, 0);
282 synthesis_count = 0;
283 chara = character;
284 weapon = have;
285 memcpy(&preview, weapon, 0xF8);
286 weapon_data = GetWeaponData(preview.item_no);
287 memset(&total, 0, 0x20);
288 flags = 1;
289 flags |= preview.flags;
290
291 for (i = 0; i < 6; i++) {
292 if (weapon_data->hole[i] > 0) {
293 attach = &preview.attach[i];
294
295 if (preview.attach[i].item_no >= ITEM_ATTACH_START) {
296 scale = 1.0f;
297
298 if (preview.attach_kind[i] == 3) {
299 scale = 2.0f;
300 }
301
302 AttachMentValuePlus(&total, attach, scale);
303
304 if (attach->item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
306
307 if (attach->sphere_flags != 0 && attach->sphere_flags != 1) {
308 flags |= attach->sphere_flags;
309 }
310 }
311 }
312 }
313 }
314
315 flags = CheckWeaponOptionStatus(flags);
316 preview.flags |= flags;
317 preview.attack += total.status[0];
318
319 if (preview.attack > weapon_data->attack_max) {
320 preview.attack = weapon_data->attack_max;
321 }
322
323 preview.endurance += total.status[1];
324
325 if (preview.endurance > 99) {
326 preview.endurance = 99;
327 }
328
329 preview.speed += total.status[2];
330
331 if (preview.speed > 99) {
332 preview.speed = 99;
333 }
334
335 preview.magic += total.status[3];
336
337 if (preview.magic > weapon_data->magic_max) {
338 preview.magic = weapon_data->magic_max;
339 }
340
341 for (j = 0; j < 5; j++) {
342 sum = preview.elem[j] + total.elem[j];
343
344 if (sum >= 99) {
345 preview.elem[j] = 99;
346 } else {
347 preview.elem[j] = sum;
348 }
349 }
350
351 for (j = 0; j < 10; j++) {
352 sum = preview.vs_monster[j] + total.vs_monster[j];
353
354 if (sum >= 99) {
355 preview.vs_monster[j] = 99;
356 } else {
357 preview.vs_monster[j] = sum;
358 }
359 }
360
361 if (preview.durability >= 99) {
362 preview.durability = 99;
363 }
364
365 memset(attachment_icons, 0, 0xA);
366 memset(attachment_values, 0, 0xA);
367 icon_count = 0;
368
369 for (slot = 0; slot < 5; slot++) {
370 if (preview.attach[slot].item_no >= ITEM_ATTACH_START) {
371 attachment_icons[icon_count] = preview.attach[slot].item_no;
372 attachment_values[icon_count] = 0;
373
374 if (attachment_icons[icon_count] >= ITEM_ATTACH_STAT_START && attachment_icons[icon_count] < ITEM_ATTACH_GEM_START) {
375 attachment_values[icon_count] = preview.attach[slot].status[preview.attach[slot].item_no - ITEM_ATTACH_STAT_START];
376 }
377
378 if (attachment_icons[icon_count] == ITEM_ATTACH_SYNTHESIS_SPHERE) {
380 }
381
382 icon_count++;
383 }
384 }
385
386 memset(weapon->attach, 0, 0xC0);
387 memset(preview.attach, 0, 0xC0);
388
389 for (j = 0; j < 6; j++) {
390 weapon->attach[j].item_no = -1;
391 }
392
393 has_double = 0;
394
395 for (hole = 0; hole < 5; hole++) {
396 if (weapon_data->hole[hole] > 0 && weapon_data->hole[hole] != 2) {
397 if (has_double != 0) {
398 preview.attach_kind[hole] = 0;
399 } else if (rand() % 50 == 5) {
400 preview.attach_kind[hole] = 3;
401 has_double = 1;
402 } else {
403 preview.attach_kind[hole] = 0;
404 }
405 }
406 }
407
408 memcpy(weapon, &preview, 0xF8);
409 effect_state = WEP_EFFECT_STATE_LEVELUP_LOAD;
410}
411
413 WEAPON_DATA *weapon_data = GetWeaponData(weapon->item_no);
414
415 weapon->attack = weapon->attack + 1;
416
417 if (weapon->attack > weapon_data->attack_max) {
418 weapon->attack = weapon_data->attack_max;
419 }
420
422
423 if (weapon->endurance > 99) {
424 weapon->endurance = 99;
425 }
426
427 weapon->speed = weapon->speed + 1;
428
429 if (weapon->speed > 99) {
430 weapon->speed = 99;
431 }
432
433 weapon->magic = weapon->magic + 1;
434
435 if (weapon->magic > weapon_data->magic_max) {
436 weapon->magic = weapon_data->magic_max;
437 }
438
439 weapon->durability = weapon->durability + 1 + rand() % 3;
440
441 if (weapon->durability > 99) {
442 weapon->durability = 99;
443 }
444
445 weapon->experience = 0;
446}
447
448void CWeaponLevelUp::SetStatusBreak(WEAPON_HAVE *have, CCharacter *character, CWeaponLevelUp *load_buffer, int tex_block) {
449 ATTACH_LIST total;
450 int page;
451 int i;
452 int slot_no;
453 ATTACH_LIST *items;
454 s16 flags;
455 ATTACH_LIST *slot;
456 float scale;
457 CDngStatusData *dng_status;
458
459 if (have == NULL) {
460 printf("src is NULL\n");
461 return;
462 }
463
464 texture_block = tex_block;
465 operation_kind = WEP_EFFECT_STATUS_BREAK;
466 effect_state = WEP_EFFECT_STATE_BREAK_LOAD;
467 effect_motion = 0;
468 CMenuEffectDataLoad(load_buffer, 1);
469 chara = character;
470 weapon = have;
471 memset(&status_item_no, 0, 0x20);
472 status_item_no = ITEM_ATTACH_SYNTHESIS_SPHERE;
475
476 s16 base_stats[4] = {0, 0, 0, 0};
477 base_stats[0] = weapon->attack;
478 base_stats[1] = weapon->endurance;
479 base_stats[2] = weapon->speed;
480 base_stats[3] = weapon->magic;
481
482 for (i = 0; i < 4; i++) {
483 status_stats[i] = 0.6f * (float) base_stats[i];
484 }
485
486 scale = 0.6f;
487
488 for (i = 0; i < 5; i++) {
489 status_elements[i] = weapon->elem[i] * scale;
490 }
491
492 for (i = 0; i < 10; i++) {
493 status_monster[i] = weapon->vs_monster[i] * scale;
494 }
495
496 flags = 0;
497 flags |= weapon->flags;
498 memset(&total, 0, 0x20);
500
501 for (i = 0; i < 6; i++) {
502 if (weapon->attach[i].item_no >= ITEM_ATTACH_START) {
503 scale = 1.0f;
504
505 if (weapon->attach_kind[i] == 3) {
506 scale = 2.0f;
507 }
508
509 AttachMentValuePlus(&total, &have->attach[i], scale);
510
511 if (weapon->attach[i].item_no == ITEM_ATTACH_SYNTHESIS_SPHERE) {
512 if (weapon->attach[i].sphere_flags != 0 && weapon->attach[i].sphere_flags != 1) {
513 flags |= weapon->attach[i].sphere_flags;
514 }
515 }
516 }
517 }
518
519 AttachMentValuePlus((ATTACH_LIST *) &status_item_no, &total, 0.6f);
520 flags = CheckWeaponOptionStatus(flags);
521 dng_status = SaveData->GetDngStatus();
522 slot_no = GetBoardSpace(0x5A, &page);
523 items = (ATTACH_LIST *) dng_status->consumable_items;
524 slot = &items[slot_no];
525 memcpy(slot, &status_item_no, 0x20);
526 slot->item_no = ITEM_ATTACH_SYNTHESIS_SPHERE;
527 items[slot_no].sphere_level = weapon->level;
528 items[slot_no].sphere_weapon_no = weapon->item_no;
529 items[slot_no].sphere_flags = flags;
530}
531
532void CWeaponLevelUp::SetBuildUp(WEAPON_HAVE *have, CCharacter *character, CWeaponLevelUp *load_buffer, int tex_block) {
533 if (have == NULL) {
534 return;
535 }
536
537 texture_block = tex_block;
538 operation_kind = WEP_EFFECT_BUILDUP;
539 effect_state = WEP_EFFECT_STATE_BUILDUP_LOAD;
540 effect_motion = 0;
542 chara = character;
543 weapon = have;
544 memcpy(&preview, weapon, 0xF8);
545 SetWeaponBuildValue(&preview, buildup_weapon_no);
546
547 if (have->item_no == ITEM_WEAPON_MARDAN_EINS || have->item_no == ITEM_WEAPON_MARDAN_TWEI) {
548 ClearFishMardanGarayanNum();
549 printf("mardan num clear!!\n");
550 }
551}
552
553void CWeaponLevelUp::WepRecover(WEAPON_HAVE *have, CCharacter *character, CWeaponLevelUp *load_buffer, int tex_block) {
554 if (have == NULL || character == NULL || load_buffer == NULL) {
555 return;
556 }
557
558 texture_block = tex_block;
559 operation_kind = WEP_EFFECT_RECOVER;
560 effect_state = WEP_EFFECT_STATE_RECOVER_LOAD;
561 effect_motion = 0;
563 chara = character;
564 weapon = have;
565}
566
567void CWeaponLevelUp::CureEffect(int x, int y, CWeaponLevelUp *load_buffer, int tex_block, int kind) {
568 CMenuEffectDataLoad(load_buffer, kind);
569 texture_block = tex_block;
570 operation_kind = kind;
571 effect_state = (operation_kind - 4) * 2 + 12;
573
574 if (kind == WEP_EFFECT_CURE_POCKET) {
575 effect_motion = 2;
576 } else {
577 if (operation_kind >= WEP_EFFECT_UNK_7) {
579 }
580
581 if (operation_kind >= WEP_EFFECT_CURE_REVIVAL_POWDER) {
583 }
584 }
585
586 effect_x = (float) x;
587 effect_y = (float) y;
588}
589
591 snd_from = -1;
592 snd_volume = 0;
593 snd_to = 0;
594 snd_step = 0;
595}
596
597void CWeaponLevelUp::SetSnd(int from, int to, int step) {
598 snd_from = from;
600 snd_to = to;
601
602 if (to < from) {
603 snd_step = -step;
604 }
605
606 if (from < to) {
607 snd_step = step;
608 }
609
610#ifdef PAL
611 if (DebugMode) {
612 printf("menu snd para:\n");
613 printf(" start:%d\n", snd_from);
614 printf(" now:%d\n", snd_volume);
615 printf(" limmit:%d\n", snd_to);
616 printf(" step:%d\n", snd_step);
617 }
618#endif
619}
620
622 if (snd_step != 0) {
624 SndSetBgmVol(snd_volume);
625
626 if (snd_step > 0) {
627 if (snd_to <= snd_volume) {
629 snd_step = 0;
630 }
631 }
632
633 if (snd_step < 0) {
634 if (snd_to >= snd_volume) {
636 snd_step = 0;
637 }
638 }
639 }
640}
641
643 int volume;
644
645 printf("snd check\n");
646
647 if (snd_from > 0 || snd_step != 0) {
648 volume = SndGetBgmVol();
649
650 if (volume != snd_volume) {
651 SndSetBgmVol(volume);
652 }
653 }
654
655 InitSnd();
656}
657
659 int size;
660 int motion_state;
661 int ready_count;
662 int se_no;
663 int volume;
664 int file_no;
665 BG_READ_INFO *read_info;
666 u_int *pack_data;
667 u_long128 *cache_base;
668 int discard;
669 int option;
670 float motion_time;
671
672 if (operation_kind == WEP_EFFECT_NONE) {
673 return;
674 }
675
676 motion_state = 0;
677
678 if (effect.frame != NULL) {
679 motion_state = effect.motion_state;
680 }
681
682 switch (effect_state) {
683 default:
684 break;
685 case WEP_EFFECT_STATE_IDLE:
686 return;
687 case WEP_EFFECT_STATE_LEVELUP_LOAD:
688 case WEP_EFFECT_STATE_BREAK_LOAD:
689 case WEP_EFFECT_STATE_BUILDUP_LOAD:
690 case WEP_EFFECT_STATE_RECOVER_LOAD:
691 case WEP_EFFECT_STATE_CURE_HEAL_HP_LOAD:
692 case WEP_EFFECT_STATE_CURE_DRINK_LOAD:
693 case WEP_EFFECT_STATE_CURE_REPAIR_LOAD:
694 case WEP_EFFECT_STATE_UNK_12:
695 case WEP_EFFECT_STATE_CURE_STATUS_LOAD:
696 case WEP_EFFECT_STATE_CURE_AILMENT_LOAD:
697 case WEP_EFFECT_STATE_CURE_REVIVAL_POWDER_LOAD:
698 case WEP_EFFECT_STATE_CURE_GOURD_LOAD:
699 case WEP_EFFECT_STATE_CURE_FRUIT_OF_EDEN_LOAD:
700 case WEP_EFFECT_STATE_CURE_POCKET_LOAD:
701 ReadBG();
702 ready_count = 0;
703
704 if (ReadBGSync() == 0) {
705 ready_count++;
706 }
707
708 if (SndSPSeSyncBG() == 0) {
709 ready_count++;
710
711 if (operation_kind != WEP_EFFECT_CURE_REPAIR && operation_kind != WEP_EFFECT_RECOVER && operation_kind != WEP_EFFECT_CURE_AILMENT && operation_kind != WEP_EFFECT_CURE_HEAL_HP && operation_kind != WEP_EFFECT_CURE_DRINK) {
712 volume = BtlMenuBGMvol;
713 SetSnd(volume, volume >> 2, 7);
714 }
715 }
716
717 if (ready_count >= 2) {
718 LOADTEXTURE_INFO2 textures[3] = {
719 {"#frame_menu_level#640#" SCREEN_HEIGHT_STR "#4", 0, 0},
720 {NULL, 0, 0},
721 {NULL, 0, 0}
722 };
723 textures[0].block_no = texture_block;
724 textures[1].block_no = texture_block;
725 char file_table[WEP_EFFECT_KIND_COUNT] = {0, 1, 2, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3};
726 char *image_names[5] = {"wlevelup", "s_break", "buildup", "menu_ex", "w_recover"};
727 char *config_names[14] = {"wlevelup", "info", "buildup", "info", "w_recover",
728 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
729 char config_name[0x20];
730 char image_name[0x20];
731
732 file_no = file_table[operation_kind];
733 strcpy(config_name, config_names[file_no]);
734 strcpy(image_name, image_names[file_no]);
735 strcat(image_name, ".img");
736 strcat(config_name, ".cfg");
737 read_info = GetReadBGFile(0);
738 textures[1].name = (char *) GetPackFile((u_int *) read_info->buffer, image_name, &size);
739 TexManager.DeleteTextureBlock(texture_block);
740 TexManager.CleanUpTextureList();
741 TexManager.LoadTextureBlockEX(-1, textures);
742 pack_data = (u_int *) read_info->buffer;
743 cache_base = read_info->buffer + (read_info->size >> 4) + 1;
744 cache_base = MenuCalcBufAlignment(cache_base);
746 MenuEffectCashBuffer.base = (u8 *) cache_base;
747 MenuEffectCashBuffer.limit = 0x9100;
748 MenuEffectCashBuffer.used = 0;
749 effect.LoadPackData(pack_data, config_name, &MenuEffectCashBuffer, &MenuEffectCashBuffer);
750 effect_buffer = (u_long128 *) ((MenuEffectCashBuffer.used << 4) + MenuEffectCashBuffer.base);
751 effect_state++;
752 effect_timer = 0.0f;
753 effect_active = true;
754
755 float position[4] = {0.0f, 0.0f, 1.0f, 1.0f};
756
757 switch (operation_kind) {
758 case WEP_EFFECT_CURE_HEAL_HP:
759 case WEP_EFFECT_CURE_DRINK:
760 case WEP_EFFECT_CURE_REPAIR:
761 case WEP_EFFECT_CURE_STATUS:
762 case WEP_EFFECT_CURE_AILMENT:
763 case WEP_EFFECT_CURE_REVIVAL_POWDER:
764 case WEP_EFFECT_CURE_GOURD:
765 case WEP_EFFECT_CURE_FRUIT_OF_EDEN:
766 case WEP_EFFECT_CURE_POCKET:
767 position[0] = effect_x;
768 position[1] = effect_y;
769 break;
770 }
771
772 effect.SetPosition(position);
773
774 float scale[3] = {1.0f, 1.0f, 1.0f};
775
776 switch (operation_kind) {
777 case WEP_EFFECT_STATUS_BREAK:
778 int i;
779
780 for (i = 0; i < 3; i++) {
781 scale[i] = 1.38f;
782 }
783
784 break;
785 case WEP_EFFECT_BUILDUP:
786 int j;
787
788 for (j = 0; j < 3; j++) {
789 scale[j] = 2.0f;
790 }
791
792 break;
793 }
794
795 effect.SetScale(scale);
798 effect.motion_speed = -1.0f;
799 effect.Step();
800 se_no = -1;
801
802 switch (operation_kind) {
803 case WEP_EFFECT_STATUS_BREAK:
804 se_no = 0x1A;
805 break;
806 case WEP_EFFECT_LEVELUP:
807 se_no = 0x19;
808 break;
809 case WEP_EFFECT_BUILDUP:
810 se_no = 0x1C;
811
812 if (IsLastWeapon(buildup_weapon_no) != 0) {
813 se_no = 0x15;
814 }
815
816 break;
817 case WEP_EFFECT_CURE_GOURD:
818 case WEP_EFFECT_CURE_FRUIT_OF_EDEN:
819 case WEP_EFFECT_CURE_POCKET:
820 case WEP_EFFECT_CURE_STATUS:
821 case WEP_EFFECT_UNK_7:
822 case WEP_EFFECT_CURE_REVIVAL_POWDER:
823 se_no = 0x14;
824 break;
825 }
826
827 if (se_no >= 0) {
828 SndSPSePlay(se_no, -1);
829 }
830
831 for (int i = 0; i < 4; i++) {
832 CommonMenuMes1.mes_no[i] = -1;
833
834 if (i >= 0 && i < 10) {
835 CommonMenuMes1.line_pos[i].x = -1;
836 CommonMenuMes1.line_pos[i].y = -1;
837 }
838 }
839
840 return;
841 }
842
843 break;
844 case WEP_EFFECT_STATE_LEVELUP_ORBIT:
845 effect_timer += 1.0f;
846
847 if (!(effect_timer < 140.0f)) {
848 effect_state = WEP_EFFECT_STATE_LEVELUP_DONE;
849 return;
850 }
851
852 break;
853 case WEP_EFFECT_STATE_LEVELUP_DONE:
854 effect_timer += 1.0f;
855
856 if (motion_state == 3) {
857 effect_timer = 200.0f;
858 effect_active = false;
859 return;
860 }
861
862 break;
863 case WEP_EFFECT_STATE_BREAK_PLAY:
864 effect_timer += 1.0f;
865
866 if (motion_state == 3) {
870 effect.motion_speed = -1.0f;
871 effect_state++;
872 effect_timer = 0.0f;
873 discard = 1;
874
875 if (IsDefaultWeapon(weapon->item_no) >= 0) {
876 discard = 0;
877 weapon->level = 0;
878 lost_default_weapon = true;
879 }
880
881 if (discard != 0) {
882 memset(weapon, 0, 0xF8);
883 weapon->item_no = -1;
884 return;
885 }
886
887 WepDataListToHaveCopy(weapon->item_no, weapon);
888 return;
889 }
890
891 break;
892 case WEP_EFFECT_STATE_BREAK_DONE:
893 effect_timer += 1.0f;
894
895 if (motion_state == 3) {
896 effect_timer = 12.0f;
897 effect_active = false;
898 return;
899 }
900
901 break;
902 case WEP_EFFECT_STATE_BUILDUP_PLAY:
903 if (motion_state == 3) {
905 SetWeaponBuildValue(weapon, buildup_weapon_no);
907 weapon->level = 0;
908 weapon->experience = 0;
909 option = DefaultWeaponOptionSet(buildup_weapon_no);
910
911 if (option != 1) {
912 option = CheckWeaponOptionStatus(option);
913 weapon->flags = weapon->flags | option;
914 }
915
916 MenuExTextureReadFlag = MENU_EX_TEX_UNREAD;
920 effect.motion_speed = -1.0f;
921 printf("effect setmotion tuuka \n");
922 effect_state++;
923 return;
924 }
925
926 break;
927 case WEP_EFFECT_STATE_BUILDUP_DONE:
928 if (motion_state == 3) {
929 effect_active = false;
930 return;
931 }
932
933 break;
934 case WEP_EFFECT_STATE_RECOVER_DONE:
935 if (motion_state == 3) {
936 effect_active = false;
937 return;
938 }
939
940 break;
941 case WEP_EFFECT_STATE_CURE_DRINK_PLAY:
942 motion_time = effect.motion_type.state.time;
943
944 if (motion_time > 52.0 && motion_time < 52.3) {
945 ComMenuSePlay(SE_EFFECT_CHIME);
946 }
947 /* fallthrough */
948 case WEP_EFFECT_STATE_CURE_HEAL_HP_PLAY:
949 case WEP_EFFECT_STATE_CURE_REPAIR_PLAY:
950 case WEP_EFFECT_STATE_UNK_13:
951 case WEP_EFFECT_STATE_CURE_AILMENT_PLAY:
952 if (motion_state == 3) {
953 if (message_no >= 0x190) {
954 effect_active = false;
955 return;
956 }
957
958 effect_active = true;
959 Initialize();
960 return;
961 }
962
963 break;
964 case WEP_EFFECT_STATE_CURE_STATUS_PLAY:
965 case WEP_EFFECT_STATE_CURE_REVIVAL_POWDER_PLAY:
966 case WEP_EFFECT_STATE_CURE_GOURD_PLAY:
967 case WEP_EFFECT_STATE_CURE_FRUIT_OF_EDEN_PLAY:
968 case WEP_EFFECT_STATE_CURE_POCKET_PLAY:
969 if (motion_state == 3) {
970 effect_active = false;
971 }
972
973 break;
974 }
975}
976
978 s16 icons[5];
979 s16 values[5];
980 int i;
981 int alpha;
982 int count;
983 float angle_step;
984 float orbit_radius;
985 float angular_rate;
986 float angle;
987 float x;
988 float y;
989
990 if (effect_state == WEP_EFFECT_STATE_IDLE) {
991 return;
992 }
993
994 if (effect_timer < 0.0f) {
995 return;
996 }
997
998 alpha = 128;
999
1000 switch (effect_state) {
1001 case WEP_EFFECT_STATE_BREAK_DONE:
1002 if (!(effect.GetNowTime() < 134.0f)) {
1003 MenuTextureReload(MenuShadowReadBlock);
1004 DrawIconParts(ITEM_ATTACH_SYNTHESIS_SPHERE, 0x132, 0xD0, 0, 0x280, alpha, status_weapon_no);
1005 }
1006
1007 break;
1008 }
1009
1010 if (effect.frame != NULL) {
1011 MenuTextureReload(texture_block);
1012 effect.Step();
1013 effect.Draw();
1014 }
1015
1016 MenuTextureReload(BtlMenuReadBlock);
1017
1018 switch (effect_state) {
1019 case WEP_EFFECT_STATE_IDLE:
1020 case WEP_EFFECT_STATE_LEVELUP_LOAD:
1021 case WEP_EFFECT_STATE_BREAK_LOAD:
1022 case WEP_EFFECT_STATE_BUILDUP_LOAD:
1023 return;
1024 case WEP_EFFECT_STATE_LEVELUP_ORBIT:
1025 count = 0;
1026
1027 for (i = 0; i < 5; i++) {
1028 if (attachment_icons[i] < ITEM_ATTACH_START) {
1029 break;
1030 }
1031
1032 icons[i] = attachment_icons[i];
1033 values[i] = attachment_values[i];
1034 count++;
1035 }
1036
1037 if (count <= 0) {
1038 return;
1039 }
1040
1041 angle_step = TWO_PI / (float) count;
1042 angular_rate = angle_step / 140.0f;
1043 orbit_radius = 128.0f - 128.0f * (effect_timer / 140.0f);
1044
1045 if (!(effect_timer < 100.0f)) {
1046 alpha = 128 - (int) (effect_timer - 100.0f) * 4;
1047
1048 if (alpha < 0) {
1049 alpha = 0;
1050 }
1051 }
1052
1053 MenuTextureReload(MenuShadowReadBlock);
1054
1055 for (i = 0; i < count; i++) {
1056 angle = angular_rate * effect_timer + angle_step * (float) i;
1057 x = orbit_radius * cosf(angle);
1058 y = orbit_radius * sinf(angle);
1059 x = 320.0f + x - 12.0f;
1060 (int) x;
1061 y = SCREEN_HALF_HEIGHT_F + y - 12.0f;
1062 (int) y;
1063 DrawIconParts(icons[i], (int) x, (int) y, 0, 0x280, alpha, values[i]);
1064 }
1065
1066 break;
1067 case WEP_EFFECT_STATE_LEVELUP_DONE:
1068 case WEP_EFFECT_STATE_BREAK_PLAY:
1069 case WEP_EFFECT_STATE_BREAK_DONE:
1070 case WEP_EFFECT_STATE_BUILDUP_PLAY:
1071 case WEP_EFFECT_STATE_BUILDUP_DONE:
1072 break;
1073 }
1074
1075 DrawMes();
1076}
1077
1079 int x;
1080 int y;
1081
1082 if (effect_active == 0 && operation_kind != WEP_EFFECT_NONE) {
1083 switch (effect_state) {
1084 case WEP_EFFECT_STATE_IDLE:
1085 case WEP_EFFECT_STATE_LEVELUP_LOAD:
1086 case WEP_EFFECT_STATE_LEVELUP_ORBIT:
1087 case WEP_EFFECT_STATE_BREAK_LOAD:
1088 case WEP_EFFECT_STATE_BREAK_PLAY:
1089 case WEP_EFFECT_STATE_BUILDUP_LOAD:
1090 return;
1091 }
1092
1093 int mes_id = 0;
1094 int mes_no[2] = {-1, -1};
1095 int values[2] = {-1, -1};
1096
1097 switch (effect_state) {
1098 case WEP_EFFECT_STATE_LEVELUP_DONE:
1099 mes_id = 0x190;
1100 mes_no[0] = GetCommonItemInfo(preview.item_no)->msg + 100;
1101 values[0] = preview.level + 1;
1102 break;
1103 case WEP_EFFECT_STATE_BREAK_DONE:
1104 mes_id = 0x191;
1105 mes_no[0] = GetCommonItemInfo(status_weapon_no)->msg + 100;
1106 values[0] = status_weapon_level;
1107 break;
1108 case WEP_EFFECT_STATE_BUILDUP_DONE:
1109 mes_id = 0x192;
1110 mes_no[0] = GetCommonItemInfo(weapon->item_no)->msg + 100;
1111 values[0] = 0;
1112 break;
1113 case WEP_EFFECT_STATE_RECOVER_DONE:
1114 mes_id = 0x193;
1115 mes_no[0] = GetCommonItemInfo(weapon->item_no)->msg + 100;
1116 values[0] = weapon->level;
1117 break;
1118 case WEP_EFFECT_STATE_CURE_STATUS_PLAY:
1119 mes_id = 0x194;
1120 mes_no[0] = message_no + 50;
1121 values[0] = message_value;
1122 break;
1123 case WEP_EFFECT_STATE_CURE_AILMENT_PLAY:
1124 mes_id = message_no;
1125 break;
1126 case WEP_EFFECT_STATE_CURE_FRUIT_OF_EDEN_PLAY:
1127 mes_id = 0x195;
1128 mes_no[0] = message_no + 50;
1129 break;
1130 case WEP_EFFECT_STATE_CURE_GOURD_PLAY:
1131 mes_id = 0x196;
1132 mes_no[0] = message_no + 50;
1133 break;
1134 case WEP_EFFECT_STATE_CURE_POCKET_PLAY:
1135 mes_id = 0x197;
1136 values[0] = message_value;
1137 break;
1138 case WEP_EFFECT_STATE_CURE_REVIVAL_POWDER_PLAY:
1139 mes_id = 0x198;
1140 mes_no[0] = message_no + 50;
1141 break;
1142 }
1143
1144 if (CommonMenuMes1.mes_made != mes_id || CommonMenuMes1.mes_no[0] != mes_no[0] || CommonMenuMes1.values[0] != values[0]) {
1145 CommonMenuMes1.value_signed = true;
1146 CommonMenuMes1.value_show = false;
1147 CommonMenuMes1.value_narrow = false;
1148 CommonMenuMes1.auto_pos = MES_POS_AUTO;
1149
1150 if (effect_state == WEP_EFFECT_STATE_CURE_FRUIT_OF_EDEN_PLAY || effect_state == WEP_EFFECT_STATE_CURE_GOURD_PLAY || effect_state == WEP_EFFECT_STATE_CURE_POCKET_PLAY || effect_state == WEP_EFFECT_STATE_CURE_STATUS_PLAY || effect_state == WEP_EFFECT_STATE_CURE_AILMENT_PLAY) {
1151 CommonMenuMes1.value_signed = false;
1152 CommonMenuMes1.value_show = true;
1153 CommonMenuMes1.auto_pos = MES_POS_CENTRE;
1154 }
1155
1156 CommonMenuMes1.mes_no[0] = mes_no[0];
1157 CommonMenuMes1.values[0] = values[0];
1158 CommonMenuMes1.mes_made = -1;
1159 CommonMenuMes1.MakeMesWin(mes_id);
1160 }
1161
1162 CommonMenuMes1.stay_frame = true;
1163 MenuTextureReload(CommonMenuMes1.tex_block);
1164 x = 0x164;
1165 y = 0x96;
1166
1167 if (effect_state == WEP_EFFECT_STATE_CURE_FRUIT_OF_EDEN_PLAY || effect_state == WEP_EFFECT_STATE_CURE_GOURD_PLAY || effect_state == WEP_EFFECT_STATE_CURE_POCKET_PLAY || effect_state == WEP_EFFECT_STATE_CURE_AILMENT_PLAY || effect_state == WEP_EFFECT_STATE_CURE_STATUS_PLAY) {
1168 x = 0x100;
1169 y = 0x96;
1170 }
1171
1172 if (operation_kind == WEP_EFFECT_RECOVER) {
1173 CommonMenuMes1.value_signed = true;
1174 CommonMenuMes1.value_show = false;
1175 CommonMenuMes1.value_narrow = false;
1176 x = 0x100;
1177 y = 0x96;
1178 CommonMenuMes1.auto_pos = MES_POS_CENTRE;
1179 }
1180
1181 DrawMenuClsMes(&CommonMenuMes1, x, y);
1182 }
1183}
CFrame * frame
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 Step()
tagMOTION_TYPE motion_type
virtual void Initialize()
float motion_speed
float GetNowTime()
virtual void Draw()
virtual void SetPosition(float x, float y, float z)
CDngStatusData * GetDngStatus()
Definition savedata.cpp:250
DNG_CONSUMABLE consumable_items[43]
void SetBuildUp(WEAPON_HAVE *have, CCharacter *character, CWeaponLevelUp *load_buffer, int tex_block)
void SetSnd(int from, int to, int step)
void SetLevelUpWeaponData()
WEAPON_HAVE preview
CCharacter * chara
void SetStatusBreak(WEAPON_HAVE *have, CCharacter *character, CWeaponLevelUp *load_buffer, int tex_block)
void CMenuEffectDataLoad(CWeaponLevelUp *load_buffer, int kind)
CCharacter effect
void SetLevelUpValue(WEAPON_HAVE *have, CCharacter *character, CWeaponLevelUp *load_buffer, int tex_block)
void WepRecover(WEAPON_HAVE *have, CCharacter *character, CWeaponLevelUp *load_buffer, int tex_block)
void CureEffect(int x, int y, CWeaponLevelUp *load_buffer, int tex_block, int kind)
WEAPON_HAVE * weapon
u_long128 * effect_buffer
s32 auto_pos
Definition clsmes.hpp:172
s32 mes_no[10]
Definition clsmes.hpp:216
s32 mes_made
Definition clsmes.hpp:207
s32 values[8]
Definition clsmes.hpp:217
s32 value_narrow
Definition clsmes.hpp:221
s32 tex_block
Definition clsmes.hpp:227
s32 value_signed
Definition clsmes.hpp:219
s32 stay_frame
Definition clsmes.hpp:189
MES_LINE_POS line_pos[10]
Definition clsmes.hpp:228
int MakeMesWin(int mes_no)
Definition clsmes.cpp:1669
s32 value_show
Definition clsmes.hpp:220
s16 sphere_weapon_no
Definition itemdata.hpp:592
s8 vs_monster[10]
Definition itemdata.hpp:598
s16 status[4]
Definition itemdata.hpp:596
u_long128 * buffer
Definition dataread.hpp:29
char vs_monster[10]
Definition itemdata.hpp:699
ATTACH_LIST attach[6]
Definition itemdata.hpp:701
s8 attach_kind[6]
Definition itemdata.hpp:702
s32 synthesis_count
Definition itemdata.hpp:704
MOTION_STATE state
Definition gameutil.hpp:273