Civ2units 1453 scenario with LUA and ToTPP 0.15

I would like to restrict the Barbarian Pirate Ship unit to move out of this area. Would something like this possible in Lua?
If yes, would it difficult to write a code which works? I'm not a programmer, so I would like to ask one of you for a code, but only if it doesn't mean
too much work for you

It would be easy to delete or move the units that leave the area. I suppose you could also give them a goto order. What do you want done with the pirate ships that attempt to leave?
 
Well, I was thinking about to send the ships back to the Caribbean if they cross the invisible border.

I like the idea @tootall_2012 mentioned in his playtest to create a sea zone where each pirate ship unit located in the zone would substract an amount of money from the players treasury. Currently I have three pirate strongholds in the Caribbean which can be conquered by the player. These strongholds spawning Pirate ships from time to time.

I also changed the Spanish Treasure Fleet event. The player don't get an amount of money each turn, instead there will be spawned a Treasure Galleon from time to time which has to sail to Cadíz to get gold as benefit.

Is it possible to create with lua an event that the player can disband the Treasure Galleon in Cadíz by pressing a certain key and he gets an amount of gold as benefit?
 
btw, how does the goto order work? Honestly I never used it before.
Use gen.setToGoingTo(unit,tile). This has 2 advantages over setting unit.gotoTile directly. 1. The tile can be 'nil' without error. 2. The tile can be a coordinate triple instead of a tile.

In principle, the unit should go to the tile specified, unless something makes the AI reconsider. One such thing might be coming across an enemy unit (this stops human goto orders as well). Sometimes, however, the AI decides it has a better use for the unit. In Hinge of Fate, the AI decided that the freighters were Sea Transport, and so tried to make them do something else from time to time. Changing the role of the unit eliminated that problem as far as I am aware.

Well, I was thinking about to send the ships back to the Caribbean if they cross the invisible border.

I like the idea @tootall_2012 mentioned in his playtest to create a sea zone where each pirate ship unit located in the zone would substract an amount of money from the players treasury. Currently I have three pirate strongholds in the Caribbean which can be conquered by the player. These strongholds spawning Pirate ships from time to time.

I also changed the Spanish Treasure Fleet event. The player don't get an amount of money each turn, instead there will be spawned a Treasure Galleon from time to time which has to sail to Cadíz to get gold as benefit.

Is it possible to create with lua an event that the player can disband the Treasure Galleon in Cadíz by pressing a certain key and he gets an amount of gold as benefit?
These are all pretty easy to do with Lua.
 
Use gen.setToGoingTo(unit,tile). This has 2 advantages over setting unit.gotoTile directly. 1. The tile can be 'nil' without error. 2. The tile can be a coordinate triple instead of a tile.

In principle, the unit should go to the tile specified, unless something makes the AI reconsider. One such thing might be coming across an enemy unit (this stops human goto orders as well). Sometimes, however, the AI decides it has a better use for the unit. In Hinge of Fate, the AI decided that the freighters were Sea Transport, and so tried to make them do something else from time to time. Changing the role of the unit eliminated that problem as far as I am aware.


These are all pretty easy to do with Lua.
This sounds very good.

Currently I'm completing the events in the Caribbean. When I'm ready with it, I would like ask you for assistance with the lua codes.
 
After releasing my AWI scenario I'm planning to design a new scenario. This time it will be a typically Civilization 2 game with technology research, government switching and unit upgrading.

What I´m planning is to set up a scenario in Europe, starting in the year 1453 and ending in 1600. With the fall of the Eastern Roman Empire a new time started and Europe went into the Renaissance. Old warfare with Knights and Swordsmen will be replaced by modern warfare with gunpowder and Cannons. Famous conflicts during that time period like the War of the Roses, the 80 Years War or the Ottoman march towards Vienna will be represented. Also many upcomming social conflicts like the Reformation will appear. It's a time where the old world stepped into a new modern world.

Nearly all civs will be playable. Currently I´m planning with the following civs:
- Holy Roman Empire
- Kingdom of England
- Kingdom of Spain
- Kingdom of France
- Ottoman Empire
- Grand Duchy of Moscow/Kingdom of Russia
- Independent States (not playable)

This is the map which I would like to use for the scenario:
View attachment 574004

And of course I will also try to use the possibilities of LUA scripting for this scenario.:)
This looks very intriguing, as do your other ideas. Era-regional scenarios as opposed to specific event, front, campaign or war scenarios, or era-global scenarios, were my very first ideas for Civ2 scenarios (however crude my earliest ones may have been, with such unevocative titles as Asia2 and SouthAm1 - I was an utter noob at the time, years ago) and I have ideas for future such style of scenarios. An interesting question, though. How would you potentially put, mid-game, the Holy Roman Empire and the Kingdom of Spain under one leader (Karl V/Carlos I), and then have become separate again in his famous, "penitent," dismantling and distribution to multiple heirs of his inheritance?
 
