[TOT] The Test Of Time Patch Project

While thinking about extending the event language, and how much work that would be, I decided to embed Lua instead. I'm already very happy with the decision:
Code:
for i = 0, 8 do
    unit = civ.CreateUnit(i, civ.GetCurrentTribe(), civ.GetCurrentLocation())
    if i % 2 == 0 then
       civ.SetVeteran(unit)
    end
end
The result:
Spoiler :

This is currently limited to one-off scripts such as those in the Debug scripts patch (they will be replaced with their Lua equivalents). The 'civ' library contains the C bindings, which I have to write, but other than that, anyone will be able to write their own scripts and have them available in the game!
 

Attachments

  • lua_units.png
    lua_units.png
    211.8 KB · Views: 1,177
For me it seems that some of the WotR video files do work (e.g. T1), while others do not (e.g. B1)... It appears that a framerate of 0.001 fps still allows playback, while 0.0005 fps does not.
Yes, that's it. Thanks for investigating. :goodjob: I'd run across about four of my videos since the release of the DirectShow video patch. All had the problem. I assumed the videos were all the same, so I concluded they all had it. I don't know why there are 3 different frame rates (0.001, 0.0005 and 0.0001); they're clustered by timestamp, so maybe they were made with different versions of VirtualDub. I've converted all of the videos to 0.001 FPS. That's ample viewing time. They're encoded in Indeo. That allows back-compatibility, plus it seems that very low frame rates aren't supported by the selection of newer codecs I have installed. I've uploaded the new files as WotR v1.11.

That's strange, other than adding content I haven't changed the launcher since February (before v0.11). So why it would start complaining about the new release and not about previous releases is not clear to me. For now it would be best to add the exception as Catfish suggested.
As Thorvald said, it's the launcher. The change occurs from v0.12.1 to v0.13.

There's nothing to go on? Could be any number of things to be honest. But since the launcher has been giving more problems recently, I've built a new one in which I also added error reporting. Could you give it a try, see if it does at least something this time?

Could either Thorvald of Lym or Catfish give it a try as well, see if it doesn't trip Avira anymore? Thanks!
Sorry for the late reply. The new file is good for me.

Still trips Avira, but this time it says 'HEUR/APC (Cloud)'. :undecide:
I'm using Avira engine version 15.00.12.420. Under Configuration, what are your heuristic detection levels for Scan and Real-Time Protection? Low, Medium or High? Mine are set to Medium.

And as stated, I double click it and nothing happens. Seems like windows won't let me open it.
Check your security software and UAC. Disable one at a time, if you've got more than one.

While thinking about extending the event language, and how much work that would be, I decided to embed Lua instead.
Sounds great, but I think your attached image has been spoiled.
 
I'm using Avira engine version 15.00.12.420. Under Configuration, what are your heuristic detection levels for Scan and Real-Time Protection? Low, Medium or High? Mine are set to Medium.
Same.
 
Got a Civilopedia bug with the 'Extra unit types' patch enabled. When the @@UNIT_INDEX value in describe.txt does not match the line number (either -1 or a reference to a different position), the unit will be displayed in the Civilopedia even if its tech prerequisite is 'no'. This produces a lot of unwanted units turning up in various Civilopedia lists, including the one for the Original game.

Odd.
 
Not a big issue, but maybe it would be great to have access to the powergraph everytime you like and not only at the end of the game.

Sure, I could bind that to a key.

Got a Civilopedia bug with the 'Extra unit types' patch enabled. When the @@UNIT_INDEX value in describe.txt does not match the line number (either -1 or a reference to a different position), the unit will be displayed in the Civilopedia even if its tech prerequisite is 'no'. This produces a lot of unwanted units turning up in various Civilopedia lists, including the one for the Original game.

Indeed. I inadvertently used that value to index the unit definitions array instead of the ordinal value corresponding to the unit type. This has been fixed in the next release.

I spend some time adding a Lua console to the game to facilitate development of scripts and experimentation. Here's a session with the interpreter:
Spoiler :

By adding hooks in certain places I can probably create a substitute for event triggers fairly quickly. Then it's just a matter of creating more bindings to do useful things in the game. There would also be a need to sandbox certain Lua functions so there's no way to do harmful things in scenarios.
 

Attachments

  • lua_console.png
    lua_console.png
    47.6 KB · Views: 1,115
If this works and Lua can replace the built-in scripting, you will have officially crossed the modding threshold into "WHAT HAS SCIENCE DONE?!". :cool:
 
This thread been going on for a while, so I can't even remember if this has been suggested: The pikeman unit is doubled against cavalry, by virtue of the #10 flag in the last @UNITS field. This is a potentially very useful feature, but limited because it only works against units with a MF of 2, and by some accounts, an attack factor of 5 or less.

This feature would become much more valuable if it could double the defense of a unit with the pikeman flag against units with higher values as well. It could then be used defensively as an anti-tank weapon for example, or provide extra protection for an apc unit against small-arms fire.

If ToTPP allowed you to designate any specific unit types as attacking at half strength against another unit with the pikeman flag, it would be very useful for a variety of scenarios.
 
First one that occurred, the last two civs, Orange and Purple (6 & 7), at some point became completely unable to research anything. I keep separate saves for every major change in my scenario, so in one save, they research fine, but in the next, they lost their ability to perform research.
[...]
The final one, technology restrictions seemed to reset themselves at one point. I can't remember if I mucked up one of my events or not, so I painstakingly reset permissions for all advances ( :ack: ).

Well, looks like tech restrictions are indeed the problem. Tribe 6 & 7 have a @LEADER2 value of 1 (Can't research, can own) for group 0 (indeed most of the techs in rules.txt) in those saves, preventing them from doing any research. EnableTechnology events gone wrong?

If this works and Lua can replace the built-in scripting, you will have officially crossed the modding threshold into "WHAT HAS SCIENCE DONE?!". :cool:

It'll be Test of Time, but not as we know it. ;)

The pikeman unit is doubled against cavalry, by virtue of the #10 flag in the last @UNITS field. This is a potentially very useful feature, but limited because it only works against units with a MF of 2, and by some accounts, an attack factor of 5 or less.

The actual check in the code is for units with MF 2, domain 0 and HP 1. Attack/defense strength and firepower don't play a role.

This feature would become much more valuable if it could double the defense of a unit with the pikeman flag against units with higher values as well. It could then be used defensively as an anti-tank weapon for example, or provide extra protection for an apc unit against small-arms fire.

If ToTPP allowed you to designate any specific unit types as attacking at half strength against another unit with the pikeman flag, it would be very useful for a variety of scenarios.

Yes, this could be implemented through another unit flag.

Another marginal issue. When you give s.o. one of your more advanced units as a present (e.g. you want to help an ally), you automatically give away the tech, too. Can't that be prevented?

Looks like breakthroughs happen 50% of the time, but yes, that can be changed. I'll put that on the list.
 
It might be tech events gone wrong, yeah. Alternatively, a typo on my end. In the 7z file I uploaded, I included three separate events files, the big 117 kb one contains the tech tree resets I mentioned. :)

Edit: I went through my sets events, but almost all normal techs were given a value of 0 for column 0 techs, but it is rather strange tribes 6 and 7 lost most of them somehow to a value of 1 for column 0. I did find that tech 94 was set to 1 for only tribes 6 & 7 in my events file. Everyone else has either 2 or 0 as intended.
 
I don't know whether you saw them or not, TNO (I know you had a lot of posts to sort through upon returning), but I had also made a few more suggestions in two posts lately. For convenience, I've quoted them below:

@TNO

