Home   Help Search Login Register  

Author Topic: Tracking a weapons position  (Read 1563 times)

0 Members and 1 Guest are viewing this topic.

Offline Nephris

  • Members
  • *
Tracking a weapons position
« on: 03 Jan 2010, 19:41:00 »
Hi guys,
i am at the beginning of planing a MP misison, that shall run as pvp on a dedicated server.
The general idea is to track an item/weapon that sends a "beacon/gps signal" in kind of a marker on the map.
Both teams can take that item and each team has to bring it to their homebase.
This is actually the idea of CTF.

But right now i want to get that item tracked via gps signal.
I thought i should use an ACE backback, what is the only one on the map, to be able to give that backpack a global variable or name.
So - i guess - i should be able to hang a marker on the backbacks changing position each 180sec.

Is it possible to give a weapon a variable for being able tracking it?
If yes, how to do this?

My tracking marker script would be executed on each client and there are more than enough out there, so this wont be the problem i hope.




HNY btw.

Edit:
As Deadfast told me it is not possible to reference to weapons, this took the wind off my sails.
So i guess i ve to look for another solution.
The problem at least for me are the complex steps a workaround will have.

So the basic idea instead would be :
-A suitcase (instead backback) gets an gps signal (marker).
-The player, that takes the suitcase via actionscript will get the suitcases'signal instead.
-If the player dies the suitcase will be set to players location and send again a signal and gets an actionmenu entry again, so that other players will fins and take it again.


In OFP singelplayer it would be perhabs possible for me to solve it almost alone,but ....
SQF and dedicated server stuff blow my small acknowledges to moon in this case.
Is there anywhere a similar map/script like that i could use or is it easier than i fear.
Ill post my first snippet idea here after work, would be great if u could support me at this point.

EditEdit
here the scripts i ve done so far.

init.sqf
Code: [Select]
/////////////////////////////////////////////
/////   Koffer AddAction   /////
/////////////////////////////////////////////


  _actionID = 0;

  if ! (IsDedicated)then
  {

_actionID = Koffer addAction ["take case", "take.sqf"];

  };


take.sqf
Code: [Select]
 

_caller = _this select 1;                   // is player taking koffer
  _id = _this select 2;
 if !(player == _caller)exitwith{};


 while {alive _caller} do {
 
 Koffer setpos getpos place;                  //place is dummy location for koffer
 "mkr" setmarkerpos getpos _caller;
  sleep 1;

 
 // Koffer removeaction _id;
  //Deletevehicle Koffer;
 //hint"Debug: Koffer klar ";
 
  };
 
  if (!(alive _caller)) then {                            //Koffer shall return to position where the caller died
   Koffer setpos getpos _caller;
   "mkr" setmarkerpos getpos Koffer;
   
   };

I wasnt able to test the last 4 lines ingame.
I am sure there will be a few points to be optimized for mp gaming.
I am in doubt of my last 4 lines to work properly.

Any comments plz?!
« Last Edit: 04 Jan 2010, 13:25:01 by Nephris »

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Tracking a weapons position
« Reply #1 on: 04 Jan 2010, 19:37:31 »
I wanted to be able to declare a weapon within a variable not long ago so I can setObjectTexture it. Turns out you cant actually get a variable to refer to the weapon exactly. A shame, however there is a solution to your method.

What you would do is simply do a check on all the players on the map that can pickup the backpack and see if it is within there weapon array. Since its not possible for it to be anywhere but one place you shouldn't have any problems. You can make a marker follow that person rather than the backpack and follow it that way maybe.

If this is a CTF mission I assume the player has to pickup the backpack before the other team and take it to their drop-off point? Should still be possible where you could then put the backpack in an ammo crate. Using the same method above, see if the backpack is within the weapon cargo of the crate; thus scoring a point if it is there. You would then have to remove the backpack from the weapon cargo and add it to where it should originally start again.
Of course, You don't have to drop it off in the ammo crate you could simply run into a marker. Since you know the player with the backpack you just have to wait for them to be within a certain distance of the drop off point and it can be removed and sent back as I said.

 Does they sound like possible solutions for you?
« Last Edit: 04 Jan 2010, 19:40:55 by JasonO »

Offline Nephris

  • Members
  • *
Re: Tracking a weapons position
« Reply #2 on: 04 Jan 2010, 21:19:15 »
Kind of...
CTF is just the basic idea.The real "story" is a downed helo with sensible documents (i now use a suitcase as i cant track weapon throughout).
We got 2 Teams that will try to get the suitcase as fast as possible.The suitcase will be placed on random locations each misison start, and has a gps signal (marker), that will also blink on if one team found the case and try to move it to the extraction point.

As i said above, i now use a a suitcase and addaction.
The case has a addaction command.As soon as someone takes it ,the suitcase gets moved to a dummy place and its gps marker will be transfered to the caller of the suitcase`actionscript.
As soon the caller (the one who took the suitcase)gets shot the suitcase will be transfered again to the death position of the caller and the marker moved back to the suitcase, so other teams can fin and take it again.

So far so good, and my scripts are working...in coop (wasnt able testing dedi)

apart the init.sqs
Code: [Select]
/////   Koffer AddAction   /////
/////////////////////////////////////////////


  _actionID = 0;

  if ! (IsDedicated)then
  {



_actionID = Koffer addAction ["take case", "take.sqf"];

  };
      

Code: [Select]
take.sqf

  _caller = _this select 1;
  _id = _this select 2;
 if !(player == _caller)exitwith{};


 while {alive _caller} do {
 
 Koffer setpos getpos place;
 "mkr" setmarkerpos getpos _caller;
  sleep 1;

 //hint"Debug: Koffer klar ";
 
  };
 
  if (!(alive _caller)) then {
   Koffer setpos getpos _caller;
   "mkr" setmarkerpos getpos Koffer;
   
   };

Up to that point is it working.

But i would also like to add the feature to be able to detach the suitcase again , e.g. to set up a trap.
Therefore i ve to set another addaction , but to the player.
And here i start stucking.
My tests werent really successful.

This is my try:

same init.sqf as above

take.sqf


Code: [Select]
  _caller = _this select 1;
  _id = _this select 2;
 
 ID = _caller addAction ["detach case", "detach.sqf"];
 if !(player == _caller)exitwith{};

if ( (!isServer) && (detach) ) then
{
 
 while {alive _caller} do {
 //if (detach) then {exit} else {
 Koffer setpos getpos place;
 "mkr" setmarkerpos getpos _caller;


 
  sleep 1;
 

 
  // Koffer removeaction _id;
  //Deletevehicle Koffer;
 //hint"Debug: Koffer klar ";
 
 
 
  if (!(alive _caller)) then {
   Koffer setpos getpos _caller;
   "mkr" setmarkerpos getpos Koffer;
   
   
   
    };
 };
 

};
};

detach.sqf

Code: [Select]
  _caller2 = _this select 1;
  _id = _this select 2;
 
 //if !(player == _caller2)exitwith{};
 
   detach = true;
   
  _caller2 removeaction _id;
 
  Koffer setpos getpos _caller2;
   "mkr" setmarkerpos getpos Koffer;
   
    if (true)exitwith{};

The problem is that the suitcase is tranfered to its dummyplace, when calling the addaction,but when i use detach action, the suitcase remains at its dummy position and each "sleep 1" an detach order is added to my actionmenu.

(detach is set false in init.sqf)
So i hope i was able to provide the basic idea where my problem is atm.
I am not able to get the suitcase detached and picked up again, as described above...
Furthermore i guess my scripts need a bit optimization.

Offline Zonekiller

  • Members
  • *
    • Zonekiller Page
Re: Tracking a weapons position
« Reply #3 on: 07 Jan 2010, 13:49:22 »
this works for me as i use the suitcase to store weapons in my mission.
3 scripts tho


[player] execVM "case.sqf";

case.sqf
Code: [Select]




_player = _this select 0;
_string = format["%1",_player];

_a = 1;
_id = 0;
_case = objnull;


while {_a > 0} do
{

while {alive _player} do
{
sleep 1;
waituntil {((nearestObject [_player, "Suitcase"] distance _player < 1.5) or (_player != vehicle _player) or !(alive _player))};

if ((_player != vehicle _player) && (nearestObject [_player, "Suitcase"] distance _player < 15))  then
{
detach _case;
//_case = nearestObject [_player, "Suitcase"];
sleep 2;
_case attachTo [vehicle _player,[0,-1.2,-.6]];
waituntil {((_player == vehicle _player) or !(alive _player))};
if ((_player == vehicle _player) or !(alive _player)) then
{
detach _case;
_case attachTo [vehicle _player,[.25,.03,.6]];
_case setdir 270;
//_case setpos [(getpos _case select 0),(getpos _case select 1),0];
};
};


if ((alive _player) && (_player == vehicle _player) && (nearestObject [_player, "Suitcase"] distance _player < 1.5)) then
{
hint "Select Use Case";
_case = nearestObject [_player, "Suitcase"];
_id = _player addaction ["Use Case","Case\hideguns.sqf",_case];
waituntil {_case distance _player > 2.5};
_player removeaction _id;
sleep 2;
};
};

while {!(alive _player)} do
{
sleep .5;
_player = call compile format ["%1", _string];
};

};

HideGuns.sqf

Code: [Select]

_player = _this select 0;
_id = _this select 2;
_case = _this select 3;

_player removeaction _id;
_initCode = "";

_player playmove "AinvPknlMstpSlayWrflDnon_medic";


_PriWeapon = primaryweapon _player;
_SecWeapon = secondaryweapon _player;

if (_PriWeapon != "") then
{
_initCode = _initCode + format["%1",_player];
_initCode = _initCode + " addweapon ";
_initCode = _initCode + str(_PriWeapon);
_initCode = _initCode + ";";
_player removeweapon _PriWeapon; 
};

if (_SecWeapon != "") then
{
_initCode = _initCode + format["%1",_player];
_initCode = _initCode + " addweapon ";
_initCode = _initCode + str(_SecWeapon);
_initCode = _initCode + ";";
_player removeweapon _SecWeapon;
};

if ((_PriWeapon != "") or (_SecWeapon != "")) then
{
_case setVehicleInit _initCode;
};

sleep 10;

_player addaction ["Drop Case","Case\showguns.sqf",_case,0,false];

_case attachTo [vehicle _player,[.25,.03,.6]];
_case setdir 270;

ShowGuns.sqf
Code: [Select]
_player = _this select 0;
_id = _this select 2;
_case = _this select 3;

_player removeaction _id;

//Titletext[format ["%1 %2", _player, _case], "Plain" , 2];

_player playmove "AinvPknlMstpSlayWrflDnon_medic";
processInitCommands;
detach _case;
_pos = position _player;
_hgt = _pos select 2;
_case setpos [(getpos _case select 0),(getpos _case select 1),_hgt];

im not sure if you will find anything useful in this but you may
ZoneKiller