Events system brainstorm

I'm having trouble getting the disabled tool tip to work. It's just ignoring the tag and treating it like it's not there.

Code:
    <Table name="CityEventChoices">
        <!-- You can make as many choices as you want - the window show expand (with a scroll bar) to acommodate them. But be reasonable! :) -->
        <!-- Note - if NOT a multiple-choice event, only make one of these! -->
        <Column name="ID" type="integer" primarykey="true" autoincrement="true"/>
        <Column name="Type" type="text" notnull="true" unique="true"/>
        <Column name="Description" type="text" reference="Language_en_US(Tag)"/>
        <!-- Help is used for Tooltips, Description for button text -->
        <Column name="Help" type="text" reference="Language_en_US(Tag)"/>
        <!-- DisabledTooltip is used for Tooltips for choices that are not active but appear in choice list.
        The DLL automatically explains to players WHY an event choice is unavailable, however you can use it you want to override the DLL. -->
        <Column name="DisabledTooltip" type="text" reference="Language_en_US(Tag)"/>

Is there something with the DLL that is preventing it from working? I checked the SQL databases and the value is showing up on the correct column, and the text is showing up in the correct place.

I'd like to be able to use the disabled tool tip as I build out events so I can hide choices that aren't available yet to keep some suspense for what is yet to come. You don't need to know what choices you are unlocking in the future with your selection because you should be living in the moment.

In case it matters, I am using CP 3.10.14.
 
Lofty goal, but it will only really work the first time someone sees the event...

As to the functionality, as I understand it does not hide the choice, it just affects the red text that appears when you hover over a disabled option (which the DLL usually auto-populates by telling you what you are missing).
 
Lofty goal, but it will only really work the first time someone sees the event...

