Attack bonus for Terrain Features?

Kafelek

Chieftain
Joined
Feb 13, 2012
Messages
11
As in the thread title, is this possible? I'm guessing, as I'm not that experienced with modding not to mention coding, that this would require some lua coding. I can change the existing defense value for the features, eg. forest, but that's not what I had in mind.

Initially I've created a new SQL following Afforess' simple yet elegant tutorial. If I only want to replace some values I go for this, eg.:

UPDATE Features SET 'Defense' = 33 WHERE Type = 'FEATURE_FOREST';
and it works.

But to add something like attack bonus to forest I would need:

ALTER TABLE Features
ADD AttackMod integer;
UPDATE Features SET 'AttackMod' = 33 WHERE Type = 'FEATURE_FOREST';
and lua code to get it working.

Am I right on this one so far or is there something wrong with the above?
Where to start with this lua code (or how to start?)? Any examples I can look at?
 
What you've described would only add a new variable to the Features table, but it wouldn't actually do anything in-game because the game's engine simply won't be looking for it. I could add a field titled "SpatzIsNotAwesome" to a table, but it wouldn't remove my awesomeness. It doesn't matter if one table has an <AttackMod> entry, there's nothing special about that name that would allow you to add something similar to a different table.

So the only way adding something like that in XML or SQL would help would be if you already had Lua code ready to take advantage of it, and there's no Lua functions that can do what you're asking. The only Lua function that allows any sort of combat change is the SetCombatStrength function, and that's got a LOT of limitations (doesn't affect ranged attacks, is multiplicative with promotions instead of additive, screws up the UI, the AI wouldn't understand it, etc.)

But the game already allows you to make promotions that add to a unit's attack in forests. That's what the UnitPromotions_Features table is for, and it already has an <Attack> value, which the Mohawk and Jaguar promotions already use. (Those promotions also boost defense, though, so if you only want the attack boost you need to make a new promotion.) If you want this to apply to everyone equally, simply give it to each unit by adding the <FreePromotion> tag to your Palace to give the promotion to all unit; this'd cover everyone but Barbarians. If you really wanted it to apply to them as well, you could tie it into a SerialEventUnitCreated function.
 
Thank you for the explenation, Spatzimaus.
Your solution is in deed better and less complicated:) I'll take your advice and just add relevant promotions instead.
I'm new to coding stuff, so I might come up with some more silly ideas while I'm learning the ropes:D There is a long road ahead of me, a long confusing road;)
 
I'll take your advice and just add relevant promotions instead.

Be careful doing this, though. The game has a soft cap of 200 promotions, and the core game uses about 160 of these slots. (DLCs, if you have them, add another 5 or so.) This doesn't leave a lot of room for mods to add a bunch of custom abilities; it's unfortunate, because the Promotions table is one of the most feature-heavy in the game and is remarkably easy to check in Lua (compared to, say, the Technologies table that requires you to go through the Teams interface for everything). So don't get into the habit of using custom promotions for everything, especially if you're intending to use your balance mod alongside any of the other large mods.

It's fine to add a single promotion to make the sorts of general balance changes you've described, of course. For instance, in my own mods I give every unit a custom Home Field Advantage promotion (+10% when fighting in friendly territory, doubled to +20% if ATTACKING within friendly territory) to enact a change in the basic combat balance of the game, sort of like your Forest change. But it means that if I wanted to add some other global change as well, it'd be better to add the new effect to that HFA promotion and not try to create a second free promotion.

(Also, since the Palace can only give a single free promotion, your mod would conflict with any other mod trying to add a universal promotion, like my own.)

I'm new to coding stuff, so I might come up with some more silly ideas while I'm learning the ropes:D There is a long road ahead of me, a long confusing road;)

Try out whatever silly ideas you want; some of them might work, and it's a good way to learn the ins and outs of the existing system. Once you have a good understanding of what is and isn't possible in XML, then you move on to trying the same sort of thing with Lua, and once you've got the hang of that, you'll be in a good position to learn the DLL once it's released. In the meantime, you can get a lot done as you learn; for my own mods, my Alpha Centauri-themed "Ascension" mod was what I used to learn XML, my Mythology mod is very Lua-heavy, and my Empires mod is going to be almost entirely DLL-based. Learning as you go is a great way to do this, but you have to be willing to compromise on your designs as you learn what is and isn't possible with the tools we've been given.
 
Thanks again, I did not know there was a limit to the number of promotions. That's good to know, it will help me in designing the promotion system better.
I was thinking of a more tactical game base experience, similar to Rules of Engagement - Stalingrad mod, but in a WW I setting and with that era feel in mind. This would of course mean changing a lot of the existing promotions and adding new ones:) I'm not that much concerned with buildings giving free promotions to built units as I'm focusing on creating scenarios (battles) when most units would be deployed from the start(with default promotions). Naturally units would still be able to gain new promotions through combat experience, also the mechanics of building units would rather be translated to something like getting reinforcements. I'm still playing with the idea and tweaking it,though.
 
Back
Top Bottom