Assigning Cargo Elements to a Mission

Take command of air and naval assets from post-WW2 to the near future in tactical and operational scale, complete with historical and hypothetical scenarios and an integrated scenario editor.

Moderator: MOD_Command

DWReese
Posts: 2294
Joined: Fri Mar 21, 2014 11:40 am
Location: Miami, Florida

Assigning Cargo Elements to a Mission

Post by DWReese »

When conducting a "simulated cargo attack mission" using the tele-porting method, the teleported unit could be issued an attack mission and be placed on the other side of the world waiting to be tele-ported into the battle at the appropriate time. That seemed to work fine.

But, with the creation of the actual CARGO function, I believe that it is more realistic, therefore I am trying to use that as much as possible, rather than the tele-porting method. One thing that befuddles me is, how do I assign a mission for the AI to use in situations like I just described involving CARGO attack units? That don't have a name, or an ID number. They are merely CARGO until that are dropped, at which time they simply appear.

Does anyone know of a way to do it? I've looked at it from several different angles, but I can't seem to be able to do it. For example, using Gunner98's H-Hour Northern Fury scenario as an example (only because it is the best), he uses the tele-porting method to drop various Soviet units to attack the Norwegians. Since they were being tele-ported in, Gunner was able to assign missions to the Soviet troops BEFORE they were airdropped. What I would like to do is figure out a way to do the same thing for the AI using the new CARGO METHOD. Is that possible?

Doug
fatgreta1066
Posts: 507
Joined: Sun Dec 30, 2012 2:37 am

RE: Assigning Cargo Elements to a Mission

Post by fatgreta1066 »

I cannot hope to answer your question but am keen to hear itnwjen someone does. Until then can I ask, is the teleporting method something likenusing lua scrip to caise units to appear when certain conditions are met, similar to what’s been done in Desert Storm?
User avatar
Gunner98
Posts: 5880
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Assigning Cargo Elements to a Mission

Post by Gunner98 »

Hay Doug

I am certain that there is a way to do what you're asking but I have not yet figured out how, but I'm not sure its needed.

There are three ways of transporting land units around around the battlefield:

1. Teleporting as in the scenario you're describing, H-hour which is the only way that it could be achieved originally. This has the disadvantage that the unit needs to exist on the map when the scenario is designed - although it can be hidden from plyers on a different side. The advantage is that it is easy to manipulate and assign to missions as you describe

2. Using Lua to 'spawn' the unit when triggered. This is cleaner and if I were to re-build H-hour I would probably change to this method. But it takes some trial and error in Lua.

3. Using the cargo method, which as you say is more realistic - sort of - but is it needed?

I think as a designer you need to ask yourself the question: What is it that I am trying to achieve?

-if the use of cargo is on the player side - no issue, it is more fun and arguably more realistic but since the player is manipulating the units there is no need to go further than provide the resources and the mission.

-if the cargo element is on an AI side; I need to ask, what is the point of the exercise? What impact will this have on the player? Is this the best way of spending your designing efforts?

I'm a firm believer that all three methods described above have their valid uses and purpose in designing scenarios. One solution does not fit all problems and you will need to mix and match as required. Keeping the end user (the player) in mind when your designing the solution is important.

Although there should be a way of doing what you are asking, it probably involves a lot of coding gymnastis which is beyond my skill. But from a player point of view, using teleport or lua, the assault comes in and the units go on the attack - eee-gad what do I do now? I think that's the trick (he says after several glasses of wine at dinner...)

B
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
User avatar
Gunner98
Posts: 5880
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Assigning Cargo Elements to a Mission

Post by Gunner98 »

Until then can I ask, is the teleporting method something likenusing lua scrip to caise units to appear when certain conditions are met, similar to what’s been done in Desert Storm?

Yes, either teleporting or Lua will be triggered by certain conditions and will be based on events created in the editor.

B
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
DWReese
Posts: 2294
Joined: Fri Mar 21, 2014 11:40 am
Location: Miami, Florida

RE: Assigning Cargo Elements to a Mission

Post by DWReese »

I'm not certain what you are referring to, but the tele-porting can be done without having CoW. Obviously, I do own CoW.

Tele-porting is basically placing a unit somewhere on the globe, and under certain conditions, the unit is transported from its location (such as on the other side of the world) to a new location. Most use it to simulate airdrops, etc. So, you could have a transport plane fly to an area, and when it arrives, an infantry unit is tele-ported in to that location to simulate being airdropped in. That is just one example. With this, the unit could have been given an attack mission and as soon as it is on the ground, it proceeds on its attack mission.

The actual cargo mission, where CoW is needed, allows you to pick and choose what units are t be transported, but they aren't in the sane format as the units are listed in the database. They are usually represented by a counter called a Landed Detachment. Since the detachment can essentially be anything, it doesn't represent actual identified units with numbers relating to a specific unit in the database. Without a specific ID number, they can't be assigned missions like the tele-ported units can. Or, if they can, I don't know how to do it.

Hopefully, I've answered your questions about tele-porting, and someone will have some info for me.

Doug
DWReese
Posts: 2294
Joined: Fri Mar 21, 2014 11:40 am
Location: Miami, Florida

RE: Assigning Cargo Elements to a Mission

Post by DWReese »

Bart,

I see your point, and I do agree with you that all three methods are useful in their own way, and in their own manner. As you said, if the active player is trying to perform the function, then perform the function. Plus, if it is the AI, use the most simple method possible and have at it. (Lua, however, is beyond my skill set, so that isn't going to happen.)

I am not trying to actively program any actual scenario. I was merely asking because I have recently become become fascinated with the cargo aspect of the game, due largely to H-Hour, and your book, of course. (How many hours did you work on that scenario, anyway?) It is one of the best ever. I have never seen an assault like that, and I can truly see why you used the tele-porting aspect (aside from it being the only one available at the time) because it is simple and it "gets the job done."

Really, I hadn't realized until yesterday, that the new cargo method doesn't 'seem' to allow me to set my cargo-combatants off on a mission because they don't have any identifying ID numbers before being air-dropped. Perhaps in the future......

Thanks for commenting, and I LOVE the book.

Doug
RoryAndersonCDT
Posts: 1826
Joined: Mon Jun 15, 2009 11:45 pm

RE: Assigning Cargo Elements to a Mission

Post by RoryAndersonCDT »

Any thoughts on how to assigned dropped cargo to a mission?
Command Dev Team
Technical Lead
Whicker
Posts: 664
Joined: Tue Jun 19, 2018 9:54 pm

RE: Assigning Cargo Elements to a Mission

Post by Whicker »

I think you can do it with a trigger of unit remains in area, and then assign them to the mission using lua. So I put ref points around the drop zone and that is the trigger area. I think the drop zone is not always inside its ref points so I think i had to make another zone outside of that one little bit. Would have been a little nicer if the same ref points worked for both but I was seeing units get left just outside the cargo mission area.

I did it a while back and it worked fairly well. Biggest problem is ground units are useless when they run out of ammo, and they don't have the concept of a home base so you can't rtb them. Would be nice if you could control them with a home base - so they rtb when out of ammo or when you want them to leave.
hasler
Posts: 39
Joined: Mon Jul 31, 2017 8:28 pm

RE: Assigning Cargo Elements to a Mission

Post by hasler »

Even with the unit remains, how do you make a lua action pointing to the dropped units to assign them to the mission? You will still be missing the unit name or guid to input.

The only way I found to set this up is to fake a cargo mission and have units created for each transport plane that enters an area, and then set them to a mission. It is a PITA because it gets very repetitive but you can do a realistic paradrop to include simulated lapes for heavy equipment (I’m looking at you missing m551).
DWReese
Posts: 2294
Joined: Fri Mar 21, 2014 11:40 am
Location: Miami, Florida

RE: Assigning Cargo Elements to a Mission

Post by DWReese »

The only way that I can see to do it for the AI side is by using the tele-porting method.

There isn't anything wrong with the tele-porting method, but the actual cargo method is more realistic (in my opinion) because you are dealing with the size of actual units. With the tele-porting method, you could essentially fly a 4-seat Cessna (or no plane at all for that matter) to a location and then tele-port an Abrams tank platoon to it.

The actual cargo option is much better, but it apparently doesn't work like that for the AI side at this time.

Doug
Whicker
Posts: 664
Joined: Tue Jun 19, 2018 9:54 pm

RE: Assigning Cargo Elements to a Mission

Post by Whicker »

the unit triggering the action is unitX so the action part of the event is:

local u = ScenEdit_UnitX()
ScenEdit_AssignUnitToMission (u.name, "your mission name")


any unit that cause a trigger to be activated is unitX, then you can do whatever you want with that unit. I used a trigger of `unit remains in area` (10 minutes).
DWReese
Posts: 2294
Joined: Fri Mar 21, 2014 11:40 am
Location: Miami, Florida

RE: Assigning Cargo Elements to a Mission

Post by DWReese »

I'm not very experienced with Lua at all, but I'm real good at being able to adapt something that I see and then use that as a blueprint for use with my own scenario. Is there any possibility that you could post a scenario (even if it is just a portion thereof) that actually shows how this is done?

Thanks

Doug
rmunie0613
Posts: 202
Joined: Tue Jan 02, 2018 7:41 pm

RE: Assigning Cargo Elements to a Mission

Post by rmunie0613 »

The LUA wrapper actually shown in LUA Legion section, shows how to get the guid of cargo. I have used it to order cargo to "deploy" from barracks when a unit is detected nearby...had some unrelated issues with assigning to the mission, but that was just answered over there also. With a lot of cargo- ie. a landing force, it can get long, as each individual unit- platoon, gun, vehicle...will have its GUID but it will work.
DWReese
Posts: 2294
Joined: Fri Mar 21, 2014 11:40 am
Location: Miami, Florida

RE: Assigning Cargo Elements to a Mission

Post by DWReese »

Thanks for the info.

Do you happen to have a scenario that you could post that depicts how to do that? It would make a great visual representation and learning tool.

Thanks,

Doug
Whicker
Posts: 664
Joined: Tue Jun 19, 2018 9:54 pm

RE: Assigning Cargo Elements to a Mission

Post by Whicker »

I'll post something later tonight. It is kind of funny watching the AI land and then attack.
DWReese
Posts: 2294
Joined: Fri Mar 21, 2014 11:40 am
Location: Miami, Florida

RE: Assigning Cargo Elements to a Mission

Post by DWReese »

Thank you so much. That's exactly what I would like to see. It doesn't have to be elaborate. They might want to include something like this with the tutorials. It seems like it would be very worthwhile.

Thanks again.

Doug
Whicker
Posts: 664
Joined: Tue Jun 19, 2018 9:54 pm

RE: Assigning Cargo Elements to a Mission

Post by Whicker »

my code above has an end statement in it for no reason so that was bad. I'll edit it.

If you have sams as cargo and the mission is a strike mission, the sams won't go anywhere unless you assign them as escorts so my actual code in the action is:

local u = ScenEdit_UnitX()
print("class: "..u.name)
if string.match(u.name, "SAM") then
ScenEdit_AssignUnitToMission (u.name, "LZ 1 Strike", true)
else
ScenEdit_AssignUnitToMission (u.name, "LZ 1 Strike")
end

Semi playable example - kind of funny - you are blue, red is about to invade:
Attachments
CargoCanKill.zip
(78.08 KiB) Downloaded 24 times
DWReese
Posts: 2294
Joined: Fri Mar 21, 2014 11:40 am
Location: Miami, Florida

RE: Assigning Cargo Elements to a Mission

Post by DWReese »

Thank you so much.

I'm going to try it out right now.

Doug
DWReese
Posts: 2294
Joined: Fri Mar 21, 2014 11:40 am
Location: Miami, Florida

RE: Assigning Cargo Elements to a Mission

Post by DWReese »

I am watching it play out right now. The landed units have just started shooting, so IT WORKS.

I have a couple of questions which I will mention now, so that I don't forget them later:

1.) One of the missions has a specific target, but the other two do not. In fact, the other two have no Reference Points listed either. So, how do they know where to go? They are heading inland, and have begun firing, so they are doing what they should, but how?

2.) Your code mentions "SAM", and there is a SAM unit in LZ1 and LZ3, but not one for LZ2. Yet, the code doesn't REALLY seem to care about the SA< inits anyway since all of the units are ultimately assigned to the various missions. I don't not much about Lua, so can you break down the code and explain it (like you are speaking to a novice) so that I understand these things? "Print"--we're not "printing" anything; "class"--; "..u.name"; "string.match"; etc. And, of course, "SAM"

Thanks, I'm heading back to the battle.

(BTW, you had two helos named #1, so I renamed one of them #5, since you were going to make a revision.)

Added Portion:

The battle worked fine, but at some point all of the ground units stopped moving or firing. It appears that all of the targets had been destroyed, other than the helo pad which was severely damaged. I believe that that has something to do with it. I'm not sure, however. The ship kept sending reinforcements, but they would never leave the area where they were dropped off. Thus, I never got to see any extraction or rescue.

After expending ALL their ordinance, the attacking forces either stopped moving, or continued moving toward nothing in particular. I'm not sure what was designed here.

The defenders were rarely got to identify any of the attackers, this the only damage to the attackers came from friendly fire.

Overall, this was a very informative scenario. It proves that it can be done.

Thanks again. I'd be really interested in hearing your answers.

Doug
Whicker
Posts: 664
Joined: Tue Jun 19, 2018 9:54 pm

RE: Assigning Cargo Elements to a Mission

Post by Whicker »

1) correct, 2 are on a generic strike mission with no targets selected so it is anything that is the enemy that they can attack. The 3rd one I made another strike mission, but set it to the air base minus the runways and stuff they couldn't really attack - otherwise they may waste all their ammo on the runway or something. Not 100% sure about that but seems possible. The ones that insert via helicopter are the ones attacking the air base. They only have ATG weapons, and not very many so they run out of ammo and then wander off.

