Jump to content

Help with a script


Recommended Posts

I've been attempting to make a mod. What I want to do is add a book to players inventory. Then attempting to add player skills without lvling up the player. Any help is appreciated. I have been working on this for a month. Scratching my head, pounding my head on things and pondering. I know I keep getting closer to making the script work. This is my first mod and is inspired by other mods that lvl up skills and player lvl. My other half wanted to lvl up skills but not his players lvl so I went to work. I've completely made a book for this and hope to share it with others once I can figure out what is wrong with the script.

Script

 

Scriptname PerkScriptBOG extends ObjectReference
{Script for Book of Gudrun}

Book Property AddItem Auto
{adds Book of Gudrun}

Actor Property SetAV Auto
{set skills}


Event
Game.GetPlayer.AddItem(Book Of Gudrun, 1 , true)
OnRead ()
Game.GetPlayer.SetAV("Illusion", 10)
Game.GetPlayer.SetAV("Conjuration", 10}
Game.GetPlayer.SetAV("Destruction", 10)
Game.GetPlayer.SetAV("Restoration", 10)
Game.GetPlayer.SetAV("Alteration", 10)
Game.GetPlayer.SetAV("Enchanting", 10)
debug.messagebox("As you ponder into this book your mind grows with the knowledge of skyrims past, present and future")
EndEvent

 

Link to comment
Share on other sites

I'm not much of an expert, not by a long-shot, but couldn't you opt to use 'Game.GetPlayer.ModAV' instead. In my experience it is more stable, and more forgiving in the engine when you want to lower an actor value.

Link to comment
Share on other sites

ModAV would be of benefit if they were wanting to temporarily affect the value or ensure that the value could be reversed for whatever reason.

SetAV would be appropriate if the intent is to make a one time permanent change.

 

If you want this to happen right at the start of the game (or when the mod is first loaded):

Make a start game enabled quest.

Add an alias pointing to the player on that quest.

Add the book to the alias inventory.

 

Then adjust your script for the book as follows (needs testing for compilation and function):

 

 

Scriptname PerkScriptBOG extends ObjectReference
{Script for Book of Gudrun}

Actor PlayerRef

Event OnRead()
	PlayerRef == Game.GetPlayer()
	PlayerRef.SetActorValue("Illusion", 10.0)
	PlayerRef.SetActorValue("Conjuration", 10.0}
	PlayerRef.SetActorValue("Destruction", 10.0)
	PlayerRef.SetActorValue("Restoration", 10.0)
	PlayerRef.SetActorValue("Alteration", 10.0)
	PlayerRef.SetActorValue("Enchanting", 10.0)
	debug.messagebox("As you ponder into this book your mind grows with the knowledge of skyrim's past, present and future")
EndEvent

Notes:

1. Changed SetAV to SetActorValue. Why? SetAV calls SetActorValue and thus SetActorValue is quicker.

2. Assigned Game.GetPlayer() to the PlayerRef variable. No need to keep calling a function on another script when it can be done once, stored and reused.

3. SetActorValue utilizes a float for the new value. Adding the decimal place is a helpful reminder that it is using a float rather than an integer.

 

 

Link to comment
Share on other sites

ModAV would be of benefit if they were wanting to temporarily affect the value or ensure that the value could be reversed for whatever reason.

SetAV would be appropriate if the intent is to make a one time permanent change.

 

If you want this to happen right at the start of the game (or when the mod is first loaded):

Make a start game enabled quest.

Add an alias pointing to the player on that quest.

Add the book to the alias inventory.

 

Then adjust your script for the book as follows (needs testing for compilation and function):

 

 

Scriptname PerkScriptBOG extends ObjectReference
{Script for Book of Gudrun}

Actor PlayerRef

Event OnRead()
	PlayerRef == Game.GetPlayer()
	PlayerRef.SetActorValue("Illusion", 10.0)
	PlayerRef.SetActorValue("Conjuration", 10.0}
	PlayerRef.SetActorValue("Destruction", 10.0)
	PlayerRef.SetActorValue("Restoration", 10.0)
	PlayerRef.SetActorValue("Alteration", 10.0)
	PlayerRef.SetActorValue("Enchanting", 10.0)
	debug.messagebox("As you ponder into this book your mind grows with the knowledge of skyrim's past, present and future")
EndEvent

Notes:

1. Changed SetAV to SetActorValue. Why? SetAV calls SetActorValue and thus SetActorValue is quicker.

2. Assigned Game.GetPlayer() to the PlayerRef variable. No need to keep calling a function on another script when it can be done once, stored and reused.

3. SetActorValue utilizes a float for the new value. Adding the decimal place is a helpful reminder that it is using a float rather than an integer.

 

 

Wait.. isn't this the other way around :

ModAV = permanent
SetAV = temporary
In all the research i've done this is the conclusion i got, from other modders like yourself and others, and from reading online.
They all advise me to use ModAV instead of SetAV for my Gain Permanent Health/Magicka/Stamina Script - Activator.
Link to comment
Share on other sites

You are also correct.

 

ModAV adds or subtracts from the permanent modifier value used in the calculation of the current value. Thus if one mods in 50, there will always be 50 more than there would have been otherwise no matter the changes.

 

I said "temporary" with ModAV not because of how it affects the value but as a contrast usage to the OP's intended one time value change. For example, my Controller Walk Run Toggle mod uses ModAV to change the speed multiplier up and down as the designated button is pressed. It is a temporary change because the previous usage gets reversed with the next usage.

 

I said "permanent" with SetAV because the idea behind its use is to change the base value so that all future calculations are affected by the new base. However, it is "temporary" in that any other usage of SetAV on that value will "permanently" erase the prior change.

 

In other words, it boils down to point of view. No confusion intended.

Link to comment
Share on other sites

You are also correct.

 

ModAV adds or subtracts from the permanent modifier value used in the calculation of the current value. Thus if one mods in 50, there will always be 50 more than there would have been otherwise no matter the changes.

 

I said "temporary" with ModAV not because of how it affects the value but as a contrast usage to the OP's intended one time value change. For example, my Controller Walk Run Toggle mod uses ModAV to change the speed multiplier up and down as the designated button is pressed. It is a temporary change because the previous usage gets reversed with the next usage.

 

I said "permanent" with SetAV because the idea behind its use is to change the base value so that all future calculations are affected by the new base. However, it is "temporary" in that any other usage of SetAV on that value will "permanently" erase the prior change.

 

In other words, it boils down to point of view. No confusion intended.

 

Got it, thanks for the explanation.
Although i would really like to find a detailed documentation on this subject, i still don't have it 100% cover.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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