Is there a way I can script a switch of an NPC or the player

Post » Tue Jun 19, 2012 11:50 am

Basically I'm working on an idea for a mod which involves a "disguise spell", to make the player look like another playable race (and I've got ideas for a sort of "look like a rock" spell as a lower ranked version), my overall plan's to try and mod a stealth related spell for every school of magic). I've written this script which does the job

Scriptname DisguisePlayer extends ActiveMagicEffect  {"disguises" player by making them the target race while active}	Race Property TargetRace  Auto  ;Race to "disguise" player as.	Race PlayerRace ;Internal value to store player's race while effect's active.	Event OnEffectStart(Actor akTarget, Actor akCaster)	;When the effect becomes active		PlayerRace = Game.GetPlayer().GetRace() ;Store player's race for later		akTarget.SetRace(TargetRace) ;set player's race as target race	EndEvent	Event OnEffectFinish(Actor akTarget, Actor akCaster)	;when the effect ends		akTarget.SetRace(PlayerRace) ;set player's race as their original race, as set in the start event.	EndEvent

As the comments note, on activation it stores the target's race (since it involved the player, I've written that but it should work equally well on an NPC, although I haven't tested that) and switches it to the target race (given by a property) and on finishing it returns their race to its original value.

I've hooked it up to an enchantment, attached that to a piece of armour and said armour makes the player character the target race while they have it equipped as I intended, but the problem is it also changes the racial abilities. Obviously this gets in the way of the idea that it's just a disguise so I was wondering if anyone knows a way I can change the NPC's race without changing their abilities (obviously this isn't much of a difference, but it feels sloppy not doing anything about it)?

EDIT: I've also encountered some more problems after using it to create a spell effect/enchantment and applied it to the robe (see the mod in my signature);
  • I've found that characters still keep their skin tone (which obviously looks off, particularly with Dunmer). Is there a way I can make the script change it manually?
  • Also, I've found that the character models don't always mesh with the robe (possibly because they get switched to the new model but since the robe's already equipped it doesn't fit).
User avatar
Chris Jones
 
Posts: 3435
Joined: Wed May 09, 2007 3:11 am

Post » Tue Jun 19, 2012 7:47 am

just wanted to give you a thumbs up for this idea.
User avatar
Sammygirl
 
Posts: 3378
Joined: Fri Jun 16, 2006 6:15 pm

Post » Tue Jun 19, 2012 7:07 am

Thanks, I don't suppose you have any ideas though (short of hardcoding in a script to manually remove each set of abilities from the player's spell list and add their "normal" race's abilities).
User avatar
Barbequtie
 
Posts: 3410
Joined: Mon Jun 19, 2006 11:34 pm

Post » Tue Jun 19, 2012 5:18 am

Thanks, I don't suppose you have any ideas though (short of hardcoding in a script to manually remove each set of abilities from the player's spell list and add their "normal" race's abilities).
That's what you'll have to do. Why don't you want to do that? It's not exactly very obtrusive or hard to code.
User avatar
marie breen
 
Posts: 3388
Joined: Thu Aug 03, 2006 4:50 am

Post » Tue Jun 19, 2012 7:17 am

That's what you'll have to do. Why don't you want to do that? It's not exactly very obtrusive or hard to code.

