Enemy Gold Formulas

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

This script allows you to use a formula to calculate how much gold is obtained from an enemy.

enemyGoldFormulas1

Download

Script: download here

Installation

Place this script below Materials and above Main

Usage

Note-tag enemies with

<gold formula: FORMULA>

Where the FORMULA is any valid ruby formula that returns a number.
You can use the following variables in your formula:

gold - the default gold value set in the database for that enemy
   a - this enemy
   p - game party
   t - game troop
   v - game variables
   s - game switches

If no gold formula is specified, then the default gold is given.

If you would like to use ruby statements that extend across multiple lines,
you can use the extended note-tag:

<gold formula>
if v[1]
  gold + 200
else
  gold - 200
end
</gold formula>

This may be useful if you have complex logic and you don’t want to write it as
a one-liner.

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

You may also like...

7 Responses

  1. Doug says:

    It seems there’s an inherent error that I’ve found while debugging. Using a simple formula like:

    is fine. The problem is the following:

    Scenario: I have a troop of 1-3 slimes. 1 will always appear, two are set halfway and might appear.

    I will use a single slime as example.

    One slime at the end of battle if you debug you will see that the script rolls gold values for every one of the 3 slimes in the troop. The rolls lets say are 5g 11g 7g. The battle summary will say: You gained 7g! But in actuality 11g is placed in your inventory. I don’t know if the problem is that Game_Troop gold_total function needs to be updated as well, but this is a problem. I haven’t confirmed yet, but I think this will have the same problem to your enemy XP formula scripts. Any idea how to fix it?

  2. Hime says:

    Updated to support “this enemy” formula variable.

  3. Charlie says:

    I have a n00b question.
    What exactly do the variables ‘t’, ‘p’ etc relate to?
    As in, is it something related to the average level of the troop? Is it just the troop number in the database? The number of enemies in the troop?
    Sorry, I’m really confused.
    I want to be able to relate gold to the enemy’s level. So that you get more gold for defeating a higher level enemy.

    • Hime says:

      It is a reference to the current troop and party objects. For example, `t.turn_count` will return the current count of the battle. `t` is simply a short-hand for `$game_troop`.

      I’ve updated the script so that you can reference the current enemy in your formula with the `a` formula variable. You can get the enemy’s level using `a.level`, assuming enemy the level script you’re using provides that as the attribute name.

Leave a Reply

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax