Advertisement
Narzew

NRGSS 1.6 (OUTDATED!)

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