SuperFox536
Member
I need some help with this script I made
It's not exactly what i want it to do
I just want it to be a simple battle where the two actors(1 player and 1 enemy)
it doesn't right though.
Code:
#--------------------------------------------------------------------------
#
#
# Fishing Scene
#
# Made by Sonic536
# Credit goes to Ultimate_Coffee for the Movement AI of the Fish
#--------------------------------------------------------------------------
class Scene_C_Battle#($Dif_level)
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Default Main
#--------------------------------------------------------------------------
def main
#Draw Background
@Battle_Back = Sprite.new
@Battle_Back.bitmap = RPG::Cache.battleback("001-Grassland01")
#Draw Windows
# Status_Win
@Status_Win = B_Status_Win.new
# Attack_Win
@Attack_Win = Window_Command.new(160, ['Attack','Defend','Special', 'Flee'])
@Attack_Win.height = 4 * 32 + 32
@Attack_Win.index = @menu_index
@Attack_Win.x = 25
@Attack_Win.y = 150
@Attack_Win.opacity = 100
# Attack_Str_Win
@Attack_Str_Win = Window_Command.new(160,['Light Attack','Normal Attack','Heavy Attack',])
@Attack_Str_Win.height = 3 * 32 + 32
@Attack_Str_Win.index = @menu_index
@Attack_Str_Win.x = 185
@Attack_Str_Win.y = 90 #310
@Attack_Str_Win.active = false
@Attack_Str_Win.visible = false
v = Viewport.new(150, 50, 500, 300)
@Fighter_Pic_01 = RPG::Sprite.new(v)
@Fighter_Pic_01.bitmap = RPG::Cache.picture("Chao_Battler_A1")
#@Fighter_Pic_01 = Sprite.new
#@Fighter_Pic_01.bitmap = RPG::Cache.picture("Chao_Battler_A1")
#@Fighter_Pic_01.x = 250
#@Fighter_Pic_01.y = 250
v = Viewport.new(270, 50, 600, 2000)
@Fighter_Pic_02 = RPG::Sprite.new(v)
@Fighter_Pic_02.bitmap = RPG::Cache.picture("Chao_Battler_A2")
#@Fighter_Pic_02 = Sprite.new
#@Fighter_Pic_02.bitmap = RPG::Cache.picture("Chao_Battler_A2")
#@Fighter_Pic_02.x = 330
#@Fighter_Pic_02.y = 250
@B_Stats_2_Win = B_Stats_2_Win.new
Audio.bgm_play("Audio/BGM/004-Battle04", 70)
# Start of Stats
$Names = ['John', 'Bob', 'Fred']
@Rand_N = rand(2)
$RanName = $Names[@Rand_N]
@RandHp = rand(33333)
$Enemy_MaxHp = @RandHp #+ (33333 * $Dif_level)
$Enemy_Hp = $Enemy_MaxHp
$Enemy_Str = rand(3333) #+ (3333 * $Dif_level)
$Enemy_Dex = rand(3333) #+ (3333 * $Dif_level)
$Enemy_Agi = rand(3333) #+ (3333 * $Dif_level)
$Player_MaxHP = $game_actors[$Chao_id].maxhp
$Player_HP = $game_actors[$Chao_id].maxhp
$Player_Str = $game_actors[$Chao_id].str.to_s
$Player_Dex = $game_actors[$Chao_id].dex.to_s
$Player_Agi = $game_actors[$Chao_id].agi.to_s
@actor_1_defend = 1
@actor_2_defend = 1
@loop = 0
# End of Stats
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
# Dispose All Windows
# Dispose Stats Win
@Attack_Win.dispose
@Attack_Str_Win.dispose
@Status_Win.dispose
@B_Stats_2_Win.dispose
Audio.bgm_stop
end
#--------------------------------------------------------------------------
# Default fish Movement
#--------------------------------------------------------------------------
def update
@Attack_Win.update
@Attack_Win.refresh
@Attack_Str_Win.update
@Attack_Str_Win.refresh
@Fighter_Pic_01.update
@Fighter_Pic_02.update
@B_Stats_2_Win.refresh
if @change_turns01
if @loop == 30
change_turns
else
@loop += 1
end
end
if @change_turns02
if @loop == 30
change_turns
else
@loop += 1
end
end
if Kboard.keyboard($R_Key_1)
$Enemy_Hp -= 300
end
if Kboard.keyboard($R_Key_2)
$Enemy_Hp = 300
end
if Kboard.keyboard($R_Key_3)
$Player_HP -= 300
end
if Kboard.keyboard($R_Key_4)
$Player_HP = 300
end
$game_variables[274], $game_variables[275] = Mouse.pos # $Mouse X Coordinates
if Input.trigger?(Input::R)
p "Mouse X " + $game_variables[274].to_s
p "Mouse Y " + $game_variables[275].to_s
end
if $Player_HP <= 0 #or $Player_HP = nil
$Player_HP = 0
end
if $Enemy_Hp <= 0 #or $Enemy_Hp = nil
$Enemy_Hp = 0
end
if @Attack_Win.active
update_command_Attack_Win
@menu_active = 0
return
end
if @Attack_Str_Win.active
update_command_Attack_Win_Str
@menu_active = 1
return
end
end
#--------------------------------------------------------------------------
# Default Message
#--------------------------------------------------------------------------
def message(text = '')
$game_temp.message_text = text.dup
message = Window_Message_Edited.new
loop do
$game_temp.message_text = text.dup
message.update
message.refresh
Input.update
Graphics.update
break unless !(Input.trigger?(Input::C) or Input.trigger?(Input::B))
end
message.dispose
end
#--------------------------------------------------------------------------
# Default Update
#--------------------------------------------------------------------------
def update_command_Attack_Win
if Input.trigger?(Input::C)
case @Attack_Win.index
when 0
#@Fighter_Pic_01.animation($data_animations[341], false)
@Attack_Str_Win.active = true
@Attack_Str_Win.visible = true
@Attack_Win.active = false
when 1
@Fighter_Pic_01.animation($data_animations[335], true)
@str_type = 3
attack_01
when 2
@Fighter_Pic_01.animation($data_animations[350], true)
@Fighter_Pic_02.animation($data_animations[351], true)
@str_type = 4
attack_01
when 3
@Fighter_Pic_01.escape
$scene = Scene_TCG.new
end
end
end
#--------------------------------------------------------------------------
# Default Update
#--------------------------------------------------------------------------
def update_command_Attack_Win_Str
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@Attack_Str_Win.active = false
@Attack_Str_Win.visible = false
@Attack_Win.active = true
end
if Input.trigger?(Input::C)
case @Attack_Str_Win.index
when 0
@str_type = 0
@Fighter_Pic_01.animation($data_animations[331], @hit)
attack_01
when 1
@str_type = 1
@Fighter_Pic_01.animation($data_animations[332], @hit)
attack_01
when 2
@str_type = 2
@Fighter_Pic_01.animation($data_animations[333], @hit)
attack_01
end
end
end
#------------------------------------------------------------------------
# def Change Turns
#------------------------------------------------------------------------
def attack_01
@Attack_Str_Win.active = false
@Attack_Str_Win.visible = false
@Attack_Win.active = true
case @str_type
when 0
@atk_str = $game_actors[$Chao_id].str / 2
@atk_agi = $game_actors[$Chao_id].agi * 2
when 1
@atk_str = $game_actors[$Chao_id].str / 1
@atk_agi = $game_actors[$Chao_id].agi * 1
when 2
@atk_str = $game_actors[$Chao_id].str * 2
@atk_agi = $game_actors[$Chao_id].agi / 2
when 3
@atk_str = 0
@atk_agi = 0
@actor_1_defend = 0
when 4
@atk_str = $game_actors[$Chao_id].str * 5
@atk_agi = $game_actors[$Chao_id].agi * 3
end
@def_dex = $Enemy_Dex
if @def_dex > @atk_agi
@r = rand(3)
if @r == 0
@defend = 0
@hit = false
else
@hit = true
@defend = 0.5
end
else
@defend = 1
end
@def_dmg = @atk_str * @defend * @actor_2_defend
$Enemy_Hp -= @def_dmg.to_i
#@Fighter_Pic_01.animation($data_animations[331], @hit)
if @hit && @str_type != 3
@Fighter_Pic_02.whiten
end
@Attack_Win.active = false
@Attack_Win.visible = false
@Attack_Str_Win.active = false
@Attack_Str_Win.visible = false
@last_turn = "Player"
@loop = 0
@change_turns02 = false
@change_turns01 = true
end
#------------------------------------------------------------------------
# def Change Turns
#------------------------------------------------------------------------
def change_turns
if @last_turn == "Player"
enemy_attack
elsif @last_turn == "Enemy"
@Attack_Win.active = true
@Attack_Win.visible = true
#@Attack_Str_Win.active = true
#@Attack_Str_Win.visible = true
end
end
#------------------------------------------------------------------------
# def Change Turns
#------------------------------------------------------------------------
def enemy_attack
@str_type = rand(4)
case @str_type
when 0
@Fighter_Pic_01.animation($data_animations[341], @hit)
@atk_str = $game_actors[$Chao_id].str / 2
@atk_agi = $game_actors[$Chao_id].agi * 2
when 1
@Fighter_Pic_01.animation($data_animations[342], @hit)
@atk_str = $game_actors[$Chao_id].str / 1
@atk_agi = $game_actors[$Chao_id].agi * 1
when 2
@Fighter_Pic_01.animation($data_animations[343], @hit)
@atk_str = $game_actors[$Chao_id].str * 2
@atk_agi = $game_actors[$Chao_id].agi / 2
when 3
@atk_str = 0
@atk_agi = 0
@actor_2_defend = 0
when 4
if @actor_02 > 100# && $Dif_level > 2
@atk_str = $game_actors[$Chao_id].str * 5
@atk_agi = $game_actors[$Chao_id].agi * 3
else
@atk_str = $game_actors[$Chao_id].str / 2
@atk_agi = $game_actors[$Chao_id].agi * 2
end
end
@def_dex = $Enemy_Dex
if @def_dex > @atk_agi
@r = rand(3)
if @r == 0
@defend = 0
@hit = false
else
@hit = true
@defend = 0.5
end
else
@defend = 1
end
@def_dmg = @atk_str * @defend * @actor_1_defend
$Player_HP -= @def_dmg.to_i
#@Fighter_Pic_01.animation($data_animations[331], @hit)
if @hit && @str_type != 3
@Fighter_Pic_01.whiten
end
@last_turn = "Enemy"
@change_turns01 = false
@loop = 0
@change_turns02 = true
change_turns
end
end # Class End
It's not exactly what i want it to do
I just want it to be a simple battle where the two actors(1 player and 1 enemy)
it doesn't right though.