As to the functionality, as I understand it does not hide the choice, it just affects the red text that appears when you hover over a disabled option (which the DLL usually auto-populates by telling you what you are missing).
That's pretty much my goal. I don't care if they know that a reward event is coming (well, I do but that may be for later hiding it would a ton of extra work while I'm still trying to develop the overall system), but I don't want them to see that for choice number X, they need to do Y for it to be available. I just want choice number X blocked with a note that says, "Sorry, not yet" so the player doesn't try to force those conditions. I want them organically grown into. Instead, the game is completely ignoring my DisabledToolTip text and using the default one.
 
Ok! I'm not sure if this has ever been used before so it may just not work.
Are you giving it a reference to a tag/text pair in Language_en_US?

Yes, I am.

Spoiler Event Code :

INSERT INTO CityEventChoices(Type,Description,Help,DisabledTooltip,EventChoiceAudio,EventChance,IsOneShot,EraScaling,EventDuration,Expires,MinimumCityPopulation,MaximumCityPopulation,RequiredCiv,RequiredEra,IsUnhappy,IsSuperUnhappy,ObsoleteEra,RequiredPolicy,RequiredIdeology,RequiresWar,RequiresWarMinor,PrereqTech,ObsoleteTech,RequiresPantheon,RequiredReligion,RequiredStateReligion,RequiresAnyStateReligion,RequiredBuildingClass,CannotHaveBuildingClass,RequiresHolyCity,RequiresIdeology,NearbyFeature,NearbyTerrain,LocalResourceRequired,HasTradeConnection,HasCityConnection,RequiresGarrison,CapitalOnly,CoastalOnly,RiverOnly,RequiresResistance,RequiresWLTKD,RequiresOccupied,RequiresRazing,HasAnyReligion,RequiresPuppet,RequiresNearbyNaturalWonder,RequiresNearbyMountain,EventBuildingClassDestruction,EventBuildingClass,CityWideBuildingDestructionChance,WLTKDTurns,ResistanceTurns,CityHappiness,RandomBarbarianSpawn,ConvertToPlayerReligionPercent,ConvertToPlayerMajorityReligionPercent,ImprovementRequired,FreeUnitsTechAppropriate,HasMetAMajorCiv,InDebt,LosingMoney,IsVassalOfSomeone,IsMasterOfSomeone,CityHasPlayerReligion,CityLacksPlayerReligion,CityHasPlayerMajorityReligion,CityLacksPlayerMajorityReligion,BasicNeedsMedianModifier,GoldMedianModifier,ScienceMedianModifier,CultureMedianModifier,ReligiousUnrestModifier) VALUES

('CITY_EVENT_NW_MT_KAILASH_CHOICE_1','TXT_KEY_CITY_EVENT_NW_MT_KAILASH_CHOICE_1','TXT_KEY_CITY_EVENT_NW_MT_KAILASH_CHOICE_1_HELP','TXT_KEY_CITY_EVENT_NW_DISABLED_HELP','AS2D_EVENT_CHOICE',0,'false','false',30,'false',0,0,NULL,NULL,'false','false',NULL,NULL,NULL,'false','false',NULL,NULL,'false',NULL,NULL,'false',NULL,NULL,'false','false',NULL,NULL,NULL,'false','false','false','false','false','false','false','false','false','false','false','false','false','false',NULL,NULL,0,0,0,0,0,0,0,NULL,0,'false','false','false','false','false','false','false','false','false',0,0,0,0,0),

('CITY_EVENT_NW_MT_KAILASH_CHOICE_2','TXT_KEY_CITY_EVENT_NW_MT_KAILASH_CHOICE_2','TXT_KEY_CITY_EVENT_NW_MT_KAILASH_CHOICE_2_HELP','TXT_KEY_CITY_EVENT_NW_DISABLED_HELP','AS2D_EVENT_CHOICE',0,'true','false',30,'false',0,0,NULL,NULL,'false','false',NULL,NULL,NULL,'false','false','TECH_CURRENCY',NULL,'false',NULL,NULL,'false',NULL,NULL,'false','false',NULL,NULL,NULL,'false','false','false','false','false','false','false','false','false','false','false','false','false','false',NULL,'BUILDINGCLASS_MANDIR',0,0,0,0,0,0,0,NULL,0,'false','false','false','false','false','false','false','false','false',0,0,0,0,0),


Spoiler Text for Event :

--------------------------------------------------------------------------------------------------
-- Disabled Natural Wonder event choice text
INSERT INTO Language_en_US (Tag, Text) VALUES
('TXT_KEY_CITY_EVENT_NW_DISABLED_HELP', 'Your civilization has not advanced far enough for this choice to be available.');
--
--------------------------------------------------------------------------------------------------


I also checked, and the text is showing up in the text database and the event database is showing the disabled text tag in the correct column.

Spoiler Screenshot :

Untitled.png


What I was wanting to do was change the text where it says "Requires Currency Technology" to more generic "'Your civilization has not advanced far enough for this choice to be available."

In an ideal setting, you wouldn't see the other choices. If I ever get the events system working about like I want it to, I might create a bunch of chain events where you can get Choice 0 (default generic GAP) or Choice X with Choice X moving down the list as you unlock the one before it. Possibly even go in and show the previously selected choices as greyed out so you can trace the path. But that's a lot of work, and I want the event system to be beefed up before I go nuts adding pure eye candy QoL features.
 
INSERT INTO CityEventChoices(Type,Description,Help,DisabledTooltip,EventChoiceAudio,EventChance,IsOneShot,EraScaling,EventDuration,Expires,MinimumCityPopulation,MaximumCityPopulation,RequiredCiv,RequiredEra,IsUnhappy,IsSuperUnhappy,ObsoleteEra,RequiredPolicy,RequiredIdeology,RequiresWar,RequiresWarMinor,PrereqTech,ObsoleteTech,RequiresPantheon,RequiredReligion,RequiredStateReligion,RequiresAnyStateReligion,RequiredBuildingClass,CannotHaveBuildingClass,RequiresHolyCity,RequiresIdeology,NearbyFeature,NearbyTerrain,LocalResourceRequired,HasTradeConnection,HasCityConnection,RequiresGarrison,CapitalOnly,CoastalOnly,RiverOnly,RequiresResistance,RequiresWLTKD,RequiresOccupied,RequiresRazing,HasAnyReligion,RequiresPuppet,RequiresNearbyNaturalWonder,RequiresNearbyMountain,EventBuildingClassDestruction,EventBuildingClass,CityWideBuildingDestructionChance,WLTKDTurns,ResistanceTurns,CityHappiness,RandomBarbarianSpawn,ConvertToPlayerReligionPercent,ConvertToPlayerMajorityReligionPercent,ImprovementRequired,FreeUnitsTechAppropriate,HasMetAMajorCiv,InDebt,LosingMoney,IsVassalOfSomeone,IsMasterOfSomeone,CityHasPlayerReligion,CityLacksPlayerReligion,CityHasPlayerMajorityReligion,CityLacksPlayerMajorityReligion,BasicNeedsMedianModifier,GoldMedianModifier,ScienceMedianModifier,CultureMedianModifier,ReligiousUnrestModifier) VALUES

('CITY_EVENT_NW_MT_KAILASH_CHOICE_1','TXT_KEY_CITY_EVENT_NW_MT_KAILASH_CHOICE_1','TXT_KEY_CITY_EVENT_NW_MT_KAILASH_CHOICE_1_HELP','TXT_KEY_CITY_EVENT_NW_DISABLED_HELP','AS2D_EVENT_CHOICE',0,'false','false',30,'false',0,0,NULL,NULL,'false','false',NULL,NULL,NULL,'false','false',NULL,NULL,'false',NULL,NULL,'false',NULL,NULL,'false','false',NULL,NULL,NULL,'false','false','false','false','false','false','false','false','false','false','false','false','false','false',NULL,NULL,0,0,0,0,0,0,0,NULL,0,'false','false','false','false','false','false','false','false','false',0,0,0,0,0),

('CITY_EVENT_NW_MT_KAILASH_CHOICE_2','TXT_KEY_CITY_EVENT_NW_MT_KAILASH_CHOICE_2','TXT_KEY_CITY_EVENT_NW_MT_KAILASH_CHOICE_2_HELP','TXT_KEY_CITY_EVENT_NW_DISABLED_HELP','AS2D_EVENT_CHOICE',0,'true','false',30,'false',0,0,NULL,NULL,'false','false',NULL,NULL,NULL,'false','false','TECH_CURRENCY',NULL,'false',NULL,NULL,'false',NULL,NULL,'false','false',NULL,NULL,NULL,'false','false','false','false','false','false','false','false','false','false','false','false','false','false',NULL,'BUILDINGCLASS_MANDIR',0,0,0,0,0,0,0,NULL,0,'false','false','false','false','false','false','false','false','false',0,0,0,0,0),
This is why you use XML for big tables...
 
Or just input few columns and take care of the remaining ones with a tactical UPDATE query to switch from horizontal to a better vertical xml-like formatting. ;)
 
