Overlord Scenario Playtest Thread

Status
Not open for further replies.
Hi, guys - I am just back, been out all day shopping and meeting family. I will look over the files and use the update.
I am pretty sure I can find the rogue co-ords - Anf thanks for the heads up on the map num, I had a feeling it was a ToT multimap thing.
 
@Prof. Garfield - is this entry reading the number of the unit from the rules file instead?

if so, Curt, U.S. Airborne still doesn't have the fix:

unitTypeBuild[object.uUSAirborne.id] = {location=USAHomeCities,allImprovements=object.iArmyBase,object.iAirbase}

Also I'm not sure but I think lua is going to read down the line from top to bottom and U.S. airborne is quite a ways down. This may simply fix when you fix all of these.

This error isn't happening while Lua is 'reading' the table from the file. As far as Lua is concerned, it received perfectly valid code. This error is happening in a program to check to make sure that the table makes sense as a "can build settings table". To check that, I used the 'pairs' function to check all the key-value pairs, and that will happen in whatever order the 'pairs' function finds convenient, which doesn't necessarily have anything to do with the order entries were made in the table.

I was never good at math so I hesitate to try and explain it like it's math, but it's basically math. You need to enclose the different equations. So, you have a "location" equation, and an "allImprovements" equation. The way you've written the above, it's as though it's all one equation (with an extra } thrown in there at the end).

What we're working on here is putting stuff into computer memory. Whenever you see an = sign (but not a ==), you should think that we're storing something in memory. The stuff to the left of the = sign says where it is, and the stuff to the right says what it is. There is a caveat that Lua regards
Code:
{thing1,thing2,thing3}
as short for
Code:
{[1]=thing1,[2]=thing2,[3]=thing3}
so, occasionally we put something in memory without an = sign.

I hope the following analogy will be helpful (it won't work for other programming languages, but should be fine for Lua).

Think of your computer memory as a warehouse with a bunch of shelves that can hold boxes. Each of these boxes can hold exactly one 'thing'. We will call whatever is in the box the "value". That value might be a number, it might be a string (a sequence of characters), or even a function (a series of instructions). Importantly, the value can be the name of a shelf. The Lua term for these 'data shelves' is table (look up hash tables if you're interested why that's the name). When we say that a value is a table, it is best to think of the value being the name of the table instead.

In order for our program to use the data we've stored in these boxes on shelves, these boxes also have names. There is a special shelf that we'll call the "local variable" shelf. It's a bit different from the other shelves and isn't really a table. But it is the default place our program looks when we want to get a value out of a box with a particular name.

If I want to place a new box on the local variable shelf, I write
Code:
local mySix = 6
If I already have a box, but want to get rid of the contents for something else, I omit the local and write
Code:
mySix = "six"

All the other shelves are 'tables'. The names of the boxes on these shelves are called "keys". Unlike the names of local variables, keys for tables can be manipulated by our programs. For our purposes, we'll restrict table keys to numbers and strings, which is plenty powerful enough.

Suppose I want to store both 6 and "six" in the variable mySix. I can't directly, since only one value can be in the box. But what I can do is place 6 and "six" in boxes on a shelf, and place the name of that shelf in mySix instead. In "conventional lua speak", we're putting these 2 values in a table, and storing that table as the value of mySix.

Code:
local mySix = {} -- find an empty table (shelf), and store its name as the value of mySix
mySix["number"] = 6 -- in the table with the name in mySix, place a value of 6 in the box called "number".  If a box with name "number" already exists, discard the existing contents.
mySix["string"] = "six" -- in the table with the name in mySix, place a value of "six" in the box called "string".  If a box with name "string" already exists, discard the existing contents.

Lua provides a couple of different ways of writing code for table actions. If the key is a string that would have a valid name for the variable shelf, you can use a . instead of [] and "".
Code:
mySix.number = 6
You can also put stuff in the the table constructor
Code:
local mySix = {["number"]=6,string="six"}  -- find an empty shelf, place the sixes in appropriate boxes, and store the name of that shelf as the value of mySix
Note that if since we could use mySix.string, we can omit the [""] when constructing the table.

Anf thanks for the heads up on the map num, I had a feeling it was a ToT multimap thing.

You should be able to just use {x,y}, all it does is count for all the maps in the game if you omit the z.
 
Using the ProcessingList feature, I have a feeling it is one of the USSR co-ords...The hunt begins! :)

EDIT: Yep! Two rogue Russian co-ords with non matching (even/odd) values...Found and fixed!
 
Last edited:
Gentlemen - It worked, finally!
A big step forwards for the scenario - :)

Behold the city menu in Copenhagen...Unable to build any heavy weapons until factories and naval yards are built!
LuaScreenie1.png

