Pommes de vie

Publié le par Cidragon6

Voici un script fort utile. En effet, celui-ci va affiché en haut à gauche de votre écran de jeu des pommes qui indiqueront la vie du héros (comme dans Zelda en gros). 

Avant de vous livrer le code, voici comment le configurer :

Vous pouvez configurer le script à ces lignes :

#=== Options ===
corazones = 10
opacidad = 255
opcion = 2
#=== Options end ==

Corazones est le nombre de cœurs qui seront affichés. Opacidad correspond à l'opacité des cœurs (très visible ou transparent parexemple). Opcion c'est le texte qui est affiché en dessous des cœurs (1 = nom du héros, 2 = PV actuels ou max du héros, 3 = Nombre de cœurs pleins, 4 =% de vie, 5 = ne rien afficher).

Enfin, dans le script scène_map, en dessous de la ligne 15, rajoutez le bout de code suivant : 

@corazones = Window_Corazones.new

En dessous de la ligne 37, ce code :

@corazones.dispose

Enfin, en dessous de la ligne 75, ce code :

@corazones.refresh

Voici le code à mettre :



#==========================================
# Pommes de vie
#
# Script téléchargé sur www.rpg-creation.com
#
# Window_Corazones
# Par DarkRog
#-----------------------------------------
#==========================================

class Window_Corazones < Window_Base
def initialize
super(-8, -8, 640, 96)
#=== Options ===
corazones = 10
opacidad = 255
opcion = 2
#=== Options fin ==
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = $fontface
self.contents.font.size = $fontsize
self.opacity = 0
@hearts = corazones
@opacity = opacidad
@option = opcion
@hr = 0
refresh
end
#----------------------------------------
# - Actualisation
#----------------------------------------
def refresh
self.contents.clear
@n = $game_party.actors[0].hp
@mn = $game_party.actors[0].maxhp
#n is the value, and mn the maxvalue:
@hr = 0
@lh = 0
for i in 0..@hearts-1
self.contents.fill_rect(i*14, 4, 1, 2, Color.new(0, 0, 0, @opacity))
self.contents.fill_rect(i*14+1, 3, 1, 4, Color.new(0, 0, 0, @opacity))
self.contents.fill_rect(i*14+2, 2, 1, 6, Color.new(0, 0, 0, @opacity))
self.contents.fill_rect(i*14+3, 1, 1, 8, Color.new(0, 0, 0, @opacity))
self.contents.fill_rect(i*14+4, 0, 1, 10, Color.new(0, 0, 0, @opacity))
self.contents.fill_rect(i*14+5, 1, 1, 10, Color.new(0, 0, 0, @opacity))
self.contents.fill_rect(i*14+6, 2, 1, 10, Color.new(0, 0, 0, @opacity))
self.contents.fill_rect(i*14+7, 1, 1, 10, Color.new(0, 0, 0, @opacity))
self.contents.fill_rect(i*14+8, 0, 1, 10, Color.new(0, 0, 0, @opacity))
self.contents.fill_rect(i*14+9, 1, 1, 8, Color.new(0, 0, 0, @opacity))
self.contents.fill_rect(i*14+10, 2, 1, 6, Color.new(0, 0, 0, @opacity))
self.contents.fill_rect(i*14+11, 3, 1, 4, Color.new(0, 0, 0, @opacity))
self.contents.fill_rect(i*14+12, 4, 1, 2, Color.new(0, 0, 0, @opacity))
#
self.contents.fill_rect(i*14+1, 4, 1, 2, Color.new(255, 255, 255, @opacity))
self.contents.fill_rect(i*14+2, 3, 1, 4, Color.new(255, 255, 255, @opacity))
self.contents.fill_rect(i*14+3, 2, 1, 6, Color.new(255, 255, 255, @opacity))
self.contents.fill_rect(i*14+4, 1, 1, 8, Color.new(255, 255, 255, @opacity))
self.contents.fill_rect(i*14+5, 2, 1, 8, Color.new(255, 255, 255, @opacity))
self.contents.fill_rect(i*14+6, 3, 1, 8, Color.new(255, 255, 255, @opacity))
self.contents.fill_rect(i*14+7, 2, 1, 8, Color.new(255, 255, 255, @opacity))
self.contents.fill_rect(i*14+8, 1, 1, 8, Color.new(255, 255, 255, @opacity))
self.contents.fill_rect(i*14+9, 2, 1, 6, Color.new(255, 255, 255, @opacity))
self.contents.fill_rect(i*14+10, 3, 1, 4, Color.new(255, 255, 255, @opacity))
self.contents.fill_rect(i*14+11, 4, 1, 2, Color.new(255, 255, 255, @opacity))
#
#@c = 255
@l = @n*100/@mn
@ho = @l*@hearts
c_color(1)
self.contents.fill_rect(i*14+2, 4, 1, 2, Color.new(@c, 0, 0, @opacity))
c_color(2)
self.contents.fill_rect(i*14+3, 3, 1, 4, Color.new(@c, 0, 0, @opacity))
c_color(3)
self.contents.fill_rect(i*14+4, 2, 1, 6, Color.new(@c, 0, 0, @opacity))
c_color(4)
self.contents.fill_rect(i*14+5, 3, 1, 6, Color.new(@c, 0, 0, @opacity))
c_color(5)
self.contents.fill_rect(i*14+6, 4, 1, 6, Color.new(@c, 0, 0, @opacity))
c_color(6)
self.contents.fill_rect(i*14+7, 3, 1, 6, Color.new(@c, 0, 0, @opacity))
c_color(7)
self.contents.fill_rect(i*14+8, 2, 1, 6, Color.new(@c, 0, 0, @opacity))
c_color(8)
self.contents.fill_rect(i*14+9, 3, 1, 4, Color.new(@c, 0, 0, @opacity))
c_color(9)
self.contents.fill_rect(i*14+10, 4, 1, 2, Color.new(@c, 0, 0, @opacity))

