Making followers turn into a werewolf when you do

Post » Mon Nov 19, 2012 1:03 pm

I want to make one of my characters in to a follower. He's a werewolf, so I want him to morph in to a werewolf when the player does. I've seen this done with all of the Companions, so I know it's possible. Does anyone know how?
User avatar
Sunny Under
 
Posts: 3368
Joined: Wed Apr 11, 2007 5:31 pm

Post » Mon Nov 19, 2012 8:03 am

There are two steps: 1) getting informed when the player transforms and 2) transforming the follower.

For 1, you have a few options. In your NPC's script, you could create a RegisterForUpdate loop that checks the PC and sees if they are a werewolf and change the NPC accordingly. However loops like this create uninstallation issues. Even when somone disables and removes your mod, the loop will keep running.

You can mitigate the constant running loop by designing your code so that the loop only runs during combat. You can add an OnCombatChange handler to your NPC and only monitor the Player with a loop during combat. You will also have to add some conditions to figure out when combat is over. The downside of this approach is the follower wont change if the player changes outside combat.

The best way to do it (but more involved) is to create a quest and add 2 aliases. One alias points at your NPC and the other alias Points at the player. The player alias should have a script attacjed that receives the OnRaceChangeComplete event. When the alias script gets the event, it checks if the player is werewold or human and and calls a quest script which enforces the change on the NPC via the other quest alias.

For 2, you add the werewolfchange spell to the npc and then cast the spell on the npc using werewolfchange.cast(npc). Changing back is a matter of assigning the NPC's race to the original race (werewolf change changes the NPC's race).

There are several mods out there that already support follower werewolf change.
User avatar
kirsty joanne hines
 
Posts: 3361
Joined: Fri Aug 18, 2006 10:06 am

Post » Mon Nov 19, 2012 10:12 am

The best way to do it (but more involved) is to create a quest and add 2 aliases. One alias points at your NPC and the other alias Points at the player. The player alias should have a script attacjed that receives the OnRaceChangeComplete event. When the alias script gets the event, it checks if the player is werewold or human and and calls a quest script which enforces the change on the NPC via the other quest alias.

For 2, you add the werewolfchange spell to the npc and then cast the spell on the npc using werewolfchange.cast(npc). Changing back is a matter of assigning the NPC's race to the original race (werewolf change changes the NPC's race).

There are several mods out there that already support follower werewolf change.
That quest method that you mentioned there using OnRaceSwitchComplete (I'm pretty sure that's what you meant, since I don't see any mention of an "OnRaceChangeComplete event" on the CK Wiki), I'm guessing that could somehow be adapted to play special music when the player is a werewolf.

So far I have the following, but I somehow doubt it will compile since there's probably a few things missing:
Spoiler

Race Property WerewolfBeastRace Auto

MusticType Property MUSUTOLM Auto

Event OnRaceSwitchComplete()
; Debug.Trace("This actor's race has finished changing")
; Check that player is a werewolf
if Race PlayerRace = Game.GetPlayer().GetRace(WerewolfBeastRace)
;Start the haunting music
MUSUTOLMWerewolf.Add()
endif
endEvent

Event OnRaceSwitchComplete()
; Debug.Trace("This actor's race has finished changing")
; Check that player is original race
if Race PlayerRace = Game.GetPlayer().GetRace(PlayerOriginalRace)
;Revert to normal music
MUSUTOLMWerewolf.Remove()
endif
EndEvent
I guess I'll have to start testing it and trying things in order to get it working in-game, and potentially have the whole thing blow up in my face and FUBAR the esp file. That is why you always keep back-ups of all your esp and script files.

Anyway, best of luck on the werewolf follower project. I don't mean to sidetrack the subject to that of getting music to play under certain circumstances. It's just that this is the first real lead I've gotten towards getting the music to play when you transform.

On another note, I have never seen the forum screw up before and include the HTML code in the visible post before. :rofl: It shouldn't be there anymore, hopefully. But now there is no name attached to the quote anymore. :facepalm:

And just as I thought, the script I posted does not quite work. Everything seems to compile except the get race part. Without using "if," it says there's too many arguments passed to function, and with "if," it says there's no viable alternative at input 'Race.' Everything else in the first event seems to be compiling (though that doesn't necessarily mean that it will work).
User avatar
A Boy called Marilyn
 
Posts: 3391
Joined: Sat May 26, 2007 7:17 am

Post » Mon Nov 19, 2012 12:05 pm

Spoiler

Race PlayerRace = Game.GetPlayer().GetRace()if (PlayerRace == WerewolfBeastRace)  ; do stuff, probably set bool indicating previous race was werewolfelse  ; check bool. If previously werewolf, turn off musicendif

Also, occasionally I have issues with the player filled aliases not getting filled if the quest is set to start game enabled. If you are not seeing events, let me know as there are ways to fix that particualr issue.
User avatar
[Bounty][Ben]
 
Posts: 3352
Joined: Mon Jul 30, 2007 2:11 pm


Return to V - Skyrim