Created
February 9, 2026 23:00
-
-
Save dderevjanik/11a7465c84efbfdd901fe54cdcc2ea8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ---@see augustus_core_api | |
| ---@see augustus_actions_api | |
| ---@see augustus_conditions_api | |
| -- ================================================== | |
| -- VALENTIA SCENARIO - Advanced Emperor Simulation | |
| -- ================================================== | |
| -- Emperor Complex Personality System | |
| local Emperor = { | |
| name = "Augustus", | |
| mood = "neutral", | |
| patience = 100, | |
| trust = 50, -- NEW: Trust level affects autonomy | |
| ambition = 70, -- NEW: Affects demands and expectations | |
| paranoia = 20, -- NEW: Increases with failures, triggers investigations | |
| generosity = 50, | |
| -- Personality traits affecting behavior | |
| traits = { | |
| pragmatic = 80, -- Prefers practical over idealistic decisions | |
| military_minded = 60, -- Values military strength | |
| cultured = 75, -- Appreciates arts and culture | |
| religious = 65, -- Cares about temples and gods | |
| economical = 70, -- Focuses on financial prosperity | |
| }, | |
| -- Dynamic expectations that evolve | |
| expectations = { | |
| min_prosperity = 20, | |
| min_culture = 15, | |
| min_peace = 30, | |
| min_favor = 40, | |
| prosperity_growth = 0, -- Expected growth per year | |
| culture_growth = 0, | |
| }, | |
| -- Tracking | |
| last_interaction_month = 0, | |
| gifts_given = 0, | |
| warnings_issued = 0, | |
| demands_made = 0, | |
| demands_fulfilled = 0, | |
| investigations = 0, | |
| -- Memory system | |
| memory = { | |
| recent_events = {}, -- Last 10 significant events | |
| performance_history = {}, -- Track ratings over time | |
| } | |
| } | |
| -- Rival Province System | |
| local RivalProvinces = { | |
| { name = "Tarraco", prosperity = 25, culture = 20, favor = 45, relation = "neutral" }, | |
| { name = "Carthago Nova", prosperity = 30, culture = 18, favor = 50, relation = "neutral" }, | |
| { name = "Corduba", prosperity = 22, culture = 25, favor = 42, relation = "friendly" } | |
| } | |
| -- Emperor Quest/Mission System | |
| local ImperialMissions = { | |
| active_mission = nil, | |
| available_missions = {}, | |
| completed_missions = 0, | |
| failed_missions = 0, | |
| } | |
| -- Mission Templates | |
| local MissionTemplates = { | |
| { | |
| id = "cultural_expansion", | |
| name = "Spread Roman Culture", | |
| description = "Build 3 cultural buildings", | |
| difficulty = "easy", | |
| rewards = { money = 2000, favor = 5 }, | |
| penalties = { favor = -3 }, | |
| check = function() | |
| local count = 0 | |
| if condition.building_count_any(COMPARE.GREATER_THAN, 0, BUILDING.THEATER) then count = count + 1 end | |
| if condition.building_count_any(COMPARE.GREATER_THAN, 0, BUILDING.AMPHITHEATER) then count = count + 1 end | |
| if condition.building_count_any(COMPARE.GREATER_THAN, 0, BUILDING.COLOSSEUM) then count = count + 1 end | |
| return count >= 3 | |
| end | |
| }, | |
| { | |
| id = "economic_boom", | |
| name = "Achieve Economic Prosperity", | |
| description = "Reach 10,000 denarii in treasury", | |
| difficulty = "medium", | |
| rewards = { money = 3000, favor = 8 }, | |
| penalties = { favor = -5, money = -1000 }, | |
| check = function() | |
| return condition.money(COMPARE.GREATER_THAN, 10000) | |
| end | |
| }, | |
| { | |
| id = "population_surge", | |
| name = "Grow the Population", | |
| description = "Reach population of 3000", | |
| difficulty = "medium", | |
| rewards = { money = 2500, favor = 6 }, | |
| penalties = { favor = -4 }, | |
| check = function() | |
| return condition.city_population(COMPARE.GREATER_THAN, 3000) | |
| end | |
| }, | |
| { | |
| id = "military_readiness", | |
| name = "Strengthen Defenses", | |
| description = "Build military academy and barracks", | |
| difficulty = "hard", | |
| rewards = { money = 4000, favor = 10 }, | |
| penalties = { favor = -8 }, | |
| check = function() | |
| return condition.building_count_any(COMPARE.GREATER_THAN, 0, BUILDING.MILITARY_ACADEMY) and | |
| condition.building_count_any(COMPARE.GREATER_THAN, 0, BUILDING.BARRACKS) | |
| end | |
| } | |
| } | |
| -- Custom Variables | |
| local GameState = { | |
| scenario_var_id = nil, | |
| reputation_var_id = nil, | |
| crisis_level = 0, | |
| seasons_of_prosperity = 0, | |
| seasons_of_decline = 0, | |
| last_prosperity = 0, | |
| political_intrigue_active = false, | |
| senate_investigation = false, | |
| } | |
| -- Historical Events System | |
| local HistoricalEvents = { | |
| { | |
| year = 3, | |
| month = 3, | |
| name = "senate_delegation", | |
| description = "A Senate delegation visits to inspect your governance", | |
| triggered = false | |
| }, | |
| { | |
| year = 5, | |
| month = 6, | |
| name = "trade_treaty", | |
| description = "Opportunity for lucrative trade treaty", | |
| triggered = false | |
| }, | |
| { | |
| year = 7, | |
| month = 9, | |
| name = "imperial_games", | |
| description = "Emperor demands games be held in his honor", | |
| triggered = false | |
| } | |
| } | |
| -- ================================================== | |
| -- UTILITY FUNCTIONS | |
| -- ================================================== | |
| -- Add event to Emperor's memory | |
| local function rememberEvent(event_type, impact) | |
| table.insert(Emperor.memory.recent_events, { | |
| year = game.year(), | |
| month = game.month(), | |
| type = event_type, | |
| impact = impact | |
| }) | |
| -- Keep only last 10 events | |
| if #Emperor.memory.recent_events > 10 then | |
| table.remove(Emperor.memory.recent_events, 1) | |
| end | |
| end | |
| -- Calculate Emperor's complex mood | |
| local function calculateEmperorMood() | |
| local favor = city.rating_favor() | |
| local prosperity = city.rating_prosperity() | |
| local culture = city.rating_culture() | |
| local peace = city.rating_peace() | |
| local treasury = finance.treasury() | |
| -- Weighted score based on Emperor's personality traits | |
| local score = 0 | |
| -- Base ratings check | |
| if favor >= Emperor.expectations.min_favor then | |
| score = score + (2 * Emperor.traits.pragmatic / 100) | |
| else | |
| score = score - 3 | |
| end | |
| if prosperity >= Emperor.expectations.min_prosperity then | |
| score = score + (2 * Emperor.traits.economical / 100) | |
| else | |
| score = score - 2 | |
| end | |
| if culture >= Emperor.expectations.min_culture then | |
| score = score + (1.5 * Emperor.traits.cultured / 100) | |
| else | |
| score = score - 1 | |
| end | |
| if peace >= Emperor.expectations.min_peace then | |
| score = score + (1 * Emperor.traits.military_minded / 100) | |
| else | |
| score = score - 2 | |
| end | |
| -- Treasury considerations | |
| if treasury > 10000 then | |
| score = score + 2 | |
| elseif treasury > 5000 then | |
| score = score + 1 | |
| elseif treasury < 1000 then | |
| score = score - 3 | |
| elseif treasury < 2000 then | |
| score = score - 1 | |
| end | |
| -- Adjust for trust and paranoia | |
| score = score + (Emperor.trust - 50) / 25 | |
| score = score - (Emperor.paranoia - 20) / 30 | |
| -- Recent performance trend | |
| if #Emperor.memory.performance_history >= 2 then | |
| local recent = Emperor.memory.performance_history[#Emperor.memory.performance_history] | |
| local previous = Emperor.memory.performance_history[#Emperor.memory.performance_history - 1] | |
| if recent > previous then | |
| score = score + 1 -- Improving trend | |
| elseif recent < previous then | |
| score = score - 1 -- Declining trend | |
| end | |
| end | |
| -- Mission success rate affects mood | |
| if ImperialMissions.completed_missions > 0 then | |
| local success_rate = ImperialMissions.completed_missions / | |
| (ImperialMissions.completed_missions + ImperialMissions.failed_missions) | |
| if success_rate > 0.7 then | |
| score = score + 1 | |
| elseif success_rate < 0.3 then | |
| score = score - 2 | |
| end | |
| end | |
| return score | |
| end | |
| -- Update Emperor's mood and traits | |
| local function updateEmperorState() | |
| local score = calculateEmperorMood() | |
| local old_mood = Emperor.mood | |
| -- Update mood | |
| if score >= 5 then | |
| Emperor.mood = "happy" | |
| Emperor.patience = math.min(100, Emperor.patience + 3) | |
| Emperor.trust = math.min(100, Emperor.trust + 2) | |
| Emperor.paranoia = math.max(0, Emperor.paranoia - 2) | |
| elseif score >= 2 then | |
| Emperor.mood = "content" | |
| Emperor.patience = math.min(100, Emperor.patience + 1) | |
| Emperor.trust = math.min(100, Emperor.trust + 1) | |
| elseif score >= -1 then | |
| Emperor.mood = "neutral" | |
| Emperor.paranoia = math.min(100, Emperor.paranoia + 1) | |
| elseif score >= -3 then | |
| Emperor.mood = "displeased" | |
| Emperor.patience = math.max(0, Emperor.patience - 5) | |
| Emperor.trust = math.max(0, Emperor.trust - 2) | |
| Emperor.paranoia = math.min(100, Emperor.paranoia + 3) | |
| else | |
| Emperor.mood = "angry" | |
| Emperor.patience = math.max(0, Emperor.patience - 10) | |
| Emperor.trust = math.max(0, Emperor.trust - 5) | |
| Emperor.paranoia = math.min(100, Emperor.paranoia + 5) | |
| end | |
| -- Track performance | |
| local perf_score = (city.rating_favor() + city.rating_prosperity() + | |
| city.rating_culture() + city.rating_peace()) / 4 | |
| table.insert(Emperor.memory.performance_history, perf_score) | |
| if #Emperor.memory.performance_history > 12 then | |
| table.remove(Emperor.memory.performance_history, 1) | |
| end | |
| return old_mood ~= Emperor.mood, score | |
| end | |
| -- Emperor's sophisticated action system | |
| local function emperorTakesAction() | |
| local favor = city.rating_favor() | |
| local prosperity = city.rating_prosperity() | |
| -- High paranoia triggers investigation | |
| if Emperor.paranoia > 70 and not GameState.senate_investigation then | |
| if math.random(1, 100) <= 25 then | |
| GameState.senate_investigation = true | |
| Emperor.investigations = Emperor.investigations + 1 | |
| ui.show_warning("ALERT: The Senate has ordered an investigation into your governance!") | |
| ui.show_warning("Improve all ratings immediately or face severe consequences!") | |
| action.adjust_favor(-5) | |
| rememberEvent("investigation_started", -10) | |
| return | |
| end | |
| end | |
| -- Senate investigation consequences | |
| if GameState.senate_investigation then | |
| if favor >= 50 and prosperity >= 35 then | |
| GameState.senate_investigation = false | |
| ui.show_warning("Investigation concluded: You are cleared of wrongdoing!") | |
| action.adjust_favor(3) | |
| Emperor.paranoia = math.max(0, Emperor.paranoia - 20) | |
| Emperor.trust = math.min(100, Emperor.trust + 10) | |
| rememberEvent("investigation_cleared", 10) | |
| elseif game.year() > 0 and game.month() % 3 == 0 then | |
| ui.show_warning("Senate investigation ongoing... Improve your performance!") | |
| action.adjust_favor(-2) | |
| end | |
| end | |
| if Emperor.mood == "happy" then | |
| -- Generous gifts | |
| if math.random(1, 100) <= Emperor.generosity then | |
| local gift = math.random(1000, 3000) | |
| action.adjust_money(gift) | |
| Emperor.gifts_given = Emperor.gifts_given + 1 | |
| ui.show_warning("Emperor Augustus rewards your excellence with " .. gift .. " denarii!") | |
| rememberEvent("gift_received", gift / 100) | |
| end | |
| -- May open trade routes or reduce prices | |
| if math.random(1, 100) <= 20 then | |
| ui.show_warning("The Emperor's favor brings prosperity to trade!") | |
| action.adjust_money(500) | |
| end | |
| -- Occasionally bestows military support | |
| if Emperor.traits.military_minded > 60 and math.random(1, 100) <= 15 then | |
| ui.show_warning("Augustus sends military advisors to strengthen your defenses!") | |
| action.adjust_favor(2) | |
| end | |
| elseif Emperor.mood == "content" then | |
| -- Encouragement and small bonuses | |
| if math.random(1, 100) <= 40 then | |
| action.adjust_favor(math.random(1, 2)) | |
| ui.show_warning("The Emperor sends words of praise!") | |
| end | |
| elseif Emperor.mood == "displeased" then | |
| -- Warnings and pressure | |
| Emperor.warnings_issued = Emperor.warnings_issued + 1 | |
| ui.show_warning("Augustus is displeased! Your ratings are below expectations!") | |
| if math.random(1, 100) <= 50 then | |
| action.adjust_favor(-math.random(1, 3)) | |
| rememberEvent("favor_penalty", -2) | |
| end | |
| -- May send rival province comparison | |
| if math.random(1, 100) <= 30 then | |
| local rival = RivalProvinces[math.random(1, #RivalProvinces)] | |
| ui.show_warning(rival.name .. " outperforms Valentia! The Emperor takes notice...") | |
| rememberEvent("unfavorable_comparison", -3) | |
| end | |
| elseif Emperor.mood == "angry" then | |
| -- Severe consequences | |
| ui.show_warning("EMPEROR'S WRATH: " .. getEmperorMessage("angry")) | |
| action.adjust_favor(-math.random(3, 7)) | |
| -- Economic sanctions | |
| if math.random(1, 100) <= 40 then | |
| local fine = math.random(500, 1500) | |
| action.adjust_money(-fine) | |
| ui.show_warning("Rome imposes economic sanctions: -" .. fine .. " denarii!") | |
| rememberEvent("sanctions", -fine / 100) | |
| end | |
| -- May trigger crisis events | |
| if math.random(1, 100) <= 20 then | |
| ui.show_warning("The Emperor's anger disrupts trade routes!") | |
| action.trade_problem_land() | |
| rememberEvent("trade_disruption", -5) | |
| end | |
| -- Critical: Threat of removal | |
| if Emperor.patience <= 20 then | |
| ui.show_warning("WARNING: The Emperor prepares to remove you from office!") | |
| ui.show_warning("Patience: " .. Emperor.patience .. "/100 - Improve immediately!") | |
| end | |
| if Emperor.patience <= 0 then | |
| ui.show_warning("Augustus has lost all patience with your incompetence!") | |
| ui.show_warning("You are REMOVED FROM OFFICE in disgrace!") | |
| action.lose() | |
| end | |
| end | |
| end | |
| -- Mission System | |
| local function createNewMission() | |
| if ImperialMissions.active_mission then return end | |
| -- Select mission based on Emperor's personality | |
| local available = {} | |
| for _, template in ipairs(MissionTemplates) do | |
| -- Weight missions by Emperor's traits | |
| local weight = 1 | |
| if template.id == "cultural_expansion" then | |
| weight = Emperor.traits.cultured / 50 | |
| elseif template.id == "economic_boom" then | |
| weight = Emperor.traits.economical / 50 | |
| elseif template.id == "military_readiness" then | |
| weight = Emperor.traits.military_minded / 50 | |
| end | |
| if math.random() < weight then | |
| table.insert(available, template) | |
| end | |
| end | |
| if #available > 0 then | |
| local mission = available[math.random(1, #available)] | |
| ImperialMissions.active_mission = { | |
| template = mission, | |
| assigned_year = game.year(), | |
| assigned_month = game.month(), | |
| deadline_months = math.random(12, 24) | |
| } | |
| Emperor.demands_made = Emperor.demands_made + 1 | |
| ui.show_warning("IMPERIAL MISSION: " .. mission.name) | |
| ui.show_warning(mission.description) | |
| ui.show_warning("Complete within " .. ImperialMissions.active_mission.deadline_months .. " months!") | |
| ui.log("Mission assigned: " .. mission.id) | |
| end | |
| end | |
| local function checkActiveMission() | |
| if not ImperialMissions.active_mission then return end | |
| local mission = ImperialMissions.active_mission | |
| local elapsed_months = (game.year() - mission.assigned_year) * 12 + | |
| (game.month() - mission.assigned_month) | |
| -- Check if completed | |
| if mission.template.check() then | |
| ImperialMissions.completed_missions = ImperialMissions.completed_missions + 1 | |
| Emperor.demands_fulfilled = Emperor.demands_fulfilled + 1 | |
| ui.show_warning("MISSION COMPLETE: " .. mission.template.name .. "!") | |
| ui.show_warning("Rewards: " .. mission.template.rewards.money .. " denarii, +" .. | |
| mission.template.rewards.favor .. " favor") | |
| action.adjust_money(mission.template.rewards.money) | |
| action.adjust_favor(mission.template.rewards.favor) | |
| Emperor.trust = math.min(100, Emperor.trust + 5) | |
| rememberEvent("mission_success", 10) | |
| ImperialMissions.active_mission = nil | |
| -- Check if deadline passed | |
| elseif elapsed_months >= mission.deadline_months then | |
| ImperialMissions.failed_missions = ImperialMissions.failed_missions + 1 | |
| ui.show_warning("MISSION FAILED: " .. mission.template.name) | |
| ui.show_warning("The Emperor is deeply disappointed!") | |
| ui.show_warning("Penalties: -" .. mission.template.penalties.favor .. " favor") | |
| action.adjust_favor(-mission.template.penalties.favor) | |
| if mission.template.penalties.money then | |
| action.adjust_money(-mission.template.penalties.money) | |
| end | |
| Emperor.trust = math.max(0, Emperor.trust - 10) | |
| Emperor.paranoia = math.min(100, Emperor.paranoia + 10) | |
| rememberEvent("mission_failure", -10) | |
| ImperialMissions.active_mission = nil | |
| -- Deadline warning | |
| elseif elapsed_months == mission.deadline_months - 3 then | |
| ui.show_warning("REMINDER: Mission deadline approaching! " .. | |
| (mission.deadline_months - elapsed_months) .. " months remain!") | |
| end | |
| end | |
| -- Rival Province System | |
| local function updateRivalProvinces() | |
| for _, rival in ipairs(RivalProvinces) do | |
| -- Rivals also develop over time | |
| rival.prosperity = math.max(0, math.min(100, rival.prosperity + math.random(-2, 3))) | |
| rival.culture = math.max(0, math.min(100, rival.culture + math.random(-2, 3))) | |
| rival.favor = math.max(0, math.min(100, rival.favor + math.random(-3, 3))) | |
| -- Compare with player | |
| local player_avg = (city.rating_favor() + city.rating_prosperity() + | |
| city.rating_culture()) / 3 | |
| local rival_avg = (rival.favor + rival.prosperity + rival.culture) / 3 | |
| if rival_avg > player_avg + 15 then | |
| if rival.relation ~= "rival" then | |
| rival.relation = "rival" | |
| ui.show_warning(rival.name .. " surpasses Valentia! They may replace you as the Emperor's favorite!") | |
| Emperor.paranoia = math.min(100, Emperor.paranoia + 5) | |
| end | |
| elseif player_avg > rival_avg + 15 then | |
| rival.relation = "inferior" | |
| else | |
| rival.relation = "neutral" | |
| end | |
| end | |
| end | |
| -- Historical Event Triggers | |
| local function checkHistoricalEvents() | |
| for _, event in ipairs(HistoricalEvents) do | |
| if not event.triggered and game.year() == event.year and game.month() == event.month then | |
| event.triggered = true | |
| if event.name == "senate_delegation" then | |
| ui.show_warning("A Senate delegation arrives to inspect Valentia!") | |
| if city.rating_favor() >= 50 then | |
| ui.show_warning("The delegation is impressed! +500 denarii, +5 favor") | |
| action.adjust_money(500) | |
| action.adjust_favor(5) | |
| Emperor.trust = math.min(100, Emperor.trust + 10) | |
| else | |
| ui.show_warning("The delegation reports concerning findings to Rome...") | |
| action.adjust_favor(-5) | |
| Emperor.paranoia = math.min(100, Emperor.paranoia + 15) | |
| end | |
| elseif event.name == "trade_treaty" then | |
| if finance.treasury() >= 3000 then | |
| ui.show_warning("Trade Treaty Opportunity: Pay 3000 Dn for +15% prosperity boost?") | |
| ui.show_warning("(Auto-accepted if you have funds)") | |
| action.adjust_money(-3000) | |
| action.change_city_rating(0, 10, false) -- Boost prosperity | |
| ui.show_warning("Treaty signed! Prosperity increases!") | |
| else | |
| ui.show_warning("Trade treaty opportunity missed - insufficient funds!") | |
| action.adjust_favor(-3) | |
| end | |
| elseif event.name == "imperial_games" then | |
| ui.show_warning("The Emperor demands games be held in his honor!") | |
| if condition.building_count_any(COMPARE.GREATER_THAN, 0, BUILDING.COLOSSEUM) or | |
| condition.building_count_any(COMPARE.GREATER_THAN, 0, BUILDING.HIPPODROME) then | |
| ui.show_warning("Your venues host magnificent games! +10 favor") | |
| action.adjust_favor(10) | |
| action.adjust_money(-1000) -- Cost of games | |
| Emperor.trust = math.min(100, Emperor.trust + 5) | |
| else | |
| ui.show_warning("Without proper venues, the games are disappointing...") | |
| action.adjust_favor(-8) | |
| Emperor.paranoia = math.min(100, Emperor.paranoia + 10) | |
| end | |
| end | |
| end | |
| end | |
| end | |
| -- ================================================== | |
| -- MESSAGE SYSTEM | |
| -- ================================================== | |
| local MOOD_CHECK_INTERVAL = 3 | |
| -- Emperor mood messages based on personality | |
| local EmperorMessages = { | |
| happy = { | |
| "The Emperor is greatly pleased with Valentia's progress!", | |
| "Augustus sends his warmest congratulations!", | |
| "Roma applauds your excellent governance!", | |
| "The Emperor considers Valentia a model for all provinces!", | |
| "Your loyalty and competence bring honor to Rome!" | |
| }, | |
| content = { | |
| "The Emperor finds your progress satisfactory.", | |
| "Augustus is pleased with Valentia's development.", | |
| "Your efforts have been noted favorably in Rome.", | |
| "Continue this course and greater rewards await." | |
| }, | |
| neutral = { | |
| "The Emperor watches Valentia with interest.", | |
| "Augustus expects continued progress from you.", | |
| "Rome awaits news of your achievements.", | |
| "The Senate debates your performance..." | |
| }, | |
| displeased = { | |
| "The Emperor is growing impatient with Valentia's progress...", | |
| "Augustus questions your competence as governor.", | |
| "Rome expects better results from this province!", | |
| "Your management displeases the Emperor!", | |
| "Rival provinces outpace your development!" | |
| }, | |
| angry = { | |
| "The Emperor's patience wears thin! Improve immediately!", | |
| "Augustus contemplates replacing you as governor!", | |
| "This is your final warning from Rome!", | |
| "The Emperor demands immediate improvements or face consequences!", | |
| "Your failures shame the glory of Rome!" | |
| } | |
| } | |
| -- Random message from mood category | |
| local function getEmperorMessage(mood) | |
| local messages = EmperorMessages[mood] or EmperorMessages.neutral | |
| return messages[math.random(1, #messages)] | |
| end | |
| -- ================================================== | |
| -- SCENARIO HOOKS | |
| -- ================================================== | |
| function on_load() | |
| ui.log("========================================") | |
| ui.log("VALENTIA SCENARIO - ADVANCED SIMULATION") | |
| ui.log("========================================") | |
| ui.log("Emperor: " .. Emperor.name) | |
| ui.log("Personality Traits:") | |
| ui.log(" Pragmatic: " .. Emperor.traits.pragmatic) | |
| ui.log(" Military: " .. Emperor.traits.military_minded) | |
| ui.log(" Cultured: " .. Emperor.traits.cultured) | |
| ui.log(" Religious: " .. Emperor.traits.religious) | |
| ui.log(" Economic: " .. Emperor.traits.economical) | |
| ui.log("========================================") | |
| ui.show_warning("Welcome to Valentia, Governor!") | |
| ui.show_warning("Emperor Augustus watches your every move...") | |
| ui.show_warning("Prove your worth to Rome!") | |
| -- Initialize custom variables | |
| GameState.scenario_var_id = scenario.create_variable("valentia_reputation", 50) | |
| GameState.reputation_var_id = scenario.create_variable("crisis_level", 0) | |
| -- Set random seed | |
| math.randomseed(game.year() * 1000 + game.month() * 100 + game.day()) | |
| -- Record initial state | |
| table.insert(Emperor.memory.performance_history, | |
| (city.rating_favor() + city.rating_prosperity() + | |
| city.rating_culture() + city.rating_peace()) / 4) | |
| end | |
| function on_tick() | |
| -- Daily monitoring | |
| if game.day() == 0 then | |
| -- Critical situations | |
| if condition.money(COMPARE.LESS_THAN, 300) then | |
| ui.show_warning("CRISIS: Treasury near bankruptcy!") | |
| GameState.crisis_level = GameState.crisis_level + 1 | |
| end | |
| if condition.unemployment(true, COMPARE.GREATER_THAN, 20) then | |
| ui.show_warning("ALERT: Unemployment crisis threatens stability!") | |
| GameState.crisis_level = GameState.crisis_level + 1 | |
| end | |
| -- Health emergencies | |
| if condition.city_health(COMPARE.LESS_THAN, 30) then | |
| ui.show_warning("Public health emergency! Disease spreads!") | |
| if math.random(1, 100) <= 30 then | |
| action.adjust_city_health(-5, false) | |
| end | |
| end | |
| end | |
| -- Weekly checks (every 4 days) | |
| if game.day() % 4 == 0 then | |
| -- Crisis escalation | |
| if GameState.crisis_level > 5 then | |
| if math.random(1, 100) <= 20 then | |
| ui.show_warning("Multiple crises strain your governance!") | |
| action.pop_sentiment_change(-5, false) | |
| end | |
| end | |
| end | |
| end | |
| function on_month() | |
| local current_month = game.year() * 12 + game.month() | |
| -- Update reputation variable | |
| local reputation = (city.rating_favor() + city.rating_prosperity()) / 2 | |
| scenario.set_variable(GameState.scenario_var_id, math.floor(reputation)) | |
| scenario.set_variable(GameState.reputation_var_id, GameState.crisis_level) | |
| -- Emperor evaluation cycle | |
| if current_month - Emperor.last_interaction_month >= MOOD_CHECK_INTERVAL then | |
| Emperor.last_interaction_month = current_month | |
| local mood_changed, score = updateEmperorState() | |
| if mood_changed then | |
| ui.show_warning("=== IMPERIAL EVALUATION ===") | |
| ui.show_warning(getEmperorMessage(Emperor.mood)) | |
| ui.log("Emperor State - Mood: " .. Emperor.mood .. " | Patience: " .. Emperor.patience .. | |
| " | Trust: " .. Emperor.trust .. " | Paranoia: " .. Emperor.paranoia) | |
| ui.log("Performance Score: " .. string.format("%.1f", score)) | |
| end | |
| -- Emperor takes action | |
| emperorTakesAction() | |
| -- Check for new missions | |
| if math.random(1, 100) <= 30 and not ImperialMissions.active_mission then | |
| createNewMission() | |
| end | |
| -- Update rival provinces | |
| updateRivalProvinces() | |
| end | |
| -- Check active mission progress | |
| checkActiveMission() | |
| -- Check for historical events | |
| checkHistoricalEvents() | |
| -- Track prosperity trends | |
| local current_prosperity = city.rating_prosperity() | |
| if current_prosperity > GameState.last_prosperity then | |
| GameState.seasons_of_prosperity = GameState.seasons_of_prosperity + 1 | |
| GameState.seasons_of_decline = 0 | |
| elseif current_prosperity < GameState.last_prosperity then | |
| GameState.seasons_of_decline = GameState.seasons_of_decline + 1 | |
| GameState.seasons_of_prosperity = 0 | |
| end | |
| GameState.last_prosperity = current_prosperity | |
| -- Prosperity milestones | |
| if GameState.seasons_of_prosperity == 6 then | |
| ui.show_warning("Six months of growth! The Emperor takes favorable notice!") | |
| action.adjust_favor(3) | |
| Emperor.trust = math.min(100, Emperor.trust + 5) | |
| elseif GameState.seasons_of_decline == 6 then | |
| ui.show_warning("Six months of decline... Rome grows concerned!") | |
| action.adjust_favor(-3) | |
| Emperor.paranoia = math.min(100, Emperor.paranoia + 5) | |
| end | |
| -- Crisis cooldown | |
| if GameState.crisis_level > 0 then | |
| GameState.crisis_level = math.max(0, GameState.crisis_level - 1) | |
| end | |
| -- Monthly status | |
| ui.log(string.format("Month %d/%d - Pop: %d | Treasury: %d | Favor: %d | Mood: %s", | |
| game.month() + 1, game.year(), city.population(), finance.treasury(), | |
| city.rating_favor(), Emperor.mood)) | |
| end | |
| function on_year() | |
| ui.show_warning("=== YEAR " .. game.year() .. " BEGINS ===") | |
| -- Comprehensive annual review | |
| local favor = city.rating_favor() | |
| local prosperity = city.rating_prosperity() | |
| local culture = city.rating_culture() | |
| local peace = city.rating_peace() | |
| local pop = city.population() | |
| ui.log("=== ANNUAL IMPERIAL REVIEW ===") | |
| ui.log("Favor: " .. favor .. " | Prosperity: " .. prosperity) | |
| ui.log("Culture: " .. culture .. " | Peace: " .. peace) | |
| ui.log("Population: " .. pop) | |
| ui.log("Emperor Mood: " .. Emperor.mood) | |
| ui.log("Trust: " .. Emperor.trust .. " | Paranoia: " .. Emperor.paranoia .. " | Patience: " .. Emperor.patience) | |
| ui.log("Missions: " .. ImperialMissions.completed_missions .. " completed, " .. | |
| ImperialMissions.failed_missions .. " failed") | |
| ui.log("Gifts Received: " .. Emperor.gifts_given .. " | Warnings: " .. Emperor.warnings_issued) | |
| -- Performance-based outcomes | |
| local avg_rating = (favor + prosperity + culture + peace) / 4 | |
| if avg_rating >= 60 then | |
| local bonus = math.random(500, 1500) | |
| action.adjust_money(bonus) | |
| ui.show_warning("EXCELLENT YEAR! Augustus rewards you with " .. bonus .. " denarii!") | |
| Emperor.generosity = math.min(100, Emperor.generosity + 5) | |
| elseif avg_rating >= 40 then | |
| ui.show_warning("Solid performance. Rome acknowledges your efforts.") | |
| action.adjust_favor(2) | |
| elseif avg_rating >= 25 then | |
| ui.show_warning("Mediocre year. The Emperor expects improvement.") | |
| else | |
| ui.show_warning("POOR PERFORMANCE! Rome questions your leadership!") | |
| action.adjust_favor(-5) | |
| local penalty = math.random(300, 800) | |
| action.adjust_money(-penalty) | |
| ui.show_warning("Penalty imposed: -" .. penalty .. " denarii") | |
| end | |
| -- Evolve Emperor's expectations | |
| if avg_rating >= 50 then | |
| Emperor.expectations.min_prosperity = math.min(60, Emperor.expectations.min_prosperity + 2) | |
| Emperor.expectations.min_culture = math.min(50, Emperor.expectations.min_culture + 2) | |
| ui.log("Emperor raises expectations due to your success") | |
| end | |
| -- Rival province annual update | |
| for _, rival in ipairs(RivalProvinces) do | |
| if rival.relation == "rival" then | |
| ui.show_warning("Rival alert: " .. rival.name .. " (Favor: " .. rival.favor .. | |
| " | Prosperity: " .. rival.prosperity .. ")") | |
| end | |
| end | |
| end | |
| function on_event(name) | |
| ui.log("Event triggered: " .. name) | |
| rememberEvent(name, 0) | |
| -- Emperor's disaster response based on mood and trust | |
| if name == "earthquake" or name == "fire" or name == "collapse" then | |
| local aid_chance = 20 + (Emperor.trust - 50) + (Emperor.generosity - 50) / 2 | |
| if Emperor.mood == "happy" or Emperor.mood == "content" then | |
| if math.random(1, 100) <= aid_chance then | |
| local aid = math.random(2000, 5000) | |
| action.adjust_money(aid) | |
| ui.show_warning("Emperor sends disaster relief: " .. aid .. " denarii!") | |
| ui.show_warning("Augustus: 'Rome takes care of its loyal servants!'") | |
| rememberEvent("imperial_aid", aid / 100) | |
| else | |
| ui.show_warning("Disaster strikes! Local resources must suffice.") | |
| end | |
| else | |
| ui.show_warning("Disaster strikes! Rome offers no assistance in your time of need...") | |
| if Emperor.mood == "angry" then | |
| ui.show_warning("'Perhaps this will teach you better governance!' - Augustus") | |
| end | |
| end | |
| end | |
| end | |
| function on_building_placed(building_type, x, y, building_id) | |
| -- Emperor reacts to specific building types | |
| local cultural_buildings = { | |
| BUILDING.THEATER, BUILDING.AMPHITHEATER, BUILDING.COLOSSEUM, | |
| BUILDING.HIPPODROME, BUILDING.LIBRARY, BUILDING.ACADEMY | |
| } | |
| local religious_buildings = { | |
| BUILDING.SMALL_TEMPLE_CERES, BUILDING.SMALL_TEMPLE_NEPTUNE, | |
| BUILDING.SMALL_TEMPLE_MERCURY, BUILDING.SMALL_TEMPLE_MARS, | |
| BUILDING.SMALL_TEMPLE_VENUS, BUILDING.LARGE_TEMPLE_CERES, | |
| BUILDING.LARGE_TEMPLE_NEPTUNE, BUILDING.LARGE_TEMPLE_MERCURY, | |
| BUILDING.LARGE_TEMPLE_MARS, BUILDING.LARGE_TEMPLE_VENUS | |
| } | |
| local military_buildings = { | |
| BUILDING.FORT_LEGIONARIES, BUILDING.FORT_JAVELIN, BUILDING.FORT_MOUNTED, | |
| BUILDING.MILITARY_ACADEMY, BUILDING.BARRACKS | |
| } | |
| -- Cultural appreciation | |
| for _, btype in ipairs(cultural_buildings) do | |
| if building_type == btype and Emperor.traits.cultured > 60 then | |
| if math.random(1, 100) <= 25 then | |
| ui.show_warning("The Emperor praises your cultural investment!") | |
| action.adjust_favor(1) | |
| rememberEvent("cultural_building", 1) | |
| return | |
| end | |
| end | |
| end | |
| -- Religious appreciation | |
| for _, btype in ipairs(religious_buildings) do | |
| if building_type == btype and Emperor.traits.religious > 60 then | |
| if math.random(1, 100) <= 20 then | |
| ui.show_warning("Augustus approves of your piety!") | |
| action.adjust_favor(1) | |
| return | |
| end | |
| end | |
| end | |
| -- Military appreciation | |
| for _, btype in ipairs(military_buildings) do | |
| if building_type == btype and Emperor.traits.military_minded > 60 then | |
| if math.random(1, 100) <= 20 then | |
| ui.show_warning("Rome commends your military preparations!") | |
| action.adjust_favor(1) | |
| return | |
| end | |
| end | |
| end | |
| end | |
| function on_building_destroyed(building_type, x, y, building_id) | |
| -- Emperor's concern over important buildings | |
| local critical_buildings = { | |
| BUILDING.FORUM, BUILDING.SENATE, BUILDING.GOVERNORS_PALACE, | |
| BUILDING.GOVERNORS_VILLA, BUILDING.GOVERNORS_HOUSE | |
| } | |
| for _, btype in ipairs(critical_buildings) do | |
| if building_type == btype then | |
| ui.show_warning("The destruction of important buildings concerns Rome!") | |
| if Emperor.mood == "angry" or Emperor.mood == "displeased" then | |
| action.adjust_favor(-2) | |
| Emperor.paranoia = math.min(100, Emperor.paranoia + 5) | |
| ui.show_warning("The Emperor suspects negligence or treachery!") | |
| end | |
| rememberEvent("critical_destruction", -5) | |
| return | |
| end | |
| end | |
| end | |
| function on_victory() | |
| ui.show_warning("========================================") | |
| ui.show_warning(" GLORIOUS VICTORY!") | |
| ui.show_warning("========================================") | |
| ui.show_warning("Valentia prospers under your masterful rule!") | |
| ui.show_warning("Emperor " .. Emperor.name .. " honors you with a triumph in Rome!") | |
| ui.log("=== FINAL STATISTICS ===") | |
| ui.log("Emperor Final Mood: " .. Emperor.mood) | |
| ui.log("Trust: " .. Emperor.trust .. " | Paranoia: " .. Emperor.paranoia) | |
| ui.log("Gifts Received: " .. Emperor.gifts_given) | |
| ui.log("Missions Completed: " .. ImperialMissions.completed_missions .. "/" .. | |
| (ImperialMissions.completed_missions + ImperialMissions.failed_missions)) | |
| ui.log("Warnings Issued: " .. Emperor.warnings_issued) | |
| ui.log("Investigations: " .. Emperor.investigations) | |
| if Emperor.mood == "happy" and Emperor.trust > 80 then | |
| ui.show_warning("You are declared 'Friend of Rome' - the highest honor!") | |
| elseif Emperor.mood == "content" then | |
| ui.show_warning("Your competence is recognized across the Empire!") | |
| else | |
| ui.show_warning("Victory achieved, though your relationship with Rome remains strained...") | |
| end | |
| end | |
| function on_defeat() | |
| ui.show_warning("========================================") | |
| ui.show_warning(" DEFEAT") | |
| ui.show_warning("========================================") | |
| ui.show_warning("You have failed Valentia and disappointed Rome.") | |
| ui.show_warning("Emperor " .. Emperor.name .. " removes you from office in disgrace.") | |
| ui.log("=== DEFEAT ANALYSIS ===") | |
| ui.log("Final Emperor Mood: " .. Emperor.mood) | |
| ui.log("Final Trust: " .. Emperor.trust .. " | Paranoia: " .. Emperor.paranoia) | |
| ui.log("Total Warnings: " .. Emperor.warnings_issued) | |
| ui.log("Investigations: " .. Emperor.investigations) | |
| ui.log("Mission Success Rate: " .. ImperialMissions.completed_missions .. "/" .. | |
| (ImperialMissions.completed_missions + ImperialMissions.failed_missions)) | |
| if Emperor.patience <= 0 then | |
| ui.show_warning("The Emperor's patience was exhausted...") | |
| end | |
| if Emperor.paranoia > 70 then | |
| ui.show_warning("Your actions bred deep suspicion in Rome...") | |
| end | |
| ui.show_warning("Your name will be forgotten by history.") | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment