mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +00:00
Added support for known models and unknown behaviors for level gen
This commit is contained in:
parent
67f0afa80c
commit
4aff26cf27
4 changed files with 67 additions and 4 deletions
|
@ -1727,10 +1727,15 @@ static void ParseLevelScriptSymbol(GfxData* aGfxData, DataNode<LevelScript>* aNo
|
|||
LevelScript _Ls[] = { OBJECT(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh) };
|
||||
memcpy(aHead, _Ls, sizeof(_Ls));
|
||||
aHead += (sizeof(_Ls) / sizeof(_Ls[0]));
|
||||
} else if (foundModel) {
|
||||
u32 behIndex = DynOS_Lua_RememberVariable(aGfxData, aHead + 5, aNode->mTokens[topTokenIndex + 8]);
|
||||
LevelScript _Ls[] = { OBJECT_EXT(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh) };
|
||||
memcpy(aHead, _Ls, sizeof(_Ls));
|
||||
aHead += (sizeof(_Ls) / sizeof(_Ls[0]));
|
||||
} else {
|
||||
u32 modelIndex = DynOS_Lua_RememberVariable(aGfxData, aHead + 5, aNode->mTokens[topTokenIndex + 0]);
|
||||
u32 behIndex = DynOS_Lua_RememberVariable(aGfxData, aHead + 6, aNode->mTokens[topTokenIndex + 8]);
|
||||
LevelScript _Ls[] = { OBJECT_EXT(modelIndex, posX, posY, posZ, angleX, angleY, angleZ, behParam, behIndex) };
|
||||
LevelScript _Ls[] = { OBJECT_EXT2(modelIndex, posX, posY, posZ, angleX, angleY, angleZ, behParam, behIndex) };
|
||||
memcpy(aHead, _Ls, sizeof(_Ls));
|
||||
aHead += (sizeof(_Ls) / sizeof(_Ls[0]));
|
||||
}
|
||||
|
@ -1759,10 +1764,15 @@ static void ParseLevelScriptSymbol(GfxData* aGfxData, DataNode<LevelScript>* aNo
|
|||
LevelScript _Ls[] = { OBJECT_WITH_ACTS(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh, acts) };
|
||||
memcpy(aHead, _Ls, sizeof(_Ls));
|
||||
aHead += (sizeof(_Ls) / sizeof(_Ls[0]));
|
||||
} else if (foundModel) {
|
||||
u32 behIndex = DynOS_Lua_RememberVariable(aGfxData, aHead + 5, aNode->mTokens[topTokenIndex + 8]);
|
||||
LevelScript _Ls[] = { OBJECT_WITH_ACTS_EXT(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, behIndex, acts) };
|
||||
memcpy(aHead, _Ls, sizeof(_Ls));
|
||||
aHead += (sizeof(_Ls) / sizeof(_Ls[0]));
|
||||
} else {
|
||||
u32 modelIndex = DynOS_Lua_RememberVariable(aGfxData, aHead + 5, aNode->mTokens[topTokenIndex + 0]);
|
||||
u32 behIndex = DynOS_Lua_RememberVariable(aGfxData, aHead + 6, aNode->mTokens[topTokenIndex + 8]);
|
||||
LevelScript _Ls[] = { OBJECT_WITH_ACTS_EXT(modelIndex, posX, posY, posZ, angleX, angleY, angleZ, behParam, behIndex, acts) };
|
||||
LevelScript _Ls[] = { OBJECT_WITH_ACTS_EXT2(modelIndex, posX, posY, posZ, angleX, angleY, angleZ, behParam, behIndex, acts) };
|
||||
memcpy(aHead, _Ls, sizeof(_Ls));
|
||||
aHead += (sizeof(_Ls) / sizeof(_Ls[0]));
|
||||
}
|
||||
|
|
|
@ -285,7 +285,13 @@
|
|||
// coop
|
||||
|
||||
#define OBJECT_WITH_ACTS_EXT(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh, acts) \
|
||||
CMD_BBBB(0x3F, 0x1C, acts, 0), \
|
||||
CMD_BBBB(0x3F, 0x18, acts, model), \
|
||||
CMD_HHHHHH(posX, posY, posZ, angleX, angleY, angleZ), \
|
||||
CMD_W(behParam), \
|
||||
CMD_PTR(beh)
|
||||
|
||||
#define OBJECT_WITH_ACTS_EXT2(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh, acts) \
|
||||
CMD_BBBB(0x40, 0x1C, acts, 0), \
|
||||
CMD_HHHHHH(posX, posY, posZ, angleX, angleY, angleZ), \
|
||||
CMD_W(behParam), \
|
||||
CMD_PTR(model), \
|
||||
|
@ -294,4 +300,7 @@
|
|||
#define OBJECT_EXT(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh) \
|
||||
OBJECT_WITH_ACTS_EXT(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh, 0x1F)
|
||||
|
||||
#define OBJECT_EXT2(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh) \
|
||||
OBJECT_WITH_ACTS_EXT2(model, posX, posY, posZ, angleX, angleY, angleZ, behParam, beh, 0x1F)
|
||||
|
||||
#endif // LEVEL_COMMANDS_H
|
||||
|
|
|
@ -828,6 +828,49 @@ static void level_cmd_place_object_ext(void) {
|
|||
u8 val7 = 1 << (gCurrActNum - 1);
|
||||
struct SpawnInfo *spawnInfo;
|
||||
|
||||
u16 modIndex = gLevelScriptModIndex;
|
||||
char* behStr = CMD_GET(char*, 20);
|
||||
|
||||
gSmLuaConvertSuccess = true;
|
||||
enum BehaviorId behId = smlua_get_mod_variable(modIndex, behStr);
|
||||
|
||||
if ((gLevelScriptModIndex == -1) || !gSmLuaConvertSuccess) {
|
||||
LOG_ERROR("Failed to place custom object: %u", behId);
|
||||
sCurrentCmd = CMD_NEXT;
|
||||
return;
|
||||
}
|
||||
|
||||
if (sCurrAreaIndex != -1 && ((CMD_GET(u8, 2) & val7) || CMD_GET(u8, 2) == 0x1F)) {
|
||||
u16 model = CMD_GET(u8, 3);
|
||||
spawnInfo = alloc_only_pool_alloc(sLevelPool, sizeof(struct SpawnInfo));
|
||||
|
||||
spawnInfo->startPos[0] = CMD_GET(s16, 4);
|
||||
spawnInfo->startPos[1] = CMD_GET(s16, 6);
|
||||
spawnInfo->startPos[2] = CMD_GET(s16, 8);
|
||||
|
||||
spawnInfo->startAngle[0] = CMD_GET(s16, 10) * 0x8000 / 180;
|
||||
spawnInfo->startAngle[1] = CMD_GET(s16, 12) * 0x8000 / 180;
|
||||
spawnInfo->startAngle[2] = CMD_GET(s16, 14) * 0x8000 / 180;
|
||||
|
||||
spawnInfo->areaIndex = sCurrAreaIndex;
|
||||
spawnInfo->activeAreaIndex = sCurrAreaIndex;
|
||||
|
||||
spawnInfo->behaviorArg = CMD_GET(u32, 16);
|
||||
|
||||
spawnInfo->behaviorScript = (BehaviorScript*)get_behavior_from_id(behId);
|
||||
spawnInfo->unk18 = gLoadedGraphNodes[model];
|
||||
spawnInfo->next = gAreas[sCurrAreaIndex].objectSpawnInfos;
|
||||
|
||||
gAreas[sCurrAreaIndex].objectSpawnInfos = spawnInfo;
|
||||
}
|
||||
|
||||
sCurrentCmd = CMD_NEXT;
|
||||
}
|
||||
|
||||
static void level_cmd_place_object_ext2(void) {
|
||||
u8 val7 = 1 << (gCurrActNum - 1);
|
||||
struct SpawnInfo *spawnInfo;
|
||||
|
||||
u16 modIndex = gLevelScriptModIndex;
|
||||
char* modelStr = CMD_GET(char*, 20);
|
||||
char* behStr = CMD_GET(char*, 24);
|
||||
|
@ -935,6 +978,7 @@ static void (*LevelScriptJumpTable[])(void) = {
|
|||
|
||||
// coop
|
||||
/*3F*/ level_cmd_place_object_ext,
|
||||
/*40*/ level_cmd_place_object_ext2,
|
||||
};
|
||||
|
||||
struct LevelCommand *level_script_execute(struct LevelCommand *cmd) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
void bhv_breakable_box_loop(void) {
|
||||
obj_set_hitbox(o, &sBreakableBoxHitbox);
|
||||
|
||||
cur_obj_set_model(smlua_model_util_load(E_MODEL_BREAKABLE_BOX_SMALL));
|
||||
//cur_obj_set_model(smlua_model_util_load(E_MODEL_BREAKABLE_BOX_SMALL));
|
||||
|
||||
if (o->oTimer == 0)
|
||||
breakable_box_init();
|
||||
|
|
Loading…
Reference in a new issue