I know, but it just feels clunky (and rather precarious; one error running the script and the player's character's going to be completly messed up.

Also, I've encountered some more problems, which I've added to the original post.
User avatar
quinnnn
 
Posts: 3503
Joined: Sat Mar 03, 2007 1:11 pm

Post » Mon Jun 18, 2012 11:56 pm

I know, but it just feels clunky (and rather precarious; one error running the script and the player's character's going to be completly messed up.
It's not clunky at all. Indeed, that's how a lot of scripts function. It happens so quickly and cleanly that you honestly have nothing to worry about. True, this removes compatibility for custom races, but I can't really think of another alternative, and it's better than manually removing racial abilities from the races within the editor.

And if you think that's clunky, man oh man would my code give you nightmares.
User avatar
Symone Velez
 
Posts: 3434
Joined: Thu Sep 07, 2006 12:39 am

Post » Tue Jun 19, 2012 8:03 am

It's not clunky at all. Indeed, that's how a lot of scripts function. It happens so quickly and cleanly that you honestly have nothing to worry about. True, this removes compatibility for custom races, but I can't really think of another alternative, and it's better than manually removing racial abilities from the races within the editor.

And if you think that's clunky, man oh man would my code give you nightmares.

Point taken.

By the way, I don't suppose you've got any suggestions for the issues I added to the OP?
User avatar
Siidney
 
Posts: 3378
Joined: Fri Mar 23, 2007 11:54 pm

Post » Tue Jun 19, 2012 5:59 am

Point taken.

By the way, I don't suppose you've got any suggestions for the issues I added to the OP?
Hmmm, that doesn't sound good. I'm honestly just as lost as you are regarding this, but I figured my problems were due to it being a custom race. I've been messing around with changing the players race as well, and it's not really working right. In my case, the race is a custom one, and doesn't actually change the players "appearance" at all.

It would seem that as though there could be some issues with the "SetRace" command. However I'm puzzled because using "setrace" within the console appears to work perfectly; it's just the scripting one that isn't working as intended.
User avatar
David John Hunter
 
Posts: 3376
Joined: Sun May 13, 2007 8:24 am

Post » Tue Jun 19, 2012 7:13 am

Hmm, I've just gone into my saved games and tried it out. I've found that the same glitch is occuring with both console commands and the scripted items (disappearing heads for Nords being the most obvious one).

I think the lack of a change in skin tone might be a seperate issue though (possibly that it's not set as part of the race's appearence, just that characters created as a given race are done so with a given tone, although that might be wrong).
User avatar
Lory Da Costa
 
Posts: 3463
Joined: Fri Dec 15, 2006 12:30 pm

Post » Tue Jun 19, 2012 5:37 am

Have you looked at the werewolf scripts? I think they work through a change race function and fiddle with the player's abilities.
User avatar
Rebekah Rebekah Nicole
 
Posts: 3477
Joined: Fri Oct 13, 2006 8:47 pm

Post » Tue Jun 19, 2012 6:03 am

Have you looked at the werewolf scripts? I think they work through a change race function and fiddle with the player's abilities.
See that's what I don't get. There's nothing overly special about the Werewolf script. It uses "SetRace" to change the player to the werewolf race. There's nothing extra done other than playing some spell effects.

EDIT: Hmm, I may be wrong on that actually. I'll post back after I do some testing.
User avatar
rebecca moody
 
Posts: 3430
Joined: Mon Mar 05, 2007 3:01 pm

Post » Tue Jun 19, 2012 10:10 am

Technically I think werewolf spells have a special "werewolf" base effect (although I tried that first and found it didn't work).
User avatar
c.o.s.m.o
 
Posts: 3419
Joined: Sat Aug 12, 2006 9:21 am

Post » Tue Jun 19, 2012 3:46 am

Technically I think werewolf spells have a special "werewolf" base effect (although I tried that first and found it didn't work).
Indeed. There is a werewolf magic effect that uses the "archetype" werewolf, but it also specifies the werewolf race as the associated item. It's possible that changing that to the desired race will do the trick.
User avatar
Dan Scott
 
Posts: 3373
Joined: Sun Nov 11, 2007 3:45 am

Post » Tue Jun 19, 2012 12:01 pm

Unfortunately not it seems. All this accomplished for me was disabling menu usage.

A lot of the functions used in the werewolf script and werewolf transformation are hard coded, which really svcks if you want to accomplish something similar. :/
User avatar
RaeAnne
 
Posts: 3427
Joined: Sat Jun 24, 2006 6:40 pm

Post » Tue Jun 19, 2012 4:02 am

Yeah, I'm starting to think that this might be down to some sort of graphical glitch (since testing with the default Dovakiin worked fine, but the glitches appeared with an actual character...).
User avatar
Everardo Montano
 
Posts: 3373
Joined: Mon Dec 03, 2007 4:23 am


Return to V - Skyrim