CurtSibling
ENEMY ACE™
- Joined
- Aug 31, 2001
- Messages
- 29,455
Is there anywhere to DL the new Lua template as a single zip?
Got it.
Cheers, dude.
BTW - I have been doing the classic rome tutorial, and it has opened up a lot of excellent features and potentials.
Just wondering though, the "events" file that packs with the Lua template is quite full compared to the tutorial version.
What is the more stripped down version of the events file you would recommend?
I prefer to start with an almost clean events sheet and add in what I need.
Refs like munitions are never going to be a concern for the scenario, so can I remove these
from the trigger events, and wipe the events file of the extra refs too?
I like the fact that most of the events are in their own file areas...I like the organisation.
But, which folder - ContextTriggerEvents, and the MainScenario folder within? (or the context folders?)
Or do I use UniversalTriggerEvents? Can you outline which to one I should use?
function unitKilledEvents.unitKilledInCombat(loser,winner,aggressor,victim,loserLocation,winnerVetStatus,loserVetSatus)
for __,unit in pairs({loser,winner}) do
if unit.type == uMilitia then
unit.owner.money = math.max(unit.owner.money-militiaCampaignCost,0)
elseif unit.type == uMarines then
unit.owner.money = math.max(unit.owner.money-marinesCampaignCost,0)
end
end
if loser.type == uLabourers then
local newLabourers = civ.createUnit(uLabourers, winner.owner, winner.location)
end
end
civ.scen.onUnitKilled(doWhenUnitKilled)
local object = require("object")
if unit.type == uMilitia then
if unit.type == object.uMilitia then
if loser.type == object.uLabourers then
local newLabourers = civ.createUnit(object.uLabourers,winner.owner,winner.location)
end
-- near top of file
local object = require("object")
local defaultCost = 5
local campaignCost = {}
campaignCost[object.uMyFirstUnit.id] = 7
campaignCost[object.uMySecondUnit.id] = 4
-- inside the unit killed code
for __,unit in pairs({winner,loser}) do
fightingCost = campaignCost[unit.type.id] or defaultCost
unit.owner.money = math.max(0,unit.owner.money-fightingCost)
end
I'd have to look at your current code to get an idea why it isn't working, but you'll want something like this
What this does is specify a campaign cost for each unit type, indexed by id number. If a unit type is left out, the defaultCost is used. In lua A or B returns B if A is false or nil, so the fightingCost line returns the default if there is no value in the table.Code:-- near top of file local object = require("object") local defaultCost = 5 local campaignCost = {} campaignCost[object.uMyFirstUnit.id] = 7 campaignCost[object.uMySecondUnit.id] = 4 -- inside the unit killed code for __,unit in pairs({winner,loser}) do fightingCost = campaignCost[unit.type.id] or defaultCost unit.owner.money = math.max(0,unit.owner.money-fightingCost) end
If you want different values for attack and defence, get rid of the loop, and use winner and loser in place of unit. You'll also need another table of values.
With barbs, just reserve the classical style for them, and make it graphically what you wish. Unless you mean making them use a different model mid-game.
I'm sure @Prof. Garfield can offer something better, but I am sure Lua allows different models of civ-relations, using humanonly and computeronly talkers.
Meaning you can openly speak as the player to the Ottoman AI (for instance) and the computer player is restricted...As I said, he no doubt can offer a better explanation.