Files
swg-main-wiki/How-To-Create-a-Custom-Vendor.md

5.6 KiB

(submitted by HeronOfAlexandria)

Overview

This document provides instructions for creating vendors, assigning an appearance, name, and title to the vendor, stocking the vendor, spawning the vendor, and setting a flag to turn the vendor on and off. It also covers different types of payment, such as credits and tokens.

The procedure for creating a vendor is to create the NPC, place the NPC, and then provide a table of items for the vendor to sell.

For this example, we will be creating a vendor that provides Mandalorian armor schematics in exchange for Marauder tokens and credits.

What You Need

This is not complicated, but it does have a lot of steps. You will need to understand how to get code from the source repository from GIT, and you will need to install Sitners (SIE). I used version 3.709.95. I downloaded the source code in a zip file, unzipped the files, then created the files I needed and uploaded them to my VM, as the Windows tools are easier to use.

I used NotePad++ as my text editor and SIE to create and edit string and tre files. You will need some familiarity with SIE. If this is your first-time using SIE, you will figure it out. We will be using files from the DSRC, Server Data, and Client Data repositories.

Creating the NPC

The easiest way to create the NPC is to begin with a related NPC, copy the necessary files, and modify to suit our needs. We are going to use the TCG vendor for a template; you will find the template in “dsrc\\sku.0\\sys.shared\\compiled\\game\\object\\mobile”. The filename is “shared_vendor_tcg_1.tpf

Copy this file and rename it to “shared_vendor_tutorial.tpf”. This is a text file, so we can edit it with a text editor; do so now, and take note of the screenshot below:

We are going to change lines 6 and 9. The objectName entry on line six refers to location of the string table and the key in the string table. This tells the client what string to display for the vendor. The entry tells the client to look in the string table “creature_names.stf” which is located in the mob directory and use the key “vendor_tcg_1”to find the string to display for the vendor. You will find this string table in the client assets repository (I used the client assets master branch), in the directory “string/mob.”

Below is a screenshot from SIE showing the key and the string value in the creature_names.stf file. This is the name the client will display for the vendor.

We are not going to edit this file; it is best that if you put your extensions in their own file to avoid future merge errors. We use SIE to create a new string table. We create the following entry, and save the file as “vendor_tutorial.stf

Save the file somewhere that is easy to find; we will need it later when we construct our tre file. Now change line six to match, like so:

Line 9 is used to define the appearance. The appearance files are in the “appearance” folder in the server data. We are going to leave this as it is; you can experiment on your own and look at existing files to determine the values to set.

Pending

events.java, buildout, event controller, template

Assets

shared_vendor_tok_x.tpf

shared_vendor_tok_m.tpf

shared_vendor_tok_c.tpf

game/object/mobile

Template (server mobile):

vendor_tcg_1.tpf to vendor_tok_x.tpf

vendor_tcg_1.tpf to vendor_tok_m.tpf

vendor_tcg_1.tpf to vendor_tok_c.tpf

Server: datatables/mob/creatures.tab

creatures.tab set the token type

datatables/item/vendor

token_x_vendor.tab

token_m_vendor.tab

token_c_vendor.tab

Conversations:

script/conversation

token_x_vendor.java

token_m_vendor.java

token_c_vendor.java

String file

conversation/token_x_vendor

conversation/token_m_vendor

conversation/token_c_vendor

Build out file

Do not forget the shared file

dsrc\\sku.0\\sys.server\\compiled\\game\\datatables\\buildout\\tatooine\\tatooine_6_2.tab

Copy the string file to the server

Copy the crc file to the client

To Do

Object vars:

string:item.vendor.vendor_table=token_x_vendor,int:ai.noClap=1

in

dsrc\\sku.0\\sys.server\\compiled\\game\\datatables\\item\\vendor

scripts:

npc.vendor.vendor,conversation.token_x_vendor

npc.vendor.vendor,conversation.tcg_vendor

the script is tcg_vendor.java located in dsrc\\sku.0\\sys.server\\compiled\\game\\script\\conversation\\tcg_vendor.java

Set VENDOR_TOKEN_TYPE ("item.token.type") otherwise it uses heroic tokens

The Box

Open, Examine, Destroy

Hiding Vendors

dsrc\\sku.0\\sys.server\\compiled\\game\\script\\event\\holiday_controller.java

dsrc\\sku.0\\sys.server\\compiled\\game\\script\\event\\planet_event_handler.java

Shared Area file

Broken Things

Slave I ITV

Bestine Election

Check This

item_reimbursement_list

@Contributors Upon request I've pushed a prototype of my buildout utility script. It is a work in progress, but serves its simple purpose at this time. To use, attach developer.buildout_utility to your player, spawn an object where you want it all pretty with whatever rotation and whatever, and then target it and say in spatial getBuildoutInfo and you'll get an SUI window with everything that you need to put in a buildout data table for an object to spawn correctly. Feel free to report any bugs to me. This is currently for exteriors only, but as Elour will tell you, use a dungeon_spawner for an interior anyways.

object/tangible/npe/npe_generic_uniform_box.iff

item_heron_gift_axkva_01_05