@hr += 1
end
if @option == 1
self.contents.font.color.set(0, 0, 0)
self.contents.draw_text(0 - 1, 7 - 1, 160, 32, $game_party.actors[0].name, 0)
self.contents.draw_text(0 - 1, 7 + 1, 160, 32, $game_party.actors[0].name, 0)
self.contents.draw_text(0 + 1, 7 - 1, 160, 32, $game_party.actors[0].name, 0)
self.contents.draw_text(0 + 1, 7 + 1, 160, 32, $game_party.actors[0].name, 0)
self.contents.font.color = normal_color
self.contents.draw_text(0, 7, 160, 32, $game_party.actors[0].name, 0)
elsif @option == 2
self.contents.font.color.set(0, 0, 0)
self.contents.draw_text(0 - 1, 7 - 1, 160, 32, "#{@n}/#{@mn}", 0)
self.contents.draw_text(0 - 1, 7 + 1, 160, 32, "#{@n}/#{@mn}", 0)
self.contents.draw_text(0 + 1, 7 - 1, 160, 32, "#{@n}/#{@mn}", 0)
self.contents.draw_text(0 + 1, 7 + 1, 160, 32, "#{@n}/#{@mn}", 0)
self.contents.font.color = normal_color
self.contents.draw_text(0, 7, 160, 32, "#{@n}/#{@mn}", 0)
elsif @option == 3
self.contents.font.color.set(0, 0, 0)
self.contents.draw_text(0 - 1, 7 - 1, 160, 32, "#{@ho/100}/#{@hearts}", 0)
self.contents.draw_text(0 - 1, 7 + 1, 160, 32, "#{@ho/100}/#{@hearts}", 0)
self.contents.draw_text(0 + 1, 7 - 1, 160, 32, "#{@ho/100}/#{@hearts}", 0)
self.contents.draw_text(0 + 1, 7 + 1, 160, 32, "#{@ho/100}/#{@hearts}", 0)
self.contents.font.color = normal_color
self.contents.draw_text(0, 7, 160, 32, "#{@ho/100}/#{@hearts}", 0)
elsif @option == 4
self.contents.font.color.set(0, 0, 0)
self.contents.draw_text(0 - 1, 7 - 1, 160, 32, "#{@l}%", 0)
self.contents.draw_text(0 - 1, 7 + 1, 160, 32, "#{@l}%", 0)
self.contents.draw_text(0 + 1, 7 - 1, 160, 32, "#{@l}%", 0)
self.contents.draw_text(0 + 1, 7 + 1, 160, 32, "#{@l}%", 0)
self.contents.font.color = normal_color
self.contents.draw_text(0, 7, 160, 32, "#{@l}%", 0)
end
end

