Jump to content

Removing spell effects from a cre


Meira

Recommended Posts

It seems like a such an obvious, every day thing, but I can seem to find or recall how to (via script) remove all spell effects from a given creature (feeblemindness, domination, sleep etc).

 

This would be used for a cre in possession a minHP item who is going to initiate a dialogue with the player when her HPs drop too low. I've come to the conclusion that simply clearing all (harmful) effects before she talks is a better solution than waiting them to expire while player fruitlessly hacks her to pieces. It would also be better than making her completely immune to spells that might prevent her from speaking. :(

Link to comment

Timed effects could be removed by fakeeffectexpirycheck.

Dispellable effects could be removed by the dispel opcode.

 

it has 3 versions:

 

param2=0: dispel all effects

1: dispel power by caster level

2: dispel power by param1

 

Some effects (not all) are removable by their companion cure opcode. These remove permanent effects too.

 

Also, make sure the code which revives the villain is not in the villain's script. Because a stunned/panicked etc creature doesn't run its own scripts. (Just realized this in IWD when somehow poquelin got panicked and couldn't escape, with minhp1 active, heh, IWD is so crappy).

 

Actually, the best way to 'revive' the creature is to call a changeanimation on it (essentially destroy the old cre and create a new). This saves a lot of trouble.

Link to comment

All right, I failed miserably in both using fakeeffectexpirycheck and applying a spell with dispel opcodes - neither seemed to have no effect in the current spells affecting the cre, no matter what I did. :p I tried to give fakeeffectexpirycheck different values and even looked up how it is used in the original game, but nothing happened. With the spell I suppose it is possible that I just failed to make a working one, my spellmaking skills aren't that good. The spells that I tried to dispel during testing were cleric's Hold Person and mage's Confusion

 

How does the changeanimation action work? Can I replace the creature with itself or do I need double cre-files? I assume that HPs and memorised spells will be restored this way too, which is not really the desired effect. I'd just like to remove the effects preventing the cre from speaking. What about the items the cre is carrying, are they reverted too?

Link to comment

Timed effects could be removed by fakeeffectexpirycheck.

You need to give a large amount of time, like a day or so, it should remove almost anything timed.

 

But confusion/hold person could be removed by specific effects.

Opcode 161 cures fear

Opcode 162 cures hold

Opcode 242 cures confusion

 

I guess changeanimation will work with the same cre.

Link to comment
Timed effects could be removed by fakeeffectexpirycheck.

You need to give a large amount of time, like a day or so, it should remove almost anything timed.

 

I remember using 1000000 and 150000, the latter being the amount used in the BG2's script I looked up, but admit that I don't know what amount of time a 'tick' represents.

Link to comment

I hope the changeanimation thing works.

I would use that one, because that seems to be the most effective.

 

[edit]

 

did you make sure you use fakeeffectexpirycheck / applyspell from an area/global script?

It will definitely not run when the creature is disabled.

 

You must also make sure you detect the defeat condition correctly.

Link to comment
I hope the changeanimation thing works.

I would use that one, because that seems to be the most effective.

 

Okay, I'll try that.

 

did you make sure you use fakeeffectexpirycheck / applyspell from an area/global script?

It will definitely not run when the creature is disabled.

 

Yes, I used the area script like you suggested above. I know that the srcipt block works and is triggered correctly, because I also set a global variable in it (and it gets set).

 

You must also make sure you detect the defeat condition correctly.

 

You totally lost me here, sorry. :p

Link to comment

Uh, is it just me or doesn't ActionOverride(O:Actor*,A:Action*) work on disabled (held and/or confused in this case) creatures? (Assuming that I'm doing the right thing when using the creature's death variable for O:Actor*)

 

Or at least I can't see how else I would apply ChangeAnimation(S:ResRef*) since it does not specify a target.

Link to comment

Oh shit, i knew there is a flaw in my idea.

Of course actionoverride won't work :p

 

But not all is lost, there is an opcode which does the changeanimation stuff.

151,1,"Summon: Replace Creature [151]","Irrelevant","Type","Replaces the targetted creature(s) with creature specified by the resource key, in the style specified by the 'Type' value.

 

Known values for 'Type' are:

0 Remove target silently

1 Remove target - kill with chunk death (giving experience)

2 Remove target - kill with normal death (giving experience)

 

If you send me an email, i could write you the spell to be applied.

Link to comment

Okay, back to the FakeEffectExpiryCheck(O:Object*,I:Ticks*) action. Could it be that it doesn't take DV as an object, but rather an entry from objects.ids, like Killed()? The example from the game uses Player1-6. I suppose I could narrow [EA.GENERAL.RACE.CLASS.SPECIFIC.GENDER.ALIGN] to be exclusive enough to only affect the cre in question here.

 

EDIT: Looks like I posted while you edited your post. If I still don't get FakeEffectExpiryCheck() to work I'll try what you suggested above.

Link to comment

Okay, and in Killed() action's case the object doesn't exist anymore, right? That said, changing FakeEffectExpiryCheck() action's object didn't make any difference, ie. it still didn't seem to do anything. I sent you an e-mail.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...