Community Patch Events Development

Hello,

I think there is something wrong with [EventPolicy] for choices. I tried it, and the policy is applied (The lua fonction player:Haspolicy() return true), but the bonuses from the policy is not applied (The tested policy is a custom made one that uses the Policy_CapitalYieldChanges and Policy_CapitalYieldModifiers tables). Giving the policy from the lua code work properly tough, so there's that.
 
Ok, I've read the GameEventsTable and the SampleEvents. This is for me like reading Portuguese. I understand when I read it, but by no means I can write it!

In the example, wanderer's choice, for farms it's <ImprovementType>, then <Number>, while for units it's <UnitClassType> then <Quantity>. Why improvements are numbered with <Number> while Units are numbered with <Quantity>? Also, I don't know the names for ImprovementTypes, except IMPROVEMENT_FARM, just because it's in the example. The same could be said for <UnitClassType>.

To be able to write something like this myself, I'd have to study it first, like learning a language. Maybe this is a no brainer for a modder, but certainly not for anyone.

At least I now know that there isn't triggers for befriending City States, or for getting more units than cities.
 
Here is something interesting:
<!-- Only valid if you are under your trade route cap -->
<Column name="LessThanMaximumTradeRoutes" type="boolean" default="false"/>

Does it mean it is possible to write a Event when I am forgetting to build a trade route?
If so, I'd love to have something like this:

When "LessThanMaximumTradeRoutes" is true,
EventCooldown = 10, Event_Class_Trade.
Help text= "There are trade routes available"
Choice1 = "I'll build them myself" (Do nothing)
Choice2 = "I'll buy one land trader" (pay land trader cost, a land trader appears in Capital)
Choice3 = "I'll buy one sea trader" (pay sea trader cost, a sea trader appears in Capital)
If there is a Bank in Capital
Choice4 = "I'll take a loan to get a land trader" (costs 20% extra gold, but pay it in 10 turns, a land trader appears in Capital)
Choice5 = "I'll take a loan to get a sea trader" (costs 20% extra gold, but pay it in 10 turns, a sea trader appears in Capital)

This is mixing a player trigger with city options and city filters, so no clue about how to do it.
 
Ok, I've read the GameEventsTable and the SampleEvents. This is for me like reading Portuguese. I understand when I read it, but by no means I can write it!

In the example, wanderer's choice, for farms it's <ImprovementType>, then <Number>, while for units it's <UnitClassType> then <Quantity>. Why improvements are numbered with <Number> while Units are numbered with <Quantity>? Also, I don't know the names for ImprovementTypes, except IMPROVEMENT_FARM, just because it's in the example. The same could be said for <UnitClassType>.

To be able to write something like this myself, I'd have to study it first, like learning a language. Maybe this is a no brainer for a modder, but certainly not for anyone.

At least I now know that there isn't triggers for befriending City States, or for getting more units than cities.

It is less complex than you think. All things (improvements, features, etc.) are defined in your game files. Start simple, focusing on one element. It may seem complex at first, but think of it as a madlibs table (https://en.wikipedia.org/wiki/Mad_Libs) - you have a lot of blanks that you need to fill in, and that's pretty much it.

G
 
Ok, I've read the GameEventsTable and the SampleEvents. This is for me like reading Portuguese. I understand when I read it, but by no means I can write it!

In the example, wanderer's choice, for farms it's <ImprovementType>, then <Number>, while for units it's <UnitClassType> then <Quantity>. Why improvements are numbered with <Number> while Units are numbered with <Quantity>? Also, I don't know the names for ImprovementTypes, except IMPROVEMENT_FARM, just because it's in the example. The same could be said for <UnitClassType>.

To be able to write something like this myself, I'd have to study it first, like learning a language. Maybe this is a no brainer for a modder, but certainly not for anyone.

At least I now know that there isn't triggers for befriending City States, or for getting more units than cities.

The way I do it for references like <ImprovementType> is that I use sqlitebrowser and look into Civ5DebugDatabase.db for the values inside the tables
 
Here is something interesting:
<!-- Only valid if you are under your trade route cap -->
<Column name="LessThanMaximumTradeRoutes" type="boolean" default="false"/>

Does it mean it is possible to write a Event when I am forgetting to build a trade route?
If so, I'd love to have something like this:

When "LessThanMaximumTradeRoutes" is true,
EventCooldown = 10, Event_Class_Trade.
Help text= "There are trade routes available"
Choice1 = "I'll build them myself" (Do nothing)
Choice2 = "I'll buy one land trader" (pay land trader cost, a land trader appears in Capital)
Choice3 = "I'll buy one sea trader" (pay sea trader cost, a sea trader appears in Capital)
If there is a Bank in Capital
Choice4 = "I'll take a loan to get a land trader" (costs 20% extra gold, but pay it in 10 turns, a land trader appears in Capital)
Choice5 = "I'll take a loan to get a sea trader" (costs 20% extra gold, but pay it in 10 turns, a sea trader appears in Capital)

This is mixing a player trigger with city options and city filters, so no clue about how to do it.

You could write an event like that, yes, however you cannot mix city and player level attributes. Many, but not all exist in both tables, however.

G
 
Sorry, I have no .db file either in Civ V folder or in MODs folder.
EDIT: Is there any example using EventLinker?

All .db files are located at "C:\Users\<user>\Documents\My Games\Sid Meier's Civilization 5\cache", the debug .db is equal to the current state of the game, so if you want all the mods values and tables, simply open or copy it after you loaded your mods inside your game.

About EventLinker, an example could be like this :
Code:
INSERT INTO Event_EventLinks(EventType,EventLinker,EventChoice,CityEvent,CityEventChoice,CheckKnownPlayers,CheckForActive) 
VALUES ('PLAYER_EVENT_COMET','PLAYER_EVENT_METEOR',null,null,null,false,false);
Which would make the event PLAYER_EVENT_COMET check that the event PLAYER_EVENT_METEOR is NOT active for the current player. Setting CheckKnownPlayers to true would also check for players known to the player (Gazebo, I might have a special request of mine : would it be possible also to add a boolean value to the table that enable the event to check if ANY player in the game has the event active? Of course default to false)

Also, I'd like to report another possible bug, but I'm not sure about where to do it so I'm gonna post it here :
I wanted to test my custom events so I wrote the following code to get the event pop at the second turn. The test code is as follow :
Code:
function TestEvent(iPlayer)
	if iPlayer == 0 then
		local pPlayer = Players[iPlayer]
		local capital = pPlayer:GetCapitalCity()
		capital:DoCityStartEvent(GameInfoTypes.CITY_EVENT_GOOD_HARVEST)
	end
end
GameEvents.PlayerDoTurn.Add(TestEvent)
The result is that absolutely nothing happens (capital and the Event Type are not nil, and I have no lua error). The same code with pPlayer: DoStartEvent() and a player event work properly.
 
All .db files are located at "C:\Users\<user>\Documents\My Games\Sid Meier's Civilization 5\cache", the debug .db is equal to the current state of the game, so if you want all the mods values and tables, simply open or copy it after you loaded your mods inside your game.
Thanks, so I need to start a game for that file to show. That's why I couldn't find it.
About EventLinker, an example could be like this :
Code:
INSERT INTO Event_EventLinks(EventType,EventLinker,EventChoice,CityEvent,CityEventChoice,CheckKnownPlayers,CheckForActive) 
VALUES ('PLAYER_EVENT_COMET','PLAYER_EVENT_METEOR',null,null,null,false,false);
Which would make the event PLAYER_EVENT_COMET check that the event PLAYER_EVENT_METEOR is NOT active for the current player.

So, the only example is in SQL. I had found that line before, but I couldn't believe it wasn't written in XML. All given examples and the Table were all in XML. And even the examples look incredibly complex for what they do.

I think it would be much simpler if we develop events the same way CBO has been developed: some skilled people receiving suggestions and feedback from unskilled players (yeah, that's me). I have some ideas for events, but 1) it would be unfair if my events get into game only because no other people care to code and 2) the production of new events will be very slow if only coders are able to design events.
 
Code:
function TestEvent(iPlayer)
	if iPlayer == 0 then
		local pPlayer = Players[iPlayer]
		local capital = pPlayer:GetCapitalCity()
		capital:DoCityStartEvent(GameInfoTypes.CITY_EVENT_GOOD_HARVEST)
	end
end
GameEvents.PlayerDoTurn.Add(TestEvent)
.
iPlayer == 0 is very awkward. Have you tried using print statements first?

1) it would be unfair if my events get into game only because no other people care to code and 2) the production of new events will be very slow if only coders are able to design events.

Sucks for them. Sometimes people suggest the craziest thing and expect coders to work their magic like we're not restricted or anything.
 
iPlayer == 0 is very awkward. Have you tried using print statements first?

I don't think it is particularly awkward. iPlayer is the player id (an integer), and 0 is always equal to player 1 (so myself in this test case)

