Checking for Current PerksRecent Actions

Post » Tue Nov 20, 2012 2:15 am

I have a quest stage 20 which is to learn a Perk.

How do I:
  • check for whether the player already has that perk and so mark that stage as completed if he does;
  • if the player doesn't have that perk, how do I get the mod to recognise that and mark the stage as completed when he does choose the perk at level up?

Also, he has to forge a weapon of a particular material and then temper it, so how would I script that so that stages 30 and 40 can be concluded?


I have all the items, recipes etc but I have been a week on the scripting part and so far reading the letter activates quest stage 10 and marks the map location, and reading the quest book completes stage 10 and starts stages 20, 30 and 40, which is to learn the perk, forge a weapon and then temper the weapon.

Any help gratefully received before I go bald!

This is my first quest mod, so I thought I'd keep it simple. :wallbash:


Cheers!
User avatar
Hannah Barnard
 
Posts: 3421
Joined: Fri Feb 09, 2007 9:42 am

Post » Tue Nov 20, 2012 4:48 am

This assumes the book you read, which finishes stage 10 and starts the other stages is an alias in the quest. If it is you could use an Event OnUpdate()

You could add a line, under the start stage 20 which would look like this

Scriptname QuestScript extends Alias  Import GameQuest Property MyQuest AutoPerk Property MyPerk AutoEvent OnRead();Your existing script here;Under the line which sets the stage 20, 30 & 40, add the following    RegisterForUpdate(1)    EndEventEvent OnUpdate()    if GetPlayer().HasPerk(MyPerk)        MyQuest.SetObjectiveCompleted(20)            UnRegisterForUpdate()    endifEndEvent

When the book is read, it starts an update event to occur every 1 second (you could change the timing of this if required).
The update then checks if the player has the perk. If the player doesn't, it will keep on checking every second.
However if the player does have the perk, quest stage 20 is set as completed and importantly, ends the update.

DISCLAIMER
I haven't tested the above script
User avatar
Claire Mclaughlin
 
Posts: 3361
Joined: Mon Jul 31, 2006 6:55 am

Post » Mon Nov 19, 2012 9:54 pm

Cheers, I'll give that a go.

~
User avatar
Amy Cooper
 
Posts: 3400
Joined: Thu Feb 01, 2007 2:38 am

Post » Tue Nov 20, 2012 6:13 am

Before I try this, is there any danger of this loop getting embedded in the save? I don't want to cause problems for people who might use the mod.

Also, would checking every second cause performance issues?

I don't have any aliases in my scripts as every item is unique, but I could add some if needed.


Cheers

~
User avatar
brandon frier
 
Posts: 3422
Joined: Wed Oct 17, 2007 8:47 pm

Post » Tue Nov 20, 2012 9:38 am

As i understand how the game saves (Anyone jump in and correct this if it is wrong), if a script is running, that will also be included within the save. Therefore a script with an Update loop will be included within that save.

You could change the script to the following. It is the update that creates the loop, so if the mod is removed the update loop ceases to exist
Scriptname QuestScript extends Alias  Import GameQuest Property MyQuest AutoPerk Property MyPerk AutoEvent OnRead();Your existing script here;Under the line which sets the stage 20, 30 & 40, add the following	RegisterForSingleUpdate(1)	EndEventEvent OnUpdate()	if GetPlayer().HasPerk(MyPerk)		MyQuest.SetObjectiveCompleted(20)	else	   RegisterForSingleUpdate(1)	endifEndEvent
In terms of performance issue, i use a similar method to check for a spell, and notice no performance issues. The update is only checking if the player has the desired perk, therefore i wouldn't expect any issues to arise.

The script i posted does depend on having the book as an alias as RegisterForUpdate & RegisterForSingleUpdate work on Active Magic Effects, Quests and Alias's
User avatar
Fam Mughal
 
Posts: 3468
Joined: Sat May 26, 2007 3:18 am

Post » Tue Nov 20, 2012 10:48 am

Thanks, I made an alias for the book but I simplified the mod to cut out stages to check for things as it was driving me nuts. Once I get the basic thing sorted:
  • read letter
  • go to map location and read book

then I can think about adding more stages to lead the player through the normal perks he needs to get to be able to make the new weapons.

At the moment, even if he had all the perks in the game, he cannot make the new weapons until he reads the book as the book adds a dummy perk and HASPERK DummyPerk is a condition of the recipes for forging and tempering. That was the most important thing to get to work, so I am glad it does.

Everything works at the moment except I can't get the HUD arrows tio show up.


Thanks very much for the help!

~
User avatar
Add Meeh
 
Posts: 3326
Joined: Sat Jan 06, 2007 8:09 am

Post » Tue Nov 20, 2012 10:15 am

The basic quest is now working perfectly, the aliases work, so I'm going to try and add these things for the other stages.

So far, player reads letter, quest starts, journal updates, map updates, floating quest markers appear;
player finds quest book, reads it, has the dummy perk added that are needed by the recipes and if he has the nornal perks, he can make the new items.

So now I'd like to try and get some more quest stages directing the player to get the perks he needs and closing the quest if he has them/when he gets them.

Is it possible to get these scripts to run once when reading the quest book and then running after the character levels up and the player chooses another perk, rather than every second?


Cheers!
User avatar
Kayleigh Williams
 
Posts: 3397
Joined: Wed Aug 23, 2006 10:41 am


Return to V - Skyrim