Jump to content

[LE] Cannot get my script to recognise a property


xEthann

Recommended Posts

So I have made a few posts on here and now I am at the point where I could scream in frustration. For whatever reason, I simply cannot get this ONE aspect of my code to work - every other part works fine.

 

Basically, the mod I am working on relies on dialogue to trigger the scripts and I am writing them within the Creation Kit fragment box. The part of the mod I cannot get to work is setting the Outfits of the NPCs and then changing them back to normal.

 

So I have one dialogue option that triggers a script which makes the NPC wear a Prisoner's Outfit

 

Then, another one will appear that SHOULD trigger a script to make the NPCs outfit go back to what it was originally. A few people have offered me suggestions but I just can't seem to get the code to work. - every other part of the code works except for this one feature and it is really slowing down my progress.

 

Using the suggestions on here, the wiki, youtube and some other sources I have made my way through quite a few options.

 

Here is one of them:

 

(1) Script to get the original outfit before setting the new one

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname AAInfluenceMakeBeggarWhiterun Extends TopicInfo Hidden

;BEGIN FRAGMENT Fragment_0
Function Fragment_0(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
if WhiterunBeggar01.GetActorRef() == none
WhiterunBeggar01.ForceRefTo(akSpeaker as objectreference)
akSpeaker.moveto(Marker01)
ReleaseScript.CitizenOutfit01 = akSpeaker.GetActorBase().GetOutfit()
akSpeaker.SetOutfit(BeggarOutfit)
debug.Notification("Citizen has been made a beggar")
EndIF
akSpeaker.EvaluatePackage()
;END CODE
EndFunction
;END FRAGMENT

ReferenceAlias Property WhiterunBeggar01  Auto  

ObjectReference Property Marker01  Auto  

Outfit Property BeggarOutfit  Auto  

AAInfluenceRelease Property ReleaseScript Auto

(2) Script to change the outfit back to normal

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname AAInfluenceRelease Extends TopicInfo Hidden

;BEGIN FRAGMENT Fragment_0
Function Fragment_0(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
if akSpeaker as objectreference == WhiterunBeggar01.GetReference()
WhiterunBeggar.clear()
akSpeaker.SetOutfit(CitizenOutfit01)
debug.Notification("Citizen's status has been restored")
endif
;END CODE
EndFunction
;END FRAGMENT

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

ReferenceAlias Property WhiterunBeggar01  Auto  

Outfit Property CitizenOutfit01 Auto

THEN after this approach didn't work, for whatever reason the two scripts just would not link together and share the CitizenOutfit01 property, I found a way to merge both these scripts into ONE script using xEdit to change the scriptname.

 

So now BOTH dialogue options share the following script:

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname AAInfluenceMakeBeggarWhiterun Extends TopicInfo Hidden

;BEGIN FRAGMENT Fragment_0
Function Fragment_0(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
if akSpeaker.HasKeyword(AAInfluenceIsBeggar)
releaseBeggar(akSpeaker)
akSpeaker.SetOutfit(CitizenOutfit01)
else
CitizenOutfit01 = originalOutfit(akSpeaker)
makeBeggar(akSpeaker)
endif
;END CODE
EndFunction
;END FRAGMENT

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

ReferenceAlias Property WhiterunPrisoner01  Auto

ObjectReference Property Marker01  Auto

Outfit Property BeggarOutfit  Auto

Outfit Property CitizenOutfit01 Auto 

Keyword Property AAInfluenceIsBeggar  Auto

function makeBeggar(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor

if WhiterunBeggar01.GetActorRef() == none
WhiterunBeggar01.ForceRefTo(akSpeaker as objectreference)
akSpeaker.moveto(Marker01)
akSpeaker.SetOutfit(BeggarOutfit)
debug.Notification("Citizen is now a beggar")

EndIF
akSpeaker.EvaluatePackage()
endfunction



function releaseBeggar(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor

if akSpeaker as objectreference == WhiterunBeggar01.GetReference()
WhiterunBeggar.clear()
debug.Notification("Citizen's status has been restored")

endif
akSpeaker.EvaluatePackage()
endfunction




Outfit function originalOutfit(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
debug.Notification("outfit captured")
return akSpeaker.GetActorBase().GetOutfit()
endfunction

Everything compiles correctly but the ONE detail that simply doesn't work is that the outfit does not change back to normal and I haven't the faintest idea why, I feel as though I have tried everything now and nothing seems to work

 

Any help is hugely appreciated - even if it means i need to start from scratch - and if you made it this far in the post, thank you and congrats!

Edited by xEthann
Link to comment
Share on other sites

Are you certain your code paths are being followed? You've got debug alerts in there. Do the expected ones fire? Is there anything in the CitizenOutfit property when you go to call the SetOutfity function directly after the releaseBeggar() function?

 

 

Have you filled the properties with the appropriate data?

In this case the relevant properties are script-driven. It's a TopicInfo, which means IIRC akSpeaker is an inherent autofill from the dialogue and citizenOutfit should be being pulled from the originalOutfit() function's GetOutfit() call.

Link to comment
Share on other sites

The properties are all filled except the CitizenOutfit01 as it is a script driven property - I fill that with the originalOutfit() function, All of the debug notifications fire - I placed them intentionally so I would know the code is working. With regard to the CitizenOutfit01 being filled, The makeBeggar() and originalOutfit() functions should always run first as it is impossible for the NPC to have the keyword AAInfluenceIsBeggar without the makeBeggar() function (I have added the keyword to the quest alias and that is only way to fill it)

 

So the way it will work is, I approach an NPC and there will be an option "You are stripped of all your earthly possessions and are cast out of the city!" (I'm making a sort of social class system that the player can influence with dialogue)

Then the NPC fills the quest alias WhiterunBeggar01 and follows the AI Packages etc and is given a new outfit.

 

Then, there is another dialogue option that is conditional to the NPC having the keyword AAInfluenceIsBeggar which then says "You may re-enter the city, your banishment has been lifted" And then this triggers the releaseBeggar() function (which works perfectly) and then sets the outfit to CitizenOutfit01 (which should've been filled when the NPC was made a beggar) but for some reason it doesn't change and now I have an NPC wandering around the city wearing rags - doesn't look the best when you use it on the Jarl and now you have a Jarl sitting on his throne in ragged robes hahahah

 

The only thing I can think of is that because CitizenOutfit is a script driven property and not a property that is filled with an In game object then perhaps it is only filled on that specific instance of the script running

 

So maybe because CitizenOutfit01 was filled on a different TopicInfo to the TopicInfo it is actually used it won't work?

 

I ran a little test where I set the CitizenOutfit01 IMMEDIATELY after setting the BeggarOutfit when making the NPC a Beggar and that worked so I know that CitizenOutfit01 is filling properly, It just isn't carrying over to the TopicInfo that releases the Beggar.

 

So basically I just need a solution to how I can get the original outfit to carry over to the next TopicInfo. Everything else works fine.

Edited by xEthann
Link to comment
Share on other sites

The properties are all filled except the CitizenOutfit01 as it is a script driven property - I fill that with the originalOutfit() function, All of the debug notifications fire - I placed them intentionally so I would know the code is working. With regard to the CitizenOutfit01 being filled, The makeBeggar() and originalOutfit() functions should always run first as it is impossible for the NPC to have the keyword AAInfluenceIsBeggar without the makeBeggar() function (I have added the keyword to the quest alias and that is only way to fill it)

 

So the way it will work is, I approach an NPC and there will be an option "You are stripped of all your earthly possessions and are cast out of the city!" (I'm making a sort of social class system that the player can influence with dialogue)

Then the NPC fills the quest alias WhiterunBeggar01 and follows the AI Packages etc and is given a new outfit.

 

Then, there is another dialogue option that is conditional to the NPC having the keyword AAInfluenceIsBeggar which then says "You may re-enter the city, your banishment has been lifted" And then this triggers the releaseBeggar() function (which works perfectly) and then sets the outfit to CitizenOutfit01 (which should've been filled when the NPC was made a beggar) but for some reason it doesn't change and now I have an NPC wandering around the city wearing rags - doesn't look the best when you use it on the Jarl and now you have a Jarl sitting on his throne in ragged robes hahahah

 

The only thing I can think of is that because CitizenOutfit is a script driven property and not a property that is filled with an In game object then perhaps it is only filled on that specific instance of the script running

 

So maybe because CitizenOutfit01 was filled on a different TopicInfo to the TopicInfo it is actually used it won't work?

 

I ran a little test where I set the CitizenOutfit01 IMMEDIATELY after setting the BeggarOutfit when making the NPC a Beggar and that worked so I know that CitizenOutfit01 is filling properly, It just isn't carrying over to the TopicInfo that releases the Beggar.

 

So basically I just need a solution to how I can get the original outfit to carry over to the next TopicInfo. Everything else works fine.

 

Personally I think you should try to avoid putting significant code in fragments like this. I'd put all the outfit & alias manipulation into a Quest script with functions for the TopicInfo fragments to call. That will make troubleshooting (and data passing) significantly simpler.

Link to comment
Share on other sites

I see, thank you for the suggestion it is greatly appreciated - I have only really been using the creation kit for about a week and a bit so I'm still unsure how a lot of it works. Do you know any resources I can use to learn how to set up a quest script and then link it to the Topic Info?

 

Thanks again :)

Link to comment
Share on other sites

I see, thank you for the suggestion it is greatly appreciated - I have only really been using the creation kit for about a week and a bit so I'm still unsure how a lot of it works. Do you know any resources I can use to learn how to set up a quest script and then link it to the Topic Info?

 

Thanks again :smile:

 

I'd generally recomment hitting up the CK wiki. But if you're creating fragment scripts with working properties and such you already have pretty much everything you need -- a working quest, you know how to navigate the CK, add & fill properties, etc.

 

On the main Quest screen, at the top, there's a tab list. You should be familiar with it b/c you've been doing dialogue. At the far right there's one called Scripts, which is a list of all the scripts that're attached to that Quest (there's similar windows for anything that can have scripts -- MagicEffects, Aliases, various kinds of ObjectReference, etc), The buttons beside should be familiar and reasonably self-explanatory. Hit "Add", and create a new script (named as you wish) that extends Quest.

This will open up the CK Papyrus editor & compiler with the scriptname line already generated. Write all your processing code -- GetOutfit, SetOutfit, etc -- here, in functions. Set properties per normal.

 

Then change your TopicInfo fragments to say this:

 

(GetOwningQuest() as ScriptName).SetBeggar()

 

and

 

(GetOwningQuest() as ScriptName).ClearBeggar()

 

Using whatever function names/script name you choose. What this does is have the topicinfo fragments tell the *quest script* to run those functions (just as when you say Actor.SetOutfit(), you're calling a function that runs on the actor; only in this case, you're accessing code you yourself wrote, not the basic stuff that shipped with the game). Because Quests are script objects that are always loaded they are extraordinarily useful for persistent data storage and state tracking, and in this case you need one anyway for the dialogue :)

 

 

(According to the Wiki TopicInfo script variables get cleared for memory reasons, so presumably that's what's been causing your issues, BTW)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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