But anyway, I did change a little my test code to this :
Code:
function TestEvent(iPlayer)
	if iPlayer == 0 then -- if player is myself
		print("Testing event start")
		local pPlayer = Players[iPlayer]
		local capital = pPlayer:GetCapitalCity()
		capital:DoCityStartEvent(GameInfoTypes.CITY_EVENT_CUSTOM_TEST) -- test a city event
		pPlayer:DoStartEvent(GameInfoTypes.PLAYER_EVENT_CUSTOM_TEST) -- test a player event
		print("Testing event end")
	end
end
GameEvents.PlayerCityFounded.Add(TestEvent)
With this code, the event PLAYER_EVENT_CUSTOM_TEST is triggered and I get this result in the firetuner when using my settler:
[28851.402] EventTestScript: Testing event start
[28851.402] EventTestScript: Testing event end

So everything looks alright. The thing is I don't have the event CITY_EVENT_CUSTOM_TEST appearing. I tried setting RandomChance to 1000 and IgnoresGlobalCooldown to true and waiting more than a few turns to get it, but never got any city event. I also noticed that I don't have any event in any tabs of the event overview interface (even player events that I did get). So maybe there is an incompatibility or a wrong installation on my side? Both my lua log file and database log file have debug mode activated and have no errors in them.
 
I don't think it is particularly awkward. iPlayer is the player id (an integer), and 0 is always equal to player 1 (so myself in this test case)

But anyway, I did change a little my test code to this :
Code:
function TestEvent(iPlayer)
	if iPlayer == 0 then -- if player is myself
		print("Testing event start")
		local pPlayer = Players[iPlayer]
		local capital = pPlayer:GetCapitalCity()
		capital:DoCityStartEvent(GameInfoTypes.CITY_EVENT_CUSTOM_TEST) -- test a city event
		pPlayer:DoStartEvent(GameInfoTypes.PLAYER_EVENT_CUSTOM_TEST) -- test a player event
		print("Testing event end")
	end
end
GameEvents.PlayerCityFounded.Add(TestEvent)
With this code, the event PLAYER_EVENT_CUSTOM_TEST is triggered and I get this result in the firetuner when using my settler:
[28851.402] EventTestScript: Testing event start
[28851.402] EventTestScript: Testing event end

So everything looks alright. The thing is I don't have the event CITY_EVENT_CUSTOM_TEST appearing. I tried setting RandomChance to 1000 and IgnoresGlobalCooldown to true and waiting more than a few turns to get it, but never got any city event. I also noticed that I don't have any event in any tabs of the event overview interface (even player events that I did get). So maybe there is an incompatibility or a wrong installation on my side? Both my lua log file and database log file have debug mode activated and have no errors in them.

Are there valid choices for the event? If it is a multi-choice event (and not an 'instant' effect) make sure numchoices in the XML for the event is greater than the default of 1.

G
 
I double-checked my sql entry to be sure, but it is alright. I also tested with one of your events, CITY_EVENT_GOOD_HARVEST, and got the same result (nothing happened).

I currently use the latest version (09/02). Is there anything I could do to be of help for you with the issues I have with events?
 
I double-checked my sql entry to be sure, but it is alright. I also tested with one of your events, CITY_EVENT_GOOD_HARVEST, and got the same result (nothing happened).

I currently use the latest version (09/02). Is there anything I could do to be of help for you with the issues I have with events?

Sounds like a local issue, events work just fine in a proper install.

G
 
Got a chance to try this finally. Fantastic work, guys! I kind of wish this was just in the installation packet. The negative events are a LOT more fun than "Oh, hey, your farms a burning" and when they DO randomly take a dump on the player, at least they're funny about it. (I especially appreciate the tournament event, which in its worst-case scenario has an option like, "Wait, tournament? Shouldn't someone on our end be organizing this? Get someone on that. What's that noise...?" <BARB SPAWNING INTENSIFIES>

I think some of the events are a perhaps a mite over-turned, but I can't say without a lot more... testing. Yes. We'll call it testing. :lol:
 
Great :D
Please do provide any balance feedback, I'm constantly coming across choices and thinking, hang on, that's not very much science to be paying on turn x, or, that's quite a lot of science to be paying on turn y. For example.
 
EDIT: Managed to find the problem. Nevermind.

I'm currently puzzled by the event "Teach Us Your Ways." I want to select the jungle option to give yields to my sugar plantations, but it says I "require jungle feature", despite having multiple jungle tiles in my city borders and even a sugar + jungle tile I have to yet to build a plantation on. Is this a bug or am I missing something?
 
Back
Top Bottom