Google_Frog wrote:If implementing a blacklist in _posts is a hack then what is _posts for? I think that this is exactly the sort of thing that _posts is meant to do. It seems like a pointless request for the engine.
I agree, because behaviour-wise nothing in the engine changes. It is all about how some unit-properties get feed into the unit-reader-thing. Perfect example for _post imo.
---
Such thing does not even have to be in _post, that is just one way.
One should remember what a unitDef file actually is:
It is a .lua script that creats a table with the properties of the units and returns it.
*How* that table is created is up to modder and what the script does is up to the modder.
Common is something like:
Code: Select all
unitDef = {
unitname = "tank",
name = "Tiger Tonk",
maxDamage = 1000,
...
...
weapons = {
def = "Cannon",
onlyTargetCategory = "TANK TRUCK INFANTRY",
badTargetCategory = "BUILDING",
},
}
return lowerkeys({ tank = unitDef })
That is not just a dumb list of "key=value" : It just looks like one because it mimics the .fbi files from Total Anthillnation. Often that is okay. Yet even in that simplest example the use of lowerkeys() is a hint that .lua files can do more.
(compare to .fbi files which were limited to "key=value" listings.)
So going with that idea it could also look like:
Code: Select all
unitDef = {
unitname = "tank",
name = "Tiger Tonk",
maxDamage = 1000,
...
...
weapons = {
def = "Cannon",
targeting = {
prefered = "TANK TRUCK INFANTRY",
lessPrefered = "BUILDING",
neverTarget = "AIRCRAFT",
}
},
return makeMyDef (lowerkeys({ tank = unitDef }))
In above example the function
makeMyDef () would take the targeting-preference table in a format the modder likes and turn it into a format that the engine likes.
Another possiblity:
Code: Select all
weapons = {
makeMyWeapon (
{weaponName="Cannon",
prefered = "TANK TRUCK INFANTRY",
lessPrefered = "BUILDING",
neverTarget = "AIRCRAFT",})
},
The possibilities are endless, the main problem is to decide on a way that fits personal preferences.