Advertisement
TechSkylander1518

Medical Summary Script

Mar 4th, 2021 (edited)
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.47 KB | None | 0 0
  1. #The Pokemon for each case
  2. Patients = [
  3. :SKITTY,
  4. :PIKACHU,
  5. :ZWEILOUS,
  6. :DITTO,
  7. :GOTHITELLE
  8. ]
  9.  
  10. #The levels of the patients
  11. #(mostly done to avoid errors when generating the Pokemon)
  12. PatientLevels = [
  13. 10,
  14. 10,
  15. 10,
  16. 10,
  17. 10,
  18. 10
  19. ]
  20.  
  21. #The genders of the patients
  22. #0-male, 1-female, 2 to randomize
  23. PatientGenders = [
  24. 2,
  25. 2,
  26. 2,
  27. 2,
  28. 2,
  29. 2
  30. ]
  31.  
  32.  
  33. #The variables for each stat
  34. MedicalVars = [
  35. 131,#Voltage
  36. 132,#Psychic Energy
  37. 133,#Blood Pressure
  38. 134,#Heart Rate
  39. 135,#Temperature
  40. 136,#Memo
  41. 137#Energy
  42. ]
  43.  
  44. #The maximum energy for each case
  45. MaxEnergy = [
  46. 10,#Case1
  47. 10,#Case2
  48. 10,#Case3
  49. 10,#Case4
  50. 10#Case5
  51. ]
  52.  
  53. #The maximum comfort for each case
  54. MaxComfort = [
  55. 10,#Case1
  56. 10,#Case2
  57. 10,#Case3
  58. 10,#Case4
  59. 10#Case5
  60. ]
  61.  
  62. #for setting blood pressure- use bloodPress("text")
  63. def bloodPress(text=nil)
  64.   $game_variables[MedicalVars[2]]=text
  65. end
  66.  
  67.  
  68. #for setting memo- use memo("Text")
  69. def memo(text=nil)
  70.   $game_variables[MedicalVars[5]]=text
  71. end
  72.  
  73. #For clearing the stats after a case
  74. def clearStats
  75.   for i in 0...MedicalVars.length
  76.     var=MedicalVars[i]
  77.     $game_variables[var]=nil
  78.   end
  79. end
  80.  
  81.  
  82. #For getting the current patient.
  83. #This saves a Pokemon to a variable so the gender stays the same.
  84. def genPatient
  85.   caseno=getCase
  86.   pkmn=pbGenPkmn(Patients[caseno],PatientLevels[caseno])
  87.   pkmn.makeNotShiny
  88.   if PatientGenders[caseno]==0
  89.     pkmn.makeMale
  90.   elsif PatientGenders[caseno]==1
  91.     pkmn.makeFemale
  92.   end
  93.   $game_variables[1]=pkmn
  94. end
  95.  
  96. #Should be run after the end of each case
  97. def newCase
  98.   clearStats
  99.   genPatient
  100. end
  101.  
  102. def medSum
  103.    # oldsprites = pbFadeOutAndHide(@sprites)
  104.     scene = PokemonMedSummary_Scene.new
  105.     screen = PokemonMedSummaryScreen.new(scene)
  106.     screen.pbStartMedScreen
  107.     yield if block_given?
  108.     pbFadeInAndShow(@sprites)#,oldsprites)
  109. end
  110.  
  111. class PokemonMedSummary_Scene
  112.   def pbUpdate
  113.     pbUpdateSpriteHash(@sprites)
  114.   end
  115.  
  116.   def pbStartMedScene
  117.     caseno=getCase
  118.     @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
  119.     @viewport.z = 99999
  120.     caseno=getCase
  121.     @pokemon   = $game_variables[1]
  122.     @page = 1
  123.     @typebitmap    = AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
  124.     @sprites = {}
  125.     @sprites["background"] = IconSprite.new(0,0,@viewport)
  126.     case caseno
  127.       when 2
  128.         @sprites["patient"] = AnimatedSprite.new("Graphics/Pictures/Medical Summary/patient_2",2,192,192,3,@viewport)
  129.       when 3
  130.         @sprites["patient"] = AnimatedSprite.new("Graphics/Pictures/Medical Summary/patient_3",4,192,192,10,@viewport)
  131.       else
  132.         @sprites["patient"] = IconSprite.new(104,186,@viewport)
  133.         @sprites["patient"].setBitmap("Graphics/Pictures/Medical Summary/patient_#{caseno}")
  134.       end
  135.     @sprites["patient"].oy = 96
  136.     @sprites["patient"].ox = 96
  137.     @sprites["patient"].x=104
  138.     @sprites["patient"].y=186
  139.     if @sprites["patient"].is_a?(AnimatedSprite)
  140.         @sprites["patient"].play
  141.     end
  142.     # skitty
  143.     case caseno
  144.       when 2
  145.         @sprites["xray"] = IconSprite.new(-35,114,@viewport)
  146.         @sprites["xray"].setBitmap("Graphics/Pictures/Medical Summary/xray_2")
  147.         @sprites["xray"].src_rect.width=247
  148.         @sprites["xray"].src_rect.height=142
  149.       else
  150.         @sprites["xray"] = IconSprite.new(-2,114,@viewport)
  151.         @sprites["xray"].setBitmap("Graphics/Pictures/Medical Summary/xray_#{caseno}")
  152.         @sprites["xray"].src_rect.width=204
  153.         @sprites["xray"].src_rect.height=142
  154.       end
  155.     @sprites["xray"].visible = false
  156.     @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
  157.     pbSetSystemFont(@sprites["overlay"].bitmap)
  158.     @sprites["movesel"] = MoveSelectionSprite.new(@viewport)
  159.     @sprites["movesel"].visible = false
  160.     @sprites["uparrow"] = AnimatedSprite.new("Graphics/Pictures/uparrow",8,28,40,2,@viewport)
  161.     @sprites["uparrow"].x = 350
  162.     @sprites["uparrow"].y = 56
  163.     @sprites["uparrow"].play
  164.     @sprites["uparrow"].visible = false
  165.     @sprites["downarrow"] = AnimatedSprite.new("Graphics/Pictures/downarrow",8,28,40,2,@viewport)
  166.     @sprites["downarrow"].x = 350
  167.     @sprites["downarrow"].y = 260
  168.     @sprites["downarrow"].play
  169.     @sprites["downarrow"].visible = false
  170.     @sprites["messagebox"] = Window_AdvancedTextPokemon.new("")
  171.     @sprites["messagebox"].viewport       = @viewport
  172.     @sprites["messagebox"].visible        = false
  173.     @sprites["messagebox"].letterbyletter = true
  174.     pbBottomLeftLines(@sprites["messagebox"],2)
  175.     drawMedPage(@page)
  176.     pbFadeInAndShow(@sprites) { pbUpdate }
  177.   end
  178.  
  179.   def pbEndScene
  180.     pbFadeOutAndHide(@sprites) { pbUpdate }
  181.     pbDisposeSpriteHash(@sprites)
  182.     @typebitmap.dispose
  183.     @viewport.dispose
  184.   end
  185.  
  186.  
  187.   def drawMedPage(page)
  188.     overlay = @sprites["overlay"].bitmap
  189.     overlay.clear
  190.     base   = Color.new(248,248,248)
  191.     shadow = Color.new(104,104,104)
  192.     # Set background image
  193.     @sprites["background"].setBitmap("Graphics/Pictures/Medical Summary/bgmed_#{page}")
  194.     imagepos=[]
  195.     # Show the Poké Ball containing the Pokémon
  196.     ballimage = sprintf("Graphics/Pictures/Summary/icon_ball_%02d",@pokemon.ballused)
  197.     imagepos.push([ballimage,14,52])
  198.     # Show status/fainted/Pokérus infected icon
  199.     status = -1
  200.     status = 6 if @pokemon.pokerusStage==1
  201.     status = @pokemon.status-1 if @pokemon.status>0
  202.     status = 5 if @pokemon.hp==0
  203.     if status>=0
  204.       imagepos.push(["Graphics/Pictures/statuses",124,100,0,16*status,44,16])
  205.     end
  206.     # Show Pokérus cured icon
  207.     if @pokemon.pokerusStage==2
  208.       imagepos.push([sprintf("Graphics/Pictures/Summary/icon_pokerus"),176,100])
  209.     end
  210.     # Show shininess star
  211.     if @pokemon.shiny?
  212.       imagepos.push([sprintf("Graphics/Pictures/shiny"),2,134])
  213.     end
  214.     caseno=getCase
  215.     #create energy bar
  216.     energy=$game_variables[StatVariables[0]]
  217.     w = (energy*200)/MaxEnergy[caseno]
  218.     w = 1 if w<1
  219.     w = ((w/2).round)*2
  220.     zone=1
  221.     imagepos.push(["Graphics/Pictures/Medical Summary/overlay_stats",4,300,0,zone*6,w,6])
  222.     #create comfort bar
  223.     comfort=$game_variables[StatVariables[2]]
  224.     w = (comfort*200)/MaxComfort[caseno]
  225.     w = 1 if w<1
  226.     w = ((w/2).round)*2
  227.     zone=3
  228.     imagepos.push(["Graphics/Pictures/Medical Summary/overlay_stats",4,364,0,zone*6,w,6])
  229.     # Draw all images
  230.     pbDrawImagePositions(overlay,imagepos)
  231.     # Write various bits of text
  232.     pagename = [_INTL("OBSERVATIONS"),
  233.                 _INTL("VITALS")
  234.                 ][page-1]
  235.     textpos = [
  236.        [pagename,26,16,0,base,shadow],
  237.        [@pokemon.name,46,54,0,base,shadow],
  238.        [_INTL("ENERGY:"),126,264,1,base,shadow],
  239.        [_INTL("COMFORT:"),126,328,1,base,shadow],
  240.        [_INTL("{1}",energy),146,264,0,base,shadow],
  241.        [_INTL("{1}",comfort),146,328,0,base,shadow],
  242.        [@pokemon.level.to_s,46,84,0,Color.new(64,64,64),Color.new(176,176,176)]
  243.     ]
  244.     # Write the gender symbol
  245.     if @pokemon.male?
  246.       textpos.push([_INTL("♂"),178,54,0,Color.new(24,112,216),Color.new(136,168,208)])
  247.     elsif @pokemon.female?
  248.       textpos.push([_INTL("♀"),178,54,0,Color.new(248,56,32),Color.new(224,152,144)])
  249.     end
  250.     # Draw all text
  251.     pbDrawTextPositions(overlay,textpos)
  252.     # Draw page-specific information
  253.     case page
  254.     when 1; drawMedPageOne
  255.     when 2; drawMedPageTwo
  256.     end
  257.   end
  258.  
  259.   def drawMedPageOne
  260.     overlay = @sprites["overlay"].bitmap
  261.     base   = Color.new(248,248,248)
  262.     shadow = Color.new(104,104,104)
  263.     imagepos = []
  264.     # Draw all images
  265.     pbDrawImagePositions(overlay,imagepos)
  266.     #draw observations
  267.     memo=$game_variables[MedicalVars[5]]
  268.     if memo.is_a?(String)
  269.       drawFormattedTextEx(overlay,232,78,273,memo)
  270.      end
  271.   end
  272.  
  273.  
  274.   def drawMedPageTwo
  275.     overlay = @sprites["overlay"].bitmap
  276.     base   = Color.new(248,248,248)
  277.     shadow = Color.new(104,104,104)
  278.     base2 = Color.new(64,64,64)
  279.     shadow2 = Color.new(176,176,176)
  280.     ysel=0
  281.     #get the stats
  282.     voltage=$game_variables[MedicalVars[0]]
  283.     psychic=$game_variables[MedicalVars[1]]
  284.     bloodpress=$game_variables[MedicalVars[2]]
  285.     heartrate=$game_variables[MedicalVars[3]]
  286.     temperature=$game_variables[MedicalVars[4]]
  287.     # Write stats and draw bars for them
  288.     textpos = [
  289.     ]
  290.     imagepos = [
  291.     ]
  292.     if temperature!=0
  293.       textpos.push([_INTL("TEMPERATURE"),248,(76+44*ysel),0,base,shadow])
  294.       textpos.push([_INTL("{1}°",temperature),486,(76+44*ysel),1,base2,shadow2])
  295.       w = temperature*2
  296.       zone = 2
  297.       imagepos.push(["Graphics/Pictures/Medical Summary/overlay_stats",248,(110+44*ysel),0,zone*6,w,6])
  298.       ysel+=1
  299.     end
  300.     if heartrate!=0
  301.       textpos.push([_INTL("HEART RATE"),248,(76+44*ysel),0,base,shadow])
  302.       textpos.push([_INTL("{1} bpm",heartrate),486,(76+44*ysel),1,base2,shadow2])
  303.       ysel+=1
  304.     end
  305.     if bloodpress!=0
  306.       textpos.push([_INTL("BLOOD PRESS"),248,(76+44*ysel),0,base,shadow])
  307.       textpos.push([_INTL("{1}",bloodpress),486,(76+44*ysel),1,base2,shadow2])
  308.       ysel+=1
  309.     end
  310.     if psychic!=0
  311.       textpos.push([_INTL("PSYCHIC ENERGY"),248,(76+44*ysel),0,base,shadow])
  312.       textpos.push([_INTL("{1}",psychic),486,(76+44*ysel),1,base2,shadow2])
  313.       w = psychic*2
  314.       zone = 3
  315.       imagepos.push(["Graphics/Pictures/Medical Summary/overlay_stats",248,(110+44*ysel),0,zone*6,w,6])
  316.       ysel+=1
  317.     end
  318.     if voltage!=0
  319.       textpos.push([_INTL("VOLTAGE"),248,(76+44*ysel),0,base,shadow])
  320.       textpos.push([_INTL("{1}",voltage),486,(76+44*ysel),1,base2,shadow2])
  321.       w = voltage*2
  322.       zone = 1
  323.       imagepos.push(["Graphics/Pictures/Medical Summary/overlay_stats",248,(110+44*ysel),0,zone*6,w,6])
  324.       ysel+=1
  325.     end
  326.     # Draw all text and images
  327.     pbDrawTextPositions(overlay,textpos)
  328.     pbDrawImagePositions(overlay,imagepos)
  329.   end
  330.  
  331.  
  332.   def pbMedScene
  333.     pbPlayCry(@pokemon)
  334.     loop do
  335.       Graphics.update
  336.       Input.update
  337.       pbUpdate
  338.       dorefresh = false
  339.       if Input.trigger?(Input::A)
  340.         pbSEStop
  341.         pbPlayCry(@pokemon)
  342.       elsif Input.trigger?(Input::B)
  343.         pbPlayCloseMenuSE
  344.         break
  345.       #Xray switching
  346.       elsif Input.trigger?(Input::TAB) && $game_switches[149]==true
  347.         pbSEPlay("GUI summary change page")
  348.           if  @sprites["xray"].visible == false
  349.           @sprites["patient"].visible = false
  350.           @sprites["xray"].visible = true
  351.           else
  352.           @sprites["patient"].visible = true
  353.           @sprites["xray"].visible = false
  354.           end
  355.       elsif Input.trigger?(Input::LEFT) && !@pokemon.egg?
  356.         oldpage = @page
  357.         @page -= 1
  358.         @page = 2 if @page<1
  359.         @page = 1 if @page>2
  360.         if @page!=oldpage   # Move to next page
  361.           pbSEPlay("GUI summary change page")
  362.           dorefresh = true
  363.         end
  364.       elsif Input.trigger?(Input::RIGHT) && !@pokemon.egg?
  365.         oldpage = @page
  366.         @page += 1
  367.         @page = 2 if @page<1
  368.         @page = 1 if @page>2
  369.         if @page!=oldpage   # Move to next page
  370.           pbSEPlay("GUI summary change page")
  371.           dorefresh = true
  372.         end
  373.       end
  374.       if dorefresh
  375.         drawMedPage(@page)
  376.       end
  377.     end
  378.   end
  379. end
  380.  
  381.  
  382.  
  383. class PokemonMedSummaryScreen
  384.   def initialize(scene)
  385.     @scene = scene
  386.   end
  387.  
  388.   def pbStartMedScreen
  389.     @scene.pbStartMedScene
  390.     ret = @scene.pbMedScene
  391.     @scene.pbEndScene
  392.     return ret
  393.   end
  394.  
  395. end
  396.  
  397.  
  398.  
  399. #These are just things I use to test
  400.  
  401. def testVars
  402.   for i in 0...MedicalVars.length
  403.     $game_variables[MedicalVars[i]]=rand(90)
  404.   end
  405.   memo("This is a test")
  406. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement