Jump to content
  • Sign Up
IGNORED

Having difficulty creating a merchant


Recommended Posts

So I've been working on a mod concept for roguish characters but I've been having trouble with some things. I've created a fence NPC to buy stolen goods and sell you leveled arrows, armor, and the like. But anytime I sell the booger any apparel she wears it. I've seen that other people have had this problem as I see mods all the time with the descriptor "fixed the merchant wearing what you sell them bug." and thought this was a common enough problem that I could find a solution, but no such luck. My searches on to this problem have revealed no answers and I feel like like I'm just banging my head against the wall on this. So does anyone know how to fix this?

 

My merchant is the class MerchFence and has a respawing chest that they own. They sell everything just fine but the wearing what I sell them often ends up in them looking ridiculous.

 

Also as a bit of a side question, I could use some help from any script witters out there. The merchants are part of an evil group that will attack any non members on site. So once your character becomes a member I want the merchants to sell special amulets and/or Rings that you can give your companions so the the guild doesn't kill your cohorts. A sort of "he's with me" badge. Could any of you help me with that? My script writing skills are limited.

Link to comment

You can not fix the "merchant wear sold armor bug"

 

You can give him a better armor so he will not use the sold armors.

Create a armor and use the nif you want ( can  be merchant clothes nif )  Give the armor a very hight armor value and set it unplayable ( so he will not sell the armor and you can not take the "cheat armor " )  Now he will not use other armor because his armor is better.

 

--------------------------

 

The ring/amulet to add the companion in the  evil faction

Not sure... try

 

 

scn xyzAmuletAddFactionScript

 

ref rNPC
short rDoOnce

 

Begin OnAdd

    set rNPC to GetContainer
    set rDoOnce to 1

End

 

Begin GameMode

    If DoOnce == 1
        rNPC.SetFactionRank xxxxFaction 0    ;;;; 0 is the lowest rank
        set rDoOnce to 0
    endif

End

 

Begin OnUnEquip   

;;; or Begin onDrop  ;;; if the item is removed from the NPC inventory ( must not be dropped! only removed from inventory )  Maybe better if the NPC equips another amulett when you are near the evil merchant.

 

   rNPC.SetFactionRank xxxxFaction -1  ;;; -1 is remove the faction
 

End

 

----------------------

 

If you want to add the companion permanent in the faction you only need ...

 

scn xyzAmuletAddFactionScript

 

ref rNPC
short rDoOnce

 

Begin OnAdd

    set rNPC to GetContainer
    set rDoOnce to 1

End

 

Begin GameMode

    If DoOnce == 1
        rNPC.SetFactionRank xxxxFaction 0    ;;;; 0 is the lowest rank
        set rDoOnce to 0
    endif

End

 

Then you can remove the ring/amulet and use it with another companion.

 

 

 

Link to comment

Thanks Fejeena for the script help. The removal part didn't quite work but that's okay with with me. I just wanted an in game way of adding the faction instead of using console commands. Unfortunately I realized a flaw in the strategy after implementing it so I've decided to go another route with it. The amulet is passing through my character meaning its affecting my faction as well, lowering my rank. But attempting this helped me get a better idea of how to work scripts like this. I decided the best course of action was to turn the faction adding feature into a spell and sell a tome. It successfully adds the faction so all is good on that front.

 

As for my original question I feel like there has to be a way to fix this. None of the Vanilla merchants have this problem, and my merchant doesn't seem to care about how effective what she's wearing is. She has been swapping out her armor for robes. Admittedly magic robes but with no armor bonus.

 

I also manged to half way solve it. After reading your comments I got a few ideas. My merchant was wearing leveled gear. So I looked at some existing merchants and they were all wearing set clothing. So I swapped out all my leveled gear on the merchant for static equipment. It half worked. My merchant no longer wears anything that takes up the same slot as equipment she is already wearing but if I sell her anything for a slot she doesn't have anything she equips it. Once again this is not happening with the vanilla merchants so I gotta be missing something.

Link to comment

A merchant will never sell their equipped owned items.

You should specify a merchant container to the ref of your trader.

To get help in depth, read this: https://cs.elderscrolls.com/index.php?title=Adding_Sellable_Items_To_Merchant_NPC

 

And to obtain precise data, open Ongar interior in the TESCS. Right click his character and look the tab Merchant Container.

Ongar's chest is just outside his house, on the left of it, below the ground. The owner of the chest is Ongar.

 

If you want your merchant to wear things the player sells to him/her, you have to:

- transfer back equipment from the chest to the merchant

- loop all the items and specify for them your merchant's ownership <= will ensure the new items won't appear in the barter menu

- perform a reequip

- send back all non-equiped items to the chest

You can adapt this without a chest by removing ownership on all items in the merchant inventory, apart those equipped/worn.

Link to comment

My vanilla merchants always wear the things I sell.

