Problems with constant effect chameleon for NPCs

Post » Sun Apr 05, 2015 9:24 pm

As part of a boss fight I'm working on, I have the boss 'disappear' and send three 'projections' of himself after the player. These projections look identical to him, except they have a constant effect chameleon to appear 'ghostly'. This all works fine -- the problem is that immediately after any one of the 3 ghosts dies, the other two lose their chameleon ability and become corporeal.

I'm at a loss to why this might be happening, because each of the three NPCs has a different script (they all do the same thing, but they are different scripts and so shouldn't interfere with one another).

Even adding precautions to add back chameleon abilities to their scripts doesn't seem to fix it.

I'll attach the scripts they have attached below. Note that though it's labelled 'scriptname 1', each of them has their own (scriptname 1, 2, 3) which do exactly the same thing, to ensure no weird variable overlaps.

Begin NON_VoidAncalAsp1short triggerfloat timerif ( menumode == 1 )	returnendifif ( onactivate == 1 )	returnendifif ( trigger == 1 )	returnendifif ( GetHealth < 1 )                     ; this part makes them vanish when they die	set timer to ( timer + getsecondspassed )	if ( timer > 0.5 )		PlaceAtMe "NON_WarpEffect" 1 1 1		StartScript NON_VoidCrystalChargerN1  ; triggers a second script included below		Set timer to 0		Set trigger to 1		Disable		Return	endifendifif ( GetScale != 1.10 )	SetScale 1.10endifif ( GetEffect, sEffectChameleon == 1 )	ReturnendifAddSpell chameleon_100_unique   ; note that this is a different chameleon ability                                ; to the one they start off with, so it's not redundantend

The above script triggers a second script which is involved with charging up a superweapon, and thus not really relevant. I included it just in case it might be involved:

Begin NON_VoidCrystalChargerN1short statIf ( menumode == 1 )	returnendifif ( stat == 0 )	If ( NON_VoidAncalagon == 8 )		PlaySound "sprigganmagic"		Player->RemoveItem "NON_AncalagonStaff1" 1		Player->AddItem "NON_AncalagonStaff2" 1		MessageBox, "The Thaumaturgica has absorbed enough metaphysical energy to reach full power."		Set NON_VoidAncalagon to 9		Set stat to 1		Return	Else		PlaySound "sprigganmagic"		MessageBox, "The Thaumaturgica absorbs the metaphysical energy trapped within Ancalagon's projection."		Set NON_VoidAncalagon to ( NON_VoidAncalagon + 1 )		Set stat to 1		Return	EndifElseIf ( stat == 1 )	stopscript NON_VoidCrystalChargerN1EndifEnd

'NON_VoidAncalagon' is a global which all three 'charger' scripts modify -- this is the only point that I can see where these scripts might interact.

It's a minor issue, but I really like the effect of having these ghost/projection enemies, so it'd be a shame if I had to scrap it. Any help would be appreciated!

User avatar
Sierra Ritsuka
 
Posts: 3506
Joined: Mon Dec 11, 2006 7:56 am

Post » Sun Apr 05, 2015 4:01 pm

I don't know much about scripting, but have you run this script in http://prdownloads.sourceforge.net/mwedit/mwedit-0.6.0.zip?download just to check if there were any errors.

User avatar
Emilie M
 
Posts: 3419
Joined: Fri Mar 16, 2007 9:08 am

Post » Mon Apr 06, 2015 2:24 am

Does each ghost NPC have a unique ID? or is it just three of the same?

User avatar
jenny goodwin
 
Posts: 3461
Joined: Wed Sep 13, 2006 4:57 am

Post » Sun Apr 05, 2015 12:03 pm

Yes, they do have unique IDs (though each of them has identical spells/items on them).

I've just run it, and it didn't complain. Which makes sense, because the scripts themselves are working.

Just to clarify, because I don't think I explained myself very well:

