Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: koktengri on January 14, 2017, 01:55:19 pm

Title: ATOA ACBS: Make a certain steal skill succes rate always 100%, (RPG XP)
Post by: koktengri on January 14, 2017, 01:55:19 pm
I've posted this in another forum but I forgot that it was pretty much dead. So, Im taking this here.
Yes, how do I make myself clear in the best way?
In my project, Im using atoa aka known as victor sants ATOA ACBS.
Theres a steal skill implemented that I use.
The rate for success of stealing is definable on ACBS | Config 1 - Basic line 501:
Steal_Rate = 50
So the steal rate is 50.

Problem is, that Im planning to have two different steal skills with different success rates.
The first steal skills success rate is listed above.
However, I want to add another steal skill which success should ALWAYS 100%. The problem is that the rate applies for all steal skills.

On ACBS | Game Enemy line 120 the succes rate is defined. At least I think its the right line, Im not 100% sure.
steal_success = rand(100) < (Steal_Rate + self.steal_attempt) * user.agi / self.agi

Can somebody edit the script so that the steal rate will ALWAYS be 100% if the using skills ID is 550? 550 is basically the skills ID Im going to use. I mean the skill that will/should always steal 100%.


And heres the demo of the full script:
https://workupload.com/start/OOmU2prO
the full code:

#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
#  This class handles enemies. It's used within the Game_Troop class
#  ($game_troop).
#==============================================================================

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :steal_items     # steal item list
  attr_accessor :steal_attempt   # steal attempts value
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     troop_id     : troop ID
  #     member_index : troop member index
  #     enemy_id     : enemy ID
  #--------------------------------------------------------------------------
  def initialize(troop_id, member_index, enemy_id = nil)
    super()
    @troop_id = troop_id
    @member_index = member_index
    troop = $data_troops[@troop_id]
    @enemy_id = enemy_id.nil? ? troop.members[@member_index].enemy_id : enemy_id
    enemy = $data_enemies[@enemy_id]
    @battler_name = enemy.battler_name
    @battler_hue = enemy.battler_hue
    @maxhp = maxhp
    @maxsp = maxsp
    @hp = @maxhp
    @sp = @maxsp
    @str = base_str
    @dex = base_dex
    @agi = base_agi
    @int = base_int
    @gold = gold
    @exp = exp
    @hidden = enemy_id.nil? ? troop.members[@member_index].hidden : false
    @immortal = enemy_id.nil? ? troop.members[@member_index].immortal : false
    @steal_items = Enemy_Steal[@enemy_id].to_a
    @steal_attempt = 0
    @moving = @sp_damage = false
    battler_position_setup
  end
  #--------------------------------------------------------------------------
  # * Check if battler is an actor
  #--------------------------------------------------------------------------
  def actor?
    return false
  end
  #--------------------------------------------------------------------------
  # * Decide if Command is Inputable
  #--------------------------------------------------------------------------
  def inputable?
    return super
  end
  #--------------------------------------------------------------------------
  # * Type string setting
  #--------------------------------------------------------------------------
  def type_name
    return 'Enemy'
  end
  #--------------------------------------------------------------------------
  # Definição de arma atual
  #--------------------------------------------------------------------------
  def current_weapon
    return nil
  end
  #--------------------------------------------------------------------------
  # * Set initial position
  #--------------------------------------------------------------------------
  def battler_position_setup
    base_x = @troop_id == 0 ? 0 : self.screen_x
    base_y = @troop_id == 0 ? 0 : self.screen_y
    @base_x = @original_x = @actual_x = @target_x = @initial_x = @hit_x = @damage_x = base_x
    @base_y = @original_y = @actual_y = @target_y = @initial_y = @hit_y = @damage_y = base_y
  end
  #--------------------------------------------------------------------------
  # * Set multi drop items
  #--------------------------------------------------------------------------
  def multi_drops
    drop_items = []
    return drop_items if Enemy_Drops[@enemy_id].nil?
    Enemy_Drops[@enemy_id].each do |item, drop_rate|
      item = item.split('')
      if item[0] == 'i'
        item = item.join
        item.slice!('i')
        if (rand(1000) < (drop_rate * 10).to_i) and not
           (item_id == $data_items[item.to_i].id)
          drop_items << $data_items[item.to_i]
        end
      elsif item[0] == 'a'
        item = item.join
        item.slice!('a')
        if (rand(1000) < (drop_rate * 10).to_i) and not
           (armor_id == $data_armors[item.to_i].id)
          drop_items << $data_armors[item.to_i]
        end
      elsif item[0] == 'w'
        item = item.join
        item.slice!('w')
        if (rand(1000) < (drop_rate * 10).to_i) and not
           (weapon_id == $data_weapons[item.to_i].id)
          drop_items << $data_weapons[item.to_i]
        end
      end
    end
    return drop_items
  end
  #--------------------------------------------------------------------------
  # * Set steal items
  #     user : user
  #     ext  : steal action extensio
  #--------------------------------------------------------------------------
  def stole_item_set(user, ext)
    return false unless ext != nil
    @item_stole = @item_to_steal = @stole_item_index = nil
    steal_success = rand(100) < (Steal_Rate + self.steal_attempt) * user.agi / self.agi
    #steal_success = 100 if
    self.steal_attempt += 1
    return nil if self.steal_items.nil? or self.steal_items == []
    return false unless steal_success
    @item_stole = []
    ext.slice!('STEAL/')
    self.steal_items.each do |item, steal_rate|
      item = item.split('')
      if item[0] == 'i' and not ext == 'GOLD'
        item = item.join
        item.slice!('i')
        @item_stole << $data_items[item.to_i] if rand(1000) < (steal_rate * 10).to_i
      elsif item[0] == 'a' and not ext == 'GOLD'
        item = item.join
        item.slice!('a')
        @item_stole << $data_armors[item.to_i] if rand(1000) < (steal_rate * 10).to_i
      elsif item[0] == 'w' and not ext == 'GOLD'
        item = item.join
        item.slice!('w')
        @item_stole << $data_weapons[item.to_i] if rand(1000) < (steal_rate * 10).to_i
      elsif item[0] == 'g' and not ext == 'ITEM'
        item = item.join
        item.slice!('g')
        @item_stole << item.to_i if rand(1000) < (steal_rate * 10).to_i
      end
    end
    return false if @item_stole == []
    self.steal_attempt = 0
    @stole_item_index = rand(@item_stole.size)
    @item_to_steal = @item_stole[@stole_item_index]
    if Multi_Steal
      self.steal_items.delete_at(@stole_item_index)
    else
      self.steal_items = []
    end
    return @item_to_steal
  end
  #--------------------------------------------------------------------------
  # * Make Action
  #--------------------------------------------------------------------------
  def make_action
    self.current_action.clear
    return unless self.movable?
    available_actions = []
    rating_max = 0
    for action in self.actions
      n = get_battle_turn
      a = action.condition_turn_a
      b = action.condition_turn_b
      next if (b == 0 and n != a) or (b > 0 and (n < 1 or n < a or n % b != a % b))
      next if self.hp * 100.0 / self.maxhp > action.condition_hp
      next if $game_party.max_level < action.condition_level
      switch_id = action.condition_switch_id
      next if switch_id > 0 and $game_switches[switch_id] == false
      next if action.kind == 1 and not skill_can_use?(action.skill_id) and Enemy_Dont_Skip_Action
      available_actions.push << action
      rating_max = [rating_max, action.rating].max
    end
    ratings_total = 0
    for action in available_actions
      ratings_total += action.rating - (rating_max - 3)  if action.rating > rating_max - 3
    end
    if ratings_total > 0
      value = rand(ratings_total)
      for action in available_actions
        if action.rating > rating_max - 3
          if value < action.rating - (rating_max - 3)
            self.current_action.kind = action.kind
            self.current_action.basic = action.basic
            self.current_action.skill_id = action.skill_id
            self.current_action.decide_random_target_for_enemy
            return
          else
            value -= action.rating - (rating_max - 3)
          end
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Get Battle Turn
  #--------------------------------------------------------------------------
  def get_battle_turn
    return $game_temp.battle_turn
  end
  #--------------------------------------------------------------------------
  # * Get Battle Screen X-Coordinate
  #--------------------------------------------------------------------------
  def screen_x
    return $data_troops[@troop_id].members[@member_index].x + Enemy_Position_AdjustX
  end
  #--------------------------------------------------------------------------
  # * Get Battle Screen Y-Coordinate
  #--------------------------------------------------------------------------
  def screen_y
    return $data_troops[@troop_id].members[@member_index].y + Enemy_Position_AdjustY
  end
  #--------------------------------------------------------------------------
  # * Get Battle Screen Z-Coordinate
  #--------------------------------------------------------------------------
  def screen_z
    return screen_y
  end
end
Title: Re: ATOA ACBS: Make a certain steal skill succes rate always 100%, (RPG XP)
Post by: KK20 on January 14, 2017, 07:10:34 pm
If all you want is to basically make the constant Steal_Rate have different values for different skills, you can do this:

In Config 1 - Basic, change Steal_Rate to this

  # Steal Base Rate (Format: {skill_id => rate, skill_id => rate, ...and so on}
  Steal_Rate = {82 => 50, 550 => 100}


Then in ACBS | Game_Enemy, find the def stole_item_set and make this change a few lines down

  def stole_item_set(user, ext)
    return false unless ext != nil
    @item_stole = @item_to_steal = @stole_item_index = nil
    steal_rate = Steal_Rate[user.current_action.skill_id]
    steal_success = rand(100) < (steal_rate + self.steal_attempt) * user.agi / self.agi
    #...rest of code redacted for length...
Title: Re: ATOA ACBS: Make a certain steal skill succes rate always 100%, (RPG XP)
Post by: koktengri on January 15, 2017, 02:56:01 am
Thanks.
Thats a help for now. But my problem is not solved. The problem is even if I set the steal rate to 100% for skillid 550, sometimes the steal still doesnt work, especially if the Item steal chance is set to low like 10%. I basically want the steals success to be 100% for the skill id 550. Even in the #code it says: "Even if the rate is 100%, that dont't grants 100% of chance of getting an item"
Title: Re: ATOA ACBS: Make a certain steal skill succes rate always 100%, (RPG XP)
Post by: KK20 on January 15, 2017, 03:36:57 am
Would you like it if I were to just change the Steal_Rate to be a flat rate rather than being based on character agility too? Also, how are you configuring your item steal rates--are you just configuring those to 100% or do you still want variable amounts for each?
Title: Re: ATOA ACBS: Make a certain steal skill succes rate always 100%, (RPG XP)
Post by: koktengri on January 15, 2017, 03:53:56 am
Well, it would be good if the character agility would be considered too in the formular, but if its not possible to make a certain skill give a 100% chance of stealing with it, you can take it out if you like so. Its not that important.
I configurate my steal items different each. Of course, they also have %. Some items can be stolen by 50% chance, some 90%. I'd want to keep the possibility to have different items at different chances.

btw. the items can be configurated at ACBS | Config 2 - Advance
example:
#¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
  # STEAL ITEMS
  #¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
  # Enemy_Steal[ID] = {'ITEM' => RATE}
  #
  # ID = Enemy ID
  # ITEM = Item type and ID. Must be expressed as 'xY'
  #  where x = item type and Y = item ID
  #  x must be 'a' for armors, 'w' for weapons, 'i' for items, 'g' for money
  #  E.g.: 'a12' = Armor ID 12
  # RATE = Item drop %. An value between 0 and 100, can be decimals
  #  E.g.: '5.4' = 5.4% drop rate
  #
  # E.g.: Enemy_Drops[15] = {'w6' => 22.5, 'g900' => 12}
  # That means enemy ID 15 (Enemy_Drops[15])
  # has 22,5% of dropping the weapon ID 6 ('w6' => 22.5) when stole,
  # and have 12% of dropping 900 gold ('g900' => 12) when stole.
  #
  # Repeated items won't be considered
  #
  Enemy_Steal[1] = {'g100' => 50, 'w1' => 50, 'a1' => 15}
Title: Re: ATOA ACBS: Make a certain steal skill succes rate always 100%, (RPG XP)
Post by: KK20 on January 15, 2017, 04:07:27 am
Place the following blocks of code in their respective places:
ACBS Config 1 - Basic : ShowHide

  # Steal Base Rate
  # Even if the rate is 100%, that dont't grants 100% of chance of getting an item
  # this value changes with the difference bettwen, the user and target's AGI, and
  # it still necessary to verify the drop rate of each item
  Steal_Rate = {82 => 50}
  # Rather than rely on agility like above, skills here are just flat rates. A
  # rate of 100% means the steal will always work. However, individual item
  # success rates will still be applied (meaning you could still fail stealing)
  Flat_Steal_Rate = {550 => 100}
  # Skills listed here will disregard item success rates and default to 100%
  Always_Steal = [550]

ACBS Game_Enemy : ShowHide

  #--------------------------------------------------------------------------
  # * Set steal items
  #     user : user
  #     ext  : steal action extensio
  #--------------------------------------------------------------------------
  def stole_item_set(user, ext)
    return false unless ext != nil
    @item_stole = @item_to_steal = @stole_item_index = nil
    skill_id = user.current_action.skill_id
    always_steal = Always_Steal.include?(skill_id)
    if Flat_Steal_Rate[skill_id] != nil
      steal_success = rand(100) < Flat_Steal_Rate[skill_id] + self.steal_attempt
    else
      steal_success = rand(100) < (Steal_Rate[skill_id] + self.steal_attempt) * user.agi / self.agi
    end
    self.steal_attempt += 1
    return nil if self.steal_items.nil? or self.steal_items == []
    return false unless steal_success
    @item_stole = []
    ext.slice!('STEAL/')
    self.steal_items.each do |item, steal_rate|
      item = item.split('')
      if item[0] == 'i' and not ext == 'GOLD'
        item = item.join
        item.slice!('i')
        @item_stole << $data_items[item.to_i] if always_steal || rand(1000) < (steal_rate * 10).to_i
      elsif item[0] == 'a' and not ext == 'GOLD'
        item = item.join
        item.slice!('a')
        @item_stole << $data_armors[item.to_i] if always_steal || rand(1000) < (steal_rate * 10).to_i
      elsif item[0] == 'w' and not ext == 'GOLD'
        item = item.join
        item.slice!('w')
        @item_stole << $data_weapons[item.to_i] if always_steal || rand(1000) < (steal_rate * 10).to_i
      elsif item[0] == 'g' and not ext == 'ITEM'
        item = item.join
        item.slice!('g')
        @item_stole << item.to_i if always_steal || rand(1000) < (steal_rate * 10).to_i
      end
    end
    return false if @item_stole == []
    self.steal_attempt = 0
    @stole_item_index = rand(@item_stole.size)
    @item_to_steal = @item_stole[@stole_item_index]
    if Multi_Steal
      self.steal_items.delete_at(@stole_item_index)
    else
      self.steal_items = []
    end
    return @item_to_steal
  end

I added two config constants that should be pretty self-explanatory as to what they do.
Title: Re: ATOA ACBS: Make a certain steal skill succes rate always 100%, (RPG XP)
Post by: koktengri on January 15, 2017, 05:23:09 am
Thanks, it seemed to work.
Thank you really much.