• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

User Events

veyDer

Chieftain
Joined
Jan 12, 2010
Messages
16
User Events
Current version: 1

Mod component for defining user events to randomly appear in the game.

Events can have one or more available options for the user to choose from, each with a separate set of effects and availability conditions.

Description
The mod is similar to the Random Events mod, but the mod creator can specify the list of events and a set of available options. Basically, it's the functionality of random events from CIV4's mod Fall From Heaven 2. The game checks, whether a given option is available and presents the user with the list of all options. The user can choose any of the available options and the specific effect will be applied.

Example:
"Wandering Wiseman"
A wandering wiseman appears at {name of the capital city} and wants to share some of his knowledge with you in exchange for some gold.

Options:
1. "Ask him to become your advisor.": -250gold, +1 Great Scientist (available only if the player has >= 250 gold)
2. "Ask him to teach some of your advisors": -100gold, random effect (available only if the player has >= 100 gold)
3. "I don't have time nor money for this nonsense!" - no effect (always available)

Another example:
"Parrots"
Citizens of {name of the city} discovered some rare parrots in the near jungle and started to trade them.

This event can only affect the plot with the Jungle feature and only if the player has discovered Animal Husbandry. The only option is to apply the effects of the event (i.e. +1 gold yield from the Jungle plot).


Also, every event can have a different probability or may trigger other events (with probability 0.0 otherwise). Event effects can be delayed (e.g. a unit will be promoted in 2 turns from the event).

Special thanks:
Whys - for SaveUtils
alpaca - for numerous Lua hints/recipes
greyTiger, smellymummy - for code examples


Available in-game (search for "User Events") or attached to this post.
 

Attachments

Can you explain this better?

Is this like the Random Events mod? Is this a utility, a UI mod, or what?
 
Yes, it is similar to the Random Events mod, but the mod creator can specify the list of events and a set of available options. Basically, it's the functionality of random events from CIV4's mod Fall From Heaven 2. The game checks, whether a given option is available and presents the user with the list of all options. The user can choose any of the available options and the specific effect will be applied.

Example:
"Wandering Wiseman"
A wandering wiseman appears at {name of the capital city} and wants to share some of his knowledge with you in exchange for some gold.

Options:
1. "Ask him to become your advisor.": -250gold, +1 Great Scientist (available only if the player has >= 250 gold)
2. "Ask him to teach some of your advisors": -100gold, random effect (available only if the player has >= 100 gold)
3. "I don't have time nor money for this nonsense!" - no effect (always available)

Another example:
"Parrots"
Citizens of {name of the city} discovered some rare parrots in the near jungle and started to trade them.

This event can only affect the plot with the Jungle feature and only if the player has discovered Animal Husbandry. The only option is to apply the effects of the event (i.e. +1 gold yield from the Jungle plot).


Also, every event can have a different probability or may trigger other events (with probability 0.0 otherwise). Event effects can be delayed (e.g. a unit will be promoted in 2 turns from the event).
 
Available subjects of event conditions and effects:

* player
* city
* unit
* plot
 
Beautiful, then.

Reminds me of Europa Universalis, actually.

So, on ActivePlayerTurnStart, you run through every player, plot, city, and unit and do a probability check? Or do you run the probability check first, then look for an appropriate condition in the game?
 
I randomize the list of events first, then for each event I test run the probability check and if satisfied check the conditions (I check every plot in the player territory and every plot with a unit of the player) and display the event only, if there is at least one available option. Otherwise, I continue with the next event.
 
is this mod more of a template for those wishing to add in their own individual random events or is this mod complete with a list of events and text, etc. Also what sort of compatibility problems would this run into with other mods?
 
At the moment it's just a template (with only four example events), but I'm working on some "event packs".

As for the compability... It doesn't modify any core game files and I've been trying to make it as independent from other mods as possible, so it shouldn't cause any compability problems.
The mod declares some LuaEvents, so there could be a possible collision there, but that's pretty unlikely.
 
Looks great. Might just bring back an ince of flavour to the game.

Looking forward the the event packs.

\Skodkim
 
I love this, as I loved it in Civ IV. Would it be possible, with the animal ones (Eg. Parrots found) for a resource (Parrots) to actually appear on the map?

Totally doable except custom graphics for resources don't work now
 
My guess is that we will not see source code until after the new dev team goes through the various systems with a comb. I fully expect patches to combat AI, diplomatic AI, maintenance functions, research agreements and trade, and engine efficiency before we get the .dll.

What I can see being released before that is fixes to the current file setup where several graphic changes are loaded through a modifiable database, giving us more tools at our disposal.
 
Hi

How's it comming along with new event packs? I'm reaaly enjoying v1 but would like to see more.

Input: The Wandering wiseman options are imo to cheap. In mny own game I modified the gold values to 250/500 gold which I feel is more fair since the effects are so good.

Good job so far!

\Skodkim
 
veyDer, great job for making an easy-to-edit random event generator. Kuddos.

I must say I'm surprised there are no responses filled with user-made events yet, so I guess I'll be the first to post something. I've been making some events of my own, and I'll share them with whomever wants them here.

Update 03-05-'11: Nevermind this post, I'll make a new thread for it...
Spoiler :

Random Events:

Added in version 3
Fixed some bugs
Changed "Minerals" and "Fertile Soil"


Local Artist - $ 150: City gets 3 extra plots
- $ 300: City gets Cultural Building
- $ 0: City gets 1 extra plot
Pioneers - Small city gets 1 extra plot
Flash Flood - All river-buildings destroyed in a city
Hurricane - Windmill/Solar Plant/Broadcast Tower destroyed by weather
Nuclear Meltdown - Nuclear Plant explodes (very rare event)
Fertile Soil - Now gives a farm Wheat
New Minerals - Mine gets random minable Resource
New Plant - Unimproved plot gets random Plantation Resource

Added in version 2

Meteor - Nuke damage near a city (rare event)
Nomads - Get a free Worker
Golden Age - Starts a Golden Age
Revolt - City becomes "occupied", needs courthouse against unhappiness.
Tidal Wave - All "Coastal" buildings in the city are destroyed.
Entrepeneur - Free Market/Bank/Stock Exchange in a city.
Monarchy - Benefit for Monarchy civ: Extra pop in capital.
Meritocracy - Benefit for Meritocracy civ: Extra Gold for each non-puppet civ.
Discipline - Benefit for Discipline civ: Second Attack promotion for a unit.

Added in version 1
Wandering Wiseman - Pay a lot of Gold: Great scientist.
- Pay some Gold: Random effect.
- Pay nothing: Nothing happens.
Skilled Engineer - Increases current production progress in all cities, increased if you're willing to spend gold.
New Spring - New oasis in desert tile
Parrots - Extra Gold in jungle tile
Rare Herbs - Extra Food and Gold in marsh tile
Resort - Extra gold in atol tile
Tradecenter - Tradecenter becomes Customs House
Renown - Extra Culture in Special-Improvement tile (Academy, Customs House etc...)
Tornado - Improved tile becomes pillaged.
Market Crash - Lose gold
Investments - Gain gold
Plague - City population decreased
Population Boom - Additional Population in a city
Diseased Unit - Unit damaged
Ancient Scrolls - Free Policy
Assimilate City - Puppeted city becomes annexed, without the "Occupied" happiness penalty.
Training - Unit gains extra XP



All events work. The one bug I know of, is that effects can stack (yeah, academies can be extra, extra, extra famous), but it's mostly a flavor issue, nothing game-breaking. Also, terrain/improvement-specific effects stay after changing the tile's terrain/improvements.

I've edited the original events a bit too. For example, I thought the wiseman's special effects were too powerful for his cost, so his costs scaled with your current Era.
Anyway, if anyone has any (doable) ideas for additional events, don't hesitate to post them, I'll see what I can do. Maybe post some further 'versions' of my user events.
 

Attachments

veyDer, great job for making an easy-to-edit random event generator. Kuddos.

I must say I'm surprised there are no responses filled with user-made events yet, so I guess I'll be the first to post something. I've been making some events of my own, and I'll share them with whomever wants them here.