This is why you use XML for big tables...
Except I'm trying to build dozens of different events and seeing all the options gives me various ideas to make them each a little more unique. Plus it lets me start with a single template when I start working on sub-templates

At this point, I can pretty quickly go through any event and/or choice and update the piece I want to change. :)
 
Guess it just doesn't work as intended then. Perhaps put in a github request.

If you want to do as you say you can just make a series of events that require the previous one to be active, and give them infinite duration.
Pillar of the Earth I, Pillar of the Earth II, etc.
The only reason I put these sorts of events all into one single holder is actually exactly so you could see the requirements for the other options! Since I felt some requirements were unusual and if you didn't know about them, you might not otherwise attempt to satisfy them.
 
Guess it just doesn't work as intended then. Perhaps put in a github request.

If you want to do as you say you can just make a series of events that require the previous one to be active, and give them infinite duration.
Pillar of the Earth I, Pillar of the Earth II, etc.
That was kind of my plan once I do that.
The only reason I put these sorts of events all into one single holder is actually exactly so you could see the requirements for the other options! Since I felt some requirements were unusual and if you didn't know about them, you might not otherwise attempt to satisfy them.
A couple things I'm trying to do make these events more user-friendly (with the goal being that others will start building expansion packs):

I am trying to keep related events in the same file. (example: the natural wonders EP has a file for each natural wonder). It isn't always practical, but that's my goal.
I'm trying to put some decent notes in files so others can follow the work that is being done on the events I build and/or modify.
Trying to move everything over to SQL so it is easier to see what's going on with a quick glance and/or update everything.
Where practical, I'm also including the text in the event file itself instead of having a separate text file with a bunch of other events.
 
The religious events still are not working. I think it might be something in this code:

Spoiler Broken Code :

