Lua that will eliminate ability to attack

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

Post Reply
DWReese
Posts: 2547
Joined: Fri Mar 21, 2014 11:40 am
Location: Miami, Florida

Lua that will eliminate ability to attack

Post by DWReese »

Hi all,

I am creating a scenario that involves a Lua script, and I need your help.

Similar to the Special Action used in the Salvo scenario (my favorite), I would like to create a situation whereby the game player has a choice of using (paying) Victory Points to negate a unit from being able to fire. This is slightly different than the Communication Disruption that is used in Salvo.

I can figure out how to set it up to make it happen using the Special Actions in Salvo as a guide, but I don't know if it is possible to completely neuter (if you will) a unit from being able to fire at all. The unit in question, a SA-20, would obviously be on the map, but (if possible) the Lua script would restrict it from firing at all.

So, is it possible? If so, can someone give me an idea as to what the Lua script would look like that restricts it from firing? The side being restricted is the Iranian side. The side using the points, not that it matters for this, is the Israeli side.

Thanks in advance.

Doug
mikmykWS
Posts: 7185
Joined: Tue Mar 22, 2005 4:34 pm

RE: Lua that will eliminate ability to attack

Post by mikmykWS »

You could remove the weapons from the mounts or mags. Take a look at the lua here and just set them to 0. tm.asp?m=4291663
User avatar
Gunner98
Posts: 5978
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Lua that will eliminate ability to attack

Post by Gunner98 »

You could switch the unit to another side which has restricted doctrine settings or you could set the doctrine WRA or set it to weapons hold.

I'm not able to get to the game at the moment but either of these should work.

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/
Dan109
Posts: 175
Joined: Thu Apr 27, 2017 1:04 pm

RE: Lua that will eliminate ability to attack

Post by Dan109 »

That's a very interesting concept, I assume to make the scenario have a variable difficulty, to increase replay-ability and let all players enjoy a victory at easier levels and replay again at a harder level.

So, you want the Israeli human player to have an unfireable Sa-20 in his opposing side, and give the player bonus VPs in that situation. Gunner98's suggestion I think is the most realistic for exactly what you want to do. Heh, and maybe deduct points if the human destroys this unit as well while in this state (depends on the politics you want to simulate). But this still makes it harder for the human (compared to sa-29 not being there) if the sa-20 is unfireable because it's got a pretty darn good radar.

I might suggest another method, of having the player experience different difficulty...teleport or create the unit into position if the player accepts the VP bonus. This can of course apply to the human player too, examples of letting the human try the scenario with/without tanker or AEW support, bonus fighters, etc.

I love your idea, it will certainly increase replay ability and let all skill levels enjoy!

P.s., I haven't played salvo yet, but if Salvo is like this, kudos guys!!!
DWReese
Posts: 2547
Joined: Fri Mar 21, 2014 11:40 am
Location: Miami, Florida

RE: Lua that will eliminate ability to attack

Post by DWReese »

Dan,

My scenario is extremely quick and small battle, lasting no more than two hours. The Israeli attack on various Iranian nuclear locations is what has been planned. The Israeli player will face a real gauntlet of threats, many of which have been randomized.

With the SA-20 being sold to Iran, it is quite likely that these could show up anywhere. Right now, I use a random method for teleporting the unit in. Some replays result in the Israeli player having a somewhat easy day of it, while others are almost impossible.

I fell in love with the new Special Action idea presented in Salvo. It involves an expenditure of Victory Points to stop something from happening. I have expounded on that idea. Rather than being a Communication Disruption, it will result in the neutering of the SA-20. The problem for the Israeli is that he must make a decision as the game begins, and he could pay these points, even if the randomization of the unit results in the unit not being teleported in. So, it's a gamble.

With the SA-20, the Israeli player will lose anywhere from 3-9 SEAD A/C. Pretty much anything over 6, without damaging or destroying almost everything will result in a loss. So, the likelihood of the SA-20 being there is great, but not definite. The likelihood of it destroying a significant portion of the Israeli planes is great, if it is there.

Every game is different. Every game is random. But, all are based on a realistic expectation of what to expect. This is primarily a situation where the Israeli must weigh out his quantities of ARMs and employ them judiciously.

The scenario is fun.

I believe that reducing the number of assigned ordinance to zero is probably the best way to do this. If someone could show me an example (scenario) where a Lua script reduces the number of ordinance available, then I will use that concept.

Thanks for the response.

Doug
Dan109
Posts: 175
Joined: Thu Apr 27, 2017 1:04 pm

RE: Lua that will eliminate ability to attack

Post by Dan109 »

You can reload with LUA but you can't deload nor remove a mount/weapon with LUA....currently.
DWReese
Posts: 2547
Joined: Fri Mar 21, 2014 11:40 am
Location: Miami, Florida

RE: Lua that will eliminate ability to attack

Post by DWReese »

Dan,

Okay, maybe here's another possibility.

If I can't "unload" the unit's ordinance from the weapon, can the unit simply be DELETED from the map? If so, that would keep the unit from firing because it no longer existed. Or, is that not possible, either?

Also, if it is possible, how will the game react if the Event Editor later attempts to teleport the unit from one location (on the other side of the world) to another (where the battle is), if it's no longer on the map because it was deleted? Would it work, or would it lock everything up?

Doug

Dan109
Posts: 175
Joined: Thu Apr 27, 2017 1:04 pm

RE: Lua that will eliminate ability to attack

Post by Dan109 »

Delete unit is definitely possible in LUA. If you delete it and then later try to teleport it, you just need to check for NIL prior to doing so. You can do that by checking the name to see if it equals NIL.
mikmykWS
Posts: 7185
Joined: Tue Mar 22, 2005 4:34 pm

RE: Lua that will eliminate ability to attack

Post by mikmykWS »

ORIGINAL: DWReese

Dan,

Okay, maybe here's another possibility.

If I can't "unload" the unit's ordinance from the weapon, can the unit simply be DELETED from the map? If so, that would keep the unit from firing because it no longer existed. Or, is that not possible, either?

Also, if it is possible, how will the game react if the Event Editor later attempts to teleport the unit from one location (on the other side of the world) to another (where the battle is), if it's no longer on the map because it was deleted? Would it work, or would it lock everything up?

Doug


Yeah you could delete it as well.

Generally when you write lua code you add a defensive piece that checks to see if the unit exists before doing stuff. You do this by checking for a nil value. You'll see this in a lot of my code but its also explained here under error handling.

https://commandlua.github.io/beta/index.html

Generally, if you forget this you get a popup error message telling you that the code couldn't find the unit you pointed at.

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

RE: Lua that will eliminate ability to attack

Post by DWReese »

Thanks for the info, Mike. I'll try it out.

Obviously, you deserve the credit as Salvo was the reason that I even thought of this in the first place. My scenario will have so many different options via randomness, that each time that you play it you will never really know what you "could" encounter.

Doug
mikmykWS
Posts: 7185
Joined: Tue Mar 22, 2005 4:34 pm

RE: Lua that will eliminate ability to attack

Post by mikmykWS »

Sounds cool Doug. Look forward to it!

Mike
Post Reply

Return to “Command: Modern Operations series”