SWAPR - SWeet Automatic Player Replacement script - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 08-02-2019, 01:09 PM   #1
Hardcard
Member
 
Hardcard's Avatar
 
Join Date: May 2013
Posts: 604
Default SWAPR - SWeet Automatic Player Replacement script


If you're tired of...
  • aircraft popping in and out of existence as players join/leave
  • having empty airbases and FARPs
  • being forced to add replacement statics by hand
  • getting high fps in airbases and FARPs


I present to you the brand new...



Step summary + Timestamps:




Old video + timestamps:
Spoiler:



What does SWAPR do?

SWAPR automatically handles the swapping of clients and their automatically generated replacement statics
It will dynamically generate static and uncontrolled AI replacements for any chosen number of clients
It will also remove those replacements dynamically, as players join client slots



Does it work for all airframes, coalitions and countries?

Yes, as long as the clients aren't carrier-based

Unfortunately, replacement statics for carrier-based clients will spawn at the bottom of the sea, instead of on the carrier's deck.

I'm currently working on ways to spawn uncontrolled AI replacements on carriers, but DCS is pretty finicky when it comes to carrier spawns... I make no promises



Does it work in all DCS maps?

Yes, it should



Does it work in MP?

Yes, as far as we've tested



Can I integrate SWAPR in my ridiculously complex missions?

Yes, SWAPR has been successfully integrated in several complex missions during its testing phase



Are there any special requirements?

SWAPR is partially powered by MOOSE, so you'll need to get the latest Moose.lua file and load it in ME (before loading SWAPR.lua)

DO NOT USE MOOSE 2.3.0 , that's an old version, SWAPR needs MOOSE 2.4.13 or higher



Where do I report issues?

Issues can be reported directly in this thread (you can also send me a PM)


IMPORTANT NOTES (extended):
Spoiler:
  • Keep clients in their own individual groups, avoid adding more than one client per group, otherwise the script won't work properly!
    ( A new version of SWAPR is coming, which will support multiple-client groups )
  • Clients must use unique PILOT names in ME, otherwise there will be problems
  • FARP-based clients must be set to either "Takeoff from ground" or "Takeoff from ground hot", otherwise their replacement statics will spawn on top of each other!
  • If you're in a SP environment, ALWAYS join spectators before choosing a coalition (when entering the mission for the first time and when switching coalitions).
    Otherwise you'll encounter problems.


Known Issues:
Spoiler:
  • SWAPR won't work properly with carrier-based clients. There's a problem with DCS, which causes statics to spawn at the bottom of the sea instead of on the carrier's deck
    I'm working on it, but don't hold your breath... I make no promises
  • When running in dedicated servers, execution delay might cause replacements to not be removed in time when clients spawn... so they'll explode and mess it all up.
    I think I've solved this particular issue in the new version I'm working on. I'll release it as soon as it passes all tests



Changelog:
Spoiler:
  • 08-04-2019
    • Improved SWAPR (Reference_Table builder).lua. Multiple-client groups are now supported (liveries will be referenced properly)
      Also, helicopters and harrier replacement statics for airbase clients will no longer be offset when spawning.
  • 08-10-2019
    • SWAPR(Plug & Play) released! Much improved version!
    • Corrected a small issue, which caused hidden client replacements to be "unhidden" (only works for airbase planes)




Big thanks to...
Spoiler:
  • Eagle Dynamics, for creating this awesome sim
  • Grimes, for the invaluable Hoggit Wiki and useful tips/assistance round these parts
  • FlightControl and Funkyfranky for their awesome work developing MOOSE
  • Funkyfranky, Delta, Pikes, Shadowze, Nolove, Mechanist, etc. (MOOSE community in general) for helping me learn the ways of MOOSE and also for their invaluable assistance
  • Miller, for inviting me to join the Apex team ( and also for the awesome present )
  • Eduardo (Rudel_chw), for helping me test SWAPR and for putting up with my numerous script modifications and PMs
  • The DCS community in general. I hope you'll enjoy SWAPR and provide useful feedback, so I can make it better




Old version of SWAPR can be downloaded here
Attached Files
File Type: lua SWAPR (Plug & Play).lua (14.2 KB, 26 views)
File Type: miz SWAPR (Plug&Play) demo.miz (1.01 MB, 14 views)

Last edited by Hardcard; 08-17-2019 at 09:52 PM.
Hardcard is offline   Reply With Quote
Old 08-02-2019, 03:08 PM   #2
Shahdoh
Senior Member
 
Shahdoh's Avatar
 
Join Date: Jan 2013
Posts: 1,263
Default

A beautiful solution to an age old problem in DCS. I would like to suggest that when you are building the reference table and you need to change all the clients to AI, that you could save those changes to another mission name. This will leave your original mission set with clients, saving you that step of changing the AI back to clients, you only need to add the trigger to load SWAPR.lua (after inserting the reference table and other changes) in the original mission and should be good to go.
Shahdoh is offline   Reply With Quote
Old 08-02-2019, 03:32 PM   #3
Hardcard
Member
 
Hardcard's Avatar
 
Join Date: May 2013
Posts: 604
Default

Quote:
Originally Posted by Shahdoh View Post
I would like to suggest that when you are building the reference table and you need to change all the clients to AI, that you could save those changes to another mission name. This will leave your original mission set with clients, saving you that step of changing the AI back to clients
Listen to the man, people!

I didn't want to complicate the process even move, but sure, having a client version and an AI version of the same mission (only for reference table generation) is a neat trick
Hardcard is offline   Reply With Quote
Old 08-02-2019, 04:17 PM   #4
Rudel_chw
Veteran
 
Join Date: Nov 2013
Location: Antofagasta, Chile
Posts: 4,245
Default

Thanks a lot for developing this Scripts @Hardcard your post is very thorough, but I would like to provide a bit of context to help highlight the significance of your development:

Up to now, when I'm the first person to arrive into a Multiplayer server, I'm greeted by an empty tarmac where my aircraft stands alone until other human players begin to login and pick up their slots .. but even then a lot of the ramp places remain empty as rarely enough players gather together to man every aircraft and helo.

For a long time I longed to have the option of having playable aircraft parked empty with no pilot on the ramp until a human player select that aircraft in the multiplayer lobby and jumps into it.

I wanted to have visible and parked over the designated parking slots all "playable" aircraft and before a pilot can jump on it in multiplyer.

This feature even presents the interesting situation to allow that client aircraft to be destroyed by the enemy on the ground when the fight moves over an airfield, even if there is no human pilot for it.

As an example, this is "The Enemy Within 3.0 MP" mission that Baltic Dragon shared on this Forum a short while ago .. I'm the first pilot to connect to the Server:



I'm the only aircraft on the ramp .. the Mission designer has placed a few ground units there in an attempt to avoid having a bare airfield, so it looks pretty nice.

However, when using @hardcard's script, the Mission now looks like this:



much better, isnt it? ... I love the fact that the "empty" aircrafts are shown by DCS with no pilot and their canopies closed, while my aircraft has a pilot and the canopy open ... it looks really good and makes the extra mission editing effort really worthwhile.

Best wishes,


Eduardo
__________________
For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra
For Gaming: 27" Monitor - Ryzen 1500X - 32 GB DDR4 2400 - MSI GTX970 - SSD 480 GB - HDD 10 TB - Windows 8.1 Pro - Thrustmaster HOTAS Cougar - Oculus Rift CV1
Mobile: iPad Pro 12.9" of 128 GB
Rudel_chw is offline   Reply With Quote
Old 08-02-2019, 05:11 PM   #5
GTFreeFlyer
Member
 
Join Date: Dec 2018
Location: Orange County, California, USA
Posts: 286
Default

This looks very cool. I’m going to try it!
__________________
Sim: RTX2080, Rift CV1, 32 GB DDR4 2666 MHz, Intel i7-8700 3.2 GHz, SSD, Windows 10 (Omen by HP Obelisk Desktop), Warthog HOTAS, CH Pro Rudder Pedals
DLC: A-10C, Hornet, Huey, PG, NTTR, The Enemy Within, Piercing Fury
IRL: Private Pilot, UAS Test Pilot, Aircraft Designer
GTFreeFlyer is offline   Reply With Quote
Old 08-02-2019, 10:07 PM   #6
Rudel_chw
Veteran
 
Join Date: Nov 2013
Location: Antofagasta, Chile
Posts: 4,245
Default

Quote:
Originally Posted by Hardcard View Post

Does it work in all DCS maps?

Yes, it should
So far, I had tested it on Caucasus and Nevada, but today I tried it out on the Persian Gulf and it works perfectly

Here is a shot with the un-moded Mission (this is the excellent "Crack the Channel", by Apache600 https://www.digitalcombatsimulator.c...files/3305550/) .. I feel so lonely:



Here is the same, but with @Hardcard's Script providing static replacement for those Clients not yet connected:



And here, its the same, but also with one of my Airfield Templates (https://forums.eagle.ru/showpost.php...postcount=36):



Love the added scenery, it makes the airbases come alive.
Cheers!

Eduardo
.
__________________
For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra
For Gaming: 27" Monitor - Ryzen 1500X - 32 GB DDR4 2400 - MSI GTX970 - SSD 480 GB - HDD 10 TB - Windows 8.1 Pro - Thrustmaster HOTAS Cougar - Oculus Rift CV1
Mobile: iPad Pro 12.9" of 128 GB
Rudel_chw is offline   Reply With Quote
Old 08-03-2019, 12:24 AM   #7
Shahdoh
Senior Member
 
Shahdoh's Avatar
 
Join Date: Jan 2013
Posts: 1,263
Default

Attempting to build the table on a Normandy WWII mission with over 200 client aircraft. I have my prefix set and and for the first 80 some aircraft, the table data looks fine. After that, the tables are truncated.

My Prefix code I am using is "%(".

Good data:
Spoiler:
Code:
 local Reference_Table = { -- ===================== TABLE STARTS HERE!!!
 
   ["(B) Chevy 28-1"] = { -- Start of (B) Chevy 28-1 subtable
     ["Heading"] = 4.5890454471979 ,
     ["Country"] = 66 ,
     ["Coalition"] = 1 ,
     ["x"] = -21711.705078125 ,
     ["Livery"] = "FW-190D9_JG54" ,
     ["y"] = -8164.1577148438 ,
     ["StaticName"] = "(B) Chevy 28-1_Replacement_Static" ,
     ["ClientName"] = "(B) Chevy 28-1" ,
     ["TypeName"] = "FW-190D9" ,
     ["CategoryName"] = "Airplane" ,
   }, -- End of (B) Chevy 28-1 subtable


Truncated data(somewhere after 80 aircraft, prior entries were complete):
Spoiler:
Code:
   ["(B) Uzi 23-1"] = { -- Start of (B) Uzi 23-1 subtable
     ["Heading"] = 2.4245519116035 ,
     ["Country"] = 2 ,
     ["Coalition"] = 2 ,
     ["x"] = -9336.021484375 ,
     ["Livery"] = "USAF 364th FS, HURRY HOME HONEY" ,
     ["y"] = -72570.4375 ,
     ["Coalition"] = 2 ,
     ["y"] = -25101.83203125 ,
     ["ClientName"] = "(F) Uzi 4-1" ,
     ["CategoryName"] = "Airplane" ,
 
   ["(F) Colt 4-1"] = { -- Start of (F) Colt 4-1 subtable
     ["Country"] = 2 ,
     ["Coalition"] = 2 ,
     ["Livery"] = "USAF 485th FS" ,
     ["y"] = -25116.49609375 ,
     ["TypeName"] = "P-51D-30-NA" ,
 
   ["(B) Chevy 26-1"] = { -- Start of (B) Chevy 26-1 subtable
     ["Country"] = 66 ,
     ["x"] = -21674.8984375 ,
     ["Livery"] = "FW-190A8_2.JG 54" ,
     ["ClientName"] = "(B) Chevy 26-1" ,
     ["CategoryName"] = "Airplane" ,
 
   ["(C) Dodge 13-1"] = { -- Start of (C) Dodge 13-1 subtable
     ["Country"] = 66 ,
     ["x"] = -34071.203125 ,
     ["y"] = -10075.522460938 ,
     ["StaticName"] = "(C) Dodge 13-1_Replacement_Static" ,
     ["CategoryName"] = "Airplane" ,



Is there some limit to the number of aircraft the script can handle? I realise this is probably on the high side and could/should be trimmed down.

Last edited by Shahdoh; 08-03-2019 at 12:58 AM.
Shahdoh is offline   Reply With Quote
Old 08-03-2019, 12:46 AM   #8
Rudel_chw
Veteran
 
Join Date: Nov 2013
Location: Antofagasta, Chile
Posts: 4,245
Default

My largest mission had 90 clients .. you really have a large one .. I hope @hardcard can shed some light into this.

That’s a strange prefix, but I dont believe it is related to this problem .. on my missions I used the "_Client" suffix, as it is easily seen on the unit list and prevents confusing Client with AI aircrafts.
__________________
For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra
For Gaming: 27" Monitor - Ryzen 1500X - 32 GB DDR4 2400 - MSI GTX970 - SSD 480 GB - HDD 10 TB - Windows 8.1 Pro - Thrustmaster HOTAS Cougar - Oculus Rift CV1
Mobile: iPad Pro 12.9" of 128 GB
Rudel_chw is offline   Reply With Quote
Old 08-03-2019, 12:54 AM   #9
Shahdoh
Senior Member
 
Shahdoh's Avatar
 
Join Date: Jan 2013
Posts: 1,263
Default

Yeah, It was a unique character already set in the mission for clients, and with that many client aircraft, thought I would give it a try.

To explain further, the client aircraft all have an Airfield code at the start, identified with the 1st character of the name of the field surrounded by parenthesis for sorting.

Since the parenthesis is a special character in Lua, have to use the escape character % prior to it so it will actually look for (.
Shahdoh is offline   Reply With Quote
Old 08-03-2019, 10:56 AM   #10
Hardcard
Member
 
Hardcard's Avatar
 
Join Date: May 2013
Posts: 604
Default

@Shahdoh

That's an interesting issue, could you share the full dump from dcs.log and the reference table builder script that you're using?

Btw, when you get the AI_SET count, does it match the number of clients that you've selected in the mission?

Do you get errors in dcs.log?

Also (you've probably thought of this already), for now, I'd do what you suggested yesterday.

Make a copy of the mission and give it a different name, so you can make wild modifications to it, then try the following stuff:
  • Target only the clients whose tables came out truncated, see if the problem persists.
    If it does, the source of the issue is likely there, we'll need to look into those clients to see what's different about them...
    Are those clients very close to other clients? Like less than 10m/~30ft apart?.
    Are those clients based on an airbase (with their own parking spot)? (screenshots might help make things clearer)

    If it doesn't persist, then proceed to the step(s) below
  • Remove all the unrelated triggers, leave only the Moose.lua and the Reference_Table builder triggers...and the clients, ofc.
    Run the mission again, see if the dumped table is still truncated... if it comes out fine, then I guess you have a trigger conflict / overload problem in your mission.
  • If it still comes out truncated, then get rid of / exclude half of the clients in the mission and run the test again.
    If it works, proceed to do the same for the other half of the clients, see if it also works.

    If it also works, then it's pretty clear that there's a limit to the number of clients that can be targeted in each run.
  • If none of the above works, then reduce the client selection to a third/quarter instead of a half and repeat the test, see what happens.
    If the issue persists, get rid of the "%(" prefix, don't use any lua magic characters in any of the client PILOT names.
    Also, you could try changing the parking spots of problematic clients.
    Also, if you're using mods, disable them, see what happens.


Please, keep us informed, I'll probably need to modify some stuff depending on your results.


@Rudel_chw

Thanks for showcasing SWAPR in your posts, cool stuff!

Last edited by Hardcard; 08-03-2019 at 01:07 PM.
Hardcard is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 04:57 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.