Code:
--------------------------------------------------------------
-- Dummy Policy Creator for Religious Events
--------------------------------------------------------------

local ePilgrimageBelief = GameInfoTypes.BELIEF_PILGRIMAGE
local eCeremonialBurialBelief = GameInfoTypes.BELIEF_CEREMONIAL_BURIAL
local eCouncilofEldersBelief = GameInfoTypes.BELIEF_PAPAL_PRIMACY
local eHeroWorshipBelief = GameInfoTypes.BELIEF_INTERFAITH_DIALOGUE
local eHolyLawBelief = GameInfoTypes.BELIEF_CHURCH_PROPERTY
local eDivineInheritanceBelief = GameInfoTypes.BELIEF_PEACE_LOVING
local eTheocraticRuleBelief = GameInfoTypes.BELIEF_WORLD_CHURCH
local eRevelationBelief = GameInfoTypes.BELIEF_TITHE
local eTranscendentThoughtsBelief = GameInfoTypes.BELIEF_INITIATION_RITES

local ePilgrimageDummyPolicy = GameInfoTypes.POLICY_PILGRIMAGE_DUMMY
local eCeremonialBurialDummyPolicy = GameInfoTypes.POLICY_CEREMONIAL_BURIAL_DUMMY
local eCouncilofEldersDummyPolicy = GameInfoTypes.POLICY_PAPAL_PRIMACY_DUMMY
local eHeroWorshipDummyPolicy = GameInfoTypes.POLICY_INTERFAITH_DIALOGUE_DUMMY
local eHolyLawDummyPolicy = GameInfoTypes.POLICY_CHURCH_PROPERTY_DUMMY
local eDivineInheritanceDummyPolicy = GameInfoTypes.POLICY_PEACE_LOVING_DUMMY
local eTheocraticRuleDummyPolicy = GameInfoTypes.POLICY_WORLD_CHURCH_DUMMY
local eRevelationDummyPolicy = GameInfoTypes.POLICY_TITHE_DUMMY
local eTranscendentThoughtsDummyPolicy = GameInfoTypes.POLICY_INITIATION_RITES_DUMMY

local tBeliefPolicy = {
    [ePilgrimageBelief] = ePilgrimageDummyPolicy,
    [eCeremonialBurialBelief] = eCeremonialBurialDummyPolicy,
    [eCouncilofEldersBelief] = eCouncilofEldersDummyPolicy,
    [eHeroWorshipBelief] = eHeroWorshipDummyPolicy,
    [eHolyLawBelief] = eHolyLawDummyPolicy,
    [eDivineInheritanceBelief] = eDivineInheritanceDummyPolicy,
    [eTheocraticRuleBelief] = eTheocraticRuleDummyPolicy,
    [eRevelationBelief] = eRevelationDummyPolicy,
    [eTranscendentThoughtsBelief] = eTranscendentThoughtsDummyPolicy,
}

function OnReligionFoundDummy(ePlayer, eHolyCity, eReligion, eBelief1, eBelief2, eBelief3, eBelief4, eBelief5)

    local pPlayer = Players[ePlayer]
    local tOwnedBelief = {eBelief1, eBelief2, eBelief3, eBelief4, eBelief5}

--------------------------------------------------------------
-- Shuffling the owned beliefs so Byzantium is randomized
--------------------------------------------------------------
    for i = 1, 4 do
        local r = math.random(i, 5)
         tOwnedBelief[i],  tOwnedBelief[r] =  tOwnedBelief[r],  tOwnedBelief[i]
    end

    for _, eOwnedBelief in tOwnedBelief do
        for eBelief, ePolicy in tBeliefPolicy do
            if eOwnedBelief == eBelief then
                pPlayer:GrantPolicy(ePolicy, true)
                -- Log for validation
                if pPlayer:HasPolicy(ePolicy) then
                    sPolicyName = Locale.ConvertTextKey(GameInfo.Policies[ePolicy].Description)
                    print(sPolicyName .. " is active")
                    return  -- Added the return to jump out of the function for Byzantium
                end
            end
        end
    end
end

GameEvents.ReligionFounded.Add(OnReligionFoundDummy)

