Jump to content

NPC transformation script


LurkerGG

Recommended Posts

So with the assistance of several other scripts I found I have been working on getting a script/spell to work that will allow a npc to transform (like the werewolf, master of shapes and other polymorph spells)

 

I admit this is a Frankenstein's monster of a script. I used parts of two different scripts. Removing certain parts (like the disabling of player abilities, dont want it to stop the player from going into their menu when a NPC transforms) and editing others to target the caster. I still am learning the basics of scripting in papyrus and the best way I learn is by doing. So I apologize if this is a nightmare to follow or there are really obvious issues.

 

Now since this is a combat oriented ability I want the spell to force the npc to equip a certain weapon, armor or spell. Once the effect is over the items are uneqipped and removed. I was planning on making the items work like the untradable/seeable follower hunter bow and iron arrow to prevent the player from getting them.

 

I plan for the transformation to work on the npc as a perk that activates either when they reach a certain level (YOUR LYDIA IS EVOLVING) or once combat starts. I have the chain looking like this; magic effect -> spell_fx -> magic effect cloak -> ability -> perk.

 

At this point the script is compiling with no errors but I am not sure if it works yet. It could be the spell works but the npcs wont activate it since they do not need to.

 

Here is the script. Thanks to both jaredbangerter (http://jaredbangerter.hubpages.com/hub/How-to-Create-New-Shape-Shifting-Spells-In-Skyrim#lastcomment) and zigurd88 for their scripts. I used jaredbangerter's script for the equip options and Zigurd88's script that works without having to complete the companion quest chain.

 

 Scriptname NPCpolymorphscript extends activemagiceffect  
{NPC transformation script}

Spell Property PolymorphSpell auto

FormList Property WerewolfDispelList auto

Race Property PolymorphRace auto

Race Property castersOriginalRace auto

Weapon Property MonsterWeapon auto

Explosion Property EndExplosion auto

ImageSpaceModifier Property ChangeFX auto

Idle Property IdleWerewolfTransformation auto

; EVENTS


Event OnEffectStart(Actor Target, Actor Caster)

; Debug.Trace("Trying to transform something that's not an actor; bailing out.", 2)
return

if (Target.GetActorBase().GetRace() != PolymorphRace)

GetCasterActor().UnequipAll()

GetCasterActor().PlayIdle(IdleWerewolfTransformation)

PrepShift()

Utility.Wait(1.5)

Game.ShakeCamera(afStrength = 0.5,afDuration = 1)

GetCasterActor().placeAtMe(EndExplosion)

GetCasterActor().SetRace(PolymorphRace)

GetCasterActor().AddSpell(SPELLCLEAR1)

GetCasterActor().EquipSpell(SPELLCLEAR1, 0)

GetCasterActor().AddSpell(SPELLCLEAR2)

GetCasterActor().EquipSpell(SPELLCLEAR2, 1)

GetCasterActor().AddItem(WEAPONCLEAR1)

GetCasterActor().EquipItem(WEAPONCLEAR1, 0)

GetCasterActor().AddItem(WEAPONCLEAR2)

GetCasterActor().EquipItem(WEAPONCLEAR2, 1)

GetCasterActor().EquipSpell(PolymorphSpell, 0)

GetCasterActor().AddSpell(PolymorphSpell)

GetCasterActor().EquipSpell(PolymorphSpell, 0)

GetCasterActor().AddItem(MonsterWeapon)

GetCasterActor().EquipItem(MonsterWeapon, 0)

GetCasterActor().AddItem(MonsterArmor)

GetCasterActor().EquipItem(MonsterArmor)

AnimationEnd()
endif

EndEvent



Event OnEffectFinish(Actor Target, Actor Caster)

; change back
if (Target == None)
; Debug.Trace("Trying to transform something that's not an actor; bailing out.", 2)
return

endif

Target.placeAtMe(EndExplosion)

ChangeFx.Apply()

GetCasterActor().SetRace(castersOriginalRace)

GetCasterActor().RemoveSpell(PolymorphSpell)

GetCasterActor().UnEquipSpell(PolymorphSpell, 1)

GetCasterActor().RemoveItem(MonsterWeapon)

GetCasterActor().UnEquipItem(MonsterWeapon, 0)

GetCasterActor().RemoveItem(MonsterArmor)

GetCasterActor().UnEquipItem(MonsterArmor)

GetCasterActor().AddSpell(SPELLCLEAR1)

GetCasterActor().EquipSpell(SPELLCLEAR1, 0)

GetCasterActor().AddSpell(SPELLCLEAR2)

GetCasterActor().EquipSpell(SPELLCLEAR2, 1)

GetCasterActor().AddItem(WEAPONCLEAR1)

GetCasterActor().EquipItem(WEAPONCLEAR1, 0)

GetCasterActor().AddItem(WEAPONCLEAR2)

GetCasterActor().EquipItem(WEAPONCLEAR2, 1)

endEvent

Function AnimationEnd()

EndFunction

Function PrepShift()
; Debug.Trace("WEREWOLF: Prepping shift...")
Actor player = GetCasterActor()

int count = 0
while (count < WerewolfDispelList.GetSize())
Spell gone = WerewolfDispelList.GetAt(count) as Spell
if (gone != None)
GetCasterActor().DispelSpell(gone)
endif
count += 1
endwhile

EndFunction

Armor Property MonsterArmor Auto

SPELL Property SPELLCLEAR1 Auto


SPELL Property SPELLCLEAR2 Auto


WEAPON Property WEAPONCLEAR1 Auto


WEAPON Property WEAPONCLEAR2 Auto 

Edited by LurkerGG
Link to comment
Share on other sites

You might want to explain exactly what's wrong, and it helps visibility to put your script inside [ code ] [ /code ] tags.

 

Exactly how is this spell being cast? Is it a self-targeting spell or what? You have if statements checking the spell target but all the commands are used on the spell caster.

Link to comment
Share on other sites

  On 4/6/2012 at 1:05 AM, fg109 said:

You might want to explain exactly what's wrong, and it helps visibility to put your script inside [ code ] [ /code ] tags.

 

Exactly how is this spell being cast? Is it a self-targeting spell or what? You have if statements checking the spell target but all the commands are used on the spell caster.

 

I intended the spell to be either always effecting the target or be during combat.

 

The problem is that it is not activating at all ingame. Since my first post I have been trying different setting and right now the magic effect that has the script on it has the following

 

The first magic effect that has the script has the following settings; archetype "werewolf", Casting type "fire and forget", delivery "self", magicskill none and min skill 0. The assoc. item 1 is set to the npc test race I made (copy and minor change to the dremora race)

 

Taper duration is set to 50 and other options are set to 0.

 

Flags active are "no recast" and "no area"

 

The magic effect is then put onto an ability and given the conditions of "get level" >= 1 and run on subject. the duration on the ability was given 1 minute just incase having no duration there would cause issues. The ability is then given the equip type none and the auto calculate for charge time and such is turned off.

 

I then have the ability attached to a perk, under perk entries I simply selected the ability from the list and added it.

 

I hope that provides more details on how exactly I am attempting to get the transformation to work.

Link to comment
Share on other sites

I don't see anything wrong with the script, so the problem is probably something else. First of all, did you hook up the properties correctly? If you don't know how, check the tutorial.

 

If you did, did you try using a clean save?

 

If that doesn't do anything either, maybe there's something wrong with the way you set up your ability. Try just using this as a script in order to test whether or not you set things up properly:

 

Scriptname NPCpolymorphscript extends activemagiceffect

Event OnEffectStart(Actor akTarget, Actor akCaster)
Debug.Notification("Magic effect start.")
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
Debug.Notification("Magic effect finish.")
EndEvent

Link to comment
Share on other sites

  On 4/6/2012 at 2:52 AM, fg109 said:

I don't see anything wrong with the script, so the problem is probably something else. First of all, did you hook up the properties correctly? If you don't know how, check the tutorial.

 

If you did, did you try using a clean save?

 

If that doesn't do anything either, maybe there's something wrong with the way you set up your ability. Try just using this as a script in order to test whether or not you set things up properly:

 

Scriptname NPCpolymorphscript extends activemagiceffect

Event OnEffectStart(Actor akTarget, Actor akCaster)
Debug.Notification("Magic effect start.")
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
Debug.Notification("Magic effect finish.")
EndEvent

 

 

Thank you so much :) I have a feeling it might be a clean save issue >.< I just tested to see if lydia would change to reflect the changes I made on the mode and they did not until I turned the mod on and off.

 

