Jump to content

Script Help... Please?


Recommended Posts

Hello, I am currently in the process of making a mod, in which a book has a script attached to it. The script's main function is that it plays music, as well as increasing each of the player's skills by 10 (I'm not worried that that sounds overpowered). All works so far, but I discovered while testing that it would increase the skill level by 10 EVERY time it was activated... amusing as this is, I need it limited, so that the music will play whenever the book is activated, but the skill increase only works the first time.

 

Here is what I have so far...

 

scn BookA
Begin OnActivate
StreamMusic random
StreamMusic "Data\Music\Special\opening.mp3"
player.advskill blade 10
player.advskill blunt 10
player.advskill marksman 10
player.advskill handtohand 10
player.advskill destruction 10
player.advskill restoration 10
player.advskill mysticism 10
player.advskill illusion 10
player.advskill conjuration 10
player.advskill alteration 10
player.advskill alchemy 10
player.advskill acrobatics 10
player.advskill athletics 10
player.advskill block 10
player.advskill heavyarmor 10
player.advskill lightarmor 10
player.advskill security 10
player.advskill sneak 10
player.advskill mercantile 10
player.advskill armorer 10
player.advskill speechcraft 10
end
Any help, from anyone willing, is greatly appreciated. Thanks.
zazz825
Link to comment
Share on other sites

It could be because you are actually increasing them by ten (10) as you can see in your script:

player.advskill armorer 10

Where 10 is the amount to increase it by. You could change it to 1 and see if it helps. Also, the documentation makes it look like it does not need a reference to run on, which would make sense, since it only ever seems to affect the player.

AdvancePCSkill Armorer 1

You could, however, see this page, where it apparently says that using AdvancePCSkill would reset skill points gathered towards a new level (or that is how I read it, could be something different, too) - also read the Discussion tab: http://cs.elderscrolls.com/index.php?title=ModPCSkill

 

No idea about the music, I have not yet looked into it much. As a side note, you could theoretically consider prefixing your scripts and forms in a unique way, to tell them apart from other stuff.

 

Another thing to note is that you do not limit the OnActivate trigger action ref. As of now, an NPC, a creature, or a script can activate the book, and player will gain skill levels. For example if using a mod that allows the player to issue command to followers, a follower could go to the book, activate it, and player, standing ten metres away, would still get skill increases. For example.

 

To limit the action ref, this would be a simple way, if you want player to be able to activate it:

Begin OnActivate
    If ( IsActionRef PlayerRef == 0 )
        Return
    Else
        ...logic here...
    EndIf    
End

There is also the OnEquip script block if you want it to work only when equipped, as well as others, if they are useful: http://cs.elderscrolls.com/index.php?title=Begin

 

Happy modding. :thumbsup:

Link to comment
Share on other sites

Looks like you need to set a ref to tell whether the book has been opened previously. It's been years since I scripted anything so forgive my syntax.

 

scn BookA
short haveread
Begin OnActivate
StreamMusic random
StreamMusic "Data\Music\Special\opening.mp3"
If haveread == 0
player.advskill blade 10
player.advskill blunt 10
player.advskill marksman 10
player.advskill handtohand 10
player.advskill destruction 10
player.advskill restoration 10
player.advskill mysticism 10
player.advskill illusion 10
player.advskill conjuration 10
player.advskill alteration 10
player.advskill alchemy 10
player.advskill acrobatics 10
player.advskill athletics 10
player.advskill block 10
player.advskill heavyarmor 10
player.advskill lightarmor 10
player.advskill security 10
player.advskill sneak 10
player.advskill mercantile 10
player.advskill armorer 10
player.advskill speechcraft 10
Set haveread to 1
Endif
end
So what happens is you create a have read variable which has no initial value. The script runs once then sets the variable to 1. Next time you read it the script won't run because the variable isn't 0. Hope this made sense.
Link to comment
Share on other sites

Ah. Oh. OOOooooops. Sorry. I misread the thing. I thought you wanted to raise it by 1 each time the book was opened. Odd. Sorry again. Disregard my reply. :facepalm:

 

Do what razorpony said.

 

Edit: But rememeber to limit the action ref, if you only want the script to fire when activated by player. Especially if you only want it to fire once, because then you should make sure an NPC or a script does not "steal" the one activation chance from the player.

short HaveRead

Begin OnActivate

    If ( IsActionRef PlayerRef == 0 )
        Return
    EndIf

    <play music here>

    If ( HaveRead )
        Return
    Else
        <skill increases>
        set HaveRead to 1
    EndIf

End
Edited by Contrathetix
Link to comment
Share on other sites

  • 1 month later...

 

Ah. Oh. OOOooooops. Sorry. I misread the thing. I thought you wanted to raise it by 1 each time the book was opened. Odd. Sorry again. Disregard my reply. :facepalm:

 

Do what razorpony said.

 

Edit: But rememeber to limit the action ref, if you only want the script to fire when activated by player. Especially if you only want it to fire once, because then you should make sure an NPC or a script does not "steal" the one activation chance from the player.

short HaveRead

Begin OnActivate

    If ( IsActionRef PlayerRef == 0 )
        Return
    EndIf

    <play music here>

    If ( HaveRead )
        Return
    Else
        <skill increases>
        set HaveRead to 1
    EndIf

End

 

 

 

Looks like you need to set a ref to tell whether the book has been opened previously. It's been years since I scripted anything so forgive my syntax.

 

scn BookA
short haveread
Begin OnActivate
StreamMusic random
StreamMusic "Data\Music\Special\opening.mp3"
If haveread == 0
player.advskill blade 10
player.advskill blunt 10
player.advskill marksman 10
player.advskill handtohand 10
player.advskill destruction 10
player.advskill restoration 10
player.advskill mysticism 10
player.advskill illusion 10
player.advskill conjuration 10
player.advskill alteration 10
player.advskill alchemy 10
player.advskill acrobatics 10
player.advskill athletics 10
player.advskill block 10
player.advskill heavyarmor 10
player.advskill lightarmor 10
player.advskill security 10
player.advskill sneak 10
player.advskill mercantile 10
player.advskill armorer 10
player.advskill speechcraft 10
Set haveread to 1
Endif
end
So what happens is you create a have read variable which has no initial value. The script runs once then sets the variable to 1. Next time you read it the script won't run because the variable isn't 0. Hope this made sense.

 

 

 

These were both really helpful, thanks so much! :D

Link to comment
Share on other sites

  • Recently Browsing   0 members

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