Jump to content
cry me a river kids

How to launch a missile at a target with mk41 VLS via scripting

Recommended Posts

I'm currently using

g1 fireAtTarget [t1, currentWeapon g1]

. where g1 is the VLS and t1 is the target. The VLS will fire but the missile goes straight up without ever turning to fly towards the target. I want this event to occur with scripting only with no player interaction. I remember there being some way to get this to work where the missile would fly to the target but I have since forgotten. Any ideas? Thanks in advance

Share this post


Link to post
Share on other sites

Never mind guys, figured it out. For vehicles that launch missiles the missile will only fly towards the target if their seeker can acquire the target. The Venator missile used has a laser semi active homing system meaning you have to launch it at something being designated by a laser. I used a remote designator g3 to mark the target and used the script 

g1 fireAtTarget [laserTarget g3, currentWeapon g1];

Now i just need a script that can get the remote designator to mark a target on its own. thanks in advance for anyone who can help

Share this post


Link to post
Share on other sites

I don't think you need the laser, try this.

g1 is the VLS and t1 is the target.

 

 

west reportRemoteTarget [t1, 3000];
t1 confirmSensorTarget [west, true];
g1 fireAtTarget [t1, "weapon_vls_01"];

  • Thanks 2

Share this post


Link to post
Share on other sites

ok, i'm risking the wrath of raising dead-ish posts here but i'm trying this and it's not working. 

 

🙂

 

Quote

west reportRemoteTarget [t1, 3000];
t1 confirmSensorTarget [west, true];
g1 fireAtTarget [t1, "weapon_vls_01"];

 

gets me the following error; 

 

'call{west |#|reportRemoteTarget [t1,3000];

t1 co...'

Error Missing :

And, my understanding of java is just solid enough to copy stuff that works most of the time and is pretty limited in terms of trouble-shooting. 

 

anyone got any thoughts? 

 

  • Like 1

Share this post


Link to post
Share on other sites
12 hours ago, theopolus said:

ok, i'm risking the wrath of raising dead-ish posts here but i'm trying this and it's not working. 

 

🙂

west reportRemoteTarget [t1, 3000];
t1 confirmSensorTarget [west, true];
g1 fireAtTarget [t1, "weapon_vls_01"];

 

gets me the following error; 

 


'call{west |#|reportRemoteTarget [t1,3000];

t1 co...'

Error Missing :

And, my understanding of java is just solid enough to copy stuff that works most of the time and is pretty limited in terms of trouble-shooting. 

 

anyone got any thoughts? 

 

I do bud!

You have fallen victim to a well-known bug, which appeared whenever you copy-paste directly from the forum. To better understand this try to copy your snippet

(west reportRemoteTarget [t1, 3000];
t1 confirmSensorTarget [west, true];
g1 fireAtTarget [t1, "weapon_vls_01"];)

and open a replay window, then select CODE button and paste it. You'll see plenty of "red dots"; that's what is throwing errors. Try it out and let me know.👍

 

 

  • Like 2

Share this post


Link to post
Share on other sites

holy crip! that's both weird and fantastic! thanks for the help. 

 

When i copy straight from the forum as you mentioned the image below is what showed up in the "code" field when i pasted it in; 

 

https://ibb.co/jvRhYK0

 

Removed all the red dots, copied that and pasted it into my mission and all is good!

 

Thanks

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, theopolus said:

When i copy straight from the forum as you mentioned the image below is what showed up in the "code" field when i pasted it in; 

 

https://ibb.co/jvRhYK0

That's EXACTLY what I was talking about. Now you know..LOL...I learned the hard way myself, bud!

Glad to help ya.TK.

Share this post


Link to post
Share on other sites

I'm clearly doing something wrong. I saw this and thought I'll have some of that.

Placed VLS - named g1

Target - named T1

Set a trigger with player activation and on activation code - 

 

west reportRemoteTarget [T1,3000];
T1 confirmSensorTarget [west,true];
g1 fireAtTarget [T1,"weapon_vls_01"];

 

Double checked I didn't get caught with the bug by typing this directly in as above.

