Page 1 of 2

Merging infantry

Posted: Tue Jun 19, 2012 8:15 am
by rf900
Merge mod v1.0

I still need to test it more but looks good.

To use it download the zip and extract, there are three files:

Code: Select all

Merge.BSF new script file that goes into the scripts directory
$DEFAULT.BSF to add the entry for the new script file (just has a new line with [b]include "merge.bsf"[/b])
text1.txt has the new texts used, taken from first campaign, there is a probably a better way to add them

The text file has these two lines:

IDS_UNIT_MERGE,"You will combine your forces.",
IDS_TT_MERGE,"Forces back to full strength!.",
What it does is when having two infantry units of the same type in adjacent squares it will check if the total number of men will be equal or lower than the normal number of that squad type. If yes it will let you perform an action, using the Load icon that merges the two squads. The resulting squad will reduce promotion one level if the other one was lowest and will get the highest morale of both. As the AI will not do it I want to keep it as neutral as possible. The end squad will loose all APs and fire action for that turn.

Let me know your comments or problems with it.

Re: Merging infantry

Posted: Tue Jun 19, 2012 10:22 am
by IainMcNeil
I think that's the right way to ensure the squads are the same - compare the GetUnitStringID.

I don't think you want to load them up. What you want to do is count how many men are left in both and if the total is less than 5, let them merge. Remove one of the units and change the man count on the remaining unit to the total value.

If there are too many men you'd need to give feedback on the ToolTip explaining why and disable the command.

Re: Merging infantry

Posted: Tue Jun 19, 2012 11:36 am
by rf900
Thanks, I have taken the load script because it is a similar interaction between two friendly units. But I think I have removed all the functionality of the loading except for the messages and icon. I am concentrating first on making it work.

Re: Merging infantry

Posted: Tue Jun 19, 2012 1:51 pm
by IainMcNeil
Ok got it - its a good way to start.

Re: Merging infantry

Posted: Tue Jun 19, 2012 5:24 pm
by GottaLove88s
That looks great. Is it possible to bring this into the next Open Beta MP release?

Re: Merging infantry

Posted: Wed Jun 20, 2012 6:28 am
by rf900
Uploaded a first version, you can change the promotions part easily I prepared the code so that by removing and adding comments you can make the squad to have the highest promotion.

Re: Merging infantry

Posted: Wed Jun 20, 2012 5:50 pm
by pipfromslitherine
A Merge command is on my list! I think that adding it and a command to swap units would be good to have in the next update. But hopefully people can try out your version, you can deal with any issues that need fixing, and then I can ride in and claim all the glory! Hurrah! ;)

It definitely sounds very cool - and it's awesome that it keeps the promotions (although, should it? Should using a lower squad 'dilute' the elite squad?).

Nice work!

Cheers

Pip

Re: Merging infantry

Posted: Thu Jun 21, 2012 6:30 am
by rf900
Yes the promotions are tricky, they should probably be more gradual and depending on the number of men of each squad and their level. I have made it this way because the AI cannot merge units, so didn't want to give the player too much of an advantage.

Re: Merging infantry

Posted: Thu Jul 26, 2012 5:03 pm
by rf900
Last version was not working properly in some cases, fixed and updated.
It now wont lower promotions as much, just one level if one of the units is of lower experience. It also takes into account carryover units mechanic, the resulting unit will be in the carryover list (maybe a bit unfair)

Re: Merging infantry

Posted: Thu Jul 26, 2012 5:19 pm
by GottaLove88s
rf900 wrote:It also takes into account carryover units mechanic, the resulting unit will be in the carryover list (maybe a bit unfair)
What's carryover units mechanic?

Re: Merging infantry

Posted: Thu Jul 26, 2012 6:44 pm
by rf900
The carryover is a system that allows units to appear in several scenarios, retaining number of men and experience. I am using it in my campaign to create a sort of storyline, in which you need to take care of some units to have them in the following missions.

Re: Merging infantry

Posted: Thu Jul 26, 2012 7:09 pm
by GottaLove88s
Doh! Thanks, I see what you mean. So, if your merge a "carryover" unit into a non-carryover one, you can recover it, to carry it into the next map of your campaign... good to know...

Re: Merging infantry

Posted: Thu Aug 02, 2012 9:51 am
by rf900
update the icons for merge and swap, if you don't want to use one of the commands comment the line in the $DEFAULT.BSF file.

Re: Merging infantry

Posted: Mon Sep 10, 2012 12:37 pm
by GottaLove88s
RF, Will this code handle special infantry units, where I've modified squads.csv to permit 8-man infantry, 4-man piats, etc?

I see that you perform your permission check using MaxMen = GetUnitMen(me)... Does GetUnitMen simply reference the original value for that unit type in squads.csv?

Re: Merging infantry

Posted: Mon Sep 10, 2012 2:17 pm
by rf900
Yes, it should work fine with any number of men for infantry types. I need to fix a bug, there is a case 2+3 or 3+2 cannot remember which one that gives 4 instead of 5. Probably with other cases with higher number of men it may be working incorrectly.

Re: Merging infantry

Posted: Mon Sep 10, 2012 2:32 pm
by GottaLove88s
rf900 wrote:Yes, it should work fine with any number of men for infantry types.
That's excellent news! Very clever code.
rf900 wrote:I need to fix a bug, there is a case 2+3 or 3+2 cannot remember which one that gives 4 instead of 5. Probably with other cases with higher number of men it may be working incorrectly.
Ok, we will hold off from using it until you tell us that the bug is stomped! :mrgreen:

Re: Merging infantry

Posted: Mon Sep 10, 2012 3:11 pm
by Old_Warrior
Question: for those scenarios that count dead units I am hoping that when the player merges two units together that the program DOES count ONE unit as destroyed. This should be in place to stop folks from bypassing the victory conditions.

This may have been discussed already but if not just a reminder to add that in.

Re: Merging infantry

Posted: Mon Sep 10, 2012 3:23 pm
by GottaLove88s
Old_Warrior wrote:Question: for those scenarios that count dead units I am hoping that when the player merges two units together that the program DOES count ONE unit as destroyed. This should be in place to stop folks from bypassing the victory conditions.

This may have been discussed already but if not just a reminder to add that in.
From the way I understand it, scenarios with unit counting victories, check your units at the start and again at the end, and if you don't have something at the end (through death or merger), you lost it...

Merge does help with carryover tho... For example in rf900's Saving Private Brian, you need to retain certain units... You can merge those with non-carryover units, to keep them healthy... although you do lose whichever unit you merged with... It's all quite neat really.
:-)

Re: Merging infantry

Posted: Mon Sep 10, 2012 3:45 pm
by Old_Warrior
For Achievements they count them during the game too and you can set a UI display to show how many you have left. Thus if the UI says "5 lost" it should increment to "6 lost" when you merge two units into one.

Also - certain units should NOT be eligible to be merged. The entire premise of the Private Bryan unit is that as the unit lost Rangers they failed to understand the mission less. Morale dropped and so on. If the original members we killed then the unit would fail to be important. Similar to "Wittman's Tiger" in a way.

Re: Merging infantry

Posted: Mon Sep 10, 2012 4:09 pm
by GottaLove88s
Old_Warrior wrote:For Achievements they count them during the game too and you can set a UI display to show how many you have left. Thus if the UI says "5 lost" it should increment to "6 lost" when you merge two units into one.
Good point. I'd forgotten that, but it's an important cheat prevention to include in scenarios...