Update 27-04-'11: "Version 2", couple of new events.

Random Events:
Spoiler :

Added in version 2:
Meteor - Nuke damage near a city (rare event)
Nomads - Get a free Worker
Golden Age - Starts a Golden Age
Revolt - City becomes "occupied", needs courthouse against unhappiness.
Tidal Wave - All "Coastal" buildings in the city are destroyed.
Entrepeneur - Free Market/Bank/Stock Exchange in a city.
Monarchy - Benefit for Monarchy civ: Extra pop in capital.
Meritocracy - Benefit for Meritocracy civ: Extra Gold for each non-puppet civ.
Discipline - Benefit for Discipline civ: Second Attack promotion for a unit.

Added in version 1:
Wandering Wiseman - Pay a lot of Gold: Great scientist.
- Pay some Gold: Random effect.
- Pay nothing: Nothing happens.
Skilled Engineer - Increases current production progress in all cities, increased if you're willing to spend gold.
New Spring - New oasis in desert tile
Parrots - Extra Gold in jungle tile
Rare Herbs - Extra Food and Gold in marsh tile
Fertile Soil - Extra Food in farm tile
Resort - Extra gold in atol tile
Minerals - Extra production in mine tile
Tradecenter - Trading Post becomes Customs House
Renown - Extra Culture in Special-Improvement tile (Academy, Customs House etc...)
Tornado - Improved tile becomes pillaged.
Market Crash - Lose gold
Investments - Gain gold
Plague - City population decreased
Population Boom - Additional Population in a city
Diseased Unit - Unit damaged
Ancient Scrolls - Free Policy
Assimilate City - Puppeted city becomes annexed, without the "Occupied" happiness penalty.
Training - Unit gains extra XP


All events work. The one bug I know of, is that effects can stack (yeah, soil can be extra, extra, extra fertile), but it's mostly a flavor issue, nothing game-breaking. Also, terrain/improvement-specific effects stay after changing the tile's terrain/improvements.

I've edited the original events a bit too. For example, I thought the wiseman's special effects were too powerful for his cost, so his costs scaled with your current Era.
Anyway, if anyone has any (doable) ideas for additional events, don't hesitate to post them, I'll see what I can do. Maybe post some further 'versions' of my user events.

Hi Hipfot

You're right - I can't understand why this thread doesn't have any more visitors too - Random Events add flavour to the game.

Thanks for your files with events. I took a look at them and they seem great. Can't wait to try them out. Just have a question regarding some of the conditions where you seen to have e.g. two "if"'s for a specific improvementtype. At least two instances:

Two times Academy
Spoiler :
--[[ Renown ]]--
-- condition function
function RenownCond( player, city, unit, plot )
-- valid only on plots with mine and mining.
return city
and (plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_ACADEMY" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_ACADEMY" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_CITADEL" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_MANUFACTORY" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_CUSTOMS_HOUSE" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_LANDMARK" ].ID )
and _PlayerHasTech( player, "TECH_PHILOSOPHY");

end

Two times Farm
Spoiler :
--[[ Tornado ]]--
-- condition function
function TornadoCond( player, city, unit, plot )
-- valid only on plots with mine and mining.
return city
and not plot:IsImprovementPillaged()
and (plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_MINE" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_PLANTATION" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_FARM" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_TERRACE_FARM" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_FARM" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_QUARRY" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_TRADING_POST" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_LUMBERMILL" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_PASTURE" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_CAMP" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_WELL" ].ID
or plot:GetImprovementType() == GameInfo.Improvements[ "IMPROVEMENT_FORT" ].ID );
end


Any idea behind this or did you just miss it?

Anyway I'm pasting my own two little cents with this post. It's not much but I'm really a noob at lua.

\Skodkim
 
Hey skodkim,

No, there's no reason behind it at all. Just an oversight on my part ;) Thanks for finding them, I'll have them removed in a next version. Good job on making more events too, I hope some day there'll be a hundred random events for people to enjoy.
 
Back
Top Bottom