RPG Creator : créez votre MMORPG ou RPG sans aucune connaissance en programmation


Disponible le 4 Juin !




- Jouez à votre jeu sur tablettes tactiles, Smartphones et navigateurs Web
- Personnalisez vos menus
- Dessinez facilement et rapidement vos cartes
- Créez des actions pour le combat A-RPG


www.rpgcreator.net


Heures au format UTC + 1 heure [ Heure d’été ]


Règles du forum


Consultez la liste des Scripts : cliquez ici



Publier un nouveau sujet Répondre au sujet  [ 3 messages ] 
Auteur Message
 Sujet du message: Amélioration menu objet v1.0
MessagePublié: 14 Juil 2010, 18:54 
Villageois (Nv 1)

Inscrit le: 12 Juil 2010, 20:09
Messages: 11
Sexe: Masculin
Points d'aide: 0/60

Créations :

Voir ses créations

PloPsoiR !
Voilà, j'ai à peu près terminé la première version de mon premier script... quel moment émouvant :') (ou pas)
Je trouvais le menu d'objets de base assez... basique. C'est pourquoi j'ai décidé de l'améliorer un peu.

Description

Un petit menu s'affiche lors de la sélection d'un objet et permet de faire les actions suivantes :
Utiliser (pour un objet)
Equiper (pour une arme/armure)
Jeter
Détails (Affiche une fenêtre détaillée avec les caractéristiques de l'objet)

Les informations détaillées se trouvent directement dans le script.

Screens
Le petit menu qui s'affiche
Image
La fenêtre "Détails"
Image
Pour un équipement, cela renvoie à la page Equipement.
Image

Démo
Demo du script, v1.0 -> La Démo !

Script

Créez un script au-dessus de Main, dans lesquels vous insérerez le code suivant (Désolé, ca passait pas avec la balise [ code]) :

#==============================================================================
# ▲ Fenêtre inventaire amélioré
#------------------------------------------------------------------------------
# Auteur : Protectator
# Version : 1.0
# Date : 15.07.2010
#------------------------------------------------------------------------------
# Ce script améliore la fenêtre d'inventaire dans le menu du groupe en y
# ajoutant certaines fonctions :
# ► Utiliser (Objet) / Equiper (Arme, Armure)
# - Dans le cas d'un objet, permet de l'utiliser normalement.
# - Dans le cas d'une arme ou d'une armure, le joueur sélectionne le héros
# à équiper, et l'amène directement dans la fenêtred d'équipement avec
# l'objet sélectionné.
# ► Jeter (Sauf objets non consommables)
# - Permet de jeter une certaine quantité d'un objet. Attention, pas de
# fenêtre de confirmation
# ► Détails
# - Ouvre une fenêtre indiquant les caractéristiques précises sur l'objet.
# Cette fenêtre est réglable plus loin dans le script.
#==============================================================================
# Il est possible que ce script soit incompatible avec certains autres.
#
# Ce script ajoute :
# Window_ItemAction
# Window_ItemDetails
# Window_ItemThrow
#
# Ce script modifie :
# Window_Target
# Scene_Item
# Scene_Equip

#***********************************
# ♦ Réglages de la fenêtre de détails
#
# Il est possible de modifier l'affichage des informations de la fenêtre de
# détails. Vous pouvez activer ou désactiver l'affichage de certaines
# caractéristiques dès la ligne 230 de ce script, vous y trouverez également des
# informations plus détaillées.
#***********************************

#==============================================================================
# ■ Window_ItemAction
#------------------------------------------------------------------------------
#  Fenêtre intervenant après le choix d'un item
# Auteur : Protectator
#==============================================================================

class Window_ItemAction < Window_Selectable
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize
super(0, 0, 128, 160)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.z += 10
@commands = ["Utiliser", "Jeter", "Détails", "Annuler"]
@item_max = @commands.size
@column_max = 1
@type = RPG::Item
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
y = i * 32
text_size = self.contents.text_size(@commands[i]).width
self.contents.draw_text(4, y, text_size, 32, @commands[i])
end
end
#--------------------------------------------------------------------------
# ● update_cursor_rect
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 32, self.width - 32, 32)
end
end
#--------------------------------------------------------------------------
# ● set_type
#--------------------------------------------------------------------------
def set_type(item)
@item = item
if item.is_a?(RPG::Item)
@commands = ["Utiliser", "Jeter", "Détails", "Annuler"]
else
@commands = ["Equiper", "Jeter", "Détails", "Annuler"]
end
refresh
end
end

#==============================================================================
# ■ Window_ItemThrow
#------------------------------------------------------------------------------
#  Fenêtre permettant de choisir la quantité à jeter d'un objet
# Auteur : Protectator
#==============================================================================

class Window_ItemThrow < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# digits_max : 桁数
#--------------------------------------------------------------------------
def initialize
@number = 0
# 数字の幅からカーソルの幅を計算 (0~9 は等幅と仮定)
dummy_bitmap = Bitmap.new(32, 32)
if dummy_bitmap.text_size("0").width < 8
size = 8
else
size = dummy_bitmap.text_size("0").width
end
@cursor_width = size + 8
dummy_bitmap.dispose
super(0, 0, 176, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.z += 20
@index = 1
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
# ● 数値の取得
#--------------------------------------------------------------------------
def number
return @number
end
#--------------------------------------------------------------------------
# ● 数値の設定
# number : 新しい数値
#--------------------------------------------------------------------------
def number=(number)
@number = [[number, 0].max, 10 ** 2 - 1].min
refresh
end
#--------------------------------------------------------------------------
# ● set_max
#--------------------------------------------------------------------------
def set_max(number)
@max = number
refresh
end
#--------------------------------------------------------------------------
# ● index=
#--------------------------------------------------------------------------
def index=(number)
@index = number
refresh
end
#--------------------------------------------------------------------------
# ● カーソルの矩形更新
#--------------------------------------------------------------------------
def update_cursor_rect
self.cursor_rect.set(@index * @cursor_width, 32, @cursor_width + 4, 32)
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update(max = 99)
super()
# 方向ボタンの上か下が押された場合
if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
# 現在の位の数字を取得し、いったん 0 にする
place = 10 ** (1 - @index)
n = @number / place % 10
@number -= n * place
# 上なら +1、下なら -1
n = (n + 1) % 10 if Input.repeat?(Input::UP)
n = (n + 9) % 10 if Input.repeat?(Input::DOWN)
# 現在の位の数字を再設定
@number += n * place
if @number > @max
@number = @max
end
refresh
end
# カーソル右
if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT)
$game_system.se_play($data_system.cursor_se)
@index = (@index + 1) % 2
end
update_cursor_rect
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
s = sprintf("%0*d", 2, @number)
self.contents.draw_text(4, 0, 144, 32, "Jeter combien ?")
for i in 0...2
self.contents.draw_text(i * @cursor_width + 4, 32, 64, 32, s[i,1])
end
end
end

#==============================================================================
# ■ Window_ItemDetails
#------------------------------------------------------------------------------
#  Fenêtre montrant tous les détails sur l'item
# Auteur : Protectator
#==============================================================================

class Window_ItemDetails < Window_Base
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize
super(0, 64, 640, 416)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.z += 20

#***********************************
# Modifications des infos présentes
#
# En-dessous de chaque description: "true" pour activer l'affichage
# "false" pour désactiver l'affichage
# Vous pouvez également changer les textes de la fenêtre détails à partir de
# la ligne 290

#****************************
# Choix des infos présentes *
#****************************

# Coloration des bonus de stats
@couleurs = true
# Affichage de la catégorie de l'objet
@activer_TYPE = true
# Affichage du prix de l'objet
@activer_PRIX = true
# Affichage du nombre d'exemplaires de l'objet possédés
@activer_NOMBRE = true


#****************************
# Objets uniquement

# Affichage de la portée (sur qui) des effets de l'objet
@item_PORTEE = true
# Affichage des conditions d'utilisation de l'objet (Combat, Carte ou Libre)
@item_OCCASION = true
# Affichage des effets de restauration de PV ou PM
@item_RESTAURE = true
# Affichage des effets de soin de statut
@item_SOIGNE_STATUT = true
# Affichage des effets d'attribution de statut
@item_INFLIGE_STATUT = false
# Affichage des effets de boost de caractéristique
@item_CARAC_BOOST = true


#****************************
# Armes uniquement

# Affichage de ou des élément(s) de l'arme
@arme_ELEMENT = true
# Affichage de la valeur d'Attaque de l'arme
@arme_ATTAQUE = true
# Affichage des effets de boost de caractéristique de l'arme
@arme_CARAC_BONUS = true

#****************************
# Armures uniquement

# Affichage des effets de boost de caractéristique de l'armure
@armure_CARAC_BONUS = true
# Affichage de la résistance aux éléments de l'armure
@armure_RES_ELEMENT = true
# Affichage de la résistance aux statuts de l'armure
@armure_RES_STATUT = true


#****************************
# Textes généraux

@texte_TYPE = "Catégorie"
@texte_DESCR = "Description "
@texte_PRIX = "Prix"
@texte_EFFETS = "Effets"
@texte_NOMBRE = "Possédé"

