Jump to content

Mod Advice: Vendor Item triggers time proximity perk


Recommended Posts

Short Version:

 

Somewhat experienced molder here, but mostly skyrim experience (I am aware there are a LOT of similarities).

I have been toying around with the idea for a new mod, and have yet to decide on an approach that would work in Fallout 4.

So, I am checking with the community, to see if there are any suggestions on a direction.

 

What I am trying to do

Basically, the player would rent a perk from a vendor for a period of time, that only works when close to that vendor.

 

Or in game terms - Arturo is good with weapons, but he can't mod them for you....wtf?

 

So, like this;

Player buys "Consulting Services: Basic Weapons" from arturo, then for the next 2 min, anything the player gets access to a perk (blacksmithing, gun nut, what ever) while working on the workbenches near Arturo (or what ever vendor - Kleo would sell the same thing).

 

How I was thinking of doing it;

 

A purchase would be the trigger, I chose this over a dialogue option for simplicity.

The item (a misc item, etc.), once in player's inventory, would cast a spell with a timed magic effect to add the perk.

 

Way to cast spell, I would look for on container change, since I did not want to have to have player "use" the item (other wise it could be an indigestible). I am not sure if it would be addspell, or cast - have to figure that out.

 

I have also looked into the RadiationHazardDeadly stuff...maybe that would be a way to do the proxmity?

 

What I have not figured out yet;

What is the best way to have the player get the service?

What is the best way to trigger the effect?

What kind of effect? A timed spell? A perk with a poximity check?

How do I enforce the proximity?

 

I have ideas on these things, but there are always other modders out there who know more than me, so looking for suggestions....

 

(I would do this for different vendors, selling different "services" - a doctor selling chemistry perks, etc.).

 

Thank you in advance for your thoughts.

Edited by davethepak
Link to comment
Share on other sites

Spells and such can be an overly complex method to avoid some simple scripting.

 

Consider attaching something like this to your buyable MISC items:

 

 

 

Actor    Property pPlayerREF Auto Const Mandatory
Message  Property pPerkTimerMessage Auto Const Mandatory
FormList Property pThisItemListOfPerksToGiveThePlayer Auto Const Mandatory
FormList Property pThisItemListOfPerksGivenToPlayer   Auto Const Mandatory

Int   iPerkTimer = 10
Int   iMessageTimer = 20 
Float fPerkTime = 180   ;real time seconds perk duration
Float fMessageTime = 10 ;real time seconds between reminder popup messages 
Float fMessageCount

;***************************************************

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

Utility.Wait(0.1) ; hold the script until the player is out of vendor menu 

Int iIndex = 0

