Disasters and Events

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
Post Reply
drakeraider
Posts: 27
Joined: Sat Feb 03, 2018 11:49 pm

Disasters and Events

Post by drakeraider »

Two things I want to do.

Is there a basic guideline for defining disasters (or beneficial events) in LUA? Civ 4 has alot of these, and it reminds me of a tabletop RPG when they happen for some reason, so I really enjoy including them.

Second,

Can I use LUA to check if a city matches certain requirements similar to the way effects work?
What I plan to do is have a building that, every turn, has a 1% chance of being built for free in any city connected by traderoute.
I have a workaround that could loosly emulate the end goal, but if this is possible for my project, it will be infinitely neater.

Is there anyone who is familiar enough with LUA to be able to be of service?
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Disasters and Events

Post by Ignatus »

The reference of what Lua API is currently available is here: Lua reference manual. It's very limited yet compared to CivIV, thus, disasters are hardly controllable, and you can't put buildings in cities. I have filed a topic on what API we need but currently active developers manage other problems. So probably it's no way now to give a free building by chance if you don't mod the binaries.

In v.3.1 you can try this: with 1% an extra appears on a city tile that enables an effect "Building_Build_Cost_Pct" making this building just very cheap for the city.
drakeraider
Posts: 27
Joined: Sat Feb 03, 2018 11:49 pm

Re: Disasters and Events

Post by drakeraider »

For that matter, is there any way to control the Actions that some units have? Like replacing the Sabatoge action?
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Disasters and Events

Post by Ignatus »

doc/README.actions (link to the development versions, but some things are available in 2.6, including ui name change).
drakeraider
Posts: 27
Joined: Sat Feb 03, 2018 11:49 pm

Re: Disasters and Events

Post by drakeraider »

If I read this right, I can create a "Missionary" unit that can build some extras to emulate a "Religious spread" mechanic. I'll have to think a bit about how I want this to work.

I'm trying to find how sabotage works, to learn if it's possible to destroy buildings.

Is there a way to destroy buildings? And if so, can I destroy small wonders at all? My particular goal on that is to have a specific set of wonders that can be destroyed by a revolution, for various reasons, but it could also be an asset for religious/diplomatic gameplay as well.
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Disasters and Events

Post by Ignatus »

drakeraider wrote:I'm trying to find how sabotage works, to learn if it's possible to destroy buildings.

Is there a way to destroy buildings? And if so, can I destroy small wonders at all? My particular goal on that is to have a specific set of wonders that can be destroyed by a revolution, for various reasons, but it could also be an asset for religious/diplomatic gameplay as well.
If you mean sabotage action, you should enable targeted sabotage and set sabotage probability to nonzero value for the building in buildings.ruleset.
If you mean a disaster, "DestroyBuilding" type is what does it, but it just can't ever strike wonders. Small wonders are removed by transferring a city to another player (e.g. you move out all city units, create a barbarian unit and move it in, then destroy the barb and move the units back, but this also reduces pop on 2 and has a lot of other quirks). Alas, the API is poor...
Post Reply