Events system brainstorm

What I'd like to do is randomize it slightly so you aren't see the same quote over and over for a set condition. My thoughts are to have several single-choice events for the same condition (e.g. on a river) and let a random one fire to set the tag. I know it can be done because the old Events and Decisions mod had the randomized settlement events but, looking through that mod, I cannot figure out how it was set up. Any hints?
I think you just make several events and have them all block one another.
I don't remember if it works like this but it might be worth a test: if you give the event all empty text strings, does it just not generate any popups at all? I.e. a silent event (usually this is done with LUA but I wonder if it can be accomplished in xml or if this was overlooked)
 
I'm playing my game again and another thought occurred to me regarding events. Can we get a Resource expansion pack? This is just an idea to add even more events to the game and I'm thinking they'd best be one-time events (though, perhaps someone else has other ideas), sort of like what you designed here.

So, for example, when a city gains a Fish Resource then the Fish Resource Event fires. If it gains Iron then the Iron Resource Event fires. Etc. I don't know if it should fire for every single time you'd gain the resource, because that may be excessive. 🤷‍♂️
 
I don't remember if it works like this but it might be worth a test: if you give the event all empty text strings, does it just not generate any popups at all? I.e. a silent event (usually this is done with LUA but I wonder if it can be accomplished in xml or if this was overlooked)
After testing an empty text string leaves a blank box. A NULL text string does not generate any pop-ups...

...but it also blocks all your non-event pop-ups (discovering natural wonders, clearing barb camps, goody huts, discovering city-states, etc..) until you have an event with a pop-up, then you get them all at once playing catch-up. It only took me several hours to figure out what was going on.

I wonder if these pieces are going to have to be written in LUA.

I've never done anything at all in LUA, and I could be completely wrong. But this is (laughably bad?) attempt after looking at code from other mods. What I'm trying to do is look and see if the city is next to a coast, river or fresh water and create dummy buildings based on NoCoast, NoRiver, and DryTown.

Spoiler LUA code :

Code:
function OnFoundCheckCity(iPlayer, iX, iY)
    
    local pPlayer = Players[iPlayer]
    local pCity = Map.GetPlot(iX, iY):GetPlotCity()
    
        if not pCity:IsCoastal() then
            pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_NOCOAST_TOWN_DUMMY, 1)
        end
        
        if not Plot:IsRiver() then 
            pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_NORIVER_TOWN_DUMMY, 1)
        end
            
        if not Plot:IsRiver() and not pCity:IsCoastal() and not Plot:IsFreshWater then
            pCity.SetNumRealBuilding(GameInfoTypes.BUILDING_DRY_TOWN_DUMMY, 1)
        end
        
end

GameEvents.PlayerCityFounded.Add(OnFoundCheckCity)
 
Last edited:
I was thinking of the way that "culturally linked" map placement works. I'm not 100% sure what the cultural groups are these days nor how they actually work, so this is just an example, not necessarily how Civ5 works:
African Events, American Events, European Events, Middle Eastern Events, etc.
What I've seen of the files, culturally linked map placement works by assigning terrain preferences to individual Civs. So Arabia and Egypt are going to have desert preferences while Rome has hill preferences. It would be easy to do, but the cis-specific events kind of handle this function now. I'll eventually look at those, but 43 event packages is going to take a minute to comb through.

I'm playing my game again and another thought occurred to me regarding events. Can we get a Resource expansion pack? This is just an idea to add even more events to the game and I'm thinking they'd best be one-time events (though, perhaps someone else has other ideas), sort of like what you designed here.

So, for example, when a city gains a Fish Resource then the Fish Resource Event fires. If it gains Iron then the Iron Resource Event fires. Etc. I don't know if it should fire for every single time you'd gain the resource, because that may be excessive. 🤷‍♂️
My thoughts are it would be a good idea to incorporate into other EPs. I think for a stand alone EP, it might get pretty overwhelming and/or unbalanced.

I would love to see reduction of random pillage chance. It is annoying. If anyone still likes it, make it rarer but very intense instead.
In the events I have modified or built, it is greatly reduced, but when you get pillages, it's normally pretty bad. Once I get around to the policy events, my thoughts are that it will be a blood bath with revolts and rebellions and barbarians spawning everywhere. I am just trying to figure out how to keep it balanced in a way that doesn't give authority times a huge buff.
 
