six Change Spell

Post » Tue May 17, 2011 8:04 am

-->Snapshot: I created a "six change spell" via OBSE, but when it changes the six, the NPC doesn't get redrawn and is invisible. How can I fix this? <--


Ever get tired of Oblivion's over abundance of males? Wishing for more females in specific places, like that castle mod you love? Why not change the six of any NPC in game with a spell! At least, that was my plan. It beat having to go into the editor to change a couple NPC's from some mod that I'm using. I was originally inspired by the "Set Essential Actors Spell" mod, and decided to do one like it, but change the NPC's six instead. I'd never scripted in OBSE before, but already had it installed, and with a little tinkering and judicial Google use, was able to get a spell that did what I wanted, only to find out that OBSE's six change command is broken! Yeah sure, it changes the six alright, but it doesn't update the NPC properly afterward. When first used, the NPC completely vanishes except for their moth and eyes, which look odd and a bit grotesque, just floating there in the air. I figured all I needed to do was get Oblivion to redraw the NPC again, and tried equipping and then unequipping an piece of clothing on the NPC (via the console). It worked...to an extent. The NPC's body reappeared (allowing me to confirm the six change had been successful), but the head remained missing. Just those two freaky eyeballs and the floating mouth. So I tried equipping a Daedric helm (which covers the entire head) and noticed an immediate improvement, at least for as long as the helm remained on. When I took it back off, the hair was now there, but the had was still missing! I also tried disabling and then renabling the NPC, but this undid the six change.

Now the way I see it, any body part that is actually disabled when an article of clothing is put on (like arms, legs, and hair) get redrawn. Unfortunately, putting on a helmet (even a Daedric one) doesn't actually disable the NPC's head, just their hair. Is there anyway to get this effect for the whole NPC's head? If there was, I could create an object to do that and then equip and remove that object on the NPC in the spell's script. Or is there any other way to disable an NPC's head or call some kind of redraw function?

Oh, and could someone yell at someone who works on the OBSE and get them to fix the setFemale function?


This is most likely more work than I'd like to do, but I also noticed something called NifSE, a NIF script editor. If anyone knows anything about this and a possible way to get it to fix my problem, I'm willing to hear it. But I'm pretty sure setFemale switches the NIF file correctly, it just never redraws it...


