Update ACS code and add playerfinishscript

This commit is contained in:
NepDisk 2025-03-10 12:36:08 -04:00
parent a7167bfbcd
commit 431d504e8d
4 changed files with 44 additions and 7 deletions

View file

@ -144,15 +144,10 @@ void ACS_LoadLevelScripts(size_t mapID)
// Insert BEHAVIOR lump into the list.
{
static const char *maplumpname;
maplumpname = G_BuildMapName(gamemap);
ACSVM::ModuleName name = ACSVM::ModuleName(
env->getString( maplumpname ),
env->getString( mapheaderinfo[mapID]->lumpname ),
nullptr,
W_CheckNumForMap(maplumpname)
mapheaderinfo[mapID]->lumpnum
);
modules.push_back(env->getModule(name));
@ -274,6 +269,29 @@ void ACS_RunLapScript(mobj_t *mo, line_t *line)
map->scriptStartTypeForced(ACS_ST_LAP, scriptInfo);
}
/*--------------------------------------------------
void ACS_RunPlayerFinishScript(player_t *player)
See header file for description.
--------------------------------------------------*/
void ACS_RunPlayerFinishScript(player_t *player)
{
Environment *env = &ACSEnv;
ACSVM::GlobalScope *const global = env->getGlobalScope(0);
ACSVM::HubScope *const hub = global->getHubScope(0);
ACSVM::MapScope *const map = hub->getMapScope(0);
ACSVM::MapScope::ScriptStartInfo scriptInfo;
ThreadInfo info;
P_SetTarget(&info.mo, player->mo);
scriptInfo.info = &info;
map->scriptStartTypeForced(ACS_ST_FINISH, scriptInfo);
}
/*--------------------------------------------------
void ACS_RunPositionScript(void)

View file

@ -138,6 +138,20 @@ void ACS_RunPlayerDeathScript(player_t *player);
void ACS_RunPlayerEnterScript(player_t *player);
/*--------------------------------------------------
void ACS_RunPlayerFinishScript(player_t *player);
Runs the map's special script for a player
finishing (P_DoPlayerExit).
Input Arguments:-
player: The player to run the script for.
Return:-
None
--------------------------------------------------*/
void ACS_RunPlayerFinishScript(player_t *player);
/*--------------------------------------------------
void ACS_RunLapScript(mobj_t *mo, line_t *line);

View file

@ -43,6 +43,7 @@ enum acs_scriptType_e
ACS_ST_UFO = 8, // UFO: Runs when the UFO Catcher is destroyed in a Special Stage.
ACS_ST_EMERALD = 9, // EMERALD: Runs when the Chaos Emerald is collected in a Special Stage.
ACS_ST_GAMEOVER = 10, // GAMEOVER: Runs when the level ends due to a losing condition and no player has an extra life.
ACS_ST_FINISH = 11, // FINISH: Runs when a player finishes
};
//

View file

@ -61,6 +61,8 @@
#include "k_color.h"
#include "k_follower.h"
#include "acs/interface.h"
#ifdef HW3SOUND
#include "hardware/hw3sound.h"
#endif
@ -1324,6 +1326,8 @@ void P_DoPlayerExit(player_t *player)
if (player == &players[consoleplayer])
demo.savebutton = leveltime;
ACS_RunPlayerFinishScript(player);
}
//