csj 0 Posted May 2, 2005 Trying to write a script that runs from engine EH. Basic two or three liner to make the gunner in the vehicle face a direction say 90 degrees from the vehicles heading. I thought "dowatch" would be the way to go being silent command. My problem is the PC just does not understand the way I write scripts  Would be thankful if someone could help on this. Share this post Link to post Share on other sites
LizardX 0 Posted May 2, 2005 Sorry mate but as I know it's not possible only by tricks. How your unit moves in a vehicle is defined in an rtm-file as a proxyGunner animation. This way you have to bother with OfpAnim. Your movement will be an "all-time" one: not static but you cannot change it with a command (look at a BIS jeep driver: he well move his hands on the wheel like mad even if the vehicle stopped), he will turn/move/gesticulate continously. You can make more anims, one for looking straight ahead, one for looking to the sides, or combining both or more, but these random anims will work only for proxiCargo guys (well, I'm not sure). Or you can make a turredted vehicle in which the defined turret will be only the proxyGunner. He will turn on his seat with his whole body but this look weird a bit IMHO. Share this post Link to post Share on other sites
csj 0 Posted May 2, 2005 Thanx for reply LizardX I am talking about a turret gunner. Everything works fine etc., It is just when AI is in gunner posi they face fwd (which looks daggy), until they spot an enemy. So all I want to do is give a silent command to gunner when AI gets in saying to face vehicle dir -90. Share this post Link to post Share on other sites
colonel_klink 0 Posted May 3, 2005 Try this: There is a command that tells the ai to scan the horizon. This will cause the gunner to turn as if looking into the distance. This is normally activated in the engage section in game by selecting the unit and 3,7 IIRC. I'm not sure how this would be done by script, tho. Will investigate. Share this post Link to post Share on other sites
DanAK47 1 Posted May 3, 2005 I had trouble with my mortar soldiers constantly watching a particular direction when an unknown target was detected. Perhaps you could create an invisible unit that is unidentifiable and reveal it to the gunner, then use a simple script to constantly position that unit at a position 90 degrees to the side of the vehicle. Share this post Link to post Share on other sites
UNN 0 Posted May 3, 2005 Quote[/b] ]Basic two or three liner to make the gunner in the vehicle face a direction say 90 degrees from the vehicles heading. I dont think you can based on the fact that, once more than one unit has entered a vehicle, they all get grouped together as one. The only way I could get the AI to point the turret in a different direction to the hull, was get the driver to disembark, and give the commander a DoWatch order. I think Dan is on the right track, it's just can you create an addon that attracts just the gunners attention, wont make him fire, but only when there are no better targets on offer? I've been looking for a way to lock a turret using scripts, similar to the way a driver locks the turret when he turns out in a tank. That could be another work around? Share this post Link to post Share on other sites
Footmunch 0 Posted May 4, 2005 I think Dan is on the right track, it's just can you create an addon that attracts just the gunners attention, wont make him fire, but only when there are no better targets on offer? You could set the ammo to 0 for the first 10 seconds or so, I _think_ the AI gunner will still point the gun at the target, even when it's not loaded. If there's a better target on offer, then the gunner will re-point anyway, but it's probably a badly designed mission in that case... Share this post Link to post Share on other sites
UNN 0 Posted May 4, 2005 Quote[/b] ]If there's a better target on offer, then the gunner will re-pointanyway, but it's probably a badly designed mission in that case... Perhaps I misunderstood, I thought he wanted the MG to point in a particular direction when in safe or careless mode? It would be annoying if the AI prioritised this above real enemy units, plus there is the problem of your other AI reacting to the invisible target to. If you can set the target to be completely invisible unless revealed using the script command, then that would not be an issue. But again, ideally you would want to remove the dummy target once the unit goes into combat mode. So as not to interfere with the AI's targeting. My idea was to place an additional cargo slot in exactly the same place as the default gunners position. From the init event set it's combat mode to safe, and move the gunner to the dummy cargo slot fire position. So it looks like he is gunner, but the gun will never move. Assuming you can detect when the AI commander goes into combat mode, you can move him into the gunner’s position. I know there are issues with detecting combat mode, but AFAIK if you set it via a script command you can detect changes? Share this post Link to post Share on other sites
Footmunch 0 Posted May 4, 2005 In a helicopter p3d file, the gun has to be pointed directly forward so that the 'turret' works properly. But this means that at mission start the gunner points in that direction as well. I _think_ CSJ wanted to push the gunner and gun round 90 degrees to make it look a little bit better. Once the turn is acheived, you could deletevehicle the 'invisible' target and add ammo to the heli. You could even justify this as an initial 'gun-loading' time at the start of the mission. I think you can make the invisible target truly invisible to other units by reducing (or increasing, I can never remember ) the accuracy, and then only those units you explicitly call 'reveal' on can see it. In safe or careless (which you can get as a string with 'behaviour _gunner' I think) modes the gunner will usually not change direction at all, so the gun should point that way until he's told about a new, 'real' target. If he wants to contiuously re-point the gun to 90 degrees off beam when there's no target, that could be hard... The other possibility is to limit the 'turret traverse' in config - the initial direction is either north (with respect to the helicopter) or the minimum swing of the turret. But this does mean that you are limiting the arc of fire for the gunner. I know the CoC_UA does some 'pointing' of mortars and guns, so maybe ask those guys... Share this post Link to post Share on other sites
csj 0 Posted May 4, 2005 Footmunch is correct with the heli gunner turret, this problem is sooo Damn annoying. I have tried a sh!t load of different methods and can not get a reaction from gunner until, as UNN said, the driver disembarks vehicle. Thanks for help all Share this post Link to post Share on other sites
UNN 0 Posted May 4, 2005 Quote[/b] ]Footmunch is correct with the heli gunner turret, this problem is sooo Damn annoying. Did not realise that was the problem. But putting a regular Game Logic at 90 degrees to the heli and calling... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Heli DoTarget Gl1 ...seems to work where DoWatch won't, you can delete the game logic after a couple of seconds. Edit: Ahh..Game logics only work when it's on the ground. The best I could do was this for the UH60 mg: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Vehicle=_This Select 0 _Camera="Camera" CamCreate (GetPos _Vehicle) _Camera CamSetTarget _Vehicle _Target="TargetE" CamCreate [0,0,0] _T=_Time+16 #L _Camera CamSetRelPos [-15,2,0] _Camera CamCommit 0 _Target SetPos (GetPos _Camera) _Vehicle DoTarget _Target @True If (_T>_Time) Then {goto "L"} DeleteVehicle _Target CamDestroy _Camera You need to create your own class similar to TargetE, but with no geometry so it's invisible. It takes about 15 seconds to finaly point in the right direction, perhaps a better target type would speed things up? Share this post Link to post Share on other sites
csj 0 Posted May 5, 2005 Thanks UNN Getting much the same - the dotarget only seems to work when driver is out of vehicle and no luck at all with the script. I think I will have to manage this action thru OFP editor when making missions. Share this post Link to post Share on other sites
UNN 0 Posted May 5, 2005 Oh..I dunno, works ok witht the BIS UH60. Are the configs similar? I noticed the mg version of the UH has this in the config: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">enableSweep=0; What ever that does? Share this post Link to post Share on other sites
csj 0 Posted May 5, 2005 class UH60MG: UH60 enableSweep=0; same as model I am model I am testing with which is the Medevacs. My gunslingers and slicks have enableSweep=1; (true) and I have not noticed any difference between the flight models. Not sure what it means. Share this post Link to post Share on other sites
Footmunch 0 Posted May 5, 2005 Thanks UNNGetting much the same - the dotarget only seems to work when driver is out of vehicle and no luck at all with the script. I think I will have to manage this action thru OFP editor when making missions. Have you tried: (gunner _vehicle) doTarget _Target It probably won't make a difference, but you never know... Share this post Link to post Share on other sites
colonel_klink 0 Posted May 6, 2005 If you are trying to get the gunner/weapon in a helo to face at 90 degrees or so from the direction the helo is heading the Viewgunner initangleX or ViewOptics initAngleX might be what you need to look at. UH60 Code <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class UH60MG: UH60 { //-- displayName=$STR_DN_UH60_MG; nameSound="blackhawk"; accuracy=1000; model="uh-60mg"; transportSoldier = 12; enableSweep=false; gunnerAction = ManActUH60Gunner; gunnerOpticsModel = "optika_empty"; weapons[]={Browning}; magazines[]={Browning}; class Turret: TurretBase { minElev=-42; maxElev=+5; minTurn=30; maxTurn=150; soundServo[]={,db-40,1.0}; } class ViewGunner: ViewGunnerBase { initAngleY=+90; minAngleY=+30; maxAngleY=+150; initAngleX=0; minAngleX=-42; maxAngleX=+5; }; }; iirc the uh60 gunner proxy faces forward yet the proxy model sits sideways and is static. If you were to make a custom gunner that moves with the weapon (ie more realistic) you would have to make a custom anim that would normally face the direction of the weapon, and be turned to face the side by attaching the weapon gunner proxy to the weapon as part of the otocvez selection. Then use either the viewgunner or viewoptics  selection to make the gunner face outwards. I hope this is helpful. Share this post Link to post Share on other sites
csj 0 Posted May 8, 2005 My gunner view has always been attached to the octocvez selection. I could not have it any other way but the res lods and cargo view are as per norm. Maybe this is why I am having problems when trying to set starting view at a different angle, conflict between lods. Share this post Link to post Share on other sites