Looking forwards to extending the Lua features...Thanks for your patience, guys...I am truly a believer now! :D
 
Now that I have the "canbuild" tables up and running in a basic way, it is time for me to start thinking about other features.
I have a sort of Lua shopping list of ideas to implement in the scenario, a loose list of these possible concepts include:
  • A method for human players to order invasions from a menu. I'd like a new method for Barbarrosa and Overlord, etc.
  • Perhaps the ability of buying attack forces that can be deployed in various theatres, maybe with 3 tiers of strength.
  • Make computer-controlled invasions work as intended, starting and launching on the AI's turn.
  • Some method to nerf the Neutral units to a certain degree...Perhaps reducing att/def or something.
  • Change leader names when a capital city capture happens, or when other events happen.
  • Instead of making workers/engineers buildable, making them buyable from a "labour pool" menu.
  • A way to limit the amount (and type) of aircraft on carriers.
There are more...But these are the major ones I am thinking about just now, especially the major invasions for each civ.

@JPetroski @Prof. Garfield
Any advice and pointers would be very welcome...:)
You both are a credit to the forum with such patient/generous help.
 
Thinking about the invasions, I have decided to make them for AI civs only. So the player will be expected to build up and launch his own campaigns.

@JPetroski, I am wondering if I can ask some advice...?

Is there a trigger in Lua that allows each civ to have an invasion event, but will not be present for whatever civ the player chooses?
 
@JPetroski, I am wondering if I can ask some advice...?

Is there a trigger in Lua that allows each civ to have an invasion event, but will not be present for whatever civ the player chooses?

Yes - you can use the .isHuman trigger. Here's the concept illustrated from Cold War (in this case it was an AI response to an invasion but you could use whatever you want). Bear in mind that you wouldn't used "state" since you're using the lua module. You'd use "flag" instead.

In the single player game, when America is NOT a human player, and it is invaded (thus triggering the state.AmericanInvadedSP flag), on each turn there's a 75% chance that they'll get some infantry units (we like our guns after all).

This will not trigger if the US is a human because of the "and not (object.tUSA.isHuman)" near the end of the first line.

Code:
if turn >=1 and turn <=135 and state.AmericaInvadedSP == true and state.AmericaDefeatedSP == false and math.random() < .75 and not (object.tUSA.isHuman) then 
civlua.createUnit(object.uUSInf, object.tUSA, {{230,52,0},{229,55,0},{228,58,0},}, {count=2, randomize=true, veteran=true})
civlua.createUnit(object.uUSInf, object.tUSA, {{226,62,0},{225,67,0},{223,71,0},}, {count=2, randomize=true, veteran=true})
civlua.createUnit(object.uUSInf, object.tUSA, {{223,81,0},{220,70,0},{216,76,0},}, {count=2, randomize=true, veteran=true})
civlua.createUnit(object.uUSInf, object.tUSA, {{216,68,0},{215,61,0},{216,54,0},}, {count=2, randomize=true, veteran=true})
civlua.createUnit(object.uUSInf, object.tUSA, {{222,56,0},{220,52,0},{213,45,0},}, {count=2, randomize=true, veteran=true})
civlua.createUnit(object.uUSInf, object.tUSA, {{211,55,0},{210,68,0},{211,77,0},}, {count=2, randomize=true, veteran=true})
civlua.createUnit(object.uUSInf, object.tUSA, {{209,75,0},{208,78,0},{205,69,0},}, {count=2, randomize=true, veteran=true})
civlua.createUnit(object.uUSInf, object.tUSA, {{205,61,0},{200,58,0},{198,66,0},}, {count=2, randomize=true, veteran=true})
civlua.createUnit(object.uUSInf, object.tUSA, {{200,72,0},{196,74,0},{194,70,0},}, {count=2, randomize=true, veteran=true})
civlua.createUnit(object.uUSInf, object.tUSA, {{190,62,0},{189,47,0},{192,44,0},}, {count=2, randomize=true, veteran=true})
end
 
My thanks, sir!
I assume it would be added to the triggerEvents file?

An now...A big favour! I am wondering, if I could ask your help on making a simple invasion template (in which I will prove co-ords and text) would you be able to help me out with code?
Once we have a prototype, I could use it to create all the other invasion events - I know you are a busy man, but this would more or less help push Overlords to a playable state.

Also, would this Lua event affect the existing macro events?
I'll be removing the invasion events from the legacyevents, but will these triggers happen alongside or instead of the legacyevents?
 
I'm going to send you a PM with something really cool. But if that doesn't help I can write the basics of an event for you.
 
A method for human players to order invasions from a menu. I'd like a new method for Barbarrosa and Overlord, etc.

Perhaps the ability of buying attack forces that can be deployed in various theatres, maybe with 3 tiers of strength.

The keyPressEvents.lua file would let you open a menu from a key press. The text module has the text.menu functionality, which should streamline the process of making menus. I haven't written generic functionality for nested menus, which you would probably want in this case. That's mostly because I haven't thought of a good way for someone to specify the tiers of the menu, as well as the choices.

Make computer-controlled invasions work as intended, starting and launching on the AI's turn.

You will want to trigger the invasion in an afterProduction event (part of the trigger events). If you want to 'trigger' the event with lua, but use legacy events to execute it, I added that functionality a little while ago. A 'lua' trigger works the same way as if a unit was killed, for example, except that the events are checked when legacy.luaTrigger is run.

Code:
Lua Trigger
Allows Lua to trigger events in the Legacy Event Engine directly
usage:
@IF
lua
triggername=myluatrigger
@AND
...

legacy.luaTrigger("myluatrigger","triggerAttackerNameOrNil","triggerDefenderNameOrNil","triggerReceiverNameOrNil")
Some method to nerf the Neutral units to a certain degree...Perhaps reducing att/def or something.

You can use a unit activation trigger to first restore all units to their 'proper' attack, and then second, to reduce the attack power of the active unit's type, if that unit is owned by the neutral player. Can't change defensive stats in this way, since you don't know what unit will be attacked.

You can also use combatResolution event to damage neutral units during the first round of combat. For example, a neutral unit could take 10 points of damage during the first round of combat, as a means of reducing its effectiveness compared to units owned by other tribes.

Change leader names when a capital city capture happens, or when other events happen.

I changed the name of the roman leader as part of my second lua lesson.

https://forums.civfanatics.com/threads/totpp-get-started-with-lua-events.636192/#post-15212108

Instead of making workers/engineers buildable, making them buyable from a "labour pool" menu.

Certainly doable. You will probably want to have counters to keep track of the current state of the labour pool.

A way to limit the amount (and type) of aircraft on carriers.

In OTR, we achieved this with an onActivation event, which disabled the carrier status of carriers for units that can't be carried by them, and enabled carrier status otherwise. In the general library there are now commands to change carrier status for unit types
Code:
--#gen.isCarryAir(unitType)-->boolean
--#gen.giveCarryAir(unitType)-->void
--#gen.removeCarryAir(unitType)-->void
I suppose that you could change the domain of aircraft that can't be carried by carriers, when those carriers are activated, if you wanted to be fancy.

Limiting the number of aircraft that can be carried is trickier. As far as I know, you'd be limited to deleting extra aircraft (or, perhaps, teleporting them back to a city if one is close enough). You may also run into difficulties with bombers trying to attack carriers, since when those carriers don't have the carrier flag, they are part of an air protected stack with the fighters that are supposed to be on deck.

Also, would this Lua event affect the existing macro events?
I'll be removing the invasion events from the legacyevents, but will these triggers happen alongside or instead of the legacyevents?

The legacy events are implemented in Lua, so they work along side the lua events. In the trigger events, there are lines that run through the legacy events, checking if any should fire. For example
Code:
legacy.doUnitKilledEvents(loser,winner)
checks for and executes appropriate unit killed events.
 
Thanks, gentlemen! This is all info I am eagerly taking in. I will digest the codes and get my brain moving.
And while I am still learning the ropes, I hope the progress of converting my scens to Lua shows I am serious. :)
 
I'm going to send you a PM with something really cool. But if that doesn't help I can write the basics of an event for you.
It's mind-blowing!

What I was thinking is this...I could post a simple event from macro, and you could maybe translate it into Lua, and this would enable me to quickly get a clue what to do.
I'm still at the starting point with Lua events, and am sure it will be very apparent once I see it in practice, based on my own macro events...:)
 
Since @Prof. Garfield pointed out the Lua and macro events work co-currently, I will remove certain events from macro and re-implement them in Lua.

I'd like to make most of the events Lua eventually, but for now, in the interests of learning the sysytem, I will stick to small steps.
 
Been doing the tutorials on @Prof. Garfield 's thread, and can see the system is very much the same as macro.
So hopefully I will not have to hassle our resident Lua experts here too much. I'll keep you updated...:)
 
I have the campaign costs, dangerous terrain, and worker/engineer capture Lua events in place.
This is the on top of the regional units, and canbuild city settings. So things are looking good for progress on Overlords.

Now my next goal is to cook up some ideas for major attacks from all the main civs.
The trick is what should the theme be to trigger for each of the attacks.
Having them happen on historical dates is too predictable.

I am weighing up the suggestions from the thread, which have been amazing and useful.

I'd like something the AI and human player can activate, or at least for the human player. Open to suggestions too!
 
I'm gettting ready to move into the next phase with the scenario, as the new update of ToTPP has added some excellent features, one that swept away the GoTo menu bug that was making the game crash.
Also, with ToTPP now able to support scenario-based city UI graphics, it means I can easily package the faction-flavoured menus I made for each empire. I have learned a small amount about Lua during the
development of Imperialism III, and I plan to make use of my knowledge in the new updates of Overlords. I will upload and post the latest version when the time comes soon.

Here is a sceenie that made me happy...My crashy save now works when the "goto" menu is opened...Expanding byte heaps ahoy!
GotoFix1.png
 
Here's the new Menu UI, which I have been working on this morning...
NewMenus1.png
 
@JPetroski
@Prof. Garfield

Once again, I am humbly seeking you good gentlemen for Lua advice and guidance. I have a working idea for the invasion events in the game. I'd like to see if this is doable in Lua.

I wanted to use the user defined techs (U1, U2, U3, etc) and name them as invasion techs from each civ. Examples are below:

Code:
Barbarossa,         8,-2,  War, Las, 0, 4    ; U1  90   [German invasion of Russia. AI gets units. Player gets 10000 gold]
Soviet Attack,      8,-2,  Rob, Cmn, 2, 4    ; U2  91   [Russian surprise attack on Germany. AI gets units. Player gets 10000 gold]
Pacific War,        8,-2,  Mon, Feu, 1, 4    ; U3  92   [Japanese invasion of Asia. AI gets units. Player gets 10000 gold]

So the Barbarossa tech is selected, and begins a research countdown (this would represent campaign preparations), the end result would be war with the target civ, in this case the USSR.
If you are the German civ, you would be at war with your ex-friends the USSR, and you could begin your invasion.

If you are playing as the Russian civ, and the AI German civ gains Barbarossa, he will get a large stack of legacy event-placed units to try and invade you.
Alternatively, he might also defer the Barbarossa research until later. This would be up to the AI, and keeps an element of the unexpected in the scenario...

I'd aim to do the tech triggers in Lua, the unit spawns and text in legacy events.

Here's the aspect I'd like to explore, and maybe Lua can help make things interesting...

When the invasion tech is achieved, I'd like to give the human player something other than free panzer stacks, as being bestowed units out of nowhere seems to OP.

Could the human player be given a gold payment (via Lua) upon the selection of the "invasion tech"? Can Lua events cover tech menu research choices?
If not an option, then a cash payment could just go to the human player upon research completion, to be spent "replacing losses", etc.

I'm sort of seeking guidance on the best way to see this up in Lua, I know a trigger can be linked to the existing legacy events, which are all ready to go.

Any other suggestions on giving something to the player in lieu of units would be welcome too. :)
If the system described seems too unworkable, I am willing to try something else.
 
Hi guys, I am noticing in my Overlords save, when I use Lua events as my choice on loading, the "F3" diplomacy screen no longer works.

Is this because the treaties, etc between civs must be set up again in Lua?

Overlords might have missed an update to the Legacy Event Engine, though the update didn't fix the issue in the (probably obsolete) version of the scenario I have.

With Lua, if tribes can't communicate, they don't appear at all in the diplomacy window (so you can't even check the intelligence report). If a tribe can't communicate with anyone, they'll get the no contact with anyone message. I figure it's best to wait a bit before asking TNO to fix things.

I may have to look again at the Legacy Event Engine, however, because when I commented out forbidden negotiations between USA and Japan, I still wasn't able to get the foreign affairs window. Making negotiationSettings.negotiation (in negotiationSettings.lua) return true for all cases did let foreign affairs window work.
 

Attachments

Could the human player be given a gold payment (via Lua) upon the selection of the "invasion tech"? Can Lua events cover tech menu research choices?
If not an option, then a cash payment could just go to the human player upon research completion, to be spent "replacing losses", etc.

From the function reference

researchCost (get)
tribe.researchCost -> integer

Returns the research cost of the tribe.


researchProgress (get/set)
tribe.researchProgress -> integer

Returns the progress towards the current research (range between 0 and tribe.researchCost).


researching (get/set)
tribe.researching -> tech

You can check what each player is researching, and how close they are to completion. If you want to give cash as soon as research starts, then check every turn (or after production) whether tribe.researching is the appropriate tech, and use gen.justOnce to give the bonus on the first turn that research goal is detected.

Alternatively, you can give a small bonus of a few units each turn that the technology is being researched, so the buildup is a bit more gradual.
 
Status
Not open for further replies.
Back
Top Bottom