Edit: I tried taking advantage of the 72 hour bug, but this had the same effect as equipping clothing on the NPC (probably because that's what happened during the 72 hours).
User avatar
cassy
 
Posts: 3368
Joined: Mon Mar 05, 2007 12:57 am

Post » Tue May 17, 2011 5:59 am

Take a look at the spell in the Unofficial Oblivion Patch (UOP) for fixing the "double-face bug" after Fast Travel. That forces a remake of the NPC similar to what you're trying to do.
User avatar
Curveballs On Phoenix
 
Posts: 3365
Joined: Sun Jul 01, 2007 4:43 am

Post » Tue May 17, 2011 4:23 am

Take a look at the spell in the Unofficial Oblivion Patch (UOP) for fixing the "double-face bug" after Fast Travel. That forces a remake of the NPC similar to what you're trying to do.


WHY DIDN'T I THINK OF THAT?!? I am now happy to announce...mixed results... From studying UOP, it seems that moving an NPC to an unused Interior world and back again causes a total redraw effect. Unfortuanly, this causes the NPC to be redrawn with their old face, so you get a woman with man's head and vice versa. Not as gorily disturbing as the floating eyeballs and mouth, but disturbing none the less...

Here's the code so far...

scn TnegaSetFemaleScriptref myTargetBegin ScriptEffectStartset myTarget to GetSelfif ( myTarget.IsActor == 1 ) && ( myTarget.GetIsCreature == 0 )    if ( myTarget.IsInCombat == 0 ) && ( player.IsInCombat == 0 )        if myTarget.GetSitting == 0            if myTarget.GetKnockedState == 0                if myTarget.isFemale == 0                    myTarget.setFemale 1                else                    myTarget.setFemale 0                endif               TnegaTargetMarker.MoveTo myTarget                myTarget.Disable                myTarget.MoveTo TnegaChangeChest                myTarget.Enable                myTarget.MoveTo TnegaTargetMarker            else                Message "This spell cannot be used when the humanoid is knocked down."            endif        else            Message "This spell cannot be used when the humanoid is sitting on anything."        endif    else        Message "This spell cannot be used if the humanoid or player is in combat."    endifelse    Message "This spell cannot be used on a non-humanoid."endifEnd



So, how do I get it to redraw with the six correct head?!? Oh, and in case you were wondering, casting the spell a second time does not produce an opposite six head on an original six body. Instead the head just pretty much stays as the Creators made it, regardless of the six of the rest of the NPC.

Why can't these things ever just work right the first (or even second, third, fifth, or twentieth) time???
User avatar
Jake Easom
 
Posts: 3424
Joined: Sun Jul 29, 2007 4:33 am

Post » Tue May 17, 2011 2:45 am

I believe Vampirism does a head change, so maybe a vamp/devamp could be combined?
User avatar
^~LIL B0NE5~^
 
Posts: 3449
Joined: Wed Oct 31, 2007 12:38 pm

Post » Tue May 17, 2011 8:54 am

I believe Vampirism does a head change, so maybe a vamp/devamp could be combined?


Okay, well I got the vampirism thing to work...kind of. The NPC gets Vampire eyes (though they are NOT one themselves), but these revert to normal if you leave the cell and come back. The only trouble now is the hair. While looking for an obse function to mess with this, I discovered an article that states that NPC's can be "refreshed" (by which I assume they mean "redrawn") by calling disable and then enable one frame later. I tried this method via the console (closing it between commands so several frames could elapse), and it did refresh everything, except the hair!!! I'd like to use this method in place of my combined UOP/Vampire hack, since it's simpler and doesn't give the NPC temporary Vampire eyes. How, though, can I get my spell script to wait a frame between disable and enable? I mean, I understand frame and wait counting, but when I tried that it didn't work. The NPC disappeared and never reappeared. I'm thinking that the spell script gets called only once, so it's not active the next frame to do the enable command... I've done stuff like this before, but always with objects, who's script gets called every frame. Maybe that's the solution, if it isn't possible to get a spell scrip that lasts for more than one frame.

Here's my code so far:
scn TnegaSetFemaleScriptref myTargetref countBegin ScriptEffectStartset myTarget to GetSelfif ( myTarget.IsActor == 1 ) && ( myTarget.GetIsCreature == 0 )    if ( myTarget.IsInCombat == 0 ) && ( player.IsInCombat == 0 )        if myTarget.GetSitting == 0            if myTarget.GetKnockedState == 0                if ( count == 0 )                    if myTarget.isFemale == 0                        myTarget.setFemale 1                    else                        myTarget.setFemale 0                    endif                    myTarget.disable                    set count to 1                elseif ( count == 1 )                    myTarget.enable                    set count to 2                endif            else                Message "This spell cannot be used when the humanoid is knocked down."            endif        else            Message "This spell cannot be used when the humanoid is sitting on anything."        endif    else        Message "This spell cannot be used if the humanoid or you are in combat."    endifelse    Message "This spell cannot be used on a non-humanoid."endifEnd



And, of course, how do I fix the NPC's hair?!? It doesn't look bad all the time, but men don't look good with braids, nor women with bald spots...
User avatar
D LOpez
 
Posts: 3434
Joined: Sat Aug 25, 2007 12:30 pm

Post » Tue May 17, 2011 5:39 am

So, in short, the main thing I'd like help with is how to make a spell script that gets processed over multiple frames so that I can call a disable command one frame, and an enable command the next. If there was some sort of fix for the hair problem (switching from guy to girl hair and vice versa), that would be nice as well (though all my current research seems to suggest that permanent hair change for an NPC isn't something OBSE has accomplished yet)...
User avatar
Jonny
 
Posts: 3508
Joined: Wed Jul 18, 2007 9:04 am

Post » Tue May 17, 2011 12:48 am

Well the problem with your spell script is that your sciprt body is in a "ScriptEffectStart" block and not a "ScriptEffectUpdate" block.
User avatar
Julie Serebrekoff
 
Posts: 3359
Joined: Sun Dec 24, 2006 4:41 am

Post » Tue May 17, 2011 10:30 am

Well the problem with your spell script is that your sciprt body is in a "ScriptEffectStart" block and not a "ScriptEffectUpdate" block.


Thanks! Got that fixed, now if only there could be something done about the hair!

Here's my code:
scn TnegaSetFemaleScriptref myTargetref doOnceBegin ScriptEffectStartset myTarget to GetSelfif ( myTarget.IsActor == 1 ) && ( myTarget.GetIsCreature == 0 )	if ( myTarget.IsInCombat == 0 ) && ( player.IsInCombat == 0 )		if myTarget.GetSitting == 0			if myTarget.GetKnockedState == 0				if myTarget.isFemale == 0					myTarget.setFemale 1				else					myTarget.setFemale 0				endif				myTarget.disable			else				Message "This spell cannot be used when the humanoid is knocked down."			endif		else			Message "This spell cannot be used when the humanoid is sitting on anything."		endif	else		Message "This spell cannot be used if the humanoid or you are in combat."	endifelse	Message "This spell cannot be used on a non-humanoid."endifEndBegin ScriptEffectUpdateif ( doOnce == 0 )	myTarget.enable	set doOnce to 1endifEnd

User avatar
..xX Vin Xx..
 
Posts: 3531
Joined: Sun Jun 18, 2006 6:33 pm

Post » Tue May 17, 2011 9:13 am

con_sixChange is not an OBSE command, it's a console command that OBSE allows to be used in scripts.

Instead of teleporting the actor around/turning him into a vampire/disabling and enabling him, try using Update3D. If the hair remains a problem or it otherwise doesn't work tell me and I'll look into it.
User avatar
Katy Hogben
 
Posts: 3457
Joined: Mon Oct 30, 2006 12:20 am


Return to IV - Oblivion