// HQ administration belongs to AI; Core sees only ERR_AdminProvider. class ERR_HQAdminProvider : ERR_AdminProvider { protected ERR_HQ m_HQ; void ERR_HQAdminProvider(ERR_HQ hq) { m_HQ = hq; } override string Id() { return "hq"; } override void Capabilities(array values) { values.Insert("supports=hq"); } override string Setting(string section, string option) { if (section != "hq") return ""; if (option == "interval") return "reportIntervalSeconds"; if (option == "squads") return "supportSquadLimit"; if (option == "radius") return "responseRadiusMetres"; if (option == "stinger") return "stingerChanceOneIn"; return ""; } override int JournalSequence() { if (!m_HQ || !m_HQ.Journal()) return -1; return m_HQ.Journal().Sequence(); } override bool ReadJournal(int after, array lines, out int cursor, int limit = 8) { if (!m_HQ || !m_HQ.Journal()) return false; m_HQ.Journal().Read(after, lines, cursor, limit); return true; } // A saved chance changes only future individual startup rolls. It cannot // reroll registered soldiers or remove/replenish an issued physical launcher. protected void StingerSetting(ERR_GameMode mode, array parts, array replies) { string key = "stingerChanceOneIn"; string effect = "Only eligible actors which have not rolled yet use this chance; no reroll, removal or replenishment of existing equipment."; string range = "0 off, 1 every eligible soldier, 2..10000 one in N"; if (parts.Count() == 3 && parts[2] == "show") { replies.Insert(key + "=" + mode.Settings().Get(key).ToString() + ". " + effect); return; } int value; if (parts.Count() == 4 && parts[2] == "set" && ERR_CommandArguments.Integer(parts[3], value) && mode.Settings().Set(key, value)) replies.Insert(key + "=" + value.ToString() + " saved. " + effect); else if (parts.Count() == 3 && parts[2] == "help") replies.Insert(range + ". " + effect); else replies.Insert("Invalid value or settings could not be saved; previous setting retained. " + range + ". " + effect); } override bool Execute(ERR_GameMode mode, string arguments, array replies) { if (arguments.IndexOf("hq stinger ") == 0) { if (!m_HQ) { replies.Insert("HQ unavailable."); return true; } array parts = {}; arguments.Split(" ", parts, true); StingerSetting(mode, parts, replies); return true; } if (arguments != "status" && arguments != "hq show" && arguments != "hq log" && arguments != "hq memory" && arguments != "hq convoy show" && arguments != "hq convoy start") return false; if (!m_HQ) { replies.Insert("HQ unavailable."); return true; } if (arguments == "hq convoy start") { m_HQ.StartScenarioConvoy(); replies.Insert(m_HQ.ConvoyStatus()); return true; } if (arguments == "hq convoy show") { replies.Insert(m_HQ.ConvoyStatus()); return true; } if (arguments == "hq memory") { m_HQ.MemoryStatus(replies); return true; } if (arguments == "hq show" || arguments == "status") replies.Insert(m_HQ.Status()); else { int cursor; ReadJournal(Math.Max(0, JournalSequence() - 8), replies, cursor); if (replies.IsEmpty()) replies.Insert("HQ journal is empty."); } return true; } override bool Help(string topic, array replies) { if (topic != "hq") return false; replies.Insert("/esc hq show | hq memory | hq log show|next|set on|off | hq convoy show|start"); replies.Insert("/esc hq interval|squads|radius|stinger show|set N"); replies.Insert("Stinger: 0 off, 1 every eligible soldier, 2..10000 one in N; applies only before each actor rolls."); replies.Insert("HQ assigns available physical squads through delivered reports. Convoy start uses the single finite initial deployment; losses are not replaced."); return true; } }