DCDecomp
A decompilation of Dark Cloud for the PlayStation 2
Loading...
Searching...
No Matches
btitem.cpp
1#pragma name_counter 2
2#pragma literal_reload 0x3ECCCCCD, 0x3FA66666
3
4#include "common.h"
5
6#include <libvu0.h>
7
8#include "btactstatus.hpp"
9#include "btitem.hpp"
10#include "btmisc.hpp"
11#include "character.hpp"
12#include "clsmes.hpp"
13#include "dataalloc.hpp"
14#include "dataread.hpp"
15#include "dngmessageman.hpp"
16#include "dngstatusdata.hpp"
17#include "dun/gameloop.hpp"
18#include "frame.hpp"
19#include "framevu1.hpp"
20#include "gamepad.hpp"
21#include "menu_draw.hpp"
22#include "menu_dungeon.hpp"
23#include "menu_save.hpp"
24#include "nowload.hpp"
25#include "snd.hpp"
26#include "sysmes.hpp"
27#include "userstatus.hpp"
28
29/* Battle item handling: treasure boxes, pickups and thrown items. */
30
31#include <cstdio>
32#include <cstring>
33
34#include "btmisc.hpp"
35#include "camerafollow.hpp"
36#include "collision.hpp"
37#include "dispctrl.hpp"
38#include "dungeonmap.hpp"
39#include "dungeonparts.hpp"
40#include "edit.hpp"
41#include "editloop3.hpp"
42#include "mainitemmodel.hpp"
43#include "mathutil.hpp"
44#include "mds.hpp"
45#include "monstorunit.hpp"
46#include "motionmodel.hpp"
47#include "savedata.hpp"
48#include "texture.hpp"
49#include "vector.hpp"
50#include "weaponeffect.hpp"
51
53static 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};
54
55// clang-format off
56char *charaNameTbl[6] = {
57 "dun/mainchara/c01d.chr", "dun/mainchara/c04b.chr", "dun/mainchara/c06b.chr",
58 "dun/mainchara/c05a.chr", "dun/mainchara/c10b.chr", "dun/mainchara/c18a.chr",
59};
60// clang-format on
61
62int BtGetTreasurebox_Sled;
63int BtGetAtraBoll_Sled;
64int TreasureboxBig_itemNo;
65int TreasureboxBig_itemType;
66float TreasureboxBig_itemScale;
67int BtGetTreasureboxSmall_itemNo;
68int BtGetTreasureboxSmall_itemVolume;
69int BtAtraGetID;
70int BtAtraGetNo;
71int BtMiniChrSelecter_Sled;
72int BtMiniChrSel_Type;
73int BtMiniChrSelectNo;
74
78int createAttachVolume(int item_no, int dungeon);
79
80void selectChrUnit(int chara_no, int reload) {
81 char weapon0_name[64];
82 char weapon1_name[64];
83 char weapon2_name[64];
84 char path[64];
85 char effect_path[64];
86 int size;
87
88 printf("%d -> %d\n", UserStatus->cur_chara, chara_no);
89
90 if (chara_no == UserStatus->cur_chara && reload == 0) {
91 return;
92 }
93
94 UserStatus->cur_chara = chara_no;
95 LoadFile(charaNameTbl[chara_no], read_buffer, &size);
96 wait_now_loading_vsync();
97 size = (u_int) (((size >> 6) + 1) << 6) >> 2;
98 u_int *weapon0 = &read_buffer[size];
99 int default_weapon = defWeapon[chara_no];
100 BtGetWeaponNamePath3(weapon0_name, path, default_weapon);
101 BtGetWeaponNamePath3(weapon1_name, path, defWeapon[chara_no] + 1);
102 BtGetWeaponNamePath3(weapon2_name, path, UserStatus->chara_weapons[chara_no][UserStatus->equipped_weapon_slot[chara_no]].item_no);
103 sprintf(path, "commenu/weapon/%s", weapon0_name);
104 LoadFile(path, weapon0, &size);
105 u_int *weapon1 = &weapon0[(u_int) (((size >> 6) + 1) << 6) >> 2];
106 sprintf(path, "commenu/weapon/%s", weapon1_name);
107 LoadFile(path, weapon1, NULL);
108 u_int *weapon2 = &weapon1[(u_int) (((size >> 6) + 1) << 6) >> 2];
109 sprintf(path, "commenu/weapon/%s", weapon2_name);
110 LoadFile(path, weapon2, NULL);
111 wait_now_loading_vsync();
112 LoadChara2(chara_no, 0, read_buffer, weapon0, weapon1, weapon2);
113 SetWeaponAttachStatus(NowWeaponHave);
114 BT_SHOT_EFFECT *effect = Get_Main_EffectPtr(chara_no, NowWeaponHave->best_elem);
115 sprintf(effect_path, "dun/mainchara/wep_eff/%s.chr", (char *) effect);
116 printf("[%d] %s\n", chara_no, effect_path);
117 LoadFile(effect_path, read_buffer, &size);
118 wait_now_loading_vsync();
119 printf("fsize = %d\n", size);
120 MainChara_Effect(effect, read_buffer, 0);
121 CWeaponFx.InitSet(NowWeapon->frame, "dcol0", "dcol1");
122 SetWeaponColor();
123 SndVoiceLoad(UserStatus->cur_chara);
124 unsigned int *buffer = read_buffer;
125 LoadFileMenuData("itemlst.img", buffer);
126 wait_now_loading_vsync();
127 SetTempTexture(0x28, (char *) read_buffer);
128 BtItemListCashFlag = 1;
129 nowUnitNow = UserStatus->cur_chara;
130
131 if (UserStatus->CheckLife() == 0) {
132 CUserStatus *user = UserStatus;
133 int cur_chara = user->cur_chara;
134 user->hp[cur_chara] = 1;
135 }
136}
137
145void LoadActiveItemIcon() {
146 unsigned int *buffer = read_buffer;
147 LoadFileMenuData("itemlst.img", buffer);
148 wait_now_loading_vsync();
149 SetTempTexture(0x28, (char *) read_buffer);
150 BtItemListCashFlag = 1;
151}
152
160void BtGetTreasureboxBig_Init() {
161 u_char *mds;
162 u_char *img;
163 u_char *chr;
164 int item_no = NowDngMap->boxes[NowDngMap->events[iventActive].index].item_no;
165
166 ResetMovePower();
167
168 if (((CDngStatusData *) UserStatus)->CheckWeaponRot(item_no) >= 10) {
169 SndSePlay(SE_CHEST_OPEN_BIG, -1, 0);
170 SetSystemMes(((CDngStatusData *) UserStatus)->CheckWeaponUser(item_no) + 0x49, -1, MES_POS_CENTRE, 0, NULL, NULL);
171 int index = NowDngMap->events[iventActive].index;
172 NowDngMap->boxes[index].lid_angle = -20.0f;
173 SetMIniMapStatus(0);
174 iventInfo = DNG_EVENT_NONE;
175 CMonUnitHold = 1;
176 CMonUnitHyde = 1;
177 CEffectHold = 1;
178 CEffectHyde = 1;
179 DngMessMan.enabled = false;
180
181 CUserStatus *user = UserStatus;
182
183 user->step_disable = 1;
184 BtActStatus.motion_no = 0;
185 BtActStatus.in_presentation = 1;
186 BtGetTreasurebox_Sled = 10;
187 autoCamTrial();
188 return;
189 }
190
191 if (item_no == ITEM_WEAPON_STEVE && PlayerAllItemCheck(ITEM_WEAPON_STEVE) != 0) {
192 item_no = ITEM_WEAPON_BONE_SLINGSHOT;
193 }
194
195 TreasureboxBig_itemType = TREASUREBOX_POSE_DEFAULT;
196
197 if (((CDngStatusData *) UserStatus)->CheckWeaponUser(item_no) == CHARA_XIAO) {
198 TreasureboxBig_itemType = TREASUREBOX_POSE_SLINGSHOT;
199 }
200
201 if (((CDngStatusData *) UserStatus)->CheckWeaponUser(item_no) == CHARA_OSMOND) {
202 TreasureboxBig_itemType = TREASUREBOX_POSE_GUN;
203 }
204
205 if (((CDngStatusData *) UserStatus)->CheckWeaponUser(item_no) == CHARA_RUBY) {
206 TreasureboxBig_itemType = TREASUREBOX_POSE_RING;
207 }
208
209 char *chara_files[6] = {"dun/mainchara/c01d_ex00.chr", "dun/mainchara/c04b_ex00.chr",
210 "dun/mainchara/c06b_ex00.chr", "dun/mainchara/c05a_ex00.chr",
211 "dun/mainchara/c10b_ex00.chr", "dun/mainchara/c18a_ex00.chr"};
212 char model_path[64];
213 char texture_path[64];
214 int size;
215
216 TreasureboxBig_itemNo = item_no;
217 NowDngMap->events[iventActive].kind = DNG_EVENT_NONE;
218 BtGetItemNamePath(model_path, texture_path, item_no);
219 BtCashBuffer.base = (u_char *) read_buffer;
220 BtCashBuffer.limit = 0x445C0;
221 BtCashBuffer.used = 0;
222 StartReadBG();
223 mds = BtCashBuffer.base + BtCashBuffer.used * 16;
224 itemOpenItemMds = (int) mds;
225 LoadFileBG(model_path, (u_long128 *) mds, &size);
226 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
227 img = BtCashBuffer.base + BtCashBuffer.used * 16;
228 itemOpenItemImg = (int) img;
229 LoadFileBG(texture_path, (u_long128 *) img, &size);
230 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
231 chr = BtCashBuffer.base + BtCashBuffer.used * 16;
232 itemOpenItemChr = (u_int *) chr;
233 LoadFileBG(chara_files[UserStatus->cur_chara], (u_long128 *) chr, &size);
234 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
235 SndSPSeLoadBG(2, (u_int *) (BtCashBuffer.base + BtCashBuffer.used * 16), &size);
236 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
237 itemOpenBig.frame->SetRotation(0.0f, 0.0f, 0.0f);
238 DngMessMan.enabled = false;
239
240 CUserStatus *user = UserStatus;
241
242 user->step_disable = 1;
243 BtActStatus.motion_no = 0;
244 BtActStatus.in_presentation = 1;
245 BtGetTreasurebox_Sled = 0;
246 autoCamTrial();
247}
248
256int BtGetTreasureboxBig_Loop() {
257 sceVu0FVECTOR position;
258 sceVu0FVECTOR item_position;
259 int done = 0;
260
261 switch (BtGetTreasurebox_Sled) {
262 case 0:
263 if (SndSPSeSyncBG() == 0 && ReadBGSync() == 0) {
264 SetTempTexture(0x1C, (char *) itemOpenItemImg);
265 itemBoxModel = LoadMDSFile((u_int *) itemOpenItemMds, &BtCashBuffer, 0, NULL, NULL);
266 CharaMain.LoadPackData((u_int *) itemOpenItemChr, "base2.cfg", &BtCashBuffer, &BtCashBuffer);
267 BtActStatus.shadow_visible = false;
268 BtGetTreasurebox_Sled++;
269 }
270
271 autoCamTrial();
272 break;
273 case 1: {
274 SetMIniMapStatus(0);
275 iventInfo = DNG_EVENT_NONE;
276 CMonUnitHold = 1;
277 CMonUnitHyde = 1;
278 CEffectHold = 1;
279 CEffectHyde = 1;
280 int index = NowDngMap->events[iventActive].index;
281 sceVu0CopyVector(position, NowDngMap->boxes[index].pos);
282 NowDngMap->boxes[index].lid_angle = -30.0f;
283 NowDngMap->boxes[index].closed = 0;
284 itemOpenBig.frame->SetPosition(position);
285 itemOpenBigFx.frame->SetPosition(position);
286 itemOpenBigFx.frame->SetRotation(0.0f, 0.0f, 0.0f);
287 sceVu0CopyVector(item_position, position);
288 item_position[0] -= 5.0f;
289 item_position[1] += 13.0f;
290
291 switch (TreasureboxBig_itemType) {
292 case TREASUREBOX_POSE_DEFAULT:
293 itemBoxModel->SetRotation(HALF_PI, 0.0f, HALF_PI);
294 itemBoxModel->SetPosition(item_position);
295 TreasureboxBig_itemScale = 1.0f;
296 break;
297 case TREASUREBOX_POSE_SLINGSHOT:
298 itemBoxModel->SetRotation(-HALF_PI, -HALF_PI, 0.0f);
299 item_position[0] += 3.5f;
300 itemBoxModel->SetPosition(item_position);
301 TreasureboxBig_itemScale = 1.0f;
302 break;
303 case TREASUREBOX_POSE_GUN:
304 itemBoxModel->SetRotation(-HALF_PI, PI_SHORT, 0.0f);
305 item_position[0] += 2.5f;
306 itemBoxModel->SetPosition(item_position);
307 TreasureboxBig_itemScale = 1.0f;
308 break;
309 case TREASUREBOX_POSE_RING:
310 itemBoxModel->SetRotation(0.0f, HALF_PI_SHORT, 0.0f);
311 item_position[0] += 3.5f;
312 itemBoxModel->SetPosition(item_position);
313 TreasureboxBig_itemScale = 2.0f;
314 break;
315 }
316
317 itemBoxModel->SetScale(0.01f, 0.01f, 0.01f);
318 itemWeponScale = 0.1f;
319 CharaMain.SetPosition(position);
320 CharaMain.SetRotation(0.0f, 0.0f, 0.0f);
321 BtActStatus.motion_no = 0x2C;
322 itemOpenBig.motion.unk_78 = 10.0f;
323 itemOpenBigFx.motion.state.time = 10.0f;
324 itemOpenBigFlag = 1;
325 SubCamera = MainCamera__4;
326 NowCamera__3 = &SubCamera;
327 NowCamera__3->FollowOff();
328 autoCamTrial();
329 BtGetTreasurebox_Sled++;
330 break;
331 }
332 case 2: {
333 CCameraFollow *camera = NowCamera__3;
334 setCameraPassData((CFrameVu1 *) itemOpenBigFx.frame, camera, "cam", "int");
335#ifdef PAL
336 float pose_time = CharaMain.GetNowTime();
337
338 if (!(pose_time < 79.0f) && pose_time <= 80.0f) {
339 BtActStatus.motion_no = 0x2D;
340 }
341
342#endif
343 float sound_time = itemOpenBigFx.motion.state.time;
344
345 if (!(sound_time <= 14.0f) && sound_time < 15.0f) {
346 SndSePlay(SE_CHEST_OPEN_BIG, -1, 0);
347 SndSPSePlay(2, -1);
348 }
349
350 float grow_time = itemOpenBigFx.motion.state.time;
351
352 if (!(grow_time <= 50.0f) && grow_time <= 55.0f) {
353 float scale = TreasureboxBig_itemScale / 5.0f * (grow_time - 50.0f);
354 itemWeponScale = scale;
355 itemBoxModel->SetScale(scale, scale, scale);
356 }
357
358 if (!(itemOpenBigFx.motion.state.time < 79.0f)) {
359 itemOpenBigFlag = 2;
360 BtActStatus.motion_no = 0x2D;
361 BtGetTreasurebox_Sled++;
362 ItemGetMes(TreasureboxBig_itemNo, -1, 0x28, 1);
363 }
364
365 break;
366 }
367 case 3: {
368 CCameraFollow *camera = NowCamera__3;
369 setCameraPassData((CFrameVu1 *) itemOpenBigFx.frame, camera, "cam", "int");
370
371 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
372 BtActStatus.shadow_visible = true;
373 TexManager.DeleteTextureBlock(0x1C);
374 TexManager.CleanUpTextureList();
375 ((CDngStatusData *) UserStatus)->GetItem(TreasureboxBig_itemNo, 0);
376 NowCamera__3->FollowOn();
377 sceVu0CopyVector(position, CharaMain.pos);
378 position[2] += 10.0f;
379 CharaMain.SetPosition(position);
380 CharaMain.SetRotation(0.0f, -PI, 0.0f);
381 BtActStatus.motion_no = 0;
382 DngMessMan.enabled = true;
383 UserStatus->step_disable = 0;
384 SetMIniMapStatus(1);
385 CMonUnitHold = 0;
386 CMonUnitHyde = 0;
387 CEffectHold = 0;
388 CEffectHyde = 0;
389 itemOpenBigFlag = 0;
390 BtActStatus.in_presentation = 0;
391 ClearSystemMes();
392 NowCamera__3 = &MainCamera__4;
393 done = 1;
394 }
395
396 break;
397 }
398 case 10:
399 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
400 ClearSystemMes();
401 DngMessMan.enabled = true;
402 UserStatus->step_disable = 0;
403 BtActStatus.in_presentation = 0;
404 NowDngMap->boxes[NowDngMap->events[iventActive].index].lid_angle = 0.0f;
405 SetMIniMapStatus(1);
406 CMonUnitHold = 0;
407 CMonUnitHyde = 0;
408 CEffectHold = 0;
409 CEffectHyde = 0;
410 done = 1;
411 }
412
413 break;
414 }
415
416 return done;
417}
418
426void BtGetTreasureboxSmall_Init(int dungeon) {
427 u_char *mds;
428 u_char *img;
429 u_char *chr;
430 int item_no = NowDngMap->boxes[NowDngMap->events[iventActive].index].item_no;
431
432 ResetMovePower();
433 int refusal = ((CDngStatusData *) UserStatus)->CheckItemGet(item_no);
434
435 if (refusal != 0) {
436 SndSePlay(SE_CHEST_OPEN_SMALL, -1, 0);
437
438 if (refusal == 1) {
439 SetSystemMes(0x48, -1, MES_POS_CENTRE, 0, NULL, NULL);
440 }
441
442 if (refusal == 2) {
443 SetSystemMes(0x51, -1, MES_POS_CENTRE, 0, NULL, NULL);
444 }
445
446 int index = NowDngMap->events[iventActive].index;
447 NowDngMap->boxes[index].lid_angle = -20.0f;
448 SetMIniMapStatus(0);
449 iventInfo = DNG_EVENT_NONE;
450 CMonUnitHold = 1;
451 CMonUnitHyde = 1;
452 CEffectHold = 1;
453 CEffectHyde = 1;
454 DngMessMan.enabled = false;
455
456 CUserStatus *user = UserStatus;
457
458 user->step_disable = 1;
459 BtActStatus.in_presentation = 1;
460 BtActStatus.motion_no = 0;
461 BtGetTreasurebox_Sled = 10;
462 autoCamTrial();
463 return;
464 }
465
466 char *chara_files[6] = {"dun/mainchara/c01d_ex00.chr", "dun/mainchara/c04b_ex00.chr",
467 "dun/mainchara/c06b_ex00.chr", "dun/mainchara/c05a_ex00.chr",
468 "dun/mainchara/c10b_ex00.chr", "dun/mainchara/c18a_ex00.chr"};
469 char model_path[64];
470 char texture_path[64];
471 int size;
472
473 NowDngMap->events[iventActive].kind = DNG_EVENT_NONE;
474
475 if (ITEM_NAME_TBL_NEW[item_no - ITEM_ATTACH_START] == NULL) {
476 item_no = ITEM_ATTACH_PERIDOT;
477 }
478
479 int volume = createAttachVolume(item_no, dungeon);
480 printf("get attach vol = %d\n", volume);
481 BtGetTreasureboxSmall_itemNo = item_no;
482 BtGetTreasureboxSmall_itemVolume = volume;
483 strcpy(model_path, "dun/item/main_data/");
484 strcat(model_path, ITEM_NAME_TBL_NEW[item_no - ITEM_ATTACH_START]);
485 strcpy(texture_path, model_path);
486 strcat(model_path, ".mds");
487 strcat(texture_path, ".img");
488 printf("[%d]%s\n", item_no, model_path);
489 printf("[%d]%s\n", item_no, texture_path);
490 BtCashBuffer.base = (u_char *) read_buffer;
491 BtCashBuffer.limit = 0x445C0;
492 BtCashBuffer.used = 0;
493 StartReadBG();
494 mds = BtCashBuffer.base + BtCashBuffer.used * 16;
495 itemOpenItemMds = (int) mds;
496 LoadFileBG(model_path, (u_long128 *) mds, &size);
497 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
498 img = BtCashBuffer.base + BtCashBuffer.used * 16;
499 itemOpenItemImg = (int) img;
500 LoadFileBG(texture_path, (u_long128 *) img, &size);
501 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
502 chr = BtCashBuffer.base + BtCashBuffer.used * 16;
503 itemOpenItemChr = (u_int *) chr;
504 LoadFileBG(chara_files[UserStatus->cur_chara], (u_long128 *) chr, &size);
505 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
506 SndSPSeLoadBG(2, (u_int *) (BtCashBuffer.base + BtCashBuffer.used * 16), &size);
507 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
508 itemOpenSmall.frame->SetRotation(0.0f, 0.0f, 0.0f);
509 DngMessMan.enabled = false;
510
511 CUserStatus *user = UserStatus;
512
513 user->step_disable = 1;
514 BtActStatus.in_presentation = 1;
515 BtActStatus.motion_no = 0;
516 BtGetTreasurebox_Sled = 0;
517 autoCamTrial();
518}
519
527int BtGetTreasureboxSmall_Loop() {
528 int done = 0;
529
530 switch (BtGetTreasurebox_Sled) {
531 case 0:
532 if (ReadBGSync() == 0) {
533 SndSPSeSyncBG();
534 SetTempTexture(0x1C, (char *) itemOpenItemImg);
535 itemBoxModel = LoadMDSFile((u_int *) itemOpenItemMds, &BtCashBuffer, 0, NULL, NULL);
536 CharaMain.LoadPackData((u_int *) itemOpenItemChr, "base2.cfg", &BtCashBuffer, &BtCashBuffer);
537 BtActStatus.shadow_visible = false;
538 BtGetTreasurebox_Sled++;
539 }
540
541 autoCamTrial();
542 break;
543 case 1: {
544 sceVu0FVECTOR position;
545
546 SetMIniMapStatus(0);
547 iventInfo = DNG_EVENT_NONE;
548 CMonUnitHold = 1;
549 CMonUnitHyde = 1;
550 CEffectHold = 1;
551 CEffectHyde = 1;
552 int index = NowDngMap->events[iventActive].index;
553 sceVu0CopyVector(position, NowDngMap->boxes[index].pos);
554 NowDngMap->boxes[index].lid_angle = -30.0f;
555 NowDngMap->boxes[index].closed = 0;
556 itemOpenSmall.frame->SetPosition(position);
557 itemOpenSmallFx.frame->SetPosition(position);
558 itemOpenSmallFx.frame->SetRotation(0.0f, 0.0f, 0.0f);
559 position[1] += 13.0f;
560 itemBoxModel->SetPosition(position);
561 position[1] -= 13.0f;
562 itemBoxModel->SetScale(0.01f, 0.01f, 0.01f);
563 itemNormalScale = 0.1f;
564 CharaMain.SetPosition(position);
565 CharaMain.SetRotation(0.0f, 0.0f, 0.0f);
566 BtActStatus.motion_no = 0x2A;
567 itemOpenSmall.motion.state.time = 10.0f;
568 itemOpenSmallFx.motion.state.time = 10.0f;
569 itemOpenSmallFlag = 1;
570 SubCamera = MainCamera__4;
571 NowCamera__3 = &SubCamera;
572 NowCamera__3->FollowOff();
573 autoCamTrial();
574 BtGetTreasurebox_Sled++;
575 break;
576 }
577 case 2: {
578 setCameraPassData((CFrameVu1 *) itemOpenSmallFx.frame, NowCamera__3, "cam", "int");
579#ifdef PAL
580 float pose_time = CharaMain.GetNowTime();
581
582 if (!(pose_time < 79.0f) && pose_time <= 80.0f) {
583 BtActStatus.motion_no = 0x2B;
584 }
585
586#endif
587 float sound_time = itemOpenSmallFx.motion.state.time;
588
589 if (!(sound_time <= 19.0f) && sound_time < 20.4f) {
590 SndSePlay(SE_CHEST_OPEN_SMALL, -1, 0);
591 SndSPSePlay(2, -1);
592 }
593
594 float grow_time = itemOpenSmallFx.motion.state.time;
595
596 if (!(grow_time <= 50.0f) && grow_time <= 55.0f) {
597 float scale = 0.2f * (grow_time - 50.0f);
598 itemNormalScale = scale;
599 itemBoxModel->SetScale(scale, scale, scale);
600 }
601
602 if (!(itemOpenSmallFx.motion.state.time < 79.0f)) {
603 BtActStatus.motion_no = 0x2B;
604 itemOpenSmallFlag = 2;
605
606 if (BtGetTreasureboxSmall_itemVolume != 0) {
607 ItemGetMes(BtGetTreasureboxSmall_itemNo, BtGetTreasureboxSmall_itemVolume, 0x28, 1);
608 } else {
609 ItemGetMes(BtGetTreasureboxSmall_itemNo, -1, 0x28, 1);
610 }
611
612 BtGetTreasurebox_Sled++;
613 }
614
615 break;
616 }
617 case 3:
618 setCameraPassData((CFrameVu1 *) itemOpenSmallFx.frame, NowCamera__3, "cam", "int");
619
620 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
621 BtActStatus.shadow_visible = true;
622 TexManager.DeleteTextureBlock(0x1C);
623 TexManager.CleanUpTextureList();
624
625 if ((unsigned int) (BtGetTreasureboxSmall_itemNo - ITEM_MAP) < 2U) {
626 if (BtGetTreasureboxSmall_itemNo == ITEM_MAP) {
627 BtEquipMap = 1;
628 }
629
630 if (BtGetTreasureboxSmall_itemNo == ITEM_MAGICAL_CRYSTAL) {
631 BtEquipMasuisyou = 1;
632 }
633 } else {
634 ((CDngStatusData *) UserStatus)->GetItem(BtGetTreasureboxSmall_itemNo, BtGetTreasureboxSmall_itemVolume);
635 }
636
637 sceVu0FVECTOR position;
638
639 sceVu0CopyVector(position, CharaMain.pos);
640 position[2] += 10.0f;
641 CharaMain.SetPosition(position);
642 CharaMain.SetRotation(0.0f, -PI, 0.0f);
643 ClearSystemMes();
644 BtActStatus.motion_no = 0;
645 DngMessMan.enabled = true;
646 UserStatus->step_disable = 0;
647 BtActStatus.in_presentation = 0;
648 SetMIniMapStatus(1);
649 CMonUnitHold = 0;
650 CMonUnitHyde = 0;
651 CEffectHold = 0;
652 CEffectHyde = 0;
653 itemOpenSmallFlag = 0;
654 NowCamera__3 = &MainCamera__4;
655 done = 1;
656 }
657
658 break;
659 case 10:
660 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
661 ClearSystemMes();
662 DngMessMan.enabled = true;
663 UserStatus->step_disable = 0;
664 BtActStatus.in_presentation = 0;
665 NowDngMap->boxes[NowDngMap->events[iventActive].index].lid_angle = 0.0f;
666 SetMIniMapStatus(1);
667 CMonUnitHold = 0;
668 CMonUnitHyde = 0;
669 CEffectHold = 0;
670 CEffectHyde = 0;
671 done = 1;
672 }
673
674 break;
675 }
676
677 return done;
678}
679
687void BtAtraGetShort_Init() {
688 int size;
689
690 atraShortGetType = 1;
691 BtCashBuffer.base = (u_char *) read_buffer;
692 BtCashBuffer.limit = 0x445C0;
693 BtCashBuffer.used = 0;
694 StartReadBG();
695 LoadFileBG(BtAtraShortCharaFile, (u_long128 *) (itemOpenItemChr = (u_int *) (BtCashBuffer.base + BtCashBuffer.used * 16)), &size);
696 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
697 LoadFileBG(BtAtraShortEffectFile, (u_long128 *) (shortAtraEffectPtr = (u_int *) (BtCashBuffer.base + BtCashBuffer.used * 16)), &size);
698 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
699 SndSPSeLoadBG(1, (u_int *) (BtCashBuffer.base + BtCashBuffer.used * 16), &size);
700 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
701 DngMessMan.enabled = false;
702 ResetMovePower();
703 CUserStatus *status = UserStatus;
704 int one = 1;
705 status->step_disable = one;
706 BtAtraGetNo = iventActive;
707 iventActive = -1;
708 BtGetAtraBoll_Sled = 0;
709 BtActStatus.in_presentation = one;
710}
711
712char BtAtraShortEffectFile[] __attribute__((section(".rodata"))) = "dun/effect/saget.chr";
713
721int BtAtraGetShort_Loop(int map_no, int floor) {
722 sceVu0FVECTOR position;
723 int done = -1;
724
725 switch (BtGetAtraBoll_Sled) {
726 case 0:
727 if (SndSPSeSyncBG() == 0 && ReadBGSync() == 0) {
728 CharaMain.LoadPackData((u_int *) itemOpenItemChr, "base2.cfg", &BtCashBuffer, &BtCashBuffer);
729 BtActStatus.shadow_visible = false;
730 shortAtraEffect.LoadPackData2((u_int *) shortAtraEffectPtr, "info.cfg", &BtCashBuffer, 0x1C, &BtCashBuffer, 0);
731 SetMIniMapStatus(0);
732 iventInfo = DNG_EVENT_NONE;
733 atraGetStatus = 1;
734 CMonUnitHold = 1;
735 CMonUnitHyde = 1;
736 CEffectHold = 1;
737 CEffectHyde = 1;
738 sceVu0CopyVector(atraGetPos, CharaMain.pos);
739 CharaMain.GetRotation(atraGetRot);
740 driveNoInterpolate = 1;
741 int index = NowDngMap->events[BtAtraGetNo].index;
742 shortAtraEffect.SetPosition(NowDngMap->atra[index].pos);
743 shortAtraEffect.SetRotation(0.0f, 0.0f, 0.0f);
744 shortAtraEffect.SetMotion(0, 6);
745 atraGetStatusRate__2 = 0.0f;
746 CDngStatusData *status = (CDngStatusData *) UserStatus;
747 int atra_id = status->atra_registry[map_no][NowDngMap->atra[index].atra_no].id;
748 BtAtraGetID = atra_id;
749 NowDngMap->atra[NowDngMap->events[BtAtraGetNo].index].used = 0;
750 NowDngMap->events[BtAtraGetNo].kind = DNG_EVENT_NONE;
751 getAtraToSaveData(atra_id, NowDngMap->atra[index].atra_no, SaveData, map_no, floor);
752 sceVu0CopyVector(position, NowDngMap->atra[index].pos);
753 CharaMain.SetPosition(position);
754 CharaMain.SetRotation(0.0f, 0.0f, 0.0f);
755 BtActStatus.motion_no = 0x2E;
756 driveNoInterpolate = 1;
757 SubCamera = MainCamera__4;
758 NowCamera__3 = &SubCamera;
759 NowCamera__3->FollowOff();
760 shortAtraEffect.SetMotionCamera(NowCamera__3);
761 BtGetAtraBoll_Sled++;
762 }
763
764 autoCamTrial();
765 break;
766 case 1: {
767#ifdef PAL
768 float pose_time = CharaMain.GetNowTime();
769
770 if (!(pose_time < 129.0f) && pose_time <= 130.0f) {
771 BtActStatus.motion_no = 0x2F;
772 }
773
774#endif
775 if (atraGetStatusRate__2 < 256.0f) {
776 atraGetStatusRate__2 += 2.0f;
777 }
778
779 float sound_time = shortAtraEffect.motion_type.state.time;
780
781 if (!(sound_time < 53.0f) && sound_time < 54.0f) {
782 SndSPSePlay(1, -1);
783 }
784
785 if (!(shortAtraEffect.motion_type.state.time < 129.5f)) {
786 AtraGetMes(map_no, BtAtraGetID, 0x28);
787 atraGetStatus = 2;
788 atraGetMsgBord = 1;
789 atraGetMsgBordRate = 0.0f;
790 BtActStatus.motion_no = 0x2F;
791 BtGetAtraBoll_Sled++;
792 }
793
794 break;
795 }
796 case 2:
797 if (atraGetMsgBordRate < 128.0f) {
798 atraGetMsgBordRate += 4.0f;
799 } else {
800 BtGetAtraBoll_Sled++;
801 }
802
803 break;
804 case 3:
805 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
806 DispFade__3.FadeInit(0.0f);
807 DispFade__3.FadeOutStart(8.0f);
808 BtGetAtraBoll_Sled++;
809 }
810
811 break;
812 case 4:
813 if (DispFade__3.GetRate() == 128.0f) {
814 DispFade__3.FadeInStart(8.0f);
815 autoCamTrial();
816 BtGetAtraBoll_Sled++;
817 }
818
819 break;
820 case 5:
821 BtActStatus.shadow_visible = true;
822 ClearSystemMes();
823 SetMIniMapStatus(1);
824 DngMessMan.enabled = true;
825 atraGetStatus = 0;
826 NowCamera__3 = &MainCamera__4;
827 CharaMain.SetRotation(0.0f, -PI, 0.0f);
828 CMonUnitHold = 0;
829 CMonUnitHyde = 0;
830 CEffectHold = 0;
831 CEffectHyde = 0;
832 atraGetMsgBord = 0;
833 NowCamera__3->SetSpeed(6.0f);
834 NowCamera__3->FollowOn();
835 UserStatus->step_disable = 0;
836 BtActStatus.motion_no = 0;
837 BtActStatus.in_presentation = 0;
838 done = 1;
839 break;
840 }
841
842 return done;
843}
844
852void BtMiniChrSelect_Init(int type) {
853 SetMIniMapStatus(0);
854 DngMessMan.enabled = false;
855 BtMiniChrSelecter_Sled = 0;
856 BtMiniChrSel_Type = type;
857}
858
866int BtMiniChrSelect_Loop() {
867 static int frameWait;
868 int done = 0;
869
870 switch (BtMiniChrSelecter_Sled) {
871 case 0:
872 BtMiniChrSelecter_Sled++;
873 frameWait = 0;
874 driveStepHold = 1;
875 frameCaputer = 1;
876 break;
877 case 1:
878 frameWait++;
879
880 if (frameWait >= 2) {
881 BtMiniChrSelecter_Sled++;
882 }
883
884 break;
885 case 2: {
886 frameCaputer = 0;
887 driveStepHold = 0;
888 int blocks[2] = {0x128, 0xD8};
889 StartQuickChange((u_long128 *) read_buffer, 0x17, blocks, BtMiniChrSel_Type);
890 BtGameModeFlag = BT_GAME_MODE_CHARA_CHANGE;
891 BtMiniChrSelecter_Sled++;
892 autoCamTrial();
893 break;
894 }
895 case 3:
896 SetMIniMapStatus(1);
897 done = 1;
898 DngMessMan.enabled = true;
899 nowUnitNow = UserStatus->cur_chara;
900 ResetStatusInfo();
901 autoCamTrial();
902 break;
903 }
904
905 return done;
906}
907
908int BtMiniItemSelect_Sled;
909int GateKey_itemNo;
910int GateKey_Sled;
911int gateItemFlag;
912int escape_chr;
913int escape_sled;
914
922void BtMiniItemSelect() {
923 SetMIniMapStatus(0);
924 DngMessMan.enabled = false;
925 BtMiniItemSelect_Sled = 0;
926 driveStepHold = 1;
927}
928
936int BtMiniItemSelect_Loop() {
937 int done = 0;
938
939 switch (BtMiniItemSelect_Sled) {
940 case 0:
941 BtMiniItemSelect_Sled++;
942 frameCaputer = 1;
943 break;
944
945 case 1:
946 BtMiniItemSelect_Sled++;
947 break;
948
949 case 2: {
950 frameCaputer = 0;
951 driveStepHold = 0;
952 miniItemSelNo = -1;
953
954 ITEM_PACK *pack = &UserStatus->item_pack;
955
956 InitEventItemSelect(0x18, BtEventInfo.item_select_list, pack, 0xB4, 0xD2, BtEventInfo.item_select_filtered, 0);
957 BtGameModeFlag = BT_GAME_MODE_ITEM_SELECT;
958 BtMiniItemSelect_Sled++;
959 break;
960 }
961
962 case 3:
963 if (BtEventInfo.item_select_result != 0) {
964 ((int *) BtEventInfo.item_select_result)[1] = miniItemSelNo;
965 }
966
967 BtEventInfo.item_select_result = 0;
968 SetMIniMapStatus(1);
969 done = 1;
970 DngMessMan.enabled = done;
971 break;
972 }
973
974 return done;
975}
976
984void BtGetGateKey_Init(int item_no) {
985 char model_path[64];
986 char texture_path[64];
987 u_char *model;
988 u_char *texture;
989 int size;
990
991 GateKey_itemNo = item_no;
992 BtGetItemNamePath(model_path, texture_path, item_no);
993 BtCashBuffer.base = (u_char *) read_buffer;
994 BtCashBuffer.limit = 0x445C0;
995 BtCashBuffer.used = 0;
996 StartReadBG();
997 model = BtCashBuffer.base + BtCashBuffer.used * 16;
998 itemOpenItemMds = (int) model;
999 LoadFileBG(model_path, (u_long128 *) model, &size);
1000 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
1001 texture = BtCashBuffer.base + BtCashBuffer.used * 16;
1002 itemOpenItemImg = (int) texture;
1003 LoadFileBG(texture_path, (u_long128 *) texture, &size);
1004 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
1005 ResetMovePower();
1006 DngMessMan.enabled = false;
1007
1008 CUserStatus *user = UserStatus;
1009
1010 user->step_disable = 1;
1011 BtActStatus.motion_no = 0;
1012 BtActStatus.in_presentation = 1;
1013 GateKey_Sled = 0;
1014 autoCamTrial();
1015}
1016
1024int BtGetGateKey_Loop() {
1025 sceVu0FVECTOR eye;
1026 sceVu0FVECTOR ref;
1027 sceVu0FVECTOR ahead;
1028 int done = 0;
1029
1030 switch (GateKey_Sled) {
1031 case 0:
1032 if (ReadBGSync() == 0) {
1033 SetTempTexture(0x1C, (char *) itemOpenItemImg);
1034 itemBoxModel = LoadMDSFile((u_int *) itemOpenItemMds, &BtCashBuffer, 0, NULL, NULL);
1035 itemBoxModel->SetReference(CharaMain.frame->SearchFrame("item"));
1036 itemBoxModel->SetPosition((0, 0.0f), (0, (0, 0.0f)), (0, (0, 0.0f)));
1037 itemBoxModel->SetRotation(0.0f, 0.0f, 0.0f);
1038 itemBoxModel->SetScale((0, (0, 1.0f)), 1.0f, (0, 1.0f));
1039 gateItemFlag = 1;
1040 GateKey_Sled++;
1041 }
1042
1043 autoCamTrial();
1044 break;
1045 case 1:
1046 SetMIniMapStatus(0);
1047 iventInfo = DNG_EVENT_NONE;
1048 CMonUnitHold = 1;
1049 CMonUnitHyde = 1;
1050 CEffectHold = 1;
1051 CEffectHyde = 1;
1052 BtActStatus.motion_no = 0x22;
1053 SubCamera.FollowOff();
1054 sceVu0CopyVector(ref, CharaMain.pos);
1055 ref[1] += 12.0f;
1056 SubCamera.SetRef(ref);
1057 sceVu0CopyVector(eye, CharaMain.pos);
1058 getCharacterVector(ahead, 0.0f);
1059 sceVu0ScaleVectorXYZ(ahead, ahead, 40.0f);
1060 eye[0] += ahead[0];
1061 eye[1] += 20.0f + ahead[1];
1062 eye[2] += ahead[2];
1063 SubCamera.SetPos(eye);
1064 NowCamera__3 = &SubCamera;
1065 NowCamera__3->Step(-1);
1066 NowCamera__3->FollowOff();
1067 SndSePlay(SE_GATE_KEY_GET, -1, 0);
1068 autoCamTrial();
1069 GateKey_Sled++;
1070 break;
1071 case 2: {
1072 float end = CharaMain.motion_type.motion_info[34].end;
1073 float time = CharaMain.motion_type.state.time;
1074
1075 if (!(time < end - 0.5f) && time <= end) {
1076 ItemGetMes(GateKey_itemNo, -1, 0x28, 1);
1077 BtActStatus.motion_no = 0x23;
1078 GateKey_Sled++;
1079 }
1080
1081 break;
1082 }
1083 case 3:
1084 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
1085 TexManager.DeleteTextureBlock(0x1C);
1086 TexManager.CleanUpTextureList();
1087 DngMessMan.enabled = true;
1088 UserStatus->step_disable = 0;
1089 SetMIniMapStatus(1);
1090 CMonUnitHold = 0;
1091 CMonUnitHyde = 0;
1092 CEffectHold = 0;
1093 CEffectHyde = 0;
1094 gateItemFlag = 0;
1095 BtActStatus.in_presentation = 0;
1096 ClearSystemMes();
1097 NowCamera__3 = &MainCamera__4;
1098 done = 1;
1099 }
1100
1101 break;
1102 }
1103
1104 return done;
1105}
1106
1107void BtGetAttach_Init(int dungeon, int item_no) {
1108 int volume = 0;
1109
1110 if (item_no >= ITEM_ATTACH_START && item_no < ITEM_ATTACH_SLAYER_END) {
1111 volume = createAttachVolume(item_no, dungeon);
1112 }
1113
1114 BtGetTreasureboxSmall_itemNo = item_no;
1115 BtGetTreasureboxSmall_itemVolume = volume;
1116 ((CDngStatusData *) UserStatus)->GetItem(item_no, volume);
1117 ClearSystemMes();
1118 ItemGetMes(BtGetTreasureboxSmall_itemNo, BtGetTreasureboxSmall_itemVolume, 0x78, 0);
1119}
1120
1128int BtGetAttach_Loop() {
1129 int done = 0;
1130
1131 switch (GateKey_Sled) {
1132 case 0:
1133 SetMIniMapStatus(0);
1134 iventInfo = DNG_EVENT_NONE;
1135 CMonUnitHold = 1;
1136 CEffectHold = 1;
1137 ItemGetMes(BtGetTreasureboxSmall_itemNo, BtGetTreasureboxSmall_itemVolume, 0x28, 1);
1138 GateKey_Sled++;
1139 break;
1140
1141 case 1:
1142 if (GamePad.Down(PAD_CIRCLE | PAD_CROSS) != 0) {
1143 DngMessMan.enabled = true;
1144 UserStatus->step_disable = 0;
1145 SetMIniMapStatus(1);
1146 CMonUnitHold = 0;
1147 CEffectHold = 0;
1148 gateItemFlag = 0;
1149 BtActStatus.in_presentation = 0;
1150 ClearSystemMes();
1151 done = 1;
1152 }
1153
1154 break;
1155 }
1156
1157 return done;
1158}
1159
1167void BtEscape_Init() {
1168 u_char *chr;
1169 int size;
1170
1171 BtCashBuffer.base = (u_char *) read_buffer;
1172 BtCashBuffer.limit = 0x445C0;
1173 BtCashBuffer.used = 0;
1174 StartReadBG();
1175 chr = BtCashBuffer.base + BtCashBuffer.used * 16;
1176 escape_chr = (int) chr;
1177 LoadFileBG("dun/effect/escape.chr", (u_long128 *) chr, &size);
1178 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
1179 SndSPSeLoadBG(8, (u_int *) (BtCashBuffer.base + BtCashBuffer.used * 16), &size);
1180 BtCashBuffer.Alloc((((size >> 6) + 1) << 6) >> 4);
1181 DngMessMan.enabled = false;
1182
1183 CUserStatus *user = UserStatus;
1184
1185 user->step_disable = 1;
1186 CMonUnitHold = 1;
1187 CMonUnitHyde = 1;
1188 CEffectHold = 1;
1189 CEffectHyde = 1;
1190 SetMIniMapStatus(0);
1191 iventInfo = DNG_EVENT_NONE;
1192 ResetMovePower();
1193 BtActStatus.motion_no = 0;
1194 BtActStatus.in_presentation = 1;
1195 escape_sled = 0;
1196 autoCamTrial();
1197}
1198
1206int BtEscape_Loop() {
1207 sceVu0FVECTOR position;
1208 sceVu0FVECTOR rotation;
1209 int done = 0;
1210
1211 switch (escape_sled) {
1212 case 0:
1213 if (SndSPSeSyncBG() == 0 && ReadBGSync() == 0) {
1214 EscapeEffect.LoadPackData2((u_int *) escape_chr, BtEffectInfoFile, &BtCashBuffer, 0x1C, &BtCashBuffer, 0);
1215 EscapeEffect.SetMotion(0, 6);
1216 EscapeEffect.motion_type.state.time = 10.0f;
1217 EscapeFlag = 1;
1218 sceVu0CopyVector(position, CharaMain.pos);
1219 CharaMain.GetRotation(rotation);
1220 EscapeEffect.SetPosition(position);
1221 EscapeEffect.SetRotation(rotation);
1222 EdFadeInit();
1223 EdFadeOut(0x78, (0, 0.0f), (0, 0.0f), 0.0f);
1224 SndSPSePlay(8, -1);
1225 escape_sled++;
1226 }
1227
1228 autoCamTrial();
1229 break;
1230 case 1:
1231 if (EdFadeOutCheck() != 0) {
1232 done = 1;
1233 }
1234
1235 autoCamTrial();
1236 break;
1237 }
1238
1239 return done;
1240}
1241
1249void BtSetActiveItemModel(u_int *buffer) {
1250 u_int *texture;
1251 int i;
1252 int size;
1253 ITEM_PACK *pack;
1254 int item_no;
1255 char model_path[64];
1256 char texture_path[64];
1257 int model_size;
1258 int texture_size;
1259 pack = &UserStatus->item_pack;
1260
1261 for (i = 0; i < 3; i++) {
1262 item_no = pack->quick_item_slot[i];
1263
1264 if (item_no == -1) {
1265 continue;
1266 }
1267
1268 BtGetItemNamePath(model_path, texture_path, item_no);
1269 LoadFile(model_path, buffer, &model_size);
1270 wait_now_loading_vsync();
1271 model_size = (u_int) (((model_size >> 6) + 1) << 6) >> 2;
1272 LoadFile(texture_path, &buffer[model_size], &texture_size);
1273 wait_now_loading_vsync();
1274
1275 if (activeItem.model[i + 1] != -1) {
1276 activeItem.models->DeleteModel(activeItem.model[i + 1]);
1277 activeItem.model[i + 1] = -1;
1278 }
1279
1280 size = texture_size;
1281 texture = &buffer[model_size];
1282
1283 if (activeItem.model[i + 1] != -1) {
1284 activeItem.models->DeleteModel(activeItem.model[i + 1]);
1285 }
1286
1287 activeItem.model[i + 1] = activeItem.models->SetCashModel(item_no, buffer, texture, size);
1288 activeItem.model[i + 5] = 0;
1289 activeItem.item[i + 1] = item_no;
1290 }
1291}
1292
1300void ParabolicInitialVector(float *velocity, float *from, float *to, float gravity, float time) {
1301 velocity[0] = (to[0] - from[0]) / time;
1302 velocity[1] = (2.0f * (to[1] - from[1]) - time * (gravity * time)) / (2.0f * time);
1303 velocity[2] = (to[2] - from[2]) / time;
1304 velocity[3] = 1.0f;
1305 float negative_one = -1.0f;
1306 velocity[1] = velocity[1] * negative_one;
1307}
1308
1316void setShotVector(float *velocity, float speed, float angle_y, float angle_x) {
1317 sceVu0FMATRIX rotation;
1318 sceVu0FMATRIX identity;
1319
1320 velocity[0] = 0.0f;
1321 velocity[1] = 0.0f;
1322 velocity[2] = speed;
1323 velocity[3] = 1.0f;
1324 sceVu0UnitMatrix(identity);
1325 sceVu0RotMatrixX(rotation, identity, angle_x);
1326 sceVu0RotMatrixY(rotation, rotation, angle_y);
1327 sceVu0ApplyMatrix(velocity, rotation, velocity);
1328}
1329
1330char no_item_name[] __attribute__((section(".rodata"))) = "";
1331
1332char *ITEM_NAME_TBL_NEW[] = {
1333 "atfire",
1334 "atice",
1335 "atthunde",
1336 "atwind",
1337 "atholy",
1338 no_item_name,
1339 no_item_name,
1340 no_item_name,
1341 no_item_name,
1342 no_item_name,
1343 "atpower",
1344 "atdamage",
1345 "atspeed",
1346 "atmagic",
1347 "juelgnet",
1348 "juelamst",
1349 "juelaqua",
1350 "jueldaia",
1351 "juelemrd",
1352 "juelparl",
1353 "juelruby",
1354 "juelprdt",
1355 "juelsphr",
1356 "juelopal",
1357 "jueltpaz",
1358 "jueltrqu",
1359 "taiyou",
1360 no_item_name,
1361 no_item_name,
1362 no_item_name,
1363 "zatdino",
1364 "zatunded",
1365 "zatsea",
1366 "zatstorn",
1367 "zatplant",
1368 "zatbeast",
1369 "zatsky",
1370 "zatmetal",
1371 "zatmimic",
1372 "zatmaji",
1373 no_item_name,
1374 no_item_name,
1375 no_item_name,
1376 no_item_name,
1377 no_item_name,
1378 no_item_name,
1379 no_item_name,
1380 no_item_name,
1381 no_item_name,
1382 no_item_name,
1383 no_item_name,
1384 "mayokest",
1385 "mayokenr",
1386 "mayokenb",
1387 "mayokedk",
1388 "dounut",
1389 "skanacnd",
1390 "kusamoti",
1391 "majopafe",
1392 "sasorijk",
1393 "ninjncki",
1394 no_item_name,
1395 no_item_name,
1396 no_item_name,
1397 "mizufutu",
1398 "mizuoisi",
1399 "mizugoku",
1400 "pan",
1401 "chicken",
1402 "bin2drnk",
1403 "dokukesi",
1404 "seisui",
1405 "sekken",
1406 "mityheal",
1407 "cheese",
1408 no_item_name,
1409 no_item_name,
1410 no_item_name,
1411 "bakudan",
1412 "ishi",
1413 "masekifi",
1414 "masekiic",
1415 "masekitd",
1416 "masekiwd",
1417 "masekiho",
1418 "isiranbo",
1419 "nebapeac",
1420 "bomnuts",
1421 "dokuring",
1422 "banana",
1423 "konamedu",
1424 "konakata",
1425 "konawarp",
1426 "konakawa",
1427 "konaexit",
1428 "konafuka",
1429 "konarepe",
1430 "konalvup",
1431 "pocket",
1432 "edenfurt",
1433 "takaraky",
1434 "hyoutan",
1435 "konarepe_at",
1436 no_item_name,
1437 "turisao",
1438 "ninzin",
1439 "imodango",
1440 "minon",
1441 "battan",
1442 "puti",
1443 "savesyo",
1444 no_item_name,
1445 "ebi",
1446 no_item_name,
1447 "gkeydran",
1448 "hikaruis",
1449 "gkeymimi",
1450 "akaikimi",
1451 "togecchi",
1452 "candy",
1453 "hook",
1454 "oukenost",
1455 "kayaku",
1456 "tokeisin",
1457 "tongrmrn",
1458 "gkey_ds",
1459 "keytuno",
1460 "mikazuki",
1461 "orgelnej",
1462 "taiysirs",
1463 "tukisirs",
1464 "ticket",
1465 no_item_name,
1466 no_item_name,
1467 no_item_name,
1468 "keyhone",
1469 "keyhige",
1470 "keysenst",
1471 "keyishi",
1472 "handol",
1473 "keysikok",
1474 "fkey_ds",
1475 no_item_name,
1476 "torokoil",
1477 "taiysizk",
1478 "pitisakn",
1479 "kusasakn",
1480 "keyhitug",
1481 "yuukiita",
1482 "patapata",
1483 "key_eye",
1484 no_item_name,
1485 "map",
1486 "masuisyo",
1487 "dorahane",
1488 "keydokut",
1489 "hengemiz",
1490 "worldmap",
1491 "honepend",
1492 "tukifue",
1493 "mahoranp",
1494 "tukinoob",
1495 "kairing",
1496 "sosareij",
1497 "icebig",
1498 "icemid",
1499 "icesml",
1500 "keyhonoo",
1501 "hantmimi",
1502 "kouyaku",
1503 "fundtion",
1504 "haniwa",
1505 "manual",
1506 "pezutama",
1507 no_item_name,
1508};
1509
1510void getCharacterVector(float *vector, float pitch) {
1511 sceVu0FVECTOR forward = {0.0f, 0.0f, 1.0f, 1.0f};
1512 sceVu0FVECTOR rotation;
1513 sceVu0FMATRIX matrix;
1514 sceVu0FMATRIX yaw;
1515 sceVu0FMATRIX tilt;
1516
1517 CharaMain.frame->GetRotation(rotation);
1518 sceVu0UnitMatrix(yaw);
1519 sceVu0RotMatrixY(yaw, yaw, rotation[1]);
1520 sceVu0UnitMatrix(tilt);
1521 sceVu0RotMatrixX(tilt, tilt, pitch);
1522 sceVu0MulMatrix(matrix, yaw, tilt);
1523 sceVu0ApplyMatrix(vector, matrix, forward);
1524}
1525
1533int ItemThrowStep(float *position, float *velocity) {
1534 sceVu0FVECTOR next_position;
1535 sceVu0FVECTOR direction;
1536 sceVu0FVECTOR hit_point;
1537 sceVu0FVECTOR normal;
1538
1539 next_position[0] = position[0] + velocity[0];
1540 next_position[1] = position[1] + velocity[1];
1541 next_position[2] = position[2] + velocity[2];
1542 next_position[3] = 1.0f;
1543 velocity[1] -= 0.12f;
1544 sceVu0Normalize(direction, velocity);
1545
1546 for (int unit_no = 0; unit_no < 16; unit_no++) {
1547 for (int i = 0; i < 16; i++) {
1548 if (NowMonstorUnit->effect[unit_no].timer[i] != 0 && DistVector(NowMonstorUnit->effect[unit_no].position[i], position) <= 1.5f + NowMonstorUnit->effect[unit_no].radius[i]) {
1549 return 2;
1550 }
1551 }
1552 }
1553
1554 WorkBuffer__2->used = 0;
1555 CCPoly *polys = (CCPoly *) WorkBuffer__2->Alloc(2000);
1556 int hit_poly = CheckHit(polys, setCollisionData(NowDngMap, polys, position, 20.0f, 1.5f), position, next_position, hit_point, 1, 4);
1557
1558 if (hit_poly >= 0) {
1559 sceVu0CopyVector(normal, polys[hit_poly].normal);
1560 sceVu0Normalize(normal, normal);
1561 ReflectionPlane(normal, hit_point, position, velocity);
1562 sceVu0CopyVector(position, hit_point);
1563 position[0] += 1.3f * normal[0];
1564 position[1] += 1.3f * normal[1];
1565 position[2] += 1.3f * normal[2];
1566 velocity[0] *= 0.4f;
1567 velocity[1] *= 0.4f;
1568 velocity[2] *= 0.4f;
1569 return 1;
1570 }
1571
1572 sceVu0CopyVector(position, next_position);
1573 return 0;
1574}
CMainItemModel * models
virtual void Step(int steps)
void SetRef(CFrame *parent, float x, float y, float z)
Definition camera.cpp:124
void SetPos(CFrame *parent, float x, float y, float z)
Definition camera.cpp:103
void SetSpeed(float speed)
Definition camera.cpp:222
void SetMotion(int no, int mode, float speed=-1.0f)
CFrame * frame
virtual void LoadPackData2(unsigned int *pack, char *name, CDataAlloc2< 1 > *alloc, int texture_block_no, CDataAlloc2< 1 > *image_alloc, int visual_type)
virtual void LoadPackData(unsigned int *pack, char *name, CDataAlloc2< 1 > *model_alloc, CDataAlloc2< 1 > *texture_alloc)
void SetMotionCamera(CCamera *camera)
tagMOTION_TYPE motion_type
virtual void SetRotation(float x, float y, float z)
float GetNowTime()
virtual void SetPosition(float x, float y, float z)
void FadeInit(float start_rate)
Definition dispctrl.cpp:251
void FadeOutStart(float fade_speed)
Definition dispctrl.cpp:239
float GetRate()
Definition dispctrl.cpp:256
void FadeInStart(float fade_speed)
Definition dispctrl.cpp:245
TREASURE_BOX boxes[24]
ATRA_BOLL atra[8]
DUNGEON_EVENT events[48]
int Down(int mask)
Definition gamepad.cpp:583
void DeleteModel(int model_no)
int SetCashModel(int item_no, unsigned int *model_data, unsigned int *texture_data, int texture_size)
MONSTOR_EFFECT_STATE effect[16]
tagMOTION_TYPE motion
CFrame * frame
virtual void GetRotation(float *out_rotation)
Definition object.cpp:116
float pos[4]
Definition object.hpp:18
ITEM_PACK item_pack
WEAPON_HAVE chara_weapons[6][11]
s8 equipped_weapon_slot[6]
ATRA_SAVE atra_registry[6][100]
void InitSet(CFrame *frame, char *root_name, char *tip_name)
CDataAlloc2< 1 > * WorkBuffer__2
Definition dataread.hpp:250
@ DNG_EVENT_NONE
float pos[4]
s32 item_select_list[16]
Definition gameloop.hpp:146
s32 item_select_result
Definition gameloop.hpp:148
s32 item_select_filtered
Definition gameloop.hpp:147
s16 quick_item_slot[3]
sceVu0FVECTOR position[16]
sceVu0FVECTOR pos
MOTION_INFO * motion_info
Definition gameutil.hpp:275
MOTION_STATE state
Definition gameutil.hpp:273