Under the Comanche Moon (dev thread)

2. Is there any way to totally prevent pillaging?
This code seems to work, but I've only made a couple small tests, and haven't tried to get the AI to pillage anything.

Code:
---@type unitObject|nil
local possiblePillager = nil
---@type tileObject|nil
local possiblePillagedTile = nil
---@type bitmask|nil
local possiblePillagedTileImprovements = nil
discreteEvents.onActivateUnit(function(unit)
    if gen.isCanImproveTiles(unit.type) then
        possiblePillager = nil
        possiblePillagedTile = nil
        possiblePillagedTileImprovements = nil
    else
        possiblePillager = unit
        possiblePillagedTile = unit.location
        possiblePillagedTileImprovements = unit.location.improvements
    end
end)

discreteEvents.onFinalOrderGiven(function(unit)
    if possiblePillager ~= unit or possiblePillagedTile ~= unit.location then
        possiblePillager = nil
        possiblePillagedTile = nil
        possiblePillagedTileImprovements = nil
        return
    end
    if possiblePillagedTileImprovements == nil then
        possiblePillager = nil
        possiblePillagedTile = nil
        possiblePillagedTileImprovements = nil
        return
    end
    -- can only get here if the possible pillaged tile isn't nil
    ---@cast possiblePillagedTile tileObject
    possiblePillagedTile.improvements = possiblePillagedTileImprovements
    possiblePillager = nil
    possiblePillagedTile = nil
    possiblePillagedTileImprovements = nil
    return
end)
 
This works perfectly! Thank you.

Since it uses up the unit's movement, I wrote in a line of ui text that says, "This unit encountered difficulties in rough terrain. (Note: Base game 'pillaging' orders do not work in this scenario.)"
 
Happy holidays @Prof. Garfield (and any others reading)!
Question: I am using this code in the munitionsSettings.lua. All is working well, except for the gen.removeAirbase. Any idea why?

Code:
local function moveTipi(unit)
    for possibleTipis in unit.location.units do
        if possibleTipis.type == unitAliases.Tipi then
            gen.killUnit(possibleTipis)
            break
        end
    end
    local munitionList = gen.createUnit(unitAliases.Women, unit.owner, unit.location, {homeCity = nil, veteran = nil})
            unit.location.terrainType = 1
            gen.removeAirbase(unit.location)
    return munitionList
end
 
Happy holidays @Prof. Garfield (and any others reading)!
Question: I am using this code in the munitionsSettings.lua. All is working well, except for the gen.removeAirbase. Any idea why?
I can think of two possibilities. First is that the airbase is removed, but tile visibility isn't updated for some reason. Check this cheating to create a unit on an adjacent square (or, just moving a unit). The second possibility is that the "stop pillage" code undoes the removal of the airbase. I'm inclined to this explanation.