def c_color(a)
if @hr <= (@ho/100)-1
@c = 255
else
if @ho/10-@hr*10 >= a and @ho/10-@hr*10 <= 9

@c = 255
else
@c = 0
end
end
end

def corazones(corazones)
@hearts = corazones
end
end


Donc voilà, je ne l'ai pas testé mais il devrait marcher correctement...
Publicité

Publié dans Scripts RPG Makers XP

Pour être informé des derniers articles, inscrivez vous :
Commenter cet article
U
<br /> Ok sa joue pas de problème j'ai le temps alors contacte moi quand t'a le temps<br /> <br /> <br /> <br />
Répondre
U
<br /> Alors volontiers sa m'intéresserai vivement<br /> <br /> Vlà mon adresse mail : floflo12492@hotmail.com<br /> <br /> Contacte-moi quand tu peux.<br /> <br /> <br />
Répondre
C
<br /> Salut ! Dsl de ne voir ton commentaire que maintenant, j'ai eu des vacances assez mouvementées, et là j'suis super malade ! Pourtant j'suis à la fac, et j'ai un examen dans quelques minutes.Il faut<br /> trop trop froid !!!<br /> Je te contacte dès que j'ai le temps, tkt !<br /> <br /> <br />
U
<br /> Et mais c'est vrai que c'est simple... je ne mettais pas imaginé que l'on faisait comme ça..... tu m'a appris quelque chose aujourdhui ! je vais peut-être essayer...<br /> <br /> <br />
Répondre
C
<br /> Et je peux t'apprendre ce que tu veux d'autre ! En plus j'suis en vacances, et ça me "déverrouillera" ! Je n'ai pas pratiqué depuis des années, mais j'suis "presque" toujours aussi performant...<br /> <br /> <br />
U
<br /> Ce que je faisais en event n'était pas autant compliqué c'àtait assez simple. J'appellerai sa presque un tour de prestigitateur car on peut faire croire a un script complex ou une<br /> programmation ardue alors que ce n'est que du bidouillage d'évènement. Mais les chose comme le Moghmenu c'est trop dur a faire en event pour moi alors j'utilise le script.<br /> <br /> <br />
Répondre
C
<br /> <br /> Les menus personnalisés à la FF ? Ce n'est pas si compliqué ! lol<br /> <br /> <br /> En fait il suffit d'utiliser une variable (ou plusieurs), dont le nombre varie selon les touches directionnelles haut et bas. Selon le nombre de cette variable, la position d'une image<br /> (sélecteur, main ou autre...) varie. Ensuite, quand on appuie sur "entrée", il y a une vérification qui est faite : selon le nombre de la variable, il y a telle ou telle option.<br /> <br /> <br /> Voilà, c'est le principe de base ! Et pourtant j'ai rien programmé depuis des années !<br /> <br /> <br /> <br />
U
<br /> hahaah c'est bien vrai ! quand j'ai commençé rpg maker je faisait tous en event et c'était très bien !(surtout que je ne connaissais pas encore les scripts) d'ailleurs, mon jeu possède peut de<br /> scripts. Comme tu l'a dit, je trouve aussi que juste des copiez coller...... sa fait un peut perdre de l'autenticité a son jeu. Moi j'ai utilisé 3 script pour le jeu que je crée en ce moment. Sa ne<br /> fera pas beaucoup de nom a citer dans les crédits <br /> <br /> <br />
Répondre
C
<br /> Il faut savoir cumuler les évènements et les scripts. L'un ne doit pas éclipser l'autre. Dans un de mes jeux, Saviors, il y avait des évènements d'une extrême complexité, alliés à une vingtaine de<br /> scripts. On peut se servir du scrit des messages, et ceux qui rajoutent des menus ; je peux prendre l'exemple de l'alchimie, avec lequel on peut construire un objet qui est le seul à pouvoir tuer<br /> "le" boss indestructible d'une quête annexe.<br /> Mais question évènement, il y avait toujours des cinématiques complexes, des systèmes d'enchères à la Final Fantasy 9 ou d'autres trucs dont je n'ai plus le souvenir...<br /> <br /> <br />