@texte_OBJET = "Objet"

@texte_SEPARATION = ", "

# Textes items
@texte_UTIL = "Utilisation"
@texte_PORTEE_0 = "Inutilisable"
@texte_PORTEE_1 = "1 ennemi"
@texte_PORTEE_2 = "Tous ennemis"
@texte_PORTEE_3 = "1 allié"
@texte_PORTEE_4 = "Tous alliés"
@texte_PORTEE_5 = "1 allié mort"
@texte_PORTEE_6 = "Tous alliés morts"
@texte_PORTEE_7 = "Utilisateur"
@texte_OCCASION_0 = "Libre"
@texte_OCCASION_1 = "En combat"
@texte_OCCASION_2 = "Hors combat"
@texte_OCCASION_3 = "Inutilisable"
@texte_RESTAURE = "Restaure "
@texte_INFLIGE = "Inflige "
@texte_SOIGNE = "Soigne "

# Textes armes
@texte_ELEMENT = "Element"
@texte_NOELEM = "Aucun"

# Textes armures
@texte_ESQ = "Esquive"
@texte_RES = "Résiste à "
@texte_RES_STATUT = "Résiste au statut "

# Couleurs
@couleur_bonus = Color.new(128, 255, 128, 255) # Couleur bonus
@couleur_malus = Color.new(255, 128, 128, 255) # Couleur malus
end
#--------------------------------------------------------------------------
# ● refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
rect = Rect.new(4, 32, self.width - 32, 32)
bitmap = RPG::Cache.icon(@item.icon_name)
case @item
when RPG::Item
type = @texte_OBJET
when RPG::Weapon
type = $data_system.words.weapon
when RPG::Armor
case @item.kind
when 0
type = $data_system.words.armor1
when 1
type = $data_system.words.armor2
when 2
type = $data_system.words.armor3
when 3
type = $data_system.words.armor4
end
end
self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.draw_text(28, 0, 212, 32, @item.name, 0)
# - - - Nombre - - -
if @activer_NOMBRE
self.contents.font.color = system_color
self.contents.draw_text(4, 32, 100, 32, @texte_NOMBRE, 0)
self.contents.font.color = normal_color
case @item
when RPG::Item
affiche = $game_party.item_number(@item.id)
when RPG::Weapon
affiche = $game_party.weapon_number(@item.id)
when RPG::Armor
affiche = $game_party.armor_number(@item.id)
end
self.contents.draw_text(104, 32, 32, 32, affiche.to_s, 2)
end
# - - - - - Effets - - - - -
self.contents.font.color = system_color
self.contents.draw_text(4, 96, 100, 32, @texte_EFFETS, 0)
self.contents.font.color = normal_color
y = 128
case @item
# Effets ITEMS
when RPG::Item
if @item_RESTAURE
if @item.recover_hp_rate != 0
affiche = @texte_RESTAURE + @item.recover_hp_rate.to_s + "% " +
$data_system.words.hp
self.contents.font.color = normal_color
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
if @item.recover_hp != 0
affiche = @texte_RESTAURE + " " + @item.recover_hp.to_s + " " +
$data_system.words.hp
self.contents.font.color = normal_color
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
if @item.recover_sp_rate != 0
affiche = @texte_RESTAURE + @item.recover_sp_rate.to_s + "% " +
$data_system.words.sp
self.contents.font.color = normal_color
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
if @item.recover_sp != 0
affiche = @texte_RESTAURE + " " + @item.recover_sp.to_s + " " +
$data_system.words.sp
self.contents.font.color = normal_color
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
end
if @item_SOIGNE_STATUT
if @item.minus_state_set.size > 0
affiche = @texte_SOIGNE
for i in 0...@item.minus_state_set.size
affiche += $data_states[@item.minus_state_set[i]].name
if i + 1 < @item.minus_state_set.size
affiche += ", "
end
end
self.contents.font.color = normal_color
self.contents.draw_text(4, y, 468, 32, affiche, 0)
y += 32
end
end
if @item_INFLIGE_STATUT
if @item.plus_state_set.size > 0
affiche = @texte_INFLIGE
for i in 0...@item.plus_state_set.size
affiche += $data_states[@item.plus_state_set[i]].name
if i + 1 < @item.plus_state_set.size
affiche += ", "
end
end
self.contents.font.color = normal_color
self.contents.draw_text(4, y, 468, 32, affiche, 0)
y += 32
end
end
if @item_CARAC_BOOST
if @item.parameter_type != 0 && @item.parameter_points != 0
if @item.parameter_points > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.parameter_points.to_s + " "
else
self.contents.font.color = @couleur_malus
affiche = @item.parameter_points.to_s + " "
end
case @item.parameter_type
when 1
affiche += $data_system.words.hp
when 2
affiche += $data_system.words.sp
when 3
affiche += $data_system.words.str
when 4
affiche += $data_system.words.dex
when 5
affiche += $data_system.words.agi
when 6
affiche += $data_system.words.int
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
end
# Effets ARMES
when RPG::Weapon
if @arme_ATTAQUE
affiche = $data_system.words.atk + " : " + @item.atk.to_s
self.contents.font.color = normal_color
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
if @arme_CARAC_BONUS
# bonus déf. phys.
if @item.pdef != 0
if @item.pdef > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.pdef.to_s + " " + $data_system.words.pdef
else
self.contents.font.color = @couleur_malus
affiche = @item.pdef.to_s + " " + $data_system.words.pdef
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
# bonus déf. mag.
if @item.mdef != 0
if @item.mdef > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.mdef.to_s + " " + $data_system.words.mdef
else
self.contents.font.color = @couleur_malus
affiche = @item.mdef.to_s + " " + $data_system.words.mdef
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
# bonus force
if @item.str_plus != 0
if @item.str_plus > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.str_plus.to_s + " " + $data_system.words.str
else
self.contents.font.color = @couleur_malus
affiche = @item.str_plus.to_s + " " + $data_system.words.str
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
# bonus dextérité
if @item.dex_plus != 0
if @item.dex_plus > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.dex_plus.to_s + " " + $data_system.words.dex
else
self.contents.font.color = @couleur_malus
affiche = @item.dex_plus.to_s + " " + $data_system.words.dex
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
# bonus agilité
if @item.agi_plus != 0
if @item.agi_plus > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.agi_plus.to_s + " " + $data_system.words.agi
else
self.contents.font.color = @couleur_malus
affiche = @item.agi_plus.to_s + " " + $data_system.words.agi
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
# bonus intelligence
if @item.int_plus != 0
if @item.int_plus > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.int_plus.to_s + " " + $data_system.words.int
else
self.contents.font.color = @couleur_malus
affiche = @item.int_plus.to_s + " " + $data_system.words.int
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
end
# Effets ARMURES
when RPG::Armor
if @armure_CARAC_BONUS
# bonus déf. phys.
if @item.pdef != 0
if @item.pdef > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.pdef.to_s + " " + $data_system.words.pdef
else
self.contents.font.color = @couleur_malus
affiche = @item.pdef.to_s + " " + $data_system.words.pdef
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
# bonus déf. mag.
if @item.mdef != 0
if @item.mdef > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.mdef.to_s + " " + $data_system.words.mdef
else
self.contents.font.color = @couleur_malus
affiche = @item.mdef.to_s + " " + $data_system.words.mdef
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
# bonus esquive
if @item.eva != 0
if @item.eva > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.eva.to_s + " " + @texte_ESQ
else
self.contents.font.color = @couleur_malus
affiche = @item.eva.to_s + " " + @texte_ESQ
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
# bonus force
if @item.str_plus != 0
if @item.str_plus > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.str_plus.to_s + " " + $data_system.words.str
else
self.contents.font.color = @couleur_malus
affiche = @item.str_plus.to_s + " " + $data_system.words.str
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
# bonus dextérité
if @item.dex_plus != 0
if @item.dex_plus > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.dex_plus.to_s + " " + $data_system.words.dex
else
self.contents.font.color = @couleur_malus
affiche = @item.dex_plus.to_s + " " + $data_system.words.dex
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
# bonus agilité
if @item.agi_plus != 0
if @item.agi_plus > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.agi_plus.to_s + " " + $data_system.words.agi
else
self.contents.font.color = @couleur_malus
affiche = @item.agi_plus.to_s + " " + $data_system.words.agi
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
# bonus intelligence
if @item.int_plus != 0
if @item.int_plus > 0
self.contents.font.color = @couleur_bonus
affiche = "+" + @item.int_plus.to_s + " " + $data_system.words.int
else
self.contents.font.color = @couleur_malus
affiche = @item.int_plus.to_s + " " + $data_system.words.int
end
self.contents.draw_text(4, y, 320, 32, affiche, 0)
y += 32
end
end
if @armure_RES_ELEMENT
if @item.guard_element_set.size > 0
affiche = @texte_RES
for i in 0...@item.guard_element_set.size
affiche += $data_system.elements[@item.guard_element_set[i]]
if i + 1 < @item.guard_element_set.size
affiche += ", "
end
end
self.contents.font.color = normal_color
self.contents.draw_text(4, y, 468, 32, affiche, 0)
y += 32
end
end
if @armure_RES_STATUT
if @item.guard_state_set.size > 0
affiche = @texte_RES_STATUT
for i in 0...@item.guard_state_set.size
affiche += $data_states[@item.guard_state_set[i]].name
if i + 1 < @item.guard_state_set.size
affiche += ", "
end
end
self.contents.draw_text(4, y, 468, 32, affiche, 0)
y += 32
end
end

