Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

How to replace multiple units?

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> How to replace multiple units? Page: [1]
Login
Message << Older Topic   Newer Topic >>
How to replace multiple units? - 11/7/2020 8:59:28 AM   
morphin

 

Posts: 432
Joined: 4/26/2002
From: Switzerland
Status: online
Is there an easy way to replace an unit? (for example with a modern version of AC or ship).
Yes i can delete the unit and add an unit, but how to replace?

Thank's
Andy
Post #: 1
RE: How to replace multiple units? - 11/7/2020 2:48:22 PM   
KnightHawk75

 

Posts: 691
Joined: 11/15/2018
Status: offline
I don't think I understand what you mean by "replace".
To swap one unit for a different one obviously you would logically delete the unit and add the new unit, and I guess if you want rename it to old units name. What is it you are trying to do exactly?

Do you mean how do you get the new unit's guid to be the same as the unit you deleted?
Provided you copied the only one down prior to deleting you would specific as custom guid when you add the new unit.
You can specify it in the custom guid field in the add unit window, or if scripting use addunit and add the guid field when calling ScenEdit_AddUnit({guid='THEOLD-UNITGUIDHEREX',...other entries...})






< Message edited by KnightHawk75 -- 11/7/2020 2:50:07 PM >

(in reply to morphin)
Post #: 2
RE: How to replace multiple units? - 11/7/2020 3:06:24 PM   
BDukes

 

Posts: 765
Joined: 12/27/2017
Status: offline
Hmm. If you think mass-quick-switch maybe use sbr file and change all the ship numbers using replace function in text editor. Likewise could do some lua through console too. Should be faster than manual unit delete and add.

(in reply to KnightHawk75)
Post #: 3
RE: How to replace multiple units? - 11/7/2020 3:22:14 PM   
morphin

 

Posts: 432
Joined: 4/26/2002
From: Switzerland
Status: online
Switch one type to another (all number of a specific typ to another, so for example 60 AC Mig-19 to Mig-20). Yes maybe with an sbr file or with LUA, but LUA i don't know enough yet....

(in reply to BDukes)
Post #: 4
RE: How to replace multiple units? - 11/7/2020 4:16:21 PM   
morphin

 

Posts: 432
Joined: 4/26/2002
From: Switzerland
Status: online
It is about the Red Dragon Descends 2022 Scenario
I have sucessfully created "Generate Template" and didn't change anything but imported it again with "Apply SBR script", but i get tis message:

"XML file is improperly formatted, read failed!"

It seems that this scenario is too big to generate a XML file?

Attachment (1)

< Message edited by morphin -- 11/7/2020 4:18:18 PM >

(in reply to morphin)
Post #: 5
RE: How to replace multiple units? - 11/7/2020 4:18:39 PM   
morphin

 

Posts: 432
Joined: 4/26/2002
From: Switzerland
Status: online
And here the ini file

Attachment (1)

(in reply to morphin)
Post #: 6
RE: How to replace multiple units? - 11/7/2020 4:27:58 PM   
morphin

 

Posts: 432
Joined: 4/26/2002
From: Switzerland
Status: online
Yes, it seems that this scenario is too big to generate a ini template. I will open a technical request

(in reply to morphin)
Post #: 7
RE: How to replace multiple units? - 11/7/2020 8:58:51 PM   
KnightHawk75

 

Posts: 691
Joined: 11/15/2018
Status: offline

quote:

ORIGINAL: morphin

Yes, it seems that this scenario is too big to generate a ini template. I will open a technical request


Are you trying to 'mass change' one particular thing, or a ton of things?
Cause I can give specific samples if you're trying to do it via Lua, and you're not customizing the unit.

~15k AU count...lol officially the largest or 2nd largest scenario I've ever loaded, I think lol.

Anyway the SBR Temple .ini and delta's generated ok for me with 2 minor errors that can be ignored.
Are you using 1147.14?
ini and delta's attached.

Attachment (1)

(in reply to morphin)
Post #: 8
RE: How to replace multiple units? - 11/8/2020 4:21:55 AM   
morphin

 

Posts: 432
Joined: 4/26/2002
From: Switzerland
Status: online
THank's
I opened in the tech forum a request:

https://www.matrixgames.com/forums/tm.asp?m=4908184

It seems that there was a kind of data mismatch. After correction i was able to import the template

->and yes i'm using 1147.14

->I would like to make PLA, DPRK and Russia much stronger. So i would like to replace older ships and AC with more modern ones. But i can now change the template and replace the one units type with another.

But if you have already LUA code that can replace all units of a type with another unit type that would be even better

Thank's

(in reply to KnightHawk75)
Post #: 9
RE: How to replace multiple units? - 11/8/2020 10:09:50 AM   
KnightHawk75

 

Posts: 691
Joined: 11/15/2018
Status: offline

quote:

ORIGINAL: morphin

THank's
I opened in the tech forum a request:

https://www.matrixgames.com/forums/tm.asp?m=4908184

It seems that there was a kind of data mismatch. After correction i was able to import the template

->and yes i'm using 1147.14

->I would like to make PLA, DPRK and Russia much stronger. So i would like to replace older ships and AC with more modern ones. But i can now change the template and replace the one units type with another.

But if you have already LUA code that can replace all units of a type with another unit type that would be even better

Thank's


I do but it's was crude and was for mainly for ships\subs and aircraft in the air, ie didn't take into account if they were 'docked', or in the case with aircraft if they were on the ground, nor did it try to keep them grouped, or keep their mission assignments..etc, ie it was for just for pin-point replacing selected things during a scene or during scene set-up.

I'm gonna see what I can whip up for a more user-friendly way to hopefully handle most if not all that for any given MASS swap of one DBID for another.

(in reply to morphin)
Post #: 10
RE: How to replace multiple units? - 11/8/2020 1:48:31 PM   
morphin

 

Posts: 432
Joined: 4/26/2002
From: Switzerland
Status: online
I just have a look at the ini file. But i think it is not possible to change the type of AC (or ship) in this file. You only have a tag for example this:

<Unit_UVYFJ7-0HM1EEBLHDJVN>
<!--Spirit #129 (F-5A Fresco [MiG-17PF Copy] [3897])-->
</Unit_UVYFJ7-0HM1EEBLHDJVN>

and so you will need to change the tag "Unit_???" and i don't think you can do this. It seems that LUA is the only possible way to Change for example all the old F-5A Fresco with MiG-21....

(in reply to KnightHawk75)
Post #: 11
RE: How to replace multiple units? - 11/8/2020 10:30:47 PM   
Rory Noonan

 

Posts: 2634
Joined: 12/18/2014
From: Melbourne, Australia
Status: offline
https://www.matrixgames.com/forums/tm.asp?m=4908508

_____________________________


(in reply to morphin)
Post #: 12
RE: How to replace multiple units? - 11/9/2020 11:01:18 AM   
KnightHawk75

 

Posts: 691
Joined: 11/15/2018
Status: offline
cross posted as well @ https://www.matrixgames.com/forums/tm.asp?m=4908508
The attached gKH_Side_ReplaceUnitsByDBID_v2.zip contains a more full featured script for this.
I extended what I already had for your use case, and hopefully what I added extends it use for a wider number of cases where people need to mass-replace, but not have to re-do as much after the mass-replace.

I tested it against some USA and PLA aircraft\ship\sub and radar facilities in your scene posted previously in other thread.



Here are the release notes for v2:
The two files Localized and Global are 99.999% the same the only difference is that for Localized_..
The gKH namespace table is defined as local, this is meant for lua console only use.
Such as during scene development process.

The global version once run once will stay in memory, so you don't need to run it again. 
It's meant more for use when wanting to use these function during the game play.