2a) If you have manpads, they won't go anywhere if they get assigned to a land strike mission, so if you don't treat them differently they just land and then sit there. I think this is because they don't have land attack weapons, and the mission was land strike. I want them to move with the other units to protect them so I assigned them to the same mission but as escorts, and then they tag along and can help defend against air attack.

2b) code explanation:

local u = ScenEdit_UnitX() --get unit that activated the trigger and set it to the variable u. Then I can use 'u' to do various things like get its name - u.name. Might be able to do just UnitX.name but not sure. ScenEdit_UnitX() is a game function that gets the unit that activates the trigger. I have seen it used sometimes as just UnitX I think. Not sure though, and you probably should use the full function. If you had some random lua that was not part of an event - ie no trigger, I don't think ScenEdit_UnitX() would do anything - or would cause an error.

print("class: "..u.name) -- whoops. This is just to trouble shoot, not needed. At one point it wasn't working and I needed to check what it was doing. Without this you don't really see what it thinks u.name is. Originally I was checking if it was a SAM by checking its classname - so the print statement is prepending the u.name part with 'class' just so it is more clear that I was checking the class... then of course I changed it to u.name which totally defeats this and is now saying 'class: unit name' which is not right - but it is just for trouble shooting so it doesn't hurt anything. When you combine a string (always in quotes) with a variable you have to put two periods in-between so Lua understands what you are doing. Other languages use a plus sign I think. 'print' means to print the values to the log - which is usually available in the lua console, or is in the luahistory log if you want to use that.

if string.match(u.name, "SAM") then -- this is the only advanced part of the code, string.match is a Lua function that takes in 2 things - a string to look at, and a thing to check and see if it is inside the first thing. So basically in english it is - "does the unit name contain the sequence 'SAM' in it anywhere?" if it does, then the result is true, and the code will execute the next line. If it is false - the name does not include SAM then it goes to the else part below. Again strings are in quotes, so SAM is in quotes, u.name is not cause it is a variable. The unit name and the SAM part are separated by a comma and are inside parens cause string.match is a function and when you have a function it always has the arguments inside parenthesis - this function has 2 arguments - the string to check (unit name) and the thing to check for (SAM). Even if a function has no arguments, there are still open and close parens after the function name. Keep in mind string.match is checking to see if SAM is part of a unit name is probably not foolproof - not sure if it is case sensitive or not, probably not, so if there was a unit named 'George Sampson' or something like that (sorry not a great example) it would pass the check cause it contains the sequence SAM we checked for (assuming it is not case sensitive).

ScenEdit_AssignUnitToMission (u.name, "LZ 1 Strike", true) -- if the unit name has SAM in it, hopefully it is a SAM unit so assign it to the LZ 1 Strike mission, but as an escort. To set a unit to a mission as an escort you pass in 'true' as a 3rd argument to the ScenEdit_AssignUnitToMission function.

else -- if the unit name doesn't include SAM in it then do something else

ScenEdit_AssignUnitToMission (u.name, "LZ 1 Strike") -- assign the unit to the normal strike mission

end -- we have an if statement, you have to close it with end
Post Reply

Return to “Command: Modern Operations series”