Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: ThallionDarkshine on December 13, 2012, 08:04:41 pm

Title: [XP] Troop Treasures
Post by: ThallionDarkshine on December 13, 2012, 08:04:41 pm
Troop Treasures
Authors: ThallionDarkshine
Version: 0.1
Type: Treasure Add-on
Key Term: Enemy Add-on



Introduction

You ever have a troop filled with many small creatures at the start of your game? You want them to give you exp and gold, but assigning individual rewards would give the player way too much exp/gold. Enter Troop Treasures. This script allows you to setup treasures by encounter, in addition to normal rewards.


Features




Screenshots

It would just be a picture of the battle result window, and you all can imagine that, right?


Demo

None yet.


Script

Spoiler: ShowHide

module Treasure_Config
  def self.troop_treasures(troop_id)
    case troop_id
    when 6 then return [3, 5, []]
    when 7 then return [1, 2, []]
    else return []
    end
  end
end

class Scene_Battle
  alias tdks_treasure_strt_p5 start_phase5
  def start_phase5
    tdks_treasure_strt_p5
    t_treasures = Treasure_Config.troop_treasures(@troop_id)
    if t_treasures.length > 0
      $game_party.gain_gold(t_treasures[1])
      for i in 0...$game_party.actors.size
        actor = $game_party.actors[i]
        if actor.cant_get_exp? == false
          last_level = actor.level
          actor.exp += t_treasures[0]
          if actor.level > last_level
            @status_window.level_up(i)
          end
        end
      end
      new_treasures = []
      t_treasures[2].each { |treasure|
        if rand(100) < treasure[0]
          case treasure[1]
          when 0:
            new_treasures.push($data_items[treasure[2]])
            $game_party.gain_item(treasure[2], treasure[3])
          when 1:
            new_treasures.push($data_weapons[treasure[2]])
            $game_party.gain_weapon(treasure[2], treasure[3])
          when 2:
            new_treasures.push($data_armors[treasure[2]])
            $game_party.gain_armor(treasure[2], treasure[3])
          end
        end
      }
     
      @result_window.exp += t_treasures[0]
      @result_window.gold += t_treasures[1]
      @result_window.treasures += new_treasures
      @result_window.height += new_treasures.length * 32
      @result_window.contents = Bitmap.new(@result_window.width - 32, @result_window.height - 32)
      @result_window.refresh
    end
  end
end

class Window_BattleResult
  attr_accessor :exp, :gold, :treasures
end



Instructions

To add a new treasure, go to this line:
def self.troop_treasures(troop_id)

Insert treasures using this template:
when TROOP_ID then return [EXP_DROP, GOLD_DROP, ITEMS_ARRAY]

To insert an item into the items array, use this template:
[DROP_CHANCE, ITEM_TYPE, ITEM_ID, ITEM_AMOUNT]

The item types are as follows:
  0 - Item
  1 - Weapon
  2 - Armor



Compatibility

Might be issues with some CBSs.


Credits and Thanks




Author's Notes

None