end
# - - - - - Droite - - - - -
y = 0
# Affiche la catégorie
if @activer_TYPE
self.contents.font.color = system_color
text_size = self.contents.text_size(@texte_TYPE).width
if text_size > 100
text_size = 100
end
self.contents.draw_text(400, y, text_size, 32, @texte_TYPE, 0)
self.contents.font.color = normal_color
self.contents.draw_text(400 + text_size, y, 208 - text_size, 32, type, 2)
y += 32
end
# Affiche le prix
if @activer_PRIX
self.contents.font.color = system_color
text_size = self.contents.text_size(@texte_PRIX).width
if text_size > 100
text_size = 100
end
self.contents.draw_text(400, y, text_size, 32, @texte_PRIX, 0)
self.contents.font.color = normal_color
self.contents.draw_text(400 + text_size, y, 208 - text_size, 32,
@item.price.to_s, 2)
y += 32
end
# - - - - -
# Items
# - - - - -
case @item
when RPG::Item
# Affiche le mot "Utilisation" si besoin
if @item_PORTEE || @item_OCCASION
self.contents.font.color = system_color
text_size = self.contents.text_size(@texte_UTIL).width
if text_size > 100
text_size = 100
end
self.contents.draw_text(400, y, text_size, 32, @texte_UTIL, 0)
self.contents.font.color = normal_color
end
if @item_PORTEE
case @item.scope
when 0
portee = @texte_PORTEE_0
when 1
portee = @texte_PORTEE_1
when 2
portee = @texte_PORTEE_2
when 3
portee = @texte_PORTEE_3
when 4
portee = @texte_PORTEE_4
when 5
portee = @texte_PORTEE_5
when 6
portee = @texte_PORTEE_6
when 7
portee = @texte_PORTEE_7
end
self.contents.draw_text(400 + text_size, y, 208 - text_size, 32, portee,
2)
y += 32
end
if @item_OCCASION
case @item.occasion
when 0
occas = @texte_OCCASION_0
when 1
occas = @texte_OCCASION_1
when 2
occas = @texte_OCCASION_2
when 3
occas = @texte_OCCASION_3
end
self.contents.draw_text(400 + text_size, y, 208 - text_size, 32, occas,
2)
y += 32
end
# - - - - -
# Armes
# - - - - -
when RPG::Weapon
if @arme_ELEMENT
self.contents.font.color = system_color
text_size = self.contents.text_size(@texte_ELEMENT).width
if text_size > 100
text_size = 100
end
self.contents.draw_text(400, y, text_size, 32, @texte_ELEMENT, 0)
self.contents.font.color = normal_color
if @item.element_set.size == 0
self.contents.draw_text(400 + text_size, y, 208 - text_size, 32,
@texte_NOELEM, 2)
y += 32
else
for i in 0...@item.element_set.size
element = $data_system.elements[@item.element_set[i]]
self.contents.draw_text(400 + text_size, y, 208 - text_size, 32,
element, 2)
y += 32
end
end
end
end
end
#--------------------------------------------------------------------------
# ● set_item
#--------------------------------------------------------------------------
def set_item(item)
@item = item
end
end

