Jump to content
Sign in to follow this  
Sheddius

Scripting In An 8th seat

Recommended Posts

Hey all, first scripting post. I found a very nice vehicle for my squad to roll around in (ExA's RG-31 Nyala) however there is just one problem, we operate in groups of 8, but the MRAP only has space for 7 (driver and gunner included), so i've been working for the past few days on a temporary workaround using a few scripts to setpos a player switchmove'd into the sitting position animation between the driver and the gunner. Sounds simple enough? That's what I thought. Here are my questions:

-I'm using addaction on the target MRAP (named "car") to make it appear as though the option to get into the pseudo-seat i've scripted is just like getting into any other seat and not break the immersion too much, shown below:

[u]Car init:[/u]

this addAction ["Get in Extra Seat", "getinmrap.sqf"]

[u]getinmrap.sqf:[/u]

sheddius switchmove "AMOVPERCMSTPSNONWNONDNON_ACRGPKNLMSTPSNONWNONDNON_GETINLOW";
sleep .5;
sheddius attachto [car,[0,.5,-1.8]];
sheddius setdir 0;
sheddius switchmove "BASICSITTINGGUNNER";

(QUESTION 1 RESOLVED!)This works marvelously however, i'm unsure how to make the action apply for everyone who is near the vehicle (currently you can see i've only got it targeted towards a unit I named "sheddius" -not too narcissistic right?) instead of just the unit i named "sheddius" in the editor. Question 1 is: how do i do that??

Answer 1: Just add the action to the vehicle itself!

car init:
_carACT = this addAction ["Get in Extra Seat", "getinmrap.sqf"];

-On to the next one:

Currently the only method i've been able to use to control when the unit riding in the 8th seat exits the vehicle is by placing in a trigger which checks if there isn't a driver in the car and then runs my "getoutmrap.sqf" script:

[u]trigger condition:[/u]

({_x in car} count [driver car]) == 0

[u]trigger on act.:[/u]

hint "success"; nul = [sheddius] execvm "getoutmrap.sqf"

(the "hint "success"" bit was just to tell me it was working)

[u]getoutmrap.sqf[/u]

sleep 1;
detach sheddius; 
sheddius setdir (getdir car)-90;
sheddius switchmove "ACRGPKNLMSTPSNONWNONDNON_AMOVPERCMSTPSRASWRFLDNON_GETOUTLOW";
sheddius setpos [getpos sheddius select 0,(getpos car select 1)+3,getpos sheddius select 2];

So Question number 2 is: is there a better way of doing this? I've tried using addaction but it doesn't seem to allow me to select actions while in the sitting animation :/ I kind of like the way it is now, it sort of simulates the awkward position that 8th man is in stuck between the driver and the guy riding shotgun, unable to get out until someone else does first, but if there was a way that allowed that 8th man to get out whenever he wanted to, i would most definitely prefer it.

-On to the next next one:

In my "getoutmrap.sqf" script, i've got the unit "sheddius" being setdir'd to an angle facing away from the MRAP and setpos'd to a position just outside the driver front door. This was working just as I had anticipated until i repositioned the MRAP and tried again, i realized that those setdir and setpos instructions were not relative to the orientation of the vehicle and so this time i exited the vehicle facing it's rear. Question 3 is: How can i make it so that the unit always exits the MRAP at the same location relative to the MRAP itself? So, no matter how it's turned (bearing 0, bearing 45, bearing 79, bearing 210, etc), i'll always emerge next to the driver side door and facing away from it? This one has me stumped as i'm thinking it's going to involve some complex calculus...i hope not.

-On to the next next next one:

Using the setpos command to place the unit in the "8th" seat cause the unit to be invisible to other units from inside the vehicle, however if one were to stand outside and look through the windows you could indeed see the guy sitting in between the driver and shotgun-occupant. Question 4 is: anyway to fix this? Any alternatives besides setpos that would be more simple? This one is not that necessary as it is only a temporary workaround, i'm sure ExA will make a larger variant soon enough.

-On to the last one:

(KINDA RESOLVED)This one is probably the most important; Question 5 is: how can I make it so that this script would work with multiple MRAP's? Right now, i'd have to make a separate pair of scripts for each MRAP as the "getinmrap.sqf" and "getoutmrap.sqf" only work with the vehicle named "car." Possibly the most simple one, but the solving of this conundrum is essential before i'd even consider using it.

Answer 5 (kinda): use the target, caller and id of the action added to any vehicle to call up both the unit trying to get in the vehicle and the exact vehicle the unit is trying to get into, regardless of name!

[u]modified car init:[/u]
_carACT = this addAction ["Get in Extra Seat", "getinmrap.sqf"];

[u]modified getinmrap.sqf:[/u]
_car = _this select 0;
_caller = _this select 1;
_id = _this select 2;
_caller switchmove "AMOVPERCMSTPSNONWNONDNON_ACRGPKNLMSTPSNONWNONDNON_GETINLOW";
sleep .5;
_caller attachto [_car,[0,.5,-1.8]];
_caller setdir 0;
_caller switchmove "BASICSITTINGGUNNER";
_car removeAction _id;

