ГлавнаяФорумRPG MakerСкрипты/ПлагиныRPG Maker VX ACEИзменённые боевые системы (CBS)Разбор скрипта Re weapon system 2
Войти на сайт
×
ТЕМА: Разбор скрипта Re weapon system 2
Разбор скрипта Re weapon system 2 5 года 8 мес. назад #110317
|
Начну с того, что данный скрипт уже рассматривался 3 года назад. На светлой есть тема с таким названием rpgmaker.ru/forum/cbs/60913-boevaya-sist...re-weapons-system-ii.
Если повторюсь в чем-то прошу сильно не судить. Начал свое знакомство я с этой игровой системы, в своем проекте. И столкнулся с множеством трудностей. Самая главная, состоит в том что данный скрипт забросили. Словно огромный фундамент и на нем стоит маленький домик, вместо замка. Начну с того что нужно перенести папки Particles в свой проект в Graphics, так же не забыть в папке character файл items. Так же нужно перенести звуки из папки SE (список можно посмотреть в скрипте RE Weapon System Main) RE Weapon System Main - разбор - перевод Default_Animation = 1 # Стандартная анимация стрельбы (когда у оружия ее нет) Opacity_Burn = 10 # Скорость, с которой увеличивается прозрачность, когда мертв Enemy_Recover = 60 # Восстановление противника (по умолчанию = 60) - если нет выставленных переключателей Attack_Key = : X # Кнопка выстрела Reload_Key = :Y # Кнопка перезарядки Pierce_Enemies = 1 # Сколько врагов может пройти пуля (по умолчанию 1) Move_Type_Custom = false true, если вы хотите, чтобы противник шел, как показано ниже Move_Type_Near = 2 # Скорость противника, когда рядом (максимум 5) Move_Type_Far = 1 # Скорость противника, когда далеко (максимум 5) Die_SE = "Monster6" # Звук, когда враг умирает Player_Die_SE = "die_abyss" # Звук когда игрок умирает Show_Damage_Sprites = true # Показать значение урона по цели Show_Melee_Sprites = true # Показать спрайты оружия ближнего боя (ножи и т. Д.) Show_Weapon_Sprites = true # Покажите огнестрельные спрайты (пистолеты и т. Д.) Show_Smoke_On_Fire = true #Покажите струи дыма при стрельбе Show_Blood_Anim = true # Показать кровь Terrain_Debug = 1 # Непроходимость обработка багов Flash = true # Вспышки при полете ракеты Floor = true # Урон по площади Melee_Wav_Name = "damage3" # Звук урона Explosion_SE = "Explosion2" # Звук взрыва Blend_Type = 1 # Звук взрыва Пропись оружия в скрипте: # Чтобы создать оружие, скопируйте: Weapons [id] = [a, b, c, d, e] и измените: # ID = Идентификатор оружия в базе данных; a = идентификатор патрона в БД # b = максимальное количество пуль в магазине; c = время ожидания следующего выстрела # d = звук выстрела, перезагрузка и нет патронов # e = увеличение иконки в плеере (по умолчанию = 1) Armas = {}; Granadas = {} Armas[61] = [16, 8, 50, "pistol"] Armas[62] = [17, 8, 60, "makarov"] Armas[63] = [18, 7, 80, "shot"] Armas[64] = [19, 30, 10,"smg"] Armas[65] = [20, 2, 70, "wes"] Armas[66] = [21, 1, 90, "rocket"] Armas[67] = [20, 7, 80, "deserteagle"] У героя в комментариях требуется прописать <starting gear: 67> - стартовый набор оружия <sound_die: Wind9> - Звук смерти В Оружии создать оружие и прописать комментариях: "area" - оружие действует на область "recover х" - скорость стрельбы X В ивентах у врагов есть несколько вариантов прописи. Вначале всегда ID c которого берутся значения параметров в ивенте пишется enemy_id=10 в параметрах врага в комментариях: damage_callback= 42 - урон animation_id= 46 - анимация удара у монстра <sound_die: Monster3> - звук при смерти - Спасибо Баги за добавление к скрипту! Далее в ивенте пишется либо Die Erase - стереть после смерти с возражением после указанного в скрипте времени. Либо Die Switch 154 - При смерти переключить переключатель 154. Есть еще один вариант Die Self B - локальный переключатель А но я не смог его заставить работать без ошибки. В скрипте есть описание перевожу на русский: # Создание врага, поместите комментарий в мероприятии: # - enemy_id= И вставьте КОД противника в базе данных # Чтобы добавить команду, когда враг умрет, положить. # Die Erase - Гнев стереть врага # Die Switch Месте Х - Гнев включения коммутатора месте х # Die Переключатель X - Гнев включения коммутатора # Die Self B # Вы можете создать объект, разместив комментарий на события # - command object # # И ЗАМЕНИТЕ command : # Self, X - Активирует переключатель месте х # Switch X - Активирует X swich # Start - Запускает все, что после. # Демку скачать можно отсюда: cloud.mail.ru/public/23Zh/rwU6m3DpZ |
Последнее редактирование: 5 года 8 мес. назад от akito66.
Администратор запретил публиковать записи гостям.
|
Разбор скрипта Re weapon system 2 4 года 10 мес. назад #115376
|
|
Администратор запретил публиковать записи гостям.
|
Разбор скрипта Re weapon system 2 4 года 10 мес. назад #115377
|
Uzuzu74 пишет:
Большое спасибо за описание. У меня возникло два вопроса. если возникают подобные вопросы по скриптам, то лучше всего прямо в сообщении скопировать весь скрипт взяв его в теги code иначе для того чтоб тебе помочь, форумчанину надо приложить много телодвижений: - найти скрипт в гугле - скачать демку - открыть там скрипт через РПГ мейкер если же скрипт можно посмотреть прямо в сообщении, то помогающий может глянуть чисто по коду и подсказать какие цифры следует изменить, даже если у него нет эйса и он не знаю язык руби так что ждем от тебя вставку скрипта в сообщение и плюс к этому еще ссылку на твою демку. |
Последнее редактирование: 4 года 10 мес. назад от yuryol.
Администратор запретил публиковать записи гостям.
|
Разбор скрипта Re weapon system 2 4 года 10 мес. назад #115390
|
Вот ссылка на демку.
cloud.mail.ru/public/4B9c/2LwxVLbM8 В архиве их две изменённая и оригинал По поводу скриптов, их там пять штук. И ещё, по второму вопросу, я забыл упомянуть об увеличение ширены линии текста, чтобы буквы нормально отображались. Надеюсь на вашу помощь. Спасибо. #==============================================================================
# Resident Evil Like Weapons System
#==============================================================================
#------------------------------------------------------------------------------
# Créditos: Leon-S.K --- ou --- Andre Luiz Marques Torres Micheletti
#==============================================================================
#------------------------------------------------------------------------------
# HUD
#------------------------------------------------------------------------------
module Hud_Config
#------------------------------------------------------------------------------
# CONFIGURAÇÕES GERAIS
#------------------------------------------------------------------------------
Switch = 2 # Id da Switch que ativa\desativa a HUD
Show_Key = :Z # Tecla que mostra\esconde a HUD
#------------------------------------------------------------------------------
# Fim das Configurações
#------------------------------------------------------------------------------
end
#==============================================================================
#------------------------------------------------------------------------------
# AREA NAO EDITAVEl!
#------------------------------------------------------------------------------
class Hud < Window_Base
attr_accessor :hp
attr_accessor :mp
attr_accessor :ammo
def initialize
super(0,0,250,300)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
@hp = $game_party.members[0].hp
@maxhp = $game_party.members[0].mhp
if $game_player.equipped_weapon != nil
@ammo = $game_player.equipped_weapon.bullets
@mags = $game_party.item_number($game_player.equipped_weapon.magazine)
end
self.z = 999
self.contents.font.color = Color.new(229,191,0)
refresh
end
def refresh
@hp = $game_party.members[0].hp
@maxhp = $game_party.members[0].mhp
if $game_player.equipped_weapon != nil
@ammo = $game_player.equipped_weapon.bullets
@mags = $game_party.item_number($game_player.equipped_weapon.magazine)
end
@wb = 149 * @hp / @maxhp
self.contents.clear
self.contents.fill_rect(0,8,151,11,Color.new(255,216,0))
self.contents.fill_rect(1,9,149,9,Color.new(0,0,0))
self.contents.gradient_fill_rect(1,9,@wb,9,Color.new(205,101,0),Color.new(0,89,0))
self.contents.draw_text(0,8,151,21,"HP",1)
if $game_player.equipped_weapon != nil
self.contents.draw_text(0,31,120,20,@ammo.to_s)
draw_icon(967, 16, 31)
self.contents.draw_text(100,31,120,20,@mags.to_s) if not @mags.nil?
draw_icon($game_player.equipped_weapon.iconset_id, 116, 30)
end
end
def dispose
super
end
end
class Scene_Map < Scene_Base
include Hud_Config
attr_accessor :hud
alias hud_start start
def start
hud_start
if $game_switches[Switch] == true
@hud = Hud.new
end
end
alias hud_update update
def update
hud_update
if Input.trigger?(Show_Key)
$game_switches[Switch] ? $game_switches[Switch] = false : $game_switches[Switch] = true
end
if $game_switches[Switch] == true
@hud.nil? ? @hud = Hud.new : refresh_hud
else
if not @hud.nil?; @hud.dispose; @hud = nil; end
end
end
def refresh_hud
@hud.refresh if $game_party.members[0].hp != @hud.hp or $game_party.members[0].mp != @hud.mp or @hud.ammo != $game_player.equipped_weapon.bullets
end
alias hud_terminate terminate
def terminate
@hud.dispose if @hud != nil
hud_terminate
end
end #==============================================================================
# Resident Evil Like Weapons System
#==============================================================================
#------------------------------------------------------------------------------
# Créditos: Leon-S.K --- ou --- Andre Luiz Marques Torres Micheletti
#==============================================================================
#------------------------------------------------------------------------------
# ARMAS A SEREM USADAS PELO SCRIPT
#------------------------------------------------------------------------------
module Weapons_To_Be_Used
#------------------------------------------------------------------------------.
# Para criar uma arma, copie: Armas[id] = [a, b, c, d, e] e mude:
# ID = Id da arma no database; a = id do item para ser o cartucho da arma
# b = maximo de balas em um cartucho; c = tempo de espera para o proximo tiro
# d = som de tiro, reload e no_ammo
# e = zoom do icone no player (padrao = 1)
Armas = {}; Granadas = {}
Armas[62] = [17, 15, 60, "pistol"]
Armas[63] = [18, 7, 80, "shot"]
Armas[64] = [19, 50, 10, "smg"]
Armas[65] = [20, 9, 60, "wes"]
Armas[66] = [21, 1, 90, "rocket"]
#----------------------------------------------------------------------------
#~ Você pode ainda criar armas com efeito de area (explosivos)
#~ Colocando no comentario da arma => "area"
#~
#~ Você pode ainda criar armas com efeito de perfuração (sniper)
#~ Colocando no comentario da arma => "pierce x"
#~ Onde x é a qnt de inimigos que ela pode atravessar
#----------------------------------------------------------------------------
end
#==============================================================================
#------------------------------------------------------------------------------
# AREA NAO EDITAVEl!
#------------------------------------------------------------------------------
class Scene_Map < Scene_Base
include Weapons_To_Be_Used
alias my_start start
def start
my_start
create_global_weapons(Armas) if $weapons.nil?
end
def create_global_weapons(armas)
$weapons = []
armas.each { |arma|
p1 = $data_weapons[arma[0]]
p2 = $data_items[arma[1][0]]
p3 = arma[1][1]
p4 = arma[1][2]
p5 = arma[1][3]
$weapons.push(Abs_Weapon.new(p1, p2, p3, p4, p5))
}
end
end
#----------------------------------------------------------------------------------#
class Abs_Weapon
attr_accessor :recover
attr_accessor :magazine
attr_accessor :bullets
attr_accessor :max
attr_accessor :weapon
attr_accessor :iconset_id
attr_accessor :name
attr_accessor :wav_name
attr_reader :area
attr_reader :pierce
attr_reader :pierce_num
def initialize(weapon, magazine, max, recover, wav_name)
@weapon, @magazine, @max, @recover, @wav_name = weapon, magazine, max, recover, wav_name
@bullets = 0; @iconset_id = @magazine.icon_index; @name = @weapon.name
@pierce = false; @area = false
if @weapon.note.include?("area")
@area = true
else
@area = false
end
if @weapon.note.include?("pierce=")
return if @weapon.note.include?("area")
number = @weapon.note.sub("pierce=","")
@pierce_num = number.to_i
@pierce = true
if @pierce_num == nil
@pierce_num = Module_Of_Config::Pierce_Enemies
end
else
@pierce = false
end
end
end
#----------------------------------------------------------------------------------#
class Game_Actor < Game_Battler
alias :my_def :change_equip
def change_equip(slot_id, item)
if slot_id == 0
for weapon in $weapons
break if item == nil
if weapon.weapon.id == item.id
$game_player.equipped_weapon = weapon
$game_player.equipped_weapon.bullets = 0 if $game_player.equipped_weapon.bullets.nil?
break
else
$game_player.equipped_weapon = nil
end
end
if item == nil
$game_player.equipped_weapon = nil
end
my_def(slot_id, item)
else
my_def(slot_id, item)
end
end
end #==============================================================================
# Resident Evil Like Weapons System
#==============================================================================
#------------------------------------------------------------------------------
# Créditos: Leon-S.K --- ou --- AndreMaker --- ou --- 4ndreMTM
#------------------------------------------------------------------------------
#
# Para Criar um inimigo, coloque o comentario em um evento:
# - enemy_id= E coloque o ID do inimigo na database
# Para adicionar um comando quando o inimigo morrer, coloque o comentario
# Die Erase - Ira apagar o inimigo
# Die Switch Local X - Ira ativar a switch local x
# Die Switch X - Ira ativar a switch
#
# Você pode criar um objeto, colocando um comentario no evento
# - object command
#
# E SUBSTITUA command por :
# Self X - Ativa a switch local x
# Switch X - Ativa a swich X
# Start - Executa tudo após o comentario
#
# Exemplo:
# - Object Self A
#
# Outro Exemplo:
# - Object Switch 20
#
# Para o Inimigo no database, coloque nos comentarios
# animation_id= id da animação
# Para definir uma animação de ataque
#
# Você ainda pode criar uma arma com dano em area ou que atravessa mais
# de um inimigo.
#
# Para fazer-lo coloque no comentario da arma:
#
# Adicione "area" para criar uma arma com efeito de area(explosao)
# Adicione "pierce x" e troque x para quantos inimigos quiser atravessar
#
# Para colocar as armas no script, visite "weapons room"
#------------------------------------------------------------------------------
#==============================================================================
module Module_Of_Config
#------------------------------------------------------------------------------
# CONFIGURAÇÕES GERAIS
#------------------------------------------------------------------------------
Default_Animation = 1 # Animação padrao de tiro (quando a arma nao tiver)
Opacity_Burn = 10 # A velocidade que a opacidade diminui quando morto
Enemy_Recover = 60 # Recover do inimigo (padrao = 60)
Attack_Key = :X # Tecla de Tiro
Reload_Key = :Y # Tecla de Reload
Pierce_Enemies = 1 # Quantos inimigos a bala pode atravessar (padrao 1)
Move_Type_Custom = false # true se quiser que o inimigo ande conforme abaixo
Move_Type_Near = 2 # A velocidade do inimigo quando perto (max 5)
Move_Type_Far = 1 # A velocidade do inimigo quando longe (max 5)
Die_SE = "Monster6" # SE tocado quando o inimigo Morre
Player_Die_SE = "die_abyss" # SE tocado quando o player morre
Show_Damage_Sprites = true # Mostrar valor do dano no alvo
Show_Melee_Sprites = true # Mostrar sprites de armas melee (facas, etc)
Show_Weapon_Sprites = true # Mostrar sprites de armas (pistolas, etc)
Show_Smoke_On_Fire = true # Mostrar sprites de fumaça ao atirar
Show_Blood_Anim = true # Mostrar sangue
# Se os tiros estiverem passando por um tile que não pode ser passavel, marque
# o tile com o numero abaixo...
Terrain_Debug = 1
Flash = true
Floor = true
Melee_Wav_Name = "knife_hit"
Explosion_SE = "Explosion2"
Blend_Type = 1
Fragments = 10
Frag_Vel = 9
Smokes = 2
Smoke_Vel = 2
Smoke_Freq = 3
Shot_Bit = {}
AreaChar = "$!rocket"
Floor_Bit = Bitmap.new("Graphics/Particles/floor")
Explosion_Bit = Bitmap.new("Graphics/Particles/explosion")
Fragment_Bit = Bitmap.new("Graphics/Particles/fragments")
Smoke_Bit = Bitmap.new("Graphics/Particles/smoke")
Blood_Bit = Bitmap.new("Graphics/Particles/blood")
Melee_Bit = Bitmap.new("Graphics/Particles/knifeslash")
Shot_Bit[:x] = Bitmap.new("Graphics/Particles/shot_x")
Shot_Bit[:y] = Bitmap.new("Graphics/Particles/shot_y")
#----------------------------------------------------------------------------------#
end
#------------------------------------------------------------------------------
# AREA NAO EDITAVEL - APENAS SE SABE OQUE ESTA FAZENDO =D
#------------------------------------------------------------------------------
class Game_Map
attr_accessor :enemies
attr_accessor :damage_sprites
attr_accessor :item_windows
attr_accessor :explosion_chars
alias abs_setup setup
def setup(map_id)
@enemies.nil? ? @enemies = [] : @enemies.clear
@item_windows.nil? ? @item_windows = [] : @item_windows.clear
abs_setup(map_id)
end
def window(type)
@item_windows.push(type)
end
end
#----------------------------------------------------------------------------------#
class Game_Event < Game_Character
include Module_Of_Config
attr_reader :enemy
attr_reader :object
attr_reader :not_blood
alias abs_setup_page_settings setup_page_settings
alias abs_initialize initialize
alias abs_update update
alias abs_start start
alias abs_movement update_self_movement
alias abs_erase_enemy erase
def initialize(map_id, event)
@enemy = nil
@recover = 0; @timer = 0
abs_initialize(map_id, event)
end
def setup_page_settings
abs_setup_page_settings
check_enemy
end
def update_self_movement
if @enemy != nil and Move_Type_Custom == true
if near_the_player?
@move_type = Move_Type_Near
abs_movement
else
@move_type = Move_Type_Far
abs_movement
end
else
abs_movement
end
end
def check_enemy
if !@enemy.nil?
@enemy = nil
$game_map.enemies.delete(self)
elsif !@object.nil?
@object = nil
$game_map.enemies.delete(self)
end
return if @list.nil?
@list.each do |command|
next if not command.code == 108 or command.code == 408
if @enemy.nil?
if command.parameters[0].downcase.include?("enemy_id=")
id = command.parameters[0].sub("enemy_id=","")
@enemy = ABS_Enemy.new(id.to_i)
@trigger = 2
$game_map.enemies.push(self)
print "Enemy #{@enemy.enemy.name} criado \n"
elsif command.parameters[0].downcase.include?("object")
die_com = command.parameters[0].downcase.sub("object ", ""); die_com.downcase!
if die_com.include?("self ")
switch = die_com.downcase.sub('self ','')
switch.downcase!
switch = check_switch_string(switch)
elsif die_com.include?("switch ") and !die_com.include?('local')
switch = die_com.downcase.sub('switch ','')
switch = switch.to_i
elsif die_com.include?('Start')
switch = true
else
switch = true
end
@object = ABS_Object.new(switch)
$game_map.enemies.push(self)
print "Objeto criado com switch #{@object.switch} \n"
end
else
if command.parameters[0].downcase.include?("die")
cmd = command.parameters[0].downcase
if cmd == "die erase"
@enemy.die = 0
elsif cmd.include?("die switch local")
@enemy.die = 1
maqoe = cmd.sub("die switch local ",'')
@enemy.switch = check_switch_string(maqoe)
elsif cmd.include?("die switch")
@enemy.die = 2
maqoe = cmd.sub("die switch ", '')
@enemy.switch = maqoe.to_i
else
@enemy.die = 0
end
print "Enemy #{@enemy.enemy.name} die command is #{@enemy.die} \n"
else
next
end
end
end
end
def check_switch_string(string)
if string.include?('a')
return "A"
elsif string.include?('b')
return "B"
elsif string.include?('c')
return "C"
elsif string.include?('d')
return "D"
end
return nil
end
def start_object
print "Object Started! \n"
if @object.switch.is_a?(String)
key = [$game_map.map_id, self.id, @object.switch]
$game_self_switches[key] ? $game_self_switches[key] = false : $game_self_switches[key] = true
print "Switch Local #{@object.switch} == #{$game_self_switches[key]} \n"
elsif @object.switch.is_a?(TrueClass)
@object = nil
$game_map.enemies.delete(self)
self.start
else
$game_switches[@object.switch] ? $game_switches[@object.switch] = false : $game_switches[@object.switch] = true
end
end
def erase
@character_name = ''
@priority_type = 1
moveto(0,0)
abs_erase_enemy
end
def damage_enemy(value)
if !@object.nil?
start_object
return
end
value -= (rand(10) - 5)
value -= @enemy.defense
value == 0 if value < 0
last_speed = @move_speed
last_freq = @move_frequency
@move_speed = 5
@move_frequency = 5
jump(0,0)
$game_map.damage_sprites.push(Damage_Sprite.new(self, value)) if Show_Damage_Sprites == true
@enemy.hp -= value
if @enemy.hp <= 0
$game_map.enemies.delete(self)
RPG::SE.new(Die_SE, 80).play
Audio.se_play('Audio/Se/Blow6', 90, 100)
expp = @enemy.enemy.exp
end
@move_speed = last_speed
@move_frequency = last_freq
end
def update
@not_blood = (@object.nil? ? false : true) if @not_blood.nil?
if @enemy != nil
@recover -= 1 if @recover > 0
x, y = distance_x_from($game_player.x).abs, distance_y_from($game_player.y).abs
if x + y <= 1
move_toward_character($game_player) if !moving?
end
update_kill if @enemy.hp <= 0
end
abs_update
end
def update_kill
if @opacity > 0
@opacity -= Module_Of_Config::Opacity_Burn
else
case @enemy.die
when 0
print "Erased enemy #{@enemy.enemy.name}\n"
self.erase
@enemy = nil
when 1
key = [$game_map.map_id, self.id, @enemy.switch]
if $game_self_switches[key] == true
$game_self_switches[key] = false
else
$game_self_switches[key] = true
end
@opacity = 255
when 2
$game_switches[@enemy.switch] ? $game_switches[@enemy.switch] = false : $game_switches[@enemy.switch] = true
@opacity = 255
end
@enemy = nil if !@enemy.nil?
end
end
def start
if @object.nil?; abs_start; else; abs_start if !@object.switch.is_a?(TrueClass); end
if @enemy.nil?
abs_start
else
ax = @x - $game_player.x
ay = @y - $game_player.y
turn_toward_player if check_really_near and !moving?
case @direction
when 2
attack if ax == 0 and ay == -1
when 4
attack if ay == 0 and ax == 1
when 6
attack if ay == 0 and ax == -1
when 8
attack if ax == 0 and ay == 1
end
end
end
def check_really_near
sx = distance_x_from($game_player.x).abs
sy = distance_y_from($game_player.y).abs
return true if sx + sy < 3
end
def attack
return if @enemy.hp == 0 or @recover > 0
@recover = Module_Of_Config::Enemy_Recover
SceneManager.scene.spriteset.blood($game_player, @direction)
value = @enemy.attack
r = rand(20)
factor = r - 10
value += factor
$game_player.damage_hero(value)
SceneManager.scene.spriteset.melee(self)
end
end
#----------------------------------------------------------------------------------#
class ABS_Object
attr_accessor :switch
def initialize(die_com)
@switch = die_com
end
end
#----------------------------------------------------------------------------------#
class ABS_Enemy
include Module_Of_Config
attr_accessor :enemy
attr_accessor :hp
attr_accessor :attack
attr_accessor :defense
attr_accessor :die
attr_accessor :switch
attr_reader :name
attr_reader :animation
def initialize(id)
@enemy = Game_Enemy.new(0, id)
@name = @enemy.name
@die = 0, @switch = nil
note = @enemy.enemy.note
if note.include?("animation=")
aid = note.sub("animation=","")
@animation = aid.to_i
else
@animation = Default_Animation
end
@hp = enemy.mhp
@attack = enemy.atk
@defense = enemy.def
end
end
#----------------------------------------------------------------------------------#
class Game_Player < Game_Character
include Module_Of_Config
attr_accessor :kill_player
attr_accessor :equipped_weapon
attr_accessor :real_vis_character_name
attr_accessor :real_vis_character_index
attr_accessor :bullets_hash
attr_reader :aiming
alias abs_initialize initialize
alias abs_update update
alias abs_movable movable?
def initialize
@recover = 0
@kill_player = false; @need_check = true
@real_vis_character_name = @character_name
@real_vis_character_index = @character_index
abs_initialize
end
def update
@recover -= 1 if @recover > 0
re_check_equipped_weapon if @need_check == true
if not @equipped_weapon == nil
@need_check = true if not @need_check = true
if Input.press?(Attack_Key) and @recover == 0
if not @equipped_weapon.bullets == 0
@equipped_weapon.area == true ? update_attack(true) : update_attack
return
else
Audio.se_play("Audio/SE/#{@equipped_weapon.wav_name}_no_ammo", 100, 130)
@recover = @equipped_weapon.recover
end
end
if Input.trigger?(Reload_Key)
if @equipped_weapon.bullets == 0
reload(@equipped_weapon)
else
Audio.se_play("Audio/Se/Buzzer1", 80, 100)
end
end
else
if Input.press?(Attack_Key)
update_melee if @recover == 0
end
end
update_kill if @kill_player
abs_update
end
def update_melee
actor = $game_party.members[0]
@recover = 60
if actor.weapons[0] != nil and Show_Melee_Sprites
SceneManager.scene.spriteset.weapon(self, actor.weapons[0].icon_index)
end
SceneManager.scene.spriteset.melee(self)
return if $game_map.enemies.empty?
$game_map.enemies.each {|enemy|
ax = @x - enemy.x
ay = @y - enemy.y
case @direction
when 2
if ax == 0 and ay == -1
enemy.damage_enemy(actor.atk)
SceneManager.scene.spriteset.blood(enemy, @direction) if enemy.object.nil?
end
when 4
if ay == 0 and ax == 1
enemy.damage_enemy(actor.atk)
SceneManager.scene.spriteset.blood(enemy, @direction) if enemy.object.nil?
end
when 6
if ay == 0 and ax == -1
enemy.damage_enemy(actor.atk)
SceneManager.scene.spriteset.blood(enemy, @direction) if enemy.object.nil?
end
when 8
if ax == 0 and ay == 1
enemy.damage_enemy(actor.atk)
SceneManager.scene.spriteset.blood(enemy, @direction) if enemy.object.nil?
end
end
}
end
def re_check_equipped_weapon
return if @equipped_weapon != nil
$weapons.each { |weapon|
if $game_party.members[0].equips.include?(weapon.weapon)
@equipped_weapon = weapon
@need_check = false
return
end
}
@need_check = false
end
def reload(weapon)
$game_party.items.each { |item|
if item.id == weapon.magazine.id
$game_party.lose_item(weapon.magazine,1)
@equipped_weapon.bullets += @equipped_weapon.max
Audio.se_play("Audio/Se/#{weapon.wav_name}_reload", 100, 100)
@recover = @equipped_weapon.recover
return
end
}
Audio.se_play("Audio/Se/Buzzer1", 85, 100)
@recover = (@equipped_weapon.recover > 40 ? @equipped_weapon.recover : 45)
end
def movable?
$game_map.explosion_chars.compact!
return false if !$game_map.explosion_chars.empty?
abs_movable
end
def update_attack(bazooca = false)
$game_map.enemies.compact!
return if @kill_player
return if $game_party.members[0].weapons[0] == nil
re_check_equipped_weapon if @equipped_weapon == nil
return if @equipped_weapon.nil? or @equipped_weapon.class != Abs_Weapon
Audio.se_stop
Audio.se_play("Audio/Se/#{@equipped_weapon.wav_name}", 100, 100)
@equipped_weapon.bullets -= 1
@recover = @equipped_weapon.recover
range_x = {'pos' => [], 'neg' => []}
range_y = {'pos' => [], 'neg' => []}
SceneManager.scene.spriteset.shoot(self)
for i in 1..8
if (map_passable?(@x - i, @y, 4) or $game_map.counter?(@x - i, @y)) and $game_map.terrain_tag(@x - i, @y) != Terrain_Debug
range_x['pos'].push(i)
else
break; next
end
end
for i in 1..8
if (map_passable?(@x + i, @y, 6) or $game_map.counter?(@x + i, @y)) and $game_map.terrain_tag(@x + i, @y) != Terrain_Debug
range_x['neg'].push(i * (-1))
else
break; next
end
end
for i in 1..8
if (map_passable?(@x, @y - i, 8) or $game_map.counter?(@x, @y - i)) and $game_map.terrain_tag(@x, @y - i) != Terrain_Debug
range_y['pos'].push(i)
else
break; next
end
end
for i in 1..8
if (map_passable?(@x, @y + i, 2) or $game_map.counter?(@x, @y + i)) and $game_map.terrain_tag(@x, @y + i) != Terrain_Debug
range_y['neg'].push(i * (-1))
else
break; next
end
end
@new_enemies = []
$game_map.enemies.each do |enemy|
ax = @x - enemy.x
ay = @y - enemy.y
case @direction
when 2
if not ax != 0
if ay == -1
@new_enemies[0] = enemy
elsif ay == - 2
@new_enemies[1] = enemy
elsif ay == - 3
@new_enemies[2] = enemy
elsif ay == - 4
@new_enemies[3] = enemy
elsif ay == - 5
@new_enemies[4] = enemy
elsif ay == - 6
@new_enemies[5] = enemy
elsif ay == - 7
@new_enemies[6] = enemy
elsif ax == - 8
@new_enemies[7] = enemy
end
end
when 4
if not ay != 0
if ax == 1
@new_enemies[0] = enemy
elsif ax == 2
@new_enemies[1] = enemy
elsif ax == 3
@new_enemies[2] = enemy
elsif ax == 4
@new_enemies[3] = enemy
elsif ax == 5
@new_enemies[4] = enemy
elsif ax == 6
@new_enemies[5] = enemy
elsif ax == 7
@new_enemies[6] = enemy
elsif ax == 8
@new_enemies[7] = enemy
end
end
when 6
if not ay != 0
if ax == -1
@new_enemies[0] = enemy
elsif ax == - 2
@new_enemies[1] = enemy
elsif ax == - 3
@new_enemies[2] = enemy
elsif ax == - 4
@new_enemies[3] = enemy
elsif ax == - 5
@new_enemies[4] = enemy
elsif ax == - 6
@new_enemies[5] = enemy
elsif ax == - 7
@new_enemies[6] = enemy
elsif ax == - 8
@new_enemies[7] = enemy
end
end
when 8
if not ax != 0
if ay == 1
@new_enemies[0] = enemy
elsif ay == 2
@new_enemies[1] = enemy
elsif ay == 3
@new_enemies[2] = enemy
elsif ay == 4
@new_enemies[3] = enemy
elsif ay == 5
@new_enemies[4] = enemy
elsif ay == 6
@new_enemies[5] = enemy
elsif ay == 7
@new_enemies[6] = enemy
elsif ay == 8
@new_enemies[7] = enemy
end
end
end
end
@new_enemies.compact!; a = 0
@new_enemies.each do |enemy|
if @equipped_weapon.pierce == true
break if a >= Pierce_Enemies + @equipped_weapon.pierce_num
else
break if a >= Pierce_Enemies
end
next if not enemy.is_a?(Game_Event)
ax = @x - enemy.x
ay = @y - enemy.y
case @direction
when 2
if ax == 0
if range_y['neg'].include?(ay)
bazooca ? damage_area(enemy) : attack_enemy(enemy)
a += 1
next
else
@equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
end
else
@equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
end
when 4
if ay == 0
if range_x['pos'].include?(ax)
bazooca ? damage_area(enemy) : attack_enemy(enemy)
a += 1
next
else
@equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
end
else
@equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
end
when 6
if ay == 0
if range_x['neg'].include?(ax)
bazooca ? damage_area(enemy) : attack_enemy(enemy)
a += 1
next
else
@equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
end
else
@equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
end
when 8
if ax == 0
if range_y['pos'].include?(ay)
bazooca ? damage_area(enemy) : attack_enemy(enemy)
a += 1
next
else
@equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
end
else
@equipped_weapon.area ? miss_area(range_x, range_y) : miss; break
end
end
end
@new_enemies.clear
if a == 0
@equipped_weapon.area ? miss_area(range_x, range_y) : miss
end
end
def miss_area(area_x, area_y)
@recover = @equipped_weapon.recover
now = @equipped_weapon.weapon.animation_id
anim_n = $data_animations[now].frames.size * 3
area_x['pos'].sort!; area_x['neg'].sort!
area_y['pos'].sort!; area_y['neg'].sort!
area_x['pos'].compact!; area_x['neg'].compact!
area_y['pos'].compact!; area_y['neg'].compact!
xis, yis = @x, @y
gm = $game_party.members[0]
pre_feito = gm.atk - gm.def
pre_feito = 0 if pre_feito <= 0
if not area_x['pos'].empty? or area_x['neg'].empty? or area_y['pos'].empty? or area_y['neg'].empty?
case @direction
when 2
if area_y['neg'][0].nil?; damage_hero(pre_feito); SceneManager.scene.spriteset.explode($game_player.x, $game_player.y); return; end
xis = @x; yis -= area_y['neg'][0]
when 4
a = area_x['pos'].size
if area_x['pos'][a - 1].nil?; damage_hero(pre_feito); SceneManager.scene.spriteset.explode($game_player.x, $game_player.y); return; end
yis = @y; xis -= area_x['pos'][a - 1]
when 6
if area_x['neg'][0].nil?; damage_hero(pre_feito); SceneManager.scene.spriteset.explode($game_player.x, $game_player.y); return; end
yis = @y; xis -= area_x['neg'][0]
when 8
a = area_y['pos'].size
if area_y['pos'][a - 1].nil?; damage_hero(pre_feito); SceneManager.scene.spriteset.explode($game_player.x, $game_player.y); return; end
xis = @x; yis -= area_y['pos'][a - 1]
end
else
return
end
xis = 0 if xis.nil?
yis = 0 if yis.nil?
SceneManager.scene.spriteset.area(self, xis, yis)
SceneManager.scene.spriteset.explode(xis,yis)
range = {}
range[:x] = [xis]; range[:y] = [yis]
for i in 0..1
range[:x].push(xis + i)
range[:y].push(yis + i)
range[:x].push(xis - i)
range[:y].push(yis - i)
end
range[:x] = range[:x] & range[:x]
range[:y] = range[:y] & range[:y]
range[:x].sort!; range[:y].sort!
print "range x = ",range[:x],"\n"
print "range y = ",range[:y],"\n\n"
$game_map.enemies.each {|enemy|
if range[:x].include?(enemy.x) and range[:y].include?(enemy.y)
print "enemy x = ",enemy.x," - enemy.y = ",enemy.y, "\n"
enemy.damage_enemy(pre_feito)
end
}
if range[:x].include?($game_player.x) and range[:y].include?($game_player.y)
$game_player.damage_hero(pre_feito)
end
end
def remove_bullets(qnt)
if @equipped_weapon.bullets - qnt < 0
@equipped_weapons.bullets = 0
else
@equipped_weapon.bullets -= qnt
end
end
def damage_area(enemy)
Audio.se_stop
Audio.se_play("Audio/Se/#{@equipped_weapon.wav_name}", 100, 100)
SceneManager.scene.spriteset.area(self, enemy.x, enemy.y)
SceneManager.scene.spriteset.explode(enemy.x, enemy.y)
xis, yis = enemy.x, enemy.y
area = {'X' => [], 'Y' => []}
area['X'].push(xis + 1)
area['X'].push(xis - 1)
area['Y'].push(yis + 1)
area['Y'].push(yis - 1)
area['X'].push(xis)
area['Y'].push(yis)
area['X'].sort!; area['Y'].sort!
$game_map.enemies.compact!
a = $game_map.enemies.compact; a.delete(enemy)
attack_enemy(enemy, true)
for enemi in a
if area['X'].include?(enemi.x) and area['Y'].include?(enemi.y)
attack_enemy(enemi, true)
end
end
Audio.se_play("Audio/Se/explosion1", 100, 100)
end
def miss
hero = $game_party.members[0]
@recover = @equipped_weapon.recover
end
def shot_anim;end
def attack_enemy(event, bazooca = false)
hero = $game_party.members[0]
r = rand(10)
rand = r - 5
event.damage_enemy(hero.atk + rand)
if event.object.nil?
SceneManager.scene.spriteset.blood(event, @direction) if bazooca != true
end
@recover = @equipped_weapon.recover
end
def get_bullets(weapon)
if not weapon.bullets == weapon.max
$game_party.lose_item(weapon.magazine, 1)
weapon.bullets += weapon.max
else
return
end
end
def damage_hero(value)
return if @kill_player
jump(0,0)
hero = $game_party.members[0]
value -= (rand(10) - 5)
value = 0 if value < 0
$game_map.damage_sprites.push(Damage_Sprite.new(self, value)) if Show_Damage_Sprites == true
if not value > hero.hp
hero.hp -= value
else
hero.hp = 1
@kill_player = true
RPG::SE.new(Player_Die_SE, 80).play
end
end
def update_kill
if @opacity > 0
@opacity -= Module_Of_Config::Opacity_Burn
else
SceneManager.goto(Scene_Gameover)
end
end
end
#----------------------------------------------------------------------------------#
class Spriteset_Map
alias abs_initialize initialize
alias abs_update update
alias abs_dispose dispose
def initialize
$game_map.damage_sprites = []
$game_map.item_windows = []
$game_map.explosion_chars = []
@spritees = {}
abs_initialize
end
def update
abs_update
trash = []
trash2 = []
$game_map.damage_sprites.each do |sprite|
sprite.update
trash.push(sprite )if sprite.disposed?
end
if !$game_map.item_windows.empty?
if $game_map.item_windows[0].is_a?(Pop)
$game_map.item_windows[0].update
trash2.push($game_map.item_windows[0]) if $game_map.item_windows[0].disposed?
end
end
trash2.each { |item| $game_map.item_windows.delete(item) }
$game_map.item_windows.compact!
trash.each { |item| $game_map.damage_sprites.delete(item) }
trash2.clear; trash.clear
for char in $game_map.explosion_chars
char.update
char.my_sprite = Sprite_Character.new(@viewport1, char) if char.my_sprite.nil?
trash.push(char) if char.disposed?
end
trash.each { |item| $game_map.explosion_chars.delete(item) }
end
def dispose
abs_dispose
$game_map.damage_sprites.each do |sprite|
sprite.bitmap.dispose
sprite.dispose
end
$game_map.damage_sprites.clear
$game_map.item_windows.each do |window|
window.dispose
end
$game_map.item_windows.clear
$game_map.explosion_chars.each { |char| char.dispose }
$game_map.explosion_chars.clear
end
end
#----------------------------------------------------------------------------------#
class Game_Party < Game_Unit
alias metodo_aliasado_com_sucesso gain_item
def gain_item(item, amount, include_equip = false)
times = $game_map.item_windows.size
$game_map.window(Pop.new(item))#, 150 * times))
metodo_aliasado_com_sucesso(item, amount, include_equip = false)
end
end
#----------------------------------------------------------------------------------#
class Damage_Sprite < Sprite
def initialize(target, value)
super(nil)
@target = target
self.bitmap = Bitmap.new(100,20)
self.bitmap.draw_text(0,0,100,20,value,1)
self.ox = 50
self.z = 999
self.x = target.screen_x
self.y = target.screen_y - 40
@timer = 50
end
def update
if @timer > 0
@timer -= 1
self.y -= 1 if not self.y < @target.screen_y - 60
else
if self.opacity > 0
self.opacity -= 15
self.y -= 2
else
dispose
end
end
end
def dispose
self.bitmap.dispose
super
end
end
#----------------------------------------------------------------------------------#
class Reward_Sprite < Sprite
def initialize(target, value)
super(nil)
@target = target
self.bitmap = Bitmap.new(100,20)
self.bitmap.font.color = Color.new(72,0,255)
self.bitmap.draw_text(0,0,100,20,value,1)
self.ox = 50
self.z = 999
self.x = target.screen_x - 5
self.y = target.screen_y - 40
@timer = 50
end
def update
if @timer > 0
@timer -= 1
self.zoom_x += 0.008
self.zoom_y += 0.008
self.y -= 1 if not self.y < @target.screen_y - 60
else
if self.opacity > 0
self.opacity -= 15
self.y -= 2
else
dispose
end
end
end
def dispose
self.bitmap.dispose
super
end
end
#----------------------------------------------------------------------------------#
class Window_Ammo < Window_Base
def initialize
super(0,0,120,52)
self.contents = Bitmap.new(width - 32, height - 32)
if not $game_player.equipped_weapon == nil
self.contents.draw_text(2,0,120,20,"Ammo:" + $game_player.equipped_weapon.bullets.to_s)
end
end
def dispose
super
end
end
#----------------------------------------------------------------------------------#
class Pop < Window_Base
def initialize(item)
if not item.nil?
super(0,355,175,60)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.draw_text(30,5,120,20, item.name)
draw_icon(item.icon_index, 5, 5)
@timer = 70
self.opacity = 0; self.visible = false
else
dispose if not self.disposed?
end
end
def update
return if self.disposed?
self.opacity = 255 if self.opacity != 255
self.visible = true if self.visible == false
@timer > 0 ? @timer -= 1 : dispose
end
def dispose
super
end
end
#----------------------------------------------------------------------------------#
module DataManager
def self.make_save_contents
contents = {}
contents[:system] = $game_system
contents[:timer] = $game_timer
contents[:message] = $game_message
contents[:switches] = $game_switches
contents[:variables] = $game_variables
contents[:self_switches] = $game_self_switches
contents[:actors] = $game_actors
contents[:party] = $game_party
contents[:troop] = $game_troop
contents[:map] = $game_map
contents[:player] = $game_player
if $weapons != nil
$weapons.compact!
contents[:weapons] = $weapons
end
contents
end
def self.extract_save_contents(contents)
$game_system = contents[:system]
$game_timer = contents[:timer]
$game_message = contents[:message]
$game_switches = contents[:switches]
$game_variables = contents[:variables]
$game_self_switches = contents[:self_switches]
$game_actors = contents[:actors]
$game_party = contents[:party]
$game_troop = contents[:troop]
$game_map = contents[:map]
$game_player = contents[:player]
$weapons = contents[:weapons] if contents.has_key?(:weapons)
$weapons.compact!
end
end
#----------------------------------------------------------------------------------#
class Explosion_Character < Game_Character
attr_accessor :my_sprite
def initialize(xis, yis, anim_id, anim_frames = 20)
super()
@identification = rand(200)
moveto(xis, yis)
@animation_id = anim_id
@timer = anim_frames
@timer = 20 if @timer <= 0
@disposed = false
update
end
def update
@my_sprite.update if @my_sprite.class == Sprite_Character
return if self.disposed?
super
if @timer > 0
@timer -= 1
@disposed = false
else
dispose
end
end
def dispose
@my_sprite.dispose if @my_sprite.class == Sprite_Character
@timer = 0
@disposed = true
end
def disposed?; @disposed; end
end
#-----##-----##-----##-----##-----##-----##-----##-----##-----##-----##-----#
# FIM ## FIM ## FIM ## FIM ## FIM ## FIM ## FIM ## FIM ## FIM ## FIM ## FIM #
#-----##-----##-----##-----##-----##-----##-----##-----##-----##-----##-----# module Definitions
Sprite_angles = {2=>[80,110,140,170],4=>[340,10,40,70],6=>[290,260,230,200],8=>[290,320,350,20]}
Move_correction = {2=>[-8,-10],4=>[0,-10],6=>[0,-4],8=>[4,-10]}
Sprite_z_values = { 2=>120, 4=>50, 6=>120, 8=>50}
Static_Angles = {2=>140,4=>40,6=>340,8=>350}
Static_Move = {2=>[-8,-14],4=>[0,-10],6=>[10,0],8=>[4,-10]}
Static_Z = { 2=>120, 4=>50, 6=>120, 8=>50}
Static_Mirror = {2 => false, 4=>false,6=>true,8=>false}
end
class Scene_Map < Scene_Base; attr_reader :spriteset; end
class Spriteset_Map
include Module_Of_Config
include Definitions
attr_accessor :smoke
alias :mtm_initialize :initialize
def initialize
@explosions = []; @smoke = []; @floors = []; @particles = []; @parts = []
@array_weapons = {}; @weapons = {}
mtm_initialize
end
alias :mtm_update :update
def update
update_explosions if !@explosions.empty?
update_smokes if !@smoke.empty?
update_particles if !@particles.empty?
update_parts if !@parts.empty?
update_array if !@array_weapons.empty?
trash = []
@floors.each { |sprite|
sprite.update
if sprite.disposed?
trash.push(sprite)
end
}
trash.each {|item| @floors.delete(item)}; trash.clear
if Show_Weapon_Sprites and $game_player.equipped_weapon != nil
update_vis_equip
end
mtm_update
end
def update_vis_equip
if @weapons.keys.include?(:player)
sprite = @weapons[:player]; player = $game_player
sprite.update
sprite.x = player.screen_x + Static_Move[player.direction][0]
sprite.y = player.screen_y + Static_Move[player.direction][1]
sprite.angle = Static_Angles[player.direction]
sprite.z = Static_Z[player.direction]# - 15
sprite.mirror = Static_Mirror[player.direction]
else
icon = ($game_player.equipped_weapon.weapon.icon_index rescue nil)
return if icon.nil?
bitmap = Bitmap.new(24,24)
bitmap.blt(0,0,Cache.system("Iconset"),Rect.new(icon%16*24,icon/16*24,24,24))
sprite = Sprite.new(@viewport1)
sprite.ox, sprite.oy = 22,22
sprite.zoom_x, sprite.zoom_y = 0.85, 0.85
sprite.bitmap = bitmap
@weapons[:player] = sprite
end
end
def update_array
trash = []
@array_weapons.each_with_index {|array, i|
update_array_weapon(array)
trash.push(@array_weapons[i]) if array[1][1] == false
}
trash.each {|item| @array_weapons.delete(item) }; trash.clear
end
def update_array_weapon(array)
array[1][0].x = array[0].screen_x + Move_correction[array[0].direction][0]
array[1][0].y = array[0].screen_y + Move_correction[array[0].direction][1]
if !array[1][3]
case array[1][2]
when 12
array[1][0].angle = Sprite_angles[array[0].direction][0]
array[1][0].z = Sprite_z_values[array[0].direction] - 15
when 9
array[1][0].angle = Sprite_angles[array[0].direction][1]
array[1][0].z = Sprite_z_values[array[0].direction] - 15
when 6
array[1][0].angle = Sprite_angles[array[0].direction][2]
array[1][0].z = Sprite_z_values[array[0].direction] - 15
when 3
array[1][0].angle = Sprite_angles[array[0].direction][3]
array[1][0].z = Sprite_z_values[array[0].direction] - 15
when 0
array[1][1] = false
array[1][0].bitmap = nil
end
else
if array[1][2] > 0
array[1][0].angle = Sprite_angles[array[0].direction][2]
array[1][0].z = Sprite_z_values[array[0].direction] - 15
else
array[1][1] = false
array[1][0].bitmap = nil
end
end
array[1][0].update
array[1][2] -= 1
end
alias :mtm_dispose :dispose
def dispose
@explosions.each {|sprite| sprite.dispose if not sprite.disposed? }
@explosions = nil
@smoke.each {|sprite| sprite.dispose if not sprite.disposed? }
@smoke = nil
@particles.each {|sprite| sprite.dispose if not sprite.disposed?}
@particles = nil
@parts.each {|sprite| sprite.dispose if not sprite.disposed?}
@parts = nil
if @weapons[:player].is_a?(Sprite)
@weapons[:player].dispose if not @weapons[:player].disposed?
@weapons[:player] = nil
end
mtm_dispose
end
def blood(target, direction)
return unless Show_Blood_Anim
if target.is_a?(Game_Event)
return if target.not_blood
end
3.times { @particles.push(Particle_Sprites::Blood.new(target,direction, @viewport1)) }
@character_sprites.each {|sprite_character|
next if sprite_character.character != target
sprite_character.flash(Color.new(255,0,0), 30)
break
}
end
def explode(x, y)
@explosions.push(Particle_Sprites::Explosion.new(x, y, @viewport1))
i = 0
loop { i += 1; break if i == 5}
for i in 0..Smokes - 1
@smoke.push(Particle_Sprites::Smoke.new(x, y, @viewport1))
end
if Floor
if @floors.empty?
@floors.push(Particle_Sprites::Floor.new(x, y, @viewport1))
else
if not @floors.any? {|floor| floor.event_x == x and floor.event_y == y}
@floors.push(Particle_Sprites::Floor.new(x, y, @viewport1))
end
end
end
end
def weapon(character, icon_index)
return if character.nil?
return if icon_index == 0
icon = icon_index
bitmap = Bitmap.new(24,24)
bitmap.blt(0,0,Cache.system("Iconset"),Rect.new(icon%16*24,icon/16*24,24,24))
sprite = Sprite.new(@viewport1)
sprite.ox, sprite.oy = 22,22
sprite.bitmap = bitmap
@array_weapons[character] = [sprite,true,12,false]
end
def melee(character)
RPG::SE.new("#{Melee_Wav_Name}", 80).play
@particles.push(Particle_Sprites::Melee.new(character, @viewport1))
end
def area(attacker, final_x, final_y)
@particles.push(Particle_Sprites::Area.new(attacker ,final_x, final_y, @viewport1))
end
def shoot(character)
@particles.push(Particle_Sprites::Shot.new(character, @parts, @viewport1))
if Show_Smoke_On_Fire
@smoke.push(Particle_Sprites::Smoke2.new(character, @viewport1))
end
end
def update_explosions
trash = []
@explosions.each {|sprite|
sprite.update
trash.push(sprite) if sprite.disposed?
}
trash.each {|item| @explosions.delete(item)}
trash.clear
end
def update_parts
trash = []
@parts.each {|sprite|
sprite.update
trash.push(sprite) if sprite.disposed?
}
trash.each {|item| @parts.delete(item)}
trash.clear
end
def update_smokes
trash = []
@smoke.each {|sprite|
sprite.update
trash.push(sprite) if sprite.disposed?
}
trash.each {|item| @smoke.delete(item)}
trash.clear
end
def update_particles
trash = []
@particles.each {|sprite|
sprite.update
trash.push(sprite) if sprite.disposed?
}
trash.each {|item| @particles.delete(item)}
trash.clear
end
end module Particle_Sprites
class Area < Game_Character
include Module_Of_Config
attr_accessor :sprite
def initialize(character, final_x, final_y, view)
super(); @character, @fx, @fy = character.clone, final_x, final_y; @view = view
@move_speed = 7
@move_frequency = 3
@through = true
@sprite = Sprite_Character.new(view,self)
set_graphic(AreaChar, 0); @disposed = false
moveto(@character.x, @character.y); set_direction @character.direction
update
end
def update
return if disposed?
@sprite.update if not @sprite.disposed?
if !destination_reached?
move_straight(@direction)
SceneManager.scene.spriteset.smoke.push(Smoke.new(@x, @y, @view))
else
dispose
end
end
def destination_reached?
return true if @x == @fx and @y == @fy
return false
end
def dispose
@disposed = true
@sprite.dispose if not @sprite.disposed?
@sprite = nil
end
def disposed?
@disposed
end
end
class Shot < Sprite
include Module_Of_Config
def initialize(character, parts_array, view)
super(view); @character = character; @direction = character.direction
case @direction
when 2; self.bitmap = Shot_Bit[:y]
when 4; self.bitmap = Shot_Bit[:x]
when 6; self.bitmap = Shot_Bit[:x]
when 8; self.bitmap = Shot_Bit[:y]
end
self.ox, self.oy = 16,16
self.x, self.y = character.screen_x, character.screen_y - 8
@parts = parts_array
@disposer = Game_Character.new
@disposer.moveto(@character.x, @character.y)
@disposer.set_direction(@direction)
get_speed; update
end
def update
return if self.disposed?
case @disposer.direction
when 2
@disposer.moveto(@disposer.x, @disposer.y + 1)
if !@disposer.map_passable?(@disposer.x, @disposer.y, @disposer.direction) or @disposer.collide_with_characters?(@disposer.x, @disposer.y) or $game_map.terrain_tag(@disposer.x, @disposer.y) == 1 and $game_map.counter?(@disposer.x, @disposer.y) != true
dispose; return
end
when 4
@disposer.moveto(@disposer.x - 1, @disposer.y)
if !@disposer.map_passable?(@disposer.x, @disposer.y, @disposer.direction) or @disposer.collide_with_characters?(@disposer.x, @disposer.y) or $game_map.terrain_tag(@disposer.x, @disposer.y) == 1 and $game_map.counter?(@disposer.x, @disposer.y) != true
dispose; return
end
when 6
@disposer.moveto(@disposer.x + 1, @disposer.y)
if !@disposer.map_passable?(@disposer.x, @disposer.y, @disposer.direction) or @disposer.collide_with_characters?(@disposer.x, @disposer.y) or $game_map.terrain_tag(@disposer.x, @disposer.y) == 1 and $game_map.counter?(@disposer.x, @disposer.y) != true
dispose; return
end
when 8
@disposer.moveto(@disposer.x, @disposer.y - 1)
if !@disposer.map_passable?(@disposer.x, @disposer.y, @disposer.direction) or @disposer.collide_with_characters?(@disposer.x, @disposer.y) or $game_map.terrain_tag(@disposer.x, @disposer.y) == 1 and $game_map.counter?(@disposer.x, @disposer.y) != true
dispose; return
end
end
self.x += @vx
self.y += @vy
self.opacity > 0 ? self.opacity -= 25 : dispose
create_new_parts
end
def get_speed
case @direction
when 2
@vx = 0
@vy = 25
when 4
@vx = -25
@vy = 0
when 6
@vx = 25
@vy = 0
when 8
@vx = 0
@vy = -25
end
end
def create_new_parts
return if self.disposed?
3.times do
case @direction
when 2
vx = 0
vy = 1
when 4
vx = -1
vy = 0
when 6
vx = 1
vy = 0
when 8
vx = 0
vy = -1
end
@parts.push(Part.new(self, self.viewport, vx, vy))
end
end
def dispose
super
@disposer = nil
end
end
class Part < Sprite
def initialize(sprite, view, vx, vy)
super(view); @sprite = sprite
self.bitmap = Bitmap.new(2,2)
self.bitmap.fill_rect(0,0,2,2,Color.new(255,216,0))
rx, ry = rand(12) - 6, rand(12) - 6
self.x, self.y = sprite.x + rx, sprite.y + ry
@vx, @vy = vx, vy
update
end
def update
return if self.disposed?
self.x += @vx
self.y += @vy
self.opacity > 0 ? self.opacity -= 8 : dispose
end
end
class Melee < Sprite
include Module_Of_Config
def initialize(character, view)
@character = character.clone
super(view)
self.bitmap = Melee_Bit
self.z = 60; self.blend_type = 1
self.ox, self.oy = 16,16
self.x, self.y = @character.screen_x, @character.screen_y - 8
character!
update
end
def update
return if disposed?
self.opacity > 0 ? self.opacity -= 6 : dispose
end
def character!
case @character.direction
when 2
self.y += 8
self.angle = 180
when 4
self.x -= 8
self.angle = 90
when 6
self.x += 8
self.angle = 270
when 8
self.y -= 8
self.angle = 0
end
end
end
class Explosion < Sprite
include Module_Of_Config
attr_reader :event
def initialize(x, y, viewport)
super(viewport)
@phase = 0; @timer = 30
@event = Game_Character.new
@event.moveto(x,y)
self.z = 999
self.bitmap = Bitmap.new(128,128)
self.ox = 64; self.oy = 64
self.x, self.y = @event.screen_x, @event.screen_y - 32
RPG::SE.new(Explosion_SE, 100).play
self.blend_type = Blend_Type
self.bitmap.blt(0,0,Explosion_Bit,Rect.new(128 * @phase,0,128,128))
self.viewport.flash(Color.new(255,105,0,190),30) if Flash
@event = nil
create_fragments
update
self.viewport.flash(Color.new(234,96,0),25)
end
def create_fragments
@fragments = []
for i in 0..Fragments - 1
@fragments.push(Fragment.new(self.x, self.y, self.viewport))
end
@fragments.compact
end
def update_fragments
trash = []
@fragments.each {|sprite|
sprite.update
trash.push(sprite) if sprite.disposed?
}
trash.each {|item| @fragments.delete(item) if @fragments.include?(item)}
end
def update
return if self.disposed?
update_fragments
self.bitmap.clear
case @timer
when 30
@phase = 0
when 27
@phase = 1
when 24
@phase = 2
when 21
@phase = 3
when 18
@phase = 4
when 15
@phase = 5
when 12
@phase = 6
when 9
@phase = 7
when 6
@phase = 8
when 3
@phase = 9
when 0
self.dispose
end
if @timer == 0
self.dispose if not self.disposed?
return
end
@timer -= 1
self.bitmap.blt(0,0,Explosion_Bit,Rect.new(128 * @phase,0,128,128))
end
def dispose
super
return if @fragments.nil?
if !@fragments.empty?
@fragments.each {|frag|
frag.dispose if not frag.disposed?
}
@fragments.clear
end
end
end
class Fragment < Sprite
include Module_Of_Config
def initialize(x, y, viewport)
super()
self.viewport = viewport
r = rand(15)
self.bitmap = Bitmap.new(32,32)
self.z = 0
self.bitmap.blt(0,0,Fragment_Bit,Rect.new(32 * r,0,32,32))
self.blend_type = 2
@vx, @vy = rand(Frag_Vel) - (Frag_Vel/2).to_i, rand(Frag_Vel) - (Frag_Vel/2).to_i
self.x, self.y = x - 16, y - 16
end
def update
return if self.disposed?
self.x += @vx
self.y += @vy
self.opacity -= 9
end
end
class Smoke < Sprite
include Module_Of_Config
def initialize(x, y, viewport)
@event = Game_Character.new
@event.moveto(x,y)
super(viewport)
self.bitmap = Smoke_Bit
self.blend_type = 2
self.opacity = 150
self.z = 999 - 5
self.x, self.y = @event.screen_x - 16, @event.screen_y - 32 - 16
@event = nil
@vx, @vy = rand(4) - 2, rand(4) - 2
@vx = 1 if @vx == 0; @vy = 1 if @vy == 0
@move_freq = Smoke_Freq
update
end
def update
return if self.disposed?
if @move_freq > 0
@move_freq -= 1
else
@move_freq = Smoke_Freq
self.x += @vx
self.y += @vy
end
self.opacity > 0 ? self.opacity -= 2 : dispose
end
end
class Smoke2 < Sprite
include Module_Of_Config
def initialize(character, viewport)
@character = character.clone
direction = character.direction
super(viewport)
self.bitmap = Smoke_Bit
self.blend_type = 2
self.opacity = 150
self.z = 0
self.zoom_x, self.zoom_y = 0.3, 0.3
case direction
when 2
self.x, self.y = @character.screen_x - 9, @character.screen_y + 6
when 4
self.x, self.y = @character.screen_x - 26, @character.screen_y - 19
when 6
self.x, self.y = @character.screen_x + 9, @character.screen_y - 21
when 8
self.x, self.y = @character.screen_x - 9, @character.screen_y - 36
end
@vx, @vy = rand(4) - 2, rand(4) - 2
@vx = 1 if @vx == 0; @vy = 1 if @vy == 0
@move_freq = Smoke_Freq + 2
update
end
def update
return if self.disposed?
if @move_freq > 0
@move_freq -= 1
else
@move_freq = Smoke_Freq + 2
self.x += @vx
self.y += @vy
end
self.opacity > 0 ? self.opacity -= 4 : dispose
end
end
class Floor < Sprite
attr_reader :event_x
attr_reader :event_y
def initialize(x,y,viewport)
@event_x, @event_y = x,y
super(viewport)
self.z = 0
self.ox, self.oy = 16,16
self.bitmap = Module_Of_Config::Floor_Bit
@event = Game_Character.new
@event.moveto(x,y)
self.x, self.y = @event.screen_x, @event.screen_y - 8
self.z = @event.screen_z
end
def update
self.x = @event.screen_x if self.x != @event.screen_x
self.y = @event.screen_y - 8 if self.y != @event.screen_y - 8
self.z = @event.screen_z if self.z != @event.screen_z
end
end
class PlayerWeapon < Sprite
Sprite_z_values = { 2=>120, 4=>50, 6=>120, 8=>50}
Sprite_Mirror = {2=>false,4=>false,6=>true,8=>false}
Sprite_Angles = {2=>100, 4=>20, 6=>340, 8=>100}
Move_correction = {2=>[2,-4],4=>[-7,-10],6=>[8,-14],8=>[-2,-18]}
def initialize(view)
super(view)
self.bitmap = Bitmap.new(24,24)
self.ox, self.oy = 12,12
icon = $game_player.equipped_weapon.weapon.icon_index
self.bitmap.blt(0,0,Cache.system("Iconset"), Rect.new(icon%16*24,icon/16*24,24,24))
update
end
def update
self.x = $game_player.screen_x + Move_correction[$game_player.direction][0]
self.y = $game_player.screen_y + Move_correction[$game_player.direction][1]
self.z = Sprite_z_values[$game_player.direction]
self.angle = Sprite_Angles[$game_player.direction]
self.mirror = Sprite_Mirror[$game_player.direction]
end
end
class Blood < Sprite
include Module_Of_Config
def initialize(target, direction, view)
@target, @direction = target, direction
super(view)
self.bitmap = Bitmap.new(32,32)
rand = rand(7) + 3
self.bitmap.blt(0,0,Blood_Bit, Rect.new(32 * rand,0,32,32))
self.ox, self.oy = 16,16
self.x, self.y = @target.screen_x, @target.screen_y - 8
self.z = 30
get_speed
update
end
def update
return if self.disposed?
return if @vx.nil? or @vy.nil?
if @target.nil?
dispose; return
end
self.x += @vx
self.y += @vy
self.opacity > 0 ? self.opacity -= 6 : dispose
end
def get_speed
case @direction
when 2
@vx = rand(4) - 2
@vy = rand(4)
when 4
@vx = -rand(4)
@vy = rand(4) - 2
when 6
@vx = rand(4)
@vy = rand(4) - 2
when 8
@vx = rand(4) - 2
@vy = -rand(4)
end
end
end
end |
Последнее редактирование: 4 года 10 мес. назад от Uzuzu74. Причина: ошибки
Администратор запретил публиковать записи гостям.
|
Разбор скрипта Re weapon system 2 4 года 10 мес. назад #115392
|
мелкьом глянул
хп, пули и прочее в первом скрипте. self.contents.fill_rect(0,8,151,11,Color.new(255,216,0))
self.contents.fill_rect(1,9,149,9,Color.new(0,0,0))
self.contents.gradient_fill_rect(1,9,@wb,9,Color.new(205,101,0),Color.new(0,89,0))
self.contents.draw_text(0,8,151,21,"HP",1)
if $game_player.equipped_weapon != nil
self.contents.draw_text(0,31,120,20,@ammo.to_s)
draw_icon(967, 16, 31)
self.contents.draw_text(100,31,120,20,@mags.to_s) if not @mags.nil?
draw_icon($game_player.equipped_weapon.iconset_id, 116, 30) в функции fill_rect, напримр в fill_rect(0,8,151,11,Color.new(255,216,0): 0 - положение по оси X 8 - положение по оси Y (начало координт сверху) 151 - ширина 11 - высота Color.new(255,216,0) - цвет. соответвует цвету в формате RGB, где первое число - красный,второе - зеленый, третье - синий gradient_fill_rect тоже самое, но доабвляется в конце еще один цвет для создания градиента draw_text(0,8,151,21,"HP",1) почти также как в fill_rect: 0 - положение по оси X 8 - положение по оси Y (начало координт сверху) 151 - ширина 11 - высота "HP" - отображаемый текст 1 - наверное прозрачность. от 0.1 до 1 draw_icon(967, 16, 31), скорее всего 967 - номер иконки в иконсете 16 - расположение по оси X 31 - оси Y расположение при повороте скорее всгео в 4 скрипте вот здесь: if !array[1][3]
case array[1][2]
when 12
array[1][0].angle = Sprite_angles[array[0].direction][0]
array[1][0].z = Sprite_z_values[array[0].direction] - 15
when 9
array[1][0].angle = Sprite_angles[array[0].direction][1]
array[1][0].z = Sprite_z_values[array[0].direction] - 15
when 6
array[1][0].angle = Sprite_angles[array[0].direction][2]
array[1][0].z = Sprite_z_values[array[0].direction] - 15
when 3
array[1][0].angle = Sprite_angles[array[0].direction][3]
array[1][0].z = Sprite_z_values[array[0].direction] - 15
when 0
array[1][1] = false
array[1][0].bitmap = nil вместо 15 меняй числа, возможно это оно и есть |
Администратор запретил публиковать записи гостям.
|
Разбор скрипта Re weapon system 2 4 года 10 мес. назад #115396
|
С отображением НР, пуль, и их количества, всё прошло на ура.
Большое спасибо. А вот,с поднятием анимации, от выстрелов, у меня ничего не выходит. |
Администратор запретил публиковать записи гостям.
|
Разбор скрипта Re weapon system 2 4 года 10 мес. назад #115397
|
Uzuzu74 пишет:
С отображением НР, пуль, и их количества, всё прошло на ура. Большое спасибо. А вот,с поднятием анимации, от выстрелов, у меня ничего не выходит. ищи что-нибудь типа direction вот в последнем скрипте эти строки скорее всего, даже класс подходит - smoke2 (в переводе "дым") меняй цифры которые возле screen_x или screen_y case direction
when 2
self.x, self.y = @character.screen_x - 9, @character.screen_y + 6
when 4
self.x, self.y = @character.screen_x - 26, @character.screen_y - 19
when 6
self.x, self.y = @character.screen_x + 9, @character.screen_y - 21
when 8
self.x, self.y = @character.screen_x - 9, @character.screen_y - 36
end |
Последнее редактирование: 4 года 10 мес. назад от yuryol.
Администратор запретил публиковать записи гостям.
|
Разбор скрипта Re weapon system 2 4 года 8 мес. назад #116091
|
Народ, кто знает как в этом скрипте можно было бы убрать оружие из рук персонажа (тут я сам буду менять его графику) ибо выглядит оно достаточно кривовато, оставить только различные эффекты выстрелов.
Пока только это получилось путем сохранения чистого png иконок, но иконки хотелось бы все же сохранить |
Администратор запретил публиковать записи гостям.
|
Модераторы: NeKotZima
Время создания страницы: 0.691 секунд