I don't know whether or not you're still taking suggestions for improvements for future patches, but if so, I have one, however late it may be. I was thinking it could be useful in certain scenarios if specific player units, not just barbarian ones, had an expiry period after first appearing, after which time they would despawn. This could be useful, for example, for general and other leader units in a long-term Roman or Chinese epic scenario, where generals and emperors, while influential in their lifetimes, would still, even if they didn't die in battle, retire or die of old age eventually. It would also be beneficial in such a case if 'expired' and 'killed' for such units could be used as separate 'if's' for events. Regardless of whether you take this up or not (or it's even possible without rewriting the game) I still the good work and look forward to seeing the result of what you're currently up to (assuming it's even Civ-related and not just RL stuff).

Two more things that would be very helpful to scenario making (they may have already been brought up): allowing events to change a civ or leader name (or gender of a leader, even) mid-game, and forcing an AI to make a cease-fire, peace treaty, or alliance with either a player or other AI-controlled civ; currently, only forcing them to declare war is possible.
 
Okay, I set tech 94 to value 0 for tribes 6 and 7. It was already 0 for the other tribes. It seemed to fix the problem. Considering tech 94 was a low priority tech and the main tree doesn't seem to depend on it, I am rather baffled why that tech caused the entire tree to be value 1 for column 0 in advance2 & leaders2 for the last two tribes.

Late Edit: Ive noticed a peculiarity. For some new units that use some of the extra slots (80 - 127), they seem to default to a specific sound. Units in slot 105 defaults to the submarine sounds, overriding the custom sound specified for it in rules.txt. There are other affected slots, I think, since I heard an out of place Warriors sound on Mars in my scenario. I my 7z file that I gave to TNO earlier in this thread, slot 105 is taken by "Cloaking Bomber"

I originally thought I had specified too many or too few new units in @COSMIC2, but the sound overrides happen even with the correct numbers.
 
First time using the patch, and the AI doesn't try to build wonders (possibly other things as well, but I haven't noticed) since I've started using it. Could you let me know what I could do to mitigate this? Thanks!
 
I don't know whether you saw them or not, TNO (I know you had a lot of posts to sort through upon returning), but I had also made a few more suggestions in two posts lately. For convenience, I've quoted them below:
[...]

These will eventually be possible when Lua has fully replaced the macro language (see below for update). For the first suggestion, simply decrement a counter every turn (civ.scen.onTurn), and when it reaches 0, do a civ.killUnit. For the second, set tribe.name and/or tribe.leader.name when I finish the bindings.

Okay, I set tech 94 to value 0 for tribes 6 and 7. It was already 0 for the other tribes. It seemed to fix the problem. Considering tech 94 was a low priority tech and the main tree doesn't seem to depend on it, I am rather baffled why that tech caused the entire tree to be value 1 for column 0 in advance2 & leaders2 for the last two tribes.

This is how EnableTechnology works, it changes group permissions, not single tech permissions.

Late Edit: Ive noticed a peculiarity. For some new units that use some of the extra slots (80 - 127), they seem to default to a specific sound. Units in slot 105 defaults to the submarine sounds, overriding the custom sound specified for it in rules.txt. There are other affected slots, I think, since I heard an out of place Warriors sound on Mars in my scenario. I my 7z file that I gave to TNO earlier in this thread, slot 105 is taken by "Cloaking Bomber"

I originally thought I had specified too many or too few new units in @COSMIC2, but the sound overrides happen even with the correct numbers.

Will have to look into that.

First time using the patch, and the AI doesn't try to build wonders (possibly other things as well, but I haven't noticed) since I've started using it. Could you let me know what I could do to mitigate this? Thanks!

Just ran a game without a human player for about a hundred turns and the Indians built the Pyramids. So there shouldn't be a problem. :)

Update on the project/lua integration:
I've implemented most of the existing event triggers, saving/loading of state to/from the saved game is fully implemented and the "civ" library is steadily expanding. I've begun rewriting the Sci-fi scenario in lua, both as a test-case and as an example of lua scenario writing. A little example:
Code:
local state = {shuttleBuilt = false,
    [...]
}

local shuttleText = "The newly built Shuttle unit is capable [...]"

local shuttleDiscoveryText = "On a test flight of the new Shuttle, [...]"

civ.scen.onCityProduction(function (city, prod)
  if civ.isUnitType(prod) and prod.name == "Shuttle" then
    civlua.justOnce(civlua.property(state, "shuttleBuilt"), function ()
      civ.ui.text(shuttleText)
      civ.giveTech(city.owner, civ.getTech(95), 0)
      civ.ui.text(shuttleDiscoveryText)
    end)
  end
end)

This example registers a callback to the onCityProduction trigger. When anything is built anywhere, this callback is run, with appropriate values for "city" and "prod". Skipping the justOnce wrapper for a sec, we test if "prod" is a unit type, and its name is "Shuttle", if so, we first show a pop-up with text, give technology 95 (Plasma Chamber (X3)) to the city owner, and then show another pop-up.

The justOnce wrapper ensures the callback only runs when "shuttleBuilt" in the state table (at the top) is false, and it ensures it is set to true when finished. The "civlua" library just contains (lua) functions that do not need to be written in C per se, and therefore are not in the "civ" library.

New are the onSave and onLoad triggers, responsible for storing/restoring state to/from the saved game. onSave has to return a string which is written to the saved game, onLoad receives this string and is responsible for restoring the scenario's state:

Code:
civ.scen.onLoad(function (buffer) state = civlua.unserialize(buffer) end)
civ.scen.onSave(function () return civlua.serialize(state) end)

