[TOTPP] Prof. Garfield's Lua Code Thread

Prof. Garfield

Deity
Supporter
Joined
Mar 6, 2004
Messages
3,936
Location
Ontario
Hello @Prof. Garfield .
I'm wondering if there's a possibility to break the "7civs" limit with the current system, jumping to the 21 described in rules.txt civs, (or even more) :

-Have a table for diplomatic relations.
-Have a table for each civilisation knowledges, units and cities owned
-Play 3 different turns like ONE same turn (and trick time displayed accordingly).
-Have secured useless "government" cities for 7 players
-At the beginning of new turn, gives the civ its accordingly units & territory and adapt its knowledges, make it at the end of previous tribe's turn human or not.
Divide all other units and territories between altered other 6 civs : "Allied civs", "At Peace civs", "At War civs", "Unknown civs", "Specific civ on diplomatic purpose (to elaborate for AI- maybe not needed for historical scenarios)"
-Some graphical consequences are to be thought indeed, yet, maybe does it worth it ?

Doable ?

Guess that could interrest @JPetroski , @tootall_2012 , @Knighttime , @CurtSibling , @Blake00 , @Pablostuka and others too.
This seems technically doable (I can't think of a reason why it wouldn't work off the top of my head), but it would take a very large amount of work, and all sorts of code that has already been written would be useless in that system. Also, players might find it difficult to figure out exactly where one tribe ends and another tribe begins if they are all lumped together based on current diplomatic status. I have no idea how the AI would cope with thinking that all the other tribes are massive either, but you're certainly not going to get game-driven diplomacy between each faction.

I'm inclined to think that all that work isn't worth the value of extra civs. With 7 civs and barbarians, you already have enough room for 5 or 6 factions, and some unaligned territory as well. I would argue that it makes more sense to change the owner of units and cities to one of the major factions when appropriate, and use other Lua tools (like can build settings) to represent the fact that tribes represent alliances and not single unified nations.

On another less enthousiastic point, sorry for not dwelving in your most recent template, but did you manage to allow caravan comodities allocation ?
I don't believe I've done any specific work on caravan commodities or trade routes. If I've promised you something, I've forgotten about it, so I'll need a reminder. I'm not sure what you mean by "caravan commodities allocation".
 

Dadais

King
Joined
Oct 20, 2010
Messages
722
Location
France
I don't believe I've done any specific work on caravan commodities or trade routes. If I've promised you something, I've forgotten about it, so I'll need a reminder. I'm not sure what you mean by "caravan commodities allocation".
No promises on your side.
Just respect towards your wizardry. :)
I meant changing (or defining) what goods freighters are holding. If not wrong at the moment, caravan created with lua all hold the first generic good ?
Also, players might find it difficult to figure out exactly where one tribe ends and another tribe begins
That's a point indeed.
 

Prof. Garfield

Deity
Supporter
Joined
Mar 6, 2004
Messages
3,936
Location
Ontario
I meant changing (or defining) what goods freighters are holding. If not wrong at the moment, caravan created with lua all hold the first generic good ?
Oh. I'm 99% sure you use unitObject.domainSpec to change that.
 

Dadais

King
Joined
Oct 20, 2010
Messages
722
Location
France
Oh. I'm 99% sure you use unitObject.domainSpec to change that.
Missed that ! Much thanks !

I'm inclined to think that all that work isn't worth the value of extra civs. With 7 civs and barbarians, you already have enough room for 5 or 6 factions, and some unaligned territory as well. I would argue that it makes more sense to change the owner of units and cities to one of the major factions when appropriate, and use other Lua tools (like can build settings) to represent the fact that tribes represent alliances and not single unified nations.
I agree many scenario can do as well and even better without that.

On the other side, I believe some others could use it with true benefit !
One could also imagine rather than a scenario giving a "normal" playthrough on worldmap, which would feel way less empty with 21+ civs than with 7 !
 
Last edited:

Dadais

King
Joined
Oct 20, 2010
Messages
722
Location
France
I'm wondering if there's a possibility to break the "7civs" limit with the current system, jumping to the 21 described in rules.txt civs, (or even more) :

