7#include "btactstatus.hpp"
13#include "collisiondata.hpp"
14#include "dataalloc.hpp"
16#include "dngstatusdata.hpp"
17#include "dun/gameloop.hpp"
18#include "dungeoneventman.hpp"
21#include "editloop.hpp"
22#include "editloop3.hpp"
24#include "itembombeffect.hpp"
26#include "mainselect.hpp"
29#include "menu_dungeon.hpp"
30#include "menu_misc.hpp"
31#include "monstorunit.hpp"
33#include "npcharacter.hpp"
34#include "runscript.hpp"
36#include "shot_freefuncs.hpp"
38#include "userstatus.hpp"
42char BtLoadMapFileName[32];
46void BtSystemScriptEventInfoInit() {
55 BtEventInfo.
request = BT_REQUEST_NONE;
67 for (
int i = 0; i < 6; i++) {
68 NPCUnit[i].
frame = NULL;
71 EdEventInfo.
npcs = NPCUnit;
77 for (
int i = 0; i < 8; i++) {
81 EdEventInfo.
messages[1] = &BtEventMes0;
82 EdEventInfo.
messages[2] = &BtEventMes1;
87 if (index < 0 || index >= 32) {
88 printf(
"** obj hdl err **\n");
92 return &BtObjHdl[index];
95void BtSystemScriptLoad(
int floor) {
103 sprintf(path,
"dun/script/d0%d/event.stb", floor + 1);
104 sprintf(mes_path,
"dun/script/d0%d/d0%d_%d.mes", floor + 1, floor + 1, LanguageCode);
105 BtSystemScriptFileBuffer.
used = 0;
106 BtEventData = (s32) (BtSystemScriptFileBuffer.
base + BtSystemScriptFileBuffer.
used * 0x10);
107 LoadFile(path, (
void *) BtEventData, &read_size);
108 wait_now_loading_vsync();
109 BtSystemScriptFileBuffer.Alloc((read_size >> 4) + 1);
110 mes = (
char *) (BtSystemScriptFileBuffer.
base + BtSystemScriptFileBuffer.
used * 0x10);
111 LoadFile(mes_path, mes, &mes_size);
112 wait_now_loading_vsync();
113 BtSystemScriptFileBuffer.Alloc((mes_size >> 4) + 1);
114 EdSetEventScript((
char *) BtEventData, mes, &BtSystemScriptFileBuffer);
115 AddSystemEventScript();
120 sprintf(path,
"dun/script/d0%d/event.stb", floor + 1);
121 BtSystemScriptFileBuffer.
used = 0;
122 BtEventData = (s32) (BtSystemScriptFileBuffer.
base + BtSystemScriptFileBuffer.
used * 0x10);
123 LoadFile(path, (
void *) BtEventData, &read_size);
124 wait_now_loading_vsync();
125 BtSystemScriptFileBuffer.Alloc((read_size >> 4) + 1);
126 EdSetEventScript((
char *) BtEventData, NULL, &BtSystemScriptFileBuffer);
127 AddSystemEventScript();
131void BtSystemScriptInit() {
138 NowCamera__3->
GetPos(pos);
139 NowCamera__3->
GetRef(ref);
144 NowCamera__3 = &SubCamera;
149 EdEventInfo.
camera = NowCamera__3;
152 for (
int i = 0; i < 6; i++) {
153 NPCUnit[i].
frame = NULL;
156 EdEventInfo.
npcs = NPCUnit;
162 for (
int i = 0; i < 8; i++) {
166 EdEventInfo.
messages[1] = &BtEventMes0;
167 EdEventInfo.
messages[2] = &BtEventMes1;
187 for (
int i = 0; i < 32; i++) {
188 BtObjHdl[i].
frame = NULL;
200 BtActStatus.unk_028 = 0;
203void BtSystemScriptAfter() {
225 sceVu0CopyVector(pos, CharaMain.
pos);
229 if (!(angle <= PI_SHORT)) {
234 MainCamera__4.
SetFollow(pos[0], pos[1] + 16.0f - 3.0f, pos[2]);
235 MainCamera__4.
Step(-1);
242 MainCamera__4.
SetPos(pos);
243 MainCamera__4.
SetRef(ref);
244 MainCamera__4.
Step(-1);
245 MainCamera__4.
Step(1);
247 MainCamera__4.
SetHeight(pos[1] - ref[1]);
248 MainCamera__4.
SetFollow(ref[0], ref[1], ref[2]);
249 MainCamera__4.
SetAngleSoon(atan2(pos[0] - ref[0], pos[2] - ref[2]));
250 MainCamera__4.
Step(-1);
251 MainCamera__4.
Step(1);
254 NowCamera__3 = &MainCamera__4;
258 return EdEventInit(event, arena, (
char *) BtEventData);
261void BtSetMapJumpFloor(
int floor) {
262 BtMapJumpFloor = floor;
274 if (argument->
type == RS_FLOAT) {
275 return (
int) argument->
f;
290 if (argument->
type == RS_INT) {
291 return (
float) argument->
i;
317static void SetStack(
RS_STACKDATA *argument,
int value) {
318 if (argument->
type == RS_PTR) {
319 argument->
p->
i = value;
331static void SetStack(
RS_STACKDATA *argument,
float value) {
332 if (argument->
type == RS_PTR) {
333 argument->
p->
f = value;
358 if (stack->
type != RS_PTR) {
366 for (i = 0; i < argument_count - 1; i++) {
372 if (argument_count > 1) {
377 BtEventInfo.
request = BT_REQUEST_ITEM_WINDOW;
382 int flag_no = GetStackInt(stack++);
384 SetStack(stack, flag);
389 int flag_no = GetStackInt(stack++);
390 int value = GetStackInt(stack);
393 if (flag_no >= 0 && flag_no < 50) {
401 int index = GetStackInt(stack++);
402 int parts_no = GetStackInt(stack++);
403 char *name = GetStackString(stack);
406 if (parts_no != -1) {
411 handle->
frame = frame;
414 printf(
"******** Frame NotFount %s *******\n", name);
415 handle->
frame = NULL;
422 handle->
frame = frame;
425 printf(
"******** All Frame NotFount %s *******\n", name);
426 handle->
frame = NULL;
435 int index = GetStackInt(stack++);
436 float x = GetStackFloat(stack++);
437 float y = GetStackFloat(stack++);
438 float z = GetStackFloat(stack);
441 if (handle->
type == 0 && handle->
frame != NULL) {
442 handle->
frame->SetPosition(x, y, z);
453 int index = GetStackInt(stack++);
454 float x = GetStackFloat(stack++);
455 float y = GetStackFloat(stack++);
456 float z = GetStackFloat(stack);
459 if (handle->
type == 0) {
463 frame->SetRotType(2);
464 frame->SetRotation(AngleLimit(x), AngleLimit(y), AngleLimit(z));
468 if (handle->
type == 1) {
472 chara->
SetRotation(AngleLimit(x), AngleLimit(y), AngleLimit(z));
480 int index = GetStackInt(stack++);
481 int draw = GetStackInt(stack);
484 if (handle->
type == 0) {
495 frame->
flags = draw_on;
499 if (handle->
type == 1) {
521 sceVu0FVECTOR local = {0.0f, 0.0f, 0.0f, 0.0f};
525 if (handle->
type == 0) {
529 frame->GetWorldPosition(pos, local);
533 if (handle->
type == 1) {
541 SetStack(stack++, pos[0]);
542 SetStack(stack++, pos[1]);
543 SetStack(stack, pos[2]);
548 sceVu0FVECTOR rot = {0.0f, 0.0f, 0.0f, 1.0f};
549 sceVu0FMATRIX matrix;
552 if (handle->
type == 0) {
556 frame->GetLWMatrix(matrix);
558 rot[1] = atan2f(matrix[2][0], matrix[2][2]);
564 if (handle->
type == 1) {
572 SetStack(stack++, rot[0]);
573 SetStack(stack++, rot[1]);
574 SetStack(stack, rot[2]);
579 BtEventInfo.
request = BT_REQUEST_URA_DUNGEON;
584 SetStack(stack++, BtEventInfo.
position[0]);
585 SetStack(stack++, BtEventInfo.
position[1]);
586 SetStack(stack, BtEventInfo.
position[2]);
591 SetStack(stack++, BtEventInfo.
direction[0]);
592 SetStack(stack++, BtEventInfo.
direction[1]);
593 SetStack(stack, BtEventInfo.
direction[2]);
598 if (stack->
type != RS_PTR) {
603 BtEventInfo.
request = BT_REQUEST_ENTRANCE_WINDOW;
608 if (stack->
type != RS_PTR) {
613 BtBattleMusic_Stop();
614 BtEventInfo.
request = BT_REQUEST_ESCAPE_WINDOW;
619 BtEventInfo.
request = BT_REQUEST_GO_DUNGEON;
624 char *map_file = GetStackString(stack++);
625 BtLoadMapType = GetStackInt(stack);
626 strcpy(BtLoadMapFileName, map_file);
627 MainDungeonMap.
map_type = BtLoadMapType;
634 BtMapJumpLoad(BtLoadMapFileName);
655 int script_no = GetStackInt(stack++);
661 int model_no = GetStackInt(stack++);
665 if (argument_count == 2) {
666 if (GetStackInt(stack++)) {
672 if (argument_count == 5) {
673 int clean = GetStackInt(stack++);
674 pos[0] = GetStackFloat(stack++);
675 pos[1] = GetStackFloat(stack++);
676 pos[2] = GetStackFloat(stack++);
684 if (argument_count == 6) {
685 int clean = GetStackInt(stack++);
686 pos[0] = GetStackFloat(stack++);
687 pos[1] = GetStackFloat(stack++);
688 pos[2] = GetStackFloat(stack++);
689 event_flag = GetStackInt(stack);
702 int atra_no = GetStackInt(stack++);
703 int have = GetAtraTipNowHave(atra_no, UserStatus->
cur_georama);
705 printf(
"%d,%d --> %d\n", atra_no, UserStatus->
cur_georama, have);
706 SetStack(stack, have);
713 pos[0] = GetStackFloat(stack++);
714 pos[1] = GetStackFloat(stack++);
715 pos[2] = GetStackFloat(stack++);
724 pos[0] = GetStackFloat(stack++);
725 pos[1] = GetStackFloat(stack++);
726 pos[2] = GetStackFloat(stack++);
734 printf(
"get id = %d\n", cur_chara);
735 SetStack(stack, cur_chara);
740 int script_no = GetStackInt(stack++);
744 if (argument_count == 2) {
745 BtEventInfo.
ext_memory = GetStackInt(stack++);
748 if (argument_count == 3) {
749 BtEventInfo.
ext_memory = GetStackInt(stack++);
753 BtEventInfo.
request = BT_REQUEST_RUN_SCRIPT;
759 int script_no = GetStackInt(stack++);
763 if (argument_count > 1) {
772 int index = GetStackInt(stack++);
773 int npc_no = GetStackInt(stack);
776 if (npc_no < 0 || npc_no > 3) {
777 printf(
"over err\n");
783 if (chara->
frame != NULL) {
795 int npc_no = GetStackInt(stack++);
796 int motion_no = GetStackInt(stack++);
800 if (argument_count > 2) {
801 speed = GetStackFloat(stack++);
804 if (argument_count > 3) {
805 mode = GetStackInt(stack);
812 if (argument_count < 3) {
815 NowDngMap->
NPCSetMotion(npc_no, motion_no, speed, mode);
822 int npc_no = GetStackInt(stack++);
823 int enable = GetStackInt(stack);
839 if (argument_count != 1) {
848 int chara = GetStackInt(stack++);
851 if (argument_count == 2) {
852 reload = GetStackInt(stack);
855 if (chara < 0 || chara > 5) {
859 selectChrUnit(chara, reload);
887 if (argument_count == 1) {
888 BtAllDrawFlag = GetStackInt(stack);
900 SetStack(stack, BtRubyDoorKey);
930 BtEventInfo.
bee_npc = GetStackInt(stack);
941 SetStack(stack, EastKingCheckComplete());
960 sceVu0FVECTOR push = {0.0f, 0.0f, 1.0f, 1.0f};
961 sceVu0FVECTOR direction;
963 sceVu0CopyVector(pos, CharaMain.
pos);
966 int bomb = SetBombEffect(pos, 1, selectMapNo * 20 + 20, 0.8f);
970 sceVu0Normalize(direction, push);
971 sceVu0ScaleVectorXYZ(collision->
hit[bomb].
velocity, direction, 0.8f);
981 BtSetStatusErr(GetStackInt(stack));
982 sceVu0CopyVector(pos, CharaMain.
pos);
984 NowColData->
Set(pos, 2, 2, 5.0f, 0.0f, 1, 2, 0, 0);
1004 int script_no = GetStackInt(stack);
1011 BtBattleMusic_Stop();
1021 int dungeon_no = GetStackInt(stack++);
1022 SaveData->
QuestDungeon(dungeon_no, GetStackInt(stack));
1032 LoadActiveItemIcon();
1037 int item_no = GetStackInt(stack++);
1039 int not_weapon = item_no < ITEM_WEAPON_START;
1042 if (!not_weapon && item_no < ITEM_WEAPON_WOODENSLINGSHOT_BROKEN) {
1046 if (item_no >= ITEM_WEAPON_WOODENSLINGSHOT_BROKEN && item_no < ITEM_WEAPON_MALLET_BROKEN) {
1050 if (item_no >= ITEM_WEAPON_MALLET_BROKEN && item_no < ITEM_WEAPON_GOLD_RING_BROKEN) {
1054 if (item_no >= ITEM_WEAPON_GOLD_RING_BROKEN && item_no < ITEM_WEAPON_FIGHTING_STICK_BROKEN) {
1058 if (item_no >= ITEM_WEAPON_FIGHTING_STICK_BROKEN && item_no < ITEM_WEAPON_MACHINE_GUN_BROKEN) {
1062 if (item_no >= ITEM_WEAPON_MACHINE_GUN_BROKEN) {
1067 SetStack(stack, owner);
1085 GetPieroItem(selectMapNo, BtUraDongeon, &item0, &item1);
1086 SetStack(stack++, item0);
1087 SetStack(stack, item1);
1099 {_GET_FLOOR_LEVEL, 1010},
1100 {_SET_FLOOR_LEVEL, 1011},
1101 {_GET_OLD_FLOOR_LEVEL, 1012},
1102 {_GET_ACTION_MODE, 1020},
1103 {_ITEM_USE_WINDOW, 1021},
1104 {_CHECK_EVENT_FLG, 1023},
1105 {_SET_EVENT_FLG, 1024},
1106 {_GET_OBJHDL, 1030},
1107 {_SET_OBJHDL_POS, 1031},
1108 {_SET_OBJHDL_ROT, 1032},
1109 {_SET_OBJHDL_DRAW_FLAG, 1033},
1110 {_GET_OBJHDL_POS, 1034},
1111 {_GET_OBJHDL_ROT, 1035},
1112 {_SET_URA_DUNGEON, 1036},
1113 {_GET_EVENT_POS, 1040},
1114 {_GET_EVENT_ROT, 1041},
1115 {_OPEN_ENTRANCE_WINDOW, 1022},
1116 {_OPEN_ESCAPE_WINDOW, 1070},
1117 {_GO_DUNGEON, 1050},
1118 {_SET_DUNGEON_MAP, 1051},
1119 {_LOAD_DUNGEON_MAP2, 1052},
1120 {_LOAD_MONSTOR, 1053},
1121 {_SET_RANDOM_MAP, 1054},
1122 {_SET_EVENT_SW, 1055},
1123 {_SET_MONSTOR_ID, 1056},
1124 {_CHK_ATRA_HAVE, 1057},
1127 {_GET_NOW_USER_ID, 1060},
1128 {_RUN_SCRIPT_NO, 1061},
1129 {_CLEAN_MONSTOR_SCRIPT_NO, 1066},
1130 {_GET_NPC_OBJHDL, 1062},
1131 {_SET_MOTION_OBJHDL, 1063},
1132 {_SET_NPC_ON_OFF, 1094},
1133 {_GET_GATEKEY_NO, 1064},
1134 {_USER_WEAPON_DRAW, 1065},
1135 {_SET_MAIN_CHR2, 1067},
1136 {_RESET_MAIN_CHR, 1071},
1137 {_SET_LIMMIT_ZONE, 1068},
1138 {_SET_DEAD_FLAG, 1069},
1139 {_ALL_DRAW_FLAG, 1072},
1140 {_SET_FLOOR_TITLE, 1073},
1141 {_GET_RUBY_ELEMENT, 1074},
1142 {_SET_RUBY_ELEMENT, 1088},
1143 {_SET_FLOOR_TITLE_OFF, 1076},
1146 {_EASTKING_COMPLETE, 1079},
1147 {_SET_RES_LIMMIT_ZONE, 1080},
1148 {_GET_ITEM_TRAPID, 1081},
1149 {_RESET_ITEM_TRAP, 1082},
1151 {_SET_STATUS_ERR, 1084},
1152 {_CHECK_MARDAN, 1086},
1153 {_NO_RESET_CHARA_NO, 1087},
1154 {_CHECK_CHR_HELP, 1089},
1155 {_HOLD_ITEM_EVENT, 1090},
1156 {_STOP_BATTLE_BGM, 1091},
1157 {_NO_STATUS_RECOVER, 1092},
1158 {_SET_QUEST_DUNGEON, 1093},
1159 {_GET_MAP_CODE, 1095},
1160 {_SET_ACTIVE_ITEM_ICON, 1096},
1161 {_GET_ITEM_UNIT_NO, 1097},
1162 {_SET_IBOX_ANGLE, 1098},
1163 {_SET_IBOX_FINISH, 1099},
1164 {_GET_PIERO_ITEM, 1100},
1165 {_CLEAR_DEAMON_SHAFT, 1101},
1169void AddSystemEventScript() {
1170 for (
int i = 0;; i++) {
1171 if (ext_func_info[i].function == NULL) {
1177 for (j = 0; j < i; j++) {
1178 if (ext_func_info[i].operation == ext_func_info[j].operation) {
1179 printf(
"same ext_func_no!!!\n");
1186 int operation = ext_func_info[i].
operation;
1188 if (operation < 0 || operation >= 1500) {
1189 printf(
"ext func over!!");
1191 ext_func__2[operation] = ext_func_info[i].
function;
void SetHeight(float height)
void SetFollow(float x, float y, float z)
void SetAngleSoon(float angle)
virtual void Step(int steps)
void SetRef(CFrame *parent, float x, float y, float z)
void SetPos(CFrame *parent, float x, float y, float z)
void SetMotion(int no, int mode, float speed=-1.0f)
virtual void GetPosition(float *out_position)
virtual void SetRotation(float x, float y, float z)
virtual void SetPosition(float x, float y, float z)
int Set(float *position, int damage, int life, float radius, float scale_rate, int target_mask, int kind, int flags, int attribute)
void SearchItemEventHold(int script_no)
void SearchDataSwitch(int script_no, int enable)
CFrame * GetFrameSearch(char *name)
int SetTreasureBox(float *pos, int item_no, int kind, int trap_no)
void NPCSetMotion(int npc_no, int motion_no)
void SetAtraBoll(float *pos, int atra_no)
CFrame * GetSearchFrame(char *name)
void CleanViewMonstor(int back_floor)
int SetupViewMonstor(int model_no, float *position, int event_flag)
virtual void GetRotation(float *out_rotation)
s32 GetMardanGareyanFlag() const
int QuestDungeon(int dungeon_no, int add)
int ChkEventFlag(int flag_no)
s32 res_limit_zone_current
int(* function)(RS_STACKDATA *, int)
s32 clear_script_ext_memory
RS_STACKDATA * escape_result
RS_STACKDATA * entrance_result
CCharacter * main_character
VILLAGER_INFO * villagers