Allora...visto che il sistema di battaglia di FFXII, e il suo sistema in generale mi è piaciuto molto, ho deciso di mettermi di buona lena e fare uno script che implementi tutto ciò che è presente nel gioco, dal bs al menu, al sistema in generale.
Ho deciso di postare mano a mano gli aggiornamenti di ciò che sto facendo nella speranza che qualcuno possa apprendere meglio l'RGSS chiedendo spiegazioni sul suo funzionamento, e anche per sentirmi un po' spronato a continuare il lavoro senza mollarlo a metà. ;O;
Archivio aggiornamenti
Update 12/3/07
• Movimento casuale dei nemici
• I nemici notano il personaggio e gli vanno incontro se questo si avvicina troppo
• Menù di battaglia apribile su mappa premendo invio (se c'è un evento, il menù viene disabilitato)
• Il menù di battaglia utilizza un cursore che si muove realmente sullo schermo (insomma non si teletrasporta qua e là)
• Premendo Attacco comparirà un elenco con il nome dei nemici, in base al nome dell'evento, sempre che esistano eventi nemici in un raggio di 6 quadretti
Update 12/3/07
• Durante la selezione del nemico un cursore indicherà sulla mappa quale è il nemico selezionato (utile con molti nemici in campo)
• Corretti alcuni bug
Update 14/3/07
• Una finestra mostra gli hp del mostro, che sono presi dal database di default: basterà infatti creare l'evento inserendo come nome l'id del mostro che si vuole utilizzare
• Premendo attacco si colpisce il nemico e gli si riducono gli hp: azzerati gli hp il nemico muore. Se si entra e riesce dalla mappa il nemico ricompare.
Update 16/7/07
• Aggiunto un nuovo caterpillar script: i due membri del party successivi al principale sono ora presenti sulla mappa e seguono l'eroe in maniera molto più realistica rispetto ad altri caterpillar presenti sulla rete (funzionante ma da completare)
Update 17/07/07
• Migliorato il caterpillar: ora i personaggi non passano attraverso i muri e evitano la maggior parte degli ostacoli con la loro intelligenza artificiale (alcuni ostacoli complessi li fanno ancora impallare)
• Corretti alcuni bug del caterpillar (che si può dire ormai completato)
Ultimo aggiornamento: 05/06/08
• Aggiunto il battle status dei personaggi (cioè la barra con gli hp e gli mp)
• Le barre sono luminescenti ;O;
Ed ecco lo script:
Istruzioni
Incollate tutto ciò che è contenuto nel file *.txt in una pagina sopra il main.
Importate come Icon l'immagine HandCursor.png lasciando il nome invariato.
A questo punto lo script sarà già in funzione:
• per aprire il menù premere Invio
• per creare un evento Nemico basta creare un evento con grafica a vostra scelta e inserire come commento
begin nemico
A questo punto inserite al posto del nome dell'evento, l'id del mostro che volete (seguendo gli id del database).
Immagine e file *.txt sono allegati a seguire
Aggiungo comunque lo script in spoiler: è lungo.
L'ho dovuto dividere in più parti altrimenti lo spoiler impazziva.. o_
Non apritele insieme o implode XD
#================================#
# - FFXII Development Kit V0.1 #
#--------------------------------#
# By Alato ~ www.rpg2s.net #
#================================#
class Game_Temp
attr_accessor :battle_menu_closed
attr_accessor :party_change_flag
attr_accessor :hp_change_flag
alias temp_initialize initialize
def initialize
temp_initialize
@battle_menu_closed = true
@party_change_flag = true
@hp_change_flag = true
end
end
class Game_Battler
def hp=(hp)
@hp = [[hp, maxhp].min, 0].max
# Morte - Resurrezione
for i in 1...$data_states.size
if $data_states[i].zero_hp
if self.dead?
add_state(i)
else
remove_state(i)
end
end
end
end
end
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# - Inizializzazione Oggetto
# troop_id : ID Gruppo di menici
# member_index : Indice del nemico
#--------------------------------------------------------------------------
def initialize(troop, member_index)
super()
@member_index = member_index
@enemy_id = troop[@member_index]
enemy = $data_enemies[@enemy_id]
@battler_name = enemy.battler_name
@battler_hue = enemy.battler_hue
@hp = maxhp
@sp = maxsp
#@hidden = troop[@member_index].hidden
#@immortal = troop[@member_index].immortal
end
end
class Game_Party
# Modifiche per non fare crashare il gioco
# quando non ci sono i compagni
# (caterpillar script)
#sostituiti totalmente add_actor e remove_actor
#--------------------------------------------------------------------------
# - Aggiunta Eroe
# actor_id : ID Eroe
#--------------------------------------------------------------------------
def add_actor(actor_id)
# Acquisizione Eroe
actor = $game_actors[actor_id]
# Quando ci sono meno di 4 eroi e l'eroe non è già nel gruppo
if @actors.size < 4 and not @actors.include?(actor)
# Aggiungi Eroe
@actors.push(actor)
# Aggiornamento Giocatore
$game_player.refresh
# Parte aggiunta
$game_temp.party_change_flag = true
$game_second_player.refresh
$game_third_player.refresh
end
end
#--------------------------------------------------------------------------
# - Rimozione Eroe
# actor_id : ID Eroe
#--------------------------------------------------------------------------
def remove_actor(actor_id)
# Rimozione Eroe
@actors.delete($game_actors[actor_id])
# Aggiornamento Giocatore
$game_player.refresh
# Parte aggiunta
$game_temp.party_change_flag = true
$game_second_player.refresh
$game_third_player.refresh
end
end
#==============================================================================
# - Game_Troop
#------------------------------------------------------------------------------
# E' la classe che gestisce i gruppi di mostri,
# usa come riferimeto $game_troop
#==============================================================================
class Game_Troop
#--------------------------------------------------------------------------
# - Settaggio
# troop_id : ID Gruppo Nemici
#--------------------------------------------------------------------------
def setup(troop, enem_events)
# Settaggio dei nemici
@enemies = []
@enem_events = enem_events
@troop = troop
#troop = $data_troops[troop_id]
for i in 0...@troop.size
enemy = $data_enemies[@troop[i]]
if enemy != nil
@enemies.push(Game_Enemy.new(@troop, i))
end
end
end
def che_nemico?(event_id)
for i in 0..@troop.size
if @enem_events[i] == event_id
return i
end
end
end
end
class Game_Map
#--------------------------------------------------------------------------
# - Settaggio Mappa
# map_id : ID Mappa
#--------------------------------------------------------------------------
def setup(map_id)
# Setta l'ID della mappa in @map_id
@map_id = map_id
# La mappa è presa dal file e settata in @map
@map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
# Settaggio delle Variabili
tileset = $data_tilesets[@map.tileset_id]
@tileset_name = tileset.tileset_name
@autotile_names = tileset.autotile_names
@panorama_name = tileset.panorama_name
@panorama_hue = tileset.panorama_hue
@fog_name = tileset.fog_name
@fog_hue = tileset.fog_hue
@fog_opacity = tileset.fog_opacity
@fog_blend_type = tileset.fog_blend_type
@fog_zoom = tileset.fog_zoom
@fog_sx = tileset.fog_sx
@fog_sy = tileset.fog_sy
@battleback_name = tileset.battleback_name
@passages = tileset.passages
@priorities = tileset.priorities
@terrain_tags = tileset.terrain_tags
# Inizializzazione Coordiante
@display_x = 0
@display_y = 0
# Elimina la richiesta di aggiornamento
@need_refresh = false
# Settaggio dati degli eventi
@events = {}
enemies = []
enem_events = []
for i in @map.events.keys
@events[i] = Game_Event.new(@map_id, @map.events[i])
if @events[i].nemico?
id_nemico = @events[i].name.to_i
enemies.push(id_nemico)
enem_events.push(i)
end
end
unless enemies.empty?
$game_troop.setup(enemies, enem_events)
end
# Settaggio dati degli eventi couni
@common_events = {}
for i in 1...$data_common_events.size
@common_events[i] = Game_CommonEvent.new(i)
end
# Settaggio della nebbia
@fog_ox = 0
@fog_oy = 0
@fog_tone = Tone.new(0, 0, 0, 0)
@fog_tone_target = Tone.new(0, 0, 0, 0)
@fog_tone_duration = 0
@fog_opacity_duration = 0
@fog_opacity_target = 0
# Settaggio dello scroll
@scroll_direction = 2
@scroll_rest = 0
@scroll_speed = 4
end
end
############################################
######## Aggiunte a Game_Character #########
############################################
class Game_Character
alias chara_initialize initialize
def initialize
chara_initialize
@allerta = false
end
#--------------------------------------------------------------------------
# - Aggiornamento
#--------------------------------------------------------------------------
def update
if party_member?
if in_chara_range?(1) == false
@move_type = 5 # Movimento party
if in_chara_range?(2) == true
@move_speed = 4#3
else
@move_speed = 4
end
elsif $game_player.moving?
@move_type = 6
end
end
if nemico?
if in_chara_range?(3) == false
@move_type = 4 # 4 = Movimento Nemico
@move_speed = 1
@character_hue = 0
else
@move_type = 2
@move_speed = 2
@character_hue = 50
end
@move_frequency = 6
end
if jumping?
update_jump
elsif moving?
update_move
else
update_stop
end
if @anime_count > 18 - @move_speed * 2
if not @step_anime and @stop_count > 0
@pattern = @original_pattern
else
@pattern = (@pattern + 1) % 4
end
@anime_count = 0
end
if @wait_count > 0
@wait_count -= 1
return
end
if @move_route_forcing
move_type_custom
return
end
if @starting or lock?
return
end
if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency)
case @move_type
when 1
move_type_random
when 2
move_type_toward_player
when 3
move_type_custom
when 4
move_type_nemico
when 5
move_party_player
when 6
move_type_fermo
end
end
end
#--------------------------------------------------------------------------
# - Riposiziona
#--------------------------------------------------------------------------
def riposiziona
case rand(3)
when 0
r_x = $game_map.display_x + rand(21)*128 - 128*3
r_y = $game_map.display_y - 128*3
when 1
r_x = $game_map.display_x + rand(21)*128 - 128*3
r_y = $game_map.display_y + 2176 + 128*3
when 2
r_x = $game_map.display_x - 128*3
r_y = $game_map.display_y + rand(16)*128 - 128*3
when 3
r_x = $game_map.display_x + 2816 + 128*3
r_y = $game_map.display_y + rand(16)*128 - 128*3
end
x = r_x / 128
y = r_y / 128
if $game_map.passable?(x, y, 0)
@real_x = r_x
@real_y = r_y
@x = x
@y = y
else
riposiziona
end
r = rand(23) + 1
if r < 10
name = "10" + r.to_s + "-Civilian0" + r.to_s
else
name = "1" + r.to_s + "-Civilian" + r.to_s
end
@character_name = name
#@move_speed = rand(2)+ 1
end
#--------------------------------------------------------------------------
# - Movimento Nemico
#--------------------------------------------------------------------------
def move_type_nemico
case rand(19)
when 0..16
move_forward
when 17
move_random
when 18
@stop_count = 0
end
end
def move_type_fermo
end
def move_type_toward_player
sx = @x - $game_player.x
sy = @y - $game_player.y
abs_sx = sx > 0 ? sx : -sx
abs_sy = sy > 0 ? sy : -sy
if sx + sy >= 20
move_random
return
end
case rand(6)
when 0..3
move_toward_player
when 4
move_toward_player#move_random
when 5
move_toward_player#move_forward
end
end
def move_party_player
case @act
when 1
mdf = -1
when 2
mdf = 1
end
gp = $game_player
mdf_x = (gp.direction == 6 ? 1 : gp.direction == 4 ? -1 : gp.direction == 2 ? mdf : gp.direction == 8 ? mdf : 0)
mdf_y = (gp.direction == 2 ? 1 : gp.direction == 8 ? -1 : gp.direction == 6 ? mdf : gp.direction == 4 ? mdf : 0)
sx = @x - $game_player.x + mdf_x
sy = @y - $game_player.y + mdf_y
if sx == 0 and sy == 0
return
end
abs_sx = sx.abs
abs_sy = sy.abs
if abs_sx == abs_sy
rand(2) == 0 ? abs_sx += 1 : abs_sy += 1
end
if abs_sx > abs_sy
sx > 0 ? move_left : move_right
if not moving? and sy != 0
sy > 0 ? move_up : move_down
end
else
sy > 0 ? move_up : move_down
if not moving? and sx != 0
sx > 0 ? move_left : move_right
end
end
if not moving?
if not in_chara_range?(1)
case @act
when 1
if abs_sx < abs_sy
sx > 0 ? move_right : move_left
else
sy > 0 ? move_down : move_up
end
when 2
if abs_sx < abs_sy
sx > 0 ? move_left : move_right
else
sy > 0 ? move_up : move_down
end
end
end
end
end
end
#--------------------------------------------------------------------------
# - E' a (quadretti) distanza dall'eroe?
#--------------------------------------------------------------------------
def in_chara_range?(quadretti)
screne_x = $game_player.real_x
screne_x -= 128*(1+quadretti)
screne_y = $game_player.real_y
screne_y -= 128*(1+quadretti)
screne_width = $game_player.real_x
screne_width += 128*(1+quadretti)
screne_height = $game_player.real_y
screne_height += 128*(1+quadretti)
return false if real_x <= screne_x
return false if real_x >= screne_width
return false if real_y <= screne_y
return false if real_y >= screne_height
return true
end
############################################
######### Aggiunte a GAme_Event ############
############################################
class Game_Event < Game_Character
#
# - Controlla se è un membro del party
#
def party_member?
return false
end
#--------------------------------------------------------------------------
# - Controlla se è un nemico
#--------------------------------------------------------------------------
def nemico?
params = XPML_read("nemico",@id,2)
return (params != nil)
end
def name
return @event.nil? ? '' : @event.name
end
def death
# Settaggio di alcune variabili
@tile_id = 0
@character_name = ""
@character_hue = 0
@move_type = 0
@through = true
@trigger = nil
@list = nil
@interpreter = nil
end
end
############################################
######### Aggiunte a Game_Player ###########
############################################
class Game_Player
def party_member?
return false
end
def nemico?
return false
end
def check_event_trigger_here(triggers)
result = false
# Quando si sta eseguendo un evento
if $game_system.map_interpreter.running?
return result
end
# Loop degli eventi
for event in $game_map.events.values
# Quando le coordinate sono uguali e l'evento ha come condizione di inizio "Azione"
if event.x == @x and event.y == @y and triggers.include?(event.trigger) and event.nemico? == false
# Quando l'evento è eseguibile
if not event.jumping? and event.over_trigger?
event.start
result = true
end
end
end
return result
end
#--------------------------------------------------------------------------
# - Controllo esecuzione degli eventi
#--------------------------------------------------------------------------
def check_event_trigger_there(triggers)
result = false
# Quando si sta eseguendo un evento
if $game_system.map_interpreter.running?
return result
end
# Sono calcolate le coordinate del tile davanti all'eroe
new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# Loop degli Eventi
for event in $game_map.events.values
# Quando le coordinate sono uguali e l'evento ha come condizione di inizio "Azione"
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger) and event.nemico? == false
# Quando l'evento è eseguibile
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
# Quando non è rilevato nessun evento
if result == false
# Quando c'è un "incontra attraverso" nel title d'avanti
if $game_map.counter?(new_x, new_y)
# Calcola le coordinate di 2 tile davanti all'eroe
new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)
# Loop degli Eventi
for event in $game_map.events.values
# Quando le coordinate sono uguali e l'evento ha come condizione di inizio "Azione"
if event.x == new_x and event.y == new_y and
triggers.include?(event.trigger) and event.nemico? == false
# Quando l'evento è eseguibile
if not event.jumping? and not event.over_trigger?
event.start
result = true
end
end
end
end
end
return result
end
#--------------------------------------------------------------------------
# - Aggiornamento
#--------------------------------------------------------------------------
def update
# Memorizza l'ultimo movimento se ci si sta muovendo
last_moving = moving?
# Se ci si sta muovendo o si sta eseguendo un evento parallelo
# o c'è un muovi evento o c'è una finestra di messaggio
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing
# Quando è premuto un tasto muove l'eroe
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
# Le coordinate vengono memorizzate in variabili temporanee
last_real_x = @real_x
last_real_y = @real_y
super
# Quando l'eroe si muove verso giu ed è possibile muovere la mappa
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# Muovi la mappa
$game_map.scroll_down(@real_y - last_real_y)
end
# Quando l'eroe si muove verso sinistra ed è possibile muovere la mappa
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# Muovi la mappa
$game_map.scroll_left(last_real_x - @real_x)
end
# Quando l'eroe si muove verso destra ed è possibile muovere la mappa
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# Muovi la mappa
$game_map.scroll_right(@real_x - last_real_x)
end
# Quando l'eroe si muove verso sù ed è possibile muovere la mappa
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# Muovi la mappa
$game_map.scroll_up(last_real_y - @real_y)
end
# Quando non ci si sta muovendo
unless moving?
# Quando il movimento è appena finito
if last_moving
# Controllo eventi "Tocco con l'eroe" - "Collisione"
result = check_event_trigger_here([1,2])
# Se non ci sono eventi da eseguire
if result == false
# Se la modalità di debug è disattiva e non si sta premendo ctrl
unless $DEBUG and Input.press?(Input::CTRL)
# Conteggio incontri casuali
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# Quando C è premuto
if Input.trigger?(Input::C)
# Controlla esecuzione eventi
$game_temp.battle_menu_closed = check_event_trigger_here([0])
$game_temp.battle_menu_closed = check_event_trigger_there([0,1,2])
end
end
#
if moving? and Input.trigger?(Input::C)
$game_temp.battle_menu_closed = false
end
end
end
#==============================================================================
# - Game_Event
#------------------------------------------------------------------------------
# E' la classe che gestisce gli eventi
# E' usata in Game_Map
#==============================================================================
class Game_Party_Player < Game_Character
#--------------------------------------------------------------------------
# - Variabile
#--------------------------------------------------------------------------
attr_reader :trigger # Condizione d'avvio
attr_reader :list # Lista dei comandi
attr_reader :starting # Se l'evento è in esecuzione
#--------------------------------------------------------------------------
# - Inizializzazione Oggetto
# map_id : ID Mappa
# event : Evento (RPG::Event)
#--------------------------------------------------------------------------
def initialize(act)
super()
@act = act
@erased = false
@starting = false
@through = false
# Posizionamento
#moveto(@event.x, @event.y)
refresh
end
def party_member?
return true
end
def nemico?
return false
end
#--------------------------------------------------------------------------
# - Settaggio di @starting
#--------------------------------------------------------------------------
def clear_starting
@starting = false
end
#--------------------------------------------------------------------------
# - Controllo Sovrapposizione
#--------------------------------------------------------------------------
def over_trigger?
# Se l'eroe non esiste o non può eseguire eventi
if @character_name != "" and not @through
# Esecuzione impossibile
return false
end
# Quando la posizione non è calpestabile
unless $game_map.passable?(@x, @y, 0)
# Esecuzione impossibile
return false
end
# Esecuzione possibile
return true
end
#--------------------------------------------------------------------------
# - Qui c'era def start
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# - Eliminazione
#--------------------------------------------------------------------------
def erase
@erased = true
refresh
end
#--------------------------------------------------------------------------
# - Aggiornamento
#--------------------------------------------------------------------------
def refresh
if $game_party.actors.size <= @act
# Vengono cancellati nome e tonalità
@character_name = ""
@character_hue = 0
return
end
actor = $game_party.actors[@act]
@character_name = actor.character_name
@character_hue = actor.character_hue
@opacity = 255
@blend_type = 0
end
#--------------------------------------------------------------------------
# - Controllo evento con collisione
#--------------------------------------------------------------------------
def check_event_trigger_touch(x, y)
# Quando è già in esecuzione
if $game_system.map_interpreter.running?
return
end
# Quando le coordinate sono uguali e l'evento ha come condizione di inizio "Tocco con l'eroe"
if @trigger == 2 and x == $game_player.x and y == $game_player.y
# Quando l'evento è eseguibile
if not jumping? and not over_trigger?
start
end
end
end
#--------------------------------------------------------------------------
# - Controllo evento con inizio automatico
#--------------------------------------------------------------------------
def check_event_trigger_auto
# Quando le coordinate sono uguali
if @trigger == 2 and @x == $game_player.x and @y == $game_player.y
# Quando l'evento è eseguibile
if not jumping? and over_trigger?
start
end
end
# Se la condizione è inizio automatico
if @trigger == 3
start
end
end
#--------------------------------------------------------------------------
# - Aggiornamento
#--------------------------------------------------------------------------
def update
super
# Controllo evento con inizio automatico
check_event_trigger_auto
# Quando c'è un processo parallelo da eseguire
if @interpreter != nil
# Quando l'interprete non è in esecuzone
unless @interpreter.running?
# Esecuzione di un evento
@interpreter.setup(@list, @event.id)
end
# Aggiornamento Interprete
@interpreter.update
end
end
end
class Spriteset_Map
#--------------------------------------------------------------------------
# - Inizializzazione Oggetto
#--------------------------------------------------------------------------
def initialize
# Creazione Livelli
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 200
@viewport3.z = 5000
# Creazione Titlemap
@tilemap = Tilemap.new(@viewport1)
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
for i in 0..6
autotile_name = $game_map.autotile_names[i]
@tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = $game_map.data
@tilemap.priorities = $game_map.priorities
# Creazione Panorama
@panorama = Plane.new(@viewport1)
@panorama.z = -1000
# Creazione Nebbia
@fog = Plane.new(@viewport1)
@fog.z = 3000
# Creazione Chara
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
@character_sprites.push(Sprite_Character.new(@viewport1, $game_second_player))
@character_sprites.push(Sprite_Character.new(@viewport1, $game_third_player))
# Creazione effetti meteorologici
@weather = RPG::Weather.new(@viewport1)
# Creazione Pictures
@picture_sprites = []
for i in 1..50
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures[i]))
end
# Creazione Sprite del timer
@timer_sprite = Sprite_Timer.new
# Aggiornamento frame
update
end
end
class Window_Base
#--------------------------------------------------------------------------
# - Disegna il nome
# actor : Personaggio
# x : Posizione del disegno: Coordinate X
# y : Posizione del disegno: Coordinate Y
#--------------------------------------------------------------------------
def draw_target_name(actor, x, y)
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 20
self.contents.font.color = normal_color
self.contents.draw_text_bordered(x, y, 120, 32, actor.name)
end
#--------------------------------------------------------------------------
# - Disegna i punti HP del bersaglio
# actor : Bersaglio
# x : Posizione del disegno: Coordinate X
# y : Posizione del disegno: Coordinate Y
# width : Ampiezza del disegno
#--------------------------------------------------------------------------
def draw_target_hp(actor, x, y, width = 144)
# Disegna la sequenza dei caratteri: "HP"
self.contents.font.color = system_color
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 20
self.contents.draw_text_bordered(x, y, 32, 32, $data_system.words.hp)
# Calcola se c'è qualche spazio che disegna i punti MaxHp
if width - 32 >= 108
hp_x = x + width - 108
flag = true
elsif width - 32 >= 48
hp_x = x + width - 48
flag = false
end
# Disegna i punti HP
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 20
self.contents.draw_text_bordered(hp_x, y, 48, 32, actor.hp.to_s, 2)
# Disegna i punti MaxHP
if flag
self.contents.font.color = normal_color
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 20
self.contents.draw_text_bordered(hp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text_bordered(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
end
end
#--------------------------------------------------------------------------
# - Disegna i punti HP dei personaggi
# actor : Personaggio
# x : Posizione del disegno: Coordinate X
# y : Posizione del disegno: Coordinate Y
# width : Ampiezza del disegno
#--------------------------------------------------------------------------
def draw_player_hp(actor_hp, actor_maxhp, x, y, bar_flag = false)
# Disegna la sequenza dei caratteri: "HP"
self.contents.font.color = system_color
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 16
self.contents.draw_text_bordered(x, y+1, 48, 32, "HP")
# Calcola se c'è qualche spazio che disegna i punti MaxHp
hp_x = x
flag = true
draw_gray_bar(hp_x - 1, y+23, 86)
draw_cyan_bar(hp_x, y+24, 84)
draw_hp_bar(hp_x, y+24, 84, actor_hp, actor_maxhp)
if flag
self.contents.font.color = normal_color
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 16
#self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text_bordered(hp_x + 35, y+1, 48, 32, actor_maxhp.to_s,2)
end
size = self.contents.text_size(actor_maxhp.to_s).width
# Disegna i punti HP
self.contents.font.color = actor_hp == 0 ? knockout_color :
actor_hp <= actor_maxhp / 4 ? crisis_color : normal_color
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 22
self.contents.draw_text_bordered(hp_x +33 - size, y-1, 48, 32, actor_hp.to_s, 2)
end
#--------------------------------------------------------------------------
# - Disegna i punti MP
# actor : Personaggio
# x : Posizione del disegno: Coordinate X
# y : Posizione del disegno: Coordinate Y
# width : Ampiezza del disegno
#--------------------------------------------------------------------------
def draw_player_sp(actor, x, y, width = 144)
# Disegna la sequenza dei caratteri: "MP"
self.contents.font.color = system_color
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 16
self.contents.draw_text_bordered(x+15, y+1, 32, 32, "MP")
# Calcola se c'è qualche spazio che disegna i punti MaxMp
sp_x = x+15
flag = false
draw_gray_bar(sp_x - 1, y+23, 52)
draw_orange_bar(sp_x, y+24, 50)
draw_mp_bar(sp_x, y+24, 50, actor)
# Disegna i punti MP
self.contents.font.color = actor.sp == 0 ? knockout_color :
actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 22
self.contents.draw_text_bordered(x + 35, y-1, 32, 32, actor.sp.to_s, 2)
# Disegna i punti MaxMP
if flag
self.contents.font.color = normal_color
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 16
self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
end
end
def draw_gray_bar(x, y, length)
gradient_red_start = 0
gradient_red_end = 0
gradient_green_start = 0
gradient_green_end = 0
gradient_blue_start = 0
gradient_blue_end = 0
draw_bar_percent = 100
for x_coord in 1..length
current_percent_done = x_coord * 100 / length
difference = gradient_red_end - gradient_red_start
red = gradient_red_start + difference * x_coord / length
difference = gradient_green_end - gradient_green_start
green = gradient_green_start + difference * x_coord / length
difference = gradient_blue_end - gradient_blue_start
blue = gradient_blue_start + difference * x_coord / length
if current_percent_done <= draw_bar_percent
rect = Rect.new(x + x_coord-1, y, 1, 4)
self.contents.fill_rect(rect, Color.new(red, green, blue, 255))
end
end
end
def draw_cyan_bar(x, y, length)
gradient_red_start = 80
gradient_red_end = 80
gradient_green_start = 80
gradient_green_end = 80
gradient_blue_start = 130
gradient_blue_end = 130
draw_bar_percent = 100
for x_coord in 1..length
current_percent_done = x_coord * 100 / length
difference = gradient_red_end - gradient_red_start
red = gradient_red_start + difference * x_coord / length
difference = gradient_green_end - gradient_green_start
green = gradient_green_start + difference * x_coord / length
difference = gradient_blue_end - gradient_blue_start
blue = gradient_blue_start + difference * x_coord / length
if current_percent_done <= draw_bar_percent
rect = Rect.new(x + x_coord-1, y, 1, 2)
self.contents.fill_rect(rect, Color.new(red, green, blue, 255))
end
end
end
def draw_orange_bar(x, y, length)
gradient_red_start = 130
gradient_red_end = 130
gradient_green_start = 80
gradient_green_end = 80
gradient_blue_start = 80
gradient_blue_end = 80
draw_bar_percent = 100
for x_coord in 1..length
current_percent_done = x_coord * 100 / length
difference = gradient_red_end - gradient_red_start
red = gradient_red_start + difference * x_coord / length
difference = gradient_green_end - gradient_green_start
green = gradient_green_start + difference * x_coord / length
difference = gradient_blue_end - gradient_blue_start
blue = gradient_blue_start + difference * x_coord / length
if current_percent_done <= draw_bar_percent
rect = Rect.new(x + x_coord-1, y, 1, 2)
self.contents.fill_rect(rect, Color.new(red, green, blue, 255))
end
end
end
def draw_hp_bar(x, y, length, actor_hp, actor_maxhp)
gradient_red_start = 80
gradient_red_end = 80
gradient_green_start = 150
gradient_green_end = 150
gradient_blue_start = 255
gradient_blue_end = 255
draw_bar_percent = (100*actor_hp)/actor_maxhp#[your equation here]
for x_coord in 1..length
current_percent_done = x_coord * 100 / length
difference = gradient_red_end - gradient_red_start
red = gradient_red_start + difference * x_coord / length
difference = gradient_green_end - gradient_green_start
green = gradient_green_start + difference * x_coord / length
difference = gradient_blue_end - gradient_blue_start
blue = gradient_blue_start + difference * x_coord / length
if current_percent_done <= draw_bar_percent
rect = Rect.new(x + x_coord-1, y, 1, 2)
self.contents.fill_rect(rect, Color.new(red, green, blue, 255))
end
end
end
def draw_mp_bar(x, y, length, actor)
gradient_red_start = 200
gradient_red_end = 200
gradient_green_start = 150
gradient_green_end = 150
gradient_blue_start = 80
gradient_blue_end = 80
draw_bar_percent = (100*actor.sp)/actor.maxsp#[your equation here]
for x_coord in 1..length
current_percent_done = x_coord * 100 / length
difference = gradient_red_end - gradient_red_start
red = gradient_red_start + difference * x_coord / length
difference = gradient_green_end - gradient_green_start
green = gradient_green_start + difference * x_coord / length
difference = gradient_blue_end - gradient_blue_start
blue = gradient_blue_start + difference * x_coord / length
if current_percent_done <= draw_bar_percent
rect = Rect.new(x + x_coord-1, y, 1, 2)
self.contents.fill_rect(rect, Color.new(red, green, blue, 255))
end
end
end
def memo_radiant_bar(length)
gradient_red_start = 80
gradient_red_end = 255
gradient_green_start = 150
gradient_green_end = 255
gradient_blue_start = 255
gradient_blue_end = 255
draw_bar_percent = 100
$r_red = []
$r_green = []
$r_blue = []
l_off = ((length/2)-1)
for x_coord in 1..l_off
difference = gradient_red_end - gradient_red_start
$r_red[x_coord] = gradient_red_start + difference * x_coord / l_off
difference = gradient_green_end - gradient_green_start
$r_green[x_coord] = gradient_green_start + difference * x_coord / l_off
difference = gradient_blue_end - gradient_blue_start
$r_blue[x_coord] = gradient_blue_start + difference * x_coord / l_off
end
#aggiungo un po' di bianco
for x_coord in 1..2
x_off = x_coord + l_off
$r_red[x_off] = 255
$r_green[x_off] = 255
$r_blue[x_off] = 255
end
gradient_red_start = 255
gradient_red_end = 80
gradient_green_start = 255
gradient_green_end = 150
gradient_blue_start = 255
gradient_blue_end = 255
draw_bar_percent = 100
l_off = length - (l_off + 2)
l_back = l_off + 2
l_off = length - l_back
for x_coord in 1..l_off
x_off = x_coord + l_back
difference = gradient_red_end - gradient_red_start
$r_red[x_off] = gradient_red_start + difference * x_coord / l_off
difference = gradient_green_end - gradient_green_start
$r_green[x_off] = gradient_green_start + difference * x_coord / l_off
difference = gradient_blue_end - gradient_blue_start
$r_blue[x_off] = gradient_blue_start + difference * x_coord / l_off
end
end
def draw_radiant_bar(x, y, length, actor_hp, actor_maxhp, offset)
draw_bar_percent = (100*actor_hp)/actor_maxhp#[your equation here]
for x_coord in 1..length
current_percent_done = x_coord * 100 / length
if current_percent_done <= draw_bar_percent
rect = Rect.new(x + x_coord-1, y, 1, 2)
x_off = (x_coord + offset) % length
red = $r_red[x_off + 1]
green = $r_green[x_off + 1]
blue = $r_blue[x_off + 1]
self.contents.fill_rect(rect, Color.new(red, green, blue, 255))
end
end
end
# sp radiant #####################
def memo_radiant_bar_mp(length)
gradient_red_start = 255
gradient_red_end = 200
gradient_green_start = 255
gradient_green_end = 150
gradient_blue_start = 255
gradient_blue_end = 80
draw_bar_percent = 100
$rm_red = []
$rm_green = []
$rm_blue = []
l_off = ((length/2)-1)
for x_coord in 1..l_off
difference = gradient_red_end - gradient_red_start
$rm_red[x_coord] = gradient_red_start + difference * x_coord / l_off
difference = gradient_green_end - gradient_green_start
$rm_green[x_coord] = gradient_green_start + difference * x_coord / l_off
difference = gradient_blue_end - gradient_blue_start
$rm_blue[x_coord] = gradient_blue_start + difference * x_coord / l_off
end
#aggiungo un po' di arancione
for x_coord in 1..2
x_off = x_coord + l_off
$rm_red[x_off] = 200
$rm_green[x_off] = 150
$rm_blue[x_off] = 80
end
gradient_red_start = 200
gradient_red_end = 255
gradient_green_start = 150
gradient_green_end = 255
gradient_blue_start = 80
gradient_blue_end = 255
draw_bar_percent = 100
l_off = length - (l_off + 2)
l_back = l_off + 2
l_off = length - l_back
for x_coord in 1..l_off
x_off = x_coord + l_back
difference = gradient_red_end - gradient_red_start
$rm_red[x_off] = gradient_red_start + difference * x_coord / l_off
difference = gradient_green_end - gradient_green_start
$rm_green[x_off] = gradient_green_start + difference * x_coord / l_off
difference = gradient_blue_end - gradient_blue_start
$rm_blue[x_off] = gradient_blue_start + difference * x_coord / l_off
end
end
def draw_radiant_bar_mp(x, y, length, actor_sp, actor_maxsp, offset)
draw_bar_percent = (100*actor_sp)/actor_maxsp#[your equation here]
for x_coord in 1..length
current_percent_done = x_coord * 100 / length
if current_percent_done <= draw_bar_percent
rect = Rect.new(x + x_coord-1, y, 1, 2)
x_off = (x_coord + offset) % length
red = $rm_red[x_off + 1]
green = $rm_green[x_off + 1]
blue = $rm_blue[x_off + 1]
self.contents.fill_rect(rect, Color.new(red, green, blue, 255))
end
end
end
end
#==============================================================================
# - Window_Selectable
#------------------------------------------------------------------------------
# E' la classe delle finestre con movimento del cursore o con funzione di
# scorrimento
#==============================================================================
class Window_Selectable_New < Window_Base
#--------------------------------------------------------------------------
# - Apri una variabile istanza
#--------------------------------------------------------------------------
attr_reader :index # Posizione del cursore
attr_reader :help_window # Finestra di aiuto
#--------------------------------------------------------------------------
# - Inizializzazione dell'oggetto
# x : Coordinate X della finestra
# y : Coordinate Y della finestra
# width : Larghezza della finestra
# height : Altezza della finestra
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
self.z = 5000
@item_max = 1
@column_max = 1
@index = -1
@cursore = Arrow_Menu.new
@cursore.x = (@column_max * 20) + x
@cursore.y = (@column_max * 20 - self.oy) + y + 10
end
#--------------------------------------------------------------------------
# - Sistemazione della posizione del cursore
# index : Nuova posizione del cursore
#--------------------------------------------------------------------------
def index=(index)
@index = index
# Viene aggiornato il testo di aiuto
# (update_help viene definito dal posto successivo)
if self.active and @help_window != nil
update_help
end
# Viene aggiornato il rettangolo del cursore
update_cursor_rect
end
#--------------------------------------------------------------------------
# - Acquisizione del numero di linee
#--------------------------------------------------------------------------
def row_max
# Il numero di linee viene elaborato dal numero di oggetti e il numero
# delle sequenze
return (@item_max + @column_max - 1) / @column_max
end
#--------------------------------------------------------------------------
# - Acquisizione di una linea superiore
#--------------------------------------------------------------------------
def top_row
# Origine di trasmissione dei contenuti di una finestra:
# Sulle coordinate Y, l'altezza di una linea viene divisa per 32
return self.oy / 20
end
#--------------------------------------------------------------------------
# - Sistemazione di una linea superiore
# row : La linea viene mostrata in cima
#--------------------------------------------------------------------------
def top_row=(row)
# Quando row è minore di zero, allora correggi ed inserisci 0
if row < 0
row = 0
end
# Quando row è maggiore di row_max - 1, poni row = row_max - 1
if row > row_max - 1
row = row_max - 1
end
# row Altezza di una linea. è l'origine di trasmissione dei contenuti
# di una finestra. Si considera come coordinata Y
self.oy = row * 20
end
#--------------------------------------------------------------------------
# - 1 Acquisizione del numero di linee che possono essere mostrate
# su una pagina
#--------------------------------------------------------------------------
def page_row_max
# Altezza della finestra del frame. Si sottrare 32 all'altezza di
# una linea e si divide per 32
return (self.height - 32) / 20
end
#--------------------------------------------------------------------------
# - 1 Acquisizione del numero di oggetti che possono essere mostrati
# su una pagina
#--------------------------------------------------------------------------
def page_item_max
# Numero di linee, page_row_max il numero di sequenze per
# le colonne @column_max
return page_row_max * @column_max
end
#--------------------------------------------------------------------------
# - Sistemazione della finestra di aiuto
# help_window : Nuova finestra di aiuto
#--------------------------------------------------------------------------
def help_window=(help_window)
@help_window = help_window
# Il testo di aiuto viene aggiornato
# (update_help viene definito dal posto successivo)
if self.active and @help_window != nil
update_help
end
end
#-------------------------------------------
#
#-------------------------------------------
def visible=(visible)
update_cursor_rect
if visible
@cursore.visible = true
@cursore.opacity = 255
self.opacity = 200
self.contents_opacity = 255
else
@cursore.visible = false
@cursore.opacity = 0
self.opacity = 0
self.contents_opacity = 0
end
end
#--------------------------------------------------------------------------
# - Aggiornamento del rettangolo del cursore
#--------------------------------------------------------------------------
def update_cursor_rect
# Posizione del cursore. Quando è minore di 0...
if @index < 0
@cursore.visible = false
@cursore.opacity = 0#self.cursor_rect.empty
return
end
# La linea corrente viene acquisita
row = @index / @column_max
# Nel caso di prima, la linea corrente viene mostrata in cima
if row < self.top_row
# Scorre in modo tale che la linea corrente vada in cima
self.top_row = row
end
# Nel caso precedente, la linea corrente viene mostrata fino alla
# fine della coda
if row > self.top_row + (self.page_row_max - 1)
# Scorre in modo tale che la linea corrente vada in coda
self.top_row = row - (self.page_row_max - 1)
end
# Viene calcolata l'ampiezza del cursore
#cursor_width = self.width / @column_max - 32
# Vengono calcolate le coordinate del cursore
pos_x = (@index % @column_max * 20) + self.x#(cursor_width + 32)
pos_y = (@index / @column_max * 20 - self.oy) + self.y + 10#+ 16
if @cursore.x != pos_x or @cursore.y != pos_y
@cursore.stop_move
@cursore.move(4, pos_x, pos_y, 255)
end
# Viene aggiornato il rettangolo del cursore
#self.cursor_rect.set(x, y, cursor_width, 32)
end
#--------------------------------------------------------------------------
# - Aggiornamento frame
#--------------------------------------------------------------------------
def update
super
# Quando è nello stato in cui si muove il cursore...
if self.active and @item_max > 0 and @index >= 0
# Quando il pulsante viene premuto nella direzione bassa...
if Input.repeat?(Input::DOWN)
# Numero di squenze: 1 nel caso in cui non viene ripetuta su una
# direzione del pulsante
# Nel caso precedente, la posizione del cursore viene data da:
# (Numero di sequenze - Numero degli oggetti)
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
# Il cursore viene mosso in basso
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
# Aggiornamento del rettangolo del cursore
update_cursor_rect
end
end
# Quando il pulsante viene premuto nella direzione alta...
if Input.repeat?(Input::UP)
# Numero di squenze: 1 nel caso in cui non viene ripetuta su una
# direzione del pulsante
# Nel caso precedente, la posizione del cursore viene data dal
# numero di sequenze
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max
# Il cursore viene mosso verso l'alto
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
# Aggiornamento del rettangolo del cursore
update_cursor_rect
end
end
# Quando il pulsante viene premuto nella direzione di destra...
if Input.repeat?(Input::RIGHT)
# Numero di sequenze >= 2 e @index < (numero di oggetti - 1) quando la
# posizione del cursore...
if @column_max >= 2 and @index < @item_max - 1
# ...viene mossa verso destra
$game_system.se_play($data_system.cursor_se)
@index += 1
# Aggiornamento del rettangolo del cursore
update_cursor_rect
end
end
# Quando il pulsante viene premuto nella direzione di sinistra...
if Input.repeat?(Input::LEFT)
# Numero di sequenze >= 2 e @index > 0 quando la posizione
# del cursore...
if @column_max >= 2 and @index > 0
# ...viene mossa verso sinistra
$game_system.se_play($data_system.cursor_se)
@index -= 1
# Aggiornamento del rettangolo del cursore
update_cursor_rect
end
end
# Quando il pulsante R viene premuto...
if Input.repeat?(Input::R)
# Prima dell'ultima linea sui dati, viene mostrata la linea fino
# alla fine della coda
if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
# Il cursore si muove avanti di una pagina
$game_system.se_play($data_system.cursor_se)
@index = [@index + self.page_item_max, @item_max - 1].min
self.top_row += self.page_row_max
# Aggiornamento del rettangolo del cursore
update_cursor_rect
end
end
# Quando il pulsante L viene premuto...
if Input.repeat?(Input::L)
# La linea correntemente mostrata in cima, se > 0...
if self.top_row > 0
# Il cursore si muove indietro di una pagina
$game_system.se_play($data_system.cursor_se)
@index = [@index - self.page_item_max, 0].max
self.top_row -= self.page_row_max
# Aggiornamento del rettangolo del cursore
update_cursor_rect
end
end
end
# Viene aggiornato il testo di aiuto
# (update_help viene definito dal posto successivo)
if self.active and @help_window != nil
update_help
end
@cursore.update
end
end
#==============================================================================
# - Window_Command
#------------------------------------------------------------------------------
# E' la finestra che compie la selezione del comando generale
#==============================================================================
class Window_Command_New < Window_Selectable_New
#--------------------------------------------------------------------------
# - Inizializzazione dell'oggetto
# width : Larghezza della finestra
# commands : Sistemazione di una sequenza di comandi del personaggio
#--------------------------------------------------------------------------
def initialize(width, commands, color = Color.new(255, 255, 255, 255))
# L'altezza di una finestra è calcolata dal numero di un comando
super(0, 0, width, commands.size * 20 + 32)
@item_max = commands.size
@commands = commands
@color = color
self.contents = Bitmap.new(width - 32, @item_max * 20)
refresh
self.index = 0
end
def reinitialize(width, commands, color = Color.new(255, 255, 255, 255))
# L'altezza di una finestra è calcolata dal numero di un comando
self.width = width
self.height = commands.size * 20 + 32
@item_max = commands.size
@commands = commands
@color = color
self.contents = Bitmap.new(width - 32, @item_max * 20)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# - Aggiornamento
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, @color)
end
end
#--------------------------------------------------------------------------
# - Disegna un oggetto
# index : Numero dell'oggetto
# color : Colore del personaggio
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
self.contents.font.name = "Comic Sans MS"
self.contents.font.size = 20
self.contents.draw_text_bordered(20, 20 * index - 5, self.contents.width - 8, 24, @commands[index], 0, color)
#rect = Rect.new(30, 24 * index, self.contents.width - 8, 24)
#self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
#self.contents.draw_text_bordered(rect, @commands[index])
end
#--------------------------------------------------------------------------
# - Cancellazione di un oggetto
# index : Numero dell'oggetto
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# - Processo di terminazionde del messaggio
#--------------------------------------------------------------------------
def terminate_message
self.active = false
self.pause = false
self.index = -1
self.contents.clear
@contents_showing = false
if $game_temp.message_proc != nil
$game_temp.message_proc.call
end
$game_temp.message_text = nil
$game_temp.message_proc = nil
$game_temp.choice_start = 99
$game_temp.choice_max = 0
$game_temp.choice_cancel_type = 0
$game_temp.choice_proc = nil
$game_temp.num_input_start = 99
$game_temp.num_input_variable_id = 0
$game_temp.num_input_digits_max = 0
$game_temp.battle_menu_closed = true
if @gold_window != nil
@gold_window.dispose
@gold_window = nil
end
end
end
#==============================================================================
# - Window_BattleStatus
#------------------------------------------------------------------------------
# E' la finestra che mostra lo stato dei membri del gruppo sulla
# schermata di battaglia
#==============================================================================
class Window_Target_Stat < Window_Base
#--------------------------------------------------------------------------
# - Inizializzazione dell'oggetto
#--------------------------------------------------------------------------
def initialize
super(0, 0, 200, 100)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
self.opacity = 180
@level_up_flags = [false, false, false, false]
end
#--------------------------------------------------------------------------
# - Rilascia
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# - Sistemazione del miglioramento dei flags
# actor_index : アクターインデックス
#--------------------------------------------------------------------------
def level_up(actor_index)
@level_up_flags[actor_index] = true
end
#--------------------------------------------------------------------------
# - Aggiornamento
#--------------------------------------------------------------------------
def refresh(event_id)
self.contents.clear
@item_max = $game_troop.enemies.size
enemy_id = $game_troop.che_nemico?(event_id)
actor = $game_troop.enemies[enemy_id]
draw_target_name(actor, 0, 0)
draw_target_hp(actor, 0, 25)
end
#--------------------------------------------------------------------------
# - Aggiornamento frame
#--------------------------------------------------------------------------
def update
super
# L'opacità è abbastanza bassa durante la fase principale
if $game_temp.battle_main_phase
self.contents_opacity -= 4 if self.contents_opacity > 191
else
self.contents_opacity += 4 if self.contents_opacity < 255
end
end
end
class Window_Barre < Window_Base
#--------------------------------------------------------------------------
# - Inizializzazione dell'oggetto
#--------------------------------------------------------------------------
def initialize
super(160, 380, 480, 160)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
self.opacity = 0
@level_up_flags = [false, false, false, false]
@offset = 0
@offset_mp = 0
memo_radiant_bar(84)
memo_radiant_bar_mp(50)
refresh
end
#--------------------------------------------------------------------------
# - Rilascia
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# - Sistemazione del miglioramento dei flags
# actor_index : アクターインデックス
#--------------------------------------------------------------------------
def level_up(actor_index)
@level_up_flags[actor_index] = true
end
#--------------------------------------------------------------------------
# - Aggiornamento
#--------------------------------------------------------------------------
def refresh
self.contents.clear
tot_party = [$game_party.actors.size, 3].min
@offset = (@offset % 84) + 1
@offset_mp = (@offset_mp % 50) + 1
for i in 0...tot_party
actor = $game_party.actors[i]
actor_y = i * 22 + (3-tot_party)*22
draw_radiant_bar(260, actor_y+24, 84, actor.hp, actor.maxhp, @offset)
draw_radiant_bar_mp(350+15, actor_y+24, 50, actor.sp, actor.maxsp, @offset_mp)
end
end
#--------------------------------------------------------------------------
# - Aggiornamento frame
#--------------------------------------------------------------------------
def update
super
end
end
#==============================================================================
# - Window_BattleStatus
#------------------------------------------------------------------------------
# E' la finestra che mostra lo stato dei membri del gruppo sulla
# schermata di battaglia
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# - Inizializzazione dell'oggetto
#--------------------------------------------------------------------------
def initialize
super(160, 380, 480, 160)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
self.opacity = 0
@level_up_flags = [false, false, false, false]
refresh
end
#--------------------------------------------------------------------------
# - Rilascia
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# - Sistemazione del miglioramento dei flags
# actor_index : アクターインデックス
#--------------------------------------------------------------------------
def level_up(actor_index)
@level_up_flags[actor_index] = true
end
#--------------------------------------------------------------------------
# - Aggiornamento
#--------------------------------------------------------------------------
def refresh
self.contents.clear
tot_party = [$game_party.actors.size, 3].min
for i in 0...tot_party
actor = $game_party.actors[i]
actor_y = i * 22 + (3-tot_party)*22
draw_target_name(actor, 170, actor_y)
draw_player_hp(actor.hp, actor.maxhp, 260, actor_y)
draw_player_sp(actor, 350, actor_y)
end
$game_temp.party_change_flag = false
end
def refresh_bar
self.contents.clear
end
#--------------------------------------------------------------------------
# - Aggiornamento frame
#--------------------------------------------------------------------------
def update
super
end
end
#==============================================================================
# - Arrow_Menu
#------------------------------------------------------------------------------
# E' lo sprite del cursore usato nei menu
#==============================================================================
class Arrow_Menu < Sprite
#--------------------------------------------------------------------------
# - Variabile
#--------------------------------------------------------------------------
attr_reader :index # Indice
attr_reader :help_window # Finestra d'aiuto
#--------------------------------------------------------------------------
# - Inizializzazione
# viewport : Livello
#--------------------------------------------------------------------------
def initialize
super
self.bitmap = RPG::Cache.icon("HandCursor.png")
self.z = 5000
self.opacity = 0
@move_count = 0
@index = 0
@duration = 0
@help_window = nil
update
end
#--------------------------------------------------------------------------
# - Settaggio della posizione
# index : Nuovo Indice
#--------------------------------------------------------------------------
def index=(index)
@index = index
update
end
#--------------------------------------------------------------------------
# - Settaggio della finestra d'aiuto
# help_window : Nuova Finestra d'aiuto
#--------------------------------------------------------------------------
def help_window=(help_window)
@help_window = help_window
# Aggiornamento (update_help e' definito nella sottoclasse)
if @help_window != nil
update_help
end
end
def stop_move
@move_count = 0
end
def move(duration, x, y, opacity)
@duration = duration
@target_x = x.to_f
@target_y = y.to_f
@target_opacity = opacity.to_f
end
def duration
return @duration
end
#--------------------------------------------------------------------------
# - Aggiornamento
#--------------------------------------------------------------------------
def update
# Rinnovamento Posizione
@move_count = (@move_count + 1) % 40
if @move_count == 5
move(4, self.x + 8, self.y, 255)
elsif @move_count == 10
move(4, self.x - 8, self.y, 255)
end
if @duration >= 1
d = @duration
if self.x != @target_x
self.x = (self.x * (d - 1) + @target_x) / d
end
if self.y != @target_y
self.y = (self.y * (d - 1) + @target_y) / d
end
if self.opacity != @target_opacity
self.opacity = (self.opacity * (d - 1) + @target_opacity) / d
end
@duration -= 1
end
# Aggiornamento (update_help e' definito nella sottoclasse)
if @help_window != nil
update_help
end
end
end
class Interpreter
# Modifica al cambia grafica
# per non far crashare il caterpillar script
def command_322
actor = $game_actors[@parameters[0]]
if actor != nil
actor.set_graphic(@parameters[1], @parameters[2],
@parameters[3], @parameters[4])
end
$game_temp.party_change_flag = true
$game_player.refresh
# Parte aggiunta
$game_second_player.refresh
$game_third_player.refresh
return true
end
end
class Scene_Title
def command_new_game
# Suona SE azione
$game_system.se_play($data_system.decision_se)
# Ferma BGM
Audio.bgm_stop
# Resetta il contatore frame per il tempo di gioco
Graphics.frame_count = 0
# Creazione oggetti
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
$game_second_player = Game_Party_Player.new(1)
$game_third_player = Game_Party_Player.new(2)
# Creazione Gruppo
$game_party.setup_starting_members
# Creazione Mappa
$game_map.setup($data_system.start_map_id)
# Trasferimento al punto d'inizio
d_x = $data_system.start_x
d_y = $data_system.start_y
$game_player.moveto(d_x, d_y)
$game_second_player.moveto(d_x + 1, d_y - 1)
$game_third_player.moveto(d_x - 1, d_y - 1)
# Aggiornamento Giocatore
$game_player.refresh
if $game_party.actors[1] != nil
$game_second_player.refresh
end
if $game_party.actors[2] != nil
$game_third_player.refresh
end
# Suona BGM e BGS automatici
$game_map.autoplay
# Aggiornamento Mappa
$game_map.update
# Cambia Scena
$scene = Scene_Map.new
end
end
class Scene_Map
#--------------------------------------------------------------------------
# - Processo Principale
#--------------------------------------------------------------------------
def main
# Fase
@phase = 0
@elenco = []
@attacking = [false]
@curs = Arrow_Menu.new
@curs.z = 4000
@curs.visible = false
@curs.opacity = 0
# Settaggio Spriteset
@spriteset = Spriteset_Map.new
# Settaggio della finestra dei messaggi
@message_window = Window_Message.new
# Settaggio finestra status personaggi
@battle_pg = Window_BattleStatus.new
@battle_pg.visible = true
# Settaggio finestra comandi
@battle_menu = Window_Command_New.new(200, ["Attacca", "Magie/Tecniche", "Mystes", "Gambit", "Oggetti"])
@battle_menu.x = 16
@battle_menu.y = 480 - @battle_menu.height - 16
#@battle_menu.index = -1
@battle_menu.visible = false
@battle_menu.active = false
# Settaggio finestra delle barre hp/sp
@barre = Window_Barre.new
@target_stat = Window_Target_Stat.new
@target_stat.visible = false
# Fade
Graphics.transition
# Loop Principale
loop do
# Aggiornamento Grafica
Graphics.update
# Aggiornamento Input
Input.update
# Aggiornamento Frame
update
# Quando cambia la scena blocca il loop
if $scene != self
break
end
end
# Preparazione Fade
Graphics.freeze
# Eliminazione chipaset
@spriteset.dispose
# Eliminazione finestra dei messaggi
@message_window.dispose
# Eliminazione Status Personaggi
@battle_pg.dispose
# Eliminazione menu di battaglia
@battle_menu.dispose
# Se la scena è il title
if $scene.is_a?(Scene_Title)
# Blocca la grafica
Graphics.transition
Graphics.freeze
end
end
#--------------------------------------------------------------------------
# - Gestione Aggiornamento
#--------------------------------------------------------------------------
def update
case @phase
when 0
update_base
when 1
update_battle_menu
@battle_menu.update
when 2
update_magie_tecniche
@battle_menu.update
when 3
update_selezione_bersaglio
@battle_menu.update
@curs.update
end
end
#--------------------------------------------------------------------------
# - Aggiornamento Base
#--------------------------------------------------------------------------
def update_base
# Loop
loop do
# Aggiornamento mappa ed interprete
$game_map.update
$game_system.map_interpreter.update
$game_player.update
$game_second_player.update
$game_third_player.update
# Aggiornamento sistema e schermo
$game_system.update
$game_screen.update
# Quando il giocatore non deve essere trasportato esce dal loop
unless $game_temp.player_transferring
break
end
# Trasporta il giocatore
transfer_player
# Quando non c'è un fade esce dal loop
if $game_temp.transition_processing
break
end
end
# Aggiornamento Chipset
@spriteset.update
# Aggiornamento finestra dei messaggi
@message_window.update
# Aggiorna lo status dei personaggi
if $game_temp.party_change_flag
@battle_pg.refresh
end
@barre.refresh
# Se c'è il gameover
if $game_temp.gameover
# Va alla scena del gameover
$scene = Scene_Gameover.new
return
end
# Se si deve tornare al title
if $game_temp.to_title
# Va alla scena del title
$scene = Scene_Title.new
return
end
# Quando c'è un fade
if $game_temp.transition_processing
# Elimina la variabile
$game_temp.transition_processing = false
# Fade
if $game_temp.transition_name == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$game_temp.transition_name)
end
end
# Quando c'è un messaggio
if $game_temp.message_window_showing
return
end
# Quando il contatore degli incontri è 0 e ci sono gruppi di mostri in lista
if $game_player.encounter_count == 0 and $game_map.encounter_list != []
# Quando non c'è un evento o gli incontri non sono disabilitati
unless $game_system.map_interpreter.running? or
$game_system.encounter_disabled
# Scelta del gruppo di nemici
n = rand($game_map.encounter_list.size)
troop_id = $game_map.encounter_list[n]
# Se il gruppo è valido
if $data_troops[troop_id] != nil
# Chiama la battaglia
$game_temp.battle_calling = true
$game_temp.battle_troop_id = troop_id
$game_temp.battle_can_escape = true
$game_temp.battle_can_lose = false
$game_temp.battle_proc = nil
end
end
end
#Quando B è premuto
if Input.trigger?(Input::B)
# Quando non c'è un evento o il menu non è disabilitato
unless $game_system.map_interpreter.running? or
$game_system.menu_disabled
# Chiama menu
$game_temp.menu_calling = true
$game_temp.menu_beep = true
end
end
# Quando è stato attivato il menu di battaglia
if $game_temp.battle_menu_closed == false
# Quando non c'è un evento o il menu non è disabilitato
unless $game_system.map_interpreter.running? or
$game_system.menu_disabled
# Vai al battle menu
$game_system.se_play($data_system.decision_se)
@battle_menu.reinitialize(200, ["Attacca", "Magie/Tecniche", "Mystes", "Gambit", "Oggetti"])
@battle_menu.y = 480 - @battle_menu.height - 16
@battle_menu.visible = true
@battle_menu.active = true
@battle_menu.index = 0
@phase = 1
end
end
# Quando è attivo il debug e si preme F9
if $DEBUG and Input.press?(Input::F9)
# Chiama il debug
$game_temp.debug_calling = true
end
# Quando il giocatore non si è mosso
unless $game_player.moving?
# Controlla se c'è quancosa da chiamare
if $game_temp.battle_calling
call_battle
elsif $game_temp.shop_calling
call_shop
elsif $game_temp.name_calling
call_name
elsif $game_temp.menu_calling
call_menu
elsif $game_temp.save_calling
call_save
elsif $game_temp.debug_calling
call_debug
end
end
end
#--------------------------------------------------------------------------
# - Aggiornamento Menu di Battaglia
#--------------------------------------------------------------------------
def update_battle_menu
# Quando B è premuto
if Input.trigger?(Input::B)
# Suona SE Annulla
$game_system.se_play($data_system.cancel_se)
# Chiudi il menu
@battle_menu.active = false
@battle_menu.visible = false
$game_temp.battle_menu_closed = true
@phase = 0
end
# Quando C è premuto
if Input.trigger?(Input::C)
# Scelta del comando da eseguire
case @battle_menu.index
when 0 # Attacca
# Suona SE Azione
$game_system.se_play($data_system.decision_se)
# Vai al menu Magie/Tecniche
@elenco = []
elenco_nomi = []
for i in $game_map.events.values
if i.nemico? and i.in_chara_range?(5)
@elenco.push(i)
id_nemico = i.name.to_i
elenco_nomi.push($data_enemies[id_nemico].name)
end
end
if @elenco.empty?
text = "Nessun bersaglio rilevato"
@battle_menu.reinitialize(250, [text], Color.new(255, 100, 100, 255))
else
@battle_menu.reinitialize(200, elenco_nomi)
@curs.x = @elenco[@battle_menu.index].real_x / 4 - 25
@curs.y = @elenco[@battle_menu.index].real_y / 4
@curs.visible = true
@curs.opacity = 255
event_id = @elenco[@battle_menu.index].id
@target_stat.refresh(event_id)
@target_stat.visible = true
end
@battle_menu.y = 480 - @battle_menu.height - 16
@battle_menu.index = 0
@phase = 3
when 1 # Magie/Tecniche
# Suona SE Azione
$game_system.se_play($data_system.decision_se)
# Vai al menu Magie/Tecniche
@battle_menu.reinitialize(200, ["Bianca", "Nera"])
@battle_menu.y = 480 - @battle_menu.height - 16
@battle_menu.index = 0
@phase = 2
when 2
end
end
end
#--------------------------------------------------------------------------
# - Aggiornamento Magie/Tecniche
#--------------------------------------------------------------------------
def update_magie_tecniche
# Quando B è premuto
if Input.trigger?(Input::B)
# Suona SE Annulla
$game_system.se_play($data_system.cancel_se)
# Vai al menu di battaglia
@battle_menu.reinitialize(200, ["Attacca", "Magie/Tecniche", "Mystes", "Gambit", "Oggetti"])
@battle_menu.y = 480 - @battle_menu.height - 16
@battle_menu.index = 0
@phase = 1
end
# Quando C è premuto
if Input.trigger?(Input::C)
# Scelta del comando da eseguire
#case @battle_menu.index
#when 1 # Magie/Tecniche
# Suona SE Azione
$game_system.se_play($data_system.decision_se)
# Chiudi il menu
@battle_menu.active = false
@battle_menu.visible = false
$game_temp.battle_menu_closed = true
@phase = 0
#end
end
end
#--------------------------------------------------------------------------
# - Aggiornamento Selezione Bersaglio
#--------------------------------------------------------------------------
def update_selezione_bersaglio
unless @elenco.empty?
pos_x = @elenco[@battle_menu.index].real_x / 4 -25
pos_y = @elenco[@battle_menu.index].real_y / 4
pos_x = pos_x - ($game_map.display_x / 4)
pos_y = pos_y - ($game_map.display_y / 4)
event_id = @elenco[@battle_menu.index].id
@curs.stop_move
if (@curs.x != pos_x or @curs.y != pos_y) and @curs.duration == 0
@curs.stop_move
@curs.move(4, pos_x, pos_y, 255)
@target_stat.refresh(event_id)
end
end
# Quando B è premuto
if Input.trigger?(Input::B)
# Suona SE Annulla
$game_system.se_play($data_system.cancel_se)
# Vai al menu di battaglia
@battle_menu.reinitialize(200, ["Attacca", "Magie/Tecniche", "Mystes", "Gambit", "Oggetti"])
@battle_menu.y = 480 - @battle_menu.height - 16
@battle_menu.index = 0
@curs.visible = false
@target_stat.visible = false
@phase = 1
end
# Quando C è premuto
if Input.trigger?(Input::C)
unless @elenco.empty?
@elenco[@battle_menu.index].animation_id = 7
enemy_id = $game_troop.che_nemico?(event_id)
$game_troop.enemies[enemy_id].hp -= 300
if $game_troop.enemies[enemy_id].dead?
Audio.se_play("Audio/SE/145-Support03.ogg", 80, 100)
@elenco[@battle_menu.index].animation_id = 96
@elenco[@battle_menu.index].death
end
@curs.visible = false
@battle_menu.active = false
@battle_menu.visible = false
@target_stat.visible = false
$game_temp.battle_menu_closed = true
@phase = 0
else
$game_system.se_play($data_system.buzzer_se)
end
end
end
end
class Scene_Map
#--------------------------------------------------------------------------
# - Trasporto
#--------------------------------------------------------------------------
def transfer_player
# Elimina la variable
$game_temp.player_transferring = false
# Quando la mappa di destinazione è diversa da quella corrente
if $game_map.map_id != $game_temp.player_new_map_id
# Settaggio nuova mappa
$game_map.setup($game_temp.player_new_map_id)
end
# Settaggio nuova posizione del giocatore
$game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
$game_second_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
$game_third_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
# Settaggio della nuova direzione
case $game_temp.player_new_direction
when 2 # Giu
$game_player.turn_down
when 4 # Sinistra
$game_player.turn_left
when 6 # Destra
$game_player.turn_right
when 8 # Sù
$game_player.turn_up
end
# Correzione posizione del giocatore
$game_player.straighten
# Aggiornamento Mappa
$game_map.update
# Creazione nuovo spriteset
@spriteset.dispose
@spriteset = Spriteset_Map.new
# Quando c'è un fade
if $game_temp.transition_processing
# Elimina la variabile
$game_temp.transition_processing = false
# Fade
Graphics.transition(20)
end
# Suona BGM e BGS automatici della mappa
$game_map.autoplay
# Resetta il frame
Graphics.frame_reset
# Aggiornamento Input
Input.update
end
end
###################
############ XPML Definition ###############
# by Rataime #
###################
def XPML_read(markup,event_id,max_param_number=0)
parameter_list = nil
event=$game_map.events[event_id]
return if event.list==nil
for i in 0...event.list.size
if event.list[i].code == 108 and event.list[i].parameters[0].downcase == "begin "+markup.downcase
parameter_list = [] if parameter_list == nil
for j in i+1...event.list.size
if event.list[j].code == 108
parts = event.list[j].parameters[0].split
if parts.size!=1 and parts[0].downcase!="begin"
if parts[1].to_i!=0 or parts[1]=="0"
parameter_list.push(parts[1].to_i)
else
parameter_list.push(parts[1])
end
else
return parameter_list
end
else
return parameter_list
end
return parameter_list if max_param_number!=0 and j==i+max_param_number
end
end
end
return parameter_list
end
class Bitmap
def draw_text_bordered(x, y, width, height, text, align = 0, color = Color.new(255, 255, 255, 255))
font.color.set(0, 0, 0, 100)
draw_text(x-1, y-1, width, height, text, align)
draw_text(x-1, y+1, width, height, text, align)
draw_text(x+1, y-1, width, height, text, align)
draw_text(x+1, y+1, width, height, text, align)
draw_text(x-1, y, width, height, text, align)
draw_text(x+1, y, width, height, text, align)
draw_text(x, y-1, width, height, text, align)
draw_text(x, y+1, width, height, text, align)
font.color = color
draw_text(x, y, width, height, text, align)
end
def draw_text_shadowed(x, y, width, height, text, align = 1, color = Color.new(255, 255, 255, 255))
font.color.set(100, 100, 100)
draw_text(x+1, y+2, width, height, text, align)
draw_text(x+2, y+1, width, height, text, align)
draw_text(x+2, y+2, width, height, text, align)
font.color.set(0, 0, 0)
draw_text(x-1, y-1, width, height, text, align)
draw_text(x-1, y+1, width, height, text, align)
draw_text(x+1, y-1, width, height, text, align)
draw_text(x+1, y+1, width, height, text, align)
font.color = color
draw_text(x, y, width, height, text, align)
end
end
Question
Alato
Allora...visto che il sistema di battaglia di FFXII, e il suo sistema in generale mi è piaciuto molto, ho deciso di mettermi di buona lena e fare uno script che implementi tutto ciò che è presente nel gioco, dal bs al menu, al sistema in generale.
Ho deciso di postare mano a mano gli aggiornamenti di ciò che sto facendo nella speranza che qualcuno possa apprendere meglio l'RGSS chiedendo spiegazioni sul suo funzionamento, e anche per sentirmi un po' spronato a continuare il lavoro senza mollarlo a metà. ;O;
Archivio aggiornamenti
Update 12/3/07
• Movimento casuale dei nemici
• I nemici notano il personaggio e gli vanno incontro se questo si avvicina troppo
• Menù di battaglia apribile su mappa premendo invio (se c'è un evento, il menù viene disabilitato)
• Il menù di battaglia utilizza un cursore che si muove realmente sullo schermo (insomma non si teletrasporta qua e là)
• Premendo Attacco comparirà un elenco con il nome dei nemici, in base al nome dell'evento, sempre che esistano eventi nemici in un raggio di 6 quadretti
Update 12/3/07
• Durante la selezione del nemico un cursore indicherà sulla mappa quale è il nemico selezionato (utile con molti nemici in campo)
• Corretti alcuni bug
Update 14/3/07
• Una finestra mostra gli hp del mostro, che sono presi dal database di default: basterà infatti creare l'evento inserendo come nome l'id del mostro che si vuole utilizzare
• Premendo attacco si colpisce il nemico e gli si riducono gli hp: azzerati gli hp il nemico muore. Se si entra e riesce dalla mappa il nemico ricompare.
Update 16/7/07
• Aggiunto un nuovo caterpillar script: i due membri del party successivi al principale sono ora presenti sulla mappa e seguono l'eroe in maniera molto più realistica rispetto ad altri caterpillar presenti sulla rete (funzionante ma da completare)
Update 17/07/07
• Migliorato il caterpillar: ora i personaggi non passano attraverso i muri e evitano la maggior parte degli ostacoli con la loro intelligenza artificiale (alcuni ostacoli complessi li fanno ancora impallare)
• Corretti alcuni bug del caterpillar (che si può dire ormai completato)
Ultimo aggiornamento: 05/06/08
• Aggiunto il battle status dei personaggi (cioè la barra con gli hp e gli mp)
• Le barre sono luminescenti ;O;
Ed ecco lo script:
Istruzioni
Incollate tutto ciò che è contenuto nel file *.txt in una pagina sopra il main.
Importate come Icon l'immagine HandCursor.png lasciando il nome invariato.
A questo punto lo script sarà già in funzione:
• per aprire il menù premere Invio
• per creare un evento Nemico basta creare un evento con grafica a vostra scelta e inserire come commento
A questo punto inserite al posto del nome dell'evento, l'id del mostro che volete (seguendo gli id del database).
Immagine e file *.txt sono allegati a seguire
Aggiungo comunque lo script in spoiler: è lungo.
L'ho dovuto dividere in più parti altrimenti lo spoiler impazziva.. o_
Non apritele insieme o implode XD
#================================# # - FFXII Development Kit V0.1 # #--------------------------------# # By Alato ~ www.rpg2s.net # #================================# class Game_Temp attr_accessor :battle_menu_closed attr_accessor :party_change_flag attr_accessor :hp_change_flag alias temp_initialize initialize def initialize temp_initialize @battle_menu_closed = true @party_change_flag = true @hp_change_flag = true end end class Game_Battler def hp=(hp) @hp = [[hp, maxhp].min, 0].max # Morte - Resurrezione for i in 1...$data_states.size if $data_states[i].zero_hp if self.dead? add_state(i) else remove_state(i) end end end end end class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # - Inizializzazione Oggetto # troop_id : ID Gruppo di menici # member_index : Indice del nemico #-------------------------------------------------------------------------- def initialize(troop, member_index) super() @member_index = member_index @enemy_id = troop[@member_index] enemy = $data_enemies[@enemy_id] @battler_name = enemy.battler_name @battler_hue = enemy.battler_hue @hp = maxhp @sp = maxsp #@hidden = troop[@member_index].hidden #@immortal = troop[@member_index].immortal end end class Game_Party # Modifiche per non fare crashare il gioco # quando non ci sono i compagni # (caterpillar script) #sostituiti totalmente add_actor e remove_actor #-------------------------------------------------------------------------- # - Aggiunta Eroe # actor_id : ID Eroe #-------------------------------------------------------------------------- def add_actor(actor_id) # Acquisizione Eroe actor = $game_actors[actor_id] # Quando ci sono meno di 4 eroi e l'eroe non è già nel gruppo if @actors.size < 4 and not @actors.include?(actor) # Aggiungi Eroe @actors.push(actor) # Aggiornamento Giocatore $game_player.refresh # Parte aggiunta $game_temp.party_change_flag = true $game_second_player.refresh $game_third_player.refresh end end #-------------------------------------------------------------------------- # - Rimozione Eroe # actor_id : ID Eroe #-------------------------------------------------------------------------- def remove_actor(actor_id) # Rimozione Eroe @actors.delete($game_actors[actor_id]) # Aggiornamento Giocatore $game_player.refresh # Parte aggiunta $game_temp.party_change_flag = true $game_second_player.refresh $game_third_player.refresh end end #============================================================================== # - Game_Troop #------------------------------------------------------------------------------ # E' la classe che gestisce i gruppi di mostri, # usa come riferimeto $game_troop #============================================================================== class Game_Troop #-------------------------------------------------------------------------- # - Settaggio # troop_id : ID Gruppo Nemici #-------------------------------------------------------------------------- def setup(troop, enem_events) # Settaggio dei nemici @enemies = [] @enem_events = enem_events @troop = troop #troop = $data_troops[troop_id] for i in 0...@troop.size enemy = $data_enemies[@troop[i]] if enemy != nil @enemies.push(Game_Enemy.new(@troop, i)) end end end def che_nemico?(event_id) for i in 0..@troop.size if @enem_events[i] == event_id return i end end end end class Game_Map #-------------------------------------------------------------------------- # - Settaggio Mappa # map_id : ID Mappa #-------------------------------------------------------------------------- def setup(map_id) # Setta l'ID della mappa in @map_id @map_id = map_id # La mappa è presa dal file e settata in @map @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id)) # Settaggio delle Variabili tileset = $data_tilesets[@map.tileset_id] @tileset_name = tileset.tileset_name @autotile_names = tileset.autotile_names @panorama_name = tileset.panorama_name @panorama_hue = tileset.panorama_hue @fog_name = tileset.fog_name @fog_hue = tileset.fog_hue @fog_opacity = tileset.fog_opacity @fog_blend_type = tileset.fog_blend_type @fog_zoom = tileset.fog_zoom @fog_sx = tileset.fog_sx @fog_sy = tileset.fog_sy @battleback_name = tileset.battleback_name @passages = tileset.passages @priorities = tileset.priorities @terrain_tags = tileset.terrain_tags # Inizializzazione Coordiante @display_x = 0 @display_y = 0 # Elimina la richiesta di aggiornamento @need_refresh = false # Settaggio dati degli eventi @events = {} enemies = [] enem_events = [] for i in @map.events.keys @events[i] = Game_Event.new(@map_id, @map.events[i]) if @events[i].nemico? id_nemico = @events[i].name.to_i enemies.push(id_nemico) enem_events.push(i) end end unless enemies.empty? $game_troop.setup(enemies, enem_events) end # Settaggio dati degli eventi couni @common_events = {} for i in 1...$data_common_events.size @common_events[i] = Game_CommonEvent.new(i) end # Settaggio della nebbia @fog_ox = 0 @fog_oy = 0 @fog_tone = Tone.new(0, 0, 0, 0) @fog_tone_target = Tone.new(0, 0, 0, 0) @fog_tone_duration = 0 @fog_opacity_duration = 0 @fog_opacity_target = 0 # Settaggio dello scroll @scroll_direction = 2 @scroll_rest = 0 @scroll_speed = 4 end end ############################################ ######## Aggiunte a Game_Character ######### ############################################ class Game_Character alias chara_initialize initialize def initialize chara_initialize @allerta = false end #-------------------------------------------------------------------------- # - Aggiornamento #-------------------------------------------------------------------------- def update if party_member? if in_chara_range?(1) == false @move_type = 5 # Movimento party if in_chara_range?(2) == true @move_speed = 4#3 else @move_speed = 4 end elsif $game_player.moving? @move_type = 6 end end if nemico? if in_chara_range?(3) == false @move_type = 4 # 4 = Movimento Nemico @move_speed = 1 @character_hue = 0 else @move_type = 2 @move_speed = 2 @character_hue = 50 end @move_frequency = 6 end if jumping? update_jump elsif moving? update_move else update_stop end if @anime_count > 18 - @move_speed * 2 if not @step_anime and @stop_count > 0 @pattern = @original_pattern else @pattern = (@pattern + 1) % 4 end @anime_count = 0 end if @wait_count > 0 @wait_count -= 1 return end if @move_route_forcing move_type_custom return end if @starting or lock? return end if @stop_count > (40 - @move_frequency * 2) * (6 - @move_frequency) case @move_type when 1 move_type_random when 2 move_type_toward_player when 3 move_type_custom when 4 move_type_nemico when 5 move_party_player when 6 move_type_fermo end end end #-------------------------------------------------------------------------- # - Riposiziona #-------------------------------------------------------------------------- def riposiziona case rand(3) when 0 r_x = $game_map.display_x + rand(21)*128 - 128*3 r_y = $game_map.display_y - 128*3 when 1 r_x = $game_map.display_x + rand(21)*128 - 128*3 r_y = $game_map.display_y + 2176 + 128*3 when 2 r_x = $game_map.display_x - 128*3 r_y = $game_map.display_y + rand(16)*128 - 128*3 when 3 r_x = $game_map.display_x + 2816 + 128*3 r_y = $game_map.display_y + rand(16)*128 - 128*3 end x = r_x / 128 y = r_y / 128 if $game_map.passable?(x, y, 0) @real_x = r_x @real_y = r_y @x = x @y = y else riposiziona end r = rand(23) + 1 if r < 10 name = "10" + r.to_s + "-Civilian0" + r.to_s else name = "1" + r.to_s + "-Civilian" + r.to_s end @character_name = name #@move_speed = rand(2)+ 1 end #-------------------------------------------------------------------------- # - Movimento Nemico #-------------------------------------------------------------------------- def move_type_nemico case rand(19) when 0..16 move_forward when 17 move_random when 18 @stop_count = 0 end end def move_type_fermo end def move_type_toward_player sx = @x - $game_player.x sy = @y - $game_player.y abs_sx = sx > 0 ? sx : -sx abs_sy = sy > 0 ? sy : -sy if sx + sy >= 20 move_random return end case rand(6) when 0..3 move_toward_player when 4 move_toward_player#move_random when 5 move_toward_player#move_forward end end def move_party_player case @act when 1 mdf = -1 when 2 mdf = 1 end gp = $game_player mdf_x = (gp.direction == 6 ? 1 : gp.direction == 4 ? -1 : gp.direction == 2 ? mdf : gp.direction == 8 ? mdf : 0) mdf_y = (gp.direction == 2 ? 1 : gp.direction == 8 ? -1 : gp.direction == 6 ? mdf : gp.direction == 4 ? mdf : 0) sx = @x - $game_player.x + mdf_x sy = @y - $game_player.y + mdf_y if sx == 0 and sy == 0 return end abs_sx = sx.abs abs_sy = sy.abs if abs_sx == abs_sy rand(2) == 0 ? abs_sx += 1 : abs_sy += 1 end if abs_sx > abs_sy sx > 0 ? move_left : move_right if not moving? and sy != 0 sy > 0 ? move_up : move_down end else sy > 0 ? move_up : move_down if not moving? and sx != 0 sx > 0 ? move_left : move_right end end if not moving? if not in_chara_range?(1) case @act when 1 if abs_sx < abs_sy sx > 0 ? move_right : move_left else sy > 0 ? move_down : move_up end when 2 if abs_sx < abs_sy sx > 0 ? move_left : move_right else sy > 0 ? move_up : move_down end end end end end end #-------------------------------------------------------------------------- # - E' a (quadretti) distanza dall'eroe? #-------------------------------------------------------------------------- def in_chara_range?(quadretti) screne_x = $game_player.real_x screne_x -= 128*(1+quadretti) screne_y = $game_player.real_y screne_y -= 128*(1+quadretti) screne_width = $game_player.real_x screne_width += 128*(1+quadretti) screne_height = $game_player.real_y screne_height += 128*(1+quadretti) return false if real_x <= screne_x return false if real_x >= screne_width return false if real_y <= screne_y return false if real_y >= screne_height return true end ############################################ ######### Aggiunte a GAme_Event ############ ############################################ class Game_Event < Game_Character # # - Controlla se è un membro del party # def party_member? return false end #-------------------------------------------------------------------------- # - Controlla se è un nemico #-------------------------------------------------------------------------- def nemico? params = XPML_read("nemico",@id,2) return (params != nil) end def name return @event.nil? ? '' : @event.name end def death # Settaggio di alcune variabili @tile_id = 0 @character_name = "" @character_hue = 0 @move_type = 0 @through = true @trigger = nil @list = nil @interpreter = nil end end ############################################ ######### Aggiunte a Game_Player ########### ############################################ class Game_Player def party_member? return false end def nemico? return false end def check_event_trigger_here(triggers) result = false # Quando si sta eseguendo un evento if $game_system.map_interpreter.running? return result end # Loop degli eventi for event in $game_map.events.values # Quando le coordinate sono uguali e l'evento ha come condizione di inizio "Azione" if event.x == @x and event.y == @y and triggers.include?(event.trigger) and event.nemico? == false # Quando l'evento è eseguibile if not event.jumping? and event.over_trigger? event.start result = true end end end return result end #-------------------------------------------------------------------------- # - Controllo esecuzione degli eventi #-------------------------------------------------------------------------- def check_event_trigger_there(triggers) result = false # Quando si sta eseguendo un evento if $game_system.map_interpreter.running? return result end # Sono calcolate le coordinate del tile davanti all'eroe new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0) new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0) # Loop degli Eventi for event in $game_map.events.values # Quando le coordinate sono uguali e l'evento ha come condizione di inizio "Azione" if event.x == new_x and event.y == new_y and triggers.include?(event.trigger) and event.nemico? == false # Quando l'evento è eseguibile if not event.jumping? and not event.over_trigger? event.start result = true end end end # Quando non è rilevato nessun evento if result == false # Quando c'è un "incontra attraverso" nel title d'avanti if $game_map.counter?(new_x, new_y) # Calcola le coordinate di 2 tile davanti all'eroe new_x += (@direction == 6 ? 1 : @direction == 4 ? -1 : 0) new_y += (@direction == 2 ? 1 : @direction == 8 ? -1 : 0) # Loop degli Eventi for event in $game_map.events.values # Quando le coordinate sono uguali e l'evento ha come condizione di inizio "Azione" if event.x == new_x and event.y == new_y and triggers.include?(event.trigger) and event.nemico? == false # Quando l'evento è eseguibile if not event.jumping? and not event.over_trigger? event.start result = true end end end end end return result end #-------------------------------------------------------------------------- # - Aggiornamento #-------------------------------------------------------------------------- def update # Memorizza l'ultimo movimento se ci si sta muovendo last_moving = moving? # Se ci si sta muovendo o si sta eseguendo un evento parallelo # o c'è un muovi evento o c'è una finestra di messaggio unless moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing # Quando è premuto un tasto muove l'eroe case Input.dir4 when 2 move_down when 4 move_left when 6 move_right when 8 move_up end end # Le coordinate vengono memorizzate in variabili temporanee last_real_x = @real_x last_real_y = @real_y super # Quando l'eroe si muove verso giu ed è possibile muovere la mappa if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y # Muovi la mappa $game_map.scroll_down(@real_y - last_real_y) end # Quando l'eroe si muove verso sinistra ed è possibile muovere la mappa if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X # Muovi la mappa $game_map.scroll_left(last_real_x - @real_x) end # Quando l'eroe si muove verso destra ed è possibile muovere la mappa if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X # Muovi la mappa $game_map.scroll_right(@real_x - last_real_x) end # Quando l'eroe si muove verso sù ed è possibile muovere la mappa if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y # Muovi la mappa $game_map.scroll_up(last_real_y - @real_y) end # Quando non ci si sta muovendo unless moving? # Quando il movimento è appena finito if last_moving # Controllo eventi "Tocco con l'eroe" - "Collisione" result = check_event_trigger_here([1,2]) # Se non ci sono eventi da eseguire if result == false # Se la modalità di debug è disattiva e non si sta premendo ctrl unless $DEBUG and Input.press?(Input::CTRL) # Conteggio incontri casuali if @encounter_count > 0 @encounter_count -= 1 end end end end # Quando C è premuto if Input.trigger?(Input::C) # Controlla esecuzione eventi $game_temp.battle_menu_closed = check_event_trigger_here([0]) $game_temp.battle_menu_closed = check_event_trigger_there([0,1,2]) end end # if moving? and Input.trigger?(Input::C) $game_temp.battle_menu_closed = false end end end #============================================================================== # - Game_Event #------------------------------------------------------------------------------ # E' la classe che gestisce gli eventi # E' usata in Game_Map #============================================================================== class Game_Party_Player < Game_Character #-------------------------------------------------------------------------- # - Variabile #-------------------------------------------------------------------------- attr_reader :trigger # Condizione d'avvio attr_reader :list # Lista dei comandi attr_reader :starting # Se l'evento è in esecuzione #-------------------------------------------------------------------------- # - Inizializzazione Oggetto # map_id : ID Mappa # event : Evento (RPG::Event) #-------------------------------------------------------------------------- def initialize(act) super() @act = act @erased = false @starting = false @through = false # Posizionamento #moveto(@event.x, @event.y) refresh end def party_member? return true end def nemico? return false end #-------------------------------------------------------------------------- # - Settaggio di @starting #-------------------------------------------------------------------------- def clear_starting @starting = false end #-------------------------------------------------------------------------- # - Controllo Sovrapposizione #-------------------------------------------------------------------------- def over_trigger? # Se l'eroe non esiste o non può eseguire eventi if @character_name != "" and not @through # Esecuzione impossibile return false end # Quando la posizione non è calpestabile unless $game_map.passable?(@x, @y, 0) # Esecuzione impossibile return false end # Esecuzione possibile return true end #-------------------------------------------------------------------------- # - Qui c'era def start #-------------------------------------------------------------------------- #-------------------------------------------------------------------------- # - Eliminazione #-------------------------------------------------------------------------- def erase @erased = true refresh end #-------------------------------------------------------------------------- # - Aggiornamento #-------------------------------------------------------------------------- def refresh if $game_party.actors.size <= @act # Vengono cancellati nome e tonalità @character_name = "" @character_hue = 0 return end actor = $game_party.actors[@act] @character_name = actor.character_name @character_hue = actor.character_hue @opacity = 255 @blend_type = 0 end #-------------------------------------------------------------------------- # - Controllo evento con collisione #-------------------------------------------------------------------------- def check_event_trigger_touch(x, y) # Quando è già in esecuzione if $game_system.map_interpreter.running? return end # Quando le coordinate sono uguali e l'evento ha come condizione di inizio "Tocco con l'eroe" if @trigger == 2 and x == $game_player.x and y == $game_player.y # Quando l'evento è eseguibile if not jumping? and not over_trigger? start end end end #-------------------------------------------------------------------------- # - Controllo evento con inizio automatico #-------------------------------------------------------------------------- def check_event_trigger_auto # Quando le coordinate sono uguali if @trigger == 2 and @x == $game_player.x and @y == $game_player.y # Quando l'evento è eseguibile if not jumping? and over_trigger? start end end # Se la condizione è inizio automatico if @trigger == 3 start end end #-------------------------------------------------------------------------- # - Aggiornamento #-------------------------------------------------------------------------- def update super # Controllo evento con inizio automatico check_event_trigger_auto # Quando c'è un processo parallelo da eseguire if @interpreter != nil # Quando l'interprete non è in esecuzone unless @interpreter.running? # Esecuzione di un evento @interpreter.setup(@list, @event.id) end # Aggiornamento Interprete @interpreter.update end end end class Spriteset_Map #-------------------------------------------------------------------------- # - Inizializzazione Oggetto #-------------------------------------------------------------------------- def initialize # Creazione Livelli @viewport1 = Viewport.new(0, 0, 640, 480) @viewport2 = Viewport.new(0, 0, 640, 480) @viewport3 = Viewport.new(0, 0, 640, 480) @viewport2.z = 200 @viewport3.z = 5000 # Creazione Titlemap @tilemap = Tilemap.new(@viewport1) @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name) for i in 0..6 autotile_name = $game_map.autotile_names[i] @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name) end @tilemap.map_data = $game_map.data @tilemap.priorities = $game_map.priorities # Creazione Panorama @panorama = Plane.new(@viewport1) @panorama.z = -1000 # Creazione Nebbia @fog = Plane.new(@viewport1) @fog.z = 3000 # Creazione Chara @character_sprites = [] for i in $game_map.events.keys.sort sprite = Sprite_Character.new(@viewport1, $game_map.events[i]) @character_sprites.push(sprite) end @character_sprites.push(Sprite_Character.new(@viewport1, $game_player)) @character_sprites.push(Sprite_Character.new(@viewport1, $game_second_player)) @character_sprites.push(Sprite_Character.new(@viewport1, $game_third_player)) # Creazione effetti meteorologici @weather = RPG::Weather.new(@viewport1) # Creazione Pictures @picture_sprites = [] for i in 1..50 @picture_sprites.push(Sprite_Picture.new(@viewport2, $game_screen.pictures[i])) end # Creazione Sprite del timer @timer_sprite = Sprite_Timer.new # Aggiornamento frame update end end class Window_Base #-------------------------------------------------------------------------- # - Disegna il nome # actor : Personaggio # x : Posizione del disegno: Coordinate X # y : Posizione del disegno: Coordinate Y #-------------------------------------------------------------------------- def draw_target_name(actor, x, y) self.contents.font.name = "Comic Sans MS" self.contents.font.size = 20 self.contents.font.color = normal_color self.contents.draw_text_bordered(x, y, 120, 32, actor.name) end #-------------------------------------------------------------------------- # - Disegna i punti HP del bersaglio # actor : Bersaglio # x : Posizione del disegno: Coordinate X # y : Posizione del disegno: Coordinate Y # width : Ampiezza del disegno #-------------------------------------------------------------------------- def draw_target_hp(actor, x, y, width = 144) # Disegna la sequenza dei caratteri: "HP" self.contents.font.color = system_color self.contents.font.name = "Comic Sans MS" self.contents.font.size = 20 self.contents.draw_text_bordered(x, y, 32, 32, $data_system.words.hp) # Calcola se c'è qualche spazio che disegna i punti MaxHp if width - 32 >= 108 hp_x = x + width - 108 flag = true elsif width - 32 >= 48 hp_x = x + width - 48 flag = false end # Disegna i punti HP self.contents.font.color = actor.hp == 0 ? knockout_color : actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color self.contents.font.name = "Comic Sans MS" self.contents.font.size = 20 self.contents.draw_text_bordered(hp_x, y, 48, 32, actor.hp.to_s, 2) # Disegna i punti MaxHP if flag self.contents.font.color = normal_color self.contents.font.name = "Comic Sans MS" self.contents.font.size = 20 self.contents.draw_text_bordered(hp_x + 48, y, 12, 32, "/", 1) self.contents.draw_text_bordered(hp_x + 60, y, 48, 32, actor.maxhp.to_s) end end #-------------------------------------------------------------------------- # - Disegna i punti HP dei personaggi # actor : Personaggio # x : Posizione del disegno: Coordinate X # y : Posizione del disegno: Coordinate Y # width : Ampiezza del disegno #-------------------------------------------------------------------------- def draw_player_hp(actor_hp, actor_maxhp, x, y, bar_flag = false) # Disegna la sequenza dei caratteri: "HP" self.contents.font.color = system_color self.contents.font.name = "Comic Sans MS" self.contents.font.size = 16 self.contents.draw_text_bordered(x, y+1, 48, 32, "HP") # Calcola se c'è qualche spazio che disegna i punti MaxHp hp_x = x flag = true draw_gray_bar(hp_x - 1, y+23, 86) draw_cyan_bar(hp_x, y+24, 84) draw_hp_bar(hp_x, y+24, 84, actor_hp, actor_maxhp) if flag self.contents.font.color = normal_color self.contents.font.name = "Comic Sans MS" self.contents.font.size = 16 #self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1) self.contents.draw_text_bordered(hp_x + 35, y+1, 48, 32, actor_maxhp.to_s,2) end size = self.contents.text_size(actor_maxhp.to_s).width # Disegna i punti HP self.contents.font.color = actor_hp == 0 ? knockout_color : actor_hp <= actor_maxhp / 4 ? crisis_color : normal_color self.contents.font.name = "Comic Sans MS" self.contents.font.size = 22 self.contents.draw_text_bordered(hp_x +33 - size, y-1, 48, 32, actor_hp.to_s, 2) end #-------------------------------------------------------------------------- # - Disegna i punti MP # actor : Personaggio # x : Posizione del disegno: Coordinate X # y : Posizione del disegno: Coordinate Y # width : Ampiezza del disegno #-------------------------------------------------------------------------- def draw_player_sp(actor, x, y, width = 144) # Disegna la sequenza dei caratteri: "MP" self.contents.font.color = system_color self.contents.font.name = "Comic Sans MS" self.contents.font.size = 16 self.contents.draw_text_bordered(x+15, y+1, 32, 32, "MP") # Calcola se c'è qualche spazio che disegna i punti MaxMp sp_x = x+15 flag = false draw_gray_bar(sp_x - 1, y+23, 52) draw_orange_bar(sp_x, y+24, 50) draw_mp_bar(sp_x, y+24, 50, actor) # Disegna i punti MP self.contents.font.color = actor.sp == 0 ? knockout_color : actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color self.contents.font.name = "Comic Sans MS" self.contents.font.size = 22 self.contents.draw_text_bordered(x + 35, y-1, 32, 32, actor.sp.to_s, 2) # Disegna i punti MaxMP if flag self.contents.font.color = normal_color self.contents.font.name = "Comic Sans MS" self.contents.font.size = 16 self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1) self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s) end end def draw_gray_bar(x, y, length) gradient_red_start = 0 gradient_red_end = 0 gradient_green_start = 0 gradient_green_end = 0 gradient_blue_start = 0 gradient_blue_end = 0 draw_bar_percent = 100 for x_coord in 1..length current_percent_done = x_coord * 100 / length difference = gradient_red_end - gradient_red_start red = gradient_red_start + difference * x_coord / length difference = gradient_green_end - gradient_green_start green = gradient_green_start + difference * x_coord / length difference = gradient_blue_end - gradient_blue_start blue = gradient_blue_start + difference * x_coord / length if current_percent_done <= draw_bar_percent rect = Rect.new(x + x_coord-1, y, 1, 4) self.contents.fill_rect(rect, Color.new(red, green, blue, 255)) end end end def draw_cyan_bar(x, y, length) gradient_red_start = 80 gradient_red_end = 80 gradient_green_start = 80 gradient_green_end = 80 gradient_blue_start = 130 gradient_blue_end = 130 draw_bar_percent = 100 for x_coord in 1..length current_percent_done = x_coord * 100 / length difference = gradient_red_end - gradient_red_start red = gradient_red_start + difference * x_coord / length difference = gradient_green_end - gradient_green_start green = gradient_green_start + difference * x_coord / length difference = gradient_blue_end - gradient_blue_start blue = gradient_blue_start + difference * x_coord / length if current_percent_done <= draw_bar_percent rect = Rect.new(x + x_coord-1, y, 1, 2) self.contents.fill_rect(rect, Color.new(red, green, blue, 255)) end end end def draw_orange_bar(x, y, length) gradient_red_start = 130 gradient_red_end = 130 gradient_green_start = 80 gradient_green_end = 80 gradient_blue_start = 80 gradient_blue_end = 80 draw_bar_percent = 100 for x_coord in 1..length current_percent_done = x_coord * 100 / length difference = gradient_red_end - gradient_red_start red = gradient_red_start + difference * x_coord / length difference = gradient_green_end - gradient_green_start green = gradient_green_start + difference * x_coord / length difference = gradient_blue_end - gradient_blue_start blue = gradient_blue_start + difference * x_coord / length if current_percent_done <= draw_bar_percent rect = Rect.new(x + x_coord-1, y, 1, 2) self.contents.fill_rect(rect, Color.new(red, green, blue, 255)) end end end def draw_hp_bar(x, y, length, actor_hp, actor_maxhp) gradient_red_start = 80 gradient_red_end = 80 gradient_green_start = 150 gradient_green_end = 150 gradient_blue_start = 255 gradient_blue_end = 255 draw_bar_percent = (100*actor_hp)/actor_maxhp#[your equation here] for x_coord in 1..length current_percent_done = x_coord * 100 / length difference = gradient_red_end - gradient_red_start red = gradient_red_start + difference * x_coord / length difference = gradient_green_end - gradient_green_start green = gradient_green_start + difference * x_coord / length difference = gradient_blue_end - gradient_blue_start blue = gradient_blue_start + difference * x_coord / length if current_percent_done <= draw_bar_percent rect = Rect.new(x + x_coord-1, y, 1, 2) self.contents.fill_rect(rect, Color.new(red, green, blue, 255)) end end end def draw_mp_bar(x, y, length, actor) gradient_red_start = 200 gradient_red_end = 200 gradient_green_start = 150 gradient_green_end = 150 gradient_blue_start = 80 gradient_blue_end = 80 draw_bar_percent = (100*actor.sp)/actor.maxsp#[your equation here] for x_coord in 1..length current_percent_done = x_coord * 100 / length difference = gradient_red_end - gradient_red_start red = gradient_red_start + difference * x_coord / length difference = gradient_green_end - gradient_green_start green = gradient_green_start + difference * x_coord / length difference = gradient_blue_end - gradient_blue_start blue = gradient_blue_start + difference * x_coord / length if current_percent_done <= draw_bar_percent rect = Rect.new(x + x_coord-1, y, 1, 2) self.contents.fill_rect(rect, Color.new(red, green, blue, 255)) end end end def memo_radiant_bar(length) gradient_red_start = 80 gradient_red_end = 255 gradient_green_start = 150 gradient_green_end = 255 gradient_blue_start = 255 gradient_blue_end = 255 draw_bar_percent = 100 $r_red = [] $r_green = [] $r_blue = [] l_off = ((length/2)-1) for x_coord in 1..l_off difference = gradient_red_end - gradient_red_start $r_red[x_coord] = gradient_red_start + difference * x_coord / l_off difference = gradient_green_end - gradient_green_start $r_green[x_coord] = gradient_green_start + difference * x_coord / l_off difference = gradient_blue_end - gradient_blue_start $r_blue[x_coord] = gradient_blue_start + difference * x_coord / l_off end #aggiungo un po' di bianco for x_coord in 1..2 x_off = x_coord + l_off $r_red[x_off] = 255 $r_green[x_off] = 255 $r_blue[x_off] = 255 end gradient_red_start = 255 gradient_red_end = 80 gradient_green_start = 255 gradient_green_end = 150 gradient_blue_start = 255 gradient_blue_end = 255 draw_bar_percent = 100 l_off = length - (l_off + 2) l_back = l_off + 2 l_off = length - l_back for x_coord in 1..l_off x_off = x_coord + l_back difference = gradient_red_end - gradient_red_start $r_red[x_off] = gradient_red_start + difference * x_coord / l_off difference = gradient_green_end - gradient_green_start $r_green[x_off] = gradient_green_start + difference * x_coord / l_off difference = gradient_blue_end - gradient_blue_start $r_blue[x_off] = gradient_blue_start + difference * x_coord / l_off end end def draw_radiant_bar(x, y, length, actor_hp, actor_maxhp, offset) draw_bar_percent = (100*actor_hp)/actor_maxhp#[your equation here] for x_coord in 1..length current_percent_done = x_coord * 100 / length if current_percent_done <= draw_bar_percent rect = Rect.new(x + x_coord-1, y, 1, 2) x_off = (x_coord + offset) % length red = $r_red[x_off + 1] green = $r_green[x_off + 1] blue = $r_blue[x_off + 1] self.contents.fill_rect(rect, Color.new(red, green, blue, 255)) end end end # sp radiant ##################### def memo_radiant_bar_mp(length) gradient_red_start = 255 gradient_red_end = 200 gradient_green_start = 255 gradient_green_end = 150 gradient_blue_start = 255 gradient_blue_end = 80 draw_bar_percent = 100 $rm_red = [] $rm_green = [] $rm_blue = [] l_off = ((length/2)-1) for x_coord in 1..l_off difference = gradient_red_end - gradient_red_start $rm_red[x_coord] = gradient_red_start + difference * x_coord / l_off difference = gradient_green_end - gradient_green_start $rm_green[x_coord] = gradient_green_start + difference * x_coord / l_off difference = gradient_blue_end - gradient_blue_start $rm_blue[x_coord] = gradient_blue_start + difference * x_coord / l_off end #aggiungo un po' di arancione for x_coord in 1..2 x_off = x_coord + l_off $rm_red[x_off] = 200 $rm_green[x_off] = 150 $rm_blue[x_off] = 80 end gradient_red_start = 200 gradient_red_end = 255 gradient_green_start = 150 gradient_green_end = 255 gradient_blue_start = 80 gradient_blue_end = 255 draw_bar_percent = 100 l_off = length - (l_off + 2) l_back = l_off + 2 l_off = length - l_back for x_coord in 1..l_off x_off = x_coord + l_back difference = gradient_red_end - gradient_red_start $rm_red[x_off] = gradient_red_start + difference * x_coord / l_off difference = gradient_green_end - gradient_green_start $rm_green[x_off] = gradient_green_start + difference * x_coord / l_off difference = gradient_blue_end - gradient_blue_start $rm_blue[x_off] = gradient_blue_start + difference * x_coord / l_off end end def draw_radiant_bar_mp(x, y, length, actor_sp, actor_maxsp, offset) draw_bar_percent = (100*actor_sp)/actor_maxsp#[your equation here] for x_coord in 1..length current_percent_done = x_coord * 100 / length if current_percent_done <= draw_bar_percent rect = Rect.new(x + x_coord-1, y, 1, 2) x_off = (x_coord + offset) % length red = $rm_red[x_off + 1] green = $rm_green[x_off + 1] blue = $rm_blue[x_off + 1] self.contents.fill_rect(rect, Color.new(red, green, blue, 255)) end end end end#============================================================================== # - Window_Selectable #------------------------------------------------------------------------------ # E' la classe delle finestre con movimento del cursore o con funzione di # scorrimento #============================================================================== class Window_Selectable_New < Window_Base #-------------------------------------------------------------------------- # - Apri una variabile istanza #-------------------------------------------------------------------------- attr_reader :index # Posizione del cursore attr_reader :help_window # Finestra di aiuto #-------------------------------------------------------------------------- # - Inizializzazione dell'oggetto # x : Coordinate X della finestra # y : Coordinate Y della finestra # width : Larghezza della finestra # height : Altezza della finestra #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) self.z = 5000 @item_max = 1 @column_max = 1 @index = -1 @cursore = Arrow_Menu.new @cursore.x = (@column_max * 20) + x @cursore.y = (@column_max * 20 - self.oy) + y + 10 end #-------------------------------------------------------------------------- # - Sistemazione della posizione del cursore # index : Nuova posizione del cursore #-------------------------------------------------------------------------- def index=(index) @index = index # Viene aggiornato il testo di aiuto # (update_help viene definito dal posto successivo) if self.active and @help_window != nil update_help end # Viene aggiornato il rettangolo del cursore update_cursor_rect end #-------------------------------------------------------------------------- # - Acquisizione del numero di linee #-------------------------------------------------------------------------- def row_max # Il numero di linee viene elaborato dal numero di oggetti e il numero # delle sequenze return (@item_max + @column_max - 1) / @column_max end #-------------------------------------------------------------------------- # - Acquisizione di una linea superiore #-------------------------------------------------------------------------- def top_row # Origine di trasmissione dei contenuti di una finestra: # Sulle coordinate Y, l'altezza di una linea viene divisa per 32 return self.oy / 20 end #-------------------------------------------------------------------------- # - Sistemazione di una linea superiore # row : La linea viene mostrata in cima #-------------------------------------------------------------------------- def top_row=(row) # Quando row è minore di zero, allora correggi ed inserisci 0 if row < 0 row = 0 end # Quando row è maggiore di row_max - 1, poni row = row_max - 1 if row > row_max - 1 row = row_max - 1 end # row Altezza di una linea. è l'origine di trasmissione dei contenuti # di una finestra. Si considera come coordinata Y self.oy = row * 20 end #-------------------------------------------------------------------------- # - 1 Acquisizione del numero di linee che possono essere mostrate # su una pagina #-------------------------------------------------------------------------- def page_row_max # Altezza della finestra del frame. Si sottrare 32 all'altezza di # una linea e si divide per 32 return (self.height - 32) / 20 end #-------------------------------------------------------------------------- # - 1 Acquisizione del numero di oggetti che possono essere mostrati # su una pagina #-------------------------------------------------------------------------- def page_item_max # Numero di linee, page_row_max il numero di sequenze per # le colonne @column_max return page_row_max * @column_max end #-------------------------------------------------------------------------- # - Sistemazione della finestra di aiuto # help_window : Nuova finestra di aiuto #-------------------------------------------------------------------------- def help_window=(help_window) @help_window = help_window # Il testo di aiuto viene aggiornato # (update_help viene definito dal posto successivo) if self.active and @help_window != nil update_help end end #------------------------------------------- # #------------------------------------------- def visible=(visible) update_cursor_rect if visible @cursore.visible = true @cursore.opacity = 255 self.opacity = 200 self.contents_opacity = 255 else @cursore.visible = false @cursore.opacity = 0 self.opacity = 0 self.contents_opacity = 0 end end #-------------------------------------------------------------------------- # - Aggiornamento del rettangolo del cursore #-------------------------------------------------------------------------- def update_cursor_rect # Posizione del cursore. Quando è minore di 0... if @index < 0 @cursore.visible = false @cursore.opacity = 0#self.cursor_rect.empty return end # La linea corrente viene acquisita row = @index / @column_max # Nel caso di prima, la linea corrente viene mostrata in cima if row < self.top_row # Scorre in modo tale che la linea corrente vada in cima self.top_row = row end # Nel caso precedente, la linea corrente viene mostrata fino alla # fine della coda if row > self.top_row + (self.page_row_max - 1) # Scorre in modo tale che la linea corrente vada in coda self.top_row = row - (self.page_row_max - 1) end # Viene calcolata l'ampiezza del cursore #cursor_width = self.width / @column_max - 32 # Vengono calcolate le coordinate del cursore pos_x = (@index % @column_max * 20) + self.x#(cursor_width + 32) pos_y = (@index / @column_max * 20 - self.oy) + self.y + 10#+ 16 if @cursore.x != pos_x or @cursore.y != pos_y @cursore.stop_move @cursore.move(4, pos_x, pos_y, 255) end # Viene aggiornato il rettangolo del cursore #self.cursor_rect.set(x, y, cursor_width, 32) end #-------------------------------------------------------------------------- # - Aggiornamento frame #-------------------------------------------------------------------------- def update super # Quando è nello stato in cui si muove il cursore... if self.active and @item_max > 0 and @index >= 0 # Quando il pulsante viene premuto nella direzione bassa... if Input.repeat?(Input::DOWN) # Numero di squenze: 1 nel caso in cui non viene ripetuta su una # direzione del pulsante # Nel caso precedente, la posizione del cursore viene data da: # (Numero di sequenze - Numero degli oggetti) if (@column_max == 1 and Input.trigger?(Input::DOWN)) or @index < @item_max - @column_max # Il cursore viene mosso in basso $game_system.se_play($data_system.cursor_se) @index = (@index + @column_max) % @item_max # Aggiornamento del rettangolo del cursore update_cursor_rect end end # Quando il pulsante viene premuto nella direzione alta... if Input.repeat?(Input::UP) # Numero di squenze: 1 nel caso in cui non viene ripetuta su una # direzione del pulsante # Nel caso precedente, la posizione del cursore viene data dal # numero di sequenze if (@column_max == 1 and Input.trigger?(Input::UP)) or @index >= @column_max # Il cursore viene mosso verso l'alto $game_system.se_play($data_system.cursor_se) @index = (@index - @column_max + @item_max) % @item_max # Aggiornamento del rettangolo del cursore update_cursor_rect end end # Quando il pulsante viene premuto nella direzione di destra... if Input.repeat?(Input::RIGHT) # Numero di sequenze >= 2 e @index < (numero di oggetti - 1) quando la # posizione del cursore... if @column_max >= 2 and @index < @item_max - 1 # ...viene mossa verso destra $game_system.se_play($data_system.cursor_se) @index += 1 # Aggiornamento del rettangolo del cursore update_cursor_rect end end # Quando il pulsante viene premuto nella direzione di sinistra... if Input.repeat?(Input::LEFT) # Numero di sequenze >= 2 e @index > 0 quando la posizione # del cursore... if @column_max >= 2 and @index > 0 # ...viene mossa verso sinistra $game_system.se_play($data_system.cursor_se) @index -= 1 # Aggiornamento del rettangolo del cursore update_cursor_rect end end # Quando il pulsante R viene premuto... if Input.repeat?(Input::R) # Prima dell'ultima linea sui dati, viene mostrata la linea fino # alla fine della coda if self.top_row + (self.page_row_max - 1) < (self.row_max - 1) # Il cursore si muove avanti di una pagina $game_system.se_play($data_system.cursor_se) @index = [@index + self.page_item_max, @item_max - 1].min self.top_row += self.page_row_max # Aggiornamento del rettangolo del cursore update_cursor_rect end end # Quando il pulsante L viene premuto... if Input.repeat?(Input::L) # La linea correntemente mostrata in cima, se > 0... if self.top_row > 0 # Il cursore si muove indietro di una pagina $game_system.se_play($data_system.cursor_se) @index = [@index - self.page_item_max, 0].max self.top_row -= self.page_row_max # Aggiornamento del rettangolo del cursore update_cursor_rect end end end # Viene aggiornato il testo di aiuto # (update_help viene definito dal posto successivo) if self.active and @help_window != nil update_help end @cursore.update end end #============================================================================== # - Window_Command #------------------------------------------------------------------------------ # E' la finestra che compie la selezione del comando generale #============================================================================== class Window_Command_New < Window_Selectable_New #-------------------------------------------------------------------------- # - Inizializzazione dell'oggetto # width : Larghezza della finestra # commands : Sistemazione di una sequenza di comandi del personaggio #-------------------------------------------------------------------------- def initialize(width, commands, color = Color.new(255, 255, 255, 255)) # L'altezza di una finestra è calcolata dal numero di un comando super(0, 0, width, commands.size * 20 + 32) @item_max = commands.size @commands = commands @color = color self.contents = Bitmap.new(width - 32, @item_max * 20) refresh self.index = 0 end def reinitialize(width, commands, color = Color.new(255, 255, 255, 255)) # L'altezza di una finestra è calcolata dal numero di un comando self.width = width self.height = commands.size * 20 + 32 @item_max = commands.size @commands = commands @color = color self.contents = Bitmap.new(width - 32, @item_max * 20) refresh self.index = 0 end #-------------------------------------------------------------------------- # - Aggiornamento #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max draw_item(i, @color) end end #-------------------------------------------------------------------------- # - Disegna un oggetto # index : Numero dell'oggetto # color : Colore del personaggio #-------------------------------------------------------------------------- def draw_item(index, color) self.contents.font.color = color self.contents.font.name = "Comic Sans MS" self.contents.font.size = 20 self.contents.draw_text_bordered(20, 20 * index - 5, self.contents.width - 8, 24, @commands[index], 0, color) #rect = Rect.new(30, 24 * index, self.contents.width - 8, 24) #self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) #self.contents.draw_text_bordered(rect, @commands[index]) end #-------------------------------------------------------------------------- # - Cancellazione di un oggetto # index : Numero dell'oggetto #-------------------------------------------------------------------------- def disable_item(index) draw_item(index, disabled_color) end end class Window_Message < Window_Selectable #-------------------------------------------------------------------------- # - Processo di terminazionde del messaggio #-------------------------------------------------------------------------- def terminate_message self.active = false self.pause = false self.index = -1 self.contents.clear @contents_showing = false if $game_temp.message_proc != nil $game_temp.message_proc.call end $game_temp.message_text = nil $game_temp.message_proc = nil $game_temp.choice_start = 99 $game_temp.choice_max = 0 $game_temp.choice_cancel_type = 0 $game_temp.choice_proc = nil $game_temp.num_input_start = 99 $game_temp.num_input_variable_id = 0 $game_temp.num_input_digits_max = 0 $game_temp.battle_menu_closed = true if @gold_window != nil @gold_window.dispose @gold_window = nil end end end #============================================================================== # - Window_BattleStatus #------------------------------------------------------------------------------ # E' la finestra che mostra lo stato dei membri del gruppo sulla # schermata di battaglia #============================================================================== class Window_Target_Stat < Window_Base #-------------------------------------------------------------------------- # - Inizializzazione dell'oggetto #-------------------------------------------------------------------------- def initialize super(0, 0, 200, 100) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = "Arial" self.contents.font.size = 24 self.opacity = 180 @level_up_flags = [false, false, false, false] end #-------------------------------------------------------------------------- # - Rilascia #-------------------------------------------------------------------------- def dispose super end #-------------------------------------------------------------------------- # - Sistemazione del miglioramento dei flags # actor_index : アクターインデックス #-------------------------------------------------------------------------- def level_up(actor_index) @level_up_flags[actor_index] = true end #-------------------------------------------------------------------------- # - Aggiornamento #-------------------------------------------------------------------------- def refresh(event_id) self.contents.clear @item_max = $game_troop.enemies.size enemy_id = $game_troop.che_nemico?(event_id) actor = $game_troop.enemies[enemy_id] draw_target_name(actor, 0, 0) draw_target_hp(actor, 0, 25) end #-------------------------------------------------------------------------- # - Aggiornamento frame #-------------------------------------------------------------------------- def update super # L'opacità è abbastanza bassa durante la fase principale if $game_temp.battle_main_phase self.contents_opacity -= 4 if self.contents_opacity > 191 else self.contents_opacity += 4 if self.contents_opacity < 255 end end end class Window_Barre < Window_Base #-------------------------------------------------------------------------- # - Inizializzazione dell'oggetto #-------------------------------------------------------------------------- def initialize super(160, 380, 480, 160) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = "Arial" self.contents.font.size = 24 self.opacity = 0 @level_up_flags = [false, false, false, false] @offset = 0 @offset_mp = 0 memo_radiant_bar(84) memo_radiant_bar_mp(50) refresh end #-------------------------------------------------------------------------- # - Rilascia #-------------------------------------------------------------------------- def dispose super end #-------------------------------------------------------------------------- # - Sistemazione del miglioramento dei flags # actor_index : アクターインデックス #-------------------------------------------------------------------------- def level_up(actor_index) @level_up_flags[actor_index] = true end #-------------------------------------------------------------------------- # - Aggiornamento #-------------------------------------------------------------------------- def refresh self.contents.clear tot_party = [$game_party.actors.size, 3].min @offset = (@offset % 84) + 1 @offset_mp = (@offset_mp % 50) + 1 for i in 0...tot_party actor = $game_party.actors[i] actor_y = i * 22 + (3-tot_party)*22 draw_radiant_bar(260, actor_y+24, 84, actor.hp, actor.maxhp, @offset) draw_radiant_bar_mp(350+15, actor_y+24, 50, actor.sp, actor.maxsp, @offset_mp) end end #-------------------------------------------------------------------------- # - Aggiornamento frame #-------------------------------------------------------------------------- def update super end end #============================================================================== # - Window_BattleStatus #------------------------------------------------------------------------------ # E' la finestra che mostra lo stato dei membri del gruppo sulla # schermata di battaglia #============================================================================== class Window_BattleStatus < Window_Base #-------------------------------------------------------------------------- # - Inizializzazione dell'oggetto #-------------------------------------------------------------------------- def initialize super(160, 380, 480, 160) self.contents = Bitmap.new(width - 32, height - 32) self.contents.font.name = "Arial" self.contents.font.size = 24 self.opacity = 0 @level_up_flags = [false, false, false, false] refresh end #-------------------------------------------------------------------------- # - Rilascia #-------------------------------------------------------------------------- def dispose super end #-------------------------------------------------------------------------- # - Sistemazione del miglioramento dei flags # actor_index : アクターインデックス #-------------------------------------------------------------------------- def level_up(actor_index) @level_up_flags[actor_index] = true end #-------------------------------------------------------------------------- # - Aggiornamento #-------------------------------------------------------------------------- def refresh self.contents.clear tot_party = [$game_party.actors.size, 3].min for i in 0...tot_party actor = $game_party.actors[i] actor_y = i * 22 + (3-tot_party)*22 draw_target_name(actor, 170, actor_y) draw_player_hp(actor.hp, actor.maxhp, 260, actor_y) draw_player_sp(actor, 350, actor_y) end $game_temp.party_change_flag = false end def refresh_bar self.contents.clear end #-------------------------------------------------------------------------- # - Aggiornamento frame #-------------------------------------------------------------------------- def update super end end #============================================================================== # - Arrow_Menu #------------------------------------------------------------------------------ # E' lo sprite del cursore usato nei menu #============================================================================== class Arrow_Menu < Sprite #-------------------------------------------------------------------------- # - Variabile #-------------------------------------------------------------------------- attr_reader :index # Indice attr_reader :help_window # Finestra d'aiuto #-------------------------------------------------------------------------- # - Inizializzazione # viewport : Livello #-------------------------------------------------------------------------- def initialize super self.bitmap = RPG::Cache.icon("HandCursor.png") self.z = 5000 self.opacity = 0 @move_count = 0 @index = 0 @duration = 0 @help_window = nil update end #-------------------------------------------------------------------------- # - Settaggio della posizione # index : Nuovo Indice #-------------------------------------------------------------------------- def index=(index) @index = index update end #-------------------------------------------------------------------------- # - Settaggio della finestra d'aiuto # help_window : Nuova Finestra d'aiuto #-------------------------------------------------------------------------- def help_window=(help_window) @help_window = help_window # Aggiornamento (update_help e' definito nella sottoclasse) if @help_window != nil update_help end end def stop_move @move_count = 0 end def move(duration, x, y, opacity) @duration = duration @target_x = x.to_f @target_y = y.to_f @target_opacity = opacity.to_f end def duration return @duration end #-------------------------------------------------------------------------- # - Aggiornamento #-------------------------------------------------------------------------- def update # Rinnovamento Posizione @move_count = (@move_count + 1) % 40 if @move_count == 5 move(4, self.x + 8, self.y, 255) elsif @move_count == 10 move(4, self.x - 8, self.y, 255) end if @duration >= 1 d = @duration if self.x != @target_x self.x = (self.x * (d - 1) + @target_x) / d end if self.y != @target_y self.y = (self.y * (d - 1) + @target_y) / d end if self.opacity != @target_opacity self.opacity = (self.opacity * (d - 1) + @target_opacity) / d end @duration -= 1 end # Aggiornamento (update_help e' definito nella sottoclasse) if @help_window != nil update_help end end end class Interpreter # Modifica al cambia grafica # per non far crashare il caterpillar script def command_322 actor = $game_actors[@parameters[0]] if actor != nil actor.set_graphic(@parameters[1], @parameters[2], @parameters[3], @parameters[4]) end $game_temp.party_change_flag = true $game_player.refresh # Parte aggiunta $game_second_player.refresh $game_third_player.refresh return true end end class Scene_Title def command_new_game # Suona SE azione $game_system.se_play($data_system.decision_se) # Ferma BGM Audio.bgm_stop # Resetta il contatore frame per il tempo di gioco Graphics.frame_count = 0 # Creazione oggetti $game_temp = Game_Temp.new $game_system = Game_System.new $game_switches = Game_Switches.new $game_variables = Game_Variables.new $game_self_switches = Game_SelfSwitches.new $game_screen = Game_Screen.new $game_actors = Game_Actors.new $game_party = Game_Party.new $game_troop = Game_Troop.new $game_map = Game_Map.new $game_player = Game_Player.new $game_second_player = Game_Party_Player.new(1) $game_third_player = Game_Party_Player.new(2) # Creazione Gruppo $game_party.setup_starting_members # Creazione Mappa $game_map.setup($data_system.start_map_id) # Trasferimento al punto d'inizio d_x = $data_system.start_x d_y = $data_system.start_y $game_player.moveto(d_x, d_y) $game_second_player.moveto(d_x + 1, d_y - 1) $game_third_player.moveto(d_x - 1, d_y - 1) # Aggiornamento Giocatore $game_player.refresh if $game_party.actors[1] != nil $game_second_player.refresh end if $game_party.actors[2] != nil $game_third_player.refresh end # Suona BGM e BGS automatici $game_map.autoplay # Aggiornamento Mappa $game_map.update # Cambia Scena $scene = Scene_Map.new end end class Scene_Map #-------------------------------------------------------------------------- # - Processo Principale #-------------------------------------------------------------------------- def main # Fase @phase = 0 @elenco = [] @attacking = [false] @curs = Arrow_Menu.new @curs.z = 4000 @curs.visible = false @curs.opacity = 0 # Settaggio Spriteset @spriteset = Spriteset_Map.new # Settaggio della finestra dei messaggi @message_window = Window_Message.new # Settaggio finestra status personaggi @battle_pg = Window_BattleStatus.new @battle_pg.visible = true # Settaggio finestra comandi @battle_menu = Window_Command_New.new(200, ["Attacca", "Magie/Tecniche", "Mystes", "Gambit", "Oggetti"]) @battle_menu.x = 16 @battle_menu.y = 480 - @battle_menu.height - 16 #@battle_menu.index = -1 @battle_menu.visible = false @battle_menu.active = false # Settaggio finestra delle barre hp/sp @barre = Window_Barre.new @target_stat = Window_Target_Stat.new @target_stat.visible = false # Fade Graphics.transition # Loop Principale loop do # Aggiornamento Grafica Graphics.update # Aggiornamento Input Input.update # Aggiornamento Frame update # Quando cambia la scena blocca il loop if $scene != self break end end # Preparazione Fade Graphics.freeze # Eliminazione chipaset @spriteset.dispose # Eliminazione finestra dei messaggi @message_window.dispose # Eliminazione Status Personaggi @battle_pg.dispose # Eliminazione menu di battaglia @battle_menu.dispose # Se la scena è il title if $scene.is_a?(Scene_Title) # Blocca la grafica Graphics.transition Graphics.freeze end end #-------------------------------------------------------------------------- # - Gestione Aggiornamento #-------------------------------------------------------------------------- def update case @phase when 0 update_base when 1 update_battle_menu @battle_menu.update when 2 update_magie_tecniche @battle_menu.update when 3 update_selezione_bersaglio @battle_menu.update @curs.update end end #-------------------------------------------------------------------------- # - Aggiornamento Base #-------------------------------------------------------------------------- def update_base # Loop loop do # Aggiornamento mappa ed interprete $game_map.update $game_system.map_interpreter.update $game_player.update $game_second_player.update $game_third_player.update # Aggiornamento sistema e schermo $game_system.update $game_screen.update # Quando il giocatore non deve essere trasportato esce dal loop unless $game_temp.player_transferring break end # Trasporta il giocatore transfer_player # Quando non c'è un fade esce dal loop if $game_temp.transition_processing break end end # Aggiornamento Chipset @spriteset.update # Aggiornamento finestra dei messaggi @message_window.update # Aggiorna lo status dei personaggi if $game_temp.party_change_flag @battle_pg.refresh end @barre.refresh # Se c'è il gameover if $game_temp.gameover # Va alla scena del gameover $scene = Scene_Gameover.new return end # Se si deve tornare al title if $game_temp.to_title # Va alla scena del title $scene = Scene_Title.new return end # Quando c'è un fade if $game_temp.transition_processing # Elimina la variabile $game_temp.transition_processing = false # Fade if $game_temp.transition_name == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $game_temp.transition_name) end end # Quando c'è un messaggio if $game_temp.message_window_showing return end # Quando il contatore degli incontri è 0 e ci sono gruppi di mostri in lista if $game_player.encounter_count == 0 and $game_map.encounter_list != [] # Quando non c'è un evento o gli incontri non sono disabilitati unless $game_system.map_interpreter.running? or $game_system.encounter_disabled # Scelta del gruppo di nemici n = rand($game_map.encounter_list.size) troop_id = $game_map.encounter_list[n] # Se il gruppo è valido if $data_troops[troop_id] != nil # Chiama la battaglia $game_temp.battle_calling = true $game_temp.battle_troop_id = troop_id $game_temp.battle_can_escape = true $game_temp.battle_can_lose = false $game_temp.battle_proc = nil end end end #Quando B è premuto if Input.trigger?(Input::B) # Quando non c'è un evento o il menu non è disabilitato unless $game_system.map_interpreter.running? or $game_system.menu_disabled # Chiama menu $game_temp.menu_calling = true $game_temp.menu_beep = true end end # Quando è stato attivato il menu di battaglia if $game_temp.battle_menu_closed == false # Quando non c'è un evento o il menu non è disabilitato unless $game_system.map_interpreter.running? or $game_system.menu_disabled # Vai al battle menu $game_system.se_play($data_system.decision_se) @battle_menu.reinitialize(200, ["Attacca", "Magie/Tecniche", "Mystes", "Gambit", "Oggetti"]) @battle_menu.y = 480 - @battle_menu.height - 16 @battle_menu.visible = true @battle_menu.active = true @battle_menu.index = 0 @phase = 1 end end # Quando è attivo il debug e si preme F9 if $DEBUG and Input.press?(Input::F9) # Chiama il debug $game_temp.debug_calling = true end # Quando il giocatore non si è mosso unless $game_player.moving? # Controlla se c'è quancosa da chiamare if $game_temp.battle_calling call_battle elsif $game_temp.shop_calling call_shop elsif $game_temp.name_calling call_name elsif $game_temp.menu_calling call_menu elsif $game_temp.save_calling call_save elsif $game_temp.debug_calling call_debug end end end #-------------------------------------------------------------------------- # - Aggiornamento Menu di Battaglia #-------------------------------------------------------------------------- def update_battle_menu # Quando B è premuto if Input.trigger?(Input::B) # Suona SE Annulla $game_system.se_play($data_system.cancel_se) # Chiudi il menu @battle_menu.active = false @battle_menu.visible = false $game_temp.battle_menu_closed = true @phase = 0 end # Quando C è premuto if Input.trigger?(Input::C) # Scelta del comando da eseguire case @battle_menu.index when 0 # Attacca # Suona SE Azione $game_system.se_play($data_system.decision_se) # Vai al menu Magie/Tecniche @elenco = [] elenco_nomi = [] for i in $game_map.events.values if i.nemico? and i.in_chara_range?(5) @elenco.push(i) id_nemico = i.name.to_i elenco_nomi.push($data_enemies[id_nemico].name) end end if @elenco.empty? text = "Nessun bersaglio rilevato" @battle_menu.reinitialize(250, [text], Color.new(255, 100, 100, 255)) else @battle_menu.reinitialize(200, elenco_nomi) @curs.x = @elenco[@battle_menu.index].real_x / 4 - 25 @curs.y = @elenco[@battle_menu.index].real_y / 4 @curs.visible = true @curs.opacity = 255 event_id = @elenco[@battle_menu.index].id @target_stat.refresh(event_id) @target_stat.visible = true end @battle_menu.y = 480 - @battle_menu.height - 16 @battle_menu.index = 0 @phase = 3 when 1 # Magie/Tecniche # Suona SE Azione $game_system.se_play($data_system.decision_se) # Vai al menu Magie/Tecniche @battle_menu.reinitialize(200, ["Bianca", "Nera"]) @battle_menu.y = 480 - @battle_menu.height - 16 @battle_menu.index = 0 @phase = 2 when 2 end end end #-------------------------------------------------------------------------- # - Aggiornamento Magie/Tecniche #-------------------------------------------------------------------------- def update_magie_tecniche # Quando B è premuto if Input.trigger?(Input::B) # Suona SE Annulla $game_system.se_play($data_system.cancel_se) # Vai al menu di battaglia @battle_menu.reinitialize(200, ["Attacca", "Magie/Tecniche", "Mystes", "Gambit", "Oggetti"]) @battle_menu.y = 480 - @battle_menu.height - 16 @battle_menu.index = 0 @phase = 1 end # Quando C è premuto if Input.trigger?(Input::C) # Scelta del comando da eseguire #case @battle_menu.index #when 1 # Magie/Tecniche # Suona SE Azione $game_system.se_play($data_system.decision_se) # Chiudi il menu @battle_menu.active = false @battle_menu.visible = false $game_temp.battle_menu_closed = true @phase = 0 #end end end #-------------------------------------------------------------------------- # - Aggiornamento Selezione Bersaglio #-------------------------------------------------------------------------- def update_selezione_bersaglio unless @elenco.empty? pos_x = @elenco[@battle_menu.index].real_x / 4 -25 pos_y = @elenco[@battle_menu.index].real_y / 4 pos_x = pos_x - ($game_map.display_x / 4) pos_y = pos_y - ($game_map.display_y / 4) event_id = @elenco[@battle_menu.index].id @curs.stop_move if (@curs.x != pos_x or @curs.y != pos_y) and @curs.duration == 0 @curs.stop_move @curs.move(4, pos_x, pos_y, 255) @target_stat.refresh(event_id) end end # Quando B è premuto if Input.trigger?(Input::B) # Suona SE Annulla $game_system.se_play($data_system.cancel_se) # Vai al menu di battaglia @battle_menu.reinitialize(200, ["Attacca", "Magie/Tecniche", "Mystes", "Gambit", "Oggetti"]) @battle_menu.y = 480 - @battle_menu.height - 16 @battle_menu.index = 0 @curs.visible = false @target_stat.visible = false @phase = 1 end # Quando C è premuto if Input.trigger?(Input::C) unless @elenco.empty? @elenco[@battle_menu.index].animation_id = 7 enemy_id = $game_troop.che_nemico?(event_id) $game_troop.enemies[enemy_id].hp -= 300 if $game_troop.enemies[enemy_id].dead? Audio.se_play("Audio/SE/145-Support03.ogg", 80, 100) @elenco[@battle_menu.index].animation_id = 96 @elenco[@battle_menu.index].death end @curs.visible = false @battle_menu.active = false @battle_menu.visible = false @target_stat.visible = false $game_temp.battle_menu_closed = true @phase = 0 else $game_system.se_play($data_system.buzzer_se) end end end end class Scene_Map #-------------------------------------------------------------------------- # - Trasporto #-------------------------------------------------------------------------- def transfer_player # Elimina la variable $game_temp.player_transferring = false # Quando la mappa di destinazione è diversa da quella corrente if $game_map.map_id != $game_temp.player_new_map_id # Settaggio nuova mappa $game_map.setup($game_temp.player_new_map_id) end # Settaggio nuova posizione del giocatore $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y) $game_second_player.moveto($game_temp.player_new_x, $game_temp.player_new_y) $game_third_player.moveto($game_temp.player_new_x, $game_temp.player_new_y) # Settaggio della nuova direzione case $game_temp.player_new_direction when 2 # Giu $game_player.turn_down when 4 # Sinistra $game_player.turn_left when 6 # Destra $game_player.turn_right when 8 # Sù $game_player.turn_up end # Correzione posizione del giocatore $game_player.straighten # Aggiornamento Mappa $game_map.update # Creazione nuovo spriteset @spriteset.dispose @spriteset = Spriteset_Map.new # Quando c'è un fade if $game_temp.transition_processing # Elimina la variabile $game_temp.transition_processing = false # Fade Graphics.transition(20) end # Suona BGM e BGS automatici della mappa $game_map.autoplay # Resetta il frame Graphics.frame_reset # Aggiornamento Input Input.update end end ################### ############ XPML Definition ############### # by Rataime # ################### def XPML_read(markup,event_id,max_param_number=0) parameter_list = nil event=$game_map.events[event_id] return if event.list==nil for i in 0...event.list.size if event.list[i].code == 108 and event.list[i].parameters[0].downcase == "begin "+markup.downcase parameter_list = [] if parameter_list == nil for j in i+1...event.list.size if event.list[j].code == 108 parts = event.list[j].parameters[0].split if parts.size!=1 and parts[0].downcase!="begin" if parts[1].to_i!=0 or parts[1]=="0" parameter_list.push(parts[1].to_i) else parameter_list.push(parts[1]) end else return parameter_list end else return parameter_list end return parameter_list if max_param_number!=0 and j==i+max_param_number end end end return parameter_list end class Bitmap def draw_text_bordered(x, y, width, height, text, align = 0, color = Color.new(255, 255, 255, 255)) font.color.set(0, 0, 0, 100) draw_text(x-1, y-1, width, height, text, align) draw_text(x-1, y+1, width, height, text, align) draw_text(x+1, y-1, width, height, text, align) draw_text(x+1, y+1, width, height, text, align) draw_text(x-1, y, width, height, text, align) draw_text(x+1, y, width, height, text, align) draw_text(x, y-1, width, height, text, align) draw_text(x, y+1, width, height, text, align) font.color = color draw_text(x, y, width, height, text, align) end def draw_text_shadowed(x, y, width, height, text, align = 1, color = Color.new(255, 255, 255, 255)) font.color.set(100, 100, 100) draw_text(x+1, y+2, width, height, text, align) draw_text(x+2, y+1, width, height, text, align) draw_text(x+2, y+2, width, height, text, align) font.color.set(0, 0, 0) draw_text(x-1, y-1, width, height, text, align) draw_text(x-1, y+1, width, height, text, align) draw_text(x+1, y-1, width, height, text, align) draw_text(x+1, y+1, width, height, text, align) font.color = color draw_text(x, y, width, height, text, align) end endAspetto speranzoso domande o proposte! :°D
HandCursor.rar
FFXII_DK.txt
Hei, mitä kuuluu?
http://imagegen.last.fm/winterheadphones/recenttracks/5/Alato.gif
Link to comment
Share on other sites
Top Posters For This Question
25
5
5
6
Popular Days
Mar 14
11
Jul 17
10
Jul 16
8
Mar 12
7
Top Posters For This Question
Alato 25 posts
Neji 5 posts
Broly88 5 posts
marigno 6 posts
Popular Days
Mar 14 2007
11 posts
Jul 17 2007
10 posts
Jul 16 2007
8 posts
Mar 12 2007
7 posts
Posted Images
81 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now