Advertisement
biward

[VXAce] BigFace

Oct 28th, 2013
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.95 KB | None | 0 0
  1. ################################################################################
  2. ############################## BIG FACE ########################################
  3. ################################################################################
  4. =begin
  5.  
  6.   Auteur : Biward
  7.   Version : 2.0
  8.   Fonctionne sur : VXAce
  9.   Date : 17/08/2013 16:47
  10.  
  11.   Ce script vous permet d'afficher des bigs faces dans vos messages, comme le
  12. Neo Message sur RPG Maker VX. Pour cela, vous avez uniquement besoin d'une
  13. variable.
  14.  
  15.   Pour l'utiliser correctement, suivez le tutoriel suivant.
  16.  
  17.   Il existe 4 commandes que vous allez pouvoir utiliser :
  18.   - bf_state(actor, number) :
  19.   cette commande va permettre de changer l'état du personnage "actor". L'image
  20. affichée sera cherchée dans le dossier Faces/Ralph/Ralph_number. Par exemple
  21.   Faces/Ralph/Ralph_1 si number = 1.
  22.  
  23.   - set_pnj_name("PNJ") :
  24.   cette commande permet de déterminer le nom du PNJ à qui on parle et donc à
  25.   l'image que le script va devoir chercher.
  26.  
  27.   - set_pnj_state(number) :
  28.   cette commande permet de déterminer l'état du PNJ à qui on parle et donc à
  29.   l'image que le script va devoir chercher.
  30.  
  31.   - reset_message :
  32.   cette commande permet de réinitialiser tous les paramètres. Cette commande est
  33.   nécessaire si vous ne voulez plus afficher de bigface sur les messages !
  34.  
  35. - type_bf(number)
  36.   cette commande permet de gérer le type d'affichage (qui est de base TYPE).
  37.   1 : fondu ; 2 : par les côtés ; 3 : par le bas
  38.  
  39. - reset_type
  40.   cette commande remet à zéro le type d'affichage qui sera à nouveau TYPE
  41.  
  42.   Suivez les exemples de la démo.
  43. =end
  44. module BI
  45.   module BF
  46.  
  47.   # Indiquez ici la variable qui va stocker l'ID du héro à afficher.
  48.     V1 = 1
  49.    
  50.     # Indiquez ici la position Y des faces :
  51.     # 416 = hauteur de la fenêtre
  52.     # 288 = hauteur de l'image dans la démo
  53.     POS_Y = 416 - 288
  54.    
  55.     # Indiquez ici le type d'affichage :
  56.     # 1 : fondu
  57.   # 2 : arrivé depuis les côtés
  58.     # 3 : arrivée d'en dessous
  59.     TYPE = 2
  60.    
  61.   end
  62. end
  63. ################################################################################
  64. ##### Début du script
  65. ################################################################################
  66. ### Cache
  67. # création des deux commandes de lecteur du fichier BF
  68. module Cache  
  69.   def self.bface(actor, number)
  70.     load_bitmap("Graphics/Faces/#{actor.name}/", "#{actor.name}_#{number}")
  71.   end  
  72.   def self.pbface(pnj, number)
  73.     load_bitmap("Graphics/Faces/#{pnj}/", "#{pnj}_#{number}")
  74.   end  
  75. end
  76.  
  77. ### Game_Interpreter
  78. # création des commandes
  79. class Game_Interpreter
  80.   def bf_state(actor, number)
  81.     $game_bf = Array.new if ! $game_bf
  82.     $game_bf[actor] = number
  83.   end    
  84.   def set_pnj_name(name)
  85.     $game_pnj = nil if ! $game_pnj
  86.     $game_pnj[0] = name.to_s
  87.   end  
  88.   def reset_message
  89.     $game_bf[$game_variables[BI::BF::V1]] = 0
  90.     $game_variables[BI::BF::V1] = 0
  91.     $game_pnj[0] = nil
  92.     $game_pnj[1] = 0
  93.   end  
  94.   def set_pnj_state(number)
  95.     $game_pnj[1] = number
  96.   end      
  97.   def update_conversation
  98.     $update_conv = true
  99.   end
  100.   def type_bf(number)
  101.     Spriteset_BigFace.type = number
  102.   end
  103.   def reset_type
  104.     Spriteset_BigFace.type = BI::BF::TYPE
  105.   end
  106. end
  107.  
  108. ### Scene_Title
  109. # création des variables au début du jeu
  110. class Scene_Title < Scene_Base
  111.   alias cng_bi command_new_game
  112.   def command_new_game
  113.     $game_bf = Array.new
  114.     $game_pnj = Array.new
  115.     $game_pnj[0] = nil
  116.     $game_pnj[1] = 0
  117.     $data_actors.size.times {$game_bf << 0 }
  118.     Spriteset_BigFace.type = BI::BF::TYPE
  119.     cng_bi
  120.   end
  121. end
  122.  
  123. ### Spriteset_Map
  124. # modification de certaines méthodes pour
  125. class Spriteset_Map
  126.   include BI::BF
  127.   alias ibi initialize
  128.   def initialize
  129.     create_bf
  130.     ibi
  131.   end  
  132.   def create_bf
  133.     @spritebf = Spriteset_BigFace.new
  134.   end  
  135.   def update_bf
  136.     @spritebf.update
  137.   end  
  138.   def update_conv
  139.     @spritebf.update_conv
  140.   end  
  141.   def dispose_bf
  142.     @spritebf.remove
  143.   end  
  144. end
  145.  
  146. ### Spriteset_BigFace
  147. # creation d'un nouveau spriteset pour la map
  148. class Spriteset_BigFace  
  149.   class << self
  150.     attr_accessor :type
  151.   end
  152.   def initialize
  153.     update
  154.   end  
  155.   def p_opacity
  156.     10.times do
  157.     @sprite.opacity += 25.5 if @sprite
  158.       @sprite2.opacity += 25.5 if @sprite2
  159.       Graphics.wait(1)
  160.     end
  161.   end  
  162.   def m_opacity
  163.     10.times do
  164.     @sprite.opacity -= 25.5 if @sprite
  165.       @sprite2.opacity -= 25.5 if @sprite2
  166.       Graphics.wait(1)
  167.     end
  168.   end  
  169.   def p_x
  170.     10.times do
  171.     @sprite.x += (@sprite.width.to_f - 40.0).to_f / 10 if @sprite.x < -40
  172.       @sprite2.x -= (@sprite2.width.to_f - 40.0).to_f / 10 if @sprite2.x > (Graphics.width - @sprite2.width + 40)
  173.       @sprite.x = -40.0 if @sprite.x > -40
  174.       @sprite2.x = (Graphics.width - @sprite2.width + 40) if @sprite2.x < (Graphics.width - @sprite2.width + 40)
  175.       Graphics.wait(1)
  176.     end
  177.   end  
  178.   def m_x
  179.     10.times do
  180.     @sprite.x -= (@sprite.width.to_f - 40.0).to_f / 10 if @sprite
  181.       @sprite2.x += (@sprite2.width.to_f - 40.0).to_f / 10 if @sprite2
  182.       Graphics.wait(1)
  183.     end
  184.   end  
  185.   def p_y
  186.     10.times do
  187.     @sprite.y -= (Graphics.height - BI::BF::POS_Y.to_f).to_f / 10 if @sprite.y > BI::BF::POS_Y
  188.       @sprite2.y -= (Graphics.height - BI::BF::POS_Y.to_f).to_f / 10 if @sprite2.y > BI::BF::POS_Y
  189.       @sprite.y = BI::BF::POS_Y if @sprite.y < BI::BF::POS_Y
  190.       @sprite2.y = BI::BF::POS_Y if @sprite2.y < BI::BF::POS_Y
  191.       Graphics.wait(1)
  192.     end
  193.   end  
  194.   def m_y
  195.     10.times do
  196.     @sprite.y += (Graphics.height - BI::BF::POS_Y.to_f) / 10 if @sprite
  197.       @sprite2.y += (Graphics.height - BI::BF::POS_Y.to_f) / 10 if @sprite2
  198.       Graphics.wait(1)
  199.     end
  200.     @sprite.y = Graphics.height if @sprite
  201.     @sprite2.y = Graphics.height if @sprite2
  202.   end  
  203.   def remove
  204.     @sprite.dispose
  205.     @sprite = nil
  206.   end  
  207.   def remove2
  208.     @sprite2.dispose
  209.     @sprite2 = nil
  210.   end  
  211.   def update
  212.     if $game_bf && $game_pnj
  213.       if $game_variables[BI::BF::V1] > 0 && $game_bf[$game_variables[BI::BF::V1]] > 0 && ! @sprite && $aff
  214.       @sprite = Sprite.new
  215.         @sprite.bitmap = Cache.bface($game_actors[$game_variables[BI::BF::V1]], $game_bf[$game_variables[BI::BF::V1]])
  216.         if Spriteset_BigFace.type == 1
  217.           @sprite.opacity = 0 if ! $update_conv
  218.           @sprite.x = -40
  219.           @sprite.y = BI::BF::POS_Y
  220.         elsif Spriteset_BigFace.type == 2
  221.           @sprite.x = -@sprite.width
  222.           @sprite.y = BI::BF::POS_Y
  223.       elsif Spriteset_BigFace.type == 3
  224.           @sprite.y = @sprite.height
  225.           @sprite.x = -40
  226.         end
  227.       end
  228.       if $game_pnj[0] != nil && $game_pnj[1] > 0 && $aff && ! @sprite2
  229.         @sprite2 = Sprite.new
  230.         @sprite2.bitmap = Cache.pbface($game_pnj[0], $game_pnj[1])
  231.         @sprite2.y = BI::BF::POS_Y
  232.         if Spriteset_BigFace.type == 1
  233.           @sprite.opacity = 0 if ! $update_conv
  234.           @sprite2.x = Graphics.width - @sprite2.width + 40
  235.         elsif Spriteset_BigFace.type == 2
  236.           @sprite2.x = Graphics.width
  237.         elsif Spriteset_BigFace.type == 3
  238.           @sprite2.y = Graphics.height
  239.           @sprite2.x = Graphics.width - @sprite2.width + 40
  240.         end
  241.       end
  242.       if @sprite || @sprite2
  243.         case Spriteset_BigFace.type
  244.         when 1
  245.           if @sprite.opacity < 255 || @sprite2.opacity < 255
  246.             p_opacity if ! $update_conv
  247.           end
  248.         when 2
  249.           if @sprite.x < -40 || @sprite2.x > (Graphics.width - @sprite2.width + 40)
  250.             p_x if ! $update_conv
  251.           end
  252.         when 3
  253.           if @sprite.y > BI::BF::POS_Y || @sprite2.y > BI::BF::POS_Y
  254.             p_y if ! $update_conv
  255.           end
  256.         end
  257.       end
  258.       if @sprite && ! $aff
  259.         m_opacity if Spriteset_BigFace.type == 1
  260.         m_x if Spriteset_BigFace.type == 2
  261.         m_y if Spriteset_BigFace.type == 3
  262.         remove
  263.       end
  264.       if @sprite2 && ! $aff
  265.         m_opacity if Spriteset_BigFace.type == 1
  266.         m_x if Spriteset_BigFace.type == 2
  267.         m_y if Spriteset_BigFace.type == 3
  268.         remove2
  269.       end
  270.     end
  271.   end    
  272.   def update_conv
  273.     remove
  274.     remove2
  275.     update
  276.     $update_conv = false
  277.   end    
  278. end
  279.  
  280. ### Scene_Map ###
  281. # ajout dans l'update
  282. # et recréation des variables si elles n'existent plus.
  283. class Scene_Map < Scene_Base
  284.   alias ubi update
  285.   def update
  286.     update_var
  287.     $aff = $game_message.visible
  288.     @spriteset.update_bf
  289.     @spriteset.update_conv if $update_conv
  290.     ubi
  291.   end
  292.  
  293.   def update_var
  294.     $game_bf = Array.new if ! $game_bf
  295.     if ! $game_pnj
  296.       $game_pnj = Array.new
  297.       $game_pnj[0] = nil
  298.       $game_pnj[1] = 0
  299.     end
  300.     Spriteset_BigFace.type = BI::BF::TYPE if ! Spriteset_BigFace.type
  301.     $data_actors.size.times {$game_bf << 0 }
  302.   end
  303. end
  304. ################################################################################
  305. ##### Fin du script
  306. ################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement