-
Notifications
You must be signed in to change notification settings - Fork 72
/
item.c
2227 lines (1975 loc) · 62.4 KB
/
item.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
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "lb/forward.h"
#include "item.h"
#include "it_266F.h"
#include "it_26B1.h"
#include "math.h"
#include "cm/camera.h"
#include "db/db_2253.h"
#include "ef/efasync.h"
#include "ef/eflib.h"
#include "ft/ftlib.h"
#include "gm/gm_1601.h"
#include "gr/grlib.h"
#include "gr/stage.h"
#include "it/inlines.h"
#include "it/it_2725.h"
#include "it/types.h"
#include "lb/lb_00B0.h"
#include "lb/lb_00F9.h"
#include "lb/lbaudio_ax.h"
#include "mp/mpcoll.h"
#include "mp/mplib.h"
#include <common_structs.h>
#include <dolphin/mtx/vec.h>
#include <dolphin/os/OSError.h>
#include <baselib/class.h>
#include <baselib/debug.h>
#include <baselib/dobj.h>
#include <baselib/gobj.h>
#include <baselib/gobjgxlink.h>
#include <baselib/gobjobject.h>
#include <baselib/gobjplink.h>
#include <baselib/gobjproc.h>
#include <baselib/gobjuserdata.h>
#include <baselib/jobj.h>
/* 267130 */ static void Item_80267130(HSD_GObj* gobj, SpawnItem* spawnItem);
/* 2674AC */ static void Item_802674AC(SpawnItem* spawnItem);
/* 2675A8 */ static void Item_802675A8(HSD_GObj* gobj);
/* 2676F4 */ static void Item_802676F4(HSD_GObj* gobj);
/* 26784C */ static bool Item_8026784C(enum_t dropItem, int);
/* 267AA8 */ static void Item_80267AA8(HSD_GObj* gobj, SpawnItem* spawnItem);
/* 26814C */ static void Item_8026814C(HSD_GObj* gobj);
/* 2682F0 */ static bool Item_802682F0(HSD_GObj* gobj);
/* 268560 */ static void Item_80268560(HSD_GObj* gobj);
/* 26862C */ static HSD_GObj* Item_8026862C(SpawnItem* spawnItem);
/* 268BE0 */ static void Item_80268BE0(HSD_JObj* item_jobj,
HSD_AnimJoint* anim_joint,
HSD_MatAnimJoint* matanim_joint,
HSD_ShapeAnimJoint* shapeanim_joint,
Item* item_data);
/* 269528 */ static void Item_80269528(HSD_GObj* gobj);
/* 2696CC */ static bool Item_802696CC(HSD_GObj* gobj);
/* 269A9C */ static void Item_80269A9C(HSD_GObj* gobj);
/* 269B60 */ static void Item_80269B60(HSD_GObj* gobj);
/* 269BE4 */ static void Item_80269BE4(HSD_GObj* gobj);
/* 269C5C */ static void Item_80269C5C(HSD_GObj* gobj);
/* 269CC4 */ static void Item_80269CC4(HSD_GObj* gobj);
/* 269DC8 */ static bool Item_80269DC8(HSD_GObj* gobj);
/* 269F14 */ static bool Item_80269F14(HSD_GObj* gobj);
/* 26A0A0 */ static void Item_8026A0A0(HSD_GObj* gobj);
/* 26A0FC */ static void Item_8026A0FC(HSD_GObj* gobj);
/* 26A158 */ static void Item_8026A158(HSD_GObj* gobj);
/* 26A1E8 */ static void Item_8026A1E8(HSD_GObj* gobj);
/* 26A294 */ static void Item_8026A294(HSD_GObj* gobj);
/* 26A788 */ static void Item_8026A788(HSD_GObj* gobj);
/* 26A810 */ static void Item_8026A810(HSD_GObj* gobj);
/* 26B0B4 */ static void Item_8026B0B4(HSD_GObj* gobj);
/// Check if items are enabled
bool Item_80266F3C(void)
{
if (gm_8016AE80() != -1) {
return true;
}
return false;
}
/// Check to load ItCo.dat/usd
void Item_80266F70(void)
{
it_8027870C(Item_80266F3C());
}
/// ItCo prefunction with 0
void Item_80266FA8(void)
{
it_8027870C(false);
}
static HSD_ObjAllocData itemAllocData;
static HSD_ObjAllocData unkAllocData1;
HSD_ObjAllocData Item_804A0C38;
HSD_ObjAllocUnk Item_804A0C64;
HSD_ObjAllocUnk2 Item_804A0CCC;
S32Vec3 Item_804A0E24;
/// Init item struct?
void Item_80266FCC(void)
{
HSD_ObjAllocInit(&itemAllocData, sizeof(Item), 4);
HSD_ObjAllocInit(&unkAllocData1, sizeof(DynamicBoneTable), 4);
HSD_ObjAllocInit(&Item_804A0C38, sizeof(ItemLink), 4);
Item_804A0C64.x0 = 0;
Item_804A0C64.x8 = 0;
Item_804A0C64.x10 = 0;
Item_804A0C64.x18 = 0;
Item_804A0C64.x1C = 0;
Item_804A0C64.x24 = 0;
Item_804A0C64.x2C = 0;
Item_804A0C64.x34 = 0;
Item_804A0C64.x3C = 0;
Item_804A0C64.x40 = 0;
Item_804A0C64.x48 = 0;
Item_804A0C64.x50 = 0;
Item_804A0C64.x58 = 0;
Item_804A0C64.x60 = 0;
Item_804A0C64.x4 = it_804D6D28->x0;
Item_804A0C64.xC = it_804D6D28->x4;
Item_804A0C64.x14 = it_804D6D28->x8;
Item_804A0C64.x20 = it_804D6D28->xC;
Item_804A0C64.x28 = it_804D6D28->x10;
Item_804A0C64.x30 = it_804D6D28->x14;
Item_804A0C64.x38 = it_804D6D28->x18;
Item_804A0C64.x44 = it_804D6D28->x1C;
Item_804A0C64.x4C = it_804D6D28->x24;
Item_804A0C64.x54 = it_804D6D28->x20;
Item_804A0C64.x5C = it_804D6D28->x28;
Item_804A0C64.x64 = it_804D6D28->x148;
Item_804A0CCC.x154.b0 = true;
Item_804A0CCC.x150 = 1;
Item_804A0E24.x = -1;
Item_804A0E24.y = -1;
Item_804A0E24.z = 0;
it_804D6D00 = -1;
it_804D6D14 = 1;
it_804D6D10 = 0;
it_804D6D0C = 0;
it_804D6D08 = 0;
it_804A0E60.x8 = 0;
it_804A0E50.x8 = 0;
it_804A0E30.x4.x8 = 0;
it_804A0E60.x0 = 0;
it_804A0E50.x0 = 0;
it_804A0E30.x4.x0 = 0;
}
static void ItUnkHoldKind(HSD_GObj* gobj)
{
Item* it = (Item*) HSD_GObjGetUserData(gobj);
switch (it->hold_kind) {
case 4:
case 5:
case 6:
case 7: {
int temp_r3 = gm_8017E068();
if (temp_r3 >= 0) {
it->xC3C = it_804D6D28->x80_float[temp_r3];
}
}
}
}
static void HSD_JObjSetScaleItem(Item* it, HSD_JObj* jobj, Vec3* scl)
{
scl->x = scl->y = scl->z = it->scl;
HSD_JObjSetScale(jobj, scl);
}
static inline void HSD_JObjSetFacingDirItem(HSD_JObj* jobj, Item* it)
{
if (it->xDC8_word.flags.x19 == true) {
HSD_JObjSetRotationY(jobj, M_PI / 2 * it->facing_dir);
}
}
static void Item_80267130(HSD_GObj* gobj, SpawnItem* spawnItem)
{
Item* item_data = (Item*) HSD_GObjGetUserData(gobj);
HSD_JObj* model = (HSD_JObj*) HSD_GObjGetHSDObj(gobj);
item_data->pos = spawnItem->prev_pos;
item_data->init_facing_dir = item_data->facing_dir = spawnItem->facing_dir;
item_data->owner = spawnItem->x0_parent_gobj;
{
int facing_dir;
if (item_data->facing_dir == -1.0F) {
facing_dir = -1;
} else {
facing_dir = 1;
}
mpColl_800436D8(&item_data->x378_itemColl, facing_dir);
}
HSD_JObjSetFacingDirItem(model, item_data);
it_80273500(gobj, &spawnItem->vel);
item_data->x5CC_currentAnimFrame = 0.0f;
item_data->x5D0_animFrameSpeed = 1.0f;
it_802753BC(gobj, spawnItem->x3C_damage);
it_802753DC(gobj);
item_data->xC64_reflectGObj = NULL;
item_data->xDCC_flag.b0 = false;
item_data->xC90_absorbGObj = NULL;
item_data->xD0C = 0;
it_8026B390(gobj);
item_data->xDC8_word.flags.x13 = false;
if (spawnItem->x48_ground_or_air == GA_Air) {
it_802762BC(item_data);
} else {
it_802762B0(item_data);
}
it_80275E98(gobj, spawnItem);
it_80274DAC(gobj);
HSD_JObjSetTranslate(model, &item_data->pos);
it_80274658(gobj, it_804D6D28->x6C_float);
it_802725D4(gobj);
it_80271508(gobj, 0);
it_80272280(gobj);
item_data->on_accessory = NULL;
item_data->touched = NULL;
item_data->entered_hitlag = NULL;
item_data->exited_hitlag = NULL;
item_data->jumped_on = NULL;
if (item_data->owner != NULL) {
db_80225DD8(gobj, item_data->owner);
} else {
db_80225D64(gobj, item_data->owner);
}
it_8027B0C4(gobj, spawnItem);
it_80279B64(item_data);
ItUnkHoldKind(gobj);
}
/// Remove Camera Box
void Item_80267454(HSD_GObj* gobj)
{
Item* item_data = gobj->user_data;
if (item_data->xDCD_flag.b01 != 0 &&
(item_data->x520_cameraBox != NULL))
{
Camera_800290D4(item_data->x520_cameraBox);
item_data->x520_cameraBox = NULL;
item_data->xDCD_flag.b01 = 0;
}
}
static void Item_802674AC(SpawnItem* spawnItem)
{
ItemKind kind = spawnItem->kind;
if (kind == It_Kind_Foods) {
spawnItem->hold_kind = 2;
return;
}
if (kind == Pokemon_Random) {
spawnItem->hold_kind = 3;
return;
}
if (kind < It_Kind_L_Gun_Ray) {
spawnItem->hold_kind = 0;
return;
}
if (kind < It_Kind_Kuriboh) {
spawnItem->hold_kind = 1;
return;
}
if (kind < It_Kind_Octarock_Stone) {
spawnItem->hold_kind = 6;
return;
}
if (kind < It_Kind_Mario_Fire) {
spawnItem->hold_kind = 7;
return;
}
if (kind < It_Kind_Unk4) {
spawnItem->hold_kind = 8;
return;
}
if (kind == It_Kind_Unk4) {
spawnItem->hold_kind = 12;
return;
}
if (kind < Pokemon_Random) {
spawnItem->hold_kind = 11;
return;
}
if (kind < Pokemon_Chicorita_Leaf) {
spawnItem->hold_kind = 9;
return;
}
if (kind < It_Kind_Old_Kuri) {
spawnItem->hold_kind = 10;
return;
}
if (kind < It_Kind_Arwing_Laser) {
spawnItem->hold_kind = 4;
return;
}
spawnItem->hold_kind = 5;
}
static void Item_802675A8(HSD_GObj* gobj)
{
Item* item_data = gobj->user_data;
switch (item_data->hold_kind) {
case 0:
Item_804A0C64.x0--;
break;
case 1:
Item_804A0C64.x8--;
break;
case 2:
Item_804A0C64.x10--;
break;
case 3:
Item_804A0C64.x58--;
break;
case 4:
Item_804A0C64.x3C--;
break;
case 5:
Item_804A0C64.x40--;
break;
case 6:
Item_804A0C64.x2C--;
break;
case 7:
Item_804A0C64.x34--;
break;
case 8:
Item_804A0C64.x18--;
break;
case 9:
Item_804A0C64.x1C--;
break;
case 10:
Item_804A0C64.x24--;
break;
case 11:
Item_804A0C64.x48--;
break;
case 12:
Item_804A0C64.x50--;
break;
}
if (gm_8018841C() && item_data->x18 == 1) {
Item_804A0C64.x60--;
}
}
static void Item_802676F4(HSD_GObj* gobj)
{
Item* item_data = gobj->user_data;
switch (item_data->hold_kind) {
case 0:
Item_804A0C64.x0++;
if (item_data->kind == 34) {
Item_804A0C64.x1C++;
}
break;
case 1:
Item_804A0C64.x8++;
break;
case 2:
it_80274EE8(Item_804A0C64.x10++);
break;
case 3:
Item_804A0C64.x58++;
break;
case 4:
Item_804A0C64.x3C++;
break;
case 5:
Item_804A0C64.x40++;
break;
case 6:
Item_804A0C64.x2C++;
break;
case 7:
Item_804A0C64.x34++;
break;
case 8:
Item_804A0C64.x18++;
break;
case 10:
Item_804A0C64.x24++;
break;
case 11:
Item_804A0C64.x48++;
break;
case 12:
Item_804A0C64.x50++;
break;
}
if (gm_8018841C() && item_data->x18 == 1) {
Item_804A0C64.x60++;
}
}
static /// @remarks #Item_8026862C loads two integers into this,
/// but the second one goes _?
bool
Item_8026784C(enum_t dropItem, int _)
{
bool result = false;
switch (dropItem) {
case 0:
if (Item_804A0C64.x0 >= Item_804A0C64.x4) {
result = true;
}
break;
case 1:
if (Item_804A0C64.x8 >= Item_804A0C64.xC) {
result = true;
}
break;
case 2:
if (Item_804A0C64.x10 >= Item_804A0C64.x14) {
result = true;
}
break;
case 3:
if (Item_804A0C64.x58 >= Item_804A0C64.x5C) {
result = true;
}
break;
case 5:
if (Item_804A0C64.x40 >= Item_804A0C64.x44) {
result = true;
}
break;
case 7:
if (Item_804A0C64.x34 >= Item_804A0C64.x38) {
result = true;
}
break;
case 9:
if (Item_804A0C64.x1C > Item_804A0C64.x20) {
Item_804A0C64.x1C--;
result = true;
}
break;
case 10:
if (Item_804A0C64.x24 >= Item_804A0C64.x28) {
result = true;
}
break;
case 11:
if (Item_804A0C64.x48 >= Item_804A0C64.x4C) {
result = true;
}
break;
case 12:
if (Item_804A0C64.x50 >= Item_804A0C64.x54) {
result = true;
}
}
return result;
}
void Item_80267978(HSD_GObj* gobj)
{
Item* item_data = gobj->user_data;
if (item_data->kind < It_Kind_Kuriboh) {
// Common items
item_data->xC4_article_data = it_804D6D24[item_data->kind];
item_data->xB8_itemLogicTable = &it_803F14C4[item_data->kind];
} else if (item_data->kind < Pokemon_Tosakinto) {
// Character items
int idx = item_data->kind - It_Kind_Kuriboh;
item_data->xC4_article_data = it_804D6D38[idx];
item_data->xB8_itemLogicTable = &it_803F3100[idx];
} else if (item_data->kind < It_Kind_Old_Kuri) {
// Pokemon
int idx = item_data->kind - Pokemon_Tosakinto;
item_data->xC4_article_data = it_804D6D30[idx];
item_data->xB8_itemLogicTable = &it_803F23CC[idx];
} else {
// Stage items
int idx = item_data->kind - It_Kind_Old_Kuri;
item_data->xC4_article_data = it_804A0F60[idx];
item_data->xB8_itemLogicTable = &it_803F4D20[idx];
if (item_data->xC4_article_data == NULL) {
OSReport("not found zako model data! check ground dat file!\n");
__assert("item.c", 686, "0");
}
}
item_data->xBC_itemStateContainer = item_data->xB8_itemLogicTable->states;
}
static void Item_80267AA8(HSD_GObj* gobj, SpawnItem* spawnItem)
{
ItemAttr* item_attr;
Item* item_data = (Item*) HSD_GObjGetUserData(gobj);
item_data->kind = spawnItem->kind;
item_data->hold_kind = spawnItem->hold_kind;
item_data->x18 = spawnItem->x10;
item_data->x1C = it_804D6D10++;
item_data->entity = gobj;
Item_80267978(gobj);
item_data->msid = -1;
item_data->xC8_joint =
item_data->xC4_article_data->x10_modelDesc->x0_joint;
item_data->xCC_item_attr = item_data->xC4_article_data->x0_common_attr;
item_data->owner = NULL;
item_data->xDC8_word.flags.x0 = 0;
item_data->ecb_lock = -1;
item_data->xDC4 = 0;
item_data->xDC8_word.flags.xF = 0;
item_data->xCC4 = 0;
item_data->xDCF_flag.b6 = 0;
item_data->xDCF_flag.b7 = 0;
item_data->xCB0_source_ply = 6;
item_data->xCB4 = -1;
item_data->xC38 = -1;
item_data->xCE8 = 0.0f;
item_data->xCE4 = 0.0f;
item_data->xCE0 = 0.0f;
item_data->xCDC = 0.0f;
item_data->xCD8 = 0.0f;
item_data->xCD4 = 0.0f;
item_data->xDD0_flag.b1 = 0;
item_data->xDC8_word.flags.x14 = 0;
item_data->xDC8_word.flags.xE = 0;
item_data->xCEC_fighterGObj = NULL;
item_data->xCF0_itemGObj = NULL;
item_data->xCF4_fighterGObjUnk = NULL;
item_data->toucher = NULL;
item_data->xC64_reflectGObj = NULL;
item_data->xCFC = 0;
item_data->atk_victim = 0;
item_data->grab_victim = 0;
item_data->xCCC_incDamageDirection = 0.0f;
item_data->xCB8_outDamageDirection = 0.0f;
item_data->xC68 = 0.0f;
item_data->xCD0 = 0.0f;
it_80275158(gobj, it_804D6D28->x30);
item_data->xDD0_flag.b3 = false;
item_data->spin_spd = item_data->xCC_item_attr->xC_spin_speed;
item_data->xDC8_word.flags.x19 = item_data->xCC_item_attr->x1_3;
item_data->xDC8_word.flags.x17 = item_data->xCC_item_attr->x1_1;
item_attr = item_data->xCC_item_attr;
item_data->xBCC_unk = item_attr->x30_unk;
item_data->xBD4_grabRange = item_attr->x38_grab_range;
item_data->xDC8_word.flags.x1A = item_data->xCC_item_attr->x1_4;
item_attr = item_data->xCC_item_attr;
item_data->xBEC = item_attr->x20;
item_attr = item_data->xCC_item_attr;
item_data->xBDC = item_attr->x20;
item_data->xDC8_word.flags.x1C = 1;
item_data->xDC8_word.flags.x1D = 1;
item_data->xDC8_word.flags.x1E = 1;
item_attr = item_data->xCC_item_attr;
item_data->xC1C = item_attr->x40;
item_data->xC0C = item_data->xC1C;
item_data->xBFC = item_data->xC0C;
item_data->xDC8_word.flags.xC = item_data->xCC_item_attr->x1_5;
item_data->xDC8_word.flags.xD = 1;
item_data->xDCD_flag.b01 = item_data->xCC_item_attr->x1_67_cam_kind;
item_data->xDCE_flag.b3 = 0;
item_data->xD54_throwNum = 0;
item_data->xD50_landNum = 0;
item_data->xD58 = 0;
item_data->xD5C = 2;
item_data->xDCC_flag.b3 = 1;
item_data->xDCC_flag.b4567 = 15;
item_data->xAC4_ignoreItemID = spawnItem->x40;
item_data->destroy_type = 4;
item_data->xDCE_flag.b5 = 0;
item_data->xDCE_flag.b4 = 0;
item_data->xC54 = 0.0f;
item_data->xC58.x = 0.0f;
item_data->xC58.x = 0.0f;
item_data->xC58.x = 0.0f;
item_data->xDC8_word.flags.x9 = 0;
item_data->xDC8_word.flags.x3 = 0;
item_data->xDC8_word.flags.x4 = 0;
item_data->xDC8_word.flags.x5 = 0;
item_data->xDC8_word.flags.x6 = 0;
item_data->xDC8_word.flags.x7 = 0;
item_data->xDC8_word.flags.x8 = 0;
item_data->xDD0_flag.b5 = 0;
item_data->xD09 = (s8) 0;
item_data->xDD0_flag.b4 = 0;
item_data->xCA8 = 0;
item_data->xCBC_hitlagFrames = 0.0f;
item_data->xCC0 = 0.0f;
item_data->xDC8_word.flags.xA = 0;
item_data->xDC8_word.flags.xB = 0;
item_data->xDCC_flag.b1 = 0;
item_data->xC70 = 1.0f;
item_data->xC6C = 1.0f;
item_data->xDCC_flag.b2 = 0;
item_data->xDD0_flag.b0 = false;
item_data->xDCE_flag.b6 = false;
item_data->xDCF_flag.b0 = false;
item_data->xDCF_flag.b1 = false;
item_data->xDCF_flag.b2 = false;
item_data->xDD1_flag.b0 = false;
item_data->xDCE_flag.b7 = 1;
item_data->scl = item_data->xCC_item_attr->x60_scale;
item_data->x3C = 0.0f;
item_data->xDCD_flag.b3 = false;
item_data->xDCD_flag.b4 = false;
item_data->xDD0_flag.b7 = false;
item_data->xBC0 = 0;
item_data->xDD1_flag.b1 = false;
item_data->xDCD_flag.b2 = false;
item_data->xD6C = -1;
item_data->sfx_unk2 = SFX_NONE;
item_data->sfx_unk1 = SFX_NONE;
item_data->xD70 = item_data->xCC_item_attr->x6C;
item_data->xD74 = item_data->xCC_item_attr->x70;
item_data->xD78 = item_data->xCC_item_attr->x74;
item_data->destroy_sfx = item_data->xCC_item_attr->destroy_sfx;
item_data->xD80 = item_data->xCC_item_attr->x7C;
item_attr = item_data->xCC_item_attr;
item_data->xD84 = item_attr->x80;
it_80275474(gobj);
it_80275504(gobj);
it_80274EF8(gobj);
if (ftLib_80086960(spawnItem->x0_parent_gobj)) {
item_data->xDC8_word.flags.x1 = false;
} else {
item_data->xDC8_word.flags.x1 = true;
}
item_data->x5C8 = 0;
item_data->xBC7 = 0;
item_data->xBC6 = 0;
item_data->xBC5 = 0;
item_data->xBC4 = 0;
item_data->x5C9 = 255;
it_80279B64(item_data);
item_data->xDCF_flag.b3 = false;
item_data->xDCF_flag.b4 = false;
item_data->xDCF_flag.b5 = false;
item_data->xDAA_byte = 1;
if (db_80225B20()) {
item_data->xDAA_flag.b4 = true;
}
if (spawnItem->x0_parent_gobj == NULL) {
item_data->x20_team_id = -1;
} else if (ftLib_80086960(spawnItem->x0_parent_gobj)) {
item_data->x20_team_id = ftLib_80086EB4(spawnItem->x0_parent_gobj);
} else if (it_80272D1C(spawnItem->x0_parent_gobj)) {
item_data->x20_team_id = it_8026B7B0(spawnItem->x0_parent_gobj);
} else {
item_data->x20_team_id = -1;
}
}
extern void PSMTXIdentity(Mtx); /* extern */
/// Setup Item JObj
void Item_802680CC(HSD_GObj* gobj)
{
Item* item_data = (Item*) HSD_GObjGetUserData(gobj);
if (item_data->xC8_joint != NULL) {
HSD_JObj* jobj = HSD_JObjLoadJoint(item_data->xC8_joint);
HSD_GObjObject_80390A70(gobj, HSD_GObj_804D7849, jobj);
} else {
HSD_JObj* jobj = HSD_JObjAlloc();
PSMTXIdentity(jobj->mtx);
jobj->scl = NULL;
HSD_GObjObject_80390A70(gobj, HSD_GObj_804D7849, jobj);
}
}
extern HSD_DObj* HSD_JObjGetDObj(HSD_JObj*);
extern void* it_803F1F90[];
static void Item_8026814C(HSD_GObj* gobj)
{
u8 _[8];
HSD_MObj* temp_r0;
HSD_DObj* var_r0;
HSD_JObj* var_r0_2;
HSD_JObj* var_r30;
HSD_DObj* var_r29;
HSD_JObj* var_r3;
var_r30 = (HSD_JObj*) HSD_GObjGetHSDObj(gobj);
while (var_r30 != NULL) {
var_r29 = HSD_JObjGetDObj(var_r30);
loop_2:
if (var_r29 != NULL) {
temp_r0 = var_r29->mobj;
if (temp_r0 != NULL) {
hsdChangeClass(temp_r0, &it_803F1F90);
}
var_r29 = var_r0 = (var_r29 != NULL) ? var_r29->next : NULL;
goto loop_2;
}
if (var_r30 == NULL) {
var_r0_2 = NULL;
} else {
var_r0_2 = var_r30->child;
}
if (var_r0_2 != NULL) {
var_r30 = var_r0_2 = (var_r30 == NULL) ? NULL : var_r30->child;
} else {
var_r0_2 = (var_r30 == NULL) ? NULL : var_r30->next;
if (var_r0_2 != NULL) {
var_r30 = var_r0_2 = (var_r30 == NULL) ? NULL : var_r30->next;
} else {
loop_25:
var_r0_2 = (var_r30 == NULL) ? NULL : var_r30->parent;
if (var_r0_2 == NULL) {
var_r30 = NULL;
} else {
var_r3 = (var_r30 == NULL) ? NULL : var_r30->parent;
var_r0_2 = (var_r3 == NULL) ? NULL : var_r3->next;
if (var_r0_2 != NULL) {
var_r3 = (var_r30 == NULL) ? NULL : var_r30->parent;
var_r30 = var_r0_2 =
(var_r3 == NULL) ? NULL : var_r3->next;
} else {
var_r30 = var_r0_2 =
(var_r30 == NULL) ? NULL : var_r30->parent;
goto loop_25;
}
}
}
}
}
}
static /// @todo Needs some serious cleaning.
bool
Item_802682F0(HSD_GObj* gobj)
{
s32 var_r4;
Item* item_data;
HSD_JObj* var_r0;
HSD_JObj* var_r3;
HSD_JObj* var_r3_2;
HSD_JObj* var_r5;
item_data = (Item*) HSD_GObjGetUserData(gobj);
if (item_data->xC4_article_data->x10_modelDesc->x4_bone_count != 0) {
item_data->xBBC_dynamicBoneTable = HSD_ObjAlloc(&unkAllocData1);
if (item_data->xBBC_dynamicBoneTable == NULL) {
return false;
}
var_r5 = gobj->hsd_obj;
var_r4 = 0;
while (var_r5 != NULL) {
(item_data->xBBC_dynamicBoneTable->bones[var_r4]) = var_r5;
var_r4++;
var_r0 = (var_r5 == NULL) ? NULL : var_r5->child;
if (var_r0 != NULL) {
var_r5 = var_r0 = (var_r5 == NULL) ? NULL : var_r5->child;
} else {
var_r0 = (var_r5 == NULL) ? NULL : var_r5->next;
if (var_r0 != NULL) {
var_r5 = var_r0 = (var_r5 == NULL) ? NULL : var_r5->next;
} else {
loop_20:
var_r0 = (var_r5 == NULL) ? NULL : var_r5->parent;
if (var_r0 == NULL) {
var_r5 = NULL;
} else {
var_r3 = (var_r5 == NULL) ? NULL : var_r5->parent;
var_r0 = (var_r3 == NULL) ? NULL : var_r3->next;
if (var_r0 != NULL) {
var_r3_2 =
(var_r5 == NULL) ? NULL : var_r5->parent;
var_r5 = var_r0 =
(var_r3_2 == NULL) ? NULL : var_r3_2->next;
} else {
var_r5 = var_r0 =
(var_r5 == NULL) ? NULL : var_r5->parent;
goto loop_20;
}
}
}
}
}
} else {
item_data->xBBC_dynamicBoneTable = NULL;
}
return true;
}
/// Set item model scale
void Item_8026849C(HSD_GObj* gobj)
{
HSD_JObj* temp_jobj = (HSD_JObj*) HSD_GObjGetHSDObj(gobj);
Item* item_data = (Item*) HSD_GObjGetUserData(gobj);
f32 tmp = item_data->scl;
Vec3 sp14;
sp14.x = sp14.y = sp14.z = tmp;
HSD_JObjSetScale(temp_jobj, &sp14);
}
static void Item_80268560(HSD_GObj* gobj)
{
int i;
Item* ip = GET_ITEM(gobj);
Article* article_data = ip->xC4_article_data;
if (article_data->x14_dynamics == NULL) {
ip->x374_dynamicBonesNum = 0;
ip->xB68 = 0;
return;
}
ip->x374_dynamicBonesNum = article_data->x14_dynamics->count;
for (i = 0; i < article_data->x14_dynamics->count; i++) {
BoneDynamicsDesc* desc = &article_data->x14_dynamics->dyn_descs[i];
HSD_JObj* jobj = ip->xBBC_dynamicBoneTable->bones[desc->bone_id];
lb_8000FD48(jobj, &ip->xD4_dynamicBones[i].dyn_desc,
desc->dyn_desc.count);
ip->xD4_dynamicBones[i].skeleton = jobj;
ip->xD4_dynamicBones[i].flags = 0;
lb_80011710(&article_data->x14_dynamics->dyn_descs[i].dyn_desc,
&ip->xD4_dynamicBones[i].dyn_desc);
}
}
extern void ftLib_8008702C(s32);
extern struct sdata_ItemGXLink it_803F1418[];
extern struct sdata_ItemGXLink it_803F2310[];
extern struct sdata_ItemGXLink it_803F2F28[];
extern struct sdata_ItemGXLink it_803F4CA8[];
static void foobar(HSD_GObj* gobj)
{
Item* it = (Item*) HSD_GObjGetUserData(gobj);
switch (it->hold_kind) {
case 0:
case 6:
if (it->xD0C == 2) {
it->xDD0_flag.b7 = 1;
}
it->xD40 = it_804D6D28->x2C;
it->xDD0_flag.b6 = 1;
it_802756D0(gobj);
it_80279B88(it, 3, 0);
break;
default:
it->xD40 = 0.0f;
it->xDD0_flag.b6 = 0;
}
}
static void foobar2(HSD_GObj* gobj)
{
Item* it = (Item*) HSD_GObjGetUserData(gobj);
// Check if item is a character item with an owner
if (it->kind >= It_Kind_Mario_Fire && it->kind < It_Kind_Unk4 &&
ftLib_80086960(it->owner))
{
it->xDC8_word.flags.xE = 1;
it->ecb_lock = ftLib_800872A4(it->owner);
ftLib_8008702C(it->ecb_lock);
}
}
static void foobar3(HSD_GObj* gobj)
{
Item* it = (Item*) HSD_GObjGetUserData(gobj);
CameraBox* cam_box;
if (it->xDCD_flag.b01 != 0) {
if (it->xDCD_flag.b01 == 1) {
it->x520_cameraBox = Camera_80029044(0);
} else {
it->x520_cameraBox = Camera_80029044(2);
}
cam_box = it->x520_cameraBox;
if (cam_box != NULL) {
cam_box->x40.x = it_804D6D28->x14C;
cam_box->x40.y = it_804D6D28->x150;
cam_box->x48.x = it_804D6D28->x154;
cam_box->x48.y = it_804D6D28->x158;
}
}
}
static HSD_GObj* Item_8026862C(SpawnItem* spawnItem)
{
HSD_GObj* gobj;
void* user_data;
if (Item_8026784C(spawnItem->hold_kind, spawnItem->kind) != 0) {
return NULL;
}
gobj = GObj_Create(6, 9, 0);
if (gobj == NULL) {
return NULL;
}
if (spawnItem->kind < It_Kind_Kuriboh) {
// Common items
GObj_SetupGXLink(gobj, it_803F1418[spawnItem->kind].x0_renderFunc, 6,
0);
} else if (spawnItem->kind < Pokemon_Tosakinto) {
// Character items
int idx = spawnItem->kind - It_Kind_Kuriboh;
GObj_SetupGXLink(gobj, it_803F2F28[idx].x0_renderFunc, 6, 0);
} else if (spawnItem->kind < It_Kind_Old_Kuri) {
// Pokemon
int idx = spawnItem->kind - Pokemon_Tosakinto;
GObj_SetupGXLink(gobj, it_803F2310[idx].x0_renderFunc, 6, 0);
} else {
// Stage items
int idx = spawnItem->kind - It_Kind_Old_Kuri;
GObj_SetupGXLink(gobj, it_803F4CA8[idx].x0_renderFunc, 6, 0);
}
user_data = HSD_ObjAlloc(&itemAllocData);
if (user_data == NULL) {
HSD_GObjPLink_80390228(gobj);
return NULL;
}
GObj_InitUserData(gobj, 6, Item_OnUserDataRemove, user_data);
Item_80267AA8(gobj, spawnItem);
Item_802680CC(gobj);
if (Item_802682F0(gobj) != false) {
Item_8026814C(gobj);
Item_8026849C(gobj);
it_8027163C(gobj);
Item_80268560(gobj);
HSD_GObjProc_8038FD54(gobj, Item_802693E4, 0);
HSD_GObjProc_8038FD54(gobj, Item_80269528, 1);
HSD_GObjProc_8038FD54(gobj, Item_802697D4, 4);
HSD_GObjProc_8038FD54(gobj, Item_80269978, 5);
HSD_GObjProc_8038FD54(gobj, Item_80269A9C, 9);
HSD_GObjProc_8038FD54(gobj, Item_80269B60, 11);