查看: 18349|回复: 11

[交流讨论] VX Ace to MV Converter

[复制链接]
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2015-10-25 16:59:29 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
http://pastebin.com/DFHK5f5R#
VX Ace to MV Converter
  1.        

  2.     module DEGICA
  3.       module CONVERT
  4.         FOLDER = 'mv-data/'
  5.       
  6.         LOGGING = false # only useful for debugging this script
  7.         LOGSCRIPTS = true # lists any damage formulae, and event commands using scripts
  8.         LOGCOMMENTS = false # only turn this on if you have scripts that look for certain comments and want to re-implement them
  9.       
  10.         def self.run
  11.           DataManager.load_normal_database
  12.           dest = FOLDER.gsub(/\\/){''}
  13.           Dir.mkdir dest unless File.exists?(dest)
  14.          
  15.           #*************************************************************************
  16.           @log = File.open(FOLDER + "_log.txt", "w") if LOGGING
  17.           @scriptlog = File.open(FOLDER + "_scripts.txt", "w") if LOGSCRIPTS
  18.           @commentlog = File.open(FOLDER + "_comments.txt", "w") if LOGCOMMENTS
  19.           #*************************************************************************
  20.          
  21.           convert_actors
  22.           convert_classes
  23.           convert_skills
  24.           convert_items
  25.           convert_weapons
  26.           convert_armors
  27.           convert_enemies
  28.           convert_troops
  29.           convert_states
  30.           convert_animations
  31.           convert_tilesets
  32.           convert_common_events
  33.           convert_system
  34.           convert_mapinfos
  35.          
  36.           Dir.glob('Data/Map???.rvdata2').each {|filename| convert_map(filename)}
  37.          
  38.           #*************************************************************************
  39.           @log.close if LOGGING
  40.           @scriptlog.close if LOGSCRIPTS
  41.           @commentlog.close if LOGCOMMENTS
  42.           #*************************************************************************
  43.         end
  44.       
  45.         #===========================================================================
  46.         #
  47.         # DATABASE CONVERSION
  48.         #
  49.         #===========================================================================
  50.       
  51.         #===========================================================================
  52.         # ACTORS
  53.         #===========================================================================
  54.         def self.convert_actors
  55.           f = File.open(FOLDER + "Actors.json", "w")
  56.           f.puts('[')
  57.           f.puts('null,')
  58.           for x in 1 ... $data_actors.size
  59.             actor = $data_actors[x]
  60.             actor = RPG::Actor.new if !actor
  61.             actor_data = '{'
  62.            
  63.             actor_data += '"id":' + x.to_s + ','
  64.             actor_data += '"battlerName":"",'
  65.             actor_data += '"characterIndex":' + actor.character_index.to_s + ','
  66.             actor_data += '"characterName":"' + actor.character_name + '",'
  67.             actor_data += '"classId":' + actor.class_id.to_s + ','
  68.             actor_data += '"equips":' + actor.equips.to_s.gsub(/ /){''} + ','
  69.             actor_data += '"faceIndex":' + actor.face_index.to_s + ','
  70.             actor_data += '"faceName":"' + actor.face_name + '",'
  71.             actor_data += '"traits":' + get_traits(actor) + ','
  72.             actor_data += '"initialLevel":' + actor.initial_level.to_s + ','
  73.             actor_data += '"maxLevel":' + actor.max_level.to_s + ','
  74.             actor_data += '"name":' + get_text(actor.name) + ','
  75.             actor_data += '"nickname":' + get_text(actor.nickname) + ','
  76.             actor_data += '"note":' + get_text(actor.note) + ','
  77.             actor_data += '"profile":' + get_text(actor.description)
  78.            
  79.             actor_data += '}'
  80.             actor_data += ',' if x < $data_actors.size - 1
  81.             f.puts(actor_data)
  82.           end
  83.           f.puts(']')
  84.           f.close
  85.         end
  86.       
  87.         #===========================================================================
  88.         # CLASSES
  89.         #===========================================================================
  90.         def self.convert_classes
  91.           f = File.open(FOLDER + "Classes.json", "w")
  92.           f.puts('[')
  93.           f.puts('null,')
  94.           for x in 1 ... $data_classes.size
  95.             cls = $data_classes[x]
  96.             cls = RPG::Class.new if !cls
  97.             cls_data = '{'
  98.            
  99.             cls_data += '"id":' + x.to_s + ','
  100.             cls_data += '"expParams":' + cls.exp_params.to_s.gsub(/ /){''} + ','
  101.             cls_data += '"traits":' + get_traits(cls) + ','
  102.             cls_data += '"learnings":' + get_learnings(cls) + ','
  103.             cls_data += '"name":' + get_text(cls.name) + ','
  104.             cls_data += '"note":' + get_text(cls.note) + ','
  105.             cls_data += '"params":' + get_params(cls)
  106.            
  107.             cls_data += '}'
  108.             cls_data += ',' if x < $data_classes.size - 1
  109.             f.puts(cls_data)
  110.           end
  111.           f.puts(']')
  112.           f.close
  113.         end
  114.         def self.get_learnings(obj)
  115.           res = '['
  116.           count = 1
  117.           max_count = obj.learnings.size
  118.           obj.learnings.each do |lrn|
  119.             res += '{"level":' + lrn.level.to_s + ','
  120.             res += '"note":' + get_text(lrn.note) + ','
  121.             res += '"skillId":' + lrn.skill_id.to_s + '}'
  122.             res += ',' if count < max_count
  123.             count += 1
  124.           end      
  125.           res += ']'
  126.           res
  127.         end
  128.       
  129.         def self.get_params(cls)
  130.           res = '['
  131.           for p in 0..7
  132.             res += '['
  133.             for l in 0..99
  134.               res += cls.params[p,l].to_s
  135.               res += ',' if l < 99
  136.             end
  137.             res += ']'
  138.             res += ',' if p < 7
  139.           end
  140.           res += ']'
  141.           res
  142.         end
  143.       
  144.         #===========================================================================
  145.         # SKILLS
  146.         #===========================================================================
  147.         def self.convert_skills
  148.           f = File.open(FOLDER + "Skills.json", "w")
  149.           f.puts('[')
  150.           f.puts('null,')
  151.           for x in 1 ... $data_skills.size
  152.             skill = $data_skills[x]
  153.             skill = RPG::Skill.new if !skill
  154.             skl_data = '{'
  155.            
  156.             skl_data += '"id":' + x.to_s + ','
  157.             skl_data += '"animationId":' + skill.animation_id.to_s + ','
  158.             skl_data += '"damage":' + get_damage(skill) + ','
  159.             skl_data += '"description":' + get_text(skill.description) + ','
  160.             skl_data += '"effects":' + get_effects(skill) + ','
  161.             skl_data += '"hitType":' + skill.hit_type.to_s + ','
  162.             skl_data += '"iconIndex":' + skill.icon_index.to_s + ','
  163.             skl_data += '"message1":' + get_text(skill.message1) + ','
  164.             skl_data += '"message2":' + get_text(skill.message2) + ','
  165.             skl_data += '"mpCost":' + skill.mp_cost.to_s + ','
  166.             skl_data += '"name":' + get_text(skill.name) + ','
  167.             skl_data += '"note":' + get_text(skill.note) + ','
  168.             skl_data += '"occasion":' + skill.occasion.to_s + ','
  169.             skl_data += '"repeats":' + skill.repeats.to_s + ','
  170.             skl_data += '"requiredWtypeId1":' + skill.required_wtype_id1.to_s + ','
  171.             skl_data += '"requiredWtypeId2":' + skill.required_wtype_id2.to_s + ','
  172.             skl_data += '"scope":' + skill.scope.to_s + ','
  173.             skl_data += '"speed":' + skill.speed.to_s + ','
  174.             skl_data += '"stypeId":' + skill.stype_id.to_s + ','
  175.             skl_data += '"successRate":' + skill.success_rate.to_s + ','
  176.             skl_data += '"tpCost":' + skill.tp_cost.to_s + ','
  177.             skl_data += '"tpGain":' + skill.tp_gain.to_s
  178.            
  179.             skl_data += '}'
  180.             skl_data += ',' if x < $data_skills.size - 1
  181.             f.puts(skl_data)
  182.           end
  183.           f.puts(']')
  184.           f.close
  185.         end
  186.       
  187.         #===========================================================================
  188.         # ITEMS
  189.         #===========================================================================
  190.         def self.convert_items
  191.           f = File.open(FOLDER + "Items.json", "w")
  192.           f.puts('[')
  193.           f.puts('null,')
  194.           for x in 1 ... $data_items.size
  195.             item = $data_items[x]
  196.             item = RPG::Item.new if !item
  197.             itm_data = '{'
  198.            
  199.             itm_data += '"id":' + x.to_s + ','
  200.             itm_data += '"animationId":' + item.animation_id.to_s + ','
  201.             itm_data += '"consumable":' + item.consumable.to_s + ','
  202.             itm_data += '"damage":' + get_damage(item) + ','
  203.             itm_data += '"description":' + get_text(item.description) + ','
  204.             itm_data += '"effects":' + get_effects(item) + ','
  205.             itm_data += '"hitType":' + item.hit_type.to_s + ','
  206.             itm_data += '"iconIndex":' + item.icon_index.to_s + ','
  207.             itm_data += '"itypeId":' + item.itype_id.to_s + ','
  208.             itm_data += '"name":' + get_text(item.name) + ','
  209.             itm_data += '"note":' + get_text(item.note) + ','
  210.             itm_data += '"occasion":' + item.occasion.to_s + ','
  211.             itm_data += '"price":' + item.price.to_s + ','
  212.             itm_data += '"repeats":' + item.repeats.to_s + ','
  213.             itm_data += '"scope":' + item.scope.to_s + ','
  214.             itm_data += '"speed":' + item.speed.to_s + ','
  215.             itm_data += '"successRate":' + item.success_rate.to_s + ','
  216.             itm_data += '"tpGain":' + item.tp_gain.to_s
  217.            
  218.             itm_data += '}'
  219.             itm_data += ',' if x < $data_items.size - 1
  220.             f.puts(itm_data)
  221.           end
  222.           f.puts(']')
  223.           f.close
  224.         end
  225.       
  226.         #===========================================================================
  227.         # WEAPONS
  228.         #===========================================================================
  229.         def self.convert_weapons
  230.           f = File.open(FOLDER + "Weapons.json", "w")
  231.           f.puts('[')
  232.           f.puts('null,')
  233.           for x in 1 ... $data_weapons.size
  234.             wpn = $data_weapons[x]
  235.             wpn = RPG::Weapon.new if !wpn
  236.             wpn_data = '{'
  237.            
  238.             wpn_data += '"id":' + x.to_s + ','
  239.             wpn_data += '"animationId":' + wpn.animation_id.to_s + ','
  240.             wpn_data += '"description":' + get_text(wpn.description) + ','
  241.             wpn_data += '"etypeId":1,' # weapons are 0 in Ace, but 1 in MV
  242.             wpn_data += '"traits":' + get_traits(wpn) + ','
  243.             wpn_data += '"iconIndex":' + wpn.icon_index.to_s + ','
  244.             wpn_data += '"name":' + get_text(wpn.name) + ','
  245.             wpn_data += '"note":' + get_text(wpn.note) + ','
  246.             wpn_data += '"params":' + wpn.params.to_s.gsub(/ /){''} + ','
  247.             wpn_data += '"price":' + wpn.price.to_s + ','
  248.             wpn_data += '"wtypeId":' + wpn.wtype_id.to_s
  249.            
  250.             wpn_data += '}'
  251.             wpn_data += ',' if x < $data_weapons.size - 1
  252.             f.puts(wpn_data)
  253.           end
  254.           f.puts(']')
  255.           f.close
  256.         end
  257.       
  258.         #===========================================================================
  259.         # ARMORS
  260.         #===========================================================================
  261.         def self.convert_armors
  262.           f = File.open(FOLDER + "Armors.json", "w")
  263.           f.puts('[')
  264.           f.puts('null,')
  265.           for x in 1 ... $data_armors.size
  266.             amr = $data_armors[x]
  267.             amr = RPG::Armor.new if !amr
  268.             amr_data = '{'
  269.            
  270.             amr_data += '"id":' + x.to_s + ','
  271.             amr_data += '"atypeId":' + amr.atype_id.to_s + ','
  272.             amr_data += '"description":' + get_text(amr.description) + ','
  273.             amr_data += '"etypeId":' + amr.etype_id.to_s + ','
  274.             amr_data += '"traits":' + get_traits(amr) + ','
  275.             amr_data += '"iconIndex":' + amr.icon_index.to_s + ','
  276.             amr_data += '"name":' + get_text(amr.name) + ','
  277.             amr_data += '"note":' + get_text(amr.note) + ','
  278.             amr_data += '"params":' + amr.params.to_s.gsub(/ /){''} + ','
  279.             amr_data += '"price":' + amr.price.to_s
  280.            
  281.             amr_data += '}'
  282.             amr_data += ',' if x < $data_armors.size - 1
  283.             f.puts(amr_data)
  284.           end
  285.           f.puts(']')
  286.           f.close
  287.         end
  288.       
  289.         #===========================================================================
  290.         # ENEMIES
  291.         #===========================================================================
  292.         def self.convert_enemies
  293.           f = File.open(FOLDER + "Enemies.json", "w")
  294.           f.puts('[')
  295.           f.puts('null,')
  296.           for x in 1 ... $data_enemies.size
  297.             foe = $data_enemies[x]
  298.             foe = RPG::Enemy.new if !foe
  299.             foe_data = '{'
  300.            
  301.             foe_data += '"id":' + x.to_s + ','
  302.             foe_data += '"actions":' + get_actions(foe) + ','
  303.             foe_data += '"battlerHue":' + foe.battler_hue.to_s + ','
  304.             foe_data += '"battlerName":"' + foe.battler_name + '",'
  305.             foe_data += '"dropItems":' + get_drop_items(foe) + ','
  306.             foe_data += '"exp":' + foe.exp.to_s + ','
  307.             foe_data += '"traits":' + get_traits(foe) + ','
  308.             foe_data += '"gold":' + foe.gold.to_s + ','
  309.             foe_data += '"name":' + get_text(foe.name) + ','
  310.             foe_data += '"note":' + get_text(foe.note) + ','
  311.             foe_data += '"params":' + foe.params.to_s.gsub(/ /){''}
  312.            
  313.             foe_data += '}'
  314.             foe_data += ',' if x < $data_enemies.size - 1
  315.             f.puts(foe_data)
  316.           end
  317.           f.puts(']')
  318.           f.close
  319.         end
  320.       
  321.         def self.get_actions(foe)
  322.           res = '['
  323.           count = 1
  324.           max_count = foe.actions.size
  325.           foe.actions.each do |action|
  326.             res += '{"conditionParam1":' + action.condition_param1.to_s + ','
  327.             res += '"conditionParam2":' + action.condition_param2.to_s + ','
  328.             res += '"conditionType":' + action.condition_type.to_s + ','
  329.             res += '"rating":' + action.rating.to_s + ','
  330.             res += '"skillId":' + action.skill_id.to_s + '}'
  331.             res += ',' if count < max_count
  332.             count += 1
  333.           end
  334.           res += ']'
  335.           res
  336.         end
  337.       
  338.         def self.get_drop_items(foe)
  339.           res = '['
  340.           count = 1
  341.           max_count = foe.drop_items.size
  342.           foe.drop_items.each do |item|
  343.             res += '{"dataId":' + item.data_id.to_s + ','
  344.             res += '"denominator":' + item.denominator.to_s + ','
  345.             res += '"kind":' + item.kind.to_s + '}'
  346.             res += ',' if count < max_count
  347.             count += 1
  348.           end
  349.           res += ']'
  350.           res
  351.         end
  352.       
  353.         #===========================================================================
  354.         # TROOPS
  355.         #===========================================================================
  356.         def self.convert_troops
  357.           f = File.open(FOLDER + "Troops.json", "w")
  358.           f.puts('[')
  359.           f.puts('null,')
  360.           for x in 1 ... $data_troops.size
  361.             troop = $data_troops[x]
  362.             troop = RPG::Troop.new if !troop
  363.             troop_data = '{'
  364.            
  365.             #***********************************************************************
  366.             log("Troop " + x.to_s + " (" + get_text(troop.name) + ")")
  367.             @logtroop = sprintf('Troop %d %s ', x, troop.name)
  368.             #***********************************************************************
  369.          
  370.             troop_data += '"id":' + x.to_s + ','
  371.             troop_data += '"members":' + get_troop_members(troop) + ','
  372.             troop_data += '"name":' + get_text(troop.name) + ','
  373.             troop_data += '"pages":' + get_troop_pages(troop)
  374.            
  375.             troop_data += '}'
  376.             troop_data += ',' if x < $data_troops.size - 1
  377.             f.puts(troop_data)
  378.           end
  379.           f.puts(']')
  380.           f.close
  381.         end
  382.       
  383.         def self.get_troop_members(troop)
  384.           res = '['
  385.           count = 1
  386.           max_count = troop.members.size
  387.           troop.members.each do |enemy|
  388.             res += '{"enemyId":' + enemy.enemy_id.to_s + ','
  389.             res += '"x":' + enemy.x.to_s + ','
  390.             res += '"y":' + enemy.y.to_s + ','
  391.             res += '"hidden":' + enemy.hidden.to_s + '}'
  392.             res += ',' if count < max_count
  393.             count += 1
  394.           end
  395.           res += ']'
  396.           res
  397.         end
  398.       
  399.         def self.get_troop_pages(troop)
  400.           res = '['
  401.           count = 1
  402.           max_count = troop.pages.size
  403.           troop.pages.each do |page|
  404.             #***********************************************************************
  405.             log("  Page " + count.to_s)
  406.             @logkey = sprintf('%s Page %d', @logtroop, count)
  407.             #***********************************************************************
  408.             cond = page.condition
  409.             res += '{"conditions":{"actorHp":' + cond.actor_hp.to_s + ','
  410.             res += '"actorId":' + cond.actor_id.to_s + ','
  411.             res += '"actorValid":' + cond.actor_valid.to_s + ','
  412.             res += '"enemyHp":' + cond.enemy_hp.to_s + ','
  413.             res += '"enemyIndex":' + cond.enemy_index.to_s + ','
  414.             res += '"enemyValid":' + cond.enemy_valid.to_s + ','
  415.             res += '"switchId":' + cond.switch_id.to_s + ','
  416.             res += '"switchValid":' + cond.switch_valid.to_s + ','
  417.             res += '"turnA":' + cond.turn_a.to_s + ','
  418.             res += '"turnB":' + cond.turn_b.to_s + ','
  419.             res += '"turnEnding":' + cond.turn_ending.to_s + ','
  420.             res += '"turnValid":' + cond.turn_valid.to_s + '},'
  421.            
  422.             res += '"list":' + get_command_list(page.list) + ','
  423.             res += '"span":' + page.span.to_s + '}'
  424.            
  425.             res += ',' if count < max_count
  426.             count += 1
  427.           end
  428.           res += ']'
  429.           res
  430.         end
  431.       
  432.         #===========================================================================
  433.         # STATES
  434.         #===========================================================================
  435.         def self.convert_states
  436.           f = File.open(FOLDER + "States.json", "w")
  437.           f.puts('[')
  438.           f.puts('null,')
  439.           for x in 1 ... $data_states.size
  440.             state = $data_states[x]
  441.             state = RPG::State.new if !state
  442.             state_data = '{'
  443.            
  444.             state_data += '"id":' + x.to_s + ','
  445.             state_data += '"autoRemovalTiming":' + state.auto_removal_timing.to_s + ','
  446.             state_data += '"chanceByDamage":' + state.chance_by_damage.to_s + ','
  447.             state_data += '"iconIndex":' + state.icon_index.to_s + ','
  448.             state_data += '"maxTurns":' + state.max_turns.to_s + ','
  449.             state_data += '"message1":' + get_text(state.message1) + ','
  450.             state_data += '"message2":' + get_text(state.message2) + ','
  451.             state_data += '"message3":' + get_text(state.message3) + ','
  452.             state_data += '"message4":' + get_text(state.message4) + ','
  453.             state_data += '"minTurns":' + state.min_turns.to_s + ','
  454.             state_data += '"motion":0,'
  455.             state_data += '"overlay":0,'
  456.             state_data += '"name":' + get_text(state.name) + ','
  457.             state_data += '"note":' + get_text(state.note) + ','
  458.             state_data += '"priority":' + state.priority.to_s + ','
  459.             state_data += '"removeAtBattleEnd":' + state.remove_at_battle_end.to_s + ','
  460.             state_data += '"removeByDamage":' + state.remove_by_damage.to_s + ','
  461.             state_data += '"removeByRestriction":' + state.remove_by_restriction.to_s + ','
  462.             state_data += '"removeByWalking":' + state.remove_by_walking.to_s + ','
  463.             state_data += '"restriction":' + state.restriction.to_s + ','
  464.             state_data += '"stepsToRemove":' + state.steps_to_remove.to_s + ','
  465.             state_data += '"traits":' + get_traits(state)        
  466.            
  467.             state_data += '}'
  468.             state_data += ',' if x < $data_states.size - 1
  469.             f.puts(state_data)
  470.           end
  471.           f.puts(']')
  472.           f.close
  473.         end
  474.       
  475.         #===========================================================================
  476.         # ANIMATIONS
  477.         #===========================================================================
  478.         def self.convert_animations
  479.           f = File.open(FOLDER + "Animations.json", "w")
  480.           f.puts('[')
  481.           f.puts('null,')
  482.           for x in 1 ... $data_animations.size
  483.             anim = $data_animations[x]
  484.             anim = RPG::Animation.new if !anim
  485.             anim_data = '{'
  486.            
  487.             anim_data += '"id":' + x.to_s + ','
  488.             anim_data += '"animation1Hue":' + anim.animation1_hue.to_s + ','
  489.             anim_data += '"animation1Name":"' + anim.animation1_name + '",'
  490.             anim_data += '"animation2Hue":' + anim.animation2_hue.to_s + ','
  491.             anim_data += '"animation2Name":"' + anim.animation2_name + '",'
  492.             anim_data += '"frames":' + get_anim_frames(anim) + ','
  493.             anim_data += '"name":' + get_text(anim.name) + ','
  494.             anim_data += '"position":' + anim.position.to_s + ','
  495.             anim_data += '"timings":' + get_anim_timings(anim)
  496.            
  497.             anim_data += '}'
  498.             anim_data += ',' if x < $data_animations.size - 1
  499.             f.puts(anim_data)
  500.           end
  501.           f.puts(']')
  502.           f.close
  503.         end
  504.       
  505.         def self.get_anim_frames(anim)
  506.           res = '['
  507.           for f in 0 ... anim.frame_max
  508.             res += '['
  509.             frame = anim.frames[f]
  510.             if frame
  511.               for c in 0 ... frame.cell_max
  512.                 res += '['
  513.                 for i in 0..7
  514.                   res += frame.cell_data[c,i].to_s
  515.                   res += ',' if i < 7
  516.                 end
  517.                 res += ']'
  518.                 res += ',' if c < frame.cell_max - 1
  519.               end
  520.             else
  521.               res += '[]'
  522.             end
  523.             res += ']'
  524.             res += ',' if f < anim.frame_max - 1
  525.           end
  526.           res += ']'
  527.           res
  528.         end
  529.       
  530.         def self.get_anim_timings(anim)
  531.           res = '['
  532.           for t in 0 ... anim.timings.size
  533.             timing = anim.timings[t]
  534.             res += '{"flashColor":' + get_color(timing.flash_color) + ','
  535.             res += '"flashDuration":' + timing.flash_duration.to_s + ','
  536.             res += '"flashScope":' + timing.flash_scope.to_s + ','
  537.             res += '"frame":' + timing.frame.to_s + ','
  538.             res += '"se":'
  539.             if timing.se.name == ''
  540.               res += 'null'
  541.             else
  542.               res += get_audio(timing.se)
  543.             end
  544.             res += '}'
  545.             res += ',' if t < anim.timings.size - 1
  546.           end
  547.           res += ']'
  548.           res
  549.         end
  550.       
  551.         #===========================================================================
  552.         # TILESETS
  553.         #===========================================================================
  554.         def self.convert_tilesets
  555.           f = File.open(FOLDER + "Tilesets.json", "w")
  556.           f.puts('[')
  557.           f.puts('null,')
  558.           for x in 1 ... $data_tilesets.size
  559.             tileset = $data_tilesets[x]
  560.             tileset = RPG::Tileset.new if !tileset
  561.             ts_data = '{'
  562.            
  563.             ts_data += '"id":' + x.to_s + ','
  564.             ts_data += '"flags":'
  565.             flags = []
  566.             for t in 0 .. 8191
  567.               flags[t] = tileset.flags[t]
  568.             end
  569.             ts_data += flags.to_s.gsub(/ /){''} + ','
  570.             ts_data += '"mode":' + tileset.mode.to_s + ','
  571.             ts_data += '"name":' + get_text(tileset.name) + ','
  572.             ts_data += '"note":' + get_text(tileset.note) + ','
  573.             ts_data += '"tilesetNames":' + tileset.tileset_names.to_s.gsub(/, /){','}
  574.            
  575.             ts_data += '}'
  576.             ts_data += ',' if x < $data_tilesets.size - 1
  577.             f.puts(ts_data)
  578.           end
  579.           f.puts(']')
  580.           f.close
  581.         end
  582.       
  583.         #===========================================================================
  584.         # COMMON EVENTS
  585.         #===========================================================================
  586.         def self.convert_common_events
  587.           f = File.open(FOLDER + "CommonEvents.json", "w")
  588.           f.puts('[')
  589.           f.puts('null,')
  590.           for x in 1 ... $data_common_events.size
  591.             event = $data_common_events[x]
  592.             event = RPG::CommonEvent.new if !event
  593.            
  594.             #***********************************************************************
  595.             log("Common Event " + x.to_s + " (" + get_text(event.name) + ")")
  596.             @logkey = sprintf('Common Event %d %s', x, event.name)
  597.             #***********************************************************************
  598.            
  599.             ev_data = '{'
  600.            
  601.             ev_data += '"id":' + x.to_s + ','
  602.             ev_data += '"list":' + get_command_list(event.list) + ','
  603.             ev_data += '"name":' + get_text(event.name) + ','
  604.             ev_data += '"switchId":' + event.switch_id.to_s + ','
  605.             ev_data += '"trigger":' + event.trigger.to_s
  606.            
  607.             ev_data += '}'
  608.             ev_data += ',' if x < $data_common_events.size - 1
  609.             f.puts(ev_data)
  610.           end
  611.           f.puts(']')
  612.           f.close
  613.         end
  614.       
  615.         #===========================================================================
  616.         # SYSTEM
  617.         #===========================================================================
  618.         def self.convert_system
  619.           f = File.open(FOLDER + "System.json", "w")
  620.           system = $data_system
  621.           sys_data = '{'
  622.          
  623.           sys_data += '"airship":' + get_vehicle(system.airship) + ','
  624.           sys_data += '"armorTypes":' + system.armor_types.to_s.gsub(/, /){','} + ','
  625.           sys_data += '"attackMotions":' + get_attack_motions + ','
  626.           sys_data += '"battleBgm":' + get_audio(system.battle_bgm) + ','
  627.           sys_data += '"battleBack1Name":"' + system.battleback1_name + '",'
  628.           sys_data += '"battleBack2Name":"' + system.battleback2_name + '",'
  629.           sys_data += '"battlerHue":' + system.battler_hue.to_s + ','
  630.           sys_data += '"battlerName":"' + system.battler_name + '",'
  631.           sys_data += '"boat":' + get_vehicle(system.boat) + ','
  632.           sys_data += '"currencyUnit":"' + system.currency_unit + '",'
  633.           sys_data += '"defeatMe":{"name":"Defeat1","pan":0,"pitch":100,"volume":90},'
  634.           sys_data += '"editMapId":' + system.edit_map_id.to_s + ','
  635.           sys_data += '"elements":' + system.elements.to_s.gsub(/, /){','} + ','
  636.           sys_data += '"equipTypes":' + system.terms.etypes.unshift('').to_s.gsub(/, /){','} + ','
  637.           sys_data += '"gameTitle":' + get_text(system.game_title) + ','
  638.           sys_data += '"gameoverMe":' + get_audio(system.gameover_me) + ','
  639.           sys_data += '"locale":"en_US",'
  640.           sys_data += '"magicSkills":[1],'
  641.           sys_data += '"menuCommands":[true,true,true,true,true,true],'
  642.           sys_data += '"optDisplayTp":' + system.opt_display_tp.to_s + ','
  643.           sys_data += '"optDrawTitle":' + system.opt_draw_title.to_s + ','
  644.           sys_data += '"optExtraExp":' + system.opt_extra_exp.to_s + ','
  645.           sys_data += '"optFloorDeath":' + system.opt_floor_death.to_s + ','
  646.           sys_data += '"optFollowers":' + system.opt_followers.to_s + ','
  647.           sys_data += '"optSideView":false,'
  648.           sys_data += '"optSlipDeath":' + system.opt_slip_death.to_s + ','
  649.           sys_data += '"optTransparent":' + system.opt_transparent.to_s + ','
  650.           sys_data += '"partyMembers":' + system.party_members.to_s.gsub(/ /){''} + ','
  651.           sys_data += '"ship":' + get_vehicle(system.ship) + ','
  652.           sys_data += '"skillTypes":' + system.skill_types.to_s.gsub(/, /){','} + ','
  653.           sys_data += '"sounds":' + get_system_sounds(system) + ','
  654.           sys_data += '"startMapId":' + system.start_map_id.to_s + ','
  655.           sys_data += '"startX":' + system.start_x.to_s + ','
  656.           sys_data += '"startY":' + system.start_y.to_s + ','
  657.           system.switches[0] = ''
  658.           sys_data += '"switches":' + system.switches.to_s.gsub(/, /){','} + ','
  659.           sys_data += '"terms":{"basic":' + (system.terms.basic + ['EXP','EXP']).to_s.gsub(/, /){','} + ','
  660.           system.terms.commands[11] = 'Options'
  661.           sys_data += '"commands":' + (system.terms.commands + ['Buy','Sell']).to_s.gsub(/, /){','} + ','
  662.           sys_data += '"params":' + (system.terms.params + ['Hit','Evasion']).to_s.gsub(/, /){','} + ','
  663.           sys_data += '"messages":' + get_system_messages + '},'
  664.           sys_data += '"testBattlers":' + get_test_battlers(system.test_battlers) + ','
  665.           sys_data += '"testTroopId":' + system.test_troop_id.to_s + ','
  666.           sys_data += '"title1Name":"' + system.title1_name + '",'
  667.           sys_data += '"title2Name":"' + system.title2_name + '",'
  668.           sys_data += '"titleBgm":' + get_audio(system.title_bgm) + ','
  669.           system.variables[0] = ''
  670.           sys_data += '"variables":' + system.variables.to_s.gsub(/, /){','} + ','
  671.           sys_data += '"versionId":' + system.version_id.to_s + ','
  672.           sys_data += '"victoryMe":' + get_audio(system.battle_end_me) + ','
  673.           sys_data += '"weaponTypes":' + system.weapon_types.to_s.gsub(/, /){','} + ','
  674.           sys_data += '"windowTone":' + get_tone(system.window_tone)
  675.          
  676.           sys_data += '}'
  677.           f.puts(sys_data)
  678.           f.close
  679.         end
  680.       
  681.         def self.get_attack_motions
  682.           res = '['
  683.           res += '{"type":0,"weaponImageId":0},'
  684.           res += '{"type":1,"weaponImageId":1},'
  685.           res += '{"type":1,"weaponImageId":2},'
  686.           res += '{"type":1,"weaponImageId":3},'
  687.           res += '{"type":1,"weaponImageId":4},'
  688.           res += '{"type":1,"weaponImageId":5},'
  689.           res += '{"type":1,"weaponImageId":6},'
  690.           res += '{"type":2,"weaponImageId":7},'
  691.           res += '{"type":2,"weaponImageId":8},'
  692.           res += '{"type":2,"weaponImageId":9},'
  693.           res += '{"type":0,"weaponImageId":10},'
  694.           res += '{"type":0,"weaponImageId":11},'
  695.           res += '{"type":0,"weaponImageId":12}'
  696.           res += ']'
  697.           res
  698.         end
  699.          
  700.         def self.get_vehicle(vehicle)
  701.           res = '{"bgm":' + get_audio(vehicle.bgm) + ','
  702.           res += '"characterIndex":' + vehicle.character_index.to_s + ','
  703.           res += '"characterName":"' + vehicle.character_name + '",'
  704.           res += '"startMapId":' + vehicle.start_map_id.to_s + ','
  705.           res += '"startX":' + vehicle.start_x.to_s + ','
  706.           res += '"startY":' + vehicle.start_y.to_s + '}'
  707.           res
  708.         end
  709.       
  710.         def self.get_system_sounds(system)
  711.           res = '['
  712.           for x in 0 ... system.sounds.size
  713.             res += get_audio(system.sounds[x])
  714.             res += ',' if x < system.sounds.size - 1
  715.           end
  716.          
  717.           res += ']'
  718.           res
  719.         end
  720.       
  721.         def self.get_system_messages
  722.           res = '{'
  723.           res += '"actionFailure":"There was no effect on %1!",'
  724.           res += '"actorDamage":"%1 took %2 damage!",'
  725.           res += '"actorDrain":"%1 was drained of %2 %3!",'
  726.           res += '"actorGain":"%1 gained %2 %3!",'
  727.           res += '"actorLoss":"%1 lost %2 %3!",'
  728.           res += '"actorNoDamage":"%1 took no damage!",'
  729.           res += '"actorNoHit":"Miss! %1 took no damage!",'
  730.           res += '"actorRecovery":"%1 recovered %2 %3!",'
  731.           res += '"alwaysDash":"Always Dash",'
  732.           res += '"bgmVolume":"BGM Volume",'
  733.           res += '"bgsVolume":"BGS Volume",'
  734.           res += '"buffAdd":"%1\'s %2 went up!",'
  735.           res += '"buffRemove":"%1''s %2 returned to normal!",'
  736.           res += '"commandRemember":"Command Remember",'
  737.           res += '"counterAttack":"%1 counterattacked!",'
  738.           res += '"criticalToActor":"A painful blow!!",'
  739.           res += '"criticalToEnemy":"An excellent hit!!",'
  740.           res += '"debuffAdd":"%1\'s %2 went down!",'
  741.           res += '"defeat":"%1 was defeated.",'
  742.           res += '"emerge":"%1 emerged!",'
  743.           res += '"enemyDamage":"%1 took %2 damage!",'
  744.           res += '"enemyDrain":"%1 was drained of %2 %3!",'
  745.           res += '"enemyGain":"%1 gained %2 %3!",'
  746.           res += '"enemyLoss":"%1 lost %2 %3!",'
  747.           res += '"enemyNoDamage":"%1 took no damage!",'
  748.           res += '"enemyNoHit":"Miss! %1 took no damage!",'
  749.           res += '"enemyRecovery":"%1 recovered %2 %3!",'
  750.           res += '"escapeFailure":"However, it was unable to escape!",'
  751.           res += '"escapeStart":"%1 has started to escape!",'
  752.           res += '"evasion":"%1 evaded the attack!",'
  753.           res += '"expNext":"To Next %1",'
  754.           res += '"expTotal":"Current %1",'
  755.           res += '"file":"File",'
  756.           res += '"levelUp":"%1 is now %2 %3!",'
  757.           res += '"loadMessage":"Load which file?",'
  758.           res += '"magicEvasion":"%1 nullified the magic!",'
  759.           res += '"magicReflection":"%1 reflected the magic!",'
  760.           res += '"meVolume":"ME Volume",'
  761.           res += '"obtainExp":"%1 %2 received!",'
  762.           res += '"obtainGold":"%1\\\\G found!",'
  763.           res += '"obtainItem":"%1 found!",'
  764.           res += '"obtainSkill":"%1 learned!",'
  765.           res += '"partyName":"%1\'s Party",'
  766.           res += '"possession":"Possession",'
  767.           res += '"preemptive":"%1 got the upper hand!",'
  768.           res += '"saveMessage":"Save to which file?",'
  769.           res += '"seVolume":"SE Volume",'
  770.           res += '"substitute":"%1 protected %2!",'
  771.           res += '"surprise":"%1 was surprised!",'
  772.           res += '"useItem":"%1 uses %2!",'
  773.           res += '"victory":"%1 was victorious!"'
  774.           res += '}'
  775.           res
  776.         end
  777.       
  778.         def self.get_test_battlers(battlers)
  779.           res = '['
  780.           for x in 0 ... battlers.size
  781.             battler = battlers[x]
  782.             res += '{'
  783.             res += '"actorId":' + battler.actor_id.to_s + ','
  784.             res += '"equips":' + battler.equips.to_s.gsub(/ /){''} + ','
  785.             res += '"level":' + battler.level.to_s
  786.             res += '}'
  787.             res += ',' if x < battlers.size - 1
  788.           end
  789.           res += ']'
  790.           res
  791.         end
  792.       
  793.         #===========================================================================
  794.         # MAPINFOS
  795.         #===========================================================================
  796.         def self.convert_mapinfos
  797.           f = File.open(FOLDER + "MapInfos.json", "w")
  798.           f.puts('[')
  799.           f.puts('null,')
  800.           max_key = $data_mapinfos.keys.max
  801.           for x in 1 .. max_key
  802.             map = $data_mapinfos[x]
  803.             if map
  804.               map_data = '{'
  805.               map_data += '"id":' + x.to_s + ','
  806.               map_data += '"expanded":' + map.expanded.to_s + ','
  807.               map_data += '"name":' + get_text(map.name) + ','
  808.               map_data += '"order":' + map.order.to_s + ','
  809.               map_data += '"parentId":' + map.parent_id.to_s + ','
  810.               map_data += '"scrollX":' + map.scroll_x.to_s + ','
  811.               map_data += '"scrollY":' + map.scroll_y.to_s
  812.               map_data += '}'
  813.             else
  814.               map_data = 'null'
  815.             end
  816.            
  817.             map_data += ',' if x < max_key
  818.             f.puts(map_data)
  819.           end      
  820.           f.puts(']')
  821.           f.close
  822.         end
  823.       
  824.      
  825.         #===========================================================================
  826.         # MAPS
  827.         #===========================================================================
  828.         def self.convert_map(filename)
  829.           map = load_data(filename)
  830.           f = File.open(FOLDER + filename.gsub(/Data\//){''}.gsub(/rvdata2/){'json'}, "w")
  831.           f.puts('{')
  832.          
  833.           #*************************************************************************
  834.           log("Map " + filename + " (" + map.display_name + ")")
  835.           filename.gsub!(/Map(\d+)\.rvdata2/) do
  836.             @logmap = sprintf('Map %d %s', $1.to_i, (
  837.               $data_mapinfos[$1.to_i] ? $data_mapinfos[$1.to_i].name : '???'))
  838.           end
  839.           #*************************************************************************
  840.          
  841.           map_data = '"autoplayBgm":' + map.autoplay_bgm.to_s + ','
  842.           map_data += '"autoplayBgs":' + map.autoplay_bgs.to_s + ','
  843.           map_data += '"battleback1Name":"' + map.battleback1_name + '",'
  844.           map_data += '"battleback2Name":"' + map.battleback2_name + '",'
  845.           map_data += '"bgm":' + get_audio(map.bgm) + ','
  846.           map_data += '"bgs":' + get_audio(map.bgs) + ','
  847.           map_data += '"disableDashing":' + map.disable_dashing.to_s + ','
  848.           map_data += '"displayName":' + get_text(map.display_name) + ','
  849.           map_data += '"encounterList":' + get_encounter_list(map.encounter_list) + ','
  850.           map_data += '"encounterStep":' + map.encounter_step.to_s + ','
  851.           map_data += '"height":' + map.height.to_s + ','
  852.           map_data += '"note":' + get_text(map.note) + ','
  853.           map_data += '"parallaxLoopX":' + map.parallax_loop_x.to_s + ','
  854.           map_data += '"parallaxLoopY":' + map.parallax_loop_y.to_s + ','
  855.           map_data += '"parallaxName":"' + map.parallax_name + '",'
  856.           map_data += '"parallaxShow":' + map.parallax_show.to_s + ','
  857.           map_data += '"parallaxSx":' + map.parallax_sx.to_s + ','
  858.           map_data += '"parallaxSy":' + map.parallax_sy.to_s + ','
  859.           map_data += '"scrollType":' + map.scroll_type.to_s + ','
  860.           map_data += '"specifyBattleback":' + map.specify_battleback.to_s + ','
  861.           map_data += '"tilesetId":' + map.tileset_id.to_s + ','
  862.           map_data += '"width":' + map.width.to_s + ','
  863.           map_data += '"data":' + get_map_data(map.data).to_s.gsub(/ /){''} + ','
  864.           map_data += '"events":' + get_map_events(map.events)
  865.           f.puts(map_data)
  866.          
  867.           f.puts('}')
  868.           f.close
  869.         end
  870.       
  871.         def self.get_encounter_list(list)
  872.           res = '['
  873.           for x in 0 ... list.size
  874.             encounter = list[x]
  875.             encounter = RPG::Map::Encounter.new if !encounter
  876.             res += '{"regionSet":' + encounter.region_set.to_s.gsub(/ /){''} + ','
  877.             res += '"troopId":' + encounter.troop_id.to_s + ','
  878.             res += '"weight":' + encounter.weight.to_s
  879.             res += '}'
  880.             res += ',' if x < list.size - 1
  881.           end
  882.           res += ']'
  883.           res
  884.         end
  885.       
  886.         def self.get_map_data(data)
  887.           res = []
  888.           for z in 0 ... data.zsize - 1 # 3 map layers
  889.             for y in 0 ... data.ysize
  890.               for x in 0 ... data.xsize
  891.                 res.push(data[x,y,z])
  892.               end
  893.             end
  894.           end
  895.           for y in 0 ... data.ysize # new 4th map layer?
  896.             for x in 0 ... data.xsize
  897.               res.push(0)
  898.             end
  899.           end
  900.           z = data.zsize - 1 # original 4th layer (regions + ???)
  901.           for y in 0 ... data.ysize
  902.             for x in 0 ... data.xsize
  903.               res.push(data[x,y,z])
  904.             end
  905.           end
  906.           for y in 0 ... data.ysize # regions
  907.             for x in 0 ... data.xsize
  908.               res.push(data[x,y,3] >> 8)
  909.             end
  910.           end
  911.           res
  912.         end
  913.       
  914.         def self.get_map_events(events)
  915.           res = '['
  916.           max_key = events.keys.max
  917.           if max_key
  918.             for x in 0 .. max_key
  919.               if events.has_key?(x)
  920.                 event = events[x]
  921.                 res += get_event(event)
  922.               else
  923.                 res += 'null'
  924.               end
  925.               res += ',' if x < max_key
  926.             end
  927.           end
  928.           res += ']'
  929.           res
  930.         end
  931.       
  932.         def self.get_event(event)
  933.           #*************************************************************************
  934.           log("  Event " + event.id.to_s + " (" + get_text(event.name) + " @ " + event.x.to_s + "," + event.y.to_s + ")")
  935.           @logevent = sprintf('%s - Event %d %s (%d,%d)', @logmap, event.id, event.name, event.x, event.y)
  936.           #*************************************************************************
  937.           res = '{"id":' + event.id.to_s + ','
  938.           res += '"name":' + get_text(event.name) + ','
  939.           res += '"note":"",'
  940.           res += '"pages":' + get_event_pages(event.pages) + ','
  941.           res += '"x":' + event.x.to_s + ','
  942.           res += '"y":' + event.y.to_s      
  943.           res += '}'
  944.           res
  945.         end
  946.       
  947.         def self.get_event_pages(pages)
  948.           res = '['
  949.           for x in 0 ... pages.size
  950.             #***********************************************************************
  951.             log("    Page " + (x+1).to_s)
  952.             @logkey = sprintf('%s - Page %d', @logevent, x+1)
  953.             #***********************************************************************
  954.             page = pages[x]
  955.             page = RPG::Event::Page.new if !page
  956.             res += get_page(page)
  957.             res += ',' if x < pages.size - 1
  958.           end
  959.           res += ']'
  960.           res
  961.         end
  962.            
  963.         def self.get_page(page)
  964.           condition = page.condition
  965.           res = '{"conditions":'
  966.           res += '{"actorId":' + condition.actor_id.to_s + ','
  967.           res += '"actorValid":' + condition.actor_valid.to_s + ','
  968.           res += '"itemId":' + condition.item_id.to_s + ','
  969.           res += '"itemValid":' + condition.item_valid.to_s + ','
  970.           res += '"selfSwitchCh":"' + condition.self_switch_ch + '",'
  971.           res += '"selfSwitchValid":' + condition.self_switch_valid.to_s + ','
  972.           res += '"switch1Id":' + condition.switch1_id.to_s + ','
  973.           res += '"switch1Valid":' + condition.switch1_valid.to_s + ','
  974.           res += '"switch2Id":' + condition.switch2_id.to_s + ','
  975.           res += '"switch2Valid":' + condition.switch2_valid.to_s + ','
  976.           res += '"variableId":' + condition.variable_id.to_s + ','
  977.           res += '"variableValid":' + condition.variable_valid.to_s + ','
  978.           res += '"variableValue":' + condition.variable_value.to_s + '},'
  979.          
  980.           res += '"directionFix":' + page.direction_fix.to_s + ','
  981.          
  982.           graphic = page.graphic
  983.           res += '"image":'
  984.           res += '{"tileId":' + graphic.tile_id.to_s + ','
  985.           res += '"characterName":"' + graphic.character_name + '",'
  986.           res += '"direction":' + graphic.direction.to_s + ','
  987.           res += '"pattern":' + graphic.pattern.to_s + ','
  988.           res += '"characterIndex":' + graphic.character_index.to_s + '},'
  989.          
  990.           res += '"moveFrequency":' + page.move_frequency.to_s + ','
  991.           res += '"moveRoute":' + get_move_route(page.move_route) + ','
  992.           res += '"moveSpeed":' + page.move_speed.to_s + ','
  993.           res += '"moveType":' + page.move_type.to_s + ','
  994.           res += '"priorityType":' + page.priority_type.to_s + ','
  995.           res += '"stepAnime":' + page.step_anime.to_s + ','
  996.           res += '"through":' + page.through.to_s + ','
  997.           res += '"trigger":' + page.trigger.to_s + ','
  998.           res += '"walkAnime":' + page.walk_anime.to_s + ','
  999.           res += '"list":' + get_command_list(page.list) + '}'
  1000.          
  1001.           res
  1002.         end
  1003.       
  1004.         #===========================================================================
  1005.         # SUPPORT OBJECTS FOR DATABASE
  1006.         #===========================================================================
  1007.       
  1008.         def self.get_traits(obj)
  1009.           res = '['
  1010.           count = 1
  1011.           max_count = obj.features.size
  1012.           obj.features.each do |feat|
  1013.             res += '{"code":' + feat.code.to_s + ','
  1014.             res += '"dataId":' + feat.data_id.to_s + ','
  1015.             res += '"value":' + feat.value.to_s + '}'
  1016.             res += ',' if count < max_count
  1017.             count += 1
  1018.           end      
  1019.           res += ']'
  1020.           res
  1021.         end
  1022.       
  1023.         def self.get_effects(obj)
  1024.           res = '['
  1025.           count = 1
  1026.           max_count = obj.effects.size
  1027.           obj.effects.each do |effct|
  1028.             res += '{"code":' + effct.code.to_s + ','
  1029.             res += '"dataId":' + effct.data_id.to_s + ','
  1030.             res += '"value1":' + effct.value1.to_s + ','
  1031.             res += '"value2":' + effct.value2.to_s + '}'
  1032.             res += ',' if count < max_count
  1033.             count += 1
  1034.           end      
  1035.           res += ']'
  1036.           res
  1037.         end
  1038.       
  1039.         def self.get_damage(obj)
  1040.           dmg = obj.damage
  1041.          
  1042.           if LOGSCRIPTS && obj.damage.formula.to_i.to_s != obj.damage.formula
  1043.             sl_data = sprintf('%s %d %s: Damage Formula: %s',
  1044.               (obj.is_a?(RPG::Skill) ? 'Skill' : 'Item'), obj.id, obj.name, dmg.formula)
  1045.             @scriptlog.puts(sl_data)
  1046.           end
  1047.          
  1048.           res = '{"critical":' + dmg.critical.to_s + ','
  1049.           res += '"elementId":' + dmg.element_id.to_s + ','
  1050.           res += '"formula":"' + dmg.formula + '",'
  1051.           res += '"type":' + dmg.type.to_s + ','
  1052.           res += '"variance":' + dmg.variance.to_s + '}'
  1053.           res
  1054.         end
  1055.       
  1056.       
  1057.         #===========================================================================
  1058.         #
  1059.         # EVENT COMMANDS
  1060.         #
  1061.         #===========================================================================
  1062.       
  1063.         #===========================================================================
  1064.         # COMMAND LISTS
  1065.         #===========================================================================
  1066.       
  1067.         def self.get_command_list(list)
  1068.           res = '['
  1069.           count = 1
  1070.           max_count = list.size
  1071.           list.each do |cmd|
  1072.             @loginfo = sprintf('%s Line %d: ', @logkey, count)
  1073.            
  1074.             case cmd.code
  1075.             when 102 # show choices
  1076.               cmd.parameters[1] -= 1 # disallow cancel
  1077.               cmd.parameters[1] = -2 if cmd.parameters[1] == 4 # branch on cancel
  1078.               cmd.parameters[2] = 0 # default
  1079.               cmd.parameters[3] = 2 # window position
  1080.               cmd.parameters[4] = 0 # window background
  1081.             when 104
  1082.               cmd.parameters[1] = 2 # key item
  1083.             when 108, 408 # comment
  1084.               log_comment(cmd.parameters[0])
  1085.             when 111
  1086.               if cmd.parameters[0] == 11 # Key Pressed
  1087.                 # ASD buttons are not catered for in MV.  To use these, you will
  1088.                 # have to add 41 (A), 43 (S) and 44 (D) to the Input.keyMapper hash
  1089.                 # in rpg_core.js:
  1090.                 # Input.keyMapper[41] = 'A'
  1091.                 # Input.keyMapper[53] = 'S'
  1092.                 # Input.keyMapper[44] = 'D'
  1093.                 case cmd.parameters[1]
  1094.                 when 14
  1095.                   cmd.parameters = [12, "Input.isTriggered('A')"]
  1096.                 when 15
  1097.                   cmd.parameters = [12, "Input.isTriggered('S')"]
  1098.                 when 16
  1099.                   cmd.parameters = [12, "Input.isTriggered('D')"]
  1100.                 else
  1101.                   cmd.parameters[1] = ['', '', 'down', '', 'left', '', 'right', '', 'up',
  1102.                     '', '', 'shift', 'cancel', 'ok', '', '', '', 'pageup', 'pagedown'][
  1103.                     cmd.parameters[1]]
  1104.                 end
  1105.               elsif cmd.parameters[0] == 12 # Script
  1106.                 log_script('Conditional Branch script call', cmd.parameters[1])
  1107.               end
  1108.             when 122 # Control Variables
  1109.               if cmd.parameters[3] == 4 # Script
  1110.                 log_script('Control Variables script call', cmd.parameters[4])
  1111.               end
  1112.             when 231 # show picture
  1113.               if cmd.parameters[9] == 2 # subtract
  1114.                 params = cmd.parameters
  1115.                 cmd.code = 355
  1116.                 cmd.parameters = [sprintf('$gameScreen.showPicture(%d, "%s", %d, %s, %s, %d, %d, %d, %d)',
  1117.                   params[0], params[1], params[2], (params[3] == 0 ? params[4].to_s : '$gameVariables.value(' + params[4].to_s + ')'),
  1118.                   (params[3] == 0 ? params[5].to_s : '$gameVariables.value(' + params[5].to_s + ')'),
  1119.                   params[6], params[7], params[8], params[9])]
  1120.               end
  1121.             when 232 # move picture
  1122.               cmd.parameters[1] = 0 # not used, but can't be blank in MV
  1123.               if cmd.parameters[9] == 2 # subtract
  1124.                 params = cmd.parameters
  1125.                 cmd.code = 355
  1126.                 cmd.parameters = [sprintf('$gameScreen.movePicture(%d, %d, %s, %s, %d, %d, %d, %d, %d)%s',
  1127.                   params[0], params[2], (params[3] == 0 ? params[4].to_s : '$gameVariables.value(' + params[4].to_s + ')'),
  1128.                   (params[3] == 0 ? params[5].to_s : '$gameVariables.value(' + params[5].to_s + ')'),
  1129.                   params[6], params[7], params[8], params[9], params[10], params[11] ? '; this.wait(' + params[10].to_s + ')' : '')]
  1130.               end
  1131.             when 285 # get location info
  1132.               cmd.parameters[1] = 6 if cmd.parameters[1] == 5 # region id now +1
  1133.             when 319 # change equipment
  1134.               cmd.parameters[1] += 1
  1135.             when 322 # change actor graphic
  1136.               cmd.parameters[4] = 0 # SV graphic
  1137.               cmd.parameters[5] = ''
  1138.             when 355, 655 # Script call
  1139.               log_script('Script call', cmd.parameters[0])
  1140.             when 505 # Move route
  1141.               mvrcmd = cmd.parameters[0]
  1142.               if mvrcmd.code == 45 # script
  1143.                 log_script('Move Route Script call', mvrcmd.parameters[0])
  1144.               end
  1145.             end
  1146.            
  1147.             evt_cmd = '{"code":' + cmd.code.to_s + ','
  1148.             evt_cmd += '"indent":' + cmd.indent.to_s + ','
  1149.             evt_cmd += '"parameters":' + convert_parameters(cmd.parameters) + '}'
  1150.            
  1151.             #***********************************************************************
  1152.             log("      " + evt_cmd)
  1153.             #***********************************************************************
  1154.            
  1155.             res += evt_cmd
  1156.             res += ',' if count < max_count
  1157.             count += 1
  1158.           end
  1159.           res += ']'
  1160.           res
  1161.         end
  1162.       
  1163.         def self.get_move_route(mr)
  1164.           res = '{"list":['
  1165.           list = mr.list
  1166.           for x in 0 ... list.size
  1167.             cmd = list[x]
  1168.            
  1169.             case cmd.code
  1170.             when 43
  1171.               if cmd.parameters[0] == 2 then
  1172.                 cmd.code = 45
  1173.                 cmd.parameters = ["this.setBlendMode(2);"]
  1174.               end
  1175.             end
  1176.            
  1177.             mvr = '{"code":' + cmd.code.to_s + ','
  1178.             mvr += '"indent":null,'
  1179.             mvr += '"parameters":' + convert_parameters(cmd.parameters) + '}'
  1180.            
  1181.             #***********************************************************************
  1182.             log("        " + mvr)
  1183.             #***********************************************************************
  1184.            
  1185.             res += mvr
  1186.             res += ',' if x < list.size - 1
  1187.           end
  1188.           res += '],"repeat":' + mr.repeat.to_s + ','
  1189.           res += '"skippable":' + mr.skippable.to_s + ','
  1190.           res += '"wait":' + mr.wait.to_s + '}'
  1191.           res
  1192.         end
  1193.       
  1194.         def self.convert_parameters(params)
  1195.           res = '['
  1196.           for x in 0 ... params.size
  1197.             param = params[x]
  1198.             case param
  1199.             when RPG::MoveRoute
  1200.               param = get_move_route(param)
  1201.             when RPG::MoveCommand
  1202.               param = get_move_command(param)
  1203.             when RPG::AudioFile
  1204.               param = get_audio(param)
  1205.             when String
  1206.               param = get_text(param)
  1207.             when Symbol
  1208.               param = get_text(param.to_s)
  1209.             when Tone
  1210.               param = get_tone(param)
  1211.             when Color
  1212.               param = get_color(param)
  1213.             end
  1214.            
  1215.             res += param.to_s
  1216.             res += ',' if x < params.size - 1
  1217.           end
  1218.           res += ']'
  1219.           res
  1220.         end
  1221.             
  1222.       
  1223.         #===========================================================================
  1224.         # COMMANDS
  1225.         #===========================================================================
  1226.       
  1227.         def self.get_move_command(param)
  1228.           res = '{"code":' + param.code.to_s + ','
  1229.           res += '"indent":null,'
  1230.           res += '"parameters":' + convert_parameters(param.parameters).to_s + '}'
  1231.           res
  1232.         end
  1233.       
  1234.         #===========================================================================
  1235.         # COMMON OBJECTS
  1236.         #===========================================================================
  1237.       
  1238.         def self.get_text(text)
  1239.           '"' + text.gsub(/\\/){'\\\\'}.gsub(/[\r\n]+/){'\\n'}.gsub(/"/){'\"'} + '"'
  1240.        end
  1241.       
  1242.        def self.get_audio(a)
  1243.          a = RPG::AudioFile.new if !a
  1244.          res = '{"name":"' + a.name + '",'
  1245.          res += '"pan":0,'
  1246.          res += '"pitch":' + a.pitch.to_s + ','
  1247.          res += '"volume":' + a.volume.to_s + '}'
  1248.          res
  1249.        end      
  1250.       
  1251.        def self.get_color(color)
  1252.          res = '['
  1253.          res += color.red.to_s + ','
  1254.          res += color.green.to_s + ','
  1255.          res += color.blue.to_s + ','
  1256.          res += color.alpha.to_s
  1257.          res += ']'
  1258.          res
  1259.        end
  1260.       
  1261.        def self.get_tone(tone)
  1262.          res = '['
  1263.          res += tone.red.to_s + ','
  1264.          res += tone.green.to_s + ','
  1265.          res += tone.blue.to_s + ','
  1266.          res += tone.gray.to_s
  1267.          res += ']'
  1268.          res
  1269.        end
  1270.       
  1271.        def self.log(details)
  1272.          @log.puts(details) if LOGGING
  1273.        end
  1274.       
  1275.        def self.log_script(title, cmd)
  1276.          @scriptlog.puts(sprintf('%s - %s: %s', @loginfo, title, cmd)) if LOGSCRIPTS
  1277.        end
  1278.       
  1279.        def self.log_comment(comment)
  1280.          @commentlog.puts(sprintf('%s - Comment: %s', @loginfo, comment)) if LOGCOMMENTS
  1281.        end
  1282.      end
  1283.     end
  1284.     DEGICA::CONVERT::run

复制代码

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
 楼主| 发表于 2015-10-25 17:06:14 | 显示全部楼层
手順:
在VX Ace 加入脚本
Image001.png
運行後,資料庫導出到文件夾中
Image002.png
把這些copy到MⅤ新遊戲Data文件夾
Image003.png
効果
Image004.png
回复 1 0

使用道具 举报

梦石
0
星屑
50
在线时间
26 小时
注册时间
2011-8-23
回帖
3
发表于 2015-10-25 18:40:51 | 显示全部楼层
用了,好用!赞一个!
回复

使用道具 举报

护国公

梦石
0
星屑
1831
在线时间
2023 小时
注册时间
2005-10-21
回帖
508
发表于 2015-10-25 19:10:05 | 显示全部楼层
怎么样切换成日文啊

点评

好的 谢谢 我还是等中文吧 要是有中文的就好了 囧TZ  发表于 2015-10-25 19:30
我誤會了,因某些関係,window是日文(window7pro可自轉日文)  发表于 2015-10-25 19:21
用日文的範例,轉出来就是日文  发表于 2015-10-25 19:19
[IMG][/IMG] ================================== 寂寥宁静雅致之心 ================================== mahoro-matic mirclecompany http://www.mday.com.cn/
回复

使用道具 举报

…あたしは天

梦石
0
星屑
2311
在线时间
4033 小时
注册时间
2010-10-4
回帖
10548

开拓者贵宾

发表于 2015-10-25 19:17:12 | 显示全部楼层
手写 to_json 哈哈哈哈哈哈哈 叫你不支持ruby标准库

点评

叫他不用Seiran30的MyJsonWriter  发表于 2015-10-25 21:39
能者多労[碌]  发表于 2015-10-25 19:23
回复

使用道具 举报

梦石
0
星屑
2116
在线时间
950 小时
注册时间
2015-7-16
回帖
692

开拓者

发表于 2015-10-26 01:03:25 | 显示全部楼层
太神了
光是把標題改得跟VA一樣還開得起來就很厲害了
當然,腳本滿天飛的遊戲還是會出一卡車錯誤
但,夠用
[神性领域扩张:扩张神性领域]
说了等于没说.
回复

使用道具 举报

梦石
1
星屑
7574
在线时间
2650 小时
注册时间
2013-8-23
回帖
2152

开拓者

发表于 2015-10-26 11:33:32 | 显示全部楼层
补充:
VA头像转MV头像

http://waifu2x.udp.jp/

具体方法请看视频
http://dwz.cn/25PYJL

视频名称:
Change Tile Size Plugin Tutorial

点评

感谢,最后还是得先1.6倍放大+PS压回1.5倍啊……  发表于 2015-10-31 17:53
http://dwz.cn/276Ewo  发表于 2015-10-31 07:55
这个的效果确实很好,然而只能扩大1.6或者2倍,也没1.5倍的啊……教程链接是空的  发表于 2015-10-31 01:05
用ImageResizer快得多 http://rm.66rpg.com/forum.php?mod=viewthread&tid=383884&page=2#pid2640581  发表于 2015-10-26 11:38
回复

使用道具 举报

梦石
0
星屑
3348
在线时间
1120 小时
注册时间
2009-4-15
回帖
761
发表于 2015-10-27 22:19:21 | 显示全部楼层
大神,这个VA转MV的功能能转换哪些内容?数据库所有数据、图片、文件以及脚本吗?

点评

图片、文件以及脚本都没有  发表于 2015-10-29 23:41
回复

使用道具 举报

梦石
0
星屑
150
在线时间
138 小时
注册时间
2011-1-19
回帖
8
发表于 2015-10-28 21:09:31 | 显示全部楼层
呃,我想问问,如果导出后出现“不能读取文件system.json”的问题,是脚本出问题了么?还是我要把之前的素材也一并放进新工程的文件夹内才行?
回复

使用道具 举报

梦石
0
星屑
50
在线时间
21 小时
注册时间
2014-2-13
回帖
5
发表于 2015-11-4 23:13:25 | 显示全部楼层
怎么下载资料库呀?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部