I don't know but what I think what is going on is that the dummy policy isn't being written, and the event is dependent on the policy to fire. No dummy policy, ergo no event chain started. And, I see the print function but don't know how to find those statements. (Firetuner? I've never used it so don't know.)

The good news is I have a bunch of other updates that makes this mod a lot more user-friendly and adds another expansion pack. I'd just really like to get the religious events working before I make the upload.
 
The religion game event needs to be activated with the following sql code to work.
Code:
UPDATE CustomModOptions SET Value = 1 WHERE Name = 'EVENTS_FOUND_RELIGION';
 
I'm having trouble getting the disabled tool tip to work. It's just ignoring the tag and treating it like it's not there.

Code:
    <Table name="CityEventChoices">
        <!-- You can make as many choices as you want - the window show expand (with a scroll bar) to acommodate them. But be reasonable! :) -->
        <!-- Note - if NOT a multiple-choice event, only make one of these! -->
        <Column name="ID" type="integer" primarykey="true" autoincrement="true"/>
        <Column name="Type" type="text" notnull="true" unique="true"/>
        <Column name="Description" type="text" reference="Language_en_US(Tag)"/>
        <!-- Help is used for Tooltips, Description for button text -->
        <Column name="Help" type="text" reference="Language_en_US(Tag)"/>
        <!-- DisabledTooltip is used for Tooltips for choices that are not active but appear in choice list.
        The DLL automatically explains to players WHY an event choice is unavailable, however you can use it you want to override the DLL. -->
        <Column name="DisabledTooltip" type="text" reference="Language_en_US(Tag)"/>

Is there something with the DLL that is preventing it from working? I checked the SQL databases and the value is showing up on the correct column, and the text is showing up in the correct place.

I'd like to be able to use the disabled tool tip as I build out events so I can hide choices that aren't available yet to keep some suspense for what is yet to come. You don't need to know what choices you are unlocking in the future with your selection because you should be living in the moment.

In case it matters, I am using CP 3.10.14.
Hi rsc2a, I asked GPT about this and the previous issue you've been trying to fix in regards to the VP Events Overhaul mod. Fwiw, here's what GPT has to say, starting with the issue of religious events not firing:

"

1. Corrected Lua Error Causing Religious Events Not to Fire

The Lua error you're encountering could be related to how you're iterating through the tables and checking the condition. Here's a cleaned-up version with potential improvements:

  • Added error checking for tOwnedBelief and tBeliefPolicy to ensure the tables exist.
  • Added logging for debugging to trace what's happening.
  • The return statement was added earlier in your version, which might cause premature exits before all beliefs are processed. If you intended to apply the policy only once, keeping the return is fine, but if you need to check all beliefs, you might want to remove it.
Spoiler suggested code :

if tOwnedBelief and tBeliefPolicy then
for _, eOwnedBelief in pairs(tOwnedBelief) do
for eBelief, ePolicy in pairs(tBeliefPolicy) do
if eOwnedBelief == eBelief then
pPlayer:GrantPolicy(ePolicy, true)

-- Log for validation
local sPolicyName = Locale.ConvertTextKey(GameInfo.Policies[ePolicy].Description)
print(sPolicyName .. " is active")

-- If Byzantium is intended to receive only one policy, return here.
-- If you want to apply multiple policies, you might want to comment this out:
return
end
end
end
else
print("Error: tOwnedBelief or tBeliefPolicy table is nil")
end


Hiding Unavailable Religion and Natural Wonder (NW) Events with Disabled Text

It seems that you want to hide certain choices until they're available by using a "DisabledTooltip." Your SQL structure looks good, but there are a few things to consider:

  1. Check if the DisabledTooltip is being correctly referenced in your event system:
    • Ensure that the engine is correctly reading the DisabledTooltip from the database and checking the conditions you want.
    • If the DLL is overriding your logic, ensure you're not re-implementing logic that the DLL already handles.
  2. Cleaned-up SQL Table Definition:
    • There doesn't seem to be an issue with your SQL definition, but I'll provide a cleaned-up version with more consistent formatting and comments.
Spoiler cleaned up table :

CREATE TABLE CityEventChoices (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
Type TEXT NOT NULL UNIQUE,
Description TEXT REFERENCES Language_en_US(Tag),
Help TEXT REFERENCES Language_en_US(Tag),
-- DisabledTooltip shows why an event choice is unavailable
DisabledTooltip TEXT REFERENCES Language_en_US(Tag)
);


  1. Debugging and Fix Suggestions:
    • Verify that the game system is properly reading the DisabledTooltip text when a choice is disabled. Sometimes, custom logic might not work if the game's internal logic overrides it. If this is the case, you might need to hook into the game's event management system or look at the mod's DLL implementation to figure out why it isn't using your DisabledTooltip.
    • You may also want to inspect how you're disabling the choices programmatically. Make sure that the DisabledTooltip is only being shown when a choice is truly unavailable and that the logic determining availability is working as expected.

Troubleshooting Steps:

  • SQL Database Debugging: Since you mentioned that the SQL values are correctly showing up, double-check that the DisabledTooltip text is in the correct format and being queried by the game logic when choices are hidden.
  • Logs: Enable debug logs in your event system to ensure that the tooltip is being triggered. For example, you could log every time a choice is evaluated, and whether or not it should be hidden, and if the tooltip is correctly referenced.
In summary, the Lua code seems to have a possible logic error with the return statement that could cause early exits. For the SQL part, the issue may be with the DLL overriding or not triggering the DisabledTooltip as intended. Checking how the game reads this and debugging with logs might help isolate the problem.
"
The formatting gets messed up when copying the code to this forum, but hopefully something in this post is useful to ya!
 
The religion game event needs to be activated with the following sql code to work.
Code:
UPDATE CustomModOptions SET Value = 1 WHERE Name = 'EVENTS_FOUND_RELIGION';
I added this update to the files and checked the database to make sure it's catching it. For some reason, the LUA still isn't giving the policy to the civ.
 
I added this update to the files and checked the database to make sure it's catching it. For some reason, the LUA still isn't giving the policy to the civ.
In order to work
Code:
pPlayer:GrantPolicy
requires
Code:
UPDATE CustomModOptions SET Value = 1 WHERE Name = 'BUGFIX_DUMMY_POLICIES';
 
In order to work
Code:
pPlayer:GrantPolicy
requires
Code:
UPDATE CustomModOptions SET Value = 1 WHERE Name = 'BUGFIX_DUMMY_POLICIES';
'BUGFIX_DUMMY_POLICIES' was not in my CustomModOptions.

I added it into the database and tried running it. Still nothing.

Seems like BUGFIX_DUMMY_POLICIES missing could be a problem anyways, because it looks like my mod isn't the only mod I use that changes those non-existent values.
 
Why bother with player:GrantPolicy when there is player:SetHasPolicy?

BUGFIX_DUMMY_POLICIES isn't a thing btw.
 
Why bother with player:GrantPolicy when there is player:SetHasPolicy?

BUGFIX_DUMMY_POLICIES isn't a thing btw.
According to the wiki, player.SetHasPolicy raises the cost of the next policy? The Google tells me i need the code below. Do I have to do something like this to avoid the policy cost increase?

Code:
if not player:HasPolicy(GameInfoTypes["POLICY_DUMMY_XXX"]) then
    player:SetNumFreePolicies(1)
    player:SetNumFreePolicies(0)
    player:SetHasPolicy(GameInfoTypes["POLICY_DUMMY_XXX"], true)
end
 
You want player:SetHasPolicy(policyID, true, true)

There's no difference though, player:GrantPolicy calls SetHasPolicy anyway. It just has a return value that's false if the player already has the policy, and cannot be used to remove a policy from the player.
 
According to the wiki, player.SetHasPolicy raises the cost of the next policy? The Google tells me i need the code below. Do I have to do something like this to avoid the policy cost increase?

Code:
if not player:HasPolicy(GameInfoTypes["POLICY_DUMMY_XXX"]) then
    player:SetNumFreePolicies(1)
    player:SetNumFreePolicies(0)
    player:SetHasPolicy(GameInfoTypes["POLICY_DUMMY_XXX"], true)
end
This one is the commonly used code to grant policies and it works.

Why bother with player:GrantPolicy when there is player:SetHasPolicy?

BUGFIX_DUMMY_POLICIES isn't a thing btw.
Some old mods for VP has it so it seems that it was a thing in the past but not anymore. Good to know.
 
Top Bottom