The orc in Slash 'N Smash a weak armor, if I sell him better armor he wear the better armor.

.......

If you set in the AI package "Armor unequip" he will wear no armor, only clothes.

.........

I do not know what you can do to fix the merchants.

 

------------------------

 

Have you add the companions in the player faction ?

PlayerFaction

 

And to not affect the player you change the script to

 

scn xyzAmuletAddFactionScript

 

ref rNPC
short rDoOnce

 

Begin OnAdd

    set rNPC to GetContainer
    set rDoOnce to 1

End

 

Begin GameMode

    If DoOnce == 1

         If rNPC != Player  || rNPC.GetFactionRank xxxxFaction < 1 ;;; is not player or has no higher faction rank as 0
              rNPC.SetFactionRank xxxxFaction 0    ;;;; 0 is the lowest rank

              rNPC.SetFactionRank Playerfaction 0   ;;;; you can add the player faction
              set rDoOnce to 0

        endif
    endif

End

 

 

Begin onDrop

         If rNPC != Player || rNPC.GetFactionRank xxxxFaction == 0 ;;; is not player

               rNPC.SetFactionRank xxxxFaction -1  ;;; -1 is remove the faction
         endif

End

 

EDIT : See post below

----

If the merchant have higher rank as 0 the " rNPC.GetFactionRank > 0  " should not remove the faction from the merchant if you by all amulets/rings

You can also add the Base ID of the merchant or the merchants, you can add a list of all merchant IDs ( the base/Editor ID, not the Ref ID )

If rNPC != Player || rNPC.GetFactionRank > 0  || rNPC.GetIsID  xxxxx != 1 || rNPC.GetIsID  yyyy != 1

Now the script does not affect player, the merchants and NPCs with faction rank higer as 0

Link to comment

shit script does not work

 

here a working script, tested in game

 

scn sg01FactionaddScript

ref rNPC
short rDoOnce

 

Begin OnAdd

    set rNPC to GetContainer
    set rDoOnce to 1

End

 

Begin GameMode

    If rDoOnce == 1 && ( rNPC == Player || rNPC.GetinFaction sg01TestFaction == 1 || rNPC.GetIsID  UrbulgroOrkulg == 1 )
        set rDoOnce to 0
        return
    else
        if  rDoOnce == 1
            rNPC.SetFactionRank sg01TestFaction 0    ;;;; 0 is the lowest rank

            rNPC.SetFactionRank Playerfaction 0   ;;;; you can add the player faction

            set rDoOnce to 0
        endif
    endif

End

 

------------------------

 

The remove onDrop or OnUnEquip    does not work til now.

The script stops working when the amulet is removed...  how can a onDrop or OnUnEquip work ?

 

You can create a second amulet to remove the faction.

 

I tested it with a NPC ( was add to both factions  ) and with Player and NPC Urbulgro Orkulg, ( both NOT add to the factions )

 

-------------------------------

EDIT

The merchants:

Have tested it .... confused...  my vanilla mercants does not use sold armor. I was sure they did it.

 

OK the merchant have real armor ( no level list )

His merchant chest is locked 100 without a key ( of course owner is the mershant NPC )

 

 

Link to comment

Update. with remove faction ( tested in game )

 

You need a item that you give your companion ( amulet , ring, or misc item like a silver Vase, Shovel, Gem, Crystal Ball, .... )

In my example the ID is sg01FactionAmulet

With Script

..........................................................

scn sg01FactionaddScript

 

ref rNPC
short rDoOnce

 

Begin OnAdd

    set rNPC to GetContainer
    set rDoOnce to 1

End


Begin GameMode

    If rDoOnce == 1 && ( rNPC == Player || rNPC.GetInFaction sg01TestFaction == 1 || rNPC.GetIsID  UrbulgroOrkulg == 1 )    ;;; UrbulgroOrkulg you replace with your merchant ID
        set rDoOnce to 0
        return
    else
        if  rDoOnce == 1
            rNPC.SetFactionRank sg01TestFaction 0    ;;;; 0 is the lowest rank

            rNPC.SetFactionRank Playerfaction 0   ;;;; you can add the player faction

            rNPC.AddItem SG01RemoveFactionToken 1    ;;;; a new Item, see below


            set rDoOnce to 0
        endif
    endif

End

............................................................

If you have more merchants you can add more IDs

 If rDoOnce == 1 && ( rNPC == Player || rNPC.GetInFaction sg01TestFaction == 1 || rNPC.GetIsID  1st-Merchant-ID == 1 || rNPC.GetIsID  2nd-Merchant-ID == 1 ) 

 

...  ...  ...

 

Then you create a second item

I use clothes item with only  ID, a name , script and set to Non-playable

In TES4Edit it looks like this

Spoiler

sg1.jpg

I use ID name SG01RemoveFactionToken

The Item need a script

 

...............................................................

scn SG01RemoveFactionScript

 

