Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Is there a way.....?

 
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 >> Lua Legion >> Is there a way.....? Page: [1]
Login
Message << Older Topic   Newer Topic >>
Is there a way.....? - 8/20/2020 8:09:57 PM   
DWReese

 

Posts: 1710
Joined: 3/21/2014
Status: offline
I like to create scenarios that uses randomization. In my mind, the enemy forces (computer-controlled) may be augmented by a random result and tele-ported in at the start of the scenario. Therefore, you (as the game player) would never know exactly what forces that you are facing. I know how to do this. But, here's a twist.....

What if I had various hangers of planes (similar to what is already on the base) and I had them (possibly) tele-ported to the base's location? Notice, I didn't say into the base. That's the problem. If I transport these to the location, then they still aren't actually ON the base itself.

So, is there a way to GROUP or INCORPORATE the newly transported hanger of aircraft INTO the base, so that it would be able to become part of the base WITHOUT ME actually doing it? (Otherwise, it would be useless.) I do realize that I could do this MANUALLY, but as a game player who is playing against the computer, I would like the computer to do it without my knowledge. I assume that, if it could be done, this would require some LUA coding, but I don't know too much about that.

If this is possible, and someone knows how to do it, could they please provide a DETAILED example (i.e. sample code) that I could essentially use as a guide to adapt to my own scenario to perform this function?

I do believe that this is an interesting and useful concept, if it can be done.

Thanks in advance.

Post #: 1
RE: Is there a way.....? - 8/21/2020 5:26:12 AM   
KnightHawk75

 

Posts: 1130
Joined: 11/15/2018
Status: offline
Entirely possible.
In the event, after the teleport action, add a second action of lua script action.
Then for each teleported unit get unit and assign it to related airbase group name (unit.group="airbase unit name").

Or ditch the whole pre-made + teleport unit thing (unless for some reason you really need it) and just script the actual creation of units at the base with certain dice rolls generating certain units and loadouts (and hangers if needed) or not as the case may be.

Post in the lua section specifically what you want and I'll dummy up a sample for it.

As is I'm interpreting what you wrote as say 4 different "packages" of units to be possible at a set airbase and say a 25% chance each time you play of one of those 4 being chosen and applied to the base, is that the sort of sample you want? Do you want each and every unit to have a random chance of appearance at the base? Should generated units also be assigned to missions etc...type of things I mean when I says post specifically what you want in the sample.


< Message edited by KnightHawk75 -- 8/21/2020 5:30:36 AM >

(in reply to DWReese)
Post #: 2
RE: Is there a way.....? - 8/21/2020 8:40:03 AM   
DWReese

 

Posts: 1710
Joined: 3/21/2014
Status: offline
Wow! Thank you for responding. Thank you for the offer.

Planes to add:

Up to a maximum of 6, coming in increments of 2 (if possible). If not, one is fine, and one is probably more realistic anyway.

The plane(s) to add is the Chinese J-11BSH Flanker C (#4449 in the database)

The call signs (if needed) would be Argonaut 9, 10, 11, 12, 13, 14, etc.)

The Load Out would be Standard CAP (6 PL 12, and 2 PL-8B) The ID is #22439. They all have the same Loadout.

I would prefer to have them in Hangers that could hold 2 Large Aircraft (18.1-26m Long) The hangers can be created new, if necessary, or I do have existing space in existing hangers. Whatever is easier.

The mission is Fiery Cross CAP 1 (AA Patrol).

The 25 percent appearance-thing is fine. I can adjust it as needed. And, yes, each unit should have the same chance of appearing. So, I might get the first (Argonaut 11), and the fourth (Argonaut 14), when everything is complete, if it works that way.

Hopefully, I addressed all of you questions.

Thanks again for doing this. I really find this to be very interesting.

(in reply to KnightHawk75)
Post #: 3
RE: Is there a way.....? - 8/21/2020 10:44:07 AM   
KnightHawk75

 

Posts: 1130
Joined: 11/15/2018
Status: offline
Gotcha thanks, should be enough to whip up a sample scene up for you that you can adjust\learn from.

(in reply to DWReese)
Post #: 4
RE: Is there a way.....? - 8/21/2020 12:01:29 PM   
DWReese

 

Posts: 1710
Joined: 3/21/2014
Status: offline
Thank you so much.

Please just work on this when it is convenient for you. There is no rush. I'm not in any hurry, so please don't put yourself out in any way.

Thanks again.

(in reply to KnightHawk75)
Post #: 5
RE: Is there a way.....? - 8/21/2020 2:56:10 PM   
KnightHawk75

 

Posts: 1130
Joined: 11/15/2018
Status: offline
Attached is a RandomHangerAddDemo.scen using db486 - Load it and select Red.

On Scene load it will...

Check if the hanger generation has run before or not (ie if someone started and saved the file previously), if it has not run it will run, if it has run it will skip it.

If it runs it will run though 6 possible hanger locations, for each one there is a 25% change it will generate the hanger (up to 3 hanger max) and assign the hanger to the base named Red_Airbase. For each generated hanger it will put 2 of the specified fighters in that hanger, give it the specified load-out (regardless of if munitions exist at the base yet), mark them both 'ready', and assign it to a mission 'Fiery Cross CAP 1'. Then mark itself as having run regardless of how many if any have been generated.

The Red_Airbase is just a sample existing airbase group so you can switch between group and single view and see the new stuff is added to the base.

At the top of the GlobalStartupScript action script there are values you can use to easily adjust a few things.
Such as:
gKH.SceneGlobals.PerHangerChancePct = 25; --percent chance for each hanger.
gKH.SceneGlobals.RedbaseHangerMax = 3; --cap at 6 aircraft.

There are others with comments to let you know how they are used.
Obviously you'll need to change the lat\lon info in the gKH.SceneGlobals.Redbase1Hangers table at the top of the script for your actual usage in another scene.
If you need to change the dbid for the hanger (41) it's in gKH.CreateHangerUnitPackage function
If you need to change the dbid,loadout etc of the aircraft it's in DoRandomHangerGeneration function.
There is a special action on red side, you can use while testing and reset the special run-once marker if you save a file after it's run. If you just want to see different random runs, don't save and just keep reopening the file you should get relatively different results each time.
There is only minimal error checking in the routines, so make sure things like lat\lon you change are actually on land etc, but a few things are logged to \logs\luahistory-date-.txt, like hitting the max, generation already having been done, the random numbers generated,etc. If you have any questions to how something works or don't understand a piece of the code, feel free to ask.



Attachment (1)

< Message edited by KnightHawk75 -- 8/21/2020 3:03:46 PM >

(in reply to KnightHawk75)
Post #: 6
RE: Is there a way.....? - 8/22/2020 10:10:08 PM   
DWReese

 

Posts: 1710
Joined: 3/21/2014
Status: offline
Thank you so much for the detailed explanation.

I intend on working on it tomorrow. This is exactly what I had hoped to do.

You are a genius.

Thanks again.

(in reply to KnightHawk75)
Post #: 7
RE: Is there a way.....? - 8/26/2020 2:10:35 PM   
jkgarner

 

Posts: 166
Joined: 4/30/2020
Status: offline
@KnightHawk75:

I am just interested in the Lua script to do that... (I can not read your commercial scenarios in my version) How about throwing just the script out?

That would be execellent!

Thanks

(in reply to DWReese)
Post #: 8
RE: Is there a way.....? - 8/26/2020 6:19:54 PM   
KnightHawk75

 

Posts: 1130
Joined: 11/15/2018
Status: offline
@jkgarner

Sure, it's nothing fancy, script attached to place in startup event. I think everything used should work in the pro version.







Attachment (1)

< Message edited by KnightHawk75 -- 8/26/2020 6:20:49 PM >

(in reply to jkgarner)
Post #: 9
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Is there a way.....? 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.211