(Since you report that the Women are created successfully, it would appear that deleting the Tipi doesn't delete the "unit" unit, otherwise the issue might be unit.location.)

If this is in the same file as the pillage code, you can try adding these lines:
Code:
possiblePillager = nil
possiblePillagedTile = nil
possiblePillagedTileImprovements = nil
gen.removeAirbase(unit.location)

If the code is in different files, the easiest thing to do is use global variables. Change references from
Code:
possiblePillager
possiblePillagedTile
possiblePillagedTileImprovements
to
Code:
_global.possiblePillager
_global.possiblePillagedTile
_global.possiblePillagedTileImprovements
 
Aha! Worked great. That was indeed the issue (the no pillaging code).

OK, another question. I know how to use tables with numbers, but how about using them for coordinates?

If I have something like:
Code:
gen.createUnit(unitAliases.ApacheBraves, civ.getTribe(3), apacheTable[math.random()])

Say I have 50 sets of coordinates: How do I register in a table the series of coordinates to randomly select one?
 
You do something like this, with nested tables:
Code:
apacheTable = {
    [1] = {0,2,0},
    [2] = {10,12,0},
    [3] = {25,41,0},
}
You can also store tileObjects as values in a table:
Code:
apacheTable = {
    [1] = civ.getTile(0,2,0),
    [2] = civ.getTile(10,12,0),
    [3] = civ.getTile(25,41,0),
}
You can use apacheTable[math.random(1,#apacheTable)] to choose a random tile. If you're using gen.createUnit, you can just use the randomize option in the options table and provide the entire apacheTable for the locations.
 
Here are a few screenshots as the world gets fleshed out. Haven't placed 95% of the units yet, but wanted to show some landscapes and features.

comancheria1.png

A small sliver of Nuevo Mexico (that's the Rio Grande you see there). In the game, this is a tribe all on its own, despite being allied w/Mexico -- it can change hands, but more importantly, despite Mexico's rage against the Comanche, NM will be a trading partner.

comancheria2.png

Trading with Comancheros - New Mexico's Indian traders. Notice your options. There are a few places and units you can "trade" with -- Forts, Trading Posts, Comancheros, to name 3. They all have different options.

comancheria3.png

Arkansas~ Forests, temperate climate, small towns. In history, as far as the moon to Comanche braves. In this game? Perhaps a legitimate target if you play your cards right.

comancheria4.png

Bexar (San Antonio) -- where the Alamo is located.

comancheria5.png

A message indicating a new trade wagon on the Santa Fe Trail!

comancheria6.png

Here are a couple trade wagons. Still need to get rid of their HP bar. You can intercept these -- negotiate or raid.

comancheria7.png

A nice panorama of bison and the encampments near the Arkansas River and Bent's Fort.

comancheria8.png

The Apache are a deadly foe. They can't really threaten the Comanche on their own, but can be quite a nuisance to traveling units, especially those seeking to raid into Mexico.

comancheria9.png

Speak of the devil. There is an Apache Braves unit near one of the only crossing points of the Rio Grande.

comancheria10.png

Display showing two things: Reputation and Current Mood. In a nutshell, at its most basic, you want to be "Trusted" and you want the mood to be "Terrified." Trust + Terror is a great combination for negotiating and getting the boundary the Comanche deserve. To become more trusted, you must relinquish some captives every now and then, deliver cattle, other kinds of "deeds." To be feared, you must loot, pillage, kidnap -- but beware! Too much of that, and the military will become incensed. More fear means better deals, but also more troops.
 
comancheria11.png

Texan homesteaders.

comancheria12.png

The Comanche are confronted!

comancheria13.png

Arrows locked~

comancheria14.png

Braves with guns approach some women/children in Texas.

comancheria15.png

Captives for the Comanche.

comancheria16.png

But you've kidnapped so many, that a mob is on the move!

comancheria18.png

Yikes!

comancheria17.png

But some other braves were using it as a distraction. Bevil raided! Many horses found and taken.

comancheria20.png

And as you can see, Texas has now become Nervous.

 

Attachments

  • comancheria17.png
    comancheria17.png
    242.6 KB · Views: 20
Quick question:
When using the civ.createCity function, how do I create a name for the city?
After creating the city, use the city.name field to change the name.
 
From someone who has only ever played original CivII, all the features you can add with LUA make this look incredibly new and exciting.
 
Hi @techumseh and @Dupuire Unaru thank you for the words of encouragement. I am still chiseling away at this, but I will admit that the lack of players for our projects can be a little bit discouraging. I still want to see this subject brought to life with the tools available, though. One obstacle was losing my notes. Funny, I did not lose any data for my project, but only my notes. But those notes had all of my research, including important dates and other features I want to include, so I've been combing through my progress and trying to remember / re-research. I know it does not need to be perfect!

Thanks again for the nudge.
 
The map is huge. Do units move way faster than in original civ?
Yes, exactly - well, Comanche units move at exceptional speeds, while conventional military units from other civs do not. It is meant to simulate the Comanche raids and covering large distances in short periods of time. The huge map also creates moments of great wilderness vs settlement-rich areas, creates dynamic river zones, and ensures a more interesting bison hunt and raids on caravans/settlers as they move through the landscape. :)
 
Top Bottom