I find that putting all scenario state in a single table (called "state" in my case) allows for very easy serialization using the provided civlua serialize/unserialize functions. The above 2 lines should be fine for use in most scenarios, at least as a default.

Other than that, the "civ" library already contains lots of functions to work with units, cities, tribes, techs, improvements, terrains etc. Too much for me to discuss all of them in this update.

I'll release it in a little while, probably after I've rewritten the Sci-fi scenario and those events are all working as they should. :)
 
Just thought I'd check in, as things have been pretty quiet recently.

How are things coming along with the latest patch, TNO? I know you talked about expanding the pikemen flag and allowing non-settler units to eat food. I think you mentioned that it would be possible to grant the 50% defense bonus to "pikemen" defending against units with HP > 1 and movement > 2. Can non-settler units be specified to eat food or cause cities to lose population when building them?

Finally, I know this was mentioned a while ago, but the developers of Civ2 created a loophole in regards to exchanging techs with other tribes. The human player is able to steal any tech advance from the other tribe's list, rather than just obtaining the tech that is on offer. This seems like an unintended bug. Is there any way to fix this?
 
How are things coming along with the latest patch, TNO?

Quite well, thank you! I hope to release it somewhere by the end of the week.

I think you mentioned that it would be possible to grant the 50% defense bonus to "pikemen" defending against units with HP > 1 and movement > 2.

Yes, but this won't be in the next release just yet, unfortunately.

Can non-settler units be specified to eat food or cause cities to lose population when building them?

The first point, no, not yet, but you'll be able to script the second point. This works:

Code:
civ.scen.onCityProduction(function (city, prod)
  if civ.isUnit(prod) and prod.type.name == "Warriors" then
    city.size = city.size - 1
  end
end)

(Which causes a city to lose 1 pop when building Warriors.)

Finally, I know this was mentioned a while ago, but the developers of Civ2 created a loophole in regards to exchanging techs with other tribes. The human player is able to steal any tech advance from the other tribe's list, rather than just obtaining the tech that is on offer. This seems like an unintended bug. Is there any way to fix this?

I see, should be easy enough to make that configurable. Though that'll be for a later release. ;)
 
Here it is, release 0.14:

The major feature of this release is that the game can now be scripted in Lua. Unfortunately, documentation on all of the available functions is a bit lacking at the moment, but I wanted to release now in case any bugs pop up in the next few days. I'll put up a new thread in a couple of days with more documentation. For the moment, there's a document describing how to migrate from old to new events, and the events for the Scifi game are available as an annotated example. Between them, they probably document about half of the available functions. For Lua documentation in general, visit http://www.lua.org

Here's a list of all the changes:

  • Lua scripting: Registers the `civ` library to interact with the game and provides the Lua console (Ctrl-Shift-F3).
  • Lua scenario events: Lua replacement for scenario events, it registers the `civ.scen` library.
  • Reporting options: Allows the player to configure various aspects of UI dialogs and delays.
  • Build transporter: Fixes two bugs associated with building transporters.
  • Map layout: Fixes a bug with rendering the status window when loading a game when the map layout is in classic mode.
  • Added the @COSMIC2 keys "BarbOffensiveUnitLimit" and "BarbUnitSupport" to the AI tweaks patch.
  • Fixed a bug in the Extra unit types patch where unused units would show up in the Civilopedia.

As always, detailed information about the patches is available in the launcher. For an overview of all patches, as well as installation instructions & requirements, see the included README.txt. Happy gaming! :)
 

Attachments

  • TOTPPv014.zip
    274.5 KB · Views: 319
And just the other day I was thinking how much easier a pet project of mine would be substituting LUA variables for flags..! :goodjob:

(EXE is back to tripping 'TR/Crypt.ZPACK.Gen4'. :dunno:)
 
Here it is, release 0.14:

The major feature of this release is that the game can now be scripted in Lua.

Let me just say one thing:

Wow.

What kind of game is that - looks simple and usable like Civ2, but the event possibilities ... :D


Documentation would of course be very nice (know what a pain that can be ...) - as long as that is still in the works, is there some way to take a look at source codes or something similar? (I looked a bit but did not find the class definitions or the like)
As long as I have some info on the methods I'd be willing to try and play around, without that trial and error gets tedious. :)

And a general question right away: Is it possible to have lua hook events into the diplomacy screen? Like, triggered by start or by offering peace etc?
From the way the negotiator events are set up I have the feeling that might actually be possible ...

Anyway, have to get back to playing around a bit. :D
 
Top Bottom