Script Extend question

Post » Tue Jun 19, 2012 1:45 am

Hi.

In my way to learn Papyrus, i'm trying to write a script that gives an armor piece a continuous effect as long the player wears it.

So, i made a script like that (For example) :


Event OnEquipped(Actor AkActor)If akActor == Game.GetPlayer(); ...Do all what I want for effect.EndIfEndEventEvent OnUnequipped(Actor AkActor)If akActor == Game.GetPlayer(); ...Remove the effect.EndIfEndevent

This script will be added on an item.

I have two questions, please.
? What should I put after the extend on the script name line ? Item ? Object ? Other ? I can't find that.
? Is the Script correct like that ?

Thank you.

EDIT :

OK, i found the answers for my 2 questions.

I have another, I can't answer myself.

I've add on an armor piece a frost resist +10, by the script, to test. ModAv("frostresist", 10). At least, it works, when I call player.getav frostresist in game, it gives me the right resist with and without the armor piece.

But that 10% resist doesn't appear on the Active effects in the Magic menu (the place where all the resists, boosts and diseases are wrote).

? How can I add that ?
User avatar
Flesh Tunnel
 
Posts: 3409
Joined: Mon Sep 18, 2006 7:43 pm

Post » Tue Jun 19, 2012 4:50 am

You need to create magic effect with "Constant Effect", "Self", "Peak Value Modifier", "FrostResist" and flags "Recover checked", "Hide in UI unchecked". Then create new spell "Ability" out of that effect, enter magnitude like "10" and add spell property in your script. Then use AddSpell/RemoveSpell functions instead of modifying actor value.
Or simply add frost resist enchant to the armor.
User avatar
carrie roche
 
Posts: 3527
Joined: Mon Jul 17, 2006 7:18 pm

Post » Tue Jun 19, 2012 2:00 pm

I don't want to just add frost resist enchantment to the armor ^^

The goal is to learn what I am doing, and how I can do some things.
In this case, I'm trying to create an armor piece with some effects already on it (even if it's not said in the object menu), but still enchantable.

So, I have the armor piece, the effect, I just had to add the effect in the "active effect" menu.
I will try to do what you say. I see what I have to do, I didn't think to do it.
User avatar
Amanda savory
 
Posts: 3332
Joined: Mon Nov 27, 2006 10:37 am

Post » Tue Jun 19, 2012 2:37 pm

Ok, all works good with the Addspell / removespell.
For one piece.

Now, I just tested. For sure, wearing multiple pieces of armor with the same effect don't stack.

I am wondering : Can I do multiple pieces of armor with this script, with those resists stackable ? One piece, +10, two pieces, +20, ... I mean, without having to create one spell for each piece. All in the same spell.

I guess I should do a magic effect working with a script, but I can't just see how start.
User avatar
Eibe Novy
 
Posts: 3510
Joined: Fri Apr 27, 2007 1:32 am

Post » Tue Jun 19, 2012 2:33 pm

Ok.
I found how to do that simply.

I made 5 spells with the same effect, but with 10, 20, 30, 40 and 50. And I put this script on the 5 items of the armor I'm trying to work with :

Scriptname ArmorResistFrost extends ObjectReferenceSpell Property TestFrostResist01 autoSpell Property TestFrostResist02 autoSpell Property TestFrostResist03 autoSpell Property TestFrostResist04 autoSpell Property TestFrostResist05 autoEvent OnEquipped(Actor AkActor)   If akActor == Game.GetPlayer()	  If (Game.Getplayer().HasSpell(TestFrostResist01))	  Game.Getplayer().removespell(TestFrostResist01)	  Game.GetPlayer().Addspell(TestFrostResist02, false)	  ElseIf (Game.Getplayer().HasSpell(TestFrostResist02))	  Game.Getplayer().removespell(TestFrostResist02)	  Game.GetPlayer().Addspell(TestFrostResist03, false)	  ElseIf (Game.Getplayer().HasSpell(TestFrostResist03))	  Game.Getplayer().removespell(TestFrostResist03)	  Game.GetPlayer().Addspell(TestFrostResist04, false)	  ElseIf (Game.Getplayer().HasSpell(TestFrostResist04))	  Game.Getplayer().removespell(TestFrostResist04)	  Game.GetPlayer().Addspell(TestFrostResist05, false)	  Else	  Game.GetPlayer().Addspell(TestFrostResist01, false)	  EndIf   EndIfEndEventEvent OnUnequipped(Actor AkActor)   If akActor == Game.GetPlayer()	  If (Game.Getplayer().HasSpell(TestFrostResist05))	  Game.Getplayer().removespell(TestFrostResist05)	  Game.GetPlayer().Addspell(TestFrostResist04, false)	  ElseIf (Game.Getplayer().HasSpell(TestFrostResist04))	  Game.Getplayer().removespell(TestFrostResist04)	  Game.GetPlayer().Addspell(TestFrostResist03, false)	  ElseIf (Game.Getplayer().HasSpell(TestFrostResist03))	  Game.Getplayer().removespell(TestFrostResist03)	  Game.GetPlayer().Addspell(TestFrostResist02, false)	  ElseIf (Game.Getplayer().HasSpell(TestFrostResist02))	  Game.Getplayer().removespell(TestFrostResist02)	  Game.GetPlayer().Addspell(TestFrostResist01, false)	  Else	  Game.GetPlayer().removespell(TestFrostResist01)	  EndIf   EndIfEndevent

I filled the good values in the Script properties in each item.

But I encounter a problem in game.
The multiple spells and resists work fine, but... The first piece I put gives me the +10, and the second gives me nothing. The 3rd, 4th and 5th works fine, until +40 instead of +50 because of this second piece which is not working.

In the reverse order, when I put off the amor, same problem, same place. I put off the item until I have 2 of them, and then I have +10. I put off one more, I still have +10. And the last item remove the spell.

I read and read again my script, I searched the logic, but I can't understand why the second piece doesn't give anything.

Can someone tell me where is the problem ?
User avatar
Love iz not
 
Posts: 3377
Joined: Sat Aug 25, 2007 8:55 pm

Post » Tue Jun 19, 2012 1:38 am

No one ? :/

I really don't find where the problem is.
User avatar
Myles
 
Posts: 3341
Joined: Sun Oct 21, 2007 12:52 pm

Post » Tue Jun 19, 2012 2:42 pm

Ok, I spotted the problem.
In fact, the script is not fast enough, and when I put on or off multiples pieces of armor too quickly, it doesn't "see" them all.
Is there a function I could add to change that ? A "return"-like function, maybe ?
User avatar
Francesca
 
Posts: 3485
Joined: Thu Jun 22, 2006 5:26 pm


Return to V - Skyrim