Flintlock
Emperor
- Joined
- Sep 25, 2004
- Messages
- 1,215
Lua was originally designed as an extension language and that's mostly what it's used for, for example Civ 5 used it for its interface. It's supposed to be very easy to call C/C++ to/from Lua. I don't know how it compares to Python, though, as I've never tried to use Python in that manner. I have already done a little proof of concept with Lua, calling Lua functions from the mod's inserted C code, and that all works nicely. It's pretty easy with LuaJIT's cffi module to interface with the C side of things from Lua.Hehe, all haillordlady Lua!Btw, what is it that makes this language so suitable for these applications compared to say python?
What I like the most about Lua is that it's small and fast. Last I checked a full Python system requires about 20 MB, and I checked years ago so it's probably larger now. The rest of C3X is only about 3.5 MB uncompressed so adding Python would bloat it a lot. For comparison, LuaJIT is only a few hundred kB. LuaJIT is also among the fastest implementations of any dynamic language, partly because Lua is such a small language so it's easier to optimize while compiling without breaking things.
This is easy to change. The game calls a function to check if a player has the tech allowing sacrifices, and I can intercept its calls and modify them to return whether the player has the allowing tech but not a disallowing one.1) It is impossible to disable it later. It just need to uncheck this box when researching a technology (like a monotheism for example), but the editor lets only to turn it on.
I'll look into this. I can see in the AI's logic that there's a function gating sacrifices that doesn't check whether the unit type has the sacrifice ability. However, in the equivalent logic for the human player, I don't see that check either. Maybe I'm missing something.2) For some reason, if a unit (for example, a worker) does not have the sacrifice option enabled, the AI can still sacrifice it when researching the necessary technology, but you cannot.
Looking at the code for this, the formula is very simple. The value of a sacrifice is twice the unit's shield cost, times two for each doubling improvement in the city. Also, the value for xenophobic governments is zero unless the city has at least 51% native population.3) I still do not understand the principle of culture points adding after the sacrifice. It would be logical if it depended on the religious type of civilization, but tests showed that there is no such connection.