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
Afficher le fichier Open project: aura-project/aura Class Usage Examples

Protected Properties

Свойство Type Description
_tabs NpcShopTab>.Dictionary

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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

Méthode Description
GetItem ( long entityId ) : Item

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

Method Details

Add() public méthode

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.
Résultat NpcShopTab

Add() public méthode

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.
Résultat NpcShopTab

Add() public méthode

Adds empty tabs.
public Add ( ) : void
Résultat void

Add() public méthode

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.
Résultat void

Add() public méthode

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).
Résultat void

Add() public méthode

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).
Résultat void

Add() public méthode

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).
Résultat void

AddQuest() public méthode

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).
Résultat void

Buy() public méthode

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

ClearTab() public méthode

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
Résultat bool

Dispose() public méthode

Unsubscribes Shop from events.
public Dispose ( ) : void
Résultat void

GetOrCreateTab() protected méthode

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

GetTabs() protected méthode

Returns thread-safe list of all tabs.
protected GetTabs ( ) : IList
Résultat IList

GetTabs() protected méthode

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
Résultat IList

Init() public méthode

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

NpcShopScript() public méthode

Creates new NpcShopScript
public NpcShopScript ( ) : System
Résultat System

OnErinnMidnightTick() protected méthode

Called at midnight (Erinn time).
protected OnErinnMidnightTick ( ErinnTime time ) : void
time Aura.Mabi.ErinnTime
Résultat void

OpenFor() public méthode

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
Résultat void

OpenRemotelyFor() public méthode

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

RandomizeItemColors() protected méthode

Randomizes colors of all items in all tabs.
protected RandomizeItemColors ( ) : void
Résultat void

SetPaymentMethod() public méthode

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

Setup() public méthode

Called when creating the shop.
public Setup ( ) : void
Résultat void

Property Details

_tabs protected_oe property

protected Dictionary _tabs
Résultat NpcShopTab>.Dictionary