Jump to content

Photo

Scripting Issues - Resistance scaling with Dragon Souls

scripting papyrus skyrim dragon dragon souls resistance fire resistance frost resistance problem help

  • Please log in to reply
4 replies to this topic

#1
DOCac42

DOCac42

    Newbie

  • Members
  • Pip
  • 10 posts

Hi,

 

I'm pretty comfortable with changing values/models and other basic things in the CK, but I've recently started trying to script.

 

I plan to have my armour chest piece with a unique effect. I'd like to have it so that, for every dragon soul you have, gain 10% frost and fire resistance (up to a max of 90%) It would be dynamic, so that, if I had 7 souls, I'd have 70% resistance, but if I used one, it'd go down to 60%.

 

Thing is, I can't figure out the script, I'm completely stuck, I have everything else made and ready to go, just the effect for the chest piece left and I can't for the life of me figure it out!

 

I've been reading guides and watching videos, searching the forums and I can't figure out how to get the player's fire and frost resistance to scale with each dragon soul.

 

Any help is greatly appreciated.


Edited by DOCac42, 30 March 2015 - 08:17 PM.


#2
newzilla7

newzilla7

    Enthusiast

  • Supporter
  • PipPip
  • 119 posts
Try using this:

float resistVal = Game.GetPlayer().GetAV("dragonsouls") * 100;

if (resistVal > 90)
    resistVal = 90;
endif

Game.GetPlayer().SetAV("frostresist", resistVal);
You'll want this block within the OnUpdate() portion of your script. Make sure you know what you're doing with OnUpdate; it can quickly become messy and buggy if you don't use clean modding techniques.

Edited by newzilla7, 31 March 2015 - 06:16 PM.


#3
DOCac42

DOCac42

    Newbie

  • Members
  • Pip
  • 10 posts

Ok, after three days of messing around with papyrus and trying to get this to work, I've narrowed down my problems.

 

The main issue is that the spell I've created is not being cast when I equip the armour.

ScriptName AATArmorScript extends ObjectReference

ObjectReference Property AATArmor Auto

Spell Property AATResistanceSpell Auto

Actor Property CurrentActor Auto

Event OnEquipped(Actor akActor)

	AATResistanceSpell.Cast(akActor)
	
EndEvent

This is the script I have on the AATArmor (my test armour)

 

Then, the OnUpdate() doesn't work in my effect script.

ScriptName AATResistanceScript extends ActiveMagicEffect

Actor Property CurrentActor Auto

Event OnEffectStart(Actor akTarget , Actor akCaster)

	CurrentActor = akTarget
	
	Debug.Notification("Effect Active")
	
	float resistVal = CurrentActor.GetAV("dragonSouls") * 10

			if (resistVal > 90)
				resistVal = 90
			endif

	CurrentActor.SetAV("frostResist", resistVal)
	CurrentActor.SetAV("fireResist", resistVal)
	
	RegisterForSingleUpdate(5.0)
EndEvent

Event OnUpdate()
	Debug.Notification("Timer Working")
	
	RegisterForSingleUpdate(5.0)
EndEvent

Event OnEffectFinish(Actor akTarget , Actor akCaster)
	if (CurrentActor == akTarget)
		float resistVal = CurrentActor.GetAV("dragonSouls") * 10

			if (resistVal > 90)
				resistVal = 90
			endif
	EndIf	
EndEvent

The calculation and modifying of values works perfectly. To test it, I created a quick test barrel to apply the effect, which worked fine (except the OnUpdate() part)

 

So I'm pretty stuck here, seeing as I don't know why the spell isn't being cast when I equip the armor, or why my single updates aren't working on the magic effect.



#4
Arocide

Arocide

    Enthusiast

  • Supporter
  • PipPip
  • 212 posts

Is working with an enchantment a possibility instead? If you are doing this for a single armor it would be much easier and you wouldn't need a script on the armor for the effect to be applied. If not then what I would try doing is modify your script on the armor to this:

ScriptName AATArmorScript extends ObjectReference

	Spell Property AATResistanceSpell Auto

	Event OnEquipped(Actor akActor)
		akActor.AddSpell(AATResistanceSpell, false)
	EndEvent
	
	Event OnUnequipped(Actor AkActor)
		akActor.RemoveSpell(AATResistanceSpell)
	EndEvent

Then ensure the AATResistanceSpell is set to Ability with constant effect and self, this should then work. Ability type spells will start when they are added to an actor and stay on (assuming you have constant effect on) so you don't need to cast them unlike spells. I think that's what you're going for?

 

EDIT: On a side note where you have:

	if (CurrentActor == akTarget)

Looks a bit redundant to me, because the script is instanced to the target so that would always return true.


Edited by Arocide, 04 April 2015 - 11:34 AM.


#5
DOCac42

DOCac42

    Newbie

  • Members
  • Pip
  • 10 posts

Haha, I can't believe I didn't think of making it an enchantment!

 

I've created AATResistanceEnch, with the constant effect and self properties and it seems to be working perfectly in-game!

I'll apply the calculation script to the OnUpdate() event and see if I can make a working negation at the end, but thinks should work from here.

 

Thanks to you both for helping me out! I've learned a lot about scripting and will hopefully be able to make a decent mod from this.

 

Thanks again :)







Also tagged with one or more of these keywords: scripting, papyrus, skyrim, dragon, dragon souls, resistance, fire resistance, frost resistance, problem, help

Page loaded in: 1.220 seconds