#==============================================================================
# ■ Window_Target
#------------------------------------------------------------------------------
#  アイテム画面とスキル画面で、使用対象のアクターを選択するウィンドウです。
# Modifié par Protectator
#==============================================================================

class Window_Target < Window_Selectable
#--------------------------------------------------------------------------
# ● リフレッシュ
# Modifié par Protectator
#--------------------------------------------------------------------------
def refresh(item = nil)
self.contents.clear
for i in 0...$game_party.actors.size
x = 4
y = i * 116
actor = $game_party.actors[i]
self.contents.font.color = disabled_color
if (item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)) && item != nil
if actor.equippable?(item)
self.contents.font.color = normal_color
end
name_size = self.contents.text_size(actor.name).width
class_name = $data_classes[actor.class_id].name
class_size = self.contents.text_size(class_name).width
self.contents.draw_text(x, y, name_size, 32, actor.name, 0)
self.contents.draw_text(x + 144, y, class_size, 32, class_name, 0)
else
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 144, y)
end
draw_actor_level(actor, x + 8, y + 32)
draw_actor_state(actor, x + 8, y + 64)
draw_actor_hp(actor, x + 152, y + 32)
draw_actor_sp(actor, x + 152, y + 64)
end
end
end

#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
#  アイテム画面の処理を行うクラスです。
# Modifié par Protectator
#==============================================================================