-Have a table for diplomatic relations.
-Have a table for each civilisation knowledges, units and cities owned
-Play 3 different turns like ONE same turn (and trick time displayed accordingly).
-Have secured useless "government" cities for 7 players
-At the beginning of new turn, gives the civ its accordingly units & territory and adapt its knowledges, make it at the end of previous tribe's turn human or not.
Divide all other units and territories between altered other 6 civs : "Allied civs", "At Peace civs", "At War civs", "Unknown civs", "Specific civ on diplomatic purpose (to elaborate for AI- maybe not needed for historical scenarios)"
-Some graphical consequences are to be thought indeed, yet, maybe does it worth it ?

You sillies @JPetroski , @tootall_2012 , @Knighttime , @CurtSibling , @Blake00 , @Pablostuka , @Fairline , @Tanelorn , @Patine , what are you thoughts about that please ?

(Let's imagine per exemple a Sengoku scenario with 43 playable and playing clans, or a colonisation one depicting seven colonies civs, their seven european rulers, and up to fourteen or twenty one amerindian tribes ?)
 

JPetroski

Deity
SLeague Staff
Joined
Jan 24, 2011
Messages
4,562
You sillies @JPetroski , @tootall_2012 , @Knighttime , @CurtSibling , @Blake00 , @Pablostuka , @Fairline , @Tanelorn , @Patine , what are you thoughts about that please ?

(Let's imagine per exemple a Sengoku scenario with 43 playable and playing clans, or a colonisation one depicting seven colonies civs, their seven european rulers, and up to fourteen or twenty one amerindian tribes ?)

Well, it's definitely an interesting concept, but I think it would be beyond my efforts to ever build. HoF was a pain in the butt just dealing with 12 rules files and I never want to do that again - and what you're proposing, I would think, would be purely massively expansive and just not feasible for myself, at least, to build.

I was kicking around the idea of eventually doing a Roman scenario where I would try and break the 7 factions with lua, but it would be done by simply recycling one. For example, both Carthage and Macedon really don't need to be around for the entirety of a scenario, and could be replaced by Parthia and the Cherusci (or whomever) that don't realy need to be around in the beginning. I don't know if I'll ever make the scenario, but that would be how I'd use lua to get more than 7 tribes out of it.
 

Knighttime

Prince
Joined
Sep 20, 2002
Messages
364
@Dadais Interesting that you posted about this... I've had almost the exact same thoughts. I even spent some time trying to sketch out a structure of text files and Lua functions, to see where I ran into problems. This was awhile back, though, and some of the issues I discovered then have been addressed by more recent TOTPP versions, with more Lua capabilities.

@Prof. Garfield zeroed in on what I think is the biggest issue, namely diplomacy. I think the solution would have to include a complete diplomacy module, written entirely in Lua, which would attempt to replace the game's built-in diplomacy logic for all nations (human and AI). In other words, the civ.scen.onNegotation() trigger would call this separate module, and then return false to prevent any of the game's default interaction between tribes. Unfortunately, though, blocking all negotiation in that trigger doesn't always prevent diplomacy status changes, as @tootall_2012 and I found out while creating Napoleon. (We had to track desired diplomatic statuses and restore them from Lua when they were changed by the game.) So all of this would take rather a lot of work, and it might also lead to a game that doesn't "feel" as much like Civ 2 as we know it.

Other issues that I encountered:
  1. There is a lot of data to write, to prepare the game state for a new nation to take their turn. For example, visibility, last-known tile improvements, and last-known city sizes are stored for every tile on the map, for every tribe. Lua is fast, but especially on a big map there might be some noticeable lag before every nation's turn as all of this game data is copied from the state table into the actual game objects. And let's face it, if you want to play with 20 or 40 or 60 unique nations, you're probably going to want a big map!
  2. Some advanced features present in Rules.txt, like tech groups (the @ LEADERS2 section) couldn't be effectively read from this file. If you want that concept, you'd have to define and code all of that some other way. Same with the city lists read by the game from City.txt -- you'd have to have your own handling for that functionality.
  3. It seems that tribe.scienceRate and tribe.taxRate are not writeable fields from Lua events. So when a new nation's data is written into one of the 7 tribe slots known to the game, it will simply inherit the rates used by the last occupant of that tribe slot. The nation could decide to change the stored values during its turn, but I suspect this would happen after their cities are processed, when it wouldn't do any good.
  4. The game was designed so that each civilization (tribe) has the concept of a "key civ" which combines with power ratings to determine actual research costs. If the tribes now represent conglomerates grouped by treaty status, that entire system would be disrupted (I'm not sure how well this could be anticipated or predicted). Note that tribe.researchCost is also not writeable.
Despite this somewhat gloomy assessment, I haven't given up entirely on this idea, and I might be willing to give it a try someday. :) It would just be so cool to be able to play a massive game with 20+ competing nations that I could accept a few drawbacks along the way. But the amount of upfront work involved, just to get a proof-of-concept going, has deterred me so far.

If you pursue this, please keep us in the loop on your progress!
 
Last edited:

Blake00

CFC Archivist & Social Media Helper
Moderator
Supporter
Joined
Sep 24, 2016
Messages
1,457
Location
Australia
Opps somehow missed your original question.. although not being a lua coder I kind gloss over everything in this thread and let you experts do your thing as it's a bit beyond me haha. ;)

However yes breaking the 7 player limit is a dream of many especially when you consider ToT's fantasy/midgard and Scifi scenarios across 4 giant worlds. Imagine them with a full 21 line up.. would be so cool!

This was all talked about over in the Civ2 clone rebuild thread as a requested feature but who knows if and when that'll ever get done.. so that's pretty cool that it's even remotely possible for you guys to do it in the original engine!
.
 

Dadais

King
Joined
Oct 20, 2010
Messages
722
Location
France
@Dadais Interesting that you posted about this... I've had almost the exact same thoughts
I'm glad this little intuition on my side met your genius thoughts !

Despite this somewhat gloomy assessment

Those do seems extremely valuable, and quite encouraging in fact ?
This gives some more limits (tech levels to be somehow similar per exemple), reminds of the much important visibility part and other game aspects not to forget !

As such, a 4000bc worldmap start with 21 civs seems thus harder to achieve (well).

If you pursue this, please keep us in the loop on your progress!

Not at the moment anyway. Dedicated to the TES v2 to finish then for the ww2upgraded to do, I may take a deeper look into it for the Sengoku one later on. :)

so that's pretty cool that it's even remotely possible for you guys to do it in the original engine!

I can't wait to see a scenario providing such a concept ! I'm afraid excitment may arouse too much hope and such a system limits may arouse deception thought.
We'll see !
 
Last edited:

Pablostuka

King
Joined
Mar 27, 2002
Messages
803
Location
Galway, IRL
You sillies @JPetroski , @tootall_2012 , @Knighttime , @CurtSibling , @Blake00 , @Pablostuka , @Fairline , @Tanelorn , @Patine , what are you thoughts about that please ?

(Let's imagine per exemple a Sengoku scenario with 43 playable and playing clans, or a colonisation one depicting seven colonies civs, their seven european rulers, and up to fourteen or twenty one amerindian tribes ?)
For some reason I missed this mention!

It's a very interesting concept indeed, we could do some tests and see what happens...
 

Dadais

King
Joined
Oct 20, 2010
Messages
722
Location
France
Hello @Prof. Garfield , just a little question there, counting on your knowledge of documented and hidden options given by lua and ToTpp,

do you know if there's a way to check with lua if sounds effects are checked on or not at the game level svp ?
 
Last edited:

Prof. Garfield

Deity
Supporter
Joined
Mar 6, 2004
Messages
3,936
Location
Ontario
Hello @Prof. Garfield , just a little question there, counting on your knowledge of documented and hidden options given by lua and ToTpp,

do you know if there's a way to check with lua if sounds effects are checked on or not at the game level svp ?
I fairly confident there is no way to check that.

You can use totpp.patches to make sure that directShow Sound or Music is enabled, but I don't know of a way to check if the player has enabled or disabled sound or music in game.
 
Top Bottom