FiaPlay

BossBar

Nov 9th, 2024 (edited)
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.17 KB | None | 0 0
  1. #------------------------------------------------------------------------------
  2. # Script creado por FiaPlay para Pokémon Essentials BES (Créditos si se usa)
  3. #------------------------------------------------------------------------------
  4. =begin Instrucciones de instalación
  5. Si actualizas desde una versión anterior es recomendable que repitas los pasos y compares con el código de una base limpia.
  6.  
  7. 1) En PokeBattle_Scene Busca:
  8. @sprites["battlebox1"]=PokemonDataBox.new(battle.battlers[1],battle.doublebattle,@viewport)
  9. y reemplázalo por:
  10.     if battle.rules["bossBar"]
  11.       @boss=getConst(BossBoxSetings,battle.rules["bossBar"])
  12.       case @boss["style"]
  13.       when ["EBS"]
  14.         @sprites["battlebox1"]=EBSBossBox.new(battle.battlers[1],@viewport)
  15.       else
  16.         c=@boss["basecolor"] || Color.new(0,128,0)
  17.         @sprites["battlebox1"]=BossDataBox.new(battle.battlers[1],c,@viewport)
  18.       end
  19.     else
  20.       @sprites["battlebox1"]=PokemonDataBox.new(battle.battlers[1],battle.doublebattle,@viewport)
  21.     end
  22.  
  23. 2) En PokeBattle_Scene Busca:
  24. @sprites["pokemon1"].tone.gray+=8 if @sprites["pokemon1"].tone.gray<0
  25. y debajo pon:
  26. @sprites["pokemon1"].tone=Tone.new(0,0,0,0) if @boss
  27.  
  28. 3) Crea un nuevo script encima de Main e inserta el scrip ahí.
  29.  
  30. 4) Descomprime este Zip en Graphics/Picturs/Battle:
  31. https://mega.nz/file/qM5SWD4C#6Lf-k5fK1JIqQ_c5txqi3uVp8-4GxloBV-WtefTkAhM
  32.  
  33. Instrucciones de uso:
  34.  
  35. 1) Crea los datos para cada barra en el módulo BossBoxSetings
  36.  
  37. 2) Antes del combate usa: setBattleRule("bossBar",:(Nombre de la contante)) #Los 2 puntos son necesarios
  38.  
  39. 3)Para un ejemplo Práctico usa:
  40. setBattleRule("bossBar",:Rayquaza)
  41. setBattleRule("bossBar",:Mewtwo)
  42. setBattleRule("bossBar",:Regidrago)
  43. setBattleRule("bossBar",:Reshiram)
  44. setBattleRule("bossBar",:BASIC)
  45. =end
  46.  
  47. module BossBoxSetings
  48.  
  49. Rayquaza = {
  50.   "name" => "Dios de los Cielos", #Nombre que se muestra sobre la barra
  51.   "basecolor" => Color.new(0,161,255), #Color principal de las letras y la barra de vida
  52.   "shadowcolor" => Color.new(0,126,199), #Color secundario de las letras
  53.   "alignment" => "left", #Alineación de la barra (por defecto está en el centro, Solo Standart)
  54. }
  55.  
  56. Mewtwo = {
  57.   "name" => "Genoma Alterado",
  58.   "basecolor" => Color.new(196,0,193),
  59.   "shadowcolor" => Color.new(125,7,125)
  60. }
  61.  
  62. Regidrago = {
  63.   "basecolor" => Color.new(204,0,193),
  64.   "shadowcolor" => Color.new(125,7,7),
  65.   "barsizeX" => 140, #Ancho de la barra (Por defecto es la misma que el texto, Solo Standart)
  66.   "barsizeY" => 10 , #Alto de la barra (Por defecto es 8, Solo Standart)
  67. }
  68.  
  69. Reshiram = {
  70.   "style" => "EBS", #Barra estilo EBS
  71.   "name" => "Deidad Ígnea",
  72.   "basecolor" => Color.new(233,233,233),
  73.   "shadowcolor" => Color.new(120,120,120), #Color secundario de la barra de vida
  74.   "showlevel" => true #Decide si mostrar o no el nivel(Solo EBS)
  75. }
  76.  
  77. BASIC = {} #No tocar este
  78. end
  79.  
  80.  
  81. #===============================================================================
  82. # Código común entre las barras de vida
  83. # Recomendable no tocar nada a partir de Aquí
  84. #===============================================================================
  85. module CustomDataBox
  86.   def exp
  87.     return 0
  88.   end
  89.  
  90.   def hp
  91.     return @animatingHP ? @currenthp : @battler.hp
  92.   end
  93.  
  94.   def animateHP(oldhp,newhp)
  95.     @starthp=oldhp
  96.     @currenthp=oldhp
  97.     @endhp=newhp
  98.     @animatingHP=true
  99.   end
  100.  
  101.   def animateEXP(oldexp,newexp)
  102.     @currentexp=oldexp
  103.     @endexp=newexp
  104.     @animatingEXP=true
  105.   end
  106.  
  107.   def update
  108.     super
  109.     @frame+=1
  110.     if @animatingHP
  111.       if @currenthp<@endhp
  112.         @currenthp+=[1,(@battler.totalhp/PokeBattle_SceneConstants::HPGAUGESIZE).floor].max
  113.         @currenthp=@endhp if @currenthp>@endhp
  114.       elsif @currenthp>@endhp
  115.         @currenthp-=[1,(@battler.totalhp/PokeBattle_SceneConstants::HPGAUGESIZE).floor].max
  116.         @currenthp=@endhp if @currenthp<@endhp
  117.       end
  118.       @animatingHP=false if @currenthp==@endhp
  119.       refresh
  120.     end
  121.     # Data box bobbing while Pokémon is selected
  122.     if ((@frame/10).floor&1)==1 && @selected==1   # Choosing commands for this Pokémon
  123.       self.y=@spriteY+2
  124.     elsif ((@frame/10).floor&1)==1 && @selected==2   # When targeted or damaged
  125.       self.y=@spriteY+2
  126.     end
  127.   end
  128. end
  129.  
  130.  
  131. #===============================================================================
  132. # Barra de vida de Jefes (Estilo FiaPlay)
  133. #===============================================================================
  134. class BossDataBox < SpriteWrapper
  135.   include CustomDataBox
  136.  
  137.   attr_reader :battler
  138.   attr_accessor :selected
  139.   attr_accessor :appearing
  140.   attr_reader :animatingHP
  141.   attr_reader :animatingEXP
  142.  
  143.   def initialize(battler,color,viewport=nil)
  144.     super(viewport)
  145.     @explevel=0
  146.     @battler=battler
  147.     @selected=0
  148.     @frame=0
  149.     @showexp=false
  150.     @animatingHP=false
  151.     @starthp=0
  152.     @currenthp=0
  153.     @endhp=0
  154.     @expflash=0
  155.     @color=color
  156.     @spriteY=2
  157.     @statuses=AnimatedBitmap.new(_INTL("Graphics/#{BATTLE_ROUTE}/battleBossStatuses"))
  158.     @contents=BitmapWrapper.new(512,62)
  159.     @boss=battler.battle.scene.boss
  160.     self.bitmap=@contents
  161.     self.visible=false
  162.     self.z=50
  163.     refresh
  164.   end
  165.  
  166.   def dispose
  167.     @statuses.dispose
  168.     @contents.dispose
  169.     super
  170.   end
  171.  
  172.   def appear
  173.     refresh
  174.     self.visible=true
  175.     self.opacity=255
  176.     self.y=@spriteY
  177.     self.x=0
  178.   end
  179.  
  180.   def refresh
  181.     self.bitmap.clear
  182.     return if !@battler.pokemon
  183.     base = @boss["basecolor"] || PokeBattle_SceneConstants::BOXTEXTBASECOLOR
  184.     shadow = @boss["shadowcolor"] || PokeBattle_SceneConstants::BOXTEXTSHADOWCOLOR
  185.     pokename = @boss["name"] || @battler.name
  186.     pbSetSystemFont(self.bitmap)
  187.     @sizeX = @boss["barsizeX"] || self.bitmap.text_size(pokename).width
  188.     textX = @boss["barsizeX"] ? (@sizeX-self.bitmap.text_size(pokename).width)/2 : 0
  189.     alignment = @boss["alignment"]
  190.     case alignment
  191.     when "left"
  192.       baseX=10
  193.     when "center" , nil
  194.       baseX=(512-@sizeX)/2
  195.     when "right"
  196.       baseX=502-@sizeX
  197.     end
  198.     textpos=[
  199.        [pokename,baseX+textX,4,false,base,shadow,PokeBattle_SceneConstants::DTBOX_OUTLINE]
  200.     ]
  201.     pbDrawTextPositions(self.bitmap,textpos)
  202.     if @battler.status>0
  203.       statusX = alignment=="right" ? -26 : @sizeX+4
  204.       self.bitmap.blt(baseX+statusX,16,@statuses.bitmap,
  205.          Rect.new(0,(@battler.status-1)*22,22,22))
  206.     end
  207.     hpGaugeSize=@sizeX
  208.     hpgauge=@battler.totalhp==0 ? 0 : (self.hp*hpGaugeSize/@battler.totalhp)
  209.     hpgauge=2 if hpgauge==0 && self.hp>0
  210.     # fill with black (shows what the HP used to be)
  211.     hpGaugeY=PokeBattle_SceneConstants::HPGAUGE_Y
  212.     # fill with HP color
  213.     barY = @boss["barsizeY"] || 8
  214.     self.bitmap.fill_rect(baseX,hpGaugeY-4,hpgauge,barY,@color)
  215.   end
  216. end
  217.  
  218. #===============================================================================
  219. # Barra de vida de Jefes (Estilo EBS)
  220. #===============================================================================
  221.  
  222. class EBSBossBox < SpriteWrapper
  223.   include CustomDataBox
  224.  
  225.   attr_reader :battler
  226.   attr_accessor :selected
  227.   attr_accessor :appearing
  228.   attr_reader :animatingHP
  229.   attr_reader :animatingEXP
  230.  
  231.   def initialize(battler,viewport=nil)
  232.     super(viewport)
  233.     @battler=battler
  234.     @selected=0
  235.     @frame=0
  236.     @starthp=0
  237.     @currenthp=0
  238.     @endhp=0
  239.     @databox=AnimatedBitmap.new("Graphics/#{BATTLE_ROUTE}/battleBossBoxEBS")
  240.     @spriteX=14
  241.     @spriteY=PokeBattle_SceneConstants::FOEBOXD1_Y
  242.     @statuses=AnimatedBitmap.new(_INTL("Graphics/#{BATTLE_ROUTE}/battleStatusesEBS"))
  243.     @contents=BitmapWrapper.new(@databox.width,@databox.height)
  244.     self.bitmap=@contents
  245.     self.visible=true
  246.     self.z=50
  247.     self.x=@spriteX
  248.     self.y=@spriteY
  249.     @boss=battler.battle.scene.boss
  250.     refresh
  251.   end
  252.  
  253.   def refresh
  254.     baseX=16
  255.     self.bitmap.clear
  256.     return if !@battler.pokemon
  257.     self.bitmap.blt(0,0,@databox.bitmap,Rect.new(0,0,@databox.width,@databox.height))
  258.     base = @boss["basecolor"] || PokeBattle_SceneConstants::BOXTEXTBASECOLOR
  259.     shadow=PokeBattle_SceneConstants::BOXTEXTSHADOWCOLOR
  260.     pokename = @boss["name"] || @battler.name
  261.     pbSetSmallFont(self.bitmap)
  262.     textpos=[
  263.        [pokename,baseX+40,8,false,base,shadow,true]
  264.     ]
  265.     genderX=self.bitmap.text_size(pokename).width
  266.     case @battler.displayGender
  267.     when 0 # Male
  268.       textpos.push([_INTL("♂"),genderX,6,false,Color.new(48,96,216),shadow,true])
  269.     when 1 # Female
  270.       textpos.push([_INTL("♀"),genderX,6,false,Color.new(248,88,40),shadow,true])
  271.     end
  272.     pbDrawTextPositions(self.bitmap,textpos)
  273.     textpos=[
  274.        [_INTL("Nv{1}",@battler.level),@databox.width-80,8,true,base,shadow,true]
  275.     ]
  276.     pbDrawTextPositions(self.bitmap,textpos) if @boss["showlevel"]
  277.     imagepos=[]
  278.     if @battler.isMega?
  279.       imagepos.push(["Graphics/#{BATTLE_ROUTE}/battleMegaEvoBox.png",baseX - 16, 7, 0, 0, -1, -1])
  280.     elsif @battler.isUltra?
  281.       imagepos.push(["Graphics/#{BATTLE_ROUTE}/battleUltraBurstBox.png",baseX- 16, 7, 0, 0, -1, -1])
  282.     elsif @battler.isPrimal?
  283.       imagepos.push(["Graphics/#{BATTLE_ROUTE}/battlePrimal#{PBSpecies.getName(@battler.species)}Box.png",baseX- 16, 7, 0, 0, -1, -1])
  284.     elsif @battler.isTera?
  285.       imagepos.push(["Graphics/Pictures/teraTypes.png",baseX - 16, 7,0,@battler.type1*32,32,32])
  286.     end
  287.     pbDrawImagePositions(self.bitmap,imagepos)
  288.     if @battler.status>0
  289.       self.bitmap.blt(160,48,@statuses.bitmap,
  290.          Rect.new(0,(@battler.status-1)*16,44,16))
  291.     end
  292.     hpGaugeSize=252
  293.     hpgauge=@battler.totalhp==0 ? 0 : (self.hp*hpGaugeSize/@battler.totalhp)
  294.     hpgauge=2 if hpgauge==0 && self.hp>0
  295.     hpzone=0
  296.     hpzone=1 if self.hp<=(@battler.totalhp/2).floor
  297.     hpzone=2 if self.hp<=(@battler.totalhp/4).floor
  298.     hpcolors=[
  299.        PokeBattle_SceneConstants::HPCOLORGREENDARK,
  300.        PokeBattle_SceneConstants::HPCOLORGREEN,
  301.        PokeBattle_SceneConstants::HPCOLORYELLOWDARK,
  302.        PokeBattle_SceneConstants::HPCOLORYELLOW,
  303.        PokeBattle_SceneConstants::HPCOLORREDDARK,
  304.        PokeBattle_SceneConstants::HPCOLORRED
  305.     ]
  306.     # fill with black (shows what the HP used to be)
  307.     hpGaugeX=PokeBattle_SceneConstants::HPGAUGE_X
  308.     hpGaugeY=PokeBattle_SceneConstants::HPGAUGE_Y
  309.     # fill with HP color
  310.     oc = @boss["shadowcolor"] || hpcolors[hpzone*2]
  311.     c = @boss["basecolor"] && @boss["shadowcolor"] ? base : [hpzone*2+1]
  312.     self.bitmap.fill_rect(48,40,hpgauge,2,oc)
  313.     self.bitmap.fill_rect(48,42,hpgauge,4,c)
  314.   end
  315.  
  316.   def dispose
  317.     @statuses.dispose
  318.     @contents.dispose
  319.     @databox.dispose
  320.     super
  321.   end
  322.  
  323.   def appear
  324.     refresh
  325.     self.visible=true
  326.     self.opacity=255
  327.   end
  328. end
  329.  
  330. class PokeBattle_Scene
  331.   attr_accessor :boss
  332.   def setBossBar(setings=:BASIC)
  333.     @sprites["battlebox1"].dispose
  334.     if setings
  335.       @boss=getConst(BossBoxSetings,setings)
  336.       case @boss["style"]
  337.       when ["EBS"]
  338.         @sprites["battlebox1"]=EBSBossBox.new(battle.battlers[1],@viewport)
  339.       else
  340.         @sprites["battlebox1"]=BossDataBox.new(@battle.battlers[1],@boss["basecolor"],@viewport)
  341.       end
  342.     else
  343.       @sprites["battlebox1"]=PokemonDataBox.new(battle.battlers[1],@battle.doublebattle,@viewport)
  344.     end
  345.     b = @sprites["battlebox1"]
  346.     b.appear
  347.   end
  348. end
  349.  
Add Comment
Please, Sign In to add comment