Jump to content

Apply Script or Effect to all Vendors


Recommended Posts

I currently am using a quest and during the OnInit() event I use RegisterForRemoteEvent() to then add the OnDeath event for Takahashi so that I can run a certain script when Takahashi is killed. Is there a way to apply this to all vendors in an easy way or will I have to do it manually for each vendor?

 

ObjectReference Property PTakBox Auto Const Mandatory

Event OnQuestInit()

RegisterForRemoteEvent( PTakBox.GetActorOwner().GetUniqueActor(), "OnDeath")

EndEvent

Event Actor.OnDeath(Actor akSender, Actor akKiller)

if akSender == PTakBox.GetActorOwner().GetUniqueActor
PTakBox.RemoveAllItems(akTransferTo = akSender)
endIf

endEvent

Link to comment
Share on other sites

You can give the player a cloak via an ability that applies a script to all actors that meet certain conditions. There are several different mods and vanilla features that use this method.

 

An example of a vanilla feature would be the power armor targeting HUD modification. Instead of an ability, this uses an enchantment, but you can easily substitute it for an ability that you give to the player via a perk. The forms go:

  1. EnchPA_TargetingHUD (an enchantment on the object mod)
  2. PA_TargetingHUD_Cloak (a cloak that the enchantment grants)
  3. DetectLifeCloakSpell (a spell that the cloak applies)
  4. DetectLifeCloakEffect (a script that the spell applies to the actors that meet the specified conditions)

Keep in mind that DetectLifeCloakEffect uses a script effect archetype so that it can apply the effect shader without doing anything else. You could either add a script on top of the effect shader, or remove the effect shader and add the script.

 

A better example would be the locational damage mod. I say better because it works in the way that you want it to work, without having to make those changes I mentioned. The forms work in a similar way:

  1. BLD_Cloak (an ability on the player instead of an enchantment on an object mod)
  2. BLD_CloakApplyEffect (a cloak that the ability applies to the player)
  3. BLD_ApplyScript (a spell that the cloak applies)
  4. DetectLifeCloakEffect (a script that the spell applies to the actors that meet the specified conditions)

So if you set up something like this, all you would need is a set of conditions that allow the spell to identify just the vendors (e.g. a keyword, a conditional property, a faction, etc.) - I would check the WorkshopParent aliases, which would likely apply something that you can check for to just the vendors.

 

Make sure to create a new perk that has the first spell as an ability, and to add that perk to the player via a quest or something.

Link to comment
Share on other sites

There is a super easy way to get the quest story manager to do this stuff for you ...

 

1. Create a new Formlist and drag all the Actor references you want from the cell view list into it.

 

2. Quest - Alias - ReferenceCollection - Max Initial fill 255 - Find Matching reference - Conditions (this can take some messing around to get the right factions, keywords and whatnot so I use lists):

 

2a GetIsObjectType: Actor

2b IsInList: Your form list

 

3. Attach a new script to the alias that will run against any and all members:

 

Event OnDeath(ObjectReference akVictimRef, Actor akKiller)
Self.RemoveRef(akVictimRef)
; do all your other stuff here
EndEvent
Link to comment
Share on other sites

You can give the player a cloak via an ability that applies a script to all actors that meet certain conditions. There are several different mods and vanilla features that use this method.

 

An example of a vanilla feature would be the power armor targeting HUD modification. Instead of an ability, this uses an enchantment, but you can easily substitute it for an ability that you give to the player via a perk. The forms go:

  1. EnchPA_TargetingHUD (an enchantment on the object mod)
  2. PA_TargetingHUD_Cloak (a cloak that the enchantment grants)
  3. DetectLifeCloakSpell (a spell that the cloak applies)
  4. DetectLifeCloakEffect (a script that the spell applies to the actors that meet the specified conditions)

Keep in mind that DetectLifeCloakEffect uses a script effect archetype so that it can apply the effect shader without doing anything else. You could either add a script on top of the effect shader, or remove the effect shader and add the script.

 

A better example would be the locational damage mod. I say better because it works in the way that you want it to work, without having to make those changes I mentioned. The forms work in a similar way:

  1. BLD_Cloak (an ability on the player instead of an enchantment on an object mod)
  2. BLD_CloakApplyEffect (a cloak that the ability applies to the player)
  3. BLD_ApplyScript (a spell that the cloak applies)
  4. DetectLifeCloakEffect (a script that the spell applies to the actors that meet the specified conditions)

So if you set up something like this, all you would need is a set of conditions that allow the spell to identify just the vendors (e.g. a keyword, a conditional property, a faction, etc.) - I would check the WorkshopParent aliases, which would likely apply something that you can check for to just the vendors.

 

Make sure to create a new perk that has the first spell as an ability, and to add that perk to the player via a quest or something.

Thanks alot! I appreciate it. I'll have to give it a go.

Link to comment
Share on other sites

 

There is a super easy way to get the quest story manager to do this stuff for you ...

 

1. Create a new Formlist and drag all the Actor references you want from the cell view list into it.

 

2. Quest - Alias - ReferenceCollection - Max Initial fill 255 - Find Matching reference - Conditions (this can take some messing around to get the right factions, keywords and whatnot so I use lists):

 

2a GetIsObjectType: Actor

2b IsInList: Your form list

 

3. Attach a new script to the alias that will run against any and all members:

 

Event OnDeath(ObjectReference akVictimRef, Actor akKiller)
Self.RemoveRef(akVictimRef)
; do all your other stuff here
EndEvent

 

Thanks! I'll have to try this.

Link to comment
Share on other sites

With the right story manager conditions you can get the quest alias to fill totally automagically with any X (say vendors) that happen to be in the game, which is great as it allows for DLCs and other mods no hard coding.

 

The challenge is finding the right conditional attributes or incantations for this stuff.

 

Whilst the generic wasteland and workshop traders are all in the DialogueMechantsFaction, there is no common vendor faction / keyword / linkref to test that includes uniques, so they need to be driven by a fixed lookup list.

 

Memo: having a standard IamaVendor (don't shoot me) keyword would be super useful for many of my mods.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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