ref me
short step

float passed
float timeout

 

Begin GameMode

 

    set passed to GetSecondsPassed
    set me to GetContainer

 

    if me == 0
        return
    endif

 

    if step == 0    
        set timeout to 5    
        Let step += 1

 

    elseif step == 1     ;;;; see blow the script: Step 1

 

        Let timeout -= passed
        if timeout <= 0
            Let step += 1
            return
        endif

 

    elseif step == 2

        if me==Player || me.GetDead || me.GetDisabled || me.GetInFaction sg01TestFaction == 0
            RemoveMe
        endif            

        if me.GetItemCount sg01FactionAmulet == 0
            me.SetFactionRank sg01TestFaction -1

            Let step += 1
            return
        endif

    elseif step == 3

        if me.GetInFaction sg01TestFaction == 0 || me.GetItemCount sg01FactionAmulet == 0
            RemoveMe    ;;; the item remove itself
        endif
    endif
end
....................................................

Step 1 :    this step is to have some time before the script works.  The "faction add amulet" and this "remove faction item"  are added at the same time to the NPC,  so this script can not find the new faction ( the script is faster than the add faction ) and remove the "remove faction item"  .  With the 5 seconds time before the rest of the script runs it works.

 

 

So you add the amulet to the NPC ( or misc tiem. must be in the inventory, must not be equipped )

NPC is add to the faction and a "remove faction item"  is added in NPC inventory.

If you remove the amulet .... nothing happens.

The "remove faction item"  script detects that the amulet is missing  and  removes the NPC from the faction and then remove itself.

 

And all should not work with the player or the merchant NPCs or NPCs that are already in the faction. Only with NPCs that are not in the faction.

 

Link to comment

Thanks Speele, That link helped. I didn't even know there was a Merchant's container tab. So the problem is now solved I was even able to set my merchant back up with her leveled equipment; which I'm really glad about I didn't like the idea of her being under equipped if the player didn't join her faction.

 

As for the script I want to ask a question to make sure I understand. I need to create 2 items one with the scn sg01FactionaddScript and 1 with the scn SG01RemoveFactionScript and give them both to the NPC to add them to the faction. Then remove both items when I want them out of the faction. Is that correct?

Link to comment

The Items. Yes two.

 

You give the NPC one item, the "Add faction item"  with the first script ( I named it sg01FactionaddScript  )

 

When you give it to a NPC ( that is not player, not in the evil faction and not one of the merchants)  the script will add the second item.

This second item you will not see in the NPC inventory because it is set to "non-playable"

 

Note:

Spoiler

if all merchants are in the evil faction you must not add the merchants in the script ( sg01FactionaddScript  )

...

...

 

Begin GameMode

    If rDoOnce == 1 && ( rNPC == Player || rNPC.GetInFaction sg01TestFaction == 1 || rNPC.GetIsID  merchantID == 1
        return
    else

...

...

 

The yellow NPC check you can delete and the line looks like:

   If rDoOnce == 1 && ( rNPC == Player || rNPC.GetInFaction sg01TestFaction == 1 )

 

 

 

The "non-playable" item with script check if the "Add faction item"  is still in the NPC inventory.

If you take the "Add faction item"  out of the NPC inventory:

If the "Add faction item" is not in the NPC inventory the script of the "non-playable" item will remove the faction and after the faction is removed it wil remove itself.

 

...................

The problem with only one Item was that the script stops working when it is removed from the NPC inventory, so the faction was not removed.

 

So you create two Items.

A amulet ( or Gem, Crystal Ball, ring ) with the add faction script ( sg01FactionaddScript  ) You add many of the items to your player for all your companions. ( if you want to buy it you add 10 or more of the items in the merchant chest and visit the first merchant without your companions so you can buy the items with the merchant attacks your companions )

 

And you create a non-playable item with the Remove Faction Script  (sg01RemoveFactionScript)

That item you do not add it to player or any merchant ( you can not see it in inventory ) It is like the Lovers with PK token to start sex, control the sex stages, ....  it is add and removed in the background.

 

------------------------

Merchants:

 

You can add more merchants chests

The first must be set in the  Ref NPC ID  ,  and the chest must be persistent and owner is NPC.

 

You can add more chests (in vanilla merchant shops they are below the cell floor )  , the chest must be persistent and owner is NPC.

So you can enable chests during a quest. ( you set the additional chests to "instantly disabled" )

First the merchant have only one chest and after you did a quest a second chest is enabled. ( You free a mine , kill goblins, then the smith have ore and can create new/better armors and weapon )

 

Link to comment

Okay cool, I get it now. Also put it into action and works great. So Big thanks are in order, I very much appreciate the help. All my scripting knowledge before this has come from reverse engineering other scripts and making small changes to suit my needs. This is the first time any of it has been explained to me and I've learned a lot, so once again Big Thanks.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...