/
itemuse.c
864 lines (640 loc) · 19.1 KB
/
itemuse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
#include "itemuse.h"
#include "hardware.h"
#include "oam.h"
#include "sound.h"
#include "face.h"
#include "spriteanim.h"
#include "msg.h"
#include "item.h"
#include "unit.h"
#include "map.h"
#include "playerphase.h"
#include "bmfx.h"
#include "targetlist.h"
#include "battle.h"
#include "action.h"
#include "mapselect.h"
#include "unitpanel.h"
#include "subtitlehelp.h"
#include "menuinfo.h"
#include "ui.h"
#include "eventinfo.h"
#include "gamedata.h"
#include "constants/iids.h"
#include "constants/terrains.h"
#include "constants/songs.h"
#include "constants/msg.h"
// TODO: map-menu.h
extern struct ProcScr CONST_DATA ProcScr_BackToUnitMenu[];
extern struct Unit gStatGainSimUnit;
static bool HasSelectTarget(struct Unit * unit, void (* list_targets)(struct Unit * unit));
static void SetStaffUseAction(struct Unit * unit);
static void SetItemUseAction(struct Unit * unit);
static void WarpSelect_Init(struct GenericProc * proc);
static void WarpSelect_Loop(struct GenericProc * proc);
static void WarpSelect_HandleConfirm(struct GenericProc * proc);
static void WarpSelect_HandleCancel(struct GenericProc * proc);
static void WarpSelect_End(struct GenericProc * proc);
struct ProcScr CONST_DATA ProcScr_SquareSelectWarp[] =
{
PROC_ONEND(WarpSelect_End),
PROC_CALL(LockGame),
PROC_WHILE_EXISTS(ProcScr_CamMove),
PROC_CALL(WarpSelect_Init),
PROC_WHILE_EXISTS(ProcScr_CamMove),
PROC_REPEAT(WarpSelect_Loop),
PROC_CALL(WarpSelect_HandleConfirm),
PROC_SLEEP(0),
PROC_CALL(UnlockGame),
PROC_GOTO(100),
PROC_LABEL(99),
PROC_CALL(WarpSelect_HandleCancel),
PROC_SLEEP(0),
PROC_CALL(UnlockGame),
PROC_LABEL(100),
PROC_END,
};
bool CanUnitUseItem(struct Unit * unit, int item)
{
if ((GetItemAttributes(item) & ITEM_ATTR_STAFF) && !CanUnitUseStaff(unit, item))
return FALSE;
switch (GetItemIid(item))
{
case IID_HEALSTAFF:
case IID_MENDSTAFF:
case IID_RECOVERSTAFF:
case IID_TINASSTAFF:
return HasSelectTarget(unit, ListAdjacentHealTargets);
case IID_PHYSICSTAFF:
return HasSelectTarget(unit, ListRangedHealTargets);
case IID_FORTIFYSTAFF:
return HasSelectTarget(unit, ListRangedHealTargets);
case IID_RESTORESTAFF:
return HasSelectTarget(unit, ListRestoreTargets);
case IID_RESCUESTAFF:
return HasSelectTarget(unit, ListRescueStaffTargets);
case IID_BARRIERSTAFF:
return HasSelectTarget(unit, ListBarrierTargets);
case IID_SILENCESTAFF:
return HasSelectTarget(unit, ListSilenceTargets);
case IID_SLEEPSTAFF:
return HasSelectTarget(unit, ListSleepTargets);
case IID_BERSERKSTAFF:
return HasSelectTarget(unit, ListBerserkTargets);
case IID_WARPSTAFF:
return HasSelectTarget(unit, ListWarpTargets);
case IID_HAMMERNESTAFF:
return HasSelectTarget(unit, ListRepairTargets);
case IID_UNLOCKSTAFF:
return HasSelectTarget(unit, ListUnlockTargets);
case IID_SECRETBOOK:
case IID_GODDESSICON:
case IID_SERAPHROBE:
case IID_DRACOSHIELD:
case IID_ENERGYRING:
case IID_SPEEDWING:
case IID_TALISMAN:
case IID_BOOTS:
case IID_BODYRING:
return CanUnitUseStatGainItem(unit, item);
case IID_HEROCREST:
case IID_KNIGHTCREST:
case IID_ORIONSBOLT:
case IID_ELYSIANWHIP:
case IID_GUIDINGRING:
return CanUnitUsePromotionItem(unit, item);
case IID_BINDINGBLADE:
return CanUnitUseBindingBladeToHeal(unit);
case IID_VULNERARY:
case IID_ELIXIR:
return CanUnitUseHealItem(unit);
case IID_PUREWATER:
return CanUnitUsePureWaterItem(unit);
case IID_TORCH:
case IID_TORCHSTAFF:
return CanUnitUseTorchItem(unit);
case IID_ANTITOXIN:
return CanUnitUseAntitoxinItem(unit);
case IID_CHESTKEY:
return CanUnitUseChestKeyItem(unit);
case IID_DOORKEY:
return CanUnitUseDoorKeyItem(unit);
case IID_BRIDGEKEY:
return CanUnitUseBridgeKeyItem(unit);
case IID_LOCKPICK:
return CanUnitUseLockpickItem(unit);
case IID_SAINTSSTAFF:
return HasSelectTarget(unit, ListSaintsStaffTargets);
default:
return FALSE;
}
}
int GetUnitItemCantUseMsg(struct Unit * unit, int item)
{
switch (GetItemIid(item))
{
case IID_BINDINGBLADE:
case IID_TORCHSTAFF:
case IID_SECRETBOOK:
case IID_GODDESSICON:
case IID_SERAPHROBE:
case IID_DRACOSHIELD:
case IID_ENERGYRING:
case IID_SPEEDWING:
case IID_TALISMAN:
case IID_BOOTS:
case IID_BODYRING:
case IID_VULNERARY:
case IID_ELIXIR:
case IID_PUREWATER:
case IID_TORCH:
case IID_ANTITOXIN:
return MSG_C3C;
case IID_CHESTKEY:
return MSG_C40;
case IID_DOORKEY:
case IID_BRIDGEKEY:
return MSG_C3F;
case IID_LOCKPICK:
if (UNIT_ATTRIBUTES(gActiveUnit) & UNIT_ATTR_STEAL)
return MSG_C43;
return MSG_C41;
case IID_HEROCREST:
case IID_KNIGHTCREST:
case IID_ORIONSBOLT:
case IID_ELYSIANWHIP:
case IID_GUIDINGRING:
{
bool boolval;
int level = gActiveUnit->level;
gActiveUnit->level = 10;
boolval = CanUnitUsePromotionItem(gActiveUnit, item);
gActiveUnit->level = level;
if (boolval)
return MSG_C3E;
return MSG_C3D;
}
default:
return MSG_C3D;
}
}
void DoUseUnitItem(struct Unit * unit, int item)
{
ClearUi();
EndFaceById(0);
switch (GetItemIid(item))
{
case IID_HEALSTAFF:
case IID_MENDSTAFF:
case IID_RECOVERSTAFF:
case IID_TINASSTAFF:
DoUseHealStaff(unit, ListAdjacentHealTargets);
break;
case IID_PHYSICSTAFF:
DoUseHealStaff(unit, ListRangedHealTargets);
break;
case IID_RESCUESTAFF:
DoUseRescueStaff(unit, ListRescueStaffTargets);
break;
case IID_RESTORESTAFF:
DoUseRestoreStaff(unit, ListRestoreTargets);
break;
case IID_SILENCESTAFF:
DoUseAttackStaff(unit, ListSilenceTargets);
break;
case IID_SLEEPSTAFF:
DoUseAttackStaff(unit, ListSleepTargets);
break;
case IID_BERSERKSTAFF:
DoUseAttackStaff(unit, ListBerserkTargets);
break;
case IID_BARRIERSTAFF:
DoUseBarrierStaff(unit);
break;
case IID_UNLOCKSTAFF:
DoUseUnlockStaff(unit, ListUnlockTargets);
break;
case IID_WARPSTAFF:
DoUseWarpStaff(unit);
break;
case IID_HAMMERNESTAFF:
DoUseRepairStaff(unit);
break;
case IID_FORTIFYSTAFF:
case IID_TORCHSTAFF:
case IID_SAINTSSTAFF:
SetStaffUseAction(unit);
break;
default:
SetItemUseAction(unit);
break;
}
}
static bool HasSelectTarget(struct Unit * unit, void (* list_targets)(struct Unit *))
{
list_targets(unit);
return CountTargets() != 0;
}
bool CanUnitUseHealItem(struct Unit * unit)
{
if (GetUnitCurrentHp(unit) == GetUnitMaxHp(unit))
return FALSE;
return TRUE;
}
bool CanUnitUseBindingBladeToHeal(struct Unit * unit)
{
if (!CanUnitUseWeapon(unit, IID_BINDINGBLADE))
return FALSE;
return CanUnitUseHealItem(unit);
}
bool CanUnitUsePureWaterItem(struct Unit * unit)
{
if (unit->barrier == 7)
return FALSE;
return TRUE;
}
bool CanUnitUseTorchItem(struct Unit * unit)
{
if (gPlaySt.vision != 0 && unit->torch != 4)
return TRUE;
return FALSE;
}
bool CanUnitUseAntitoxinItem(struct Unit * unit)
{
if (unit->status != UNIT_STATUS_POISON)
return FALSE;
return TRUE;
}
bool CanUnitUseChestKeyItem(struct Unit * unit)
{
if (gMapTerrain[unit->y][unit->x] != TERRAIN_CHEST)
return FALSE;
if (!CheckAvailableChestTileEvent(unit->x, unit->y))
return FALSE;
return TRUE;
}
bool CanUnitUseDoorKeyItem(struct Unit * unit)
{
ListOpenTerrainTargets(unit, TERRAIN_DOOR);
return CountTargets();
}
bool CanUnitUseBridgeKeyItem(struct Unit * unit)
{
ListOpenTerrainTargets(unit, TERRAIN_DRAWBRIDGE);
return CountTargets();
}
bool CanUnitUseLockpickItem(struct Unit * unit)
{
if (!(UNIT_ATTRIBUTES(unit) & UNIT_ATTR_STEAL))
return FALSE;
if (!CanUnitUseChestKeyItem(unit) && !CanUnitUseDoorKeyItem(unit) && !CanUnitUseBridgeKeyItem(unit))
return FALSE;
return TRUE;
}
bool CanUnitUsePromotionItem(struct Unit * unit, int item)
{
u8 const * jlist = NULL;
if (unit->level < 10)
return FALSE;
switch (GetItemIid(item))
{
case IID_HEROCREST:
jlist = JList_HeroCrestPromotes;
break;
case IID_KNIGHTCREST:
jlist = JList_KnightCrestPromotes;
break;
case IID_ORIONSBOLT:
jlist = JList_OrionBoltPromotes;
break;
case IID_ELYSIANWHIP:
jlist = JList_ElysianWhipPromotes;
break;
case IID_GUIDINGRING:
jlist = JList_GuidingRingPromotes;
break;
}
while (*jlist)
{
if (unit->jinfo->id == *jlist)
return TRUE;
jlist++;
}
return FALSE;
}
bool CanUnitUseStatGainItem(struct Unit * unit, int item)
{
bool result;
struct ItemBonuses const * bonuses = GetItemBonuses(item);
ClearUnit(&gStatGainSimUnit);
gStatGainSimUnit.pinfo = unit->pinfo;
gStatGainSimUnit.jinfo = unit->jinfo;
gStatGainSimUnit.max_hp = unit->max_hp + bonuses->hp;
gStatGainSimUnit.pow = unit->pow + bonuses->pow;
gStatGainSimUnit.skl = unit->skl + bonuses->skl;
gStatGainSimUnit.spd = unit->spd + bonuses->spd;
gStatGainSimUnit.def = unit->def + bonuses->def;
gStatGainSimUnit.res = unit->res + bonuses->res;
gStatGainSimUnit.lck = unit->lck + bonuses->lck;
gStatGainSimUnit.bonus_mov = unit->bonus_mov + bonuses->mov;
gStatGainSimUnit.bonus_con = unit->bonus_con + bonuses->con;
UnitCheckStatOverflow(&gStatGainSimUnit);
result = gStatGainSimUnit.max_hp != unit->max_hp;
if (gStatGainSimUnit.pow != unit->pow)
result = TRUE;
if (gStatGainSimUnit.skl != unit->skl)
result = TRUE;
if (gStatGainSimUnit.spd != unit->spd)
result = TRUE;
if (gStatGainSimUnit.def != unit->def)
result = TRUE;
if (gStatGainSimUnit.res != unit->res)
result = TRUE;
if (gStatGainSimUnit.lck != unit->lck)
result = TRUE;
if (gStatGainSimUnit.bonus_mov != unit->bonus_mov)
result = TRUE;
if (gStatGainSimUnit.bonus_con != unit->bonus_con)
result = TRUE;
return result;
}
static void SetStaffUseAction(struct Unit * unit)
{
EndLimitView();
TmFill(gBg2Tm, 0);
EnableBgSync(BG2_SYNC_BIT);
gAction.id = ACTION_STAFF;
}
static void SetItemUseAction(struct Unit * unit)
{
gAction.id = ACTION_USEITEM;
}
fu8 StaffMapSelect_Select(struct MapSelectProc * proc, struct SelectTarget * target)
{
gAction.target = target->uid;
SetStaffUseAction(NULL);
return MENU_ACTION_NOCURSOR | MENU_ACTION_END | MENU_ACTION_SE_6A | MENU_ACTION_CLEAR;
}
void DoUseRescueStaff(struct Unit * unit, void (* list_targets)(struct Unit * unit))
{
list_targets(unit);
MapFill(gMapMovement, -1);
StartSubtitleHelp(
StartMapSelectExt(&MapSelectInfo_WarpUnit, StaffMapSelect_Select),
DecodeMsg(MSG_C2A));
}
static void WarpSelect_Init(struct GenericProc * proc)
{
struct SpriteAnim * anim;
StartSubtitleHelp(proc, DecodeMsg(MSG_C24));
CameraMoveWatchPosition(proc,
GetUnit(gAction.target)->x,
GetUnit(gAction.target)->y);
EndLimitView();
BuildWarpDestinationMap(gActiveUnit, GetUnit(gAction.target));
gBmSt.flags &= ~BM_FLAG_LIMITCURSOR;
StartLimitView(1);
SetMapCursorPosition(
GetUnit(gAction.target)->x,
GetUnit(gAction.target)->y);
anim = StartSpriteAnim(SpriteAnim_08102450, 0);
anim->oam2 = OAM2_CHR(0) + OAM2_PAL(0);
SetSpriteAnimId(anim, 0);
proc->ptr = anim;
proc->unk4A = 2; // neither TRUE nor FALSE
}
static void WarpSelect_Loop(struct GenericProc * proc)
{
bool warpAllowed = gMapMovementSigned[gBmSt.cursor.y][gBmSt.cursor.x] != -1;
HandlePlayerMapCursor();
if (gKeySt->pressed & KEY_BUTTON_A)
{
if (warpAllowed)
{
Proc_Break(proc);
gAction.x_target = gBmSt.cursor.x;
gAction.y_target = gBmSt.cursor.y;
SetStaffUseAction(gActiveUnit);
TmFill(gBg2Tm, 0);
EnableBgSync(BG2_SYNC_BIT);
PlaySe(SONG_6A);
return;
}
else
{
PlaySe(SONG_6C);
}
}
if (gKeySt->pressed & KEY_BUTTON_B)
{
Proc_Goto(proc, 99);
TmFill(gBg2Tm, 0);
EnableBgSync(BG2_SYNC_BIT);
PlaySe(SONG_6B);
}
if (warpAllowed != proc->unk4A)
{
SetSpriteAnimId(proc->ptr, warpAllowed ? 0 : 1);
}
DisplaySpriteAnim(proc->ptr,
gBmSt.cursor_sprite.x - gBmSt.camera.x,
gBmSt.cursor_sprite.y - gBmSt.camera.y);
proc->unk4A = warpAllowed;
}
static void WarpSelect_HandleConfirm(struct GenericProc * proc)
{
ResetTextFont();
EndLimitView();
EndSubtitleHelp();
SetMapCursorPosition(
gActiveUnit->x,
gActiveUnit->y);
CameraMoveWatchPosition(proc,
gActiveUnit->x,
gActiveUnit->y);
}
static void WarpSelect_HandleCancel(struct GenericProc * proc)
{
ResetTextFont();
EndLimitView();
EndSubtitleHelp();
SetMapCursorPosition(
gActiveUnit->x,
gActiveUnit->y);
SpawnProc(ProcScr_BackToUnitMenu, PROC_TREE_3);
}
static void WarpSelect_End(struct GenericProc * proc)
{
EndLimitView();
EndSpriteAnim(proc->ptr);
}
fu8 WarpMapSelect_Select(struct MapSelectProc * proc, struct SelectTarget * target)
{
EndMapSelect(proc);
gAction.target = target->uid;
SpawnProc(ProcScr_SquareSelectWarp, PROC_TREE_3);
return MENU_ACTION_SE_6A;
}
void DoUseWarpStaff(struct Unit * unit)
{
ListWarpTargets(unit);
MapFill(gMapMovement, -1);
StartSubtitleHelp(
StartMapSelectExt(&MapSelectInfo_WarpUnit, WarpMapSelect_Select),
DecodeMsg(MSG_C29));
PlaySe(SONG_6A);
}
fu8 UnlockMapSelect_Select(struct MapSelectProc * proc, struct SelectTarget * target)
{
gAction.x_target = target->x;
gAction.y_target = target->y;
SetStaffUseAction(NULL);
return MENU_ACTION_NOCURSOR | MENU_ACTION_END | MENU_ACTION_SE_6A | MENU_ACTION_CLEAR;
}
void DoUseUnlockStaff(struct Unit * unit, void (* list_targets)(struct Unit * unit))
{
list_targets(unit);
MapFill(gMapMovement, -1);
StartSubtitleHelp(
StartMapSelectExt(&MapSelectInfo_Unlock, UnlockMapSelect_Select),
DecodeMsg(MSG_C2E));
PlaySe(SONG_6A);
}
fu8 RepairMapSelect_Select(struct MapSelectProc * proc, struct SelectTarget * target)
{
ResetTextFont();
gAction.target = target->uid;
StartEquipInfoWindow(
StartMenu(&MenuInfo_RepairItem),
GetUnit(gAction.target),
16, 11);
StartFace(0, GetUnitFid(GetUnit(gAction.target)), 184, 12, 2);
return MENU_ACTION_NOCURSOR | MENU_ACTION_END | MENU_ACTION_SE_6A | MENU_ACTION_CLEAR;
}
void DoUseRepairStaff(struct Unit * unit)
{
ListRepairTargets(unit);
MapFill(gMapMovement, -1);
StartSubtitleHelp(
StartMapSelect(&MapSelectInfo_Repair),
DecodeMsg(MSG_C2C));
PlaySe(SONG_6A);
}
fu8 RepairMapSelect_SwitchIn(struct MapSelectProc * proc, struct SelectTarget * target)
{
MakeActiveMuWatchPosition(target->x, target->y);
RefreshUnitRepairInventoryPanel(GetUnit(target->uid));
}
void RepairMapSelect_Init(struct MapSelectProc * proc)
{
StartUnitInventoryPanel(proc);
}
fu8 RepairItemMenu_Entry_SwitchIn(struct MenuProc * menu, struct MenuEntProc * ent)
{
UpdateEquipInfoWindow(ent->id);
}
fu8 RepairItemMenu_Entry_SwitchOut(struct MenuProc * menu, struct MenuEntProc * ent)
{
}
fu8 RepairItemMenu_Entry_Available(struct MenuEntInfo const * info, int id)
{
int item = GetUnit(gAction.target)->items[id];
if (!item)
return MENU_ENTRY_HIDDEN;
if (!IsItemRepairable(item))
return MENU_ENTRY_DISABLED;
return MENU_ENTRY_ENABLED;
}
u32 RepairItemMenu_Entry_Display(struct MenuProc * menu, struct MenuEntProc * ent)
{
int item = GetUnit(gAction.target)->items[ent->id];
int isRepairable = IsItemRepairable(item);
func_fe6_08016720(&ent->text, item, isRepairable, gBg0Tm + TM_OFFSET(ent->x, ent->y));
EnableBgSync(BG0_SYNC_BIT);
return 0;
}
fu8 RepairItemMenu_Entry_Select(struct MenuProc * menu, struct MenuEntProc * ent)
{
if (ent->availability == MENU_ENTRY_DISABLED)
{
int msg, item = GetUnit(gAction.target)->items[ent->id];
if (GetItemAttributes(item) & (ITEM_ATTR_UNBREAKABLE | ITEM_ATTR_UNREPAIRABLE | ITEM_ATTR_LOCK_DRAGON))
msg = MSG_C45;
else if (!(GetItemAttributes(item) & (ITEM_ATTR_WEAPON | ITEM_ATTR_STAFF)))
msg = MSG_C3A;
else if (GetItemUses(item) == GetItemMaxUses(item))
msg = MSG_C39;
if (msg != 0)
MenuFrozenHelpBox(menu, msg);
return MENU_ACTION_SE_6B;
}
gAction.extra = ent->id;
SetStaffUseAction(gActiveUnit);
return MENU_ACTION_NOCURSOR | MENU_ACTION_END | MENU_ACTION_SE_6A | MENU_ACTION_CLEAR | MENU_ACTION_ENDFACE;
}
void DoUseHealStaff(struct Unit * unit, void (* list_targets)(struct Unit * unit))
{
list_targets(unit);
MapFill(gMapMovement, -1);
StartSubtitleHelp(
StartMapSelect(&MapSelectInfo_Heal),
DecodeMsg(MSG_C28));
}
void DoUseRestoreStaff(struct Unit * unit, void (* list_targets)(struct Unit * unit))
{
list_targets(unit);
MapFill(gMapMovement, -1);
StartSubtitleHelp(
StartMapSelect(&MapSelectInfo_Restore),
DecodeMsg(MSG_C2B));
}
int RestoreMapSelect_Init(struct MapSelectProc * proc)
{
StartUnitHpStatusPanel(proc);
}
fu8 RestoreMapSelect_SwitchIn(struct MapSelectProc * proc, struct SelectTarget * target)
{
MakeActiveMuWatchPosition(target->x, target->y);
RefreshUnitHpStatusPanel(GetUnit(target->uid));
}
void DoUseBarrierStaff(struct Unit * unit)
{
ListBarrierTargets(unit);
MapFill(gMapMovement, -1);
StartSubtitleHelp(
StartMapSelect(&MapSelectInfo_Barrier),
DecodeMsg(MSG_C2D));
}
int BarrierMapSelect_Init(struct MapSelectProc * proc)
{
StartUnitResChangePanel(proc);
}
fu8 BarrierMapSelect_SwitchIn(struct MapSelectProc * proc, struct SelectTarget * target)
{
MakeActiveMuWatchPosition(target->x, target->y);
RefreshUnitResChangePanel(GetUnit(target->uid));
}
void DoUseAttackStaff(struct Unit * unit, void (* list_targets)(struct Unit * unit))
{
list_targets(unit);
MapFill(gMapMovement, -1);
StartSubtitleHelp(
StartMapSelect(&MapSelectInfo_AttackStaff),
DecodeMsg(MSG_C2F));
}
int AttackStaffMapSelect_Init(struct MapSelectProc * proc, struct SelectTarget * target)
{
StartUnitStaffOffensePanel(proc);
}
fu8 AttackStaffMapSelect_SwitchIn(struct MapSelectProc * proc, struct SelectTarget * target)
{
MakeActiveMuWatchPosition(target->x, target->y);
RefreshUnitStaffOffensePanel(
GetUnit(target->uid),
GetOffensiveStaffAccuracy(gActiveUnit, GetUnit(target->uid)));
}
void SubtitleMapSelect_End(struct MapSelectProc * proc)
{
EndSubtitleHelp();
ClearUi();
}