setplayerskeletonpath on NPCs?

Post » Sat Feb 19, 2011 1:16 am

EDIT: Question finished. Thanks for all the help!

Is it possible to use the setplayerskeletonpath OBSE function on an NPC? Does the default work on NPCs, or is it only one the player as the name suggests? For those unfamiliar with setplayerskeleton path, it is an OBSE function with version 18+ and it's wiki page is http://cs.elderscrolls.com/constwiki/index.php/Setplayerskeletonpath (written by me)
User avatar
meghan lock
 
Posts: 3451
Joined: Thu Jan 11, 2007 10:26 pm

Post » Sat Feb 19, 2011 4:08 am

I'm not for sure and currently forget, but I think there is a separate "setNPCskeletonpath", for NPCs.

If in doubt, checkout the script used in the "Centaur" race mode by Da Mage:

http://tesalliance.org/forums/index.php?/files/file/775-the-oblivion-centaur-project/

He has both NPC centaurs, and also an esp to enable "player" centaurs.

Koniption
User avatar
Queen Bitch
 
Posts: 3312
Joined: Fri Dec 15, 2006 2:43 pm

Post » Sat Feb 19, 2011 3:19 am

Yep, no "SetNPCskeletonpath" found. Besides, Da Mage probably set the skeleton on the npc tab, not through script.
I've seen TalkieToaster with a mod that changes, or atleast looks like it changes the skeleton path through a spell. Will check it out or ask TalkieToaster how they did it...
User avatar
elliot mudd
 
Posts: 3426
Joined: Wed May 09, 2007 8:56 am

Post » Fri Feb 18, 2011 10:18 pm

To change if for an NPC is quite easy.....that function is for the special case of the player, which cannot be disabled.

this is a segment of code I wrote up a while back that changes an NPC's skeleton:
string_var tempstring  ref temp  short refresh  float timer    begin onactivate          set temp to AdrienneBerene          set tempstring to sv_construct "Characters\_Male\Skeleton2.NIF "          SetModelPathex $tempstring temp          set refresh to 1  end    begin gamemode  if refresh == 2          if timer > 0.0001                  superref.enable                  set refresh to 0          else                  set timer to timer + getsecondspassed          endif  elseif refresh == 1          superref.disable          set refresh to 2  endif  end


The Theory:
Use the generic function SetModelPathEx on a NPC base Id, this causes it to access to skeleton path. Change it and then you need to refresh the NPC, to do that you need to disable them for a frame and then enable them again. In my example the NPC AdrienneBerene has a reference ID 'superref'.....but thats just so the code doesnt get any more complicated.
User avatar
Campbell
 
Posts: 3262
Joined: Tue Jun 05, 2007 8:54 am

Post » Fri Feb 18, 2011 8:54 pm

Thank You!
Will try.
User avatar
Flutterby
 
Posts: 3379
Joined: Mon Sep 25, 2006 11:28 am

Post » Fri Feb 18, 2011 10:35 pm

Thank You!
Will try.

Newer versions of OBSE (since 0019, I think?) make it easier:
npcRef.SetModelPath "whatever"npcRef.update3D; done

User avatar
Smokey
 
Posts: 3378
Joined: Mon May 07, 2007 11:35 pm

Post » Sat Feb 19, 2011 11:11 am

Newer versions of OBSE (since 0019, I think?) make it easier:
npcRef.SetModelPath "whatever"npcRef.update3D; done



oh, thats a handy little function :)
User avatar
DarkGypsy
 
Posts: 3309
Joined: Tue Jan 23, 2007 11:32 am

Post » Sat Feb 19, 2011 12:50 am

Ok, I tried making a script, though I'm afraid there is some bugs in it. Would there be any noticable in this?
scn aaaRandomSkeletonScript  Short RandomShort Skeletonbegin onload          if random <= 50           set skeleton to 1        elseif random <= 65          set skeleton to 2     elseif random  <= 77          Set skeleton to 3     elseif random <= 85          Set skeleton to 4     elseif random <= 97          Set skeleton to 5     elseif random <= 100          set skeleton to 6   endifendbegin gamemode       if skeleton == 2        setmodelpath "Characters\_Male\Skeletonfat.NIF "           update3D       if skeleton == 3        setmodelpath"Characters\_Male\Skeletonthin.NIF "           update3D       if skeleton == 4        setmodelpath "Characters\_Male\Skeletonanorexic.NIF "           update3D       if skeleton == 5        setmodelpath "Characters\_Male\SkeletonOverweight.NIF "           update3D       if skeleton == 6        setmodelpath "Characters\_Male\Skeletonhunched.NIF "           update3D   endifend 


Also, how does the end block structure work. I've seen some cases where a lot are used, so how do I tell. I keep getting that message.
User avatar
Jhenna lee Lizama
 
Posts: 3344
Joined: Wed Jun 06, 2007 5:39 am

Post » Sat Feb 19, 2011 8:40 am

I dont have oblivion on hand to actually compile it but, the obvious error is that you have too many 'if' statements, other then the first one, they should be 'elseif'. Rule of thumb, for every 'if' there needs to be an 'endif'. Like so:

begin gamemode        if skeleton == 2         setmodelpath "Characters\_Male\Skeletonfat.NIF"            update3D        elseif skeleton == 3         setmodelpath"Characters\_Male\Skeletonthin.NIF"            update3D        elseif skeleton == 4         setmodelpath "Characters\_Male\Skeletonanorexic.NIF"            update3D        elseif skeleton == 5         setmodelpath "Characters\_Male\SkeletonOverweight.NIF"            update3D        elseif skeleton == 6         setmodelpath "Characters\_Male\Skeletonhunched.NIF"            update3D    endif end 

User avatar
Madison Poo
 
Posts: 3414
Joined: Wed Oct 24, 2007 9:09 pm

Post » Sat Feb 19, 2011 12:52 am

Heh... I forgot about that :facepalm:
So I tried it, and it does randomly select one of the listed skeletons. Though I have come into a big of trouble. The npc don't show up. They cannot be seen and interacted with, even with just pointing the cursor at them. They turn visible with the correct skeleton if I pause the game or press the ~ button. Any ideas on what could be happening?
User avatar
Marine Arrègle
 
Posts: 3423
Joined: Sat Mar 24, 2007 5:19 am

Post » Sat Feb 19, 2011 1:52 am

Yep, the gamemode keeps running.

easy fix, just put an if in to make sure it only runs once:

scn aaaRandomSkeletonScript Short RandomShort SkeletonShort doonce begin onload      	if random <= 50  		set skeleton to 1	elseif random <= 65		set skeleton to 2	elseif random  <= 77		set skeleton to 3	elseif random <= 85		set skeleton to 4	elseif random <= 97		set skeleton to 5	elseif random <= 100 		set skeleton to 6 	endif end  begin gamemode	if doonce == 0		if skeleton == 2			setmodelpath "Characters\_Male\Skeletonfat.NIF"    			update3D		elseif skeleton == 3			setmodelpath"Characters\_Male\Skeletonthin.NIF"    			update3D 		elseif skeleton == 4			setmodelpath "Characters\_Male\Skeletonanorexic.NIF"    			update3D 		elseif skeleton == 5			setmodelpath "Characters\_Male\SkeletonOverweight.NIF"    			update3D 		elseif skeleton == 6			setmodelpath "Characters\_Male\Skeletonhunched.NIF"    			update3D		endif	set doonce to 1	endifend 

User avatar
Shae Munro
 
Posts: 3443
Joined: Fri Feb 23, 2007 11:32 am


Return to IV - Oblivion