Aller au contenu

Photo

In need of aid with script to check for effect and more.


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

#1
Xeneize

Xeneize
  • Members
  • 133 messages

Greetings.

 

I have been now for over a day attempting to work on a script that goes on 'On perception Script' of a NPC.

 

What I am looking to attempt is to make it so the NPC will check a PC when it comes into the NPC's perception field for the invisibility effect and if true, it will run up to him and fire up a conversation.

 

So far I have not been able to see what I am doing wrong, but here's the coding I have so far:

    void main()

{



object oPC = GetLastPerceived();

int GetEffectType = oPC;



if (!GetIsPC(oPC)) return;



if (!GetLastPerceptionSeen()) return;

if (GetEffectType(EFFECT_TYPE_INVISIBILITY, oPC))

   {

   ActionStartConversation(oPC, "CONVERSATION");

}

}

Being fairly new myself to scripting, I thank anyone that might be able to help me with this in advance.



#2
Dann-J

Dann-J
  • Members
  • 3 161 messages

You would need to cycle through all the effects on the PC before testing each one, via a GetFirstEffect() / GetNextEffect() 'while' loop.

 

Alternatively, you could check for the spell IDs of any of the invisibily spells, via GetHasSpellEffect(). That assumes you don't have any custom methods of imparting invisibility to players in your module/campaign, so it could only come from a standard spell. The possibilites are; Invisibility (90), Greater Invisibility (88), Retributive Invisibility (841), and Invisibility Sphere (92). The assassin invisibility spells are also separate entries (607 and 608), as is that of the gray dwarf (804).



#3
Tchos

Tchos
  • Members
  • 5 072 messages

Hang on a minute...  In my experience, if the PC is invisible, the On Perception script will not fire, because the NPC did not perceive the PC.



#4
Dann-J

Dann-J
  • Members
  • 3 161 messages

They might perceive the invisible target by hearing it, but unless they've got True Seeing they certainly won't see it. Giving the NPC a lot of listen skill points might do the trick though.

 

Personally, I'd probably create a custom area-of-effect and apply it to the NPC from their OnSpawn script. The AOE's OnEnter script could then check whether you're invisible or not, and do different things accordingly.

 

The easiest way would probably be to use an ordinary talk trigger, which will ignore invisibility and start a conversation regardless. Then a conditional script could check whether the target is invisible.

 

I'd be avoiding using the perception event for anything plot-critical.



#5
4760

4760
  • Members
  • 1 213 messages

Additionally, it should give errors at compilation:

object oPC = GetLastPerceived(); // oPC is an OBJECT

int GetEffectType = oPC; // GetEffectType is an INTEGER, but it also is a RESERVED KEYWORD (function name).


#6
Psionic-Entity

Psionic-Entity
  • Members
  • 195 messages

For starters, make sure the NPC has true seeing. Not sure if it's mandatory but it could be one reason it's not working. Then use something like this.

void main() {
	object oPC = GetLastPerceived();
    if (!GetIsPC(oPC)) return;
	
	effect eEffect = GetFirstEffect(oPC);
	while (GetIsEffectValid(eEffect)) {
		if (GetEffectType(eEffect) == EFFECT_TYPE_INVISIBILITY) break;
		eEffect = GetNextEffect(oPC);
	}
	if (!GetIsEffectValid(eEffect)) return;
	ActionStartConversation(oPC,"CONVERSATION");
}


#7
Xeneize

Xeneize
  • Members
  • 133 messages

That is actually a true thing I have experienced. While I have fixed this problem I now find myself with another dilema, which is the fact I would like to find a way for a NPC that has normal spot/listen or no way to see invisible, to still catch people with invisibility effects and fire up the aforementioned conversation. Is that somehow doable at all? Or is the only way by making sure the NPC has means to see such a thing as would a PC?

 

Thank you in advance for the help :)



#8
Psionic-Entity

Psionic-Entity
  • Members
  • 195 messages

That one's harder but still possible. First you need to decide whether you want this NPC to move. If yes, you need to apply an AOE effect to the NPC during its spawn phase that adds an AOE effect with a custom on enter script that basically does what the "on perception" script I posted above works. This may involve adding a row to vfx_persistent.2da so that you can have an invisible AOE of the desired size. If not, then your best bet is to draw a new custom trigger in the toolset with the same on enter script. Replace the PC definition with a GetEnteringObject call and you've got it settled.



#9
Xeneize

Xeneize
  • Members
  • 133 messages

Alright thank you very much for the help to all of you, really appreciated :)