Hello @Patine,
many thanks :thumbsup:

Currently I'm overworking my scenario which I finally named 'Age of Reformation' and covered the time period from 1517 to 1645. I know about the division of the Habsburg Empire into a Spanish and an Austrian line but in my game both nations are united during the game. I'm afraid dividing the Empire it could affect too much on the gameplay. Especially with the habsburgs you have the full range of gameplay, from the colonization of Central and South America to the Ottoman Wars until the religious and social conflicts during the Reformation.

Btw, if you would like to play a game with the current version, you will find the files here:
Age of Reformation
 
I've made some major updates on my Reformation scenario. The events of the Thirty Years War are now complete excluded and will find their way into an own scenario in future. Fairline has drawn a lot of great 30YW units, they should deserve their own scenario.

In the new version beside the Habsburgs, the Ottomans, France, Protestants and Mesoamericans are playable too which means that every nation get their own events. A lot of events are already done, except those for the Protestants and Mesoamericans. The colonization of the New World and the Reformation are the main events for the European nations, for the Ottomans the conquest of the Middle East and Africa.

The New World is now filled with much more life. Beside random events for every nation pirates will be a real threat in the Caribbean now. Tootall_2012 had some nice ideas (thanks for that) and Prof.Garfield wrote the codes to realize them (also thanks for that).

Ships will be attacked by the pirates, so it would be wise to protect them within the Caribbean Sea. Pirates are also able to make raids on cities in the Caribbean and plunder a certain amount of gold from the players treasury.

Currently the work is still in progress but I will let you know when a first playable version will be ready.

Pirates have plundered a Spanish treasure galleon
1667307645344.png
 
Just one question. Tootall_2012 made a playtest with my updated Reformation scenario and has encountered maybe a curious bug.

When he has built the Coastal Defence improvement in one of his cities and as followed the city was attacked by an enemy naval unit, the pop up ingame text box 'Coastal Defence bonus' didn't appear.
I checked my scenario files and found nothing. I also didn't disable the pop up text boxes via lua.

Does anyone had this bug too and found maybe a solution to fix the bug?
Currently I'm using ToTPP Version 0.18.4
 
Would it be possible to limit the options for the diplomat menu via lua?
I would like to allow only 'Investigate City' if possible.
You can eliminate options (for the human player) by editing game.txt. There isn't a direct way to interfere with this menu using Lua. You could prevent technology theft (except from spies) with something like
Code:
for city in civ.iterateCities() do
    gen.setTechnologyStolen(city)
end
You also have the option to use
Code:
gen.setCityInvestigated(city)
which will set the flag that allows the human player to look inside an AI city. You would have to come up with some sort of event for choosing when spying takes place.
 
Hi civ2units,

Prof. Garfield is correct, there are two methods you can use to limit units spy abilities.

The first is to modifiy the @SPYOPTIONS section in the game.txt file. You can remove any of the 7 options available to the diplomats (IMPORTANT: you simply remove the text associated to the option but keep the line itself)

Code:
-- keeping all options
@SPYOPTIONS
Establish Embassy
Investigate City
Steal Technology
Industrial Sabotage
Poison Water Supply
Plant Nuclear Device
Incite a Revolt

-- Example: keeping only 3 of the 7 options: investigate, device and incite options (note how the space for the removed options are still present)
@SPYOPTIONS

Investigate City



Plant Nuclear Device
Incite a Revolt

The second allows you to give the spy ability to ANY unit (not just diplomats) using lua.

Check out the 'keyPressEvents.lua' file from John's HoF scenario where he gave the GermanScoutCar and German Scout Planes the ability to spy on cities. In this case, either unit which is located next to an enemy city can investigate the city by pressing on the 'k' key.

Code:
local function photoRecon(unit)
    if (civ.getActiveUnit().type == object.uGermanScoutCar or civ.getActiveUnit().type == object.uGermanScoutPlane)then
    civ.playSound("Spysound.wav")
        for _,tile in pairs(gen.getAdjacentTiles(civ.getActiveUnit().location)) do
            if tile.city and tile.city.owner ~= civ.getActiveUnit().owner then
                text.simple("Our photo reconnaissance unit has brought back information about "..tile.city.name..".  Click on the city to see the information.","Reconnaissance")
                gen.setCityInvestigated(tile.city)
            end
        end
    end

end
 
