SameOldBard Posted April 21, 2020 Share Posted April 21, 2020 (edited) Hi, I searched for this but I could not find a proper answer. I have two questions: 1: I need to find out through script if the player already has a perk given by a book (a perk magazine). I know I can use the HasPerk(perk) method to check if the player does have it. The issue I have is about how to figure out which Perk is associated with said Magazine. Any clues on how to get that info? 2: I tried to call SetName (sorry for the wrong value on the topic name) on a ObjectReference from a PlaceAtMe call which later I set through a ForceRefTo on an AliasReference so I can get a proper name at the Objective but so far it does not seem to be working. The text option in the Alias Reference are properly set and it does get the default name of the object that instantiated. What am doing wrong? Thanks,SameOldBard. Edited April 21, 2020 by SameOldBard Link to comment Share on other sites More sharing options...
DieFeM Posted April 21, 2020 Share Posted April 21, 2020 (edited) For #1 I would say you will need to add the perk and magazine relation in a property, I would use an array of structs for this end. MagazinePerk[] Property MagazinePerks Auto Const Struct MagazinePerk Perk MagPerk Book Magazine EndStructYou need to fill the property MagazinePerks with all magazines and its perks, then you can find out which is the perk for a given magazine with FindStruct: Int StructIndex = MagazinePerks.FindStruct("Magazine", MagazineToCheck) If Game.GetPlayer().HasPerk(MagazinePerks[StructIndex].MagPerk) ; do stuff EndIfFor #2 I would use a "Display Name" in the alias instead of SetName. The display name is a Message form that will replace the name of the reference that is stored. Name replaced with MessageYou can use a Message to replace the display name of anything in a quest's alias. Select a message on the "Display Name" dropdown on the Alias window.The Title of the Message is used instead of the alias's normal name. The Message can use text replacement (see above), including the base name of the aliased object. This is how you'd rename a sword to "Bob's Iron Longsword" for example.In order to use this, you need to mark the specified alias as "Stores Text" (this indicates to the quest that the alias name needs to be saved onto the quest instance data).If the resulting text is '[...]', then that means the alias wasn't filled. Source: https://www.creationkit.com/index.php?title=Text_Replacement Edited April 21, 2020 by DieFeM Link to comment Share on other sites More sharing options...
SameOldBard Posted April 21, 2020 Author Share Posted April 21, 2020 Hi DieFeM, thanks for replying! So, regarding #1, I have already the Form in a struct, so I was trying to avoid the need for the Perk pair by hoping that the Book object would hold a reference somewhere to the Perk, as at least in CK it does have the reference in there. For #2, the display name seems like a really good option, I will give it a try, as I do have the Form at hand and could dynamically set the value if it allows me to do the TextReplacement for that specific case. I will give it a try. Thanks again for the great reply and really useful code examples (I had no idea about the FindStruct, I've been parsing through my structs with the good old while(), this should save me a bunch of code) Cheers,SameOldBard Link to comment Share on other sites More sharing options...
SameOldBard Posted April 21, 2020 Author Share Posted April 21, 2020 So, Regarding #2, it did not work, the object which I do instantiate with the PlaceAtMe, is a placeholder, that is why I need to SetName to it (which does not seem to work). I had tried before the Text Replacement on the objective Display Text by using the <Alias.CurrentName=Aliasxx> and it was still showing the placeholder default name. Which is a very bad name for a quest marker hehe. Any idea why it is not working? I only Start the quest once I had the placeholder processed and the SetName is done. Still it does not work. I'm at a loss regarding this. I can set the names myself, but it might take a while. Link to comment Share on other sites More sharing options...
DieFeM Posted April 22, 2020 Share Posted April 22, 2020 The Message must be set to the quest that uses it (Quest Owner), in the alias must be checked "Stores Text" and maybe "Uses Stored Text" (not 100% sure, I don't recall if it is strictly necessary), the alias must be set to Specific Reference: none, and Optional (because the specific reference is none, and a quest with non filled aliases that are not optional will not start), then you need to fill the alias with the reference that placeAtMe returns. ObjectReference Ref = Game.GetPlayer().PlaceAtMe(ObjectToPlace) AliasRef.ForceRefTo(Ref) Link to comment Share on other sites More sharing options...
DieFeM Posted April 22, 2020 Share Posted April 22, 2020 Additionally, when you use FindStruct, you should check if the returned index is greater than -1, -1 means the passed argument was not found in the struct. Link to comment Share on other sites More sharing options...
SameOldBard Posted April 22, 2020 Author Share Posted April 22, 2020 All check. Again the issue is that I am instantiating a placeholder which name is not the same as the form I have a reference to. I feel up the ReferenceAlias dynamically because I don't want any cell edit. My goal is to somehow set the text to use the form name. I tried that by using SetName in the placeholder. But SetName does not seem to work, as I still get the placeholder name in the objective title.But I could not set the Form Name or Display name to to the objective. I checked the Text Replacement page a good many times and found no way I can do that without the ObjectReference already having the proper name. Link to comment Share on other sites More sharing options...
SameOldBard Posted April 22, 2020 Author Share Posted April 22, 2020 Additionally, when you use FindStruct, you should check if the returned index is greater than -1, -1 means the passed argument was not found in the struct.Perfect, thanks Link to comment Share on other sites More sharing options...
SameOldBard Posted April 22, 2020 Author Share Posted April 22, 2020 function GetReference(QuestObjective objective, ObjectiveTarget target) objRef = ResolvePlaceholder(objective, target, name) ; More non important stuff being done endFunction ObjectReference function ResolvePlaceholder(QuestObjective objective, ObjectiveTarget target) ObjectReference placeholder = _playerReference.PlaceAtMe(ObjectivePlaceholder, 1, true, true) if(placeholder == NONE) Trace("CreatePlaceholder - Could not create the Placeholder!!!") else placeholder.SetName(target.FormID.GetName()) placeholder.SetPosition(target.X, target.Y, target.Z) endif return placeholder endFunction Here a piece of the code to help understand it Link to comment Share on other sites More sharing options...
DieFeM Posted April 22, 2020 Share Posted April 22, 2020 That's how I do a name replacement for a reference created with PlaceAtMe: Link to comment Share on other sites More sharing options...
Recommended Posts