Jump to content

A quick question about scripting


johntheemofag

Recommended Posts

All I'm trying to do is get an NPC to go to a point and then look at the player. I've managed to get the first part accomplished using a travel AI Package, and the second part I'm attempting to accomplish by writing a script that essentially forces the NPC to look at the player. It's just "Look Player" in a "Begin GameMode" block. And it works, sort of. The only problem is that the Look function apparently has a very limited range on it, and I was wondering if anyone knew how to overcome that. I want the NPC to be forced to look at the player even from a considerable distance. What it's doing now is looking at the player until the reference moves out of this apparent zone of look limitations and then their head locks in one position and doesn't move until the player is back in their acceptable proximity. I could have sworn that I had this working a few weeks ago, but I just tried to do it again in a different plugin, and it refuses to work. I'm sure I'm overlooking something incredibly simple, so, sorry if this is an incredibly ridiculous question.
Link to comment
Share on other sites

Have you tried making a dummy pistol that shoots blanks and making the NPC use that with a Use Weapon Package? I think even ambush has a pretty limited range, so a fake weapon might be your best choice.

I'm not really sure how to do that, although now I'm really curious. I figured it out, although I think it's sort of a nasty hack: since this is a triggered event, and the player's movements are restricted by a wall and a floor, which in turn restricts his movements to two axises, I put a ref in front of the NPC and wrote a script which adjusts the refs position and essentially rotates it around the NPCs head according to the player's X/Y position. Don't worry; I wrote it to mark itself for deletion when the player exits the trigger. :p

 

At any rate, could you elaborate on the dummy pistol thing? Would the NPC still perform the pistol attack animation?

Link to comment
Share on other sites

Would the NPC still perform the pistol attack animation?

Most likely.

 

There might be a way to script the NPC to look in your direction as long as the player is in LOS (Line of Sight). I don't think that LOS has the range limitations of other methods.

 

Another possibility might be to give him a force greet dialogue AI package that triggers at a certain distance while preventing the NPC from moving toward the player somehow. That might get him to focus on the player at a greater range without appearing to take aim with a weapon. He would initiate dialogue when you get within speaking range.

 

It would probably help to avoid having any other NPC nearby to distract your target NPC. They seem to like to stare at each other.

Link to comment
Share on other sites

I've never tried to do a dummy pistol (never had a need for a staring NPC), but you would definitely have to do something about the animations. In fact, that would be the tricky part, if it isn't as simple as just leaving the fields for anims blank or something like that.

 

It just occurred to me to do it that way because Arkansas is more or less scripted to something similar (just with an actual rifle and with cars instead of a dummy weapon and the player).

 

On the other hand, if you can script it with GetHeadingAngle or similar functions, that might work a lot better.

Link to comment
Share on other sites

I've never tried to do a dummy pistol (never had a need for a staring NPC), but you would definitely have to do something about the animations. In fact, that would be the tricky part, if it isn't as simple as just leaving the fields for anims blank or something like that.

 

It just occurred to me to do it that way because Arkansas is more or less scripted to something similar (just with an actual rifle and with cars instead of a dummy weapon and the player).

 

On the other hand, if you can script it with GetHeadingAngle or similar functions, that might work a lot better.

Only if there's a way to make the character's head turn a certain way, and if there is, I don't know it. I managed to get the script to force an object scaled to 0 to always stay in front of the player, but the little male without a father NPC only activates the look function when a player is in the vicinity, regardless of what the objectref is.

 

I tried the Dialog thing and it has the same limitations. Well, not precisely: the distance can be modified, but the NPC will activate dialog no matter how far away you are if you set the distance to that amount. Like, from clear across the freaking map.

 

:|

 

This can't seriously be as difficult as I'm making it.

Link to comment
Share on other sites

I found a few game settings that appear to alter the headtracking parameters. The only one that appears to do anything is fAIMaxHeadTrackDistanceFromPC, which is initially set to 2000 (units), although the most I ever get is a paltry ~320. Interesting, setting it from 0-300 actually has an effect, but increasing it past that apparently does not. Either there is some weird-ass modifier that the engine is using that isn't named the same as these, or the engine isn't following its own rules.
Link to comment
Share on other sites

If an NPC is far enough away, does it really matter whether they are precisely head tracking you? I'm wondering if this isn't something you can't fudge with something like:

 

ref npc
float angle

set angle to npc.GetAngle Z + npc.GetHeadingAngle player
npc.SetAngle Z angle

 

That should at least make them turn bodily toward the player.

Link to comment
Share on other sites

If an NPC is far enough away, does it really matter whether they are precisely head tracking you? I'm wondering if this isn't something you can't fudge with something like:

 

ref npc
float angle

set angle to npc.GetAngle Z + npc.GetHeadingAngle player
npc.SetAngle Z angle

 

That should at least make them turn bodily toward the player.

Thanks; I ended up using that. I put X markers under each potential view port and do GetDistance checks on the player to each marker, and whichever he is closest to, the NPC is rotated using formula you posted. Well, it's better than nothing, but I have to say, I'm a little disappointed that even after I spent that time tracking down that variable, it apparently doesn't even do anything. Oh, well. Given the things that I've never had problems with in the GECK, this is pretty trivial.

 

Thanks again!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...