Jump to content
Sign in to follow this  
galzohar

Set turret direction to point up?

Recommended Posts

Basically I want to have grad launchers to appear as if they're firing on some distant target. The problem is I couldn't find any way to actually make them aim and fire in a certain direction (prefer to not over-complicated by using the artillery module). Making them fire was easy though. I don't actually have to have them turn to that direction as they shouldn't be turning around during the actual mission, just need to set them pointing at that direction. Also I need to be sure that nothing makes the vehicle drive around nor turn to point at *anything* else so that every time I order it to fire it will shoot at the same direction.

Any idea how to get it done? Is there an easy command I'm missing? Which kinds of disableAI should I use?

Share this post


Link to post
Share on other sites

Would putting an object such as an invisible H or other object REALLY high up, then getting your unit to target it work you think? Just throwing ideas around :)

Share this post


Link to post
Share on other sites

Tried that already, but it didn't work and according to the wiki it shouldn't work on objects anyway.

Share this post


Link to post
Share on other sites

Damn, how about something small like a chicken then 'enableSimulation false' it. Im not even sure if it works on AI but hey ho :)

Another way could be if you get the turretUnit you could then get that unit to lookAt the chicken.

Share this post


Link to post
Share on other sites

using an invisible H and making it target it ( name the invisable h and target that name) works flawlessly, you must setposATL or setposASL the H to make it above ground/sea height but it does work, i had a mission with it working perfect, i will try to recreate it and post the folder here for you in a few minutes.

ah i found the post where i got that working, here is a link

http://forums.bistudio.com/showthread.php?t=90464

Edited by H3NRY

Share this post


Link to post
Share on other sites

I'll give it a try again with setPosASL instead of setPos, but I'm not even sure grad launchers actually know how to target stuff directly?

Share this post


Link to post
Share on other sites

they do, try to set yoru self and a grad on the airfield, you in command.. tell them to target you then to fire :) ( i believe 2 2 would be to target you then 33 to fire, after selecting them of course )

i did have it working and sometimes i would start the mission and it would fire but then it wouldnt keep the target, was odd. but after using thatscript mentioned on that page i ignored it and just went with the script cause it had no adverse effects, hopefully it will be the same for you

Share this post


Link to post
Share on other sites

He seems to target it, but it's not reliable. I'll tell him to target in a loop (as well as before the loop) with some sleep in between each command, and it'll still fire at least 1 round straight before targeting the target no matter how much sleep I put in there. Another funny thing is that he would NEVER aim at the target until an enemy is in front of him, and even then he will still start with a forward shot and only then aim up at the target object.

Using doFire instead of grad1 fire (weapons this select 0) will make it simply not fire at all. Trying to give the commands to the gunner instead of the vehicle don't do any good either - it still won't target and won't fire (and as we know from earlier it wouldn't target anyway until it fired at least 1 shot first).

Share this post


Link to post
Share on other sites

In the other thread we used the lookat command no target or dotarget. Did you try using that yet? The do -commands all have reliability issues. Dofire only works if the target is an enemy config'd object that the AI would want to fire at and is in realistic range per the games configs, it wont work on non enemy/target objects or far away valid targets, sucks. Run the lookat command on the vehicle gunner if its crew vehicle.

Which unit/vehicle is grad launcher exactly? I dont have the game running right now so I dont know which side/unit we are talking about. Some weapons wont aim straight at a target like the Mk19 tries to aim at the ground spot when its told to target instead of a straight "rifle" style aim. If the gunner has the lookat command used he should line up the barrel to his line of sight.

fire command should not go early like that. The sleep should work. Post up your code/method and we can check that. If the unit receives a fire command before its ready to fire it will screw up. The barrel will aim straight up as a result of getting to many fire commands before its loaded its next round.

In my methods I use lookat and use a ~3 or sleep 3 in .sqf and it works every time, this is with M119 and Mk19 though. No reason it shouldnt work elsewhere but I havent tested. I have to wait 8 seconds between shots to avoid the "straight up shot" thing incidentally.

