Add PodiumPosition ACS function

Returns the best position of all non-CPU players.
This commit is contained in:
Sally Coolatta 2023-03-02 20:44:16 -05:00
parent 9073d5bd17
commit 0f9f10d90f
3 changed files with 45 additions and 0 deletions

View file

@ -1351,3 +1351,45 @@ bool CallFunc_EncoreMode(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::
thread->dataStk.push(encoremode); thread->dataStk.push(encoremode);
return false; return false;
} }
/*--------------------------------------------------
bool CallFunc_PodiumPosition(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC)
Returns the best position of all non-CPU players.
--------------------------------------------------*/
bool CallFunc_PodiumPosition(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC)
{
UINT8 ret = MAXPLAYERS;
INT32 i;
(void)argV;
(void)argC;
for (i = 0; i < MAXPLAYERS; i++)
{
player_t *player = NULL;
if (playeringame[i] == false)
{
continue;
}
player = &players[i];
if (player->spectator == true)
{
continue;
}
if (player->bot == true)
{
continue;
}
ret = std::min(ret, player->position);
}
thread->dataStk.push(ret);
return false;
}

View file

@ -85,4 +85,6 @@ bool CallFunc_PlayerLap(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::W
bool CallFunc_LowestLap(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_LowestLap(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
bool CallFunc_EncoreMode(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_EncoreMode(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
bool CallFunc_PodiumPosition(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
#endif // __SRB2_ACS_CALL_FUNCS_HPP__ #endif // __SRB2_ACS_CALL_FUNCS_HPP__

View file

@ -163,6 +163,7 @@ Environment::Environment()
addFuncDataACS0( 309, addCallFunc(CallFunc_EncoreMode)); addFuncDataACS0( 309, addCallFunc(CallFunc_EncoreMode));
addFuncDataACS0( 500, addCallFunc(CallFunc_CameraWait)); addFuncDataACS0( 500, addCallFunc(CallFunc_CameraWait));
addFuncDataACS0( 501, addCallFunc(CallFunc_PodiumPosition));
} }
ACSVM::Thread *Environment::allocThread() ACSVM::Thread *Environment::allocThread()