Jump to content

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


Recommended Posts

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/4ZIzjQCR#gR0aJmQ3hI3YAF8SD1sHnAk7VGlu7NDp5ZtWsJneLlA

 

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.

Link to comment
Share on other sites

In the quest record, at the player's dialog where they return the gear there should be a script fragment box. Inside this box there needs to be some code added.

 

I do not know what variables or alias names you are using. Therefore, the code that should be present should be along the lines of:

PlayerRef.RemoveItem(AliasOfTheObjectToRemove,1,false,AliasOfTheOneGettingTheObject)

AliasOFTheOneGettingTheObject.EquipItem(AliasOfTheObjectToRemove)

 

Alternatively, that stage fragment could simply set the quest's stage to the next one with MyRunningQuest.SetStage(XX) - where XX is whatever stage number. And that quest stage have the code similar to the above in it. And afterwards you can end the quest and stop it by using: MyRunningQuest.Stop()

 

Before you can add code that would use properties to either the dialog fragment or the stage fragment, the properties need to be created first. Before the properties can be created and added to the script that contains the various fragments, the script needs to be created. Thus the following needs to be done:

Enter the following in the fragment code window: ;Code goes here - note the semi-colon is all that is necessary

Compile the script fragment. This will create the script.

You may need to exit the quest record and re-enter the stage or dialog fragment for the CK to update the windows with the newly created script.

There should be a properties button available, select it.

Add properties for what you need

Assign the properties the correct data

Add your code to the fragment box and remove the temporary line used to initially compile the fragment

Compile the script fragment again.

 

There is more involved than that but without specifics cannot really go into real detail. This should at least get you in the right direction...

Link to comment
Share on other sites

Here's the Topic Info from the existing alpha version:

 

Mango-Topic-Info.jpg

 

And the Papyrus fragment that hasn't been working:

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)
Link to comment
Share on other sites

With the fragment you are using, the property button should be on the Advanced tab. You'll need to make sure that you have your properties filled with the correct data. Otherwise, even with the correct code it will do nothing as it has nothing to work with.

Link to comment
Share on other sites

Made some progress. I left "getowningquest().setstage(40)" there and moved the rest to the quest stage itself.

 

In there, I got a compile error, that "DrqMango_ArmorDraugrCuirass" was undefined. So, I clearly do not know how to have a script give a reference-alias NPC a generic item. Your suggestion from earlier, to do somethign like "AliasOFTheOneGettingTheObject.EquipItem(AliasOfTheObjectToRemove)" wouldn't work here, as that's the quest-flagged version I just removed from the player. I'm trying to add the generic, non-quest-flagged version to the NPC.

 

I tried the following in the quest stage 40's fragment, and it compiled:

SetObjectiveCompleted(30)
;;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(Alias_MangoCuir2Alias.GetRef(), 1)
;;Have her equip the non-quest version:
Alias_MangoAlias.GetActorRef().EquipItem(Alias_MangoCuir2Alias.GetRef())
Alias_MangoAlias.GetActorRef().SetRelationshipRank(Game.GetPlayer(), 3)
CompleteQuest()
Stop()

The removal worked! Progress! Having the NPC equip the replacement did not work. In this case, I had created a new "MangoCuir2Alias" property and "Alias_MangoCuir2Alias" alias to it, for the generic non-quest-flagged cuirass, using the NPC as the "container" for it, since I don't know another way. This is probably wrongheaded. I imagine there's a simple way to tell Alias_MangoAlias to EquipItem some generic thing by RefID. Maybe it's a "Game.Get...something" I don't know about. I didn't get as far as testing whether the SetRelationshipRank worked. Maybe there's even a simple way to remove the quest flag from the same item without swapping it out, and just transfer the item from PC to NPC. Beats-a me. I'm a graphics and meshes and xEdit patches modder. This quest scripting stuff is a whole new thing for me. :-/

 

I did add CompleteQuest() and Stop() at the end of stage 40 here, as someone at another forum recommended those for the final quest stage.

Link to comment
Share on other sites

Here's the entire script:

 

 

 

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 14
Scriptname QF_DrqMangoGearQst_0500DF04 Extends Quest Hidden

;BEGIN ALIAS PROPERTY MangoCuirAlias
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_MangoCuirAlias Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY MangoAlias
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_MangoAlias Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY MangoCuir2Alias
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_MangoCuir2Alias Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY MangoChestAlias
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_MangoChestAlias Auto
;END ALIAS PROPERTY

;BEGIN ALIAS PROPERTY MangoEmbershardMarkerAlias
;ALIAS PROPERTY TYPE ReferenceAlias
ReferenceAlias Property Alias_MangoEmbershardMarkerAlias Auto
;END ALIAS PROPERTY

;BEGIN FRAGMENT Fragment_13
Function Fragment_13()
;BEGIN CODE
SetObjectiveCompleted(30)
;;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(Alias_MangoCuir2Alias.GetRef(), 1)
;;Have her equip the non-quest version:
Alias_MangoAlias.GetActorRef().EquipItem(Alias_MangoCuir2Alias.GetRef())
Alias_MangoAlias.GetActorRef().SetRelationshipRank(Game.GetPlayer(), 3)
CompleteQuest()
Stop()
;END CODE
EndFunction
;END FRAGMENT

;BEGIN FRAGMENT Fragment_10
Function Fragment_10()
;BEGIN CODE
SetObjectiveCompleted(10)
;END CODE
EndFunction
;END FRAGMENT

;BEGIN FRAGMENT Fragment_0
Function Fragment_0()
;BEGIN CODE
SetObjectiveDisplayed(10)
;;Fails to compile with inexplicable 'is undefined' error:
;MangoEmbershardMarkerAlias.AddToMap()
;;This also fails:
;Alias_MangoEmbershardMarkerAlias.AddToMap()
;;FAIL:
;MangoEmbershardMarkerAlias.GetReference().AddToMap()
;;This finally compiled, but I don't know if it will actually work:
Alias_MangoEmbershardMarkerAlias.GetReference().AddToMap()
;END CODE
EndFunction
;END FRAGMENT

;BEGIN FRAGMENT Fragment_4
Function Fragment_4()
;BEGIN CODE
SetObjectiveCompleted(10)
SetObjectiveDisplayed(30)
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment
 

 

 

Link to comment
Share on other sites

Give this a shot. Try on a new game or save that has not seen your mod / quest active.

;BEGIN FRAGMENT Fragment_13
Function Fragment_13()
;BEGIN CODE
SetObjectiveCompleted(30)
Actor MangoActor = Alias_MangoAlias.GetReference() as Actor 
Armor MangoCuirass = Alias_MangoCuirAlias.GetReference().GetBaseObject() as Armor 
;;Remove quest version from player
Game.GetPlayer().RemoveItem(Alias_MangoCuirAlias.GetReference(), 1)
;;Have her equip the non-quest version:
If MangoActor.GetItemCount(MangoCuirass) < 1
  MangoActor.AddItem(MangoCuirass,1)
EndIf
MangoActor.EquipItem(MangoCuirass)
MangoActor.SetRelationshipRank(Game.GetPlayer(), 3)
CompleteQuest()
Stop()
;END CODE
EndFunction
;END FRAGMENT
Link to comment
Share on other sites

  • Recently Browsing   0 members

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