Jump to content
Sign in to follow this  
sion

[QUESTION] CursorTarget Alternatives? Need for "Spotter - Range me script"

Recommended Posts

hi guys

hope someone can help me

i want to make a script, that makes a ai spotter in your group able to tell u (via chat) the range to the point wich you (as sniper) are actual looking at (e.g. with the scope of ur sniper rifle).

Until know i found that script:

_sniper = _this select 0;

_spotter = _this select 1;

_teamDistanceMax = 50;

_dis = 0;

while {alive _sniper && alive _spotter} do {

if (player == _sniper) then {

if (cameraview == "GUNNER") then {

if (_sniper distance _spotter < _teamDistanceMax) then {

if !(isnull leader cursortarget) then {

_disTemp = _sniper distance cursortarget;

_disRel = abs (_dis - _disTemp);

if (_disRel > 100) then {

_disText = (round (_disTemp / 100)) * 100;

if (_disText > 1000) then {_disText = -1};

_spotter sidechat format ["%1 M",_disText];

};

_dis = _disTemp;

};

};

};

};

sleep 1

};

This one is working "ok", but with "cursortarget" u only get ranges for objects (Houses, Units etc ....) But if u are pointing just somewhere else (grass, trees, plants etc) u dont get an value...

so i need an alternative to "cursortarget". I need something that works like the rangefinder wich gives u all ranges and not only those of objects.

anybody got an idea? aimpos or vectorDir doesnt work or i maybe used them wrong?

pls post every idea you might have :)

thanks

Share this post


Link to post
Share on other sites

I believe you're looking for screenToWorld:

_pos = screenToWorld [0.5,0.5];

_pos should then contain the coordinates of whatever is at the center of the screen (even if it is empty terrain). Give it a try. :)

Edited by MadDogX

Share this post


Link to post
Share on other sites

i love u THANKS :D

works much better just sometimes when aiming onto a building i get a value > 3000 but i guess its ok know :D

Share this post


Link to post
Share on other sites

There is one already in game - not used it yet but it looks interesting:

[player,nameAIunit] spawn BIS_fnc_spotter;

I think the AI spotter must already exist - if you click right mouse button on an enemy target he reports the distance.

Share this post


Link to post
Share on other sites
There is one already in game - not used it yet but it looks interesting:

[player,nameAIunit] spawn BIS_fnc_spotter;

I think the AI spotter must already exist - if you click right mouse button on an enemy target he reports the distance.

thx but i think the first one is better ;)

In the mission (coop) u can recruit units (e.g. u spawn as sniper and can recruit units to your group) thats why the spotter (ai) has no name and i guess this function wouldnt work :)

but now i have a new problem

the ranging itself is working quite well

but it is working all the time (u can ask for range without conditions)

dont know how to add a condition

i want that u only can ask for range if u are a sniper and a friendly spotter is near (40m or less) both alive of course :)

maybe someone could help me here?

thats the init yet:

JG_SPOTTING_PATH = "jg_spotter\";

//Classes that can Use spotting

jg_sniper_classes = tfor_sniper;

//spotters

jg_spotter_classes = tfor_spotter;

if(isDedicated) exitWith{};

if(not (typeOf player in jg_sniper_classes) && count jg_sniper_classes > 0) exitWith{};

jg_spotteraction = player addAction ["Range me",(JG_SPOTTING_PATH+"rangeme.sqs")];

player addEventHandler ["KILLED",{

[] spawn {

WaitUntil{alive player};

player removeAction jg_spotteraction;

jg_spotteraction = player addAction ["Range me",(JG_SPOTTING_PATH+"rangeme.sqs")];

};

}];

Share this post


Link to post
Share on other sites

_sptr = group player createUnit ["US_Soldier_Spotter_EP1", Position player, [], 0, "FORM"];
nul = [player,_sptr] spawn BIS_fnc_spotter;
(group player) setCombatMode "BLUE";

works with spawning too.

When using in and count you must refer to an array

jg_sniper_classes = [tfor_sniper,"US_Soldier_Spotter_EP1"];

Edited by Mattar_Tharkari

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  

×