Disasters and Events

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

Disasters and Events

Postby drakeraider » Sat Apr 25, 2020 8:47 am

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: 493
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Disasters and Events

Postby Ignatus » Sat Apr 25, 2020 2:21 pm

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

Postby drakeraider » Sat Apr 25, 2020 6:08 pm

For that matter, is there any way to control the Actions that some units have? Like replacing the Sabatoge action?

Ignatus
Elite
Posts: 493
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Disasters and Events

Postby Ignatus » Sat Apr 25, 2020 10:30 pm

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

Postby drakeraider » Thu May 28, 2020 12:50 am

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: 493
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Disasters and Events

Postby Ignatus » Thu May 28, 2020 9:06 am

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...