The code you're looking for is a case statement within a switch within a function (or procedure i forgot). It is called for all units and then say something like if unit is named pikeman then ... else if musketeer then ... etc
Thank you very much. If I said that the unit.script file was spaghetti code (and I did) I now eat my words unreservedly. Now, I have had a better look and start understanding it (slowly), I think it is pretty good. So my bad mistake for calling it "spaghetti code". My only excuse is that I only learned Borland Turbo Pascal many years ago, I am rusty, and I have never learned script languages or object languages. Looks like it is time to start learning. Now, time for me to start eating my big helping of humble pie. And then to get into the learning.
UPDATE Cavalry build speed decreased (still way slower than vanilla) but cost increased. It is now easier to create Cavalry squadrons but they are much more expensive. Pike armour increased so that pike duals last much longer. Realistic fire rates, accuracy etc as always, but a new damage system based on range soon to be developed! (thanks to General WVPM). This mod will then be combined with his scripting work.
The most important thing: creating mod with replacing whole files could be wrong way, because devs can make update, which will change something in the files (e.g. some parameter or AI behavior) and you cant replace them by your old files. There is another way - to replace only section of text in that file. I have look at yours files very quickly and found, that full upgraded reiter will have 1(basic)+18(upgrades)+4(blacksmith, accademy)=23 armor against pikes. Pikeman 17c has 8(basic)+9(upgrades)=17 pike dmg. So pikemans have no chance against reiters. Reiter has creation time set to 1200 (after blacksmith upgrade it will be 600). Pikeman creates in 150. So 4 pikemans vs 1 reiter. You can try it in editor, who vins when fully upgraded . Also musketeers attack set to 40 (+11 upgrades)+49(+10,15,20,30% academy) = about 100 dmg meens, that nobody would make pikemans. Just shooters and cavalry. Damage get from bullet from 10m and from 100m would be cca the same. In this case I would rather think about accuracy model, that decreases it with increasing range, instead of damege model. But keep working bro. There is tons of work . Good luck.
HEY BROTHER FRANCESCO THANK YOU FOR YOUR HARD WORK BTW HOW DO I INSTALL YOUR MODS IN COSSACKS 3 OFFICIAL MOD MANAGER AM NEW TO THESE WILL GREATLY APPRECIATE IF YOU REPLY IN DETAIL
I've not looked at upgrades yet, just physics. I need to especially now highlanders have a bayonet attack! I'm afraid I don't know how to use mod manager, this is just a simple copy-paste job into the scripts/lib folder
I highly recomend to you to study how to use it. Its better in the begining, when your changes arent so big as in the future. Because when they change something in e.g. unit.script file, you have to make your highlader bayonet attack again in that file. Hope you understand me. Look at this thread: https://www.cossacks3.com/forum/index.php?threads/unofficial-cossacks-3-mod-manager.17753/ Its not too complicated and for now Lieutenant-Général has made a huge amount of work at MM, which spares me a tons of hours of time in modding.
About the damage model, I made it to model accuracy into damage, in order to remove the randomness. Imagine you would fire 10 rounds that each would do 100 damage, but only 20% hit the target. This could be modeled as 10 rounds that each do 20 damage and always hit. I think this system is closer to the vanilla Cossacks system, which is why I went with it.
UPDATE Works with latest patch - next version will work with mod manager. Some small changes: Towers given much greater line of sight and range (still less than a cannon, more than a howitzer) Cannon cost increased to prevent ai from spamming them early on Next up: Finding a way to keep the American Conquest style musket behavior while removing friendly fire that sometimes happens.
CAN I ASK HOW DO I INSTALL YOUR MODS BECAUSE LAST TIME WHEN I COPY PASTE IN THE SCRIPT FOLDER IT STOPPED WORKING
I won't modify any balance/unit values until GSC have finished their own work, they haven't even scratched the surface yet with their own changes, I'll wait and see what the change with the finished product.
UPDATE 1.Removed friendly fire from muskets that crippled previous versions; units will still cause realistic friendly fire when shooting into masses of troops engaged in melee, but will now refuse to fire if they think a unit in their own regiment is in danger of being hit. 2.Increased headshot chance for bullets from 0.02 to 2% this seems small but makes a huge difference to the potency of firearms. 3.Dramatically increased the bonus from being in column and square. Cavalry now have no hope of breaking them, and pikemen, rather than being individually well-armoured, rely largely on being in formation during big battles. Musketeers and Grenadiers also get a large bonus to bayonet attack when in column to simulate its use to break enemy lines. 4. Highlanders now receive bayonet, rather than firepower upgrades in the barracks, and also benefit from bayonet upgrades in the blacksmith/academy. 5. Increased the range of Pandurs and Chasseurs slightly more to make them more useful as light infantry. Annoyingly, the ai randomly decides each game whether to build musketeers OR pandurs/chasseurs solely at the start of each game, but this will at least give the player some ability to experiment with light infantry tactics. 6. Lowered the amount of cannons and howitzers available per depot from 5 to 2. The ai will still spam them if it gets hold of villagers from other nations and builds more depots cheaply!
I made a small mod where is a 10% chance to reduce the damage to zero. either be a miss, a dodge or a parry. However that has of course a large RNG influence and I try to solve it otherwise. My game also has bonusdmg, and since the dmg is already big enough bonus defense. For example light melee cavalry deals 50% (after shield reduction but before other armour reduction) less damage against melee only pike.