class Scene_Item
#--------------------------------------------------------------------------
# ● メイン処理
# Modifié par Protectator
#--------------------------------------------------------------------------
def main
# ヘルプウィンドウ、アイテムウィンドウを作成
@help_window = Window_Help.new
@item_window = Window_Item.new
@action_window = Window_ItemAction.new
@details_window = Window_ItemDetails.new
@throw_window = Window_ItemThrow.new
# ヘルプウィンドウを関連付け
@item_window.help_window = @help_window
# ターゲットウィンドウを作成 (不可視・非アクティブに設定)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
@action_window.visible = false
@action_window.active = false
@details_window.visible = false
@details_window.active = false
@throw_window.visible = false
@throw_window.active = false
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画面を更新
Graphics.update
# 入力情報を更新
Input.update
# フレーム更新
update
# 画面が切り替わったらループを中断
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# ウィンドウを解放
@help_window.dispose
@item_window.dispose
@action_window.dispose
@throw_window.dispose
@details_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
# Modifié par Protectator
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@help_window.update
@item_window.update
@action_window.update
@details_window.update
@target_window.update
# アイテムウィンドウがアクティブの場合: update_item を呼ぶ
if @item_window.active
update_item
return
end
# Si la fenêtre d'action est active
if @action_window.active
update_action
return
end
# Si la fenêtre des jeterest active
if @throw_window.active
@throw_window.update
update_throw
return
end
# Si la fenêtre des détails est active
if @details_window.active
update_details
return
end
# ターゲットウィンドウがアクティブの場合: update_target を呼ぶ
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (アイテムウィンドウがアクティブの場合)
# Modifié par Protectator
#--------------------------------------------------------------------------
def update_item
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# メニュー画面に切り替え
$scene = Scene_Menu.new(0)
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムウィンドウで現在選択されているデータを取得
@item = @item_window.item
# 使用アイテムではない場合
# 決定 SE を演奏
# 効果範囲が味方の場合
if @item.is_a?(RPG::Item)
if @item.scope >= 3
# ターゲットウィンドウをアクティブ化
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@action_window.set_type(@item)
@details_window.set_item(@item)
@action_window.x = @item_window.index % 2 * 320 + 16
@action_window.y = @item_window.index / 2 * 32 + 112 -
(@item_window.index / 14) * 192
@throw_window.x = @item_window.index % 2 * 320 + 16 + 128
@throw_window.y = @item_window.index / 2 * 32 + 112 + 32 -
(@item_window.index / 14) * 192
@action_window.index = 0
@action_window.visible = true
@action_window.active = true
$game_system.se_play($data_system.decision_se)
# 効果範囲 (単体/全体) に応じてカーソル位置を設定
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# 効果範囲が味方以外の場合
else
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@item_window.draw_item(@item_window.index)
end
# マップ画面に切り替え
$scene = Scene_Map.new
return
else
$game_system.se_play($data_system.buzzer_se)
end
end
else
$game_system.se_play($data_system.decision_se)
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@action_window.set_type(@item)
@details_window.set_item(@item)
@action_window.x = @item_window.index % 2 * 320 + 16
@action_window.y = @item_window.index / 2 * 32 + 112 -
(@item_window.index / 14) * 192
@throw_window.x = @item_window.index % 2 * 320 + 16 + 128
@throw_window.y = @item_window.index / 2 * 32 + 112 + 32 -
(@item_window.index / 14) * 192
@action_window.index = 0
@action_window.visible = true
@action_window.active = true
@target_window.index = 0
end
return
end
end
#--------------------------------------------------------------------------
# ● update_action
# Auteur : Protectator
#--------------------------------------------------------------------------
def update_action
# Si le joueur revient en arrière
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# ターゲットウィンドウを消去
@item_window.active = true
@action_window.visible = false
@action_window.active = false
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
case @item
when RPG::Item
if $game_party.item_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
when RPG::Weapon
if $game_party.weapon_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
when RPG::Armor
if $game_party.armor_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
end
case @action_window.index
when 0
$game_system.se_play($data_system.decision_se)
@action_window.active = false
@target_window.active = true
@target_window.visible = true
@target_window.refresh(@item)
return
when 1
$game_system.se_play($data_system.decision_se)
@throw_window.refresh
case @item
when RPG::Item
@throw_window.set_max($game_party.item_number(@item.id))
when RPG::Weapon
@throw_window.set_max($game_party.weapon_number(@item.id))
when RPG::Armor
@throw_window.set_max($game_party.armor_number(@item.id))
end
@action_window.active = false
@throw_window.active = true
@throw_window.visible = true
return
when 2
$game_system.se_play($data_system.decision_se)
@details_window.refresh
@action_window.active = false
@details_window.active = true
@details_window.visible = true
return
when 3
$game_system.se_play($data_system.cancel_se)
@item_window.active = true
@action_window.visible = false
@action_window.active = false
return
end
end
end
#--------------------------------------------------------------------------
# ● update_throw
# Auteur : Protectator
#--------------------------------------------------------------------------
def update_throw
# Si le joueur revient en arrière
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# ターゲットウィンドウを消去
@action_window.active = true
@throw_window.visible = false
@throw_window.active = false
return
end
if Input.trigger?(Input::C)
@item_window.active = true
@action_window.visible = false
@action_window.active = false
@throw_window.visible = false
@throw_window.active = false
if @throw_window.number != 0
$game_system.se_play($data_system.escape_se)
case @item
when RPG::Item
$game_party.lose_item(@item.id, @throw_window.number)
when RPG::Weapon
$game_party.lose_weapon(@item.id, @throw_window.number)
when RPG::Armor
$game_party.lose_armor(@item.id, @throw_window.number)
end
@item_window.refresh
else
$game_system.se_play($data_system.cancel_se)
end
@throw_window.number = 0
@throw_window.index = 1
end
end
#--------------------------------------------------------------------------
# ● update_details
# Auteur : Protectator
#--------------------------------------------------------------------------
def update_details
# Si le joueur revient en arrière
if Input.trigger?(Input::B) || Input.trigger?(Input::C)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# ターゲットウィンドウを消去
@action_window.active = true
@details_window.visible = false
@details_window.active = false
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
# Modifié par Protectator
#--------------------------------------------------------------------------
def update_target
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# アイテム切れなどで使用できなくなった場合
unless $game_party.item_can_use?(@item.id)
# アイテムウィンドウの内容を再作成
@item_window.refresh
end
# ターゲットウィンドウを消去
@action_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムを使い切った場合
case @item
when RPG::Item
if $game_party.item_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
when RPG::Weapon
if $game_party.weapon_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
when RPG::Armor
if $game_party.armor_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
end
# ターゲットが全体の場合
if @target_window.index == -1
# パーティ全体にアイテムの使用効果を適用
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# ターゲットが単体の場合
if @target_window.index >= 0
if @item.is_a?(RPG::Item)
# ターゲットのアクターにアイテムの使用効果を適用
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
# Si ce n'est pas un objet
else
target = $game_party.actors[@target_window.index]
if target.equippable?(@item)
case @item
when RPG::Weapon
slot = 0
when RPG::Armor
slot = @item.kind + 1
end
$game_system.se_play($data_system.decision_se)
$scene = Scene_Equip.new(@target_window.index, slot, true, @item)
return
else
$game_system.se_play($data_system.buzzer_se)
end
end
end
# アイテムを使った場合
if used
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@item_window.draw_item(@item_window.index)
end
# ターゲットウィンドウの内容を再作成
@target_window.refresh(@item)
# 全滅の場合
if $game_party.all_dead?
# ゲームオーバー画面に切り替え
$scene = Scene_Gameover.new
return
end
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
# アイテムを使わなかった場合
unless used
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end

#==============================================================================
# ■ Scene_Equip
#------------------------------------------------------------------------------
#  装備画面の処理を行うクラスです。
# Modifié par Protectator
#==============================================================================

class Scene_Equip
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# forced : Active la fenêtre window_item par défaut à l'ouverture
# focus : RPG::Weapon ou RPG::Armor sur lequel placer le sélecteur
# Modifié par Protectator
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0, forced = false, focus = nil)
@actor_index = actor_index
@equip_index = equip_index
@forced = forced
@focus = focus
end
#--------------------------------------------------------------------------
# ● リフレッシュ
# Modifié par Protectator
#--------------------------------------------------------------------------
def refresh
# アイテムウィンドウの可視状態設定
@item_window1.visible = (@right_window.index == 0)
@item_window2.visible = (@right_window.index == 1)
@item_window3.visible = (@right_window.index == 2)
@item_window4.visible = (@right_window.index == 3)
@item_window5.visible = (@right_window.index == 4)
# 現在装備中のアイテムを取得
item1 = @right_window.item
# 現在のアイテムウィンドウを @item_window に設定
case @right_window.index
when 0
@item_window = @item_window1
when 1
@item_window = @item_window2
when 2
@item_window = @item_window3
when 3
@item_window = @item_window4
when 4
@item_window = @item_window5
end
# ライトウィンドウがアクティブの場合
if @forced
@right_window.active = false
@item_window.active = true
@item_window.index = 0
@forced = false
if @focus
case @focus
when RPG::Weapon
for i in 0...$game_party.weapon_number(@focus.id)
if @focus.id == @item_window.item.id
break
end
@item_window.index += 1
end
when RPG::Armor
for i in 0...$game_party.armor_number(@focus.id)
if @focus.id == @item_window.item.id
break
end
@item_window.index += 1
end
end
end
end
if @right_window.active
# 装備変更後のパラメータを消去
@left_window.set_new_parameters(nil, nil, nil)
end
# アイテムウィンドウがアクティブの場合
if @item_window.active
# 現在選択中のアイテムを取得
item2 = @item_window.item
# 装備を変更
last_hp = @actor.hp
last_sp = @actor.sp
@actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
# 装備変更後のパラメータを取得
new_atk = @actor.atk
new_pdef = @actor.pdef
new_mdef = @actor.mdef
# 装備を戻す
@actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
@actor.hp = last_hp
@actor.sp = last_sp
# レフトウィンドウに描画
@left_window.set_new_parameters(new_atk, new_pdef, new_mdef)
end
end
end
Commentaire
Voilà donc mon first script, mais j'en suis assez content :)
Si quelqu'un veut lire un peu ça, me dire si y'a des trucs un peu bizarres, ou si j'aurais pu faire plus simple par exemple... je suis vraiment preneur. Le script fonctionne, mais j'ai pas tout à fait l'impression d'avoir codé au plus simple ni au plus clair ^^' Si vous voulez que je commente mon code partiellement ou totalement, ou que je vous dise où sont les modifications dans les deux scripts que j'ai touchés, pas de problème. J'aimerais m'améliorer et je ferai le nécessaire, c'est pour ca que je ne refuse pas un peu d'aide et d'intérêt ;)
Et il va sans dire que je suis naturellement ouvert aux remarques, commentaires, avis et autres propositions...
Merci !


Haut
 Profil  
 
 Sujet du message: Re: Amélioration menu objet v1.0
MessagePublié: 19 Juil 2010, 10:18 
Villageois (Nv 1)

Inscrit le: 12 Juil 2010, 20:09
Messages: 11
Sexe: Masculin
Points d'aide: 0/60

Créations :

Voir ses créations

Hm, 67 vues et pas un seul retour ? Je pense quand même que certains ont du l'essayer, non ? :lol:
Je demande pas grand chose, juste savoir si vous avez des remarques à faire dessus, est-ce qu'il y a des bugs/incompatibilités avec beaucoup d'autres scripts ou si vous avez d'autres idées pour améliorer le script... merci :)


Haut
 Profil  
 
 Sujet du message: Re: Amélioration menu objet v1.0
MessagePublié: 07 Fév 2011, 12:35 
Villageois (Nv 1)

Inscrit le: 08 Aoû 2008, 00:00
Messages: 17
Points d'aide: 0/60

Créations :

Voir ses créations

Bon, sorry pour le nécro post.

J'ai tester, et j'aime beaucoup.
Mais j'ai copier le gros pavé de code que tu nous a donné, et cela ne fonctionne pas sur tout les objets chez moi... Certain ne fond même pas apparaitre la page.
Enfin bon. Je vais tester avec les trois codes de la démo, se serra surement mieux.

En tout cas, merci, parce que pour un inventaire limité, c'est très utile de virer quelques objets quand on à plus de place.


Haut
 Profil  
 
Afficher les messages depuis:  Trier par  
Publier un nouveau sujet Répondre au sujet  [ 3 messages ] 

Heures au format UTC + 1 heure [ Heure d’été ]


Qui est en ligne ?

Utilisateurs parcourant actuellement ce forum : Aucun utilisateur inscrit et 1 invité


Vous ne pouvez pas publier de nouveaux sujets dans ce forum
Vous ne pouvez pas répondre aux sujets dans ce forum
Vous ne pouvez pas éditer vos messages dans ce forum
Vous ne pouvez pas supprimer vos messages dans ce forum
Vous ne pouvez pas insérer de pièces jointes dans ce forum

Rechercher pour:
Sauter vers:  
cron
RPG Creative Forum version 5 ; Tous droits réservés
phpBB Group (Traduit par Xaphos)
Optimisé pour une résolution 1024*728