Jump to content

PortalGunner

Member
  • Content Count

    32
  • Joined

  • Last visited

  • Medals

Community Reputation

1 Neutral

About PortalGunner

  • Rank
    Private First Class

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thanks for the effort - I might look at doing that later but for now I'd rather not redesign the entire thing. I have put all the scripts into functions though so they precompile (updated OP).
  2. If you wanted to account for both turrets you could check for second seat using FullCrew and if it exists add a second AI inside turretDir.sqf .
  3. - I'm using CBA's Extended Event Handlers to load centerTurret.sqf onto anything with class Helicopter. - I don't want to look for an empty gunners seat because I want to still be able to use the action if an AI is in the seat (which is what the else in turretDir.sqf is for). FullCrew works well enough for this. - Would there be any significant advantage to launching it as a function? I'm aware it will precompile it but I'm not sure if it would really do much for the script - it would only get use a few times a session at most. - Also yes, he runs a regular listen server (not the best decision, I know) for his discord group. He hasn't the hardware for dedicated and I haven't managed to convince him to let a few of us pay for server hosting. EDIT: I set the target of the AI to objNull (in the 'else') rather than follow the same script because if I did, after lining it up they'd just go back to an 'untargeted' state anyway.
  4. Automatic code? Like centring the turret when nobody's in the gunner seat? Well TBH our server host doesn't have the best CPU so I would like to avoid as many loops as I can. Plus someone might have some obscure reason to keep it uncentered.
  5. Yep, for some reason those invisible characters were the cause of those errors. Works perfectly now. Unless you can think of any further optimisations I think that's all I can do. I will update OP with working script.
  6. Wow that is weird. I'll test it tomorrow.
  7. No inverted commas in my scripts u~u but knowing me its entirely possible it's some minuscule thing.
  8. I actually did change it to doTarget on the one I sent the error of (my only change) - it happens on both doTarget and doWatch If I comment out only the waitUntil, I get the same error. If I comment out everything related to _pencil (leaving the waitUntil alone) I get: And if I comment out everything related to _pencil as well as the waitUntil, there's no error. So it's somewhere in the lines of _pencil or waitUntil. Dunno if that helps.
  9. Seeing what I can do with this, but something is wrong: // [] execVM "turretDir.sqf"; allowCenterTurret = false; // disallow further instances of script _veh = vehicle player; // set current player's vehicle as script object if (_veh emptyPositions "gunner" > 0) then { // check if the gunner seat is empty _group = createGroup civilian; // if so create a temporary unit to fill slot _group deleteGroupWhenEmpty true; _unit = _group createUnit ["B_Soldier_F", position _veh, [], 50, "NONE"]; _unit setCaptive true; _unit allowDamage false; _unit hideObjectGlobal true; _unit setSpeaker "NoVoice"; _unit setName "Turret Control"; _unit assignAsGunner _veh; // move the temporary unit to gunner seat _unit moveInGunner _veh; _epsilon = 0.001; // minimum difference between vectors _vec = vehicle _unit; _pencil = "Land_PencilRed_F" createVehicle [0,0,0]; _pencil allowDamage false; _pencil hideObjectGlobal true; _pencil attachTo [_vec, [0,5,0]]; _unit doWatch _pencil; _sleeptime = time + 10; waitUntil { sleep 0.1; (time >= _sleeptime) || (((_vec weaponDirection (currentWeapon _vec)) vectorDistance (vectorDir _vec)) < _epsilon); }; deleteVehicle _unit; // remove temporary unit deleteVehicle _pencil; allowCenterTurret = true; // allow further instances of script } else { // if the gunner seat is NOT empty _unit = gunner _veh; // set current gunner (AI/player) as script object _unit doWatch objNull; // order unit to watch nothing (defaults to forward) allowCenterTurret = true; // allow further instances of script }; I'm getting an Invalid Number error after "_pencil = "Land_PencilRed_F" createVehicle [0,0,0];"
  10. Something like this I guess? // mission.malden\inq\turretDir.sqf 0 = _turretUnit spawn { _this doWatch (vectorDir (vehicle _this)); waitUntil { ([(vehicle _this) weaponDirection (currentWeapon (vehicle _this))] call INQ_fnc_computeSourceDir) == ([vectorDir (vehicle _this)] call INQ_fnc_computeEndDir); }; }; // mission.malden\functions\fn_computeSourceDir _SourceX = [_this select 0, 4] call BIS_fnc_cutDecimals; _SourceY = [_this select 1, 4] call BIS_fnc_cutDecimals; _SourceZ = [_this select 2, 4] call BIS_fnc_cutDecimals; [_SourceX, _SourceY, _SourceZ] // mission.malden\functions\fn_computeEndDir _EndX = [_this select 0, 4] call BIS_fnc_cutDecimals; _EndY = [_this select 1, 4] call BIS_fnc_cutDecimals; _EndZ = [_this select 2, 4] call BIS_fnc_cutDecimals; [_EndX, _EndY, _EndZ] I haven't tested it yet. Is there a better way to round out the decimals to 4 places?
  11. Working well! There isn't a way to detect when the AI is looking at the marker is there, rather than using sleep? CursorTarget/Object is player-only. Either way, thanks a lot for the help.
  12. It works as intended with these optimisations, thank you for them. Only improvement I can think of is to move the marker with the heli, because right now you have to keep its position still. Would it be better (performance and reliability) to attachTo a temporary invisible object in front of the heli, or to use a loop to update the marker position?
  13. Okay it's done guys! Thanks so much for the help! I had to change driver _veh == player out for another call // mission.malden\centerTurret.sqf _veh = _this select 0; _veh addAction ["Center Turret", "turretdir.sqf", nil, 3, false, false, "", "(allowCenterTurret) && (call checkForGunnerSeat) && (call checkInDriverSeat)"]; // mission.malden\init.sqf checkForGunnerSeat = compile preprocessFileLineNumbers "checkgunner.sqf"; checkInDriverSeat = compile preprocessFileLineNumbers "checkdriver.sqf"; allowCenterTurret = true; // mission.malden\checkdriver.sqf _is_player_driver = false; if (driver vehicle player == player) then { _is_player_driver = true; }; _is_player_driver; I think I might publicly release this script after some more testing because I couldn't find anything like it earlier. Updating OP to the working script.
  14. Another update - it now, inexplicably, (mostly) works, the day after. I changed allowCenterTurret to a global var after I found it working. // mission.malden\description.ext class Extended_InitPost_EventHandlers { class Helicopter { clientInit = "_this execVM 'centerTurret.sqf';"; }; }; // mission.malden\centerTurret.sqf _veh = _this select 0; _veh addAction ["Center Turret", "turretdir.sqf", nil, 3, false, false, "", "(allowCenterTurret) && (call checkForGunnerSeat)"]; The above works perfectly, but I still need to check if the player executing the addAction is the driver. Yet with me in the pilot's seat and: _veh addAction ["Center Turret", "turretdir.sqf", nil, 3, false, false, "", "(allowCenterTurret) && (call checkForGunnerSeat) && (driver _veh == player)"]; the action doesn't appear. Replacing _veh with vehicle player also doesn't work. Am I not seeing something?
×