Jump to content
Sign in to follow this  
charliereddog

Determine where an object came from?

Recommended Posts

A mission I am building starts with the players being completely mapless.

There are a number of possible units/locations where a map may be procured. If it's from an enemy, I want to show the enemy camps as markers, while a friendly map would only have the US markers.

I'm fine for the code to actually show/hide the markers, but how would I go about determining where the map comes from? it needs to be non-unit specific, as the code which gives the map generates it randomly.

Share this post


Link to post
Share on other sites

When the map is obtained, you can compare the distance to those markers and see which one is nearest.

Share this post


Link to post
Share on other sites

I don't quite get, what you're really after, though I'm pretty sure the following two BIS functions (from the function library/module) will help you out:

  • BIS_fnc_dirTo
    Returns the compass direction from object/position 1 to object/position 2. Return is always >=0 <360.
    • Parameters: [object or position 1, object or position 2]
    • Example: [player, getpos dude] call BIS_fnc_dirTo

    [*]BIS_fnc_relPos

    Returns a position that is a specified distance and compass direction from the passed position or object.

    • Parameters: [object or position, distance, direction]
    • Example: [player, 5, 100] call BIS_fnc_relPos

With the first, you can determin a direction (say from the player to one of the enemies to get an idea `where` they are comming from). And with the latter you could position your enemy-camp marker, in a distance to your liking (maybe a little random like 800 + random 600), and at the direction you gathered from your enemy (which you could again randomize a little by adding/subtracting a little).

But then, I'm really not sure, what you're up to.

Share this post


Link to post
Share on other sites

Apologies, i think I may have used some bum words which have thrown you guys off the track of what I'm trying to achieve.

Players start with no map in the middle of a wood at night. All around them are enemy patrols, on foot and in vehicles. Around the wood are various enemy camps. The players have no idea where they are.

There's a 30% chance that an enemy leader may have a map on him. Should the players kill an enemy leader that has a map, when they search the body of course they'll have the option of taking that map.

There's also a couple of dead/wounded US aircrew in the area. Again, there's a chance that should the players stumble on them, they MAY have a map also.

This is what I need to do,

Player A shoots and kills enemy officer and takes map. He needs to see the enemy markers on his map. Therefore I need to know the source of the map.

Player B stumbles on a dead US body which has a map on it. He needs to see the friendly markers. Again, I need to differentiate where the map came from.

I know that this could end up being a complete pain the ass regarding players trying to switch maps etc, I'm not too concerned about that. Once a player has a map, regardless of what he then does with it, the only markers he will be able to see is the ones on the first map.

Hope that's slightly more clear.

Share this post


Link to post
Share on other sites

The the player picks the map item up on his own then there's no way to tell where he took it from. But it'd be just as easy to add a custom action to the possible places he can get it, in which case you can them determine which object he got it from (and this what markers to show).

Here are two examples. Depending on how many variations of the map you want and how many places to get them from, second one could be better.

1. Tell by object:

Add the action:

object addAction ["Take Map","takemap.sqf",[],3,false,true,"","_this distance _target <= 3"]

takemap.sqf:

_obj = _this select 0;
_player = _this select 1;

if(_player == player)then{
_player playMove "AinvPknlMstpSlayWrflDnon";
waitUntil{animationState _player == "AinvPknlMstpSlayWrflDnon" || !(alive _player)};
if(alive _player)then{
_player addWeapon "ItemMap";

// here's where you find out what markers to show
if(_obj == ObjA)then{<show markers for map from ObjA>};
if(_obj == ObjB)then{<show markers for map from ObjB>};
// etc...

_obj removeAction (_this select 2);
};
};

2. Pass a parameter:

Add the action:

object addAction ["Take Map","takemap.sqf",["EastMap"],3,false,true,"","_this distance _target <= 3"]

takemap.sqf:

_obj = _this select 0;
_player = _this select 1;

_mapType = _this select 3;

if(_player == player)then{
_player playMove "AinvPknlMstpSlayWrflDnon";
waitUntil{animationState _player == "AinvPknlMstpSlayWrflDnon" || !(alive _player)};
if(alive _player)then{
_player addWeapon "ItemMap";

// here's where you find out what markers to show
if(_mapType == "EastMap")then{<show markers for OPFOR map>};
if(_mapType == "WestMap")then{<show markers for BLUFOR map>};
// etc...

_obj removeAction (_this select 2);
};
};

Share this post


Link to post
Share on other sites

As I said, the locations etc are determined by random, and I'd rather not add extra actions if I can get away with it, although your idea is rather nifty and i'll use it if I have to.

Share this post


Link to post
Share on other sites

Surely you can still use this with the randomness. Are you using a custom script to randomly place them or built in stuff (like unit radius, grouped markers, etc..)?

Either way this will still work as long as you know which unit/object you are adding the map to.

Share this post


Link to post
Share on other sites

Yes it will still work, but if the player does the normal thing and goes to the gear menu to take the map, then nothing will work at all. I'm all for removing the option for player idiocy if possible.

I'm thinking of making an array of people the map is added to, adding some sort of trigger (maybe an eventhandler?) checking if a map has been picked up, and then checking through the array to determine who now doesn't have a map.

When a unit is killed, I know they move to grpnull, but do they retain their name?

Share this post


Link to post
Share on other sites
if the player does the normal thing and goes to the gear menu to take the map, then nothing will work at all. I'm all for removing the option for player idiocy if possible.

Ah ok, if you want to implement it that way, without using actions.... well, you could just check if the map is present in the inventory of one of the players and then see which dead bodies are nearby.

Share this post


Link to post
Share on other sites
Yes it will still work, but if the player does the normal thing and goes to the gear menu to take the map, then nothing will work at all. I'm all for removing the option for player idiocy if possible.

That's why you just add the action and not the physical map. This my personal opinion, but if it's important for the mission (ex, an objective or something), it should be obvious enough for the player to find it without having to look through everyone he kills' gear. It's the most guaranteed to work way to do it IMO. Other tricks such as finding nearby bodies or whatnot will probably still work, but that's still guessing.

Share this post


Link to post
Share on other sites
[*]BIS_fnc_relPos

Returns a position that is a specified distance and compass direction from the passed position or object.

  • Parameters: [object or position, distance, direction]
  • Example: [player, 5, 100] call BIS_fnc_relPos

I was all excited about this function since I thought "I can finally just move something 10m BEHIND something rather than 10m SOUTH". I was wrong, still just compass and not relational, even though it's called relPos. :)

Share this post


Link to post
Share on other sites
I was all excited about this function since I thought "I can finally just move something 10m BEHIND something rather than 10m SOUTH". I was wrong, still just compass and not relational, even though it's called relPos. :)

uhm, I think you just don't get it ;)

Of course you can do that.

If you wanna place/doMove/... somthing 10m behind some object/vehicle/player, whatever, then you:

  1. get the direction your object/vehicle/player is faceing to. You may wanna try getDir for that.
  2. Since you wanna place something `behind`, lets do some trickery like _dir - 180
  3. And now you are ready to get the position which is 10m behind your object/vehicle/player, or whatever, with the BIS_fnc_relPos.

Or, where exactly do you think is a problem with this function? Perhaps you will be more happy with BIS_fnc_relativeDirTo, but hey... what do I know. :rolleyes:

Share this post


Link to post
Share on other sites

*smirk* sorry to interrupt you guys, but have you ever heard of ModeltoWorld ?

object1 setpos object2 ModeltoWorld [0,-10,0];

this is all you need, to move object1 10 meters behind object2. ;)

Share this post


Link to post
Share on other sites

Hehe, I was waiting for someone to bring up modelToWorld. ;)

But IMO it's a bit offtopic.

Share this post


Link to post
Share on other sites
But IMO it's a bit offtopic.

Agreed, awesome command though. ;)

(almost as good as conditional actions) :P

Share this post


Link to post
Share on other sites

Offtopic or not, I'm glad Tajin came up with this. Thanks. This approach seems a lot more reasonable than what I've suggested. hehe

Share this post


Link to post
Share on other sites
*smirk* sorry to interrupt you guys, but have you ever heard of ModeltoWorld ?

object1 setpos object2 ModeltoWorld [0,-10,0];

this is all you need, to move object1 10 meters behind object2. ;)

Yeah, that's what I was using, but i wanted to use the new functions! :) The other problem I was dealing with is that the model i was moving was elevated, due to attachTo, so after modelToWorld, I then had to drop it to the ground.

Share this post


Link to post
Share on other sites

Glad to see my thread hasn't gone to complete waste. ;)

I've got a semi working idea in my head, but not sure how to put it into action just yet.

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  

×