How to detect spell efficiency on an NPC?

Post » Sat May 28, 2011 7:33 am

I want an NPC to have different dialogue responses when he's under one of "mind altering" spells. Currently I do it by having in his script code like
short me_charmedif ( GetEffect, sEffectCharm == 1 )	set me_charmed to 1else	set me_charmed to 0endif
for every spell effect I want detected and then using those local vars in dialogue conditions. The imperfection of this method, though, is that I can't detect the strength of a spell the NPC was hit by. So a 1-point Charm will always give a positive response, even though it doesn't affect the target much, and there's no point to use a stronger spell that, according to common sense, would have a real effect with substantial probability of failure. Well, I could also include Player->GetIllusion check into equation, but it's not the same thing. Does anybody have an idea how to make this work realistically and not just so-so?

Thanks.
User avatar
rebecca moody
 
Posts: 3430
Joined: Mon Mar 05, 2007 3:01 pm

Post » Sat May 28, 2011 2:03 am

You could do something like this:

Begin somescriptshort me_charmedfloat local_dispfloat tempif ( GetEffect, sEffectCharm == 1 )	if ( me_charmed == 0 )		set temp to GetDisposition		if ( temp > 99 )			set me_charmed to 1			Return		endif		set temp to ( temp - local_disp )		if ( temp >= 20 )			set me_charmed to 1		else			set me_charmed to -1		endif	endif	Returnendifset me_charmed to 0set local_disp to GetDispositionEnd



In this case, me_charmed will be set to 1 when:

( NPC is under a charm effect and has 100 disposition )

OR

( NPC is under a charm effect of 20+ magnitude )



Still not perfect, but perhaps it's closer to your goal.
User avatar
yessenia hermosillo
 
Posts: 3545
Joined: Sat Aug 18, 2007 1:31 pm

Post » Sat May 28, 2011 2:37 am

I suppose it must be
Begin somescriptshort me_charmedfloat local_dispfloat tempif ( GetEffect, sEffectCharm == 1 )	if ( me_charmed == 0 )		set temp to GetDisposition		if ( temp > 99 )			set me_charmed to 1			Return		endif		set temp to ( temp - local_disp )		if ( temp >= 20 )			set me_charmed to 1		else			set me_charmed to -1		endif	endif	ReturnELSE	set me_charmed to 0	set local_disp to GetDispositionendifEnd


Well, this might actually work. Perhaps (I'll have to check that in game) Calm Humanoid, and Demoralize Humanoid might be detected similarly by Fight and Flee levels. The question how to measure Command Humanoids, though, seems to be still open. Anyway, thanks.
User avatar
Spencey!
 
Posts: 3221
Joined: Thu Aug 17, 2006 12:18 am

Post » Fri May 27, 2011 10:21 pm

does command change the NPC's ai package to follow? if so and not an NPC that is a companion or otherwise scripted to follow, you could just check for the effect and that the NPC is in aifollow.
User avatar
Dean Ashcroft
 
Posts: 3566
Joined: Wed Jul 25, 2007 1:20 am

Post » Sat May 28, 2011 3:17 am

Yes, but it only gives 1/0 result; GetEffect sEffectCommandHumanoids does essentially the same. I want not just the fact of the spell working but its amplitude. [shrug] Of course, it's not *really* that important, using Command in this way only serves a roleplaying rather than gameplaying purpose. It's just that I tend to be a perfectionist about things I do.
User avatar
Jake Easom
 
Posts: 3424
Joined: Sun Jul 29, 2007 4:33 am

Post » Sat May 28, 2011 6:30 am

I suppose it must be


Using Return in the first if structure already makes it work like that. You can either use else or return. Using both does not hurt but is unnecessary.
User avatar
Carlos Vazquez
 
Posts: 3407
Joined: Sat Aug 25, 2007 10:19 am

Post » Sat May 28, 2011 5:23 am

but isnt command a binary, style effect? it works or it doesent, as magnitude is based on target level, or is there a formula for the spell that i dont know about?

if it does function the way i think, would it not satisfy your RP to do the geteffect check?

or can you not hijack effects (like resist corpus and blight and such) add these effects to the vanilla command spells, and check magnitude by checking for the command effect in conjunction with the effects for the different magnitudes (lowest magnitude would be just effect x, while highest could be effects x, y, and z)

that might conflict with other mods that script spells the same way, however.
User avatar
Trista Jim
 
Posts: 3308
Joined: Sat Aug 25, 2007 10:39 pm

Post » Sat May 28, 2011 5:40 am

it works or it doesent, as magnitude is based on target level
Actually, you're right, I didn't think about it. Yes, level-based success is perfectly all right with me... I don't even have to check AI package for it, as GetEffect does all I really need in this case. :celebration: Thanks.
User avatar
Hairul Hafis
 
Posts: 3516
Joined: Mon Oct 29, 2007 12:22 am


Return to III - Morrowind