Share this post


Link to post
Share on other sites

lookAt seems to work great (as long as the target isn't too far away), thanks! doTarget is definitely messed up, and so is doFire (but grad1 fire (weapons grad1 select 0) works fine as it did before).

Now I need to find a way to not make the rockets explode after flying a certain distance, which I'm assuming should be possible since the BM-21 grads (either insurgent or russian) should be useable with the artillery module which sends rockets much further away than the distance at which they were exploding when I tested it.

The rockets explode early even when I fire them manually, so it must have something to do with the magazine... Any idea if there are alternative magazines I can use?

I replaced the magazine with an artillery module magazine (ARTY_40Rnd_120mmHE_BM21 instead of the default one) and it flies further without exploding (explosion is no longer within visible distance) but I still hear it exploding after it flies for a while, so it's still not good enough. Also if the arty ammo does happen to hit something, it doesn't do any damage at all.

Edited by galzohar

Share this post


Link to post
Share on other sites

Its possible the rockets are exploding when they are hitting your "aiming" object? If you use invisi-H im not sure if its a "hard" object or not. You could delete the object immediately after the fire command is given to test.

I used a game logic in my tests which has no collision but I also used "TargetEpopup" and deletecollection command to create a quick and dirty invisi-target object that seems to have no collision as well. Also the popup target can use dofire since it has the proper config value but that is neither here nor there.

So the round should go sailing through its aiming object on its way and wont explode untill hits the ground. Im pretty sure the round is colliding with your target. Let me know if this is it.

Share this post


Link to post
Share on other sites

They explode even when fired manually in random directions, so it has nothing to do with the object.

I flew up in the sky with a helo to see if the arty module magazines actually explode, but no explosion is seen - only a sound is played. The standard magazine has a visible explosion as well though. Again both happen also when firing the thing myself at no specific target.

Share this post


Link to post
Share on other sites

Does the weapon use target like laser object? You might need the weapon to target an object first and then try manual method (fire command not mouse click). Sorry I dont have any experience with this weapon. The arty M119 rounds wont explode untill they land. I have "pulled" missles and lgb out of aircraft with lasertarget object (basically making the unit fire on the target as if it were an enemy) but even if they were manual fire they still would only blow up on contact with ground. This may be a specific config to this weapon then? Ill try and test it out next time Im in the editor and post back if I find anything.

EDIT:

Also, you may have to resort to actually deleting the round. Grabbing the round involves the use of nearestobjects (range) then checking the list for the object type to match the round object. Then you can do what you want with it. Not sure if that matches your idea but it is a possible direction and useful technique in general.

EDIT2:

Check OFPEC Arma2 Weapons in the OFPEC Comref section (or BIS Wiki as well ofcourse) for all available Magazines/Rounds for the weapon type. I only see one Mag called 40Rnd_Grad though. I fear this is a weird issue that may prove a bit daunting to pin down but oh the satisfaction when you get the working solution, my friend.....

Edited by TJ72

Share this post


Link to post
Share on other sites

The worst thing is that after some more testing, it seems to ignore the lookAt on occasion and fire at random stuff (usually the player which is hostile to it). I tried all kinds of combinations of lookAt - currently I actually do this:

while {alive _gnr && _gnr == gunner _grad} do
{
if (!(alive _gnr && _gnr == gunner _grad)) exitWith {};
_grad lookAt targetH;
sleep 3;
if (!(alive _gnr && _gnr == gunner _grad)) exitWith {};
_grad lookAt targetH;
sleep 0.5;
if (!(alive _gnr && _gnr == gunner _grad)) exitWith {};
_grad lookAt targetH;
sleep .1;
if (!(alive _gnr && _gnr == gunner _grad)) exitWith {};
_grad lookAt targetH;
_grad fire (weapons _grad select 0);
sleep 5;
};

And it will still occasionally fire more than 1 round at me without looking up even for a fraction of a second between the rounds. I could not figure out what makes it decide whether to do what the script says or to do what it feels like.

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
Sign in to follow this  

×