#================================================#
#○쉬운 액션 알피지 1.00 Ver
#================================================#
class Game_Character
attr_accessor :monster
alias status_initialize initialize
def initialize
status_initialize
@monster = Game_Monster.new
end
end
#================================================#
#○몬스터 객체를 생성
# 능력치들이 자동으로 저장될 공간을 생성
#================================================#
class Game_Monster
attr_accessor :status
attr_accessor :hp
attr_accessor :maxhp
def initialize
@status = nil
@hp = nil #○몬스터hp는 DB에 존재하지 않는 값이라 새객체에 maxhp값을 담아 사용
@maxhp = nil #○maxhp는 자주사용되는 값이기에 새 객체에 담아 사용
end
end
#================================================#
#○DB에 있는 몬스터 능력치를 이벤트로 담아온다.
#================================================#
class Game_Map < Game_Map
def setup(map_id) #○맵이 열리자마자 monster_setup이 호출된다.
super
monster_setup
end
def monster_setup
for event_id in @map.events.keys #○현재 맵에 존재하는 맵이벤트 해시키를 배열화
for monster_id in 1 .. $data_enemies.size #○DB에 존재하는 몬스터(에너미) 갯수
if @map.events[event_id] != nil and $data_enemies[monster_id] != nil #○nil값(빈값)방지 or 에러방지
#○맵이벤트의 이름과 DB상의 몬스터 이름이 같다면
if @map.events[event_id].name == $data_enemies[monster_id].name
#○몬스터객체에 DB상의 몬스터 능력치를 대입한다.
$game_map.events[event_id].monster.status = $data_enemies[monster_id]
$game_map.events[event_id].monster.maxhp = $game_map.events[event_id].monster.status.maxhp
$game_map.events[event_id].monster.hp = $game_map.events[event_id].monster.maxhp
break
end
end
end
end
end
end
#===============================================#
#○각종 정의에 필요한 몬스터값을 변수에 담아 값을 리턴
#===============================================#
class Game_Event < Game_Event
def monster_pdef
return $monster_pdef = @monster.status.pdef
end
def monster_mdef
return $monster_mdef = @monster.status.mdef
end
def monster_atk
return $monster_atk = @monster.status.atk
end
def monster_str
return $monster_str = @monster.status.str
end
def monster_dex
return $monster_dex = @monster.status.dex
end
def monster_int
return $monster_int = @monster.status.int
end
def monster_spd
return $monster_spd = @monster.status.agi
end
end
#===============================================#
#○각종 정의에 필요한 주인공 능력치를 메소드에 담는다.
#===============================================#
class Game_Player < Game_Character
def player_pdef
return $game_party.actors[0].pdef
end
def player_mdef
return $game_party.actors[0].mdef
end
def player_atk
return $game_party.actors[0].atk
end
def player_str
return $game_party.actors[0].str
end
def player_dex
return $game_party.actors[0].dex
end
def player_int
return $game_party.actors[0].int
end
def player_spd
return $game_party.actors[0].agi
end
end
#===============================================#
#○몬스터 행동 정의
#===============================================#
class Game_Event < Game_Event
attr_accessor :gauge
attr_accessor :attack_delay
def update
super
return if not action?
die! if dead?
attack!
end
def action?
return (@monster.hp != nil)
end
def dead?
return false if not action?
return (@monster.hp <= 0)
end
def attack!
if @delay == nil or @delay == 0
@delay = 40
else
@delay -= 1
return
end
new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
if $game_player.x == new_x and $game_player.y == new_y
turn_toward_player
$game_player.damage(monster_atk,monster_str,@monster.status.animation2_id)
end
end
def turn_toward_player
super
$game_player.turn_right if @direction == 4
$game_player.turn_left if @direction == 6
$game_player.turn_up if @direction == 2
$game_player.turn_down if @direction == 8
end
def damage(atk,status,ani)
return if not action?
min_dmg = (atk + status) * 0.1
dmg = [atk + status - monster_pdef, 0].max
dmg = min_dmg if min_dmg >= dmg
@monster.hp = [@monster.hp - dmg, 0].max
@gauge = @monster.hp.to_f / @monster.maxhp.to_f
turn_toward_player
move_backward if $game_player.player_str > monster_str
self.animation_id = ani
end
def die!
return if @dead
if rand(100) <= @monster.status.treasure_prob
$game_party.gain_weapon(@monster.status.weapon_id,1)
$game_party.gain_armor(@monster.status.armor_id,1)
$game_party.gain_item(@monster.status.item_id,1)
end
$game_party.actors[0].exp += @monster.status.exp
$game_party.gain_gold(@monster.status.gold)
self.animation_id = 54
erase
@dead = true
@monster.hp = nil
end
end
class Game_Player < Game_Player
attr_accessor :gauge
def update
super
if Input.trigger?(Input::C)
for event in $game_map.events.values
new_x = @x + (@direction == 6 ? 1 :@direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 :@direction == 8 ? -1 : 0)
if event.x == new_x and event.y == new_y and event.monster.status != nil
event.damage(player_atk, player_str,weapon_ani)
end
end
end
end
def weapon_ani
weapon_id = $game_party.actors[0].weapon_id
return 4 if $data_weapons[weapon_id] == nil
return $data_weapons[weapon_id].animation2_id
end
def damage(atk,status,ani)
min_dmg = (atk + status) * 0.1
dmg = [atk + status - player_pdef, 0].max
dmg = min_dmg if min_dmg >= dmg
$game_party.actors[0].hp = [$game_party.actors[0].hp - dmg, 0].max
@gauge = $game_party.actors[0].hp.to_f / $game_party.actors[0].maxhp.to_f
move_backward if $game_player.player_str < $monster_str
self.animation_id = ani
end
end
#===================================
#hp 게이지 테스트용 (카피라이트 모름.)
#===================================
class Sprite_Character < Sprite_Character
def update
super
if @character.gauge != nil #and @character.gauge > 0
gauge(@character.gauge)
@character.gauge = nil
end
if @_gauge_setup then
@_gauge_duration = [@_gauge_duration -5,0].max
@_gauge_sprite_b.x = self.x
@_gauge_sprite_b.y = self.y
@_gauge_sprite_b.opacity = @_gauge_duration
@_gauge_sprite.x =self.x
@_gauge_sprite.y =self.y
@_gauge_sprite.opacity = @_gauge_duration
end
end
def gauge(p)
setup_gauge if not @_gauge_setup
@_gauge_sprite.src_rect = Rect.new(0, 0, p*30,2)
@_gauge_duration = 255
end
def setup_gauge
dispose_gauge
@_gauge_setup = true
@_gauge_sprite = Sprite.new(self.viewport)
@_gauge_sprite.bitmap = Bitmap.new(30,2)
@_gauge_sprite.bitmap.fill_rect(0, 0, 30, 2, Color.new(255, 0, 0))
@_gauge_sprite.ox = 15
@_gauge_sprite.oy = -1
@_gauge_sprite.z = 1000
@_gauge_sprite_b = Sprite.new(self.viewport)
@_gauge_sprite_b.bitmap = Bitmap.new(32,4)
@_gauge_sprite_b.bitmap.fill_rect(0,0,32,4, Color.new(0,0,0))
@_gauge_sprite_b.bitmap.fill_rect(1,1,30,2, Color.new(0,0,0))
@_gauge_sprite_b.ox = 16
@_gauge_sprite_b.oy = 0
@_gauge_sprite_b.z = 999
end
def dispose_gauge
return if not @_gauge_setup
@_gauge_setup = false
@_gauge_sprite.dispose
@_gauge_sprite_b.dispose
end
def dispose
dispose_gauge
super
end
end
class Game_Actor < Game_Battler
def exp_rate
if @exp_list[@level+1] - @exp_list[@level] > 0
return (@exp- @exp_list[@level]).to_f / (@exp_list[@level+1] - @exp_list[@level]).to_f
else
return 0
end
end
end
class Window_Gauge < Window_Base
def initialize
super(0, 0, 145,105) #<사이즈
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font = Font.new("휴먼옛체", 16) #폰트사이즈
self.opacity = 255
self.back_opacity = 150
end
def refresh
self.contents.clear
self.contents.draw_text(0, -4,120,30, @show_text4)
self.contents.draw_text(0, 12, 120, 30, @show_text)
self.contents.draw_text(0, 28, 120, 30, @show_text2)
self.contents.draw_text(0, 47, 120, 30, @show_text3)
end
def actor
$game_party.actors[0]
end
def update
super
text = sprintf("HP :%d /%d", actor.hp, actor.maxhp)
text2 = sprintf("MP :%d /%d", actor.sp, actor.maxsp)
text3 = sprintf("EXP:%.3f%%",(actor.exp_rate*100).to_f)
text4 = sprintf("LV:%d %s ",actor.level,actor.name)
if @show_text != text or @show_text2 != text2 or @show_text3 != text3 or @show_text4 != text4
@show_text = text
@show_text2 = text2
@show_text3 = text3
@show_text4 = text4
refresh
end
end
end
class Scene_Map < Scene_Map
def update
super
@window_gauge = Window_Gauge.new unless @window_gauge
@window_gauge.update
unless $scene.is_a?(Scene_Map)
@window_gauge.dispose
@window_gauge=nil
end
end
end
스페이스바 누르면 공격이 됩니다
이벤트에 몬스터 이름을 적어놓고 이동형식을
근접하다라고 하면 됩니다
#================================================#
#○쉬운 액션 알피지 1.00 Ver by [Niotsoft.펜릴]
#버그발견시 www.niotsoft.com 에 글남겨주세요.
#================================================#