Trigger wont accept that script and reports  - On activation Type Bool expected Nothing  as error.

Tried just first two lines - no error reported. Error is from third line.

Used checkmuzzle g1 to double check muzzle name and it doesn't report any muzzle at all  - just returns empty string. (?)

For fireAtTarget the muzzle is optional so I took out "weapon_vls_01" and I still get same error and trigger wont accept code. Stumped.

Any suggestions? 

Share this post


Link to post
Share on other sites

 

4 hours ago, The Real Bunc said:

I'm clearly doing something wrong. I saw this and thought I'll have some of that.

Placed VLS - named g1

Target - named T1

Set a trigger with player activation and on activation code - 

 

west reportRemoteTarget [T1,3000];
T1 confirmSensorTarget [west,true];
g1 fireAtTarget [T1,"weapon_vls_01"];

 

Double checked I didn't get caught with the bug by typing this directly in as above.

Trigger wont accept that script and reports  - On activation Type Bool expected Nothing  as error.

Tried just first two lines - no error reported. Error is from third line.

Used checkmuzzle g1 to double check muzzle name and it doesn't report any muzzle at all  - just returns empty string. (?)

For fireAtTarget the muzzle is optional so I took out "weapon_vls_01" and I still get same error and trigger wont accept code. Stumped.

Any suggestions? 

 

my own test mission has this working. The condition on the trigger is set to Radio Alpha -  in my activation field i have; 

 

west reportRemoteTarget [t1, 3000];
t1 confirmSensorTarget [west, true];
g1 fireAtTarget [t1, "weapon_vls_01"];

i have an opfor unit (the target) named "t1" and i have a blufor MK41 VLS cruise missile turret manned with a blufor rifleman to act as gunner - the Mk41 is named "g1". 

 

when i select Radio Alpha, a missile launches, flies to target and destroys it. 

 

i don't know if any of that will help you but it at least confirms that it is working on my end. 

 

side matters - ie. if your target is opfor (east) then the above setup and code would work. if your target is blufor (west) you can put an opfor unit in the Mk41 turrent and you would have the change the side in the trigger code to be east - ie. 

 

east reportRemoteTarget [t1,3000];
t1 confirmSensorTarget [east,true];
g1 fireAtTarget [t1,"weapon_vls_01"];

that will allow the Mk41 to launch a cruise missile at a blufor target. 

 

Hope some of this helps to troubleshoot. 

  • Like 1

Share this post


Link to post
Share on other sites

Just tried again. Still getting exactly the same error report " On activation Type Bool expected Nothing "  when I try to put that code in the trigger on activation box. This is driving me nuts. If its working for you its clearly something really simple but not obvious. I know the first two lines of the code are fie because when i just run them and take control of the VLS it shows that the VLS has picked up the target t1.  I don't suppose you could post a link to a really simple mission setup with a vls, player, target and trigger where this is working for you?  I just can't see any difference between the code im posting for the third line and your third line yet the trigger just wont accept mine!

 

Ive just tried naming the VLS itself g1 - didnt work - and then tried naming the gunner unit g1 - also didn't work so I've ruled that difference out as being the cause.

Share this post


Link to post
Share on other sites
29 minutes ago, The Real Bunc said:

Just tried again. Still getting exactly the same error report " On activation Type Bool expected Nothing "  when I try to put that code in the trigger on activation box. This is driving me nuts.

If you look at my post above, You'll discover that you fell victim to the same bug..or perhaps you might have. If you've copied the code from YOUR post, it contains one of the red dots that prevent it to work. If you copy-paste the code from @theopolus post is "clean" and working. Tested.

 

Share this post


Link to post
Share on other sites

I really wish that was it but its not. The bug would impact the first two copied lines as well but it doesn't and they are accepted by the trigger without issue. Ive tried typing the code in fresh rather than doing a copy and it still doesn't work and I get exactly the same error report when I put that third line of code in the activation box.  It was the code from @thepolus that I copied and posted btw. Then I tried just straight typing it in. Its infuriating.  I realise you have it working but I'm at a complete loss now as to why I cant get the trigger to accept that third line of code. You couldn't post a simple mission setup could you as above? That may help me work out why its working for you and not for me. Pulling my hair out now in frustration.

  • Confused 1

Share this post


Link to post
Share on other sites

Bizarre. I can execute that third line of code in the debug code box when I pause the game and it runs without error and a missile is fired. But when I copy that very same line of code from that code execution box back into the trigger I get the same error report as before. So the code works fine when executed from the debug console but reports an error when the exact same code line is put in a trigger. Eh?

Share this post


Link to post
Share on other sites

Heya, i have today off so tinkering is fun. 

 

Example mission is below; 

 

Example | VLS via Trigger

 

Mission is vanilla, on stratis and is left unbinarized so you can tear it apart and use what you like. 

 

Btw, while I was testing it out i had the same initial error that you reported - Bool error. Then i realised that i had forgot to name the targets (ie. i hadn't gone in and named them "t1" and "t2" in the variable name field). Not sure if that was your issue but this example mission works flawlessly. 

 

Note: you will want your view distance up as the ships are about 2.5 km out. 

  • Like 2

Share this post


Link to post
Share on other sites

Many thanks @theopolus. Your mission as you said works fine. I cant at this point see any difference between the code in your triggers and mine. Going to try just to copy your code from the triggers now and put it into fresh triggers in a new mission and double check that works.  Many thanks for the help.

 

Ok I see a difference in the way yo are using the code. You have the code wrapped in a call block in your two radio triggers. Im assuming that is allowing the trigger to accept the third line of code which is throwing the error when i try to put it in as simply part of three lines of code to be called on activation. The call wrapper seems to prevent the error? I wonder why that is - any ideas?

  • Like 1

Share this post


Link to post
Share on other sites

Hope it works for you and glad to do it. Post back with your progress just so folks know what it might have been or just that it works reliably. 

 

Good luck. 

  • Like 1

Share this post


Link to post
Share on other sites

I can confirm that this is working in a trigger.

 

Quote

call{west reportRemoteTarget [t1, 3000]; 
t1 confirmSensorTarget [west, true]; 
g1 fireAtTarget [t1, "weapon_vls_01"];}

 

Share this post


Link to post
Share on other sites

Yes wrapping it in a call like that works. The bare code didn't. Weird and I'm not sure why. Anyway all good now. Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

saw that later, but for clarification, when you get an error like: Type Bool/string/number/anything else... expected Nothing  as error in on activation (or init) field of trigger/objects, that means you face to the known limitation (editor, not scripted sqf) kept by compatibility (I presume). In this case, your code needs to return... nothing.

east reportRemoteTarget [t1,3000];   // reporteRemoteTarget  returns nothing

t1 confirmSensorTarget [east,true];  // confirmSensorTarget  returns nothing

g1 fireAtTarget [t1,"weapon_vls_01"]; // fireAtTarget returns a boolean.

so, you just have to write:

0 = g1 fireAtTarget [t1,"weapon_vls_01"];  // or any variable name instead of 0.

 

  • Thanks 3

Share this post


Link to post
Share on other sites

That's really helpful Pierremgi. I had been thinking about it last night and started to realize that it was something to do with there being a return value when there probably shouldn't be. Your explanation is very helpful and much appreciated. I hadn't realised that this was an issue with how the trigger boxes handle code. Ive had problems like this occasionally before and it makes sense now. 

  • Like 1

Share this post


Link to post
Share on other sites

If you have CBA or (I think) 3den Enhanced loaded, they add the call wrapper automatically, which may be why the others had no problem. 

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, Harzach said:

If you have CBA or (I think) 3den Enhanced loaded, they add the call wrapper automatically, which may be why the others had no problem. 

 

I use 3den Enhanced, and it did not add the call  wrapper automatically. I wonder if there is a setting I haven't selected or something. 

Share this post


Link to post
Share on other sites
24 minutes ago, stburr91 said:

 

I use 3den Enhanced, and it did not add the call  wrapper automatically. I wonder if there is a setting I haven't selected or something. 

I might be wrong about 3E. CBA definitely does it,  though.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×