With these modifications any unit can now approach the vehicle and use the action "Get in Extra Seat," however when the driver leaves and the "getoutmrap.sqf" is initiated, the "sheddius" unit teleports in at the side of the vehicle as i've yet to figure out how to make the "getoutmrap.sqf" manipulate the caller of another script (namely "getinmrap.sqf") and make him appear to exit the vehicle (Question number 6? hehe). As you can see I've only got the "getin" part down, not the "getout," as i'm still stumped with that.

Thanks very much guys for reading patiently through my giant wall of text, i've attempted to format my post so that my questions and comments stick out easily enough and hopefully save some time when answering as well. Also, please tell me if i'm missing something totally simple and all this can be accomplished with a single command i didn't find in the biki or something, that is usually how these little projects get resolved!

-Also, in an effort to facilitate helpful answers i've created a very simple demo mission of the vehicle, the 8th seat, and the scripts, it requires only the RG-31 addon itself to play (http://www.armaholic.com/page.php?id=18130) and the example mission which i've uploaded to rapidshare (http://rapidshare.com/files/3364797134/8thseattest.Desert_E.zip).

Thanks again!

Edited by Sheddius
First question resolved, fifth question half resolved

Share this post


Link to post
Share on other sites

For question one,I can try to help you the best I can.

if (!local player) exitWith {};

player switchmove "AMOVPERCMSTPSNONWNONDNON_ACRGPKNLMSTPSNONWNONDNON_GETINLOW";
sleep .5;
player attachto [car,[0,.5,-1.8]];
player setdir 0;
player switchmove "BASICSITTINGGUNNER";

Try that, that's the best I can do LOL. Honestly, you'd be better off maybe just letting the 8th person tag along with an ATV or Motorcycle, or another car. Sometimes you have to ask; is something so trivial worth the hassle? Unless ofcourse if arma scripting is your newfound hobby, then I guess it could be satisfying to accomplish this task.

You could also only make the action available only to a specific person. So only they see the action and can use the seat etc. This wouldn't be a bad idea if the maps only for yourself &/or personal friends to use.

Edited by Iceman77

Share this post


Link to post
Share on other sites

Hahaha! Yes, i've heard the same from a couple buddies on teamspeak: "who cares if there's only 7 seats??" I guess you're right about the scripting being a new hobby sort of thing, i'm very interested in seeing this problem solved. Thanks for the suggestion on question 1 however i beat you to the punch just a few hours before you posted, i just added the action to the vehicle itself! Super simple and now everyone, even bad guys wanting to ride in the 8th seat, can select the action.

Share this post


Link to post
Share on other sites

haha, yeah I was gonna suggest adding it to the vehicle. But seen in your post that you already had. How is the pseudo seat working for you?

Share this post


Link to post
Share on other sites

Works perfectly! The guy sitting in the 8th seat is protected from small arms and explosions's the same as any other occupant it seems, besides the problems that i've already listed, it seems like a pretty decent solution. Also, recently spoke to the addon creator himself, Stiltman, and he told me that he'll try his best to make newer versions that have the capacity for various numbers of occupants, including my 8-man version. Needless to say, i'm very excited.

Share this post


Link to post
Share on other sites

I'm still stuck on one thing guys, I don't know why an action added through addaction won't appear to the player that is in the sitting animation in the 8th seat. I think i can figure it out from there, i've made a new script, "getinoutmrap.sqf" and this one's a consolidation of the previous two allowing the _caller and _car variables to be used in both the getting in process and the getting out process.

[u]"getinoutmrap.sqf"[/u]

_car = _this select 0;
_caller = _this select 1;
_id == 1234567;
if ((_car getvariable "occupied") == 0) exitWith
{
_caller switchmove "AMOVPERCMSTPSNONWNONDNON_ACRGPKNLMSTPSNONWNONDNON_GETINLOW";
sleep .5;
_caller attachto [_car,[0,.5,-1.8]];
_caller setdir 0;
_caller switchmove "BASICSITTINGGUNNER";
_car removeAction _id;
_car setvariable ["occupied", 1, true];
_caller addaction ["Get Out", "getinoutmrap.sqf"];
};
if ((_car getvariable "occupied") == 1) exitWith
{
sleep 1;
detach _caller; 
_caller setdir (getdir car)-90;
_caller switchmove "ACRGPKNLMSTPSNONWNONDNON_AMOVPERCMSTPSRASWRFLDNON_GETOUTLOW";
_caller setpos [getpos _caller select 0,(getpos _car select 1)+3,getpos _caller select 2];
_car setvariable ["occupied", 0, true];
_carACT = _car addAction ["Get in Extra Seat", "getinoutmrap.sqf"];
_caller removeaction 1234567;
};

Any ideas?

Share this post


Link to post
Share on other sites

You could also only make the action available only to a specific person. So only they see the action and can use the seat etc. This wouldn't be a bad idea if the maps only for yourself &/or personal friends to use.

^

if (player == unitname) then { ... add the action to the vehicle here....}

or

veh addAction ["<t color='#A6C42'>[Get Out]</t>", "getout.sqf", [], 1, false, true, "", "(player == someGuy)"];

Edited by Iceman77

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  

×