To my knowledge I was setting up the properties as they should have been. I will go over the tutorial you linked just encase.

 

I will try the script you provided as well and get back with the results as soon as I can.

 

thank you again :)

Link to comment
Share on other sites

Ok so the script you provided worked the moment I entered or left the building or area as lydia was in. I got the messages magic effect start and magic effect finish. This happened in my current save and a much much older save I had.

 

I will try the original script again with the older save I have and a clean save. See if that may have been an issue.

Link to comment
Share on other sites

Ok I figured it out, it was something in the script.

 

 ; Debug.Trace("Trying to transform something that's not an actor; bailing out.", 2)
return 

 

Was causing it to stop and not function and all. I will do further testing but once I am sure I have it down I will post the final script.

 

Thanks again man for the assist :)

Link to comment
Share on other sites

So here is the working script. Clean saves are your friend when testing mods that use this script.

 

 Scriptname NPCpolymorphscript extends activemagiceffect  
{NPC transformation script}

Spell Property PolymorphSpell auto

FormList Property WerewolfDispelList auto

Race Property PolymorphRace auto

Race Property TargetsOriginalRace auto

Weapon Property MonsterWeapon auto

Explosion Property EndExplosion auto

ImageSpaceModifier Property ChangeFX auto

Idle Property IdleWerewolfTransformation auto

; EVENTS


Event OnEffectStart(Actor Target, Actor Caster)

TargetsOriginalRace = Target.GetActorBase().GetRace()

if (Target.GetActorBase().GetRace() != PolymorphRace)

Debug.Notification("Magic effect start.")

GetTargetActor().UnequipAll()

GetTargetActor().PlayIdle(IdleWerewolfTransformation)

PrepShift()

Utility.Wait(1.5)

Game.ShakeCamera(afStrength = 0.5,afDuration = 1)

GetTargetActor().placeAtMe(EndExplosion)

GetTargetActor().SetRace(PolymorphRace)

GetTargetActor().AddSpell(SPELLCLEAR1)

GetTargetActor().EquipSpell(SPELLCLEAR1, 0)

GetTargetActor().AddSpell(SPELLCLEAR2)

GetTargetActor().EquipSpell(SPELLCLEAR2, 1)

GetTargetActor().AddItem(WEAPONCLEAR1)

GetTargetActor().EquipItem(WEAPONCLEAR1, 0)

GetTargetActor().AddItem(WEAPONCLEAR2)

GetTargetActor().EquipItem(WEAPONCLEAR2, 1)

GetTargetActor().EquipSpell(PolymorphSpell, 0)

GetTargetActor().AddSpell(PolymorphSpell)

GetTargetActor().EquipSpell(PolymorphSpell, 0)

GetTargetActor().AddItem(MonsterWeapon)

GetTargetActor().EquipItem(MonsterWeapon, 0)

GetTargetActor().AddItem(MonsterArmor)

GetTargetActor().EquipItem(MonsterArmor)

AnimationEnd()
Endif

EndEvent

Event OnEffectFinish(Actor Target, Actor Caster)

Target.placeAtMe(EndExplosion)

ChangeFx.Apply()

GetTargetActor().SetRace(TargetsOriginalrace)

GetTargetActor().RemoveSpell(PolymorphSpell)

GetTargetActor().UnEquipSpell(PolymorphSpell, 1)

GetTargetActor().RemoveItem(MonsterWeapon)

GetTargetActor().UnEquipItem(MonsterWeapon, 0)

GetTargetActor().RemoveItem(MonsterArmor)

GetTargetActor().UnEquipItem(MonsterArmor)

GetTargetActor().AddSpell(SPELLCLEAR1)

GetTargetActor().EquipSpell(SPELLCLEAR1, 0)

GetTargetActor().AddSpell(SPELLCLEAR2)

GetTargetActor().EquipSpell(SPELLCLEAR2, 1)

GetTargetActor().AddItem(WEAPONCLEAR1)

GetTargetActor().EquipItem(WEAPONCLEAR1, 0)

GetTargetActor().AddItem(WEAPONCLEAR2)

GetTargetActor().EquipItem(WEAPONCLEAR2, 1)

Debug.Notification("Magic effect finish.")

endEvent

Function AnimationEnd()

EndFunction

Function PrepShift()
; Debug.Trace("WEREWOLF: Prepping shift...")
Actor player = GetCasterActor()

int count = 0
while (count < WerewolfDispelList.GetSize())
Spell gone = WerewolfDispelList.GetAt(count) as Spell
if (gone != None)
GetTargetActor().DispelSpell(gone)
endif
count += 1
endwhile

EndFunction

Armor Property MonsterArmor Auto

SPELL Property SPELLCLEAR1 Auto


SPELL Property SPELLCLEAR2 Auto


WEAPON Property WEAPONCLEAR1 Auto


WEAPON Property WEAPONCLEAR2 Auto [/Code]

Edited by LurkerGG
Link to comment
Share on other sites

  • 4 years later...
  • 4 months later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...