ReplaceUnitsByDBID() takes 6 parameters, first 5 are required.
 theside: the string side name to operate on, only validation is that it's a string and non-nil. special side "_ALL_" not implimented yet.
 thetype: the string unit type code 'Aircraft','Submarine','Ship','Facility' etc. Validation is only it non-nil and string.
 thedbid: the database id# for the unit being replaced.  must exist and be a number.
 theloadoutid:  the loadout dbid id to further restrict the replacement on, OR 0 to match all (ie only on unit dbid). 
 tParams: the table of parameters that you would normally feed to ScenEdit_addunit(), only thing required is {dbid=###,loadoutid=###}
 themode: optional;either nil\empty or one of "Normal" or "KeepGUIDS" Not fully tested yet, exists for future enhancement purposes.
 themode: default if left empty or is anything else is "Normal", replacement units get new guids, keepguids attempts to reuse old unit guids.
THINGS TO BE AWARE OF:

 -Replacement units will by default get new GUIDS, if you want to try reusing old guid, set themode to "KeepGUIDs", however this comes with risk.
  The risk is that the unit will be removed before an attempt to create the replacement, and if that fails for some reason the original is now gone.  

 -Replacement units that were members of groups will be put back into group the original was a members of, however leads may change.

 -Replacement units that were members of missions will be assigned to the original units mission. HOWEVER if they were flagged as escorts
  they will not get re-flagged as escorts as there is at present no way to detect this in LUA that I found.

 -Replacement units that were parked\docked inside bases will be generated and placed in the originally hosting parent. HOWEVER they will
  NOT be placed in the same parking spots. Those in th air or at sea,etc will be placed in the same location as the original. 

 -Replacement units will be assigned the course that the original unit had, if they had a course.

 -Replacement units in most cases MAY NOT RECEIVE WRA\DOCTRINE\EMCON settings that the original had. However they should get group\mission\etc
  inheritence, such that when you are done making changes, and you goto the various higher level settings screens and press REAPPLY to units
  affected it should take care of things. If you had non-iherited specific settings on the original you will have to manually adjust again.
 -Replacement units in most cases may not get the same speed\throttle setting that the original had, though some attempt has been made to 
  preserve altitude\depth, but wide testing has not been done (ie it generally works but current vs desired may be screwed if not on mission).

 -Replacing units such as a carrier or airbase\port dbid component - keep in mind any hosted aircraft\ships will be removed.
  While it's possible to modify the script to support auto re-generation of hosted units at present it does not support this.  
  For the above reason I DO NOT recommend using this on DBID's that are part of a port\air-base\carrier, but you can provides you don't mind
  losing the contents. 

 -Remember that once you run a change, if you want to reverse it, the reverse application may affect more units than original if the side 
  originally had some existing units of what you changed certain things too. ie if side had 5 su-27's and you swap 15 mig21 to su27's, then try
  swapping back all su-27's to mig-21's then 20 units will be affected on the swap back. Should be obvious but it's worth keeping in mind.

 -You must specificy both the dbid and loadoutid, if you feed it a loadoutid# that is 0, it will ignore loadoutid matching and just use dbid. 
   
EXAMPLE USAGE (happens to be base on Red Dragon Desecnds 2022 scene, but is illustrative of any)
If using in console place these after the end of all the function related code...ie bottom.

-- ** Aircraft swap examples 
-- swap j-8f 2473 with loadoutid 9626 to j-11b 4641 loadout: 25278 
--gKH.Side:ReplaceUnitsByDBID('PLA','Aircraft', 2473, 9626,{dbid=4641,loadoutid=25278});
-- swap j-11b 4641 with loadoutid 25278 to j-8 4273  loadout: 9626
--gKH.Side:ReplaceUnitsByDBID('PLA','Aircraft', 4641, 25275,{dbid=2473,loadoutid=9626});

-- swap ALL j-8f 2473 to j-11b 4641 loadout: 25278 
--gKH.Side:ReplaceUnitsByDBID('PLA','Aircraft', 2473, 0,{dbid=4641,loadoutid=25278});
-- swap ALL j-11b 4641 to j-8 4273  loadout: 9626
--gKH.Side:ReplaceUnitsByDBID('PLA','Aircraft', 4641, 0,{dbid=2473,loadoutid=9626});
-- ** Submarine swap examples (note the last param false here is not needed, just shows that sending invaild entry is same as it not being there)
-- swap S-368 296 to 093B Shang 665 0 
--gKH.Side:ReplaceUnitsByDBID('PLA','Submarine', 296, 0,{dbid=665,loadoutid=0}, false);
-- swap 093B Shang 665 to j-8 S-296  0
--gKH.Side:ReplaceUnitsByDBID('PLA','Submarine', 665, 0,{dbid=296,loadoutid=0}, false);

-- ** Ship swap examples 
-- swap Type 037-IG Houxin 349 to 056A Jiangdao  2703 0 
--gKH.Side:ReplaceUnitsByDBID('PLA','Ship', 349, 0, {dbid=2703,loadoutid=0}, false)
-- swap Type 056A Jiangdao 2703 to type 037-IG Houxi 349 0 
--gKH.Side:ReplaceUnitsByDBID('PLA','Ship', 2703, 0, {dbid=349,loadoutid=0}, false);

-- ** Facility swap examples 
-- swap jy-27 Wide mat 545 to BigBird D 2444 
--gKH.Side:ReplaceUnitsByDBID('PLA','Facility', 545, 0,{dbid=2444,loadoutid=0}, false);
-- swap BigBird D 2444 to jy-27 Wide mat 545 
--gKH.Side:ReplaceUnitsByDBID('PLA','Facility', 2444,0, {dbid=545,loadoutid=0}, false);


Attachment (1)

< Message edited by KnightHawk75 -- 11/9/2020 3:04:54 PM >

(in reply to Rory Noonan)
Post #: 13
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> How to replace multiple units? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.152