- class Game_Battler
-
- def skill_hit?(user, skill)
- if ( [3,4].include?(skill.scope) and self.hp == 0) or
- ( [5,6].include?(skill.scope) and self.hp >= 1)
- return false
- end
- # else
- return true
- end
-
- def attack_hit?(attacker)
- hit_result = (rand(100) < attacker.hit)
- return hit_result
- end
-
- def damage_correct(attacker, damage)
- # critical
- if rand(100) < 4 * attacker.dex / self.agi
- damage *= 2
- self.critical = true
- end
- # Guard
- damage /= 2 if self.guarding?
- return damage
- end
-
-
- def attack_self_damage(attacker)
- self.critical = false
- # basic damage
- atk = [attacker.atk - self.pdef / 2, 0].max
- damage = atk * (20 + attacker.str) / 20
- # Element correction
- damage *= elements_correct(attacker.element_set)
- damage /= 100
- if (damage > 0)
- damage = damage_correct(attacker, damage)
- end
- # Dispersion
- if damage.abs > 0
- amp = [damage.abs * 15 / 100, 1].max
- damage += rand(amp+1) + rand(amp+1) - amp
- end
- return damage
- end
-
- def skill_effect(user, skill)
- data = skill.name.split(/%/)
- skill_rate = data[1].nil? ? 100 : data[1].to_i
- hit_result = attack_hit?(user)
- # If hit occurs
- if hit_result == true
- damage = attack_self_damage(user)
- self.damage = damage * skill_rate / 100
- # State Removed by Shock
- remove_states_shock
- # Substract damage from HP
- self.hp -= self.damage
- # State change
- @state_changed = false
- states_plus(user.plus_state_set)
- states_minus(user.minus_state_set)
- # When missing
- else
- # Set damage to "Miss"
- self.damage = "Miss"
- # Clear critical flag
- self.critical = false
- end
-
- end
-
- end
-
-
- class Game_Actor < Game_Battler
- attr_accessor :left_skills
-
- alias actor_init initialize
- def initialize(actor_id)
- actor_init(actor_id)
- @left_skills = Hash.new
- n = max_skill_uses
- @skills.each { |id| @left_skills[id] = n }
- end
-
- def max_skill_uses
- return [@level/4, 1].max
- end
-
- #--------------------------------------------------------------------------
- # * Recover All
- #--------------------------------------------------------------------------
- def recover_all
- @hp = maxhp
- @sp = maxsp
- for i in @states.clone
- remove_state(i)
- end
- @skills.each { |id| @left_skills[id] = max_skill_uses }
- end
-
- def skill_can_use?(skill_id)
- if @left_skills[skill_id] <= 0
- return false
- end
- # Unusable if incapacitated
- if dead?
- return false
- end
- # If silent, only physical skills can be used
- if $data_skills[skill_id].atk_f == 0 and self.restriction == 1
- return false
- end
- # Get usable time
- occasion = $data_skills[skill_id].occasion
- # If in battle
- if $game_temp.in_battle
- # Usable with [Normal] and [Only Battle]
- return (occasion == 0 or occasion == 1)
- # If not in battle
- else
- # Usable with [Normal] and [Only Menu]
- return (occasion == 0 or occasion == 2)
- end
- end
-
- end
-
- class Window_Skill < Window_Selectable
- #--------------------------------------------------------------------------
- # * Draw Item
- # index : item number
- #--------------------------------------------------------------------------
- def draw_item(index)
- skill = @data[index]
- if @actor.skill_can_use?(skill.id)
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- x = 4 + index % 2 * (288 + 32)
- y = index / 2 * 32
- rect = Rect.new(x, y, self.width / @column_max - 32, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- bitmap = RPG::Cache.icon(skill.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- # remove the % from the name:
- nameParts = skill.name.split(/%/)
- self.contents.draw_text(x + 28, y, 204, 32, nameParts[0], 0)
- #self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
- max = @actor.max_skill_uses
- left = @actor.left_skills[skill.id]
- self.contents.draw_text(x + 232, y, 48, 32, "#{left}/#{max}", 2)
- end
-
- end
-
-
- class Scene_Battle
- #--------------------------------------------------------------------------
- # * Make Skill Action Results
- #--------------------------------------------------------------------------
- def make_skill_action_result
- # Get skill
- @skill = $data_skills[@active_battler.current_action.skill_id]
- # If not a forcing action
- unless @active_battler.current_action.forcing
- # If unable to use due to SP running out
- unless @active_battler.skill_can_use?(@skill.id)
- # Clear battler being forced into action
- $game_temp.forcing_battler = nil
- # Shift to step 1
- @phase4_step = 1
- return
- end
- end
- # ------------------------------------------- #
- # Use up SP -- disabled
- #@active_battler.sp -= @skill.sp_cost
- # Use up 'skill times' instead
- if @active_battler.is_a?(Game_Actor)
- @active_battler.left_skills[@skill.id] -= 1
- end
- # ------------------------------------------- #
- # Refresh status window
- @status_window.refresh
- # Show skill name on help window
- @help_window.set_text(@skill.name, 1)
- # Set animation ID
- @animation1_id = @skill.animation1_id
- @animation2_id = @skill.animation2_id
- # Set command event ID
- @common_event_id = @skill.common_event_id
- # Set target battlers
- set_target_battlers(@skill.scope)
- # Apply skill effect
- for target in @target_battlers
- target.skill_effect(@active_battler, @skill)
- end
- end
-
- def make_skill_action_result
- # Get skill
- @skill = $data_skills[@active_battler.current_action.skill_id]
- # If not a forcing action
- unless @active_battler.current_action.forcing
- # If unable to use due to SP running out
- unless @active_battler.skill_can_use?(@skill.id)
- # Clear battler being forced into action
- $game_temp.forcing_battler = nil
- # Shift to step 1
- @phase4_step = 1
- return
- end
- end
- # Use up SP
- @active_battler.sp -= @skill.sp_cost
- # Refresh status window
- @status_window.refresh
- # -------------------------------------- #
- name_parts = @skill.name.split(/%/)
- # Show skill name on help window
- @help_window.set_text(name_parts[0], 1)
- # -------------------------------------- #
- # Set animation ID
- @animation1_id = @skill.animation1_id
- @animation2_id = @skill.animation2_id
- # Set command event ID
- @common_event_id = @skill.common_event_id
- # Set target battlers
- set_target_battlers(@skill.scope)
- # Apply skill effect
- for target in @target_battlers
- target.skill_effect(@active_battler, @skill)
- end
- end
-
- end
Expand to see the code.
You didn't give much detail, hopefully this is what you meant.
- if you forget to add %x to the skill name, it does 100% damage.
- all skills have the same # of uses: level/4.
- each skill has a separate number. a level 4 actor with x skills can use each skill once, rather than any skill 4x times.
- skill menu shows the number of skills you have left (1/3 etc).
- Recover All will heal the # of skill uses too.
Weapons already effect the damage dealt by skills, so I didn't have to change that.