C# Class Aura.Channel.Scripting.Scripts.NpcShopScript

Represents a regular NPC shop.
The difference between a gold and a ducat shop is: none. The secret lies in the DucatPrice value of ItemOptionInfo. If it is > 0, the client shows that, instead of the gold price, and assumes that you're paying with ducats. TODO: Find the best way to add ducat items. Mixing the two should be possible I suppose. AddItem/AddDucatItem? Selling items always uses gold (option to sell for ducats?). Aside from Ducats and Gold there are two more currencies, Stars and Pons. The client will show the buy currency based on the values set, Duncan > Stars > Gold. Pons overweights everything, but it's displayed alongside other prices if they aren't 0.
Inheritance: IScript, IDisposable
Show file Open project: aura-project/aura Class Usage Examples

Protected Properties

Property Type Description
_tabs NpcShopTab>.Dictionary

Public Methods

Method Description
Add ( string tabTitle, Func shouldDisplay = null ) : NpcShopTab

Adds empty tab.

Add ( string tabTitle, bool randomizeColors, Func shouldDisplay = null ) : NpcShopTab

Adds empty tab.

Add ( ) : void

Adds empty tabs.

Add ( string tabTitle, Item item, int price, int stock ) : void

Adds item to tab.

Add ( string tabTitle, int itemId, int amount = 1, int price = -1, int stock = -1 ) : void

Adds item to tab.

Add ( string tabTitle, int itemId, string metaData, int price = -1, int stock = -1 ) : void

Adds item to tab.

Add ( string tabTitle, int itemId, uint color1, uint color2, uint color3, int price = -1, int stock = -1 ) : void

Adds item to tab.

AddQuest ( string tabTitle, int questId, int price, int stock = -1 ) : void

Adds quest scroll item to tab.

Buy ( Creature creature, long itemEntityId, bool moveToInventory, bool directBankTransaction ) : bool

ClearTab ( string tabTitle ) : bool

Removes all items from tab.

This, just like adding items at run-time, does not live update the currently open shops. Afaik it's not on officials either, but it would be possible, if we create a list of open shop instances and use the clear and fill shop packets.

Dispose ( ) : void

Unsubscribes Shop from events.

Init ( ) : bool

Initializes shop, calling setup and adding it to the script manager.

NpcShopScript ( ) : System

Creates new NpcShopScript

OpenFor ( Creature creature, NPC owner ) : void

Sends OpenNpcShop for creature and this shop.

OpenRemotelyFor ( Creature creature ) : void

Sends OpenShopRemotelyR and OpenNpcShop for creature and this shop.

SetPaymentMethod ( string tabTitle, PaymentMethod method ) : void

Sets the payment method for the given tab.

Setup ( ) : void

Called when creating the shop.

Protected Methods

Method Description
GetOrCreateTab ( string tabTitle ) : NpcShopTab

Returns the given tab, after creating if necessary.

GetTabs ( ) : IList

Returns thread-safe list of all tabs.

GetTabs ( Creature creature, NPC owner ) : IList

Returns thread-safe list of visible tabs, or all tabs if one of the parameters is null.

TODO: This could be cached.

OnErinnMidnightTick ( ErinnTime time ) : void

Called at midnight (Erinn time).

RandomizeItemColors ( ) : void

Randomizes colors of all items in all tabs.

Private Methods

Method Description
GetItem ( long entityId ) : Item

Returns item from one of the tabs by id. or null.

Method Details

Add() public method

Adds empty tab.
public Add ( string tabTitle, Func shouldDisplay = null ) : NpcShopTab
tabTitle string Tab title displayed in-game
shouldDisplay Func Function that determines whether tab should be displayed, set null if not used.
return NpcShopTab

Add() public method

Adds empty tab.
public Add ( string tabTitle, bool randomizeColors, Func shouldDisplay = null ) : NpcShopTab
tabTitle string Tab title displayed in-game
randomizeColors bool Determines whether item colors are randomized on midnight.
shouldDisplay Func Function that determines whether tab should be displayed, set null if not used.
return NpcShopTab

Add() public method

Adds empty tabs.
public Add ( ) : void
return void

Add() public method

Adds item to tab.
public Add ( string tabTitle, Item item, int price, int stock ) : void
tabTitle string
item Item
price int Uses db value if lower than 0.
stock int Amount of times item can be bough, unlimited if lower than 0.
return void

Add() public method

Adds item to tab.
public Add ( string tabTitle, int itemId, int amount = 1, int price = -1, int stock = -1 ) : void
tabTitle string
itemId int
amount int
price int Uses db value if lower than 0 (default).
stock int Amount of times item can be bough, unlimited if lower than 0 (default).
return void

Add() public method

Adds item to tab.
public Add ( string tabTitle, int itemId, string metaData, int price = -1, int stock = -1 ) : void
tabTitle string
itemId int
metaData string
price int Uses db value if lower than 0 (default).
stock int Amount of times item can be bough, unlimited if lower than 0 (default).
return void

Add() public method

Adds item to tab.
public Add ( string tabTitle, int itemId, uint color1, uint color2, uint color3, int price = -1, int stock = -1 ) : void
tabTitle string
itemId int
color1 uint
color2 uint
color3 uint
price int Uses db value if lower than 0 (default).
stock int Amount of times item can be bough, unlimited if lower than 0 (default).
return void

AddQuest() public method

Adds quest scroll item to tab.
public AddQuest ( string tabTitle, int questId, int price, int stock = -1 ) : void
tabTitle string
questId int
price int
stock int Amount of times item can be bough, unlimited if lower than 0 (default).
return void

Buy() public method

public Buy ( Creature creature, long itemEntityId, bool moveToInventory, bool directBankTransaction ) : bool
creature Aura.Channel.World.Entities.Creature
itemEntityId long
moveToInventory bool
directBankTransaction bool
return bool

ClearTab() public method

Removes all items from tab.
This, just like adding items at run-time, does not live update the currently open shops. Afaik it's not on officials either, but it would be possible, if we create a list of open shop instances and use the clear and fill shop packets.
public ClearTab ( string tabTitle ) : bool
tabTitle string
return bool

Dispose() public method

Unsubscribes Shop from events.
public Dispose ( ) : void
return void

GetOrCreateTab() protected method

Returns the given tab, after creating if necessary.
protected GetOrCreateTab ( string tabTitle ) : NpcShopTab
tabTitle string
return NpcShopTab

GetTabs() protected method

Returns thread-safe list of all tabs.
protected GetTabs ( ) : IList
return IList

GetTabs() protected method

Returns thread-safe list of visible tabs, or all tabs if one of the parameters is null.
TODO: This could be cached.
protected GetTabs ( Creature creature, NPC owner ) : IList
creature Aura.Channel.World.Entities.Creature Creature opening the shop
owner Aura.Channel.World.Entities.NPC NPC owning the shop
return IList

Init() public method

Initializes shop, calling setup and adding it to the script manager.
public Init ( ) : bool
return bool

NpcShopScript() public method

Creates new NpcShopScript
public NpcShopScript ( ) : System
return System

OnErinnMidnightTick() protected method

Called at midnight (Erinn time).
protected OnErinnMidnightTick ( ErinnTime time ) : void
time Aura.Mabi.ErinnTime
return void

OpenFor() public method

Sends OpenNpcShop for creature and this shop.
public OpenFor ( Creature creature, NPC owner ) : void
creature Aura.Channel.World.Entities.Creature Creature opening the shop
owner Aura.Channel.World.Entities.NPC NPC owning the shop
return void

OpenRemotelyFor() public method

Sends OpenShopRemotelyR and OpenNpcShop for creature and this shop.
public OpenRemotelyFor ( Creature creature ) : void
creature Aura.Channel.World.Entities.Creature Creature opening the shop
return void

RandomizeItemColors() protected method

Randomizes colors of all items in all tabs.
protected RandomizeItemColors ( ) : void
return void

SetPaymentMethod() public method

Sets the payment method for the given tab.
public SetPaymentMethod ( string tabTitle, PaymentMethod method ) : void
tabTitle string
method PaymentMethod
return void

Setup() public method

Called when creating the shop.
public Setup ( ) : void
return void

Property Details

_tabs protected property

protected Dictionary _tabs
return NpcShopTab>.Dictionary