Aller au contenu

Photo

Pseudo "PC In Range" Hook (A Little Like "PC On Perceived") ... Working Model


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

Hi All,

I have found that there have been occasions where I would like something to happen when something came within range of the PC, based upon the PC from a "hook" point of view. In my latest need, I wanted to have creatures have a variable change when they came within a certain range of the PC ... and within the PCs line of sight.

Now, my first approach was to use the creatures OnPerceive hook, but that fails if the PC is invisible. However, by reversing the approach and have the same code fire if the PC spots the creature was the solution. To get around this missing hook, I ended up messing around with the Persistent Effects, and managed to place a persistent AoE that meets the criteria I need. Furthermore, I think by using a NULL EffectIconEffect image and string, I should be able to make the whole thing "invisible" to the player. :)

At the moment, in brief testing, the effect works well. Every PC has the effect put on them at spawn time (including the Main PC) and I am currently using a 20 m radius circle that fires an OnEnter whenever a creature enters the effect ... and so trigger my code.

This may have already been done by others to equal effect, but it only just came to me and I thought others may be interested in the facility of such a hook.

I will finish working on it tomorrow, and report if there are any problems ... Is anybody aware of any potential problems here?
 
SEE MY NEXT POST

Cheers,
Lance.



#2
Dann-J

Dann-J
  • Members
  • 3 161 messages

I do it the other way around. I give the creature that I want to react to the players a custom AOE, and have the AOE OnEnter script check whether the entering object is a party member. It allows me to create NPCs who turn to face party members as they pass by and utter one-line comments. Merchants can hawk their wares, or villagers can make certain comments reflecting the party's recent activities (praising them for completing a quest, abusing them for commiting a crime, etc).

 

I use the same system to make timid non-hostile animals run away if a player gets too close. It could also be used to make guard dogs begin to bark, or for wild creatures to change from neutral to hostile if you get too close to them. It's also a more reliable way for an NPC to initiate a conversation that doesn't require painting down a conversation trigger.



#3
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

I do it the other way around. I give the creature that I want to react to the players a custom AOE, and have the AOE OnEnter script check whether the entering object is a party member. It allows me to create NPCs who turn to face party members as they pass by and utter one-line comments. Merchants can hawk their wares, or villagers can make certain comments reflecting the party's recent activities (praising them for completing a quest, abusing them for commiting a crime, etc).
 
I use the same system to make timid non-hostile animals run away if a player gets too close. It could also be used to make guard dogs begin to bark, or for wild creatures to change from neutral to hostile if you get too close to them. It's also a more reliable way for an NPC to initiate a conversation that doesn't require painting down a conversation trigger.


Hi Dann-J,

Yes, I have a list of things I intend to alter to use this concept. If I can keep the effect being triggered from the PC without it causing any issues, then I will. However, I need to make sure it is reliable enough to use that way. If not, I will also switch to creature/NPC specific .... or better still, I might as well use both!

You say ... "creatures to change from neutral to hostile if you get too close to them" ... That's the exact thing I needed and which brought me to this solution. :) See my other recent posts about resting. ;)

 

I'm not sure if this edit below is correct or not ... Will test more later.

EDIT: OK, I don't know what has gone wrong, but when the effect is applied to the PC, it goes a little wonky after a few seconds ... I tried getting to the bottom of it, but have been unsuccessful. Therefore, I will stick with the effect on just the NPCs as you did. Hopefully, they won't play up like these have been on the PCs ...

Basically, if you bump into the PCs with the effect on them, then the effect On Enter keeps firing! Makes no sense at all. :( ... I just found this in the Lexicon, so maybe it's related to that: "There are a few graphical problems with using MOB_ declared AOE's as location AOE's, and PER_ declared AOE's used as mobile (moving with the PC) AOE's."

 

OK, having played around with this a little more, I made couple of discoveries, which may be helpful:-

 

A ) When applying persistent AoE to PCs, it is best to add a very short delay: 0.001. They appear to work reliably then.

B ) When applying such (TEMPORARY VERSION) alongside another effect (e.g. I added AoE effect to the Invisibility spell), the effect icon remains hidden. (Good!)

 

It may be that the problems reported in the Lexicon may well simply need this delay to overcome the reported issues.

 

Cheers,
Lance.