Hi, @civ2units , I'm currently playing older version and I can say it's in the top 3 scenarios I've ever played. There are small issues though:
1. Since Armour Factory improvement is needed for Siege Mortar units to build, the Habsburgs will never be able to build the unit for as long as they control the city with Dutch Textile Industry wonder (Antwerp), since it acts as the Hydro plant in all cities (which supersedes Power plant/Armour factory).
2. Similary with Peasants: since they require Granary, after capturing Jerusalem which has Dome of the Rock (Pyramids), no more granaries can be build, therefore cities which don't have them can't build Peasants.
These were probably unintended wonder side effects.
3. As for the game ballance, The Ottomans play a very passively (even in their own territory), while in reality they represented very existential threat. To give them more active role I've made some changes in the Rules.txt and canBuildSettings.lua: Ottoman Arquebusiers are available in all Ottoman cities now. Dhows (which were unbuildable) are now available in Algiers, Tunis, Tripolis and Alexandria. Mamlukes are available in Alexandria, Cairo and Siyut. Janissaries available in all "core" Ottoman cities. Protestants can now build sail ships in Oslo (given that it has Shipyards improvement) to give them alternative port to Amsterdam if they fail to capture it.
4. Rebels/barbarians are being overproduced in some cities while completely absent from others (see 1st screenshot). I don't know how to fix this (maybe we can change which barb cities currently produce units with Lua).
5. English are concentrating their Caravels in Calais for some reason. Once I've laid a siege to that city only to kill some ~15 caravels. This is something the AI does, I'm not sure can it be stopped.
6. Neutrals/Christan Nations (over)produce Peasants, even though they shouldn't produce any (2nd screenshot).
7. After acquiring Antigua and Anguilla, the English inherit large number of Native Warriors which they then ship to Calais! AI bug?
8. Sometimes, Fortress unit is being transported in ships. I've intercepted French Caravel transporting a fortress from Marseilles to my (empty) Santo Domingo colony. This is easy fixable by setting Fortress as an air domain or even better, a "Domain 3" unit, which doesn't suffer from "air unit in a city" penalty when attacked.
9. Protestants send large number of units eastwards (3rd screenshot). AI bug, again?
10. Neutrals are producing Pikemen in the eastern cities (4th screenshot). Was this intended?
 

Attachments

  • Screenshot_2023-04-27_15-25-57.png
    Screenshot_2023-04-27_15-25-57.png
    322 KB · Views: 54
  • Screenshot_2023-04-27_15-30-43.png
    Screenshot_2023-04-27_15-30-43.png
    175.7 KB · Views: 58
  • Screenshot_2023-04-27_15-40-24.png
    Screenshot_2023-04-27_15-40-24.png
    667.2 KB · Views: 58
  • Screenshot_2023-04-27_15-40-32.png
    Screenshot_2023-04-27_15-40-32.png
    266.3 KB · Views: 60
Hello @Nightgoblin, please appologize my late reply. Currently I only checks the SL irregular because real life is very busy.

Anyway, many thanks for playing my scenario and great to read that you enjoyed the scenario.

Honestly I didn't aware the effect the two wonders have on the units building list. This is something I have to fix.
In my updated version the Ottomans will be a playable fraction, so they have build restrictions. If they are controlled by the AI, I will give them more units via events.
Of course the Protestanbts should be able to build ships in Oslo. It seems that I just forgot to set it in the canBuildSettings.lua. Many thanks that you fixed it.
Unfortunatelly the AI makes a lot of stupid things. I try to avoid most of them by changing the diplomacy status via events, so that the AI from time to time gets into war to each other.
Neutrals should be only able to produce Supply Wagons and Fortresses. I have to fix this too.

Again many thanks for playing the scenario and giving me a good feedback. :thumbsup:
 
Does anyone knows if it would be possible to give units the advanced abilities from vanilla game Freight and/or Engineers units?
I know that i can change the role of an unit in the rules file but then they have only the standard Settlers/Caravan abilities.
 
@ UNITS_ADVANCED column G, the sixth bit from the right, allows you to give a unit Engineering abilities (where it works twice as fast as a Settler).

I'm not aware of any way to give a unit the Freight capability; that seems to be hardcoded to the unit type with ID 49. If I'm wrong, someone please correct me!
 
@ UNITS_ADVANCED column G, the sixth bit from the right, allows you to give a unit Engineering abilities (where it works twice as fast as a Settler).

I'm not aware of any way to give a unit the Freight capability; that seems to be hardcoded to the unit type with ID 49. If I'm wrong, someone please correct me!
Are spy traits slot hardcoded, too?
 
Top Bottom