Jump to content

Please help with quest script!


elseagoat

Recommended Posts

Ok, so I have two problems. The first one is this:

 

I have created a new perk, and put it in my tree, getting rid of the five "X spells cost half magicka" perks. I now want to make it so that once the player takes this single perk I made, the player will automatically gain each of the five half magicka perks when they reach the appropriate skill level.

 

So I made my perk, which basically has no perk entries. Then I made a quest. The quest has no name, priority 0, type "none." Originally I tried Start Game Enabled, but that didn't work, because I wanted to do this check every time the player gained skill to add the appropriate magicka cost reduction perk, so say the player reaches skill level 50 in Conjuration, the moment he skills up, he gets the "Adept Conjuration" perk automatically added. So when I tried Event OnStoryIncreaseSkill() it never got the event, because apparently that event only happens when the quest is started as a result of a skillup. Which seems really dumb to me, why not just use OnInit() if you want to do stuff when the quest starts...

 

But anyways, I changed the event from none (greying out Start Game Enabled) to Skill Increase. Then I attached this script to the quest:

 

Scriptname ESG_AdvSkillMagic extends Quest  

String Property SchoolOfMagic Auto
Perk Property MagickaPerk1 Auto
Perk Property MagickaPerk2 Auto
Perk Property MagickaPerk3 Auto
Perk Property MagickaPerk4 Auto
Perk Property MagickaPerk5 Auto


Event OnStoryIncreaseSkill(string asSkill)
Debug.Notification("Player just increased the " + asSkill+ " skill")
If (asSkill == SchoolOfMagic)
	int SkillLevel = Game.Getplayer().GetAV("Conjuration") as int
	If (SkillLevel >= 25 && Game.GetPlayer().HasPerk(MagickaPerk1) && Game.GetPlayer().HasPerk(MagickaPerk2) == false)
		Game.GetPlayer().AddPerk(MagickaPerk2)
	EndIf
	If (SkillLevel >= 50 && Game.GetPlayer().HasPerk(MagickaPerk3) == false)
		Game.GetPlayer().AddPerk(MagickaPerk3)
	EndIf
	If (SkillLevel >= 75 && Game.GetPlayer().HasPerk(MagickaPerk4) == false)
		Game.GetPlayer().AddPerk(MagickaPerk4)
	EndIf
	If (SkillLevel >= 100 && Game.GetPlayer().HasPerk(MagickaPerk5) == false)
		Game.GetPlayer().AddPerk(MagickaPerk5)
	EndIf
EndIf
endEvent

 

Now, here are my questions:

 

1) Am I doing this right? Or is there a better way to do what I have described?

 

2) Do I need to do anything with fragments in the quest stages tab? (Anyone that could elaborate on what the hell a fragment is and kmyQuest and how to use them please do).

 

3) How would I make it so that if a player is say, level 34 conjuration, and all the sudden they decide they want to put some perks in the tree, and they pick up the perk that is referenced as a property MagickaPerk1, how would I make this quest script immediately give them MagickaPerk2 instead of making them wait for their next skill up for the script to run?

 

4) How do I make this quest start each time the player skills up, and then stop, and be able to be started again on the next skill up?

 

 

 

 

 

Now, onto my second set of questions regarding a completely different scenario.

 

I have a magic effect with a script attached, and this effect needs to get the actor reference that is the target, pass it to a quest script that is always running to store it when the effect starts, and then I need to retrieve that actor reference from the quest script in a separate magic effect with a different script.

 

Essentially, I am making a spell that when cast, buffs your reanimated minion if you have one. But I don't want to have to aim it at the minion, I just want it to cast it immediately on the minion no matter where I am looking, assuming I have an undead minion.

 

So this is how I have it set up.

 

This is the first spell which gets the actor reference:

Scriptname ESG_SaveActorToQuest extends activemagiceffect

Event OnEffectStart(Actor akTarget, Actor akCaster)
   ESG_MyQuestScript.StoreActor(akTarget)
EndEvent

 

This is the script in the quest that runs all the time:

Scriptname ESG_ConjurationInstall extends Quest  

Actor AberrationStoredActor

Function AberrationStoreActor(Actor NewActor)
AberrationStoredActor = NewActor
EndFunction

Actor Function AberrationRetrieveActor()
Return AberrationStoredActor
EndFunction

 

This is the second spell which retrieves the actor reference:

Scriptname ESG_GetActorAndCastAtIt extends activemagiceffect

Spell Property BuffAbility Auto

Actor ActorToCastAt

Event OnEffectStart(Actor akTarget, Actor akCaster)
   ActorToCastAt = ESG_MyQuestScript.RetrieveActor()
If ((ActorToCastAt as ObjectReference).GetCurrentLocation() == Game.GetPlayer().GetCurrentLocation() && ActorToCastAt.IsDead() == false)
	ActorToCastAt.AddSpell(BuffAbility)
EndIf
EndEvent

 

 

So what am I doing wrong here? I need to be able to update the actor reference stored in the quest script any time I hit a new target with the first spell, and then I need to, at any time after that, be able to get that actor reference into a script on a second spell. These scripts I posted are obviously wrong, how do I do the casting for something like this?

 

 

Any help is MUCH appreciated.

Edited by elseagoat
Link to comment
Share on other sites

So when I tried Event OnStoryIncreaseSkill() it never got the event, because apparently that event only happens when the quest is started as a result of a skillup. Which seems really dumb to me, why not just use OnInit() if you want to do stuff when the quest starts...

 

OnInit will have no knowledge of what skill just increased, if that's important.

In general you also want to keep OnInit short and sweet.

Use OnReset for more complex tasks.

 

I rewrote the quest script so it would work as either start game enabled, or story manager fired.

 

 

Scriptname ESG_AdvSkillMagic extends Quest  

String Property SchoolOfMagic Auto
Perk Property MagickaPerk1 Auto
Perk Property MagickaPerk2 Auto
Perk Property MagickaPerk3 Auto
Perk Property MagickaPerk4 Auto
Perk Property MagickaPerk5 Auto

; If the quest is start game enabled, then OnInit and OnUpdate will handle adding the perks.
; Poll every 2 mins.

Event OnInit()
RegisterForSingleUpdate(120)
EndEvent

Event OnUpdate()
GivePerks()
RegisterForSingleUpdate(120)
EndEvent

; If we use the story manager, then can only run at levelup

Event OnStoryIncreaseSkill(string asSkill)
Debug.Notification("Player just increased the " + asSkill+ " skill")
; Run conjuration perk check regardless of what skill increased.
GivePerks()
Stop() ; So quest can be restarted by story manager - (Run Once NOT checked)
; Stop() will also unregister the Update if it was set.
EndEvent

; The function common to both methods.

Function GivePerks()
Actor player = Game.Getplayer() ; only call the function once

If !(player.HasPerk(MagickaPerk1))
	Return ; bail out as nothing to do
EndIf

Int SkillLevel = player.GetActorValue("Conjuration") As Int

If (SkillLevel >= 25)
	If !(player.HasPerk(MagickaPerk2))
		player.AddPerk(MagickaPerk2)
	EndIf
	If (SkillLevel >= 50)
		If !(player.HasPerk(MagickaPerk3))
			player.AddPerk(MagickaPerk3)
		EndIf
		If (SkillLevel >= 75)
			If !(player.HasPerk(MagickaPerk4))
				player.AddPerk(MagickaPerk4)
			EndIf
			If (SkillLevel >= 100)
				If !(player.HasPerk(MagickaPerk5))
					player.AddPerk(MagickaPerk5)
				EndIf
			EndIf
		EndIf
	EndIf
EndIf
EndFunction

 

 

 

Now, here are my questions:

 

1) Am I doing this right? Or is there a better way to do what I have described?

 

2) Do I need to do anything with fragments in the quest stages tab? (Anyone that could elaborate on what the hell a fragment is and kmyQuest and how to use them please do).

 

3) How would I make it so that if a player is say, level 34 conjuration, and all the sudden they decide they want to put some perks in the tree, and they pick up the perk that is referenced as a property MagickaPerk1, how would I make this quest script immediately give them MagickaPerk2 instead of making them wait for their next skill up for the script to run?

 

4) How do I make this quest start each time the player skills up, and then stop, and be able to be started again on the next skill up?

 

1/ Looked OK to me.

 

2/ You don't need fragments here. But think of them as events that can run at specific points in your quest.

kmyQuest is an Alias for the main script (eg. ESG_AdvSkillMagic). So it's easy to access properties/functions from the fragment.

eg.

String origVal = kMyQuest.SchoolOfMagic

kMyQuest.SchoolOfMagic = "foo"

kMyQuest.GivePerks()

 

3/ Use the Start Game Enabled variant, so it will poll every 2 mins.

 

4/ Remember to Stop() quests if you want the story manager Event to fire again.

 

I've not looked at the rest of your post yet. Will if I get time.

Edited by tunaisafish
Link to comment
Share on other sites

So what am I doing wrong here? I need to be able to update the actor reference stored in the quest script any time I hit a new target with the first spell, and then I need to, at any time after that, be able to get that actor reference into a script on a second spell. These scripts I posted are obviously wrong, how do I do the casting for something like this?

 

You'd missed setting a properties in your magic effect scripts to the questscript.

Also, you don't need to define functions in the quest, as an Auto property does that for you :)

 

 

 

Scriptname ESG_ConjurationInstall extends Quest  

Actor Property AberrationStoredActor Auto

 

Scriptname ESG_SaveActorToQuest extends activemagiceffect

ESG_ConjurationInstall Property QS Auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
   QS.AberrationStoredActor = akTarget
EndEvent

 

Scriptname ESG_GetActorAndCastAtIt extends activemagiceffect

Spell Property BuffAbility Auto

Actor ActorToCastAt

Event OnEffectStart(Actor akTarget, Actor akCaster)
   ActorToCastAt = QS.AberrationStoredActor
If ((ActorToCastAt as ObjectReference).GetCurrentLocation() == Game.GetPlayer().GetCurrentLocation() && ActorToCastAt.IsDead() == false)
	ActorToCastAt.AddSpell(BuffAbility)
EndIf
EndEvent

 

 

Link to comment
Share on other sites

Wow thanks! I ended up using a different method and avoided using the quest script at all for the first set of questions, but your answers cleared up a lot of problems I may encounter in the future. Thanks so much!

 

Don't worry about the second part, I eventually got that working.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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