While (iIndex < pThisItemListOfPerksToGiveThePlayer.GetSize)
   Perk ThisPerk = pThisItemListOfPerksToGiveThePlayer.GetAt(iIndex) as Perk 
   If (pPlayerREF.HasPerk(ThisPerk) == FALSE)
      pThisItemListOfPerksGivenToPlayer.AddForm(ThisPerk) as Perk 
      (pPlayerREF.AddPerk(ThisPerk)
   EndIf
   iIndex +=1
EndWhile

fMessageCount = 0
StartTimer(fPerkTime, iPerkTimer)        
StartTimer(fMessageTime, iMessageTimer) 

EndEvent

;***************************************************

Event OnTimer(Int iTimer) 

If (iTimer == iMessageTimer)
   fMessageCount +=1
   Float fTimerToGo = fPerkTime - (fMessageTime * fMessageCount)
   pPerkTimerMessage.Show(fTimerToGo) ; New crafting perks expire in %.0f seconds
   StartTimer(fMessageTime, iMessageTimer) 

ElseIf (iTimer == iPerkTimer)
   CancelTimer(iMessageTimer)

   While (Utility.InsdInMenuMode() == TRUE)
      Utility.Wait(1.0) ; hold the script player may be crafting
   EndWhile

   Int iIndex = 0
   While (iIndex < pThisItemListOfPerksGivenToPlayer.GetSize)
      Perk ThisPerk = pThisItemListOfPerksGivenToPlayer.GetAt(iIndex) as Perk
      pPlayerREF.RemovePerk(ThisPerk)
      iIndex +=1
   EndWhile

   pThisItemListOfPerksGivenToPlayer.Revert()
   pPlayerREF.RemoveItem((Self.GetBaseObject(), aiCount = -1, abSilent = True, akOtherContainer = None)
EndIf

EndEvent
;*************************************************** 

 

 

 

You could add an OnDistanceGreaterThan event for the vendor and remove the perks, although a user buying time limited perks (ahem consultancy) then running off is an edge case.

Link to comment
Share on other sites

Spells and such can be an overly complex method to avoid some simple scripting.

 

Consider attaching something like this to your buyable MISC items:

 

 

 

Actor    Property pPlayerREF Auto Const Mandatory
Message  Property pPerkTimerMessage Auto Const Mandatory
FormList Property pThisItemListOfPerksToGiveThePlayer Auto Const Mandatory
FormList Property pThisItemListOfPerksGivenToPlayer   Auto Const Mandatory

Int   iPerkTimer = 10
Int   iMessageTimer = 20 
Float fPerkTime = 180   ;real time seconds perk duration
Float fMessageTime = 10 ;real time seconds between reminder popup messages 
Float fMessageCount

;***************************************************

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

Utility.Wait(0.1) ; hold the script until the player is out of vendor menu 

Int iIndex = 0

While (iIndex < pThisItemListOfPerksToGiveThePlayer.GetSize)
   Perk ThisPerk = pThisItemListOfPerksToGiveThePlayer.GetAt(iIndex) as Perk 
   If (pPlayerREF.HasPerk(ThisPerk) == FALSE)
      pThisItemListOfPerksGivenToPlayer.AddForm(ThisPerk) as Perk 
      (pPlayerREF.AddPerk(ThisPerk)
   EndIf
   iIndex +=1
EndWhile

fMessageCount = 0
StartTimer(fPerkTime, iPerkTimer)        
StartTimer(fMessageTime, iMessageTimer) 

EndEvent

;***************************************************

Event OnTimer(Int iTimer) 

If (iTimer == iMessageTimer)
   fMessageCount +=1
   Float fTimerToGo = fPerkTime - (fMessageTime * fMessageCount)
   pPerkTimerMessage.Show(fTimerToGo) ; New crafting perks expire in %.0f seconds
   StartTimer(fMessageTime, iMessageTimer) 

ElseIf (iTimer == iPerkTimer)
   CancelTimer(iMessageTimer)

   While (Utility.InsdInMenuMode() == TRUE)
      Utility.Wait(1.0) ; hold the script player may be crafting
   EndWhile

   Int iIndex = 0
   While (iIndex < pThisItemListOfPerksGivenToPlayer.GetSize)
      Perk ThisPerk = pThisItemListOfPerksGivenToPlayer.GetAt(iIndex) as Perk
      pPlayerREF.RemovePerk(ThisPerk)
      iIndex +=1
   EndWhile

   pThisItemListOfPerksGivenToPlayer.Revert()
   pPlayerREF.RemoveItem((Self.GetBaseObject(), aiCount = -1, abSilent = True, akOtherContainer = None)
EndIf

EndEvent
;*************************************************** 

 

 

 

You could add an OnDistanceGreaterThan event for the vendor and remove the perks, although a user buying time limited perks (ahem consultancy) then running off is an edge case.

 

Wow, THANK YOU VERY MUCH for all that.

 

The container change event was close to what I was thinking, but the other stuff I was not even considering.

I am still learning the F4 side of the CK (have a lot of skyrim scripting experience - but still learning what the mandatory property calls are all about...and have only just recently started to mess with arrays and formlists in papyrus).

 

I was hesitant about using addperk and remove perk in scripting, because of possible issues with the player saving the game, or adding a perk before the menu runs out, etc. Maybe I could lock out saves or something - not sure.

I know it is not possible to make a mod bullet proof, but always try to think about how users are going to abuse something... ;)

 

I will review this in detail - now to find time to actually work on the mod.....sigh.

Thank you again - nice well written code.

Link to comment
Share on other sites

You might also consider a defaultemptytrigger. Only when inside this box the player has the perk or can enable the workbench

(Or scrap the perk idea completely and just use the trigger.)

 

Fascinating - excellent idea!

I think I might stay away from anything in the worldspace, as my PC does NOT like rendering things in CK (get 60fps in game, get crap in CK).

Also, I want to ensure maximum future compatibility with any mods that alter diamond city or the vendors.

 

I am going to research this however - as I have never used it and always good to learn and add new things to my toolbelt.

 

thank you for your response - this is excellent - getting good input from the community for things I would not have known possible.

Link to comment
Share on other sites

Mods that change DC wouldn't matter in this regard.

Only that Arturo has the item to buy/sell and you've got an "On Itemadded()... script attached to it"

 

DC has tons of layers that can be disabled btw... but I get it. At Bunker Hill you'd have even more problems.

 

 

The most important matter is: How does Arturo have an item added to his vendor inventory? Through an injector script or a unstable approach. (Just putting the item into the vendor container)

 

 

 

There's a third approach to this idea. You can use the workbench by default, but you'd have to pay 50 caps. If you can't pay you can't use it. (The caps would vanish into "thin air" or could be added to Arturo if you're into putting extra stuff into scripts)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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