Each NPC has a constant effect chameleon ability ('chameleon_60') added, plus a constant effect chameleon amulet for good measure. Their scripts detect for if these NPCs lose the chameleon effect, and add a subsequent chameleon ability ('chameleon_100_unique') if they do.

They are initially in ghost form, but the moment any one of the three dies, the other two become corporeal.

All of their scripts are working fine -- after they 'become corporeal', I checked their spells and they did indeed have the 'chameleon_100_unique', which means that their scripts picked up on their losing the chameleon effect and tried to counter it. Except that it didn't work for some reason -- they didn't go ghostly again.

So it seems to be something about the mechanics of chameleon constant effect abilities which I'm just not aware of?

The NPCs are initially disabled upon entering the cell, and are enabled at a certain point in the battle, if that helps.

User avatar
Sebrina Johnstone
 
Posts: 3456
Joined: Sat Jun 24, 2006 12:58 pm

Post » Sun Apr 05, 2015 11:52 pm

Aargh! This just gets more bizarre and seemingly un-resolvable the more I test.

I set up test scripts for each of the ghosts which reported a message whenever the 'chameleon effect' wasn't present. The moment I entered the cell with the ghosts, these messageboxes were triggered. In other words, the moment I walked into the cell, the game registered them as not having any chameleon effect on.

However! When I got tricky and mixed the scripts up so that only one of their scripts attempted to counter the loss of chameleon effect by adding a new chameleon spell, all of them retained their chameleon effects (until one of them died). So basically, the game reads them as not having chameleon effects active the moment I walk in, but for whatever reason, they actually do still have chameleon effects. ??!!

So I tried setting up other innocuous NPCs to have constant effect chameleon abilities as well and found the same thing: they reported not having any chameleon effect, despite having the effect. BUT for reasons unknown, when I got them to fight me and killed one of them, none of the others went corporeal the way mine do.

So I thought it might have been something with my NPCs' scripts, and I blocked them completely... but they still lost their chameleons when they died!

What the... ???????????????!!!!!!!!!!!!!!!!!!!!!!!!!!!!

User avatar
Gen Daley
 
Posts: 3315
Joined: Sat Jul 08, 2006 3:36 pm

Post » Sun Apr 05, 2015 11:35 pm

It's weird. Sometimes you need to deceive the game by having a parameter or similar that's positive when it isn't positive, instead it's false and still you instruct the game to think it's a positive result.

I hope you can solve it. Good luck. :smile:

User avatar
Logan Greenwood
 
Posts: 3416
Joined: Mon Jul 30, 2007 5:41 pm

Post » Sun Apr 05, 2015 4:34 pm

I performed a limited test of your script so I think I can clear up a few issues. I suspected that the 'no detection' was a result of the cell loading. Although not strictly speaking, it is as if the NPC's animation is not fully engaged so the engine does not detect the effect. I added a 5 frame delay before checking for the effect and the message (I added) did not display as it had in my initial test. Upon death, the ability is no longer active (the body appears corporal) – at least without your script active. In my tests the disabling seemed instantaneous although you 0.5 seconds may have been run during the death animation. In death the NPC may not be able to 'process' abilities (again sort of, but not exactly an animation issue – they are no longer animate).

I did not test (and have no certain insight) as to why the other two NPCs become visible upon the death of the third. It should not matter if they wore the same script – changes made by one local script will not affect another (think of the official slaveScript for the truth of this). Perhaps it is some sort of strange stacking effect of the chameleon effect that negates their behavior. You might at least test again with the delay I introduced so you do not have multiple chameleon effects active. Just so there was no doubt, I added the chameleon ability to a random NPC-on-the-street and it worked as expected. If nothing else works, maybe you could reapply the ability to the surviving NPCs after one of them falls.

User avatar
remi lasisi
 
Posts: 3307
Joined: Sun Jul 02, 2006 2:26 pm


Return to III - Morrowind