Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module FFS
- module Stealable
- # UserVarId ist die Variable-ID, welche speichert, welcher Gegner
- # den Skill verwendet hat um so eine eindeutige Zuweisung zu erhalten.
- UserVarId = 321
- # ItemStealId ist die Variable-ID, welche speichert, welches Item aus der
- # vordefinierten Tabelle gestohlen wird.
- ItemStealId = 322
- # TextVarId ist die Variable-ID, welche verwendet wird um den Text vom
- # Stehlen dynamisch in der Messagebox anzuzeigen.
- TextVarId = 323
- # Entspricht einer Prozentzahl, wieviel mindestens
- # bei einem erfolgreichen Diebstahl geklaut wird.
- MinGeldRate = 1.0
- # Entspricht einer Prozentzahl, wieviel maximal vom
- # gesamten Geld geklaut werden kann.
- MaxGeldRate = 3.0
- # Definiert die Liste, welche Items geklaut werden können.
- # Die Aufschlüsselung ist wie folgt:
- #
- # [item ID, Typ, Wahrscheinlichkeit]
- #
- # item ID entspricht der ID, welche in der Datenbank das Item festlegt.
- #
- # Typ ist ein Wert, der besagt, was für ein Item es ist.
- # 1 = Item, 2 = Waffe und 3 = Rüstung
- #
- # Wahrscheinlichkeit ist eine Zahl zwischen 1 und 9.
- # 1 besagt, das es eher unwahrscheinlich ist, wobei 9 sehr Wahrscheinlich
- # ist.
- ItemListe = [
- [ 1,1, 1],
- [ 2,1, 1],
- [ 3,1, 5],
- [ 4,1, 2],
- [ 70,2, 9],
- [ 6,3, 7],
- ] # <-- NICHT LÖSCHEN!!
- #--------------------------------------------------------------------------
- # * Get Random Steal
- #--------------------------------------------------------------------------
- def self.get_random_steal
- steal_list = []
- for i in 0...ItemListe.size
- for j in 0...ItemListe[i][2]
- steal_list.push(ItemListe[i])
- end
- end
- steal_list = randomize_list(steal_list)
- lucky_item = rand(steal_list.size)
- return steal_list[lucky_item]
- end
- #--------------------------------------------------------------------------
- # * Randomize List
- #--------------------------------------------------------------------------
- def self.randomize_list(ary)
- nary = Array.new(ary.size)
- pos = 0
- for i in 0...ary.size
- pos = rand(ary.size)
- while (nary[pos] != nil)
- pos = rand(ary.size)
- end
- nary[pos] = ary[i]
- end
- return nary
- end
- #--------------------------------------------------------------------------
- # * Check Steal
- #--------------------------------------------------------------------------
- def self.check_steal(ary, cnt=0)
- cnt += 1
- item = get_item(ary)
- if $game_party.has_item?(item)
- $game_party.lose_item(item, 1)
- return ary
- end
- return [] if cnt >= 10
- ary = get_random_steal
- check_steal(ary, cnt)
- end
- #--------------------------------------------------------------------------
- # * Get Item
- #--------------------------------------------------------------------------
- def self.get_item(item)
- case item[1]
- when 1
- item = $data_items[item[0]]
- when 2
- item = $data_weapons[item[0]]
- when 3
- item = $data_armors[item[0]]
- end
- return item
- end
- #--------------------------------------------------------------------------
- # * Make Money Steal
- #--------------------------------------------------------------------------
- def self.make_money_steal
- width_calc = Window_Base.new(0,0,0,0)
- money = 0
- money = rand() * (MaxGeldRate - MinGeldRate) + MinGeldRate
- money = ($game_party.gold / 100 * money).floor
- #~ $game_variables[UserVarId].add_stolen_gold(money, $game_variables[UserVarId].index)
- $game_troop.add_stolen_money(money, $game_variables[UserVarId].index)
- $game_party.lose_gold(money)
- if $game_switches[236] == true
- text = "%s steals %s\eC[1]%s"
- else
- text = "%s klaut %s\eC[1]%s"
- end
- text = sprintf(text, $game_variables[UserVarId].name, money, Vocab.currency_unit)
- $game_variables[YEA::MESSAGE::VARIABLE_WIDTH] = width_calc.text_size(text).width - 24
- $game_variables[TextVarId] = text
- end
- #--------------------------------------------------------------------------
- # * Make Item Steal
- #--------------------------------------------------------------------------
- def self.make_item_steal
- width_calc = Window_Base.new(0,0,0,0)
- $game_variables[ItemStealId] = FFS::Stealable.get_item($game_variables[
- ItemStealId])
- if $game_switches[236] == true
- text = "%s steals \eC[5]"
- else
- text = "%s klaut \eC[5]"
- end
- $game_variables[TextVarId] = sprintf(text, $game_variables[UserVarId].name)
- text += $game_variables[FFS::Stealable::ItemStealId].name
- text = sprintf(text, $game_variables[UserVarId].name)
- $game_variables[YEA::MESSAGE::VARIABLE_WIDTH] = width_calc.text_size(text).width
- end
- end
- end
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # * Destructively Get Control Code
- #--------------------------------------------------------------------------
- def obtain_escape_code(text)
- text.slice!(/^[\?$\.\|\^!><\{\}\\]|^[A-Z]+/i)
- end
- #--------------------------------------------------------------------------
- # * Preconvert Control Characters
- # As a rule, replace only what will be changed into text strings before
- # starting actual drawing. The character "\" is replaced with the escape
- # character (\e).
- #--------------------------------------------------------------------------
- alias :flip_convert_escape_characters_steal_text :convert_escape_characters
- def convert_escape_characters(text)
- result = flip_convert_escape_characters_steal_text(text)
- result.gsub!(/\eresultMoney/i) { $game_variables[FFS::Stealable::TextVarId].to_s }
- result.gsub!(/\eresultItem/i) { get_message($game_variables[FFS::Stealable::ItemStealId]).to_s }
- result
- end
- def get_message(item)
- text = $game_variables[FFS::Stealable::TextVarId]
- if item.is_a?(RPG::Item)
- text += escape_icon_item(item.id, :item)
- elsif item.is_a?(RPG::Weapon)
- text += escape_icon_item(item.id, :weapon)
- elsif item.is_a?(RPG::Armor)
- text += escape_icon_item(item.id, :armour)
- end
- return text
- end
- end
- class Window_Message < Window_Base
- #--------------------------------------------------------------------------
- # * Control Character Processing
- # code : the core of the control character
- # e.g. "C" in the case of the control character \C[1].
- # text : character string buffer in drawing processing (destructive)
- # pos : draw position {:x, :y, :new_x, :height}
- #--------------------------------------------------------------------------
- alias :flip_process_escape_character_steal_text :process_escape_character
- def process_escape_character(code, text, pos)
- flip_process_escape_character_steal_text(code, text, pos)
- return if code == nil
- case code.upcase
- when '?'
- wait(60)
- @pause_skip = true
- end
- end
- end
- #==============================================================================
- # ** BattleManager
- #------------------------------------------------------------------------------
- # This module manages battle progress.
- #==============================================================================
- class << BattleManager
- # ---------------------------------------------------------------------------
- # Overwrite method : process escape
- # ---------------------------------------------------------------------------
- def process_escape
- # Play Begin Escape Voice
- actor_to_speak = DiamondandPlatinum3::BattleVoices::get_battle_actor_id()
- DiamondandPlatinum3::BattleVoices::play_escape_attempt_voice(actor_to_speak)
- $game_variables[YEA::MESSAGE::VARIABLE_WIDTH] = 0
- $game_variables[YEA::MESSAGE::VARIABLE_ROWS] = 0
- $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
- success = @preemptive ? true : (rand < @escape_ratio)
- Sound.play_escape
- if success
- process_abort
- $game_party.alive_members.each do |member|
- member.battle_phase = :escape
- end
- else
- @escape_ratio += 0.1
- $game_message.add('\.' + Vocab::EscapeFailure)
- $game_party.clear_actions
- end
- wait_for_message
- # Play Voice for either successful or unsucessful escape
- if success
- DiamondandPlatinum3::BattleVoices::play_escape_successful_voice(actor_to_speak, true)
- else
- DiamondandPlatinum3::BattleVoices::play_escape_failed_voice(actor_to_speak)
- end
- # Finish Up
- return success
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement