bbslayer7 Posted June 10, 2012 Share Posted June 10, 2012 I need help creating a script that transforms the player into Zigurd88's Demon Form when your health goes below 20% or 10% while wearing an armor with a scripted magic effect. Oh and this is a private modification as I don't have permission to upload. Here's what I want it to do (in order)1. When the player's health goes below 20% make the player invulnerable.2. Immediately after that fully restore the player's health.3. Add the DemonChange magic effect to the player.4. After the transformation is complete disable the player's invulnerability.5. After Demon Form wears off restore player's health to full and reset the script so if the player's health goes below 20% it'll start all over again. I could script just about anything in fallout, but papyrus just seems so much more complicated. I just can't quite wrap my head around it. I have tried using the avoid death perk's script as a base to go off of but this here is all I got... Scriptname DemonTransformationScript extends ActiveMagicEffect Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked ) PercentHealth = GetTargetActor().GetAVPercentage("Health") If PercentHealth < 0.1 If (Game.GetPlayer().HasMagicEffect(RockjointEffect)) PlayerProperty.SetInvulnerable(true) HealSpell.Cast(GetTargetActor()) DemonSpell.Cast(GetTargetActor()) InvicibleTimer.SetValue + 1.0 EndIf EndIf endEvent Spell Property HealSpell Auto Spell Property DemonSpell Auto float Property PercentHealth = 100.0 Auto GlobalVariable Property InvicibleTimer Auto Ref Property PlayerProperty Auto I wish I could just use player.setinvulnerable but I doubt that works with papyrus. Well that's what I got so far doubt it's right but I'm not sure where to go from here. Link to comment Share on other sites More sharing options...
RandomlyAwesome Posted June 10, 2012 Share Posted June 10, 2012 (edited) Edit:If I understand the percantage part(it being between 0 and 1 instead of 0 and 100 always confused me) it should activate at 10%.While I'm not an expert or anything this should work just replace Demonform effect with whatever the name of the effect for demon form is and put the script in a magiceffect(and an enchantment I suppose). By the way the mods page says that you can upload any updates/improvements if you credit the author(Zigurd88) Scriptname DemonTransformationScript extends ActiveMagicEffect Function Toggle EndFunction Bool isdemon =False Spell Property HealSpell Auto Spell Property DemonSpell Auto float Property PercentHealth = 100.0 Auto GlobalVariable Property InvicibleTimer Auto Ref Property PlayerProperty Auto Auto State Humanform isdemon = False PercentHealth = GetTargetActor().GetAVPercentage("Health") If PercentHealth <0.1 Function Toggle() GoToState("Transformation") EndFunction EndIf EndState State Transformation if isdemon == False PlayerProperty.SetInvulnerable(true) HealSpell.Cast(GetTargetActor()) DemonSpell.Cast(GetTargetActor()) Function Toggle() GoToState("Demonform") EndFunction ElseIf isdemon == True HealSpell.Cast(GetTargetActor()) Function Toggle() GoToState("Humanform") EndFunction EndIf EndState State Demonform isdemon = True playerproperty.SetInvulnerable(False) if (Game.GetPlayer().HasMagicEffect(DemonFormEffect)) Else Function Toggle() GoToState("Transformation") EndFunction EndIf EndState Edited June 10, 2012 by RandomlyAwesome Link to comment Share on other sites More sharing options...
bbslayer7 Posted June 10, 2012 Author Share Posted June 10, 2012 doesn't seem to be working I can't change the spell properties and I'm getting these 2 errors when saving. c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DemonTransformationScript.psc(2,23): mismatched input '\\r\\n' expecting LPAREN c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\DemonTransformationScript.psc(0,0): error while attempting to read script DemonTransformationScript: Object reference not set to an instance of an object. Link to comment Share on other sites More sharing options...
RandomlyAwesome Posted June 10, 2012 Share Posted June 10, 2012 (edited) This should at least compile by the way isn't this a bit to overpowered(since it technically stops you from dying) would you want me to add a cooldown or something if this one worksScriptname DemonTransformationScript extends ActiveMagicEffect Spell property Heal Auto Float Property HealthPercentage = 1.0 Auto Spell Property Demonformspell Auto Bool isdemon = false Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked ) HealthPercentage = GetTargetActor().GetAVPercentage("Health") If isdemon == False If Healthpercentage <0.1 Heal.Cast(Game.GetPlayer(),Game.GetPlayer()) Demonformspell.Cast(Game.GetPlayer(),Game.GetPlayer()) isdemon = True EndIf ElseIf isdemon == True If (Game.GetPlayer().HasMagicEffect(DemonFormEffect)) Else Heal.Cast(Game.GetPlayer(),Game.GetPlayer()) isdemon = False EndIf EndIf EndEvent Edited June 10, 2012 by RandomlyAwesome Link to comment Share on other sites More sharing options...
bbslayer7 Posted June 10, 2012 Author Share Posted June 10, 2012 Yeah it is a little overpowered, but that's kind of what I was going for. With this armor you could roleplay as a chaos god from the warhammer 40000 series (at least that's what I was going to do). I thought it'd really only make sense that you could only die in demon form. As for a cooldown that just wouldn't seem right for a chaos god to have to wait to use its powers again. So I was thinking as way to balance it a little I'd stick this enchantment on either a set of clothes or an armor set with very low defense, that's all I could think of. Link to comment Share on other sites More sharing options...
fg109 Posted June 10, 2012 Share Posted June 10, 2012 (edited) I've noticed that when switching races on an NPC, any magic effect is re-applied. Does the demon form spell change the player's race? Because then there will be a problem in using a magic effect script to do this. Because if it gets re-applied, then the variables are re-initialized and so you won't be able to track whether or not you're in demon form properly. Edited June 10, 2012 by fg109 Link to comment Share on other sites More sharing options...
RandomlyAwesome Posted June 10, 2012 Share Posted June 10, 2012 (edited) EDIT:fixed somthingYeah Fg is right it replaces the race so.....Use this script instead Scriptname DemonTransformationScript extends ActiveMagicEffect Spell property Heal Auto Float Property HealthPercentage = 1.0 Auto Spell Property Demonformspell Auto Bool isdemon = false Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked ) HealthPercentage = Game.GetPlayer().GetActorValuePercentage("health") If isdemon == False If Healthpercentage >0.1 Heal.Cast(Game.GetPlayer(),Game.GetPlayer()) Demonformspell.Cast(Game.GetPlayer(),Game.GetPlayer()) isdemon = True EndIf ElseIf isdemon == True If (Game.GetPlayer().GetRace(PolymorphRace)) Else Heal.Cast(Game.GetPlayer(),Game.GetPlayer()) isdemon = False EndIf EndIf EndEvent Edited June 10, 2012 by RandomlyAwesome Link to comment Share on other sites More sharing options...
fg109 Posted June 10, 2012 Share Posted June 10, 2012 Actually, I just tested in the game and the magic effect is re-applied if it was on an ability. Having it as an enchantment on a ring, the magic effect is not re-applied, so it should track the variables properly. Link to comment Share on other sites More sharing options...
Recommended Posts