Jump to content
Sign in to follow this  
xawery

Safe knowsabout level when in vehicle

Recommended Posts

Hi all,

I'm trying to achieve the following in my mission, and I was hoping you experienced types could help me make it come true tounge2.gif

I'm making a trapped-behind-enemy-lines type of mission. The player is a downed pilot desperately trying to reach an extraction zone. The island is crawling with soldiers and civilian life (thanks to the awesome DAC!wink_o.gif. What I want to do is give the player the opportunity to hide in the back of civilian vehicles. In other words, I don't want the enemy to engage the player if he's inside a vehicle (for simplicity's sake), unless he comes in close proximity of an enemy soldier. I imagine this will involve manipulating the knowsabout value.

My first approach was as follows: create a trigger that sets the player (s1) captive if he's in a car and his knowsabout value relative to enemy e1 is below a high number, say 3.5 (off the top of my head). That way, unless the player passed right under the enemy's nose, he would not be engaged.

Naturally, this didn't work otherwise I wouldn't be writing this post smile_o.gif Even if it did, I wouldn't be able to use it on all the enemies on the map. Well then, oh knowledgeable types! Any suggestions? smile_o.gif

Share this post


Link to post
Share on other sites

you might want to approach this from a different angle......

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["getin", {(_this select 2) setCaptive true;(_this select 0) setCaptive true}];

this addEventHandler ["getout", {(_this select 2) setCaptive false}]

put this in the init line of a vehicle to test,

I'd see this as a foundation to a larger script.

http://community.bistudio.com/wiki/addEventHandler

Share this post


Link to post
Share on other sites

Hey Squ33z3,

thanks for the tip! I hadn't even considered event handlers. Would it be possible to apply an event handler to an entire class of vehicles, e.g. cars? The problem is that all the vehicles in the mission are spawned using DAC, so I don't really have the opportunity to add an event handler per vehicle...

Regards,

X.

Share this post


Link to post
Share on other sites

Ah yes, I was considering isKindOf already. If I understand this correctly, I should be able to attach this eventhandler to all vehicles of the "car" class by adding something like this to the init.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (vehicle player isKindOf "Car") then {(vehicle player) addEventHandler ["getin", {(_this select 2) setCaptive true;(_this select 0) setCaptive true}]; (vehicle player) addEventHandler ["getout", {(_this select 2) setCaptive false}]}

Now, I'm pretty damn sure that's not proper syntax  whistle.gif You've already helped me a great deal sq33z3; my gratitude would reach new heights if only you'd tell me how to add this to the init properly  biggrin_o.gif

Share this post


Link to post
Share on other sites

open DAC\Scripts\DAC_Group_Vehicle.sqf

under the comments...

//-----------------------------

//#endcreate

//-----------------------------

add

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if ((_vehc isKindOf "Car")and((side driver _vehc) == civilian))then

{

_vehc addEventHandler ["getin", {(_this select 2) setCaptive true;_vehc setCaptive true}];

_vehc addEventHandler ["getout", {(_this select 2) setCaptive false}];

};

I put the ((side driver _vehc) == civilian)) in so only civ vehicles can be used to hide in.

Also I ran a test and noticed that you can just shoot the driver and steal a car to fool the enemy so it would still need more added to it.

it might be better to start a script with the EventHandlers so to get better results.

Share this post


Link to post
Share on other sites

Thanks a lot sq33z3, I'm beginning to understand how this would work smile_o.gif I also noticed the problem with the player killing the driver. Wouldn't it be possible to solve this by adding (player != driver _veh) to the initial conditions?

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  

×