Merge branch 'ufo-script' into 'master'

Add "UFO" script type

See merge request KartKrew/Kart!1111
This commit is contained in:
Sal 2023-03-29 00:39:34 +00:00
commit 4588a20a95
6 changed files with 67 additions and 13 deletions

View file

@ -271,6 +271,29 @@ void ACS_RunOvertimeScript(void)
map->scriptStartType(ACS_ST_OVERTIME, {});
}
/*--------------------------------------------------
void ACS_RunCatcherScript(mobj_t *mo)
See header file for description.
--------------------------------------------------*/
void ACS_RunCatcherScript(mobj_t *mo)
{
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, mo);
scriptInfo.info = &info;
map->scriptStartType(ACS_ST_UFO, scriptInfo);
}
/*--------------------------------------------------
void ACS_RunEmeraldScript(mobj_t *mo)
@ -291,7 +314,7 @@ void ACS_RunEmeraldScript(mobj_t *mo)
scriptInfo.info = &info;
map->scriptStartTypeForced(ACS_ST_EMERALD, scriptInfo);
map->scriptStartType(ACS_ST_EMERALD, scriptInfo);
}
/*--------------------------------------------------

View file

@ -155,6 +155,16 @@ void ACS_RunPositionScript(void);
void ACS_RunOvertimeScript(void);
/*--------------------------------------------------
void ACS_RunCatcherScript(mobj_t *mo);
Runs the map's special script for when the
Special Stage UFO Catcher is destroyed.
--------------------------------------------------*/
void ACS_RunCatcherScript(mobj_t *mo);
/*--------------------------------------------------
void ACS_RunEmeraldScript(mobj_t *mo);

View file

@ -41,7 +41,8 @@ enum acs_scriptType_e
ACS_ST_LAP = 5, // LAP: Runs when a player's lap increases from crossing the finish line.
ACS_ST_POSITION = 6, // POSITION: Runs when the POSITION period ends.
ACS_ST_OVERTIME = 7, // OVERTIME: Runs when Overtime starts in timed game modes.
ACS_ST_EMERALD = 8, // EMERALD: Runs when the Chaos Emerald is collected in a Special Stage.
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.
};
//

View file

@ -72,6 +72,7 @@ waypoint_t *K_GetSpecialUFOWaypoint(mobj_t *ufo);
void Obj_SpecialUFOThinker(mobj_t *ufo);
boolean Obj_SpecialUFODamage(mobj_t *ufo, mobj_t *inflictor, mobj_t *source, UINT8 damageType);
void Obj_PlayerUFOCollide(mobj_t *ufo, mobj_t *other);
boolean Obj_UFOEmeraldCollect(mobj_t *ufo, mobj_t *toucher);
void Obj_UFOPieceThink(mobj_t *piece);
void Obj_UFOPieceDead(mobj_t *piece);
void Obj_UFOPieceRemoved(mobj_t *piece);

View file

@ -698,7 +698,7 @@ boolean Obj_SpecialUFODamage(mobj_t *ufo, mobj_t *inflictor, mobj_t *source, UIN
ufo->flags = (ufo->flags & ~MF_SHOOTABLE) | (MF_SPECIAL|MF_PICKUPFROMBELOW);
ufo->shadowscale = FRACUNIT/3;
ACS_RunEmeraldScript(source);
ACS_RunCatcherScript(source);
S_StopSound(ufo);
S_StartSound(ufo, sfx_clawk2);
@ -757,6 +757,32 @@ void Obj_PlayerUFOCollide(mobj_t *ufo, mobj_t *other)
K_KartBouncing(other, ufo);
}
boolean Obj_UFOEmeraldCollect(mobj_t *ufo, mobj_t *toucher)
{
if (toucher->player != NULL)
{
if (P_CanPickupItem(toucher->player, 0) == false)
{
return false;
}
}
if (ufo_collectdelay(ufo) > 0)
{
return false;
}
if (toucher->hitlag > 0)
{
return false;
}
ACS_RunEmeraldScript(toucher);
CONS_Printf("You win!\n");
return true;
}
void Obj_UFOPieceThink(mobj_t *piece)
{
mobj_t *ufo = ufo_piece_owner(piece);

View file

@ -391,18 +391,11 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
K_CheckEmeralds(player);
break;
case MT_SPECIAL_UFO:
if (!P_CanPickupItem(player, 0))
if (Obj_UFOEmeraldCollect(special, toucher) == false)
{
return;
}
if (special->threshold > 0)
return;
if (toucher->hitlag > 0)
return;
P_LinedefExecute(LE_BOSSDEAD, toucher, NULL);
CONS_Printf("You win!\n");
break;
/*
case MT_EERIEFOG: