I want to make it so that when you pick an attack method and you're about to pick the enemy you want to attack, you get to see what your chances are of hitting them. So far, I've worked something out for 1v1 battles. However, I know that with multiple enemies or actors, it's going to be problematic:
So far I have not been able to incorporate the skill's hitrate into this, only the actor's normal hitrate. Here is my code for
I need a better way to get the IDs for the actor and the skill or item they may be using. Any help on how to do this?
EDIT: This is solved! Thanks for your help, @MobiusXVI
So far I have not been able to incorporate the skill's hitrate into this, only the actor's normal hitrate. Here is my code for
Ruby:
#==============================================================================
# ** Arrow_Enemy
#------------------------------------------------------------------------------
# This arrow cursor is used to choose enemies. This class inherits from the
# Arrow_Base class.
#==============================================================================
class Arrow_Enemy < Arrow_Base
#--------------------------------------------------------------------------
# * Get Enemy Indicated by Cursor, actor performing action, and the
# competence being used in battle.
#--------------------------------------------------------------------------
def enemy
return $game_troop.enemies[@index]
end
def actor
return $game_party.actors[@index]
end
def skill
return 0
end
#---------------------------------------------------------------------------
# * Frame Update
#---------------------------------------------------------------------------
def update
super
# Skip if indicating a nonexistant enemy
$game_troop.enemies.size.times do
break if self.enemy.exist?
@index += 1
@index %= $game_troop.enemies.size
end
# Cursor right
if Input.repeat?(Input::RIGHT)
$game_system.se_play($data_system.cursor_se)
$game_troop.enemies.size.times do
@index += 1
@index %= $game_troop.enemies.size
break if self.enemy.exist?
end
end
# Cursor left
if Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
$game_troop.enemies.size.times do
@index += $game_troop.enemies.size - 1
@index %= $game_troop.enemies.size
break if self.enemy.exist?
end
end
# Set sprite coordinates
if self.enemy != nil
self.x = self.enemy.screen_x
self.y = self.enemy.screen_y
end
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
# Display enemy name and states in the help window
@help_window.set_enemy(self.enemy, self.actor, self.skill)
end
end
Ruby:
#==============================================================================
# ** Window_Help
#------------------------------------------------------------------------------
# This window shows skill and item explanations along with actor status.
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# * Set Text
# text : text string displayed in window
# align : alignment (0..flush left, 1..center, 2..flush right)
#--------------------------------------------------------------------------
def set_text(text, align = 0)
# If at least one part of text and alignment differ from last time
if text != @text or align != @align
# Redraw text
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
#--------------------------------------------------------------------------
# * Set Actor
# actor : status displaying actor
#--------------------------------------------------------------------------
def set_actor(actor)
if actor != @actor
self.contents.clear
draw_actor_name(actor, 4, 0)
draw_actor_state(actor, 140, 0)
draw_actor_hp(actor, 284, 0)
draw_actor_sp(actor, 460, 0)
@actor = actor
@text = nil
self.visible = true
end
end
#--------------------------------------------------------------------------
# * Set Enemy
# enemy : name and status displaying enemy, as well as success rate of
# action
#--------------------------------------------------------------------------
def set_enemy(enemy, actor, skill)
text = ""
state_text = make_battler_state_text(enemy, 112, false)
if state_text != ""
text += state_text
else
text += "[Normal]"
end
#get hit rate
hit = actor.hit
avoid = enemy.eva
skillhit = ConquestExeCompetence::COMPETENCES[skill][:hitbonus]
hitrate = (hit - avoid)
#if hitrate > 100
# hitrate = 100
#end
hitrate = hitrate.to_s
text += " (Hit: " + hitrate + "%)"
set_text(text, 1)
end
end
I need a better way to get the IDs for the actor and the skill or item they may be using. Any help on how to do this?
EDIT: This is solved! Thanks for your help, @MobiusXVI