If you make it certain to fire ( i dont remember if the probability should be 1000 or -1...), then I seem to remember there is a flag like ignoresglobalcooldown. So this shouldn't be an issue.

For #building it's the same thing, there is only the positive check, not the opposite, so you have to split it into two events.

Would something like this work?

Spoiler LUA code :

Code:
local iFieldsGeneral3 = GameInfoTypes.CITY_EVENT_FIELDS_OF_GOLD_v3a
local iFieldsGeneral4 = GameInfoTypes.CITY_EVENT_FIELDS_OF_GOLD_v4a
local iFieldsAdmiral3 = GameInfoTypes.CITY_EVENT_FIELDS_OF_GOLD_v3b
local iFieldsAdmiral4 = GameInfoTypes.CITY_EVENT_FIELDS_OF_GOLD_vb
local iChoiceGeneral = GameInfoTypes.CITY_EVENT_FIELDS_OF_GOLD_CHOICE_1a
local iChoiceGeneral = GameInfoTypes.CITY_EVENT_FIELDS_OF_GOLD_CHOICE_1b
local eBuildingGeneral = GameInfoTypes.BUILDING_FIELDS_GENERAL_DUMMY
local eBuildingAdmiral = GameInfoTypes.BUILDING_FIELDS_ADMIRAL_DUMMY

-- Count specialization buildings from event. Max allowable is 5 to keep balance.

function FieldsGoldCount(iPlayer, iCityID, iChoice)

    local pPlayer = Players[iPlayer]

    If GameEvents.CityEventActivated == iFieldsGeneral3 or GameEvents.CityEventActivated == iFieldsGeneral4 then

        if pPlayer:IsMinorCiv() then return end

        if pPlayer:CountNumBuildings(eBuildingGeneral) >= 5 then
            *******************NEED STRING TO DISABLE iChoiceGeneral*****************
        end
    end

    If GameEvents.CityEventActivated == iFieldsAdmiral3 or GameEvents.CityEventActivated == iFieldsAdmiral4 then

        if pPlayer:IsMinorCiv() then return end

        if pPlayer:CountNumBuildings(eBuildingAdmiral) >= 5 then
            *******************NEED STRING TO DISABLE iChoiceAdmiral*****************
        end
    end

end

GameEvents.CityEventActivated.Add(FieldsGoldCount)
 
The mod event system really enhances impressive experience of the game.

Here are just my opinion about some of them. I am not a veteran player by the way.

  • The barbarians spawning everywhere in a city state (likes 10 turns) looks very funny and cool. It encourages long term planning, so I love it.
  • The event that I can pick any great person now VS +1 happiness for bath every city forever is very cool too.
  • The event that randomly pillages my farm/mine are cool at first. In late game, its repetitive occurrences require micro manage my worker too much.
  • Hurricane should spawn in a tile (or zone) and randomly moves around, or just have countdown, or just disable production much more than 1 turn.
  • ^ It encourages enemy to plan to attack that weak city, and encourages alliance to plan to protect it.
  • By the way, in VP version 3.10 (not the last version), during late games, there are events popup almost every turn. Every event looks insignificant.
 
I turned them off in previous patches because they were very repeatable I knew what to expect etc.
 
After testing an empty text string leaves a blank box. A NULL text string does not generate any pop-ups...

...but it also blocks all your non-event pop-ups (discovering natural wonders, clearing barb camps, goody huts, discovering city-states, etc..) until you have an event with a pop-up, then you get them all at once playing catch-up. It only took me several hours to figure out what was going on.

I wonder if these pieces are going to have to be written in LUA.

I've never done anything at all in LUA, and I could be completely wrong. But this is (laughably bad?) attempt after looking at code from other mods. What I'm trying to do is look and see if the city is next to a coast, river or fresh water and create dummy buildings based on NoCoast, NoRiver, and DryTown.

Spoiler LUA code :

Code:
function OnFoundCheckCity(iPlayer, iX, iY)
  
    local pPlayer = Players[iPlayer]
    local pCity = Map.GetPlot(iX, iY):GetPlotCity()
  
        if not pCity:IsCoastal() then
            pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_NOCOAST_TOWN_DUMMY, 1)
        end
      
        if not Plot:IsRiverSide() then
            pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_NORIVER_TOWN_DUMMY, 1)
        end
          
        if not Plot:IsRiverSide() and not pCity:IsCoastal() and not Plot:IsFreshWater then
            pCity.SetNumRealBuilding(GameInfoTypes.BUILDING_DRY_TOWN_DUMMY, 1)
        end
      
end

GameEvents.PlayerCityFounded.Add(OnFoundCheckCity)

I've been arguing with this for a while. Why isn't this working?
 
Last edited:
I've been arguing with this for a while. Why isn't this working?
just a guess, but its possible the lua hook is disabled by default in VP. Have you checked CustomModOptions to make sure PlayerCityFounded is not locked behind something there? Pretty sure I used this hook without much issue before, so this implies a recent change to custommodoptions, or something gone off in recent version (I'm still lagging behind a few) -- possible, but unlikely this is the issue imo.

Alternatively, sometimes I've found that these boolean lua functions such as IsCoastal, IsFreshWater, IsRiverSide etc don't return the expected value. Unless you've double-checked each in other projects etc., you might experiment with the plot's versions of these instead of the city's, though again just a guess here.

In your third conditional you have a '.' instead of a ':', looks like -- but that should only affect that particular conditional and not the rest.

If you're watching the lua console in firetuner, and its not throwing any errors that pinpoint which line is failing, then my guess is your function is not getting called at all -- double check your lua triggers are setup correctly in modbuddy -- very rarely I've had to just scrap a project file, copy everything over to a new one due to some invisible corruption or w/e, but again this is very rare
 
Last edited:
Well, I just now managed to get this to work

Spoiler Working LUA :

Code:
function OnFoundCheckCity(iPlayer, iX, iY)
 
    local pPlayer = Players[iPlayer]
    local pCity = Map.GetPlot(iX, iY):GetPlotCity()
    local plot = pCity:GetCityIndexPlot( i ) -- Added
 
        if not pCity:IsCoastal() then
            pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_NOCOAST_TOWN_DUMMY, 1)
        end
     
        if not plot:IsRiver() then
            pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_NORIVER_TOWN_DUMMY, 1)
        end
     
        if not pCity:IsCoastal() and not plot:IsRiver() then
                pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_DRY_TOWN_DUMMY, 1)
        end
     
end

GameEvents.PlayerCityFounded.Add(OnFoundCheckCity)

So now a "dry town" is one that has a NoCoast and a NoRiver tag. What I'd like to do is look at everything one ring outside the City (i.e. immediately adjacent to it) so I can check for other water (e.g. oasis, water-giving NWs). I don't know exactly how the iX and iY calculated to write a do function, but that was the direction I was leaning. Ideas?
 
Use this, I think its the best way if you only want things 1-tile away/adjacent:

Code:
function GetAdjacentPlots( plot )
    local plotList = {}
    local direction_types = {
        DirectionTypes.DIRECTION_NORTHEAST,
        DirectionTypes.DIRECTION_SOUTHEAST,
        DirectionTypes.DIRECTION_WEST,
        DirectionTypes.DIRECTION_EAST,
        DirectionTypes.DIRECTION_SOUTHWEST,
        DirectionTypes.DIRECTION_NORTHWEST
    }
    for loop, direction in ipairs(direction_types) do
        local adjPlot = Map.PlotDirection( plot:GetX(), plot:GetY(), direction )
        if ( adjPlot ~= nil ) then table.insert(plotList, adjPlot) end
    end
    return plotList
end

It will give you a table with adjacent plots in it -- I assume you can figure out how to iterate through the table and perform the plot checks, but if its not clear I can explain further.
 
Well, I just now managed to get this to work

Spoiler Working LUA :

Code:
function OnFoundCheckCity(iPlayer, iX, iY)
 
    local pPlayer = Players[iPlayer]
    local pCity = Map.GetPlot(iX, iY):GetPlotCity()
    local plot = pCity:GetCityIndexPlot( i ) -- Added
 
        if not pCity:IsCoastal() then
            pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_NOCOAST_TOWN_DUMMY, 1)
        end
     
        if not plot:IsRiver() then
            pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_NORIVER_TOWN_DUMMY, 1)
        end
     
        if not pCity:IsCoastal() and not plot:IsRiver() then
                pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_DRY_TOWN_DUMMY, 1)
        end
     
end

GameEvents.PlayerCityFounded.Add(OnFoundCheckCity)

So now a "dry town" is one that has a NoCoast and a NoRiver tag. What I'd like to do is look at everything one ring outside the City (i.e. immediately adjacent to it) so I can check for other water (e.g. oasis, water-giving NWs). I don't know exactly how the iX and iY calculated to write a do function, but that was the direction I was leaning. Ideas?

This is simpler:

Code:
for direction = 0, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do
	local pAdjacentPlot = Map.PlotDirection(plot:GetX(), plot:GetY(), direction)
	local bcheck= pAdjacentPlot:IsFreshWater() or pAdjacentPlot:GetFeatureType() == GameInfoTypes.FEATURE_OASIS  --whatever you need to check
	if pAdjacentPlot and bcheck then
		---code
	end
end
 
This is simpler:

Code:
for direction = 0, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do
    local pAdjacentPlot = Map.PlotDirection(plot:GetX(), plot:GetY(), direction)
    local bcheck= pAdjacentPlot:IsFreshWater() or pAdjacentPlot:GetFeatureType() == GameInfoTypes.FEATURE_OASIS  --whatever you need to check
    if pAdjacentPlot and bcheck then
        ---code
    end
end
i think this will result in lua error iff plot being checked is at edge of map, but you could nest the conditional and put the boolean declaration after confirming adjacentplot is not nil. Minor quibble though this will still run, console errors notwithstanding
 
Code worked great for adjacency check.

Putting together the post to upload version 1. Plan on publishing in the morning. A couple quick questions:

1. How do you hide dummy buildings in the city view?
2. Is there an easy way to bulk add files in ModBuddy instead of setting each one to update database individually?
 
Sorry to jump in here, maybe this has been answered already, but why hasn't one of the larger more popular event mods have been added to the base VP mode yet?
The base events that come with VP are either bad, or super repetitive.
I also find most of the base events don't really do anything impactful, particularly once your past the ealy stages and are just an immersion breaking chore.
 
I've started flowcharting a BYOA-style set of policy events. Thoughts on the direction I'm thinking so far?

Spoiler Direction I'm Thinking So Far :
1708054954903.png


I'm thinking regular revolts, rebellions, religious uprisings, the interior isn't safe so keep soldiers close by if you want to keep your cities.

I am a bit concerned that this will be a big buff to authority types since it's pretty much raging barbarians in the heartland.
 

Attachments

  • 1708049796053.png
    1708049796053.png
    74.4 KB · Views: 13
Last edited:
I'm thinking regular revolts, rebellions, religious uprisings, the interior isn't safe so keep soldiers close by if you want to keep your cities.
I like this idea in general -- however I'd be concerned if it was too arbitrarily RNG.

For example, if the uprisings and revolts are just triggered via a global probability ie every plot has x% chance per turn for uprising to occur, this will feel very gamey, and the more frequent, the more pronounced this vibe will be.

On the other hand, if they were more frequent but also weighted more heavily to occur when certain conditions were right, when it makes thematic sense for uprisings to occur, I'd very much enjoy this.

Just brainstorming but maybe there a gaps that can be filled in VP's current representations of revolts/uprisings... The events might serve as a bit of a warning that the more drastic VP revolts are approaching, if they are setup to be more sensitive to the same triggers
 
I like this idea in general -- however I'd be concerned if it was too arbitrarily RNG.

For example, if the uprisings and revolts are just triggered via a global probability ie every plot has x% chance per turn for uprising to occur, this will feel very gamey, and the more frequent, the more pronounced this vibe will be.

On the other hand, if they were more frequent but also weighted more heavily to occur when certain conditions were right, when it makes thematic sense for uprisings to occur, I'd very much enjoy this.

Just brainstorming but maybe there a gaps that can be filled in VP's current representations of revolts/uprisings... The events might serve as a bit of a warning that the more drastic VP revolts are approaching, if they are setup to be more sensitive to the same triggers
...more frequent but also weighted more heavily to occur when certain conditions were right...

That's the plan. In my "Direction I'm Thinking So Far" section, you can see which event choices would trigger revolts, uprisings, etc. Some event choices don't, but some (e.g. adopting centralized government or feudalism, creating a state church, etc.) opens you up to discontent (i.e. revolts, rebellions, and uprisings). I'm also planning that they would largely be local (i.e. city-based) occurrences with one major revolt to act as a switch to turn off the event effects (so no more forever bonus yields).
 
Top Bottom