colonel_klink 0 Posted June 21, 2004 Scenario: Rescue boat toodles off to find a downed pilot marooned on an island. Simple enuff? Problem: Script to detect, from script in rescue boat addon, if the nearestvehicle/object/unit is derived from the man class. By using the following script <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _boat = _this select 0 _timer = 200 #loop ~0.001 _person = nearestObject getpos _boat ? ("man" counttype [_person] == 1 && _person distance _boat < 20) : goto "pickup" _timer = _timer-1 ?(_timer>0):goto "loop" exit #Pickup _person assignAsCargo  _Boat _person moveincargo _Boat _boat Sidechat "Passenger on board" exit it only works when the boat has gone on shore and is on top of the rescuee.   Not favourable enuff unfortunately. So any suggestions to detect the guy at a minimum radius from the rescue boat? Oh and I have tried to figure this cos/sin mathematics thingee based upon the direction of the boat and its x,y positions, but it doesn't seem to gel in my old rain very well. P.s. this is for the Police launch with the next fishing boat release. Share this post Link to post Share on other sites
MidShip 0 Posted June 21, 2004 Holds type "man" valid in water ? What's your navigational issue (bearing from _boat to _person ?) Share this post Link to post Share on other sites
Footmunch 0 Posted June 21, 2004 Nearest object only works out to 50 metres, but I can't remember if it's a box or a sphere. Does the marooned man 'request' pickup? If so, you can include him in the script, and just do a 'distance' between the boat and man, and wait for that to drop below 50 or so. Share this post Link to post Share on other sites
MidShip 0 Posted June 21, 2004 With the right man type, for instance "civilian" etc. it works. nearestObject[boat , "civilian"] (man within 50m constraint of course) Share this post Link to post Share on other sites
colonel_klink 0 Posted June 21, 2004 Quote[/b] ]With the right man type, for instance "civilian" etc. it works.nearestObject[boat , "civilian"] (man within 50m constraint of course) This part works no problem. However I dont want to write this code for every "man" type class. What I'm aiming to do is get the rescue boat to pick up any human unit based on the parent class .e.g. "man". Quote[/b] ]Does the marooned man 'request' pickup? If so, you caninclude him in the script, and just do a 'distance' between the boat and man, and wait for that to drop below 50 or so. No. He doesn't request pickup. That is entirely a different script. Share this post Link to post Share on other sites
korax 4 Posted June 23, 2004 Well i guess if you use nearestobject right at the same spot as the boat, it will always return the boat as being the closest, no?  Try checking in random positions AROUND the boat for any people.. like this <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_boat = _this select 0 _timer = 200 #loop ~0.001 _pos = [(getpos _boat select 0)+ 10 - random 20,(getpos _boat select 1)+10 - random 20,0] _person = nearestObject _pos ? ("man" counttype [_person] == 1 && _person distance _boat < 20) : goto "pickup" _timer = _timer-1 ?(_timer>0):goto "loop" exit #Pickup _person assignAsCargo  _Boat _person moveincargo _Boat _boat Sidechat "Passenger on board" exit Or if you want a Sin/Cos formula for finding people infront of the boat, or beside it, I can help you with that too. Share this post Link to post Share on other sites
colonel_klink 0 Posted June 23, 2004 Well i guess if you use nearestobject right at the same spot as the boat, it will always return the boat as being the closest, no?  Try checking in random positions AROUND the boat for any people.. like this<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_boat = _this select 0 _timer = 200 #loop ~0.001 _pos = [(getpos _boat select 0)+ 10 - random 20,(getpos _boat select 1)+10 - random 20,0] _person = nearestObject _pos ? ("man" counttype [_person] == 1 && _person distance _boat < 20) : goto "pickup" _timer = _timer-1 ?(_timer>0):goto "loop" exit #Pickup _person assignAsCargo  _Boat _person moveincargo _Boat _boat Sidechat "Passenger on board" exit Or if you want a Sin/Cos formula for finding people infront of the boat, or beside it, I can help you with that too. I'll try that thanks. y the way I would be interested in the sin cos functions to place objects on addons that have to move or change direction with the addon.. edit: It works! That got the guys a$$ off the island. Thanks once again, Korax. The police boat is another step closer to release Share this post Link to post Share on other sites