Merging infantry

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Merging infantry

Post 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.
Attachments
Swap and Merge.zip
Swap and Merge
(10.47 KiB) Downloaded 167 times
Last edited by rf900 on Thu Aug 02, 2012 9:53 am, edited 6 times in total.
IainMcNeil
Site Admin
Site Admin
Posts: 13558
Joined: Fri Apr 01, 2005 10:19 am

Re: Merging infantry

Post 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.
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Merging infantry

Post 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.
IainMcNeil
Site Admin
Site Admin
Posts: 13558
Joined: Fri Apr 01, 2005 10:19 am

Re: Merging infantry

Post by IainMcNeil »

Ok got it - its a good way to start.
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

Re: Merging infantry

Post by GottaLove88s »

That looks great. Is it possible to bring this into the next Open Beta MP release?
SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Merging infantry

Post 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.
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Re: Merging infantry

Post 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
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Merging infantry

Post 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.
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Merging infantry

Post 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)
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

Re: Merging infantry

Post 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?
SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Merging infantry

Post 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.
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

Re: Merging infantry

Post 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...
SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Merging infantry

Post 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.
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

Re: Merging infantry

Post 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?
SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: Merging infantry

Post 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.
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

Re: Merging infantry

Post 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:
SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
Old_Warrior
Major - Jagdpanther
Major - Jagdpanther
Posts: 1022
Joined: Fri Apr 30, 2010 3:13 am

Re: Merging infantry

Post 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.
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

Re: Merging infantry

Post 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.
:-)
SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
Old_Warrior
Major - Jagdpanther
Major - Jagdpanther
Posts: 1022
Joined: Fri Apr 30, 2010 3:13 am

Re: Merging infantry

Post 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.
GottaLove88s
Lieutenant-General - Do 217E
Lieutenant-General - Do 217E
Posts: 3151
Joined: Fri Apr 06, 2012 6:18 pm
Location: Palau

Re: Merging infantry

Post 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...
SCENARIO LINKS
Seelow'45 -> www.slitherine.com/forum/viewtopic.php?f=313&t=55132
Normandy'44 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42094
Dieppe'42 -> www.slitherine.com/forum/viewtopic.php?f=87&t=42347
Post Reply

Return to “Battle Academy : Modders Corner ”