[+] Added AIScript for GameSettings to specify the AI script to use
This commit is contained in:
parent
f7f00ed4fa
commit
738641270a
5 changed files with 19 additions and 11 deletions
|
@ -112,6 +112,7 @@ void SaveGameSettings(CFile &file)
|
|||
file.printf("\nGameSettings.NetGameType = %d\n", GameSettings.NetGameType);
|
||||
for (int i = 0; i < PlayerMax - 1; ++i) {
|
||||
file.printf("GameSettings.Presets[%d].PlayerColor = %d\n", i, GameSettings.Presets[i].PlayerColor);
|
||||
file.printf("GameSettings.Presets[%d].AIScript = \"%s\"\n", i, GameSettings.Presets[i].AIScript);
|
||||
file.printf("GameSettings.Presets[%d].Race = %d\n", i, GameSettings.Presets[i].Race);
|
||||
file.printf("GameSettings.Presets[%d].Team = %d\n", i, GameSettings.Presets[i].Team);
|
||||
file.printf("GameSettings.Presets[%d].Type = %d\n", i, GameSettings.Presets[i].Type);
|
||||
|
@ -1022,6 +1023,7 @@ void InitSettings()
|
|||
{
|
||||
for (int i = 0; i < PlayerMax; ++i) {
|
||||
GameSettings.Presets[i].PlayerColor = i;
|
||||
GameSettings.Presets[i].AIScript = "ai-passive";
|
||||
GameSettings.Presets[i].Race = SettingsPresetMapDefault;
|
||||
GameSettings.Presets[i].Team = SettingsPresetMapDefault;
|
||||
GameSettings.Presets[i].Type = SettingsPresetMapDefault;
|
||||
|
|
|
@ -101,6 +101,7 @@ public:
|
|||
MPPlayer() : PlayerColor(0), Race(0), Team(0), Type(0) {}
|
||||
|
||||
std::string Name;
|
||||
std::string AIScript;
|
||||
int PlayerColor;
|
||||
int Race;
|
||||
int Team;
|
||||
|
@ -198,6 +199,7 @@ static FullReplay *StartReplay()
|
|||
for (int i = 0; i < PlayerMax; ++i) {
|
||||
replay->Players[i].Name = Players[i].Name;
|
||||
replay->Players[i].PlayerColor = GameSettings.Presets[i].PlayerColor;
|
||||
replay->Players[i].AIScript = GameSettings.Presets[i].AIScript;
|
||||
replay->Players[i].Race = GameSettings.Presets[i].Race;
|
||||
replay->Players[i].Team = GameSettings.Presets[i].Team;
|
||||
replay->Players[i].Type = GameSettings.Presets[i].Type;
|
||||
|
@ -248,6 +250,7 @@ static void ApplyReplaySettings()
|
|||
|
||||
for (int i = 0; i < PlayerMax; ++i) {
|
||||
GameSettings.Presets[i].PlayerColor = CurrentReplay->Players[i].PlayerColor;
|
||||
GameSettings.Presets[i].AIScript = CurrentReplay->Players[i].AIScript;
|
||||
GameSettings.Presets[i].Race = CurrentReplay->Players[i].Race;
|
||||
GameSettings.Presets[i].Team = CurrentReplay->Players[i].Team;
|
||||
GameSettings.Presets[i].Type = CurrentReplay->Players[i].Type;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
//@{
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
@ -47,10 +48,11 @@ class CMap;
|
|||
----------------------------------------------------------------------------*/
|
||||
|
||||
struct SettingsPresets {
|
||||
int PlayerColor; /// Color of a player
|
||||
int Race; /// Race of the player
|
||||
int Team; /// Team of player -- NOT SELECTABLE YET
|
||||
int Type; /// Type of player (for network games)
|
||||
int PlayerColor; /// Color of a player
|
||||
std::string AIScript; /// AI script for computer to use
|
||||
int Race; /// Race of the player
|
||||
int Team; /// Team of player
|
||||
int Type; /// Type of player (for network games)
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -743,13 +743,13 @@ static int CclGetPlayerData(lua_State *l)
|
|||
} else if (!strcmp(data, "SpeedResearch")) {
|
||||
lua_pushnumber(l, p->SpeedResearch);
|
||||
return 1;
|
||||
} else if (!strcmp(data, "Allow")) {
|
||||
LuaCheckArgs(l, 3);
|
||||
const std::string ident = LuaToString(l, 3);
|
||||
char b[2];
|
||||
b[0] = UpgradeIdentAllowed(Players[p->Index], ident.c_str());
|
||||
b[1] = 0;
|
||||
lua_pushstring(l, b);
|
||||
} else if (!strcmp(data, "Allow")) {
|
||||
LuaCheckArgs(l, 3);
|
||||
const std::string ident = LuaToString(l, 3);
|
||||
char b[2];
|
||||
b[0] = UpgradeIdentAllowed(Players[p->Index], ident.c_str());
|
||||
b[1] = 0;
|
||||
lua_pushstring(l, b);
|
||||
return 1;
|
||||
} else {
|
||||
LuaError(l, "Invalid field: %s" _C_ data);
|
||||
|
|
|
@ -46,6 +46,7 @@ $#include "settings.h"
|
|||
|
||||
struct SettingsPresets {
|
||||
int PlayerColor;
|
||||
string AIScript;
|
||||
int Race;
|
||||
int Team;
|
||||
int Type;
|
||||
|
|
Loading…
Reference in a new issue