Advertisement
Narzew

NRGSS v 1.7

Jul 30th, 2012
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 27.70 KB | None | 0 0
  1. ############################################################
  2. #**NRGSS (Narzew RGSS Module)
  3. #**Narzew
  4. #**narzewcreations.rox.pl
  5. #**Projekt zaczęty 1 kwietnia 2012 roku.
  6. #**Wersja 1.7
  7. ############################################################
  8. #**Zeiling Engine and NRGSS Engine
  9. #**Narzew
  10. #**Thanks:
  11. #**Whiteflute (A Crying Minister) - Parts of MsgBox, some tutorials, some other parts
  12. ############################################################
  13. #??.04.12 - Script Start Date
  14. #11.05.12 - Script Completed Date V 1.0
  15. #20.05.12 - Script Completed Date V 1.1
  16. #1.06.12 - Script Completed Date V 1.2
  17. #3.06.12 - Script Completed Date V 1.3
  18. #10.06.12 - Script Completed Date V 1.4
  19. #22.06.12 - Script Completed Date V 1.5
  20. #13.07.12 - Script Completed Date V 1.6
  21. #27.07.12 - Script Completed Date V 1.7
  22. #V 1.7
  23. ############################################################
  24.  
  25. $nrgss = 1.7
  26.  
  27. add = 0
  28. remove = 1
  29. set = 2
  30. enable = 0
  31. disable = 1
  32. play = 0
  33. stop = 1
  34. fade = 2
  35. save = 0
  36. menu = 1
  37. encounter = 2
  38. title = 1
  39. gameover = 2
  40. debug = 3
  41. map = 4
  42. battle = 5
  43. shop = 6
  44. name = 7
  45. item = 8
  46. skill = 9
  47. equip = 10
  48. status = 11
  49. exit = 12
  50. bgm = 0
  51. bgs = 1
  52. me = 2
  53. se = 3
  54. item = 0
  55. weapon = 1
  56. armor = 2
  57. level = 0
  58. exp = 1
  59. hp = 2
  60. sp = 3
  61. maxhp = 4
  62. maxsp = 5
  63. str = 6
  64. dex = 7
  65. agi = 8
  66. int = 9
  67. atk = 10
  68. pdef = 11
  69. mdef = 12
  70. eva = 13
  71. enemyhp = 14
  72. enemysp = 15
  73. enemymaxhp = 16
  74. enemymaxsp = 17
  75. enemystr = 18
  76. enemydex = 19
  77. enemyagi = 20
  78. enemyint = 21
  79. enemyatk = 22
  80. enemypdef = 23
  81. enemymdef = 24
  82. enemyeva = 25
  83. player_x = 26
  84. player_y = 27
  85. direction = 28
  86. screen_x = 29
  87. screen_y = 30
  88. terrain_tag = 31
  89. map_id = 32
  90. actors_size = 33
  91. gold = 34
  92. steps = 35
  93. frame_count = 36
  94. frame_rate = 37
  95. timer = 38
  96. frame_ratio = 39
  97. timer_ratio = 40
  98. save_count = 41
  99. x = 0
  100. y = 1
  101. standalone = 0
  102. in_file = 1
  103. file = 1
  104. script = 0
  105. file = 1
  106. mb_ok = 0x0
  107. mb_okcancel = 0x1
  108. mb_abortretryignore = 0x2
  109. mb_yesnocancel = 0x3
  110. mb_yesno = 0x4
  111. mb_retrycancel = 0x5
  112. mb_iconerror = 0x10
  113. mb_iconquestion = 0x20
  114. mb_iconwarning = 0x30
  115. mb_iconinformation = 0x40
  116. mb_systemmodal = 0x1000
  117. mb_taskmodal = 0x2000
  118. mb_topmost = 0x40000
  119. mb_fatal = 0x042010
  120. mb_warn = 0x042030
  121. idok = 1
  122. idcancel = 2
  123. idabort = 3
  124. idretry = 4
  125. idignore = 5
  126. idyes = 6
  127. idno = 7
  128. error_section_num = (/^(?:Section)?{?(\d+)}?:/)
  129. error_section = (/^(?:Section)?{?\d+}?:/)
  130. double_crlf = (/\n\n/)
  131. messagebox = Win32API.new('user32', 'MessageBoxA', %w(p p p i), 'i')
  132. msgbox = Win32API.new('user32', 'MessageBoxA', %w(p p p i), 'i')
  133. getprivateprofilestring = Win32API.new('kernel32', 'GetPrivateProfileStringA',%w(p p p p l p),'l')
  134. rgss_eval = Win32API.new('RGSS.dll', 'RGSSEval', 'p', 'v') if File.exist?('RGSS.dll')
  135. rgss2_eval = Win32API.new('RGSS2.dll', 'RGSSEval', 'p', 'v') if File.exist?('RGSS2.dll')
  136. rgss3_eval = Win32API.new('RGSS3.dll', 'RGSSEval', 'p', 'v') if File.exist?('RGSS3.dll')
  137.  
  138. module NRGSS
  139.  
  140.   $registered_names = []
  141.   $activated_names = []
  142.   $nrgss_extensions = []
  143.  
  144.   def self.register(product)
  145.     $registered_names << product
  146.   end
  147.  
  148.   def self.registered?(product)
  149.     $registered_names.include?(product) ? true : false
  150.   end
  151.  
  152.   def self.activate_product(product)
  153.     $activated_names << product
  154.   end
  155.  
  156.   def self.activated?
  157.     $activated_names.include?(product) ? true : false
  158.   end
  159.  
  160.   def self.activate(product)
  161.     NRGSS.register(product) if !(NRGSS.registered?(product))
  162.     NRGSS.activate_product(product) if !($activated_names.include?(product))
  163.     unless NRGSS.registered?(product)
  164.       unless NRGSS.activated?(product)
  165.         raise 'Error wit activating #{product}. Game will now close.'
  166.       end
  167.     end
  168.   end
  169.  
  170.   def self.extend(name, type, file=nil, encrypted=false)
  171.     case type
  172.     when 0
  173.       $nrgss_extensions << name
  174.     when 1
  175.       NRGSS.eval_script(file, encrypted)
  176.       $nrgss_extensions << name
  177.     end
  178.   end
  179.  
  180.   def self.extended?(name)
  181.     $nrgss_extensions.include?(name) ? true : false
  182.   end
  183.  
  184.   def self.in_range?( x, y, value)
  185.     value = self if value ==  nil
  186.     return true if value.to_i > x.to_i and value < y.to_i
  187.   end
  188.  
  189.   def self.round_range(x, y, value)
  190.     value = self if value == nil
  191.     if value > x
  192.       value = x
  193.     elsif value < y
  194.       value = y
  195.     end
  196.   end
  197.  
  198.   def self.unpack_byte(byte)
  199.     result  = []
  200.     case byte
  201.     when 0 then result << '$NULL$'
  202.     when 1 then result << '$SOH$'
  203.     when 2 then result << '$STX$'
  204.     when 3 then result << '$ETX$'
  205.     when 4 then result << '$EOT$'
  206.     when 5 then result << '$ENQ$'
  207.     when 6 then result << '$ACK$'
  208.     when 7 then result << '$BEL$'
  209.     when 8 then result << '$BS$'
  210.     when 9 then result << '$TAB$'
  211.     when 10 then result << '$LF$'
  212.     when 11 then result << '$VT$'
  213.     when 12 then result << '$FF$'
  214.     when 13 then result << '$CR$'
  215.     when 14 then result << '$SO$'
  216.     when 15 then result << '$SI$'
  217.     when 16 then result << '$DLE$'
  218.     when 17 then result << '$DC1$'
  219.     when 18 then result << '$DC2$'
  220.     when 19 then result << '$DC3$'
  221.     when 20 then result << '$DC4$'
  222.     when 21 then result << '$NAK$'
  223.     when 22 then result << '$SYN$'
  224.     when 23 then result << '$ETB$'
  225.     when 24 then result << '$CAN$'
  226.     when 25 then result << '$EN$'
  227.     when 26 then result << '$SUB$'
  228.     when 27 then result << '$ESC$'
  229.     when 28 then result << '$FS$'
  230.     when 29 then result << '$GS$'
  231.     when 30 then result << '$RS$'
  232.     when 31 then result << '$US$'
  233.     when 32 then result << ' '
  234.     when 33 then result << '!'
  235.     when 34 then result << '\"'
  236.     when 35 then result << '#'
  237.     when 36 then result << '$'
  238.     when 37 then result << '%'
  239.     when 38 then result << '&'
  240.     when 39 then result << '\''
  241.     when 40 then result << '('
  242.     when 41 then result << ')'
  243.     when 42 then result << '*'
  244.     when 43 then result << '+'
  245.     when 44 then result << ','
  246.     when 45 then result << '-'
  247.     when 46 then result << '.'
  248.     when 47 then result << '/'
  249.     when 48 then result << '0'
  250.     when 49 then result << '1'
  251.     when 50 then result << '2'
  252.     when 51 then result << '3'
  253.     when 52 then result << '4'
  254.     when 53 then result << '5'
  255.     when 54 then result << '6'
  256.     when 55 then result << '7'
  257.     when 56 then result << '8'
  258.     when 57 then result << '9'
  259.     when 58 then result << ':'
  260.     when 59 then result << ';'
  261.     when 60 then result << '<'
  262.     when 61 then result << '='
  263.     when 62 then result << '>'
  264.     when 63 then result << '?'
  265.     when 64 then result << '@'
  266.     when 65 then result << 'A'
  267.     when 66 then result << 'B'
  268.     when 67 then result << 'C'
  269.     when 68 then result << 'D'
  270.     when 69 then result << 'E'
  271.     when 70 then result << 'F'
  272.     when 71 then result << 'G'
  273.     when 72 then result << 'H'
  274.     when 73 then result << 'I'
  275.     when 74 then result << 'J'
  276.     when 75 then result << 'K'
  277.     when 76 then result << 'L'
  278.     when 77 then result << 'M'
  279.     when 78 then result << 'N'
  280.     when 79 then result << 'O'
  281.     when 80 then result << 'P'
  282.     when 81 then result << 'Q'
  283.     when 82 then result << 'R'
  284.     when 83 then result << 'S'
  285.     when 84 then result << 'T'
  286.     when 85 then result << 'U'
  287.     when 86 then result << 'V'
  288.     when 87 then result << 'W'
  289.     when 88 then result << 'X'
  290.     when 89 then result << 'Y'
  291.     when 90 then result << 'Z'
  292.     when 91 then result << '['
  293.     when 92 then result << '\\'
  294.     when 93 then result << ']'
  295.     when 94 then result << '^'
  296.     when 95 then result << '_'
  297.     when 96 then result << '`'
  298.     when 97 then result << 'a'
  299.     when 98 then result << 'b'
  300.     when 99 then result << 'c'
  301.     when 100 then result << 'd'
  302.     when 101 then result << 'e'
  303.     when 102 then result << 'f'
  304.     when 103 then result << 'g'
  305.     when 104 then result << 'h'
  306.     when 105 then result << 'i'
  307.     when 106 then result << 'j'
  308.     when 107 then result << 'k'
  309.     when 108 then result << 'l'
  310.     when 109 then result << 'm'
  311.     when 110 then ersult << 'n'
  312.     when 111 then result << 'o'
  313.     when 112 then result << 'p'
  314.     when 113 then result << 'q'
  315.     when 114 then result << 'r'
  316.     when 115 then result << 's'
  317.     when 116 then result << 't'
  318.     when 117 then result << 'u'
  319.     when 118 then result << 'v'
  320.     when 119 then result << 'w'
  321.     when 120 then result << 'x'
  322.     when 121 then result << 'y'
  323.     when 122 then result << 'z'
  324.     when 123 then result << '{'
  325.     when 124 then result << '|'
  326.     when 125 then result << '}'
  327.     when 126 then result << '~'
  328.     when 127 then result << '$DEL$'
  329.     else
  330.       result << '$NOT$'
  331.     end
  332.     return result
  333.   end
  334.  
  335.   def self.unpack_text(text)
  336.     result = []
  337.     text.each{|byte|
  338.     result << NRGSS.unpack_byte(byte)
  339.     }
  340.     return result.to_s
  341.   end
  342.  
  343.   def self.pack_bytes(text)
  344.     result = []
  345.     text.each_byte{|byte| result << byte }
  346.     return result
  347.   end
  348.  
  349.   def self.pack_byte(letter)
  350.     result = []
  351.     letter.each_byte{|byte| result << letter }
  352.     return result.at(0)
  353.   end
  354.  
  355.   def self.encrypt_int(int, val=12)
  356.     srand(val*2 + 4)
  357.     (val * 3 + 7).times{
  358.     int = int + val
  359.     int = int - 2
  360.     int = int + rand(val * 4 - 6)
  361.     int = int - rand(val * 3 + 7)
  362.     }
  363.     return int
  364.   end
  365.  
  366.   def self.decrypt_int(int, val=12)
  367.     srand(val*2 + 4)
  368.     (val * 3 + 7).times{
  369.     int = int - val
  370.     int = int + 2
  371.     int = int - rand(val * 4 - 6)
  372.     int = int + rand(val * 3 + 7)
  373.     }
  374.     return int
  375.   end
  376.  
  377.   def self.require_rbl(file)
  378.     raise("Rbl #{file} is required. Please install or download it.") if !File.exist?(file)
  379.   end
  380.  
  381.   def self.rbl_read(data)
  382.     file = File.open(data, 'rb')
  383.     data = file.read
  384.     file.close
  385.   end
  386.  
  387.   def self.rbl_build(src, file)
  388.     writefile = File.open(file, 'wb')
  389.     $rbl_data = src
  390.     Marshal.dump($rbl_data, writefile)
  391.     writefile.close
  392.   end
  393.  
  394.   def self.rbl_call(rbl, func, args, bind=false)
  395.     file = File.open(rbl, 'rb')
  396.     $rbl_data = Marshal.load(file)
  397.     $rbl_args = args
  398.     eval(Zlib::Inflate.inflate($rbl_data[func])) if bind == false or bing == 0 or bind == nil
  399.     eval(Zlib::Inflate.inflate($rbl_data[func]), TOPLEVEL_BINDING) if bind == true or bind == 1
  400.     file.close
  401.   end
  402.  
  403.   def self.zlib_compress_file(readfile2, writefile2, level=9)
  404.     readfile = File.open(readfile2, 'rb')
  405.     data = readfile.read
  406.     readfile.close
  407.     writefile = File.open(writefile2, 'wb')
  408.     i1 = Zlib::Deflate.deflate(data, level)
  409.     writefile.write(i1)
  410.     writefile.close
  411.   end
  412.  
  413.   def self.zlib_decompress_file(readfile2, writefile2, level=9)
  414.     readfile = File.open(readfile2, 'rb')
  415.     data = readfile.read
  416.     readfile.close
  417.     writefile = File.open(writefile2, 'wb')
  418.     i1 = Zlib::Deflate.deflate(data, level)
  419.     writefile.write(i1)
  420.     writefile.close
  421.   end
  422.  
  423.   def self.mda_compress(datalist, archive)
  424.     $archived_data = []
  425.     file = File.open(archiwe, 'wb')
  426.     count = 0
  427.     datalist.each{|data|
  428.     datafile = File.open(data, 'rb')
  429.     datafile_d = datafile.read
  430.     datafile.close
  431.     $archived_data[count] = datafile_d
  432.     count += 1
  433.     }
  434.     Marshal.dump($archived_data, file)
  435.     file.close
  436.   end
  437.  
  438.   def self.mda_load(data, archive)
  439.     file = File.open(data, archive)
  440.     $archived_data = Marshal.load(file)
  441.     return $archived_data[data]
  442.   end
  443.  
  444.   def self.decompress(data, file, archive)
  445.     NRGSS.file_write(NRGSS.mda_load(data, archive), file)
  446.   end
  447.  
  448.   def self.file_read(var, file2)
  449.     file = File.open(file2, 'rb')
  450.     var = file.read
  451.     file.close
  452.   end
  453.  
  454.   def self.file_read2(file2)
  455.     file = File.open(file2, 'rb')
  456.     return file.read
  457.   end
  458.  
  459.   def self.file_read3(file2)
  460.     return load_data(file2)
  461.   end
  462.  
  463.   def self.file_write(var, file2)
  464.     file = File.open(file2, 'wb')
  465.     file.write(var)
  466.     file.close
  467.   end
  468.  
  469.   def self.file_link(afile, bfile, cfile)
  470.     file1 = File.open(afile, 'rb')
  471.     file2 = File.open(bfile, 'rb')
  472.     file3 = File.open(cfile, 'wb')
  473.     file3.write(file1.read)
  474.     file3.write(file2.read)
  475.     file1.close
  476.     file2.close
  477.     file3.close
  478.   end
  479.  
  480.   def self.cbrt(x)
  481.     result = x**(1.0/3.0)
  482.     return result
  483.   end
  484.  
  485.   def self.root(nr, st)
  486.     result = nr**(1.0/st.to_f)
  487.     return result
  488.   end
  489.  
  490.   def self.oppose(nr)
  491.     result = nr - (nr*2)
  492.     return result
  493.   end
  494.  
  495.   def self.threepower(x, st)
  496.     return (x**st)**st
  497.   end
  498.  
  499.   def self.circlethreepower(x)
  500.     return (x**x)**x
  501.   end
  502.  
  503.   def self.zlib_defl(filename)
  504.     file = File.open(filename, 'rb')
  505.     filedata = file.read
  506.     file.close
  507.     return Zlib::Deflate.deflate(filedata, 9)
  508.   end
  509.  
  510.   def self.zlib_infl(filename)
  511.     file = File.open(filename)
  512.     filedata = file.read
  513.     file.close
  514.     return Zlib::Inflate.inflate(filedata)
  515.   end
  516.  
  517.   def self.randomize(min, max)
  518.     return rand(max - min + 1)
  519.   end
  520.  
  521.   def self.set_variable(var, value)
  522.     $game_variables[var] = value
  523.   end
  524.  
  525.   def self.get_variable(var)
  526.     return $game_variables[var]
  527.   end
  528.  
  529.   def self.get_player(value)
  530.     case value
  531.     when value = 0 then return $game_player.x
  532.     when value = 1 then return $game_player.y
  533.     when value = 2 then return $game_player.direction
  534.     when value = 3 then return $game_player.screen_x
  535.     when value = 4 then return $game_player.screen_y
  536.     when value = 5 then return $game_player.terrain_tag
  537.     end
  538.   end
  539.  
  540.   def self.change_variable(variable, value, method, args=[0])
  541.     case method
  542.     when 0 then $game_variables[variable] += value
  543.     when 1 then $game_variables[variable] -= value
  544.     when 2
  545.       case value
  546.       when 0 then NRGSS.set_variable(variable, $game_actors[args[0]].level)
  547.       when 1 then NRGSS.set_variable(variable, $game_actors[args[0]].exp)
  548.       when 2 then NRGSS.set_variable(variable, $game_actors[args[0]].hp)
  549.       when 3 then NRGSS.set_variable(variable, $game_actors[args[0]].sp)
  550.       when 4 then NRGSS.set_variable(variable, $game_actors[args[0]].maxhp)
  551.       when 5 then NRGSS.set_variable(variable, $game_actors[args[0]].maxsp)
  552.       when 6 then NRGSS.set_variable(variable, $game_actors[args[0]].str)
  553.       when 7 then NRGSS.set_variable(variable, $game_actors[args[0]].dex)
  554.       when 8 then NRGSS.set_variable(variable, $game_actors[args[0]].agi)
  555.       when 9 then NRGSS.set_variable(variable, $game_actors[args[0]].int)
  556.       when 10 then NRGSS.set_variable(variable, $game_actors[args[0]].atk)
  557.       when 11 then NRGSS.set_variable(variable, $game_actors[args[0]].pdef)
  558.       when 12 then NRGSS.set_variable(variable, $game_actors[args[0]].mdef)
  559.       when 13 then NRGSS.set_variable(variable, $game_actors[args[0]].eva)
  560.       when 14 then NRGSS.set_variable(variable, $game_troop.enemies[args[0]].hp)
  561.       when 15 then NRGSS.set_variable(variable, $game_troop.enemies[args[0]].sp)
  562.       when 16 then NRGSS.set_variable(variable, $game_troop.enemies[args[0]].maxhp)
  563.       when 17 then NRGSS.set_variable(variable, $game_troop.enemies[args[0]].maxsp)
  564.       when 18 then NRGSS.set_variable(variable, $game_troop.enemies[args[0]].str)
  565.       when 19 then NRGSS.set_variable(variable, $game_troop.enemies[args[0]].dex)
  566.       when 20 then NRGSS.set_variable(variable, $game_troop.enemies[args[0]].agi)
  567.       when 21 then NRGSS.set_variable(variable, $game_troop.enemies[args[0]].int)
  568.       when 22 then NRGSS.set_variable(variable, $game_troop.enemies[args[0]].atk)
  569.       when 23 then NRGSS.set_variable(variable, $game_troop.enemies[args[0]].pdef)
  570.       when 24 then NRGSS.set_variable(variable, $game_troop.enemies[args[0]].mdef)
  571.       when 25 then NRGSS.set_variable(variable, $game_troop.enemies[args[0]].eva)
  572.       when 26 then NRGSS.set_variable(variable, NRGSS.get_player(0))
  573.       when 27 then NRGSS.set_variable(variable, NRGSS.get_player(1))
  574.       when 28 then NRGSS.set_variable(variable, NRGSS.get_player(2))
  575.       when 29 then NRGSS.set_variable(variable, NRGSS.get_player(3))
  576.       when 30 then NRGSS.set_variable(variable, NRGSS.get_player(4))
  577.       when 31 then NRGSS.set_variable(variable, NRGSS.get_player(5))
  578.       when 32 then NRGSS.set_variable(variable, $game_map.map_id)
  579.       when 33 then NRGSS.set_variable(variable, $game_party.actors.size)
  580.       when 34 then NRGSS.set_variable(variable, $game_party.gold)
  581.       when 35 then NRGSS.set_variable(variable, $game_party.steps)
  582.       when 36 then NRGSS.set_variable(variable, Graphics.frame_count)
  583.       when 37 then NRGSS.set_variable(variable, Graphics.frame_rate)
  584.       when 38 then NRGSS.set_variable(variable, $game_system.timer)
  585.       when 39 then NRGSS.set_variable(variable, Graphics.frame_count / Graphics.frame_rate)
  586.       when 40 then NRGSS.set_variable(variable, $game_system.timer / Graphics.frame_rate)
  587.       when 41 then NRGSS.set_variable(variable, $game_system.save_count)
  588.       end
  589.     end
  590.   end
  591.  
  592.   def self.return_data(data, args=[0])
  593.     case data
  594.     when 0 then return($game_actors[args[0]].level)
  595.     when 1 then return($game_actors[args[0]].exp)
  596.     when 2 then return($game_actors[args[0]].hp)
  597.     when 3 then return($game_actors[args[0]].sp)
  598.     when 4 then return($game_actors[args[0]].maxhp)
  599.     when 5 then return($game_actors[args[0]].maxsp)
  600.     when 6 then return($game_actors[args[0]].str)
  601.     when 7 then return($game_actors[args[0]].dex)
  602.     when 8 then return($game_actors[args[0]].agi)
  603.     when 9 then return($game_actors[args[0]].int)
  604.     when 10 then return($game_actors[args[0]].atk)
  605.     when 11 then return($game_actors[args[0]].pdef)
  606.     when 12 then return($game_actors[args[0]].mdef)
  607.     when 13 then return($game_actors[args[0]].eva)
  608.     when 14 then return($game_troop.enemies[args[0]].hp)
  609.     when 15 then return($game_troop.enemies[args[0]].sp)
  610.     when 16 then return($game_troop.enemies[args[0]].maxhp)
  611.     when 17 then return($game_troop.enemies[args[0]].maxsp)
  612.     when 18 then return($game_troop.enemies[args[0]].str)
  613.     when 19 then return($game_troop.enemies[args[0]].dex)
  614.     when 20 then return($game_troop.enemies[args[0]].agi)
  615.     when 21 then return($game_troop.enemies[args[0]].int)
  616.     when 22 then return($game_troop.enemies[args[0]].atk)
  617.     when 23 then return($game_troop.enemies[args[0]].pdef)
  618.     when 24 then return($game_troop.enemies[args[0]].mdef)
  619.     when 25 then return($game_troop.enemies[args[0]].eva)
  620.     when 26 then return(NRGSS.get_player(0))
  621.     when 27 then return(NRGSS.get_player(1))
  622.     when 28 then return(NRGSS.get_player(2))
  623.     when 29 then return(NRGSS.get_player(3))
  624.     when 30 then return(NRGSS.get_player(4))
  625.     when 31 then return(NRGSS.get_player(5))
  626.     when 32 then return($game_map.map_id)
  627.     when 33 then return($game_party.actors.size)
  628.     when 34 then return($game_party.gold)
  629.     when 35 then return($game_party.steps)
  630.     when 36 then return(Graphics.frame_count)
  631.     when 37 then return(Graphics.frame_rate)
  632.     when 38 then return($game_system.timer)
  633.     when 39 then return(Graphics.frame_count / Graphics.frame_rate)
  634.     when 40 then return($game_system.timer / Graphics.frame_rate)
  635.     when 41 then return($game_system.save_count)
  636.     end
  637.   end
  638.  
  639.   def self.set_timer(time)
  640.     $game_system.timer = time * Graphics.frame_rate
  641.     $game_system.timer_working = true
  642.   end
  643.  
  644.   def self.stop_timer
  645.     $game_system.timer_working = false
  646.   end
  647.  
  648.   def self.change_money(int, operation)
  649.     case operation
  650.     when 0 then $game_party.gold += int
  651.     when 1 then $game_party.gold -= int
  652.     when 2 then $game_party.gold = int
  653.     end
  654.   end
  655.  
  656.   def self.change_items(id, number, type, operation)
  657.     case operation
  658.     when 0
  659.       case type
  660.       when 0 then $game_party.gain_item(id, number)
  661.       when 1 then $game_party.gain_weapon(id, number)
  662.       when 2 then $game_party.gain_armor(id, number)
  663.       end
  664.     when 1
  665.       case type
  666.       when 0 then $game_party.lose_item(id,number)
  667.       when 1 then $game_party.lose_weapon(id, number)
  668.       when 2 then $game_party.lose_armor(id, number)
  669.       end
  670.     end
  671.   end
  672.  
  673.   def self.change(operation, args=[])
  674.     case operation
  675.     when 0 then $game_system.windowskin_name = args[0]
  676.     when 1 then $game_system.battle_bgm = args[0]
  677.     when 2 then $game_system.battle_end_me = args[0]
  678.     end
  679.   end
  680.  
  681.   def self.manage(type, operation)
  682.     case type
  683.     when 0
  684.       case operation
  685.       when 0 then $game_system.save_disabled = false
  686.       when 1 then $game_system.save_disabled = true
  687.       end
  688.     when 1
  689.       case operation
  690.       when 0 then $game_system.menu_disabled = false
  691.       when 1 then $game_system.menu_disabled = true
  692.       end
  693.     when 2
  694.       case operation
  695.       when 0 then $game_system.encounter_disabled = false
  696.       when 1 then $game_system.encounter_disabled = true
  697.       end
  698.     end
  699.   end
  700.  
  701.   def self.play(filename, type, operation, args=[100,100])
  702.     volume = 100 if volume == 0
  703.     pitch = 100 if pitch == 0
  704.     case operation
  705.     when 0
  706.       case type
  707.       when 0 then $game_system.bgm_play(filename, args[0], args[1])
  708.       when 1 then $game_system.bgs_play(filename, args[0], args[1])
  709.       when 2 then $game_system.me_play(filename, args[0], args[1])
  710.       when 3 then $game_system.se_play(filename, args[0], args[1])
  711.       end
  712.     when 1
  713.       case type
  714.       when 0 then $game_system.bgm_stop
  715.       when 1 then $game_system.bgs_stop
  716.       when 2 then $game_system.me_stop
  717.       when 3 then $game_system.se_stop
  718.       end
  719.     when 2
  720.       case type
  721.       when 0 then $game_system.bgm_fade(args[0])
  722.       when 1 then $game_system.bgs_fade(args[0])
  723.       when 2 then $game_system.me_fade(args[0])
  724.       when 3 then $game_systen.se_fade(args[0])
  725.       end
  726.     end
  727.   end
  728.  
  729.   def self.change_hero(hero, attribute, operation, value)
  730.     case operation
  731.     when 0
  732.       case attribute
  733.       when 0 then $game_actors[hero].level += value
  734.       when 1 then $game_actors[hero].exp += value
  735.       when 2 then $game_actors[hero].hp += value
  736.       when 3 then $game_actors[hero].sp += value
  737.       when 4 then $game_actors[hero].maxhp += value
  738.       when 5 then $game_actors[hero].maxsp += value
  739.       when 6 then $game_actors[hero].str += value
  740.       when 7 then $game_actors[hero].dex += value
  741.       when 8 then $game_actors[hero].agi += value
  742.       when 9 then $game_actors[hero].int += value
  743.       when 10 then $game_actors[hero].learn_skill(value)
  744.       end
  745.     when 1
  746.       case attribute
  747.       when 0 then $game_actors[hero].level -= value
  748.       when 1 then $game_actors[hero].exp -= value
  749.       when 2 then $game_actors[hero].hp -= value
  750.       when 3 then $game_actors[hero].sp -= value
  751.       when 4 then $game_actors[hero].maxhp -= value
  752.       when 5 then $game_actors[hero].maxsp -= value
  753.       when 6 then $game_actors[hero].str -= value
  754.       when 7 then $game_actors[hero].dex -= value
  755.       when 8 then $game_actors[hero].agi -= value
  756.       when 9 then $game_actors[hero].int -= value
  757.       when 10 then $game_actors[hero].forget_skill(value)
  758.       end
  759.     when 2
  760.       case atrribute
  761.       when 0 then $game_actors[hero].level = value
  762.       when 1 then $game_actors[hero].exp = value
  763.       when 2 then $game_actors[hero].hp = value
  764.       when 3 then $game_actors[hero].sp = value
  765.       when 4 then $game_actors[hero].maxhp = value
  766.       when 5 then $game_actors[hero].maxsp = value
  767.       when 6 then $game_actors[hero].str = value
  768.       when 7 then $game_actors[hero].dex = value
  769.       when 8 then $game_actors[hero].agi = value
  770.       when 9 then $game_actors[hero].int = value
  771.       end
  772.     end
  773.   end
  774.  
  775.   def self.heal(actor)
  776.     $game_actors[actor].hp = $game_actors[actor].maxhp
  777.     $game_actors[actor].sp = $game_actors[actor].maxsp
  778.   end
  779.  
  780.   def self.heal_all
  781.     $game_actors.recover_all
  782.   end
  783.  
  784.   def self.call(operation)
  785.     case operation
  786.     when 0 then $scene=Scene_Save.new
  787.     when 1 then $scene=Scene_Title.new
  788.     when 2 then $scene=Scene_Gameover.new
  789.     when 3 then $scene=Scene_Debug.new
  790.     when 4 then $scene=Scene_Map.new
  791.     when 5 then $scene=Scene_Battle.new
  792.     when 6 then $scene=Scene_Shop.new
  793.     when 7 then $scene=Scene_Name.new
  794.     when 8 then $scene=Scene_Item.new
  795.     when 9 then $scene=Scene_Skill.new
  796.     when 10 then $scene=Scene_Equip.new
  797.     when 11 then $scene=Scene_Status.new
  798.     when 12 then $scene=Scene_End.new
  799.     end
  800.   end
  801.  
  802.   def self.save_script(filename='script.txt')
  803.     file = File.open(filename, 'wb')
  804.     if NRGSS.registered?('NCEA')
  805.       NCEA.load_game_data
  806.       script = $game_data[8]
  807.     else
  808.       script = load_data('Data/Scripts.rxdata')
  809.     end
  810.     script.each {|s|
  811.     file.write(Zlib::Inflate.inflate(s.at(2)))
  812.     file.write("\n\n\n")
  813.     }
  814.     file.close
  815.   end
  816.  
  817.   def self.compile_crbl(data, filename)
  818.     file = File.open(filename, 'wb')
  819.     datafile = File.open(data, 'rb')
  820.     data2 = datafile.read
  821.     $result = Zlib::Deflate.deflate(data2, 9)
  822.     Marshal.dump($result, file)
  823.     datafile.close
  824.     file.close
  825.   end
  826.  
  827.   def self.eval_crbl(crbl, bind=false)
  828.     $result = load_data(crbl)
  829.     to_eval = Zlib::Inflate.inflate($result)
  830.     case bind
  831.     when false then eval(to_eval)
  832.     when true then eval(to_eval, TOPLEVEL_BINDING)
  833.     end
  834.   end
  835.  
  836.   def self.messagebox(message, title, type)
  837.     msgbox.call(0, message, title, type)
  838.   end
  839.  
  840.   def self.b64_encode(x)
  841.     return [x].pack('m')
  842.   end
  843.  
  844.   def self.b64_decode(x)
  845.     return x.unpack('m').first
  846.   end
  847.  
  848.   def self.b64_encode_file(file, result)
  849.     readfile = File.open(file, 'rb')
  850.     writefile = File.open(result, 'wb')
  851.     data = readfile.read
  852.     writefile.write(NRGSS.b64_encode(data))
  853.     readfile.close
  854.     writefile.close
  855.   end
  856.  
  857.   def self.b64_decode_file(file, result)
  858.     readfile = File.open(file, 'rb')
  859.     writefile = File.open(result, 'wb')
  860.     data = readfile.read
  861.     writefile.write(NRGSS.b64_decode(data))
  862.     readfile.close
  863.     writefile.close
  864.   end
  865.  
  866.   def self.rgss_eval(x)
  867.     rgss_eval.call(x)
  868.   rescue
  869.     print 'RGSS.dll not found. Method not executed.'
  870.   end
  871.  
  872.   def self.rgss2_eval(x)
  873.     rgss2_eval.call(x)
  874.   rescue
  875.     print 'RGSS2.dll not found. Method not executed.'
  876.   end
  877.  
  878.   def self.rgss3_eval(x)
  879.     rgss3_eval.call(x)
  880.   rescue
  881.     print 'RGSS3.dll not found. Method not executed.'
  882.   end
  883.  
  884.   def self.eval_script(filename, encrypted=false, bind=false)
  885.     if encrypted == false
  886.       file = File.open(filename, 'rb')
  887.       data = file.read
  888.       file.close
  889.       if bind == true
  890.         eval(data, TOPLEVEL_BINDING)
  891.       else
  892.         eval(data)
  893.       end
  894.     else
  895.       file = File.open(filename, 'rb')
  896.       $result = Marshal.load(file)
  897.       file.close
  898.       data = Zlib::Inflate.inflate($result)
  899.       if bind == true
  900.         eval(data, TOPLEVEL_BINDING)
  901.       else
  902.         eval(data)
  903.       end
  904.     end
  905.   end
  906.  
  907.   def self.move_file(file, new_location)
  908.     file = File.open(file, 'rb')
  909.     data = file.read
  910.     file.close
  911.     file = File.open("#{new_location}/#{file}", 'wb')
  912.     file.write(data)
  913.     file.close
  914.   end
  915.  
  916.   def self.check_bytesize(file, bytesize)
  917.     file = File.open(file, 'rb')
  918.     return true if file.bytesize == bytesize
  919.     return false
  920.   end
  921.  
  922.   def self.uri_download(x, nam)
  923.     open(x) {|f|
  924.     file = File.open(nam, 'wb')
  925.     file.write(f.read)
  926.     file.close
  927.     }
  928.   end
  929.  
  930.   def self.location_table(locations_ary)
  931.     result = []
  932.     locations_ary.each{|location|
  933.     Dir.foreach(location){|x|
  934.     if x != '.'
  935.       if x != '..'
  936.         result << "#{location}/#{x}"
  937.       end
  938.     end
  939.     }
  940.     }
  941.     return result
  942.   end
  943.  
  944.   def self.change_windowskin(filename)
  945.     $game_system.windowskin_name = filename
  946.   end
  947.    
  948. end
  949.  
  950. def _d(int, key=12)
  951.   return NRGSS.decrypt_int(int, key)
  952. end
  953.  
  954. def _e(int, key=12)
  955.   return NRGSS.encrypt_int(int, key)
  956. end
  957.  
  958. def _td(int, key=12)
  959.   dec = NRGSS.decrypt_int(int, key)
  960.   enc = NRGSS.encrypt_int(dec, key)
  961.   return enc == int
  962. end
  963.  
  964. def byte(byte)
  965.   return NRGSS.pack_byte(byte)
  966. end
  967.  
  968. def ubyte(byte)
  969.   return NRGSS.unpack_byte(byte)
  970. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement