Forum Jump :

Author Message


Posts: 1
Rank:


Level: Member

Country: no
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2014-10-15 21:17        
     
Hi! Im trying to make it impossible to drop an AI inside walls but i cant seem to make it work :-(
The goal is to use "nearestObject" to see the distance from the hostage to the nearest wall. If the hostage is closer than example: "1 meter". You cannot drop the hostage.
I've tried googling for abour 3 hours now and still can't make it work :'(
here is my script: "undrag.sqf
private ["_dragee","_unit","_nearest"];
_dragee	= _this select 3; 
allowDropPlayer = true;
_unit = hostage1;

_nearest = getPos hostage1 nearestObject "house";  

if (((hostage1 distance _nearest) < 3)) then
{
hint "distance 10";
allowDropPlayer = false;

} else {

hint "You are too far away or your engine is running";

};


if (allowDropPlayer) then {
	detach _unit;
	_unit setVariable["Escorting",false,true];
	if(!(_unit getVariable "Escorting")) exitWith {removeAllActions player;}; //He's not being Escorted.
};

You guys have any suggestions?
Thanks!


Author Message


Posts: 250
Rank:


Level: Member

Country: ca
Location:
Occupation:
Age:
In-game name: austinXmedic

 
#2 Posted at 2014-10-16 01:16        
     
In theory I believe nearestObjects returns the nearest object to you as the first element inside the array it should give you after searching.

Either way that probably wont be best as if theres 2 walls nearby then you can drop them in the wall farther away still.

Get something that functions first then go for something bigger.

private ["_dragee","_unit","_nearest"];
_dragee	= _this select 3; 
allowDropPlayer = true;
_unit = hostage1;

_nearobjects = nearestObjects [getpos Hostage1,["House","Building"],10];
_nearest = _nearobjects select 0;

if (((hostage1 distance _nearest) < 3)) then
{
hint "distance 10";
allowDropPlayer = false;

} else {

hint "You are too far away or your engine is running";

};


if (allowDropPlayer) then {
	detach _unit;
	_unit setVariable["Escorting",false,true];
	if(!(_unit getVariable "Escorting")) exitWith {removeAllActions player;}; //He's not being Escorted.
};

Some of my work:
http://steamcommunity.com/sharedfiles/filedetails/?id=287343671 -- Unit Play/ Unit Capture Functions Guide
http://steamcommunity.com/sharedfiles/filedetails/?id=265454265 -- Zeus Guide
add me on steam: austin_medic