View Full Version : AttachTo and you -AC130 Gunship Simulation and More!
I just came across this relatively rad little gem to show you guys:
Using the AttachTo command it is possible to have static guns (ie. M119, TOW Launcher) firing from a flying C130 at ground targets. Very cool
Notes:
-With skill set to max and positioned where they have clear aim, most static weapons will engage the targets while flying while at a relatively high altitude (700~m), with the m119 gun performing this task best (followed by the TOW launcher, M2 machine gun at lower altitudes). Thusly, the main issue of the system for me thus far is I can't remember how to keep an aircraft flying at this sort of altitude while circling an area
-So far I've only got it working with the guns on top of the plane; looks naff up close, but you can't see it when it's circling above
-Improper placement will cause fratricide for the plane and anyone on it
-I can't see how to change the rotation/bearing of the gun beyond straight on; I originally came up with this trying to put a marksman in a heli, but realised he couldn't turn around to face outside
How to do it:
Really simple, far less than you'd expect:
1. Create plane, name it
2. Create gun, in init field:
this attachTo [planes name, [offset array -xyz, fiddle with this]]
I also group together the plane and the gun and set the guns skill to max.
And that's it! Anyone that would feel like developing this further would probably do a better job than I, and this could really help with developing an AC130 addon (just cut out some holes in the c130 body, mod the static guns so you can limit their 'swng', and then incorporate these commands into the addon)
I'm toying with an idea that seems like someone has done already (it's almost too easy), if so then good job all round!
Test mission (call in the plane using Higher Command):
http://www.sendspace.com/file/jvsd7d
Put the following into the init field of the C130:
this flyInHeight 700
Thanks for the tip about the attachTo command. Sounds like we can have a lot of fun with it. :)
Put the following into the init field of the C130:
this flyInHeight 700
Thanks for the tip about the attachTo command. Sounds like we can have a lot of fun with it. :)
Gave it a shot, didn't work :confused:
Edit: I'm an idiot, got it working!
It might take a while to reach that altitude. You could always setPos it there first. Try this:
this setPos [(position this) select 0, (position this) select 1, 700]; this flyInHeight 700
Got it working, put in player instead of this, oops.
This could also be used for other cool stuff, like putting SPG-9's in the back of civvie trucks, perfect for those guerilla ops.
All I wish is we could set the rotation too.
Commando84
Jun 2 2009, 21:02
man this sounds frakkin awesome!!! :D
Even with limited rotation I think people might find this useful :)
Interesting extra:
If you put a mortar in the back of a truck, the GL Artillery module still works for player targetting; still yet to try with an AI artillery strike (since I still can't get them to work, haha), but if so then this could make mortars a helluva lot more useful.
This could also be used for other cool stuff, like putting SPG-9's in the back of civvie trucks, perfect for those guerilla ops.
Yeah, new the attach command is going to open up quite a few possibilities.
All I wish is we could set the rotation too.
You need to use the SetVectorUp and SetVectorDir commands once the object is attached.
You need to use the SetVectorUp and SetVectorDir commands once the object is attached.
Good thinking, but it doesn't seem to be working, hmm
It would also probably be a good idea to have the guns on the AC130 shoot laser-straight, regardless of distance, to ensure that we don't have any accuracy issues. It's really important.
It would also probably be a good idea to have the guns on the AC130 shoot laser-straight, regardless of distance, to ensure that we don't have any accuracy issues. It's really important.
The AI M119's seem to hit the mark every time once the plane's lined up to shoot during a turn, they're really good at it compared to what the player can do
Good thinking, but it doesn't seem to be working, hmm
The attach command has been in VBS2 for quite a while. In VBS you can use the SetVector commands on attached objects.
I don't have ArmaII atm so I cant say if the same can be said for that.
The attach command has been in VBS2 for quite a while. In VBS you can use the SetVector commands on attached objects.
I don't have ArmaII atm so I cant say if the same can be said for that.
It doesn't seem to change a thing, even if I put in values pulled from a command that gets the vector of another object :confused:
Also, I've found that Machineguns rarely work, only firing off one or two rounds and then that's it, could be due to the ranges involved?
Maddmatt
Jun 2 2009, 23:27
You can set the direction of the attached objects with the setdir command, but in this situation the direction is relative to the object it's attached to.
That's based on my own experimenting with it. Not sure how the setvectordir commands work in this situation.
AttachTo is a really amazing piece of code. The possibilities are almost endless - its what I used in the fastrope script I released earlier.
Not sure if you've seen this thread here: http://forums.bistudio.com/showthread.php?t=73387 where I've been trying to do something similar - allow attached units to shoot from the top of an APC.
So far I've got a script that allows a player to climb up on top of the vehicle. There's 4 positions ontop of the vehicle that can be used. From there you can shoot etc. If you use the command on a player you can change your arc of fire by bringing up the iron sites and then using the alt key to move your aim around. Its a bit limited but you can still get quite a nice field of fire. The only problem I've encountered so far is you cannot give an attached unit an action so there's no way yet I can get the player to disembark - may have to use displaysetEventhandler.
If i get it sorted I'm hoping that for instance once you are seated in a chopper you could move to the doors through an action and the attachTo command and fire out using the method described above.
@<hidden> - to get the weapons mounted inside the plane you will most likely have to change the mempoint you are using see: http://community.bistudio.com/wiki/attachTo_(VBS2). As one thing I've found is using attachTo when inside a vehicle attaches you to a different point than when used outside a vehicle even though the coordinates are the same.
Maddmatt
Jun 3 2009, 00:20
As one thing I've found is using attachTo when inside a vehicle attaches you to a different point than when used outside a vehicle even though the coordinates are the same.
I think it's best to force the unit out of any vehicle he is in before attaching him. Setpos is one way to do that.
Baron von Beer
Jun 3 2009, 00:27
problem with attaching infantry, seems they cannot reload, unless I'm missing something obvious. Assume due to animation change, thought that seems odd since they can kneel/go prone.
You can set the direction of the attached objects with the setdir command, but in this situation the direction is relative to the object it's attached to.
That's based on my own experimenting with it. Not sure how the setvectordir commands work in this situation.
Top notch! Setdir does it, SetVectorDir did nothing. Nice one!
The AI M119's seem to hit the mark every time once the plane's lined up to shoot during a turn, they're really good at it compared to what the player can do
There's a difference here. I'm imagining that we want to control the guns like we did in "Death From Above" in Call of Duty 4, and that's with a TV view with all of the guns properly sighted in on the crosshairs regardless of range. It should allow us to target under player control, not AI control.
The goal with an AC130 mod is to make these slots usable: Pilot, and TV Operator/Gunner. If you just use AI controlled gunnery, it kind of loses its magic for some of the folks involved. Besides, the guns on the AC130 is NOT the M119. Don't forget that the AC-130 also comes equipped with a 40mm L60 Bofors (their impacts are similar to 203 HE impacts, but with significantly more damage), which is originally by design an anti-aircraft gun but can be applied to other purposes such as its role on the Spooky.
I think it would be best if we opted to use the AC-130H Pave Spectre II armament, rather than the Spooky. That's strictly only one Bofors and one 105mm, so we don't have to worry about calibrating the Vulcan that would normally appear on the AC-130U. (Besides, it's plausible since the Marines tend to get hand-me-downs from the Army and the Air Force!)
Here's an outline for you modders if you're serious about tackling the AC-130H:
Recommended Fabrication Requirements:
Occupancy Slots - Minimum, 3 (Pilot, TV operator/gunner, Navigator or Loader)
Armaments - L60 40mm BOFORS, M102 Howitzer
Functions - Ability to utilize FLIR (or spoofed FLIR), laser-straight accuracy with L60 and 105mm M102. Laser Designator for support, as well, especially useful in sensitive, delicate operations deep in enemy territory.
Ability to use Flares in an "angel wing" arrangement is a bonus.
The reason I chose the AC-130H as the suggested platform for this discussion is to simplify the vehicle to just two primary weapons, so that experimentation, fine-tuning, and improvements to the vehicle's code/scripting will not be as difficult. In a nutshell, it's easier to start with a simpler configuration, and when it's working flawlessly, upgrade it! :D
This sounds like a fantastic piece of code! A question to those who have used it, would it be possible to use this to, maybe, attach a vehicle to the deck of an LCAC?
There's a difference here. I'm imagining that we want to control the guns like we did in "Death From Above" in Call of Duty 4, and that's with a TV view with all of the guns properly sighted in on the crosshairs regardless of range. It should allow us to target under player control, not AI control.
The goal with an AC130 mod is to make these slots usable: Pilot, and TV Operator/Gunner. If you just use AI controlled gunnery, it kind of loses its magic for some of the folks involved. Besides, the guns on the AC130 is NOT the M119. Don't forget that the AC-130 also comes equipped with a 40mm L60 Bofors (their impacts are similar to 203 HE impacts, but with significantly more damage), which is originally by design an anti-aircraft gun but can be applied to other purposes such as its role on the Spooky.
I think it would be best if we opted to use the AC-130H Pave Spectre II armament, rather than the Spooky. That's strictly only one Bofors and one 105mm, so we don't have to worry about calibrating the Vulcan that would normally appear on the AC-130U. (Besides, it's plausible since the Marines tend to get hand-me-downs from the Army and the Air Force!)
Here's an outline for you modders if you're serious about tackling the AC-130H:
Recommended Fabrication Requirements:
Occupancy Slots - Minimum, 3 (Pilot, TV operator/gunner, Navigator or Loader)
Armaments - L60 40mm BOFORS, M102 Howitzer
Functions - Ability to utilize FLIR (or spoofed FLIR), laser-straight accuracy with L60 and 105mm M102. Laser Designator for support, as well, especially useful in sensitive, delicate operations deep in enemy territory.
Ability to use Flares in an "angel wing" arrangement is a bonus.
The reason I chose the AC-130H as the suggested platform for this discussion is to simplify the vehicle to just two primary weapons, so that experimentation, fine-tuning, and improvements to the vehicle's code/scripting will not be as difficult. In a nutshell, it's easier to start with a simpler configuration, and when it's working flawlessly, upgrade it! :D
The first obstacle to overcome in that case would be making it so the aiming point would stay fixed on a given area, so you could actually hit something; There's a very big margin for error when you try to gun it yourself, especially due to how much the plane's velocity effects where the shell will land.
You appear to have overthought this a lot more than I anticipated; This is me simply throwing together whatever I could get my hands on to get a 'pretty much there' solution
The first obstacle to overcome in that case would be making it so the aiming point would stay fixed on a given area, so you could actually hit something; There's a very big margin for error when you try to gun it yourself, especially due to how much the plane's velocity effects where the shell will land.
You appear to have overthought this a lot more than I anticipated; This is me simply throwing together whatever I could get my hands on to get a 'pretty much there' solution
You're talking to someone who's studying game development. This isn't overthinking, this is actually underthinking in terms of game dev work. :P
Edit: Yeah, you should look at Mando Missiles' system for the UAV. It actually looks functional and when you click the button, it locks onto wherever you were looking at, or a given target if it's near the crosshairs. That's auto-lockon, which would be useful for dealing with larger targets.
Hi.
I tried your manipulation and when I write
this attachTo [my planes name, [offset array -xyz, fiddle with this (or player)]] the game says me that I missed a ]
Do you know what's the problem ? Thanks.
Here's a test mission, in which I also attached a UAV to the bottom of the C130 so you can use FLIR
(Updated)
http://www.sendspace.com/file/jvsd7d
Thank you, I downloaded it.
Edit : Haha, it's awesome. Hope to see an AC-130 addon like in CoD 4.
The_Captain
Jun 3 2009, 17:28
If you use deleteCollection on the gun, it'll turn invisible on the client the code is executed on, but will still be able to fire normally. It will have physics collisions/damage, but will not be able to be harmed by enemy fire. This will make the simulation look less wonky.
You can use the getPitchBank and setPitchBank functions that are included with arma2 on the guns to get them to point in the direction you want.
Have fun...
I just came up with an design document solution for the AC-130H Pave Spectre II while in discussion with Zipper5 on IRC. To make the AC-130 a feasible product, you need three things:
1. A properly modeled AC-130, without the guns!
2. The guns, modeled as a single weapon object.
3. New ammunition types.
Breaking it down
Creating the AC-130 Model
You need to model it after the AC-130H Pave Spectre II, not the AC-130J Spooky. This means only two gun portholes, one for the 40mm Bofors, and one for the 105mm m102. You would also want to be mindful about the collision mesh - make sure you have a large collision mesh hole where the guns will be mounted in order to prevent any potential problems from cropping up.
ALTERNATIVE SOLUTION for AC-130: Use the C-130J that's already ingame, simply retexture it so that the gun portholes are textured onto the side.
Creating the Guns
You need to model the guns accurately after the 40mm L60 Bofors, and the 105mm M102, and position them in the mesh so that they will "snap" into the AC-130 model that has been fabricated beforehand. They will be attached to the AC-130 using the AttachTo scripting command.
ALTERNATIVE SOLUTION: Make the guns have no collision mesh whatsoever, and use the AttachTo command to position them properly where the textured gun portholes are on the C-130J retexture.
Making the Ammunition
You would need to create new ammunition for these guns, and they would have to be of a variety of types, as well as have a specific ballistic property that arbitrarily ignores the conventional trajectory deviation that is commonly applied to ballistics. (In other words, it has to be capable of staying laser-straight when fired.)
Ammunition Types for the L60: HE, Flechette, Incendiary, Illumination
Ammunition Types for the M102: HE, HEAT, Illumination, Incendiary, APFSDS?
The Implementation
To put this together properly, you'd be able to take advantage of the attachTo scripting command, to ensure that the guns are properly positioned, as well as vectored. This is very important that the aircraft model is properly prepared so that it does not collide with the gun model. Make sure the 40mm and the M102 howitzer are part of the same gun model, not separate, so that when they are moved around by the gunner, it moves in unison. The rest, I leave to you, Modders! This is your official game design document!
-NK
Edit: I've added an alternative solution to the first two steps of the game design document. I strongly recommend looking into that, since it is a MUCH less time-intensive procedure.
If you use deleteCollection on the gun, it'll turn invisible on the client the code is executed on, but will still be able to fire normally. It will have physics collisions/damage, but will not be able to be harmed by enemy fire. This will make the simulation look less wonky.
You can use the getPitchBank and setPitchBank functions that are included with arma2 on the guns to get them to point in the direction you want.
Have fun...
Good idea, but when the plane banks, the guns overpitch, and any AI gunners hop out and the gun isn't fireable
Updated my example mission, plane's fitted with deleteCollection'ed gun and TOW launcher; just call it in to the mission area using the higher command interface and watch it blow stuff up :yay:
http://www.sendspace.com/file/jvsd7d
Good idea, but when the plane banks, the guns overpitch, and any AI gunners hop out and the gun isn't fireable
Updated my example mission, plane's fitted with deleteCollection'ed gun and TOW launcher; just call it in to the mission area using the higher command interface and watch it blow stuff up :yay:
http://www.sendspace.com/file/jvsd7d
Gentlemen, the perfect AC130 is born. Thank you so much for this, it's pretty much perfect :yay:
EDIT: Note: It fires much more frequently and successfully when it orbits a little further away
Gentlemen, the perfect AC130 is born.
Needs a way to target infantry first :p Right now all it'll do is shoot cars/boats/armor, and trying to fit a machinegun yields no results. Perhaps making one of the heli miniguns into a static turret?
Needs a way to target infantry first :p Right now all it'll do is shoot cars/boats/armor, and trying to fit a machinegun yields no results. Perhaps making one of the heli miniguns into a static turret?
Are unit engagement ranges hardcoded? Maybe trying an M2 at first with an edited spotting and firing range would do the trick?
Are unit engagement ranges hardcoded? Maybe trying an M2 at first with an edited spotting and firing range would do the trick?
Must be, either that or just having trouble aiming within the limited field/range allowed, works fine when put in a heli
Maddmatt
Jun 3 2009, 23:22
It will probably have trouble engaging infantry because the AI has a hard time seeing them from that range? Might need to config a new static weapon where the AI has better spotting ability, to simulate the optics that they would have on the AC-130.
It will probably have trouble engaging infantry because the AI has a hard time seeing them from that range? Might need to config a new static weapon where the AI has better spotting ability, to simulate the optics that they would have on the AC-130.
Having come back to this, I tried grouping the plane up with a guy on the ground; It worked great and the AC130 started firing at the infantry on the ground with its guns.. MG still no luck, though. Even tried attaching a tank to the thing and it didn't work.
Need a script to pass on the revealed units from one unit to another; I remember using one in OFP at one point; They just can't see the men from that high up
Fantastic work gents!!!!!
The angels on our shoulders......
http://www.armedforces-int.com/images/projects/15/ac-130-deploying-flares.jpg
The smoke actually looks like an angel too lmao!
:D
Extremeus Decimus
Jun 6 2009, 02:00
Not sure if anybody has permission to try this, maybe someone could get in contact with the talented script Mando and ask if he's got any plans to port it to ArmA II, he's already made a gun suite to go alongside his missile suite, it had definable weapons, I've unoffically tested it (without permission and thus will never be released), and it seemed to work ok!, the guns engaged the infantry (kind of, its not really them firing per sey but it gives the intended effect)
Binkowski
Jun 6 2009, 02:10
Hehe, I'm sure Mandoble will import his scripts including the missle suite in ArmA2. We may have ourselves the AC130U Spectres gentlemen!
peteweir
Nov 27 2009, 17:37
Hey guys, new here :P
Just wondering, has any body else, besides me, had a problem with the sharp turns the ac130 AI makes? it jolts the gun view up and makes me lose sight of the target.
I love the whole ac130 gunship mod but i would love it if someone could make a script/command that made the ac130 turn at a given radius, smoothly around one point (the enemy).
I've been trying to find some script for ages now for the ac130 but also for the UAV.
Any help would be much apreciated
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.