mirror of
https://github.com/cxong/cdogs-sdl.git
synced 2025-07-23 07:23:01 +02:00
Add Utnapisthim and Ziusudra #712
Show AI players momentarily at end of player selection menu
This commit is contained in:
@@ -597,5 +597,54 @@
|
||||
"probabilityToTrack": 25,
|
||||
"probabilityToShoot": 2,
|
||||
"actionDelay": 15
|
||||
},
|
||||
{
|
||||
"Class": "Jones",
|
||||
"PlayerTemplateName": "Utnapishtim",
|
||||
"HairType": "ponytail",
|
||||
"FacehairType": "dutch",
|
||||
"Skin": "ffb26aff",
|
||||
"Arms": "ffad4bff",
|
||||
"Body": "23e0ffff",
|
||||
"Legs": "9f5d2aff",
|
||||
"Hair": "fff7efff",
|
||||
"Feet": "faa23fff",
|
||||
"Facehair": "fcfcfcff",
|
||||
"Hat": "fc7e04ff",
|
||||
"Glasses": "fc7e04ff",
|
||||
"speed": 256,
|
||||
"Gun": "Small Launcher",
|
||||
"maxHealth": 40,
|
||||
"excessHealth": 80,
|
||||
"flags": 0,
|
||||
"probabilityToMove": 50,
|
||||
"probabilityToTrack": 25,
|
||||
"probabilityToShoot": 2,
|
||||
"actionDelay": 15
|
||||
},
|
||||
{
|
||||
"Class": "Jones",
|
||||
"PlayerTemplateName": "Ziusudra",
|
||||
"HairType": "long",
|
||||
"FacehairType": "beard",
|
||||
"HatType": "beret",
|
||||
"Skin": "ffb26aff",
|
||||
"Arms": "fcfcfcff",
|
||||
"Body": "ff6316ff",
|
||||
"Legs": "ff6023ff",
|
||||
"Hair": "fff7efff",
|
||||
"Feet": "744815ff",
|
||||
"Facehair": "fcfcfcff",
|
||||
"Hat": "ffb96eff",
|
||||
"Glasses": "fc7e04ff",
|
||||
"speed": 256,
|
||||
"Gun": "Small Launcher",
|
||||
"maxHealth": 40,
|
||||
"excessHealth": 80,
|
||||
"flags": 0,
|
||||
"probabilityToMove": 50,
|
||||
"probabilityToTrack": 25,
|
||||
"probabilityToShoot": 2,
|
||||
"actionDelay": 15
|
||||
}]
|
||||
}
|
@@ -155,7 +155,6 @@ static void MainMenuTerminate(GameLoopData *data)
|
||||
UnloadAllCampaigns(&mData->campaigns);
|
||||
CFREE(mData);
|
||||
}
|
||||
static menu_t *FindSubmenuByName(menu_t *menu, const char *name);
|
||||
static void MainMenuOnEnter(GameLoopData *data)
|
||||
{
|
||||
MainMenuData *mData = data->Data;
|
||||
@@ -177,7 +176,7 @@ static void MainMenuOnEnter(GameLoopData *data)
|
||||
GameEventsTerminate(&gGameEvents);
|
||||
|
||||
// Auto-enter the submenu corresponding to the last game mode
|
||||
menu_t *startMenu = FindSubmenuByName(mData->ms.root, "Start");
|
||||
menu_t *startMenu = MenuGetSubmenuByName(mData->ms.root, "Start");
|
||||
if (mData->wasClient)
|
||||
{
|
||||
mData->ms.current = startMenu;
|
||||
@@ -187,13 +186,13 @@ static void MainMenuOnEnter(GameLoopData *data)
|
||||
switch (mData->lastGameMode)
|
||||
{
|
||||
case GAME_MODE_NORMAL:
|
||||
mData->ms.current = FindSubmenuByName(startMenu, "Campaign");
|
||||
mData->ms.current = MenuGetSubmenuByName(startMenu, "Campaign");
|
||||
break;
|
||||
case GAME_MODE_DOGFIGHT:
|
||||
mData->ms.current = FindSubmenuByName(startMenu, "Dogfight");
|
||||
mData->ms.current = MenuGetSubmenuByName(startMenu, "Dogfight");
|
||||
break;
|
||||
case GAME_MODE_DEATHMATCH:
|
||||
mData->ms.current = FindSubmenuByName(startMenu, "Deathmatch");
|
||||
mData->ms.current = MenuGetSubmenuByName(startMenu, "Deathmatch");
|
||||
break;
|
||||
default:
|
||||
mData->ms.current = mData->ms.root;
|
||||
@@ -201,15 +200,6 @@ static void MainMenuOnEnter(GameLoopData *data)
|
||||
}
|
||||
}
|
||||
}
|
||||
static menu_t *FindSubmenuByName(menu_t *menu, const char *name)
|
||||
{
|
||||
CASSERT(menu->type == MENU_TYPE_NORMAL, "invalid menu type");
|
||||
CA_FOREACH(menu_t, submenu, menu->u.normal.subMenus)
|
||||
if (strcmp(submenu->name, name) == 0)
|
||||
return submenu;
|
||||
CA_FOREACH_END()
|
||||
return menu;
|
||||
}
|
||||
static void MainMenuOnExit(GameLoopData *data)
|
||||
{
|
||||
MainMenuData *mData = data->Data;
|
||||
|
@@ -425,11 +425,10 @@ void MenuSetDisabled(menu_t *menu, const bool isDisabled)
|
||||
|
||||
menu_t *MenuGetSubmenuByName(menu_t *menu, const char *name)
|
||||
{
|
||||
CA_FOREACH(menu_t, subMenu, menu->u.normal.subMenus)
|
||||
if (strcmp(subMenu->name, name) == 0)
|
||||
{
|
||||
return subMenu;
|
||||
}
|
||||
CASSERT(menu->type == MENU_TYPE_NORMAL, "invalid menu type");
|
||||
CA_FOREACH(menu_t, submenu, menu->u.normal.subMenus)
|
||||
if (strcmp(submenu->name, name) == 0)
|
||||
return submenu;
|
||||
CA_FOREACH_END()
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -524,7 +524,6 @@ static void CheckReenableLoadMenu(menu_t *menu, void *data)
|
||||
{
|
||||
menu_t *loadMenu = MenuGetSubmenuByName(menu, "Load");
|
||||
UNUSED(data);
|
||||
assert(loadMenu);
|
||||
loadMenu->isDisabled = PlayerTemplateGetById(&gPlayerTemplates, 0) == NULL;
|
||||
}
|
||||
static menu_t *CreateCustomizeMenu(
|
||||
|
101
src/prep.c
101
src/prep.c
@@ -309,6 +309,7 @@ typedef struct
|
||||
char suffixes[CDOGS_PATH_MAX];
|
||||
char suffixnames[CDOGS_PATH_MAX];
|
||||
EventWaitResult waitResult;
|
||||
int endCounter;
|
||||
} PlayerSelectionData;
|
||||
static void PlayerSelectionTerminate(GameLoopData *data);
|
||||
static void PlayerSelectionOnExit(GameLoopData *data);
|
||||
@@ -358,22 +359,6 @@ static void PlayerSelectionOnExit(GameLoopData *data)
|
||||
PlayerSelectionData *pData = data->Data;
|
||||
if (pData->waitResult == EVENT_WAIT_OK)
|
||||
{
|
||||
for (int i = 0, idx = 0; i < (int)gPlayerDatas.size; i++, idx++)
|
||||
{
|
||||
PlayerData *p = CArrayGet(&gPlayerDatas, i);
|
||||
if (!p->IsLocal)
|
||||
{
|
||||
idx--;
|
||||
continue;
|
||||
}
|
||||
|
||||
// For any player slots not picked, turn them into AIs
|
||||
if (p->inputDevice == INPUT_DEVICE_UNSET)
|
||||
{
|
||||
PlayerTrySetInputDevice(p, INPUT_DEVICE_AI, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!gCampaign.IsClient)
|
||||
{
|
||||
gCampaign.MissionIndex = 0;
|
||||
@@ -406,35 +391,38 @@ static GameLoopResult PlayerSelectionUpdate(GameLoopData *data, LoopRunner *l)
|
||||
LoopRunnerPop(l);
|
||||
return UPDATE_RESULT_OK;
|
||||
}
|
||||
|
||||
// Menu input
|
||||
|
||||
int idx = 0;
|
||||
const bool useMenuCmd = GetNumPlayers(PLAYER_ANY, true, true);
|
||||
for (int i = 0; i < (int)gPlayerDatas.size; i++, idx++)
|
||||
if (pData->endCounter == 0)
|
||||
{
|
||||
const PlayerData *p = CArrayGet(&gPlayerDatas, i);
|
||||
if (!p->IsLocal)
|
||||
// Menu input
|
||||
const bool useMenuCmd = GetNumPlayers(PLAYER_ANY, true, true);
|
||||
for (int i = 0; i < (int)gPlayerDatas.size; i++, idx++)
|
||||
{
|
||||
idx--;
|
||||
continue;
|
||||
}
|
||||
if (p->inputDevice != INPUT_DEVICE_UNSET)
|
||||
{
|
||||
MenuSystem *ms = &pData->menus[idx].ms;
|
||||
if (ms->current->customPostUpdateFunc)
|
||||
const PlayerData *p = CArrayGet(&gPlayerDatas, i);
|
||||
if (!p->IsLocal)
|
||||
{
|
||||
ms->current->customPostUpdateFunc(
|
||||
ms->current, ms->current->customPostUpdateData);
|
||||
idx--;
|
||||
continue;
|
||||
}
|
||||
MenuUpdateMouse(ms);
|
||||
if (useMenuCmd)
|
||||
if (p->inputDevice != INPUT_DEVICE_UNSET)
|
||||
{
|
||||
cmds[idx] |=
|
||||
MenuSystem *ms = &pData->menus[idx].ms;
|
||||
if (ms->current->customPostUpdateFunc)
|
||||
{
|
||||
ms->current->customPostUpdateFunc(
|
||||
ms->current, ms->current->customPostUpdateData);
|
||||
}
|
||||
MenuUpdateMouse(ms);
|
||||
if (useMenuCmd)
|
||||
{
|
||||
cmds[idx] |=
|
||||
GetMenuCmd(&gEventHandlers, ms->current->mouseHover);
|
||||
}
|
||||
if (!MenuIsExit(ms) && cmds[idx])
|
||||
{
|
||||
MenuProcessCmd(ms, cmds[idx]);
|
||||
}
|
||||
if (!MenuIsExit(ms) && cmds[idx])
|
||||
{
|
||||
MenuProcessCmd(ms, cmds[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,16 +453,43 @@ static GameLoopResult PlayerSelectionUpdate(GameLoopData *data, LoopRunner *l)
|
||||
}
|
||||
if (isDone && hasAtLeastOneInput)
|
||||
{
|
||||
pData->waitResult = EVENT_WAIT_OK;
|
||||
if (!gCampaign.IsClient && CanLevelSelect(gCampaign.Entry.Mode))
|
||||
// For any player slots not picked, turn them into AIs
|
||||
bool hasAIPlayers = false;
|
||||
idx = 0;
|
||||
for (int i = 0; i < (int)gPlayerDatas.size; i++, idx++)
|
||||
{
|
||||
LoopRunnerChange(l, LevelSelection(&gGraphicsDevice));
|
||||
PlayerData *p = CArrayGet(&gPlayerDatas, i);
|
||||
if (!p->IsLocal)
|
||||
{
|
||||
idx--;
|
||||
continue;
|
||||
}
|
||||
if (p->inputDevice == INPUT_DEVICE_UNSET || p->inputDevice == INPUT_DEVICE_AI)
|
||||
{
|
||||
hasAIPlayers = true;
|
||||
PlayerTrySetInputDevice(p, INPUT_DEVICE_AI, 0);
|
||||
pData->menus[idx].ms.current = MenuGetSubmenuByName(pData->menus[idx].ms.root, "Done");
|
||||
}
|
||||
}
|
||||
if (hasAIPlayers && pData->endCounter < 70)
|
||||
{
|
||||
// If we have AI players, wait a bit before continuing
|
||||
pData->endCounter++;
|
||||
return UPDATE_RESULT_DRAW;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoopRunnerChange(l, GameOptions(gCampaign.Entry.Mode));
|
||||
pData->waitResult = EVENT_WAIT_OK;
|
||||
if (!gCampaign.IsClient && CanLevelSelect(gCampaign.Entry.Mode))
|
||||
{
|
||||
LoopRunnerChange(l, LevelSelection(&gGraphicsDevice));
|
||||
}
|
||||
else
|
||||
{
|
||||
LoopRunnerChange(l, GameOptions(gCampaign.Entry.Mode));
|
||||
}
|
||||
return UPDATE_RESULT_OK;
|
||||
}
|
||||
return UPDATE_RESULT_OK;
|
||||
}
|
||||
|
||||
AssignPlayerInputDevices(&gEventHandlers);
|
||||
|
Reference in New Issue
Block a user