Jump to content

Quest scripting help request - take item from player, equip on quest-giver


Recommended Posts

Posted (edited)

I can't for the life of me seem to get this right.  I've tried a dozen variations, over a few months of frustration, and it just is never working.

 

I've taken an old open-permissions basic follower mod (Mango) and started adding stuff to it, including new XVASynth dialogue.  I've started with a simple "find my lost gear" micro-quest (right in the same dungeon).

 

The quest starts.  The marker works.  Finding the gear updates the quest (only the cuirass is required from the chest the stuff is found in).  The dialogue when you return to the quest-giver is there, but then when you trigger it to give the gear, nothing happens and the quest is stuck forever. 

 

What's supposed to happen is when you tell her you got her gear for her, it takes the quest-flagged cuirass from you and equips the non-quest-flagged variant on the NPC. Sounds dirt simple.

 

Here's the mod in its presently broken alpha state.  Can anyone please help fix this?  I think if I get this working and see why it works and my older attempts failed, I'll be able to proceed with the rest of the "real" quests I have in mind without any further serious problems. 

 

https://mega.nz/file...7NDp5ZtWsJneLlA

 

NSFW: The follower NPC doesn't have an outfit on when you find her, so if your game has nude textures instead of vanilla underwear textures, she'll show up nude.

 

For expedient testing: Clear out Embershard mine, and save.  Install the alpha mod, and go back into Embershard.  The follower NPC, Mango, is chained to the wall across from the locked bandit armory room in the middle of the dungeon.  The dialogue is very simple and self-explanatory.  The Heirloom Nordic Cuirass to find is in the chest on the table near the bandits' forge and armoring table in the cavern a bit further inside the dungeon.

Edited by Darklocq
tags
Posted

Here's the Topic Info:

 

Mango-Topic-Info.jpg

 

And the Papyrus fragment:

 


getowningquest().setstage(40)
;;The following stuff can also be done via Quest Stage 40 itself.
;;Remove scripted quest version from player (and from game):
Game.GetPlayer().RemoveItem(Alias_MangoCuirAlias.GetRef(), 1)
;;The next line should be redundant:
;Alias_MangoAlias.GetActorRef().AddItem(DrqMango_ArmorDraugrCuirass, 1)
;;Have her equip the non-quest version:
Alias_MangoAlias.GetActorRef().EquipItem(DrqMango_ArmorDraugrCuirass)
Alias_MangoAlias.GetActorRef().SetRelationshipRank(Game.GetPlayer(), 3)

Posted

Don't know if it's the only issue but looks like you forgot to fill the properties on the topic quest fragment (TIF__0200DF0F).

That's a very common issue (at least for me ;) )when working with scripts.

Some tips that will cut down in the number of aliases you need: 

You can use:

akSpeaker  to easily get the speaking actor in the fragment.

You can also do:

QF_DrqMangoGearQst_0500DF04 q = GetOwningQuest() as QF_DrqMangoGearQst_0500DF04

To get access to all alias as:  q.ALIAS_MangoAlias  etc.  just like in the Quest Fragment.

or eg ReferenceAlias a = getOwningQuest().getAliasByName( "ManguCuiAlias" ) as ReferenceAlias  if you only need one.)

 

(I usually also put CompleteQuest() and stop() in the  final stage quest fragment.)

Posted

I think I can avoid some of this by just moving the actions to the Quest Stage 40 instead of having them in this dialogue fragment, yes?  I'm getting the impression that the quest aliases are local vars inside the quest and can't be accessed by the dialogue Papyrus fragment without jumping through hoops.

Posted
3 hours ago, Darklocq said:

I think I can avoid some of this by just moving the actions to the Quest Stage 40 instead of having them in this dialogue fragment, yes?  I'm getting the impression that the quest aliases are local vars inside the quest and can't be accessed by the dialogue Papyrus fragment without jumping through hoops.

 

Yes, in the quest stage 40 script segment you will automatically have access to the quest alias properties, so it will be easier to use there.   (Accessing quest aliases outside the quest script can be done by getting them by name or with a cast (see below).)

If you want to do something with the speaker and there could be multiple NPCs that could say the line, then doing it in the dialog fragment is handy as you have ` akSpeaker ' there, Else it's likely enough to just put a setstage there and you won't need any properties.

 

But hoop jumping is great exercise ;) so:

 

> quest aliases are local vars inside the quest

Technically they are properties, not local vars, so you do have access to them outside the script, as long you have a reference to the quest that is of the right type.   When you do GetOwningQuest() you get a reference to the quest, but its of type `Quest', and not every quest has these properties so the compiler will not allow you use them unless you tell the compiler what type of quest this actually is with a cast eg:

MyQuest mq =  GetOwningQuest() as MyQuest

so you can access properties present only on `MyQuest'  (in this case `MyQuest' is the name of the quest fragments script- which, unless you renamed it, is likely some auto generated name like QF_DrqMangoGearQst_0500DF04 ).

 

Important thing to remember is that if you use properties on any script (fragment) you have to make sure they are filled.

In most cases they don't have any value initially (with a few exceptions). Simply clicking `property - auto fill all' will do the trick if the names correspond to the objects you want in them.  (Do so after the script is saved/compiled.)

 

(Sorry if I go on about things you already know...)

 

Posted

That's all helpful!  Thanks.  I think in this exact instance I'm going to scrap the gear-swapping hooey, because the NPC is a follower, and different follower frameworks handle equipping outfits differently (put in inventory, put in an alternative inventory, build a context-specific outfit, yadda yadda), so it's saner for the player to manually give the gear back, in whatever way works best for their follower framework.  But shortly, I will need to do a "take this item from the PC and give it to the NPC" thing anyway, for a journal book, so it's good to have practiced and beat on the bugs with this early attempt.

Posted

Noted.  It sounds like something like:

  Alias_NPC'sName.GetReference().AddItem(GenericItem'sID, 1)

should work, the way it does with Game.GetPlayer().AddItem(...), but in my case it did not.  Maybe I just had some kind of typo in it though.  Will try it again next time something like that comes up.

Posted

If quest giver is who your talking to in dialogue you could probably just use akSpeaker.AddItem(deeznuts, 2)

 

What is the item? 

 

And if player has item at beginning of dialogue 

 

PlayerRef.RemoveItem(deeznuts, 2) Ouch!

 

PlayerRef would have to made as references 

Posted

OK. I'll refer back to this thread when I get to the part where I need to do those kinds of things. Right now, I'm just doing "go here, do that" stuff and don't need to swap any inventory items out.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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