Reset primary attack weapon

Post new mods and scenarios here.

Moderator: MOD_Command

Post Reply
DMAN
Posts: 98
Joined: Fri Jan 11, 2019 3:56 am

Reset primary attack weapon

Post by DMAN »

Hi all,

Is there a way to reset a platform's primary attack weapon?
I've added a mount to a submarine and want it to withdraw once the rounds are expended from that mount (specifically).

Also, no matter which weapon record I add to the magazine, the mount does not reload.
Is there a way to achieve this? (Avoiding LUA, preferably; if not, I'll have a look at it).

These units will be AI-controlled so I'd like to get it to work.

I've attached a save. See if you can have the Golfs reload their Strobile VLS. [:)]
Every P-800 Onyx magazine weapon record is there (I don't want to use Yakhont because it cannot strike land targets).

Cheers!
Attachments
Docking test.zip
(13.32 KiB) Downloaded 5 times
User avatar
michaelm75au
Posts: 11889
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Reset primary attack weapon

Post by michaelm75au »

I can see the issue. The SS-N-26 isn't the default weapon on the mount, and the weapon has a 'default' load of 0. Which means it wont reload.
Michael
User avatar
michaelm75au
Posts: 11889
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Reset primary attack weapon

Post by michaelm75au »

Worked around.
1. Remove all weapon records from the mount.
2. Add the SS-N-26 8/8 ROF 2 (with a value it is probably setting the default load value.)
3. Set current number to 0
4. Sub RTB due to lack of weapons.

Sub replenishes from port magazines and deploys.

Set the current count back to '0', and it withdraws again.

You can also use Lua to set the default load value for the SS-N-26 on the mount.
Michael
DMAN
Posts: 98
Joined: Fri Jan 11, 2019 3:56 am

RE: Reset primary attack weapon

Post by DMAN »

ORIGINAL: michaelm75au

Worked around.
1. Remove all weapon records from the mount.
2. Add the SS-N-26 8/8 ROF 2 (with a value it is probably setting the default load value.)
3. Set current number to 0
4. Sub RTB due to lack of weapons.

Sub replenishes from port magazines and deploys.

Set the current count back to '0', and it withdraws again.

You can also use Lua to set the default load value for the SS-N-26 on the mount.

Thanks, Michael.

After doing this workaround, can I then copy the unit and integrate it in my scenario for the AI?
User avatar
michaelm75au
Posts: 11889
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Reset primary attack weapon

Post by michaelm75au »

If you do the work around when you create the unit (ie add the mount, remove all weapons, and then add back the SS-N-26 as above), it should be be okay. It just needs the 'default' load set for the first time. I doubt it will change unless you try adding more weapons. Not sure what initially sets the 'default' but I assume it sets the default load when the mount is retrieved from database.
Michael
DMAN
Posts: 98
Joined: Fri Jan 11, 2019 3:56 am

RE: Reset primary attack weapon

Post by DMAN »

Hi Michael,

It seems the clones units don't RTB as desired. So the workaround for that is to mod each one as they are cloned using the method you developed.

It's ok. I have only 14 Golf II SSBs to do :)

Thanks for your help yet again!
DMAN
Posts: 98
Joined: Fri Jan 11, 2019 3:56 am

RE: Reset primary attack weapon

Post by DMAN »

If you'll run that test at 30 mins, you'll observe some odd behaviour exhibited by the units.

For instance, instead of approaching the west coast of Japan and then firing their missiles, the subs go around to the east coast to fire!

I also had one sub dead in the water with full diesel but no battery, which then recharged after I manually surfaced it.
(this just happened again to 2 more subs: bug maybe?)

Subs redeploying from the base are going to the north rather than out to sea.
(the unit eventually did deploy)

And now, you'll see the course of the submarine to the south. Do you know why it is doing that?
Attachments
Docking test.zip
(21.92 KiB) Downloaded 2 times
KnightHawk75
Posts: 1557
Joined: Thu Nov 15, 2018 7:24 pm

RE: Reset primary attack weapon

Post by KnightHawk75 »

For your monitoring a particular mount on a unit for a weapon count and wanting it to 'do something' when it hits zero..
See the embedded script in this version of your sample for ideas on how to do that.
At present it just checks every 1 minute and refills it when it and stop it from firing on land...when it sees it go under 7. but you can change that easy and of course whatever it is you really want in the GoDoSomeThingWithTheResults() function.

BTW on your other simple issue all I did was add munition mag to unit and some ss-n-26's to and it reloaded fine, though I see you were trying to get it do that from the dock vs. itself, wasn't clear in the first post.


"It's ok. I have only 14 Golf II SSBs to do :)"
---
Set one up the way you want first. shift-c 13 times after that should be fine.
Attachments
Docking test_kh1b.zip
(18.08 KiB) Downloaded 3 times
DMAN
Posts: 98
Joined: Fri Jan 11, 2019 3:56 am

RE: Reset primary attack weapon

Post by DMAN »

ORIGINAL: KnightHawk75

For your monitoring a particular mount on a unit for a weapon count and wanting it to 'do something' when it hits zero..
See the embedded script in this version of your sample for ideas on how to do that.
At present it just checks every 1 minute and refills it when it and stop it from firing on land...when it sees it go under 7. but you can change that easy and of course whatever it is you really want in the GoDoSomeThingWithTheResults() function.

BTW on your other simple issue all I did was add munition mag to unit and some ss-n-26's to and it reloaded fine, though I see you were trying to get it do that from the dock vs. itself, wasn't clear in the first post.

Hi Knighthawk,

Thanks for the advice!
It is working now.
I followed the previous advice, ran some tests, and it does what I want it to do.
I also added the submarines directly to the base so if there are no more land targets, they RTB and only deploy when new land contacts are detected within their strike range.

Did you write the LUA script specifically for this?
Thank-you! But I tell you what, that's WAY over my head. I'm flatout getting overlays to load!

Also, if it works when the scenario is built, great; if not, then it's ok. There will be plenty of other events for the human player to concern themselves with [:)]

"It's ok. I have only 14 Golf II SSBs to do :)"
---
Set one up the way you want first. shift-c 13 times after that should be fine.

Yes, I tried that. My efforts resulted in the clone firing it's missiles then sitting there.
KnightHawk75
Posts: 1557
Joined: Thu Nov 15, 2018 7:24 pm

RE: Reset primary attack weapon

Post by KnightHawk75 »

The oddity your seeing with RTB (I was able to repo) is that copies for whatever reason don't seem to get their primary weapon updated to include the p-800, seems the editor and scripting trigger that but a copy\clone maybe does not for some reason? I noticed messages on the manual ones about weapon exhaustion but on the clones in same mission and base etc no such message when empty.

Definitely something to remember in future for my own stuff.
DMAN
Posts: 98
Joined: Fri Jan 11, 2019 3:56 am

RE: Reset primary attack weapon

Post by DMAN »

ORIGINAL: KnightHawk75

The oddity your seeing with RTB (I was able to repo) is that copies for whatever reason don't seem to get their primary weapon updated to include the p-800, seems the editor and scripting trigger that but a copy\clone maybe does not for some reason? I noticed messages on the manual ones about weapon exhaustion but on the clones in same mission and base etc no such message when empty.

Definitely something to remember in future for my own stuff.

Hopefully it's just this time, for me. I have performed hundreds of mods on the platforms in my scenario.

I can't go back now. [:)]

Perhaps a better way to do the Withdraw/Deploy settings would be to have each weapon on the platform, or all, or none, able to be set, rather than 'Primary Attack' and 'Primary Defence' only?
There are so many other more-detailed options, I don't see this as an impossible change.
KnightHawk75
Posts: 1557
Joined: Thu Nov 15, 2018 7:24 pm

RE: Reset primary attack weapon

Post by KnightHawk75 »

Hey michael if you still reading... looks like scripting doesn't trigger the primary weapon thing either in testing right now.

I run the following (txt file) which creates the units, adds the mount in question, removes all 3 weapons and then adds back the one desired. No weapon-state RTB exhaustion triggered like in an 'editor' manually touched unit using same data. Is there something that I could do in script that would trigger that getting updated?



Attachments
TestScript..nExhaust.txt
(1.97 KiB) Downloaded 1 time
KnightHawk75
Posts: 1557
Joined: Thu Nov 15, 2018 7:24 pm

RE: Reset primary attack weapon

Post by KnightHawk75 »

ORIGINAL: DMAN

Hopefully it's just this time, for me. I have performed hundreds of mods on the platforms in my scenario.

I can't go back now. [:)]

Perhaps a better way to do the Withdraw/Deploy settings would be to have each weapon on the platform, or all, or none, able to be set, rather than 'Primary Attack' and 'Primary Defence' only?
There are so many other more-detailed options, I don't see this as an impossible change.

Yeah it would be nice to define\set\query what are considered primary.

I'm gonna try the delta file route as well, see if that acts like the gui-editor or not, at least we'll know.;)
DMAN
Posts: 98
Joined: Fri Jan 11, 2019 3:56 am

RE: Reset primary attack weapon

Post by DMAN »

ORIGINAL: KnightHawk75

Yeah it would be nice to define\set\query what are considered primary.

I'm gonna try the delta file route as well, see if that acts like the gui-editor or not, at least we'll know.;)

I have used the delta template to make sensor and communications changes for my scenario, and I'll be using it for magazines, but that's the limit of my knowledge [:)]
KnightHawk75
Posts: 1557
Joined: Thu Nov 15, 2018 7:24 pm

RE: Reset primary attack weapon

Post by KnightHawk75 »

Update: Never mind it does work with scripting. I failed to notice you removed the nuke mount (noticed it in the delta) :--)) Big impact that on primary weapon selection I'm sure lol.

I updated script to take off the nukes and now they act just like the gui touched version rtbing after done firing automatically, was worried there for a minute (I do lots of mass setup via scripts).

Anyway if do ever need to recreate your 14, you can plop this in the console just change the '3' to '14' and it'll do it all for you (including the torpedo update in the mag).

Attachments
TestScript..nExhaust.txt
(2.2 KiB) Downloaded 4 times
DMAN
Posts: 98
Joined: Fri Jan 11, 2019 3:56 am

RE: Reset primary attack weapon

Post by DMAN »

Thanks, Knighthawk!

I don't know how you understand it, though.
Post Reply

Return to “Mods and Scenarios”