payl0ad Posted June 23, 2018 Share Posted June 23, 2018 (edited) I am working on a new mechanic that would require the player to use some kind of tool to harvest meat from animals. I have a concept of implementation that would use a consumable item that scans for corpses around the player and adds some leveled item to them. But that's yucky because it forces a pipboy interaction. What I'd rather do is hook into the quick loot menu and add a hotkey (let's use E because that's free for containers anyway) to that which makes the player consume said tool, do its business logic and the item-add thing on activation while the player is watching. I'd want controls to be frozen for a second or two to indicate the player working, just to prevent looting mid-combat. But that's cosmetics. The problem I'm having: I have no clue if that's even possible. I can't find anything about that menu in Fallout4.esm so I don't know what to reverse-engineer. My fear is that this is hidden somewhere in HUDMenu.swf but I neither can nor actually want to replace that, given that my mod would become somewhat incompatible to both HUDFramework and DEF_UI. Can anybody shed some light on this please? Other suggestions for an implementation? Edited June 23, 2018 by payl0ad Link to comment Share on other sites More sharing options...
pra Posted June 23, 2018 Share Posted June 23, 2018 I think you want the "activate" perk entry point:https://www.creationkit.com/fallout4/index.php?title=Perk_Entry_Point you will need to give that perk to the player. you can look at the silver shroud quest, the part where you can leave calling cards. or at my Grave Digger mod, which adds an option to bury corpses. Link to comment Share on other sites More sharing options...
payl0ad Posted June 23, 2018 Author Share Posted June 23, 2018 Thank you so much. I'll have a look. Link to comment Share on other sites More sharing options...
payl0ad Posted June 24, 2018 Author Share Posted June 24, 2018 (edited) Can you describe how you set things up so that you can call the script functions in the quest script from the perk entry? I've build the quest script and the structures around it but I can't seem to figure out why my fragments don't compile. I think I got the gist of what Gravedigger is doing. I'm getting: C:\Users\Username\AppData\Local\Temp\PapyrusTemp\Fragments\Perks\PRKF_tb_HarvestMeatPerk_040B40AD_1.psc(7,21): Harvest is not a function or does not existwhen trying to compile ptb_HarvestMeatQuest.Harvest(akTargetRef)The functions in the quest script: Function Harvest(ObjectReference akTarget) Actor targetActor = akTarget as Actor if (targetActor != None) Self.Butcher(targetActor) endIf EndFunction Function Butcher(Actor akVictim) ActorBase ThisVictimBase = akVictim.GetBaseObject() as ActorBase Actor Player = Game.GetPlayer() as Actor int RaceIndex = 0 if Player.GetItemCount(pButcherKit) > 0 while ( RaceIndex < pHarvestableRaces.Length ) if pHarvestableRaces[RaceIndex].HasForm(ThisVictimBase) akVictim.AddItem(pHarvestedItems[RaceIndex]) Player.RemoveItem(pButcherKit, 1) else Debug.Trace(self+": No harvestable race found on "+akVictim) endIf RaceIndex += 1 endWhile else pButcherKitMissingMessage.Show() endIf EndFunctionWhich, of course, compile just fine. Like... it's there, isn't it? http://i0.kym-cdn.com/photos/images/newsfeed/000/173/576/Wat8.jpg?1315930535 Edited June 25, 2018 by payl0ad Link to comment Share on other sites More sharing options...
pra Posted June 25, 2018 Share Posted June 25, 2018 you might have to cast ptb_HarvestMeatQuest to you quest type. Link to comment Share on other sites More sharing options...
payl0ad Posted June 25, 2018 Author Share Posted June 25, 2018 I'm sorry, I don't follow. Here is the PSC file that contains my fragment code: ;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment Scriptname Fragments:Perks:PRKF_tb_HarvestMeatPerk_040B40AD_1 Extends Perk Hidden Const ;END FRAGMENT CODE - Do not edit anything between this and the begin comment Quest Property ptb_HarvestMeatQuest Auto Const MandatoryIt clearly is a Quest type Property. Here is a screenshot of the Perk entry point and the fragment property: Anything look out of place to you? Link to comment Share on other sites More sharing options...
pra Posted June 25, 2018 Share Posted June 25, 2018 "Quest type Property" <- Yes, that's the problem. "Quest" does not have any method "Harvest". Your quest script has probably something like "Scriptname MySpecialMeatHarvestQuest extends Quest". It's the "MySpecialMeatHarvestQuest" which contains "Harvest". This means, you either have to change your property to be of type "MySpecialMeatHarvestQuest", or add a cast:(ptb_HarvestMeatQuest as MySpecialMeatHarvestQuest).harvest(akTargetRef) Link to comment Share on other sites More sharing options...
payl0ad Posted June 27, 2018 Author Share Posted June 27, 2018 Wow, now it's obvious. Thanks! Compiles without error, using this scheme: HarvestMeatQuest MyQuest = ptb_HarvestMeatQuest as HarvestMeatQuest MyQuest.Harvest(akTargetRef) Link to comment Share on other sites More sharing options...
payl0ad Posted July 1, 2018 Author Share Posted July 1, 2018 (edited) Alright, this works pretty damn fine. There's one caveat with my implementation though and I'd like to have some input from you guys. Currently, the harvesting part works any number of times on a single corpse. I'd like to limit that so a corpse can only be harvested once. Preferably in a way that is easily detectable. If there was an item that does not show up in the quick loot menu and is otherwise not playable too, I could add that to the container after harvesting and use it to block the hotkey. But I don't know if there is such an item. I also can't think of a different solution except tracking harvested ObjectRefs in an array and let the script deny service when it comes across an ObjectRef that it's seen before. But that would only help for the last 128 corpses that were harvested. Should also sorta work but feels incredibly clunky to me. Anybody want to help out? :smile: Edited July 1, 2018 by payl0ad Link to comment Share on other sites More sharing options...
pra Posted July 1, 2018 Share Posted July 1, 2018 Add a keyword to the corpse. That's the best way IMO. Then in your perk, add the condition "hasKeyword <myKeyword> == 0" Link to comment Share on other sites More sharing options...
Recommended Posts