# Discounts

This is a new feature as of v1.2.0 of the Poké Mart Plugin. It allows you to setup discounts that would apply to all items in a store. Right now there's no way to exclude an item from a discount but it might be in the future.&#x20;

```ruby
def pbSomeMart
  pbPokemonMart([
    :POKEBALL, :GREATBALL, :ULTRABALL,
    :POTION, :SUPERPOTION, :HYPERPOTION, :MAXPOTION,
    :FULLRESTORE, :REVIVE,
    :ANTIDOTE, :PARALYZEHEAL, :AWAKENING, :BURNHEAL, :ICEHEAL,
    :FULLHEAL,
    :REPEL, :SUPERREPEL, :MAXREPEL,
    :ESCAPEROPE
  ], useCat: true, discount: 27)
end
```

Enabling discount is done by adding `discount:` and a Game Variable ID.

***

There are 3 ways to setup a discount

```ruby
DISCOUNTS = {
  27 => [0, 1, 4, 7, 11]
}
```

The first way is by using a variable and assigning an array of values (in percentage (4 = 4% discount on the item's price).

* `27` = Game Variable ID 27.
  * \[0, 1, 4, 7, 11] = An Array with 1 or more discount values.
    * 0 = discount used when Game Variable 27 equals to 0.\
      ![](/files/aR3mFBhDSSZUPrhTvQS3)
    * 1 = discount used when Game Variable 27 equals to 1.\
      ![](/files/t589krGQOxKYoeKl0aIj)
    * 4 = discount used when Game Variable 27 equals to 2.\
      ![](/files/yWBybsdutCrQ8pec0pJh)
    * 7 = discount used when Game Variable 27 equals to 3.\
      ![](/files/7Do03ndixayzyNRqUtqe)
    * 11 = discount used when Game Variable 27 equals to 4.\
      ![](/files/syjO7tYrEJhYDLdFFTLF)

{% hint style="info" %}
Each number in the array has an index, the index starts at 0. The script will use the index that matches the value of the variable. If a game variable would have been set too high, you'll be notified.
{% endhint %}

***

The second way is by using a combination with an Item that is first required to be owned by the player and a Game Variable. Again you assign an array of values. You can combine multiple Variables with the same Item but you can't repeat a game variable. If you do, you might get the wrong discount as result. It's also possible to use negative values, this will result in overcharge instead of discount. (-2 = 2% extra on the item's price).

```ruby
DISCOUNTS = {
  :COUPONA => { 
    26 => [0, 3, 6, 8, 10],
    28 => [0, -2, -5] 
  },
}
```

* :COUPONA = Item ID :COUPONA
  * 26 = Game Variable ID 26.
    * \[0, 3, 6, 8 ,10]
      * 0 = discount used when Gam Variable 26 equals to 0.\
        ![](/files/n8eoX6y0TUHpCHya1Nn6)
      * 3 = discount used when Game Variable 26 equals to 1.\
        ![](/files/80ZppZhGOmjRjIcVic66)
      * 6 = discount used when Game Variable 26 equals to 2.\
        ![](/files/fH8oUQTQQZR5ozepDPed)
      * 8 = discount used when Game Variable 26 equals to 3.\
        ![](/files/APGb0ChxJ941QCMEdjec)
      * 10 = discount used when Game Variable 26 equals to 4.\
        ![](/files/dpTucopdxxtlWQIeH7Kg)
  * 28 = Game Variable ID 28.
    * \[0, -2, -5]
      * 0 = overcharge used when Game Variable 28 equals to 0.\
        ![](/files/KaCm6qHGL0tCK3jssq6E)
      * -2 = overcharge used when Game Variable 28 equals to 1.\
        ![](/files/1KLWhNTPfhRJZIfRu3zL)
      * -5 = overcharge used when Game Variable 28 equals to 2.\
        ![](/files/kbdoDNR9ianVidvVQp89)

***

You can combine discount and overcharge values in the same array but it could be easier to mange to keep them separated.

For Example you can have a game variable increase by 1 for each time the player blacks out. You can start with a discount of 10 and then decrease it each time.

```ruby
DISCOUNTS = {
  29 => [10, 8, 6, 4, 2, 0, -2, -4, -6, -8, -10, -12]
}
```

Of course you can combine this here as well with an item.

```ruby
DISCOUNTS = {
  :COUPONB => {
    29 => [10, 8, 6, 4, 2, 0, -2, -4, -6, -8, -10, -12]
  }
}
```

When Game Variable 29 would become higher than 11, the discount/overcharge would become 0. To prevent that from happening, you can work with a conditional to only increase the variable if it's smaller than 11. (There are 12 values but remember the first value is 0). A good place to increase the variable would be the start over event. But this is only an example so that's up to you how you do it.

***

The third way is by using the value of the value directly. This means that it's independable from an array you setup in DISCOUNTS. The script will use the value of the Game Variable you put in the pokemart command to use as the discount/overcharge.&#x20;

You are allowed to put -30 instead of 30 as this will make the discount an overcharge instead. Even if there's a way to make the Game Variable's value negative, you can reuse the Game Variable 30 to use as a discount for another store instead.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://arckytech.gitbook.io/arckys-poke-mart-guide/settings-and-setup-file/discounts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
