Home   Help Search Login Register  

Author Topic: [SOLVED] Searching Bodies to add Markers.  (Read 1084 times)

0 Members and 1 Guest are viewing this topic.

Offline Nexolate

  • Members
  • *
  • The lurking S.T.A.L.K.E.R.
[SOLVED] Searching Bodies to add Markers.
« on: 21 Mar 2008, 20:50:23 »
Firstly I want to thank the OFPEC community for their generous donations in tutorials. They've really helped me understand the Editor and how it works, however I now have a small request.

I'm making a Mission, the details are unimportant, but I want it so that when the player (or anyone on his team) 'searches' the body of a certain enemy Squad Leader they'll get a Marker appear on their map to guide him to a secret Weapons Stash. If you've played S.T.A.L.K.E.R., you'll know exactly what I mean.

The few ideas I've had are:

Taking the SLs Primary Weapon.
Staying within a distance of the SLs Body (for a set time).

I would greatly appreciate any Editor's input on this subject, because I'm stumped.
Thanks for reading.
« Last Edit: 03 Apr 2008, 19:16:29 by Nexolate »
You'll only notice me when it's too late.

Offline paritybit

  • Members
  • *
Re: Searching Bodies to add Markers.
« Reply #1 on: 21 Mar 2008, 23:12:54 »
I'm not sure what your scripting proficiency level is, but if you're at all familiar with adding actions (via the addAction command) that is probably your best bet.  I'm still new at this so maybe somebody will come along with a better answer.

In this less-than-elegant example, we have an object named "deadBody" which represents the body, and we have a global variable called "CacheTempAction" which we are going to use to store the action ID so we can remove it once you've searched the body.  You'll also have to know the game position (used to create the marker) of the weapon cache.

You could create a script called AddWeaponCacheMarker.sqf:
Code: [Select]
createMarkerLocal ( "Weapon Cache", [position of the cache] );
deadBody removeAction CacheTempAction;

And then, somewhere in the mission initialization (or death-of-the-enemy code) add the action to the body with this command:
Code: [Select]
CacheTempAction = deadBody addAction ["Search Body", "AddWeaponCacheMarker.sqf"];

There are numerous ways to improve this, but I hope you get the idea.  Note that I've used createMarkerLocal which will create a marker locally on the player's instance, but not on any remote (server or other player) running instance.  You can use createMarker instead, which will create it across all instances.

- paritybit
« Last Edit: 21 Mar 2008, 23:15:39 by paritybit »
Heroes don't die -- they just respawn.

Offline Nexolate

  • Members
  • *
  • The lurking S.T.A.L.K.E.R.
Re: Searching Bodies to add Markers.
« Reply #2 on: 22 Mar 2008, 00:51:56 »
Thanks for your speedy response.

Having read that, it certainly looks like a viable solution to my problem.
However, I still fail to see how that ties the Marker creation to the 'searching' of the body. In your code, you're creating an action called "Search Body, but I don't think this will activate if you actually did search it.

Or, am I missing something?
You'll only notice me when it's too late.

Offline paritybit

  • Members
  • *
Re: Searching Bodies to add Markers.
« Reply #3 on: 22 Mar 2008, 01:00:51 »
Maybe I missed something.  As far as I know there isn't an actual command in the game to "search a body".  Right?

What I've suggested is to add an action to search a body, and when that action is performed the script is executed to create the marker (and the action removed from the body).  Therefore, in the game you would have to walk up to the body, activate your context menu (scroll the mouse wheel) and select the action which you've added ("Search Body"); at that point the AddWeaponCacheMarker.sqf script would execute causing a marker to appear on your map.  You could also add a hint to pop up and let you know what's happened.

If there already is such an action, then I'm not sure of the appropriate way to execute the script when that action is executed.
« Last Edit: 22 Mar 2008, 01:03:27 by paritybit »
Heroes don't die -- they just respawn.

Offline Nexolate

  • Members
  • *
  • The lurking S.T.A.L.K.E.R.
Re: Searching Bodies to add Markers.
« Reply #4 on: 22 Mar 2008, 01:02:15 »
Ah right, I see how it works now. Ok, I'll give that a go tomorrow when I get some time.

Thanks for your help, I'll post back here if there are any issues.

EDIT:
This code works! Pretty much as is!
Obviously you need to change a few names so that Scripts and the "Dead Body" match, but other than that you've nailed it pretty much on the head. Thanks so much for your help, if I ever release this Mission to the public I'll make sure to include special thanks in the Readme. =)

Thanks again.


EDIT: No consecutive posting please     h-
« Last Edit: 22 Mar 2008, 11:04:47 by h- »
You'll only notice me when it's too late.