Jump to content
Sign in to follow this  
meshcarver

Request or advice for script to move objects when player ISN'T looking at them

Recommended Posts

Hi guys,

my first post here in this dark mysterious side of addon making, and I'm not sure it's in the correct topic so mods please feel free to move if not.

I've made some "characters" for a map I'm creating and I would like to have them move/change position slightly when the player ISN'T looking at them- ie; when they're off screen.

Firstly, about the characters. They can be thought of as metal sheets- they do not animate as such and are basically cut out figures that will dot the landscape. So there's no actual animations to bear in mind, these will be static in of themselves so are simple in that regard- they could be though of as planks of wood for this topic if that helps.

At this early stage if I'm to be exact about their exact behaviour I'd have to say I'd like them to have a random chance of movement (A figure I'd play with and experiment with) 2-10 meters generally towards the player but not always. This occurs ONLY when the player does not have line of sight with it- when player turns his back on it past a certain degree. This is to ensure player never sees it "materialise" or actually move across the landscape and this would also increase the unnerving factor imo. Sometimes (again randomly) a sound will play like metal dragging along concrete (dependant on surface type).

Also, and this is the point- if they get too close to player, player suffers a form of health degeneration (the same as burning would be fine for now as I'll refine that part in future) and will quickly (Again I'd like this figure configurable) die unless he moves away.

That's basically it.

The only other thing I can think of is in what form I'd like these characters to come. I am open to advice about that, but I think it'd be best that they don't come "embedded" in the new map like this, but rather so I could place them individually or in clusters in certain areas and make them as a mission file?

Bottom line is I'd like to be able to place them one at a time or a group in the editor too.

Another idea I've had put to me is to make them animal AI or ambient life? Would that be a module? I don't know... so I'm asking all this here in the hopes that someone sees an interest in this and would please consider setting up a script if it's NOT too much trouble... I have no idea what it takes to make something like this happen guys, but if someone did, then be assured I'd study said script until I fully understood how it works.

If this would be simply too much work for someone then no worries- I have no idea the amount of work involved in this.

Thanks for your time,

Marc

Share this post


Link to post
Share on other sites

A module is totally possible - how many of these things do you want on the map?

Is it:

A fixed amount

A number per player

Up to mission maker

<sorry, you answered that already>

Module to control the script and then individual objects could work.

Also - what is their behaviour if you consider multiple players?

Will they:

Move towards nearest player

Fixate on certain player and move towards them?

Thx

EDIT: Just to clarify, are these for SP only or do you want them available for MP? ALso, how do you want them to handle water? Will they cross water to get to the player, or will they refuse/pick another player (if it is MP)

Edited by Das Attorney

Share this post


Link to post
Share on other sites

Hey man,

thanks for your questions and interest!

I think I'm badly placed to answer multiplayer requirements as I haven't got a clue in any difference there'd be between SP and MP for this kind of thing. Say for now it was just SP- would it be an easy transition somewhere down the line to make it MP compatible?

They will not cross water if that's better/easier. Water can always be problematic anyway can't it? I don't know...

In SP they will obviously move towards the player yes, but if they worked in MP, then yes, they'd move towards nearest player- an interesting gameplay dynamic would come out of that- to try to get past them blocking a doorway say you send someone in as bait..!? ;)

Ideally, I'd love these to be individually placeable in the editor, and to have a "group" or "radius placement" of them or something similar with a random number... I hope that makes sense. In effect, like placing Units down as normal.

Das Attorney, are you interested in this as you are considering the script, or just asking? No problem either way of course..!

Share this post


Link to post
Share on other sites

I need to go to bed now (it's very late here) but start work on something for you tomorrow.

It's probably easier to make it for MP, then it will be compatible for SP automatically as well, rather than fiddling around later on to code in MP.

Re water: it's easier to have them cross water (either at surface level or on the sea floor). I can code in some checks for water if you want it to act as a barrier, but they aren't totally reliable (will need to periodically sample terrain from point A to point B) and it might be a bit more resource-hungry so you could always comment that bit out if you don't like it.

Re: Placing, you could put the module down (to enable them) and then have some objects to place at will in the editor. I agree that might be a bit better in terms of giving the mission maker complete autonomy in how they initially place the objects.

Also, are they destructible? (Thinking if you need a respawn system for them)

:)

EDIT: I should have gone to bed but I started work on this for you. The SP version will be easy as the camera is local so it's coming along nicely there. MP will be not be as straightforward as I first thought. I can still work out which direction units are roughly looking (which should be good enough accounting for error) but you can't get the position & direction of each players camera from the server. So it will still work ok but only for people on foot. (There's no way for the server to tell where a player is looking if they are in a vehicle). Anyway, I'll have a think and see if i can get round that one.

Edited by Das Attorney

Share this post


Link to post
Share on other sites

Holy shit- PM sent mate, thank you..!!!

Making them MP compatible is great if it works for SP too yes..! :)

In regards water, I reckon it'd be good to allow them to cross thinking about it... but they'd be more freaky if they submerged instead of walking on water kind of thing.

Also, if in MP, I think if ANY player is looking at them then they shouldn't move at all, as it'd spoil the "trick" and perhaps that is also easier for you to code..?

Also, they should be indestructible mate.

PS- As I said in the PM, goto bed mate..! ;)

PPS- there's a more detailed description of what they are here fyi:

Fyi, there are currently 10 different Designators, all will behave the same but they will be different objects/units.

Another point, it'd be great to experiment with a figure in meters as a radius for when the chances of movement occur- so like only s chance if there's a player within 30 meters say.

Edited by meshcarver

Share this post


Link to post
Share on other sites

If I knew how to get the player's field of view setting, then I could have done something more fancy.

_testPos = getPos _testTarget;
_playerPos = getPos player;

_direction = ((_testPos select 0) - (_playerPos select 0)) 
atan2 
((_testPos select 1) - ((_playerPos select 1)));

_dirDiff =  _direction - (getDir player - 180); //atan2 returns -180 to 180, so need to make 360 dir to a -180 to 180 too
if(180 - abs(_dirDiff) < 60) then //You can adjust this 60 to compensate for the player's field of view
{
hintsilent "Yes, Can see";
} 
else
{
hintsilent "No, Cannot see";
};

Share this post


Link to post
Share on other sites

Hi Ed,

apologies man, I should have mentioned that Das Attorney has taken an interest in this now and is in the process of creating a really good script mate.

Thanks very much for your post all the same- all this codey stuff is very interesting for me to look at..! :)

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  

×