Advertisement
Astfgl

Astfgl V0.7 09/07/2016

Jul 9th, 2016
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Astfgl's QOL script box improvements v0.7
  3. // by Astfgl
  4. // Date: 09/07/2016  
  5. //
  6. // You are allowed to use this plugin free of charge, both for commercial and
  7. // non commercial use. If used in a commercial project, a free copy would be
  8. // nice, but is not required. You are freely allowed to edit this plugin, but
  9. // you must keep this header intact and readable. You are not allowed to
  10. // release anything using or based on this plugin without abiding by this
  11. // license. Your credits must include "Scriptbox QOL Improvements by Astfgl".
  12. // Furthermore, you are not allowed to release this plugin or any version you
  13. // have edited, on any forum but the official rpgmakerweb.com forums without my
  14. // express written permission. Do not claim ownership.
  15. //
  16. // I'd much appreciate a PM on the RPGMakerweb.com forums if you find a clever use
  17. // for one or more event commands I provided: profile Astfgl66. Or write in the
  18. // thread.
  19. //
  20. // If you have any suggestion for a command you'd like referenced, drop me a PM
  21. // and I'll see what i can do. If you provide me with the exact script call
  22. // there's a 99% chanche it will make it in!
  23. //
  24. // Credits:
  25. //      -Plugin template made by Faytless / Thomas Pham. Without that, I
  26. // would still be making modification in the core files.
  27. //      -The point in polygon formula was taken from the internet.
  28. // Credit in comment near the command along with link to the source.
  29. // It is free to use and redistribute, under MIT license. It means you have
  30. // to credit them too.
  31. //      -RPG Maker extender project for RPGMaker VXACE, for providing me with the idea
  32. // and need to do this plugin.
  33. //      -Tsukihime for the plugin jump_to_label via script call for Ace, which
  34. // inspired me to write the function for MV.
  35. //=============================================================================
  36.  
  37.  
  38. /*:
  39.  * @plugindesc Script box syntax QOL improvements for eventing
  40.  * @author Astfgl
  41.  *
  42.  * @param No params are available
  43.  * @desc
  44.  * @default ---  
  45.  
  46.  */
  47.  
  48.   (function() {
  49.   var parameters = PluginManager.parameters('Astgfl');
  50.  
  51.  
  52.  // Below i define all the functions that can be used while inside a script box
  53.  
  54.   var _Game_Interpreter_Astfgl = Game_Interpreter.prototype.command355;
  55.  
  56.   Game_Interpreter.prototype.command355 = function() {
  57.     var variableId, Index, value
  58.     var script = this.currentCommand().parameters[0] + '\n';
  59.     while (this.nextEventCode() === 655) {
  60.         this._index++;
  61.         script += this.currentCommand().parameters[0] + '\n';
  62.     }
  63.    
  64.     var SV = function(variableId, value) {
  65.         $gameVariables.setValue(variableId, value)
  66.     }
  67.    
  68.     var SVA = function(variableId, index, value) {
  69.         $gameVariables.SVA(variableId, index, value)
  70.     }
  71.    
  72.     var RV = function(variableId) {
  73.         return $gameVariables.value(variableId)
  74.     }
  75.    
  76.     var RVA = function(variableId, index) {
  77.         return $gameVariables.RVA(variableId, index)
  78.     }
  79.    
  80.     var SS = function(switchId, value) {
  81.         $gameSwitches.setValue(switchId, value)
  82.     }
  83.    
  84.     var RS = function(switchId){
  85.         return $gameSwitches.value(switchId)
  86.     }
  87.    
  88.     var SSelf = function(mapId,eventId,name,bool) {
  89.         $gameSelfSwitches.setValue([mapId,eventId,name], bool);
  90.     }
  91.    
  92.     var RSelf = function(mapId,eventId,name) {
  93.         return $gameSelfSwitches.value([mapId,eventId,name])
  94.     }
  95.    
  96.     var add_gold = function(value) {
  97.         $gameParty.gainGold(value);
  98.     }
  99.    
  100.     var add_item = function(itemId, n) {
  101.         $gameParty.gainItem($dataItems[itemId], n);
  102.     }
  103.    
  104.     var add_weapon = function(weaponId,n,bool) {
  105.         bool = bool || false
  106.         $gameParty.gainItem($dataWeapons[weaponId], n, bool);
  107.     }
  108.    
  109.     var add_armor = function(armorId,n,bool) {
  110.         bool = bool || false
  111.         $gameParty.gainItem($dataArmors[armorId], n, bool);
  112.     }
  113.    
  114.     var actor_add = function(actorId) {
  115.         $gameParty.addActor(actorId)
  116.     }
  117.    
  118.     var actor_remove = function(actorId) {
  119.         $gameParty.removeActor(actorId)
  120.     }
  121.    
  122.     var actor_hp_add = function(actorId,n) {
  123.         n = n || 0;
  124.         $gameActors.actor(actorId).gainHp(n);
  125.     }
  126.    
  127.     var actor_mp_add = function(actorId,n) {
  128.         n = n || 0;
  129.         $gameActors.actor(actorId).gainMp(n);  
  130.     }
  131.    
  132.     var actor_tp_add = function(actorId,n) {
  133.         n = n || 0;
  134.         $gameActors.actor(actorId).gainTp(n);
  135.     }
  136.    
  137.     var actor_vadd = function(actorId, nHP, nMP, nTP) {
  138.         nHP = nHP || 0;
  139.         nMP = nMP || 0;
  140.         nTP = nTP || 0;
  141.         $gameActors.actor(actorId).gainHp(nHP);
  142.         $gameActors.actor(actorId).gainMp(nMP);
  143.         $gameActors.actor(actorId).gainTp(nTP);
  144.     }
  145.    
  146.     var actor_st_add = function(actorId, n) {
  147.          $gameActors.actor(actorId).addState(n);
  148.     }
  149.    
  150.     var actor_st_remove = function(actorId, n) {
  151.         $gameActors.actor(actorId).removeState(n)
  152.     }
  153.    
  154.     var actor_change_exp = function(actorId,n) {
  155.         $gameActors.actor(actorId).gainExp(n);
  156.     }
  157.    
  158.     var actor_change_lvl = function(actorId, n, bool) {
  159.         bool = bool || false
  160.         $gameActors.actor(actorId).changeLevel(n, bool);
  161.     }
  162.    
  163.     var actor_change_params = function(actorId, paramId, n) {
  164.         $gameActors.actor(actorId).addParam(paramId, n);
  165.     }
  166.    
  167.     var actor_skill_l = function(actorId, n) {
  168.         $gameActors.actor(actorId).learnSkill(n);
  169.     }
  170.    
  171.     var actor_skill_f = function(actorId, n) {
  172.         $gameActors.actor(actorId).forgetSkill(n);
  173.     }
  174.    
  175.     var actor_equip_w = function(actorId,slotId,item) {
  176.         $gameActors.actor(actorId).changeEquip(slotId, $dataWeapons[item]);
  177.     }
  178.    
  179.     var actor_equip_a = function(actorId,slotId,item) {
  180.         $gameActors.actor(actorId).changeEquip(slotId, $dataArmors[item]);
  181.     }
  182.    
  183.     var actor_change_name = function(actorId,n) {
  184.         $gameActors.actor(actorId).setName(n)
  185.     }
  186.    
  187.     var actor_change_class = function(actorId,n,bool) {
  188.         bool = bool || false
  189.         $gameActors.actor(actorId).changeClass(n, bool)
  190.     }
  191.    
  192.     var actor_change_handle = function(actorId, n) {
  193.         $gameActors.actor(actorId).setNickname(n)
  194.     }
  195.    
  196.     var actor_change_profile = function(actorId, n) {
  197.         $gameActors.actor(actorId).setProfile(n)
  198.     }  
  199.    
  200.     var transfer = function(mapId, x, y, direction, fadetype) {
  201.         $gamePlayer.reserveTransfer(mapId, x, y, direction, fadetype);
  202.     }
  203.    
  204.     var transfer_event = function(eventId,x,y) {
  205.         if (eventId === 0) {
  206.             $gamePlayer.setPosition(x, y)
  207.         } else{
  208.             $gameMap.event(eventId).setPosition(x, y)
  209.         }
  210.     }
  211.    
  212.     var equip_id = function(actorId, n) {
  213.         if ($gameActors.actor(actorId).equips()[n]) {
  214.         return $gameActors.actor(actorId).equips()[n].id
  215.         }
  216.     }
  217.    
  218.     var equip_name = function(actorId, n) {
  219.         if ($gameActors.actor(actorId).equips()[n]) {
  220.         return $gameActors.actor(actorId).equips()[n].name
  221.         }
  222.     }
  223.    
  224.     var actor_weaponC = function(actorId, n) {
  225.         return $gameActors.actor(actorId).equips().contains($dataWeapons[n])
  226.     }
  227.    
  228.     var actor_armorC = function(actorId, n) {
  229.         return $gameActors.actor(actorId).equips().contains($dataArmors[n])
  230.     }
  231.    
  232.     var actor_skillC = function(actorId, n) {
  233.         return $gameActors.actor(actorId).skills().contains($dataSkills[n])
  234.     }
  235.    
  236.     var pic_show = function(pictureId, name, origin, x , y ,  scaleX, scaleY, opacity, blendMode) {
  237.         blendMode = blendMode || 0;
  238.         opacity = opacity || 255;
  239.         scaleX = scaleX || 100;
  240.         scaleY = scaleY || 100;
  241.         $gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode)
  242.     }
  243.    
  244.     var pic_move = function(pictureId, origin, x , y,  scaleX, scaleY, opacity, blendMode, duration) {
  245.         duration = duration || 1;
  246.         blendMode = blendMode || 0;
  247.         opacity = opacity || 255;
  248.         scaleX = scaleX || 100;
  249.         scaleY = scaleY || 100;
  250.         $gameScreen.movePicture(pictureId, origin, x, y, scaleX, scaleY, opacity, blendMode, duration)
  251.     }
  252.    
  253.     var pic_rotate = function(pictureId, speed) {
  254.         $gameScreen.rotatePicture(pictureId, speed);
  255.     }
  256.    
  257.     var pic_tint = function(pictureId, tone, duration) {
  258.         $gameScreen.tintPicture(pictureId, tone, duration);
  259.     }
  260.    
  261.     var pic_erase = function(pictureId) {
  262.         $gameScreen.erasePicture(pictureId);
  263.     }
  264.    
  265.     var pic_clear = function() {
  266.         $gameScreen.clearPictures()
  267.     }
  268.    
  269.     var player_x = function() {
  270.         return $gamePlayer.x
  271.     }
  272.  
  273.     var player_y = function() {
  274.         return $gamePlayer.y
  275.     }
  276.    
  277.     var event_x = function(eventId) {
  278.         return get_event_by_id(eventId).x
  279.     }
  280.    
  281.     var event_y = function(eventId) {
  282.         return get_event_by_id(eventId).y
  283.     }
  284.    
  285.     var gold = function() {
  286.         return $gameParty.gold()
  287.     }
  288.    
  289.     var actor_paramb = function (actorId,paramId) {
  290.         return $gameActors.actor(actorId).currentClass().params[paramId][$gameActors.actor(actorId)._level]
  291.     }
  292.     //50 Commands!
  293.     var actor_param = function(actorId, paramId) {
  294.         var calc
  295.         calc = $gameActors.actor(actorId).paramPlus(paramId) + actor_paramb(actorId,paramId)
  296.         return calc
  297.     }
  298.    
  299.     var actor_lvl = function(actorId) {
  300.         return $gameActors.actor(actorId)._level
  301.     }
  302.    
  303.     var actor_equip_clear = function(actorId) {
  304.         $gameActors.actor(actorId).clearEquipments()
  305.     }
  306.    
  307.     var actor_equip_opti = function(actorId) {
  308.         $gameActors.actor(actorId).optimizeEquipments()
  309.     }
  310.    
  311.     var event_jump = function(eventId,xto,yto) {
  312.         get_event_by_id(eventId).forceMoveRoute({
  313.           list:[{code: 14,indent: null,parameters:[xto-event_x(eventId),yto-event_y(eventId)] }],repeat:false,skippable:true,wait:false})
  314.         }
  315.    
  316.     var event_id = function() {
  317.         return $gameMap._interpreter.eventId()
  318.     }
  319.    
  320.     var jump_to_label = function(label) {
  321.         $gameMap._interpreter.jump_to_label(label)
  322.     }
  323.    
  324.     var anim_show = function(eventId, animId) {
  325.         if (eventId > 0) {
  326.         $gameMap.events()[eventId].requestAnimation(animId);
  327.         }
  328.         if (eventId === 0) {
  329.         $gamePlayer.requestAnimation(animId)
  330.         }
  331.     }
  332.    
  333.     var regionC = function(x,y) {
  334.         return $gameMap.regionId(x, y);
  335.     }
  336.    
  337.     var event_idat = function(x,y) {
  338.         return $gameMap.eventIdXy(x, y);
  339.     }
  340.    
  341.     var terrain_tag = function(x,y) {
  342.         return $gameMap.terrainTag(x, y);
  343.     }
  344.    
  345.     var equip_note = function(actorId, equipId) {
  346.         if ($gameActors.actor(actorId).equips()[equipId]) {
  347.         return $gameActors.actor(actorId).equips()[equipId].note
  348.         }
  349.     }
  350.    
  351.     var weapon_note = function(Id) {
  352.         return $dataWeapons[Id].note
  353.     }
  354.    
  355.     var armor_note = function(Id) {
  356.         return $dataArmors[Id].note
  357.     }
  358.    
  359.     var actor_note = function(Id) {
  360.         return $dataActors[Id].note
  361.     }
  362.    
  363.     var item_note = function(Id) {
  364.         return $dataItems[Id].note
  365.     }
  366.    
  367.     var skill_note = function(Id) {
  368.         return $dataSkills[Id].note
  369.     }
  370.    
  371.     var monster_note = function(Id) {
  372.         return $dataEnemies[Id].note
  373.     }
  374.    
  375.     var monster_param = function(Id, paramId) {
  376.         return $dataEnemies[Id].params[paramId]
  377.     }
  378.    
  379.     var event_distance = function(Id1, Id2) {
  380.         var calc
  381.         calc = Math.abs(event_x(Id1)-event_x(Id2))
  382.         calc +=  Math.abs(event_y(Id1)-event_y(Id2))
  383.         return calc
  384.     }
  385.    
  386.     //V 0.2 02/06/2016 70 Functions
  387.    
  388.     var items = function() {
  389.         var a = $gameParty.items().length
  390.         var i, list
  391.         i = 0
  392.         list = []
  393.            while (i < a) {
  394.                list.push($gameParty.items()[i].id)
  395.                i++
  396.            }
  397.        
  398.         return list
  399.     }
  400.    
  401.     var items_name = function() {
  402.         var a = $gameParty.items().length
  403.         var i, list
  404.         i = 0
  405.         list = []
  406.            while (i < a) {
  407.                list.push($gameParty.items()[i].name)
  408.                i++
  409.            }
  410.        
  411.         return list
  412.     }
  413.    
  414.     var itemC = function(id) {
  415.         if (items().contains(id)) {
  416.             return true
  417.         } else {
  418.             return false
  419.         }
  420.     }
  421.    
  422.     var actor_skills = function(actorId) {
  423.         var a, i, list
  424.         a = $gameActors.actor(actorId).skills().length
  425.         i = 0
  426.         list = []
  427.         while (i < a) {
  428.             list.push($gameActors.actor(actorId).skills()[i].id)
  429.             i++
  430.         }
  431.         return list
  432.     }
  433.    
  434.     var actor_skills_name = function(actorId) {
  435.         var a, i, list
  436.         a = $gameActors.actor(actorId).skills().length
  437.         i = 0
  438.         list = []
  439.         while (i < a) {
  440.             list.push($gameActors.actor(actorId).skills()[i].name)
  441.             i++
  442.         }
  443.         return list
  444.     }
  445.    
  446.     var item_scope = function(id) {
  447.         return $dataItems[id].scope
  448.     }
  449.    
  450.     var item_scope_n = function(id) {
  451.         var a
  452.         a = item_scope(id)
  453.         if (a === 0) {return "None"}
  454.         if (a === 1) {return "1 Enemy"}
  455.         if (a === 2) {return "All Enemies"}
  456.         if (a === 3) {return "1 Random Enemy"}
  457.         if (a === 4) {return "2 Random Enemies"}
  458.         if (a === 5) {return "3 Random Enemies"}
  459.         if (a === 6) {return "4 Random Enemies"}
  460.         if (a === 7) {return "1 Ally"}
  461.         if (a === 8) {return "All Allies"}
  462.         if (a === 9) {return "1 Dead Ally"}
  463.         if (a === 10) {return "All Dead Allies"}
  464.         if (a === 11) {return "User"}
  465.     }
  466.    
  467.     var item_price = function(id) {
  468.         return $dataItems[id].price
  469.     }
  470.    
  471.     var item_name = function(id) {
  472.         return $dataItems[id].name
  473.     }
  474.    
  475.     var currency = function() {
  476.         return $dataSystem.currencyUnit
  477.     }
  478.    
  479.     var save = function(id) {
  480.         $gameSystem.onBeforeSave();
  481.         DataManager.saveGame(id);
  482.     }
  483.    
  484.     var weapons = function () {
  485.         var a = $gameParty.weapons().length
  486.         var i, list
  487.         i = 0
  488.         list = []
  489.            while (i < a) {
  490.                list.push($gameParty.weapons()[i].id)
  491.                i++
  492.            }
  493.        
  494.         return list
  495.     }
  496.    
  497.     var weapons_name = function () {
  498.         var a = $gameParty.weapons().length
  499.         var i, list
  500.         i = 0
  501.         list = []
  502.            while (i < a) {
  503.                list.push($gameParty.weapons()[i].name)
  504.                i++
  505.            }
  506.        
  507.         return list
  508.     }
  509.    
  510.     var armors = function () {
  511.         var a = $gameParty.armors().length
  512.         var i, list
  513.         i = 0
  514.         list = []
  515.            while (i < a) {
  516.                list.push($gameParty.armors()[i].id)
  517.                i++
  518.            }
  519.        
  520.         return list
  521.     }
  522.    
  523.     var armors_name = function () {
  524.         var a = $gameParty.armors().length
  525.         var i, list
  526.         i = 0
  527.         list = []
  528.            while (i < a) {
  529.                list.push($gameParty.armors()[i].name)
  530.                i++
  531.            }
  532.        
  533.         return list
  534.     }
  535.    
  536.     var armor_desc = function(id) {
  537.         return $dataArmors[id].description
  538.     }
  539.    
  540.     var weapon_desc = function(id) {
  541.         return $dataWeapons[id].description
  542.     }
  543.    
  544.     var item_desc = function(id) {
  545.         return $dataItems[id].description
  546.     }
  547.    
  548.     var monster_gold = function(Id) {
  549.         return $dataEnemies[Id].gold
  550.     }
  551.    
  552.     var monster_exp = function(Id) {
  553.         return $dataEnemies[Id].exp
  554.     }
  555.    
  556.     var actor_class_id = function(actorId) {
  557.         return $gameActors.actor(actorId).currentClass().id
  558.     }
  559.    
  560.     var actor_class_name = function(actorId) {
  561.         return $gameActors.actor(actorId).currentClass().name
  562.     }
  563.    
  564.     var skill_desc = function(id) {
  565.         return $dataSkills[id].description
  566.     }
  567.    
  568.     var skill_scope = function(id) {
  569.         return $dataSkills[id].scope
  570.     }
  571.    
  572.     var skill_scope_n = function(id) {
  573.         var a
  574.         a = skill_scope(id)
  575.         if (a === 0) {return "None"}
  576.         if (a === 1) {return "1 Enemy"}
  577.         if (a === 2) {return "All Enemies"}
  578.         if (a === 3) {return "1 Random Enemy"}
  579.         if (a === 4) {return "2 Random Enemies"}
  580.         if (a === 5) {return "3 Random Enemies"}
  581.         if (a === 6) {return "4 Random Enemies"}
  582.         if (a === 7) {return "1 Ally"}
  583.         if (a === 8) {return "All Allies"}
  584.         if (a === 9) {return "1 Dead Ally"}
  585.         if (a === 10) {return "All Dead Allies"}
  586.         if (a === 11) {return "User"}
  587.     }
  588.    
  589.     var skill_cost_mp = function(id) {
  590.         return $dataSkills[id].mpCost
  591.     }
  592.    
  593.     var skill_cost_tp = function(id) {
  594.         return $dataSkills[id].tpCost
  595.     }
  596.    
  597.     var monster_desc = function(id) {
  598.         return $dataEnemies[id].description
  599.     }
  600.    
  601.     //100 commands
  602.    
  603.     var event_in_rect = function(eventId,x1,y1,x2,y2) {
  604.         var a, b, minx, maxx, miny, maxy
  605.        
  606.         if (eventId === 0) {
  607.             a = player_x();
  608.             b = player_y();
  609.             } else {
  610.             a = event_x(eventId);
  611.             b = event_y(eventId);
  612.         };
  613.        
  614.         minx = Math.min(x1,x2)
  615.         maxx = Math.max(x1,x2)
  616.         miny = Math.min(y1,y2)
  617.         maxy = Math.max(y1,y2)
  618.        
  619.         if (a>= minx && a<= maxx && b>=miny && b<= maxy) {
  620.             return true
  621.         } else {
  622.             return false
  623.         }
  624.        
  625.     }
  626.    
  627.     var event_in_circle = function(eventId,x,y,radius) {
  628.         var ex, ey
  629.        
  630.         if (eventId === 0) {
  631.             ex = player_x();
  632.             ey = player_y();
  633.             } else {
  634.             ex = event_x(eventId)
  635.             ey = event_y(eventId)
  636.         }
  637.        
  638.         if ((ex-x)^2+(ey-y)^2 <= radius^2) {
  639.             return true
  640.         } else {
  641.             return false
  642.         }
  643.        
  644.     }
  645.    
  646.     var event_in_polygon = function(eventId,polygon) { // Polygons are defined using an array of their coordinates [[x1,y1],[x2,y2],...[xn,yn]].
  647.         // ray-casting algorithm based on
  648.         // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
  649.         // credit: https://github.com/substack/point-in-polygon MIT license
  650.        
  651.         var x, y
  652.         if (eventId === 0) {x = player_x(); y = player_y()}
  653.         else {x = event_x(eventId); y = event_y(eventId)}
  654.        
  655.         var inside = false;
  656.         for (var i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
  657.             var xi = polygon[i][0], yi = polygon[i][1];
  658.             var xj = polygon[j][0], yj = polygon[j][1];
  659.  
  660.             var intersect = ((yi > y) != (yj > y))
  661.                 && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
  662.             if (intersect) inside = !inside;
  663.         }
  664.  
  665.         return inside;
  666.        
  667.     }
  668.    
  669.     var actor_in_party = function(actorId) {
  670.         var list, i
  671.         list = []
  672.         i = 0
  673.         while (i < $gameParty.size()) {
  674.            list.push($gameParty.members()[i].actorId())
  675.            i++
  676.            }
  677.         if (list.contains(actorId)) {
  678.             return true
  679.         } else {
  680.             return false
  681.         }
  682.     }
  683.    
  684.     var actor_in_party_n = function(actorName) {
  685.         var list, i
  686.         list = []
  687.         i = 0
  688.         while (i < $gameParty.size()) {
  689.            list.push($gameParty.members()[i].name())
  690.            i++
  691.            }
  692.         if (list.contains(actorName)) {
  693.             return true
  694.         } else {
  695.             return false
  696.         }
  697.     }
  698.    
  699.     var weaponC = function(id,bool) {
  700.         if (bool === undefined) {bool = false}
  701.         return $gameParty.hasItem($dataWeapons[id], bool)
  702.     }
  703.    
  704.     var armorC = function(id,bool) {
  705.         if (bool === undefined) {bool = false}
  706.         return $gameParty.hasItem($dataArmors[id], bool)
  707.     }
  708.    
  709.     var actor_armors_type = function(id) {
  710.         var i,list
  711.         i = 0
  712.         list = []
  713.         while (i < $gameActors.actor(id).armors().length) {
  714.             list.push($gameActors.actor(id).armors()[i].atypeId)
  715.             i++
  716.         }
  717.        
  718.         return list
  719.     }
  720.    
  721.     var actor_armors_contains = function(actorId, typeId) {
  722.         var list
  723.         list = actor_armors_type(actorId)
  724.         if (list.contains(typeId)) {
  725.             return true
  726.         } else {
  727.             return false
  728.         }
  729.        
  730.     }
  731.    
  732.     var actor_weapons_type = function(id) {
  733.         var i,list
  734.         i = 0
  735.         list = []
  736.         while (i < $gameActors.actor(id).weapons().length) {
  737.             list.push($gameActors.actor(id).weapons()[i].wtypeId)
  738.             i++
  739.         }
  740.        
  741.         return list
  742.     }
  743.    
  744.     var actor_weapons_contains = function(actorId, typeId) {
  745.         var list
  746.         list = actor_weapons_type(actorId)
  747.         if (list.contains(typeId)) {
  748.             return true
  749.         } else {
  750.             return false
  751.         }
  752.        
  753.     }
  754.    
  755.         //V0.32
  756.    
  757.     var actor_hp = function(id) {
  758.         return $gameActors.actor(id).hp
  759.     }
  760.    
  761.     var actor_mp = function(id) {
  762.         return $gameActors.actor(id).mp
  763.     }
  764.    
  765.     var actor_tp = function(id) {
  766.         return $gameActors.actor(id).tp
  767.     }
  768.    
  769.     var actor_weapons = function(id) {
  770.         var i,list
  771.         i = 0
  772.         list = []
  773.         while (i < $gameActors.actor(id).weapons().length) {
  774.             list.push($gameActors.actor(id).weapons()[i].id)
  775.             i++
  776.         }
  777.        
  778.         return list
  779.     }
  780.    
  781.     var actor_armors = function(id) {
  782.         var i,list
  783.         i = 0
  784.         list = []
  785.         while (i < $gameActors.actor(id).armors().length) {
  786.             list.push($gameActors.actor(id).armors()[i].id)
  787.             i++
  788.         }
  789.        
  790.         return list
  791.     }
  792.    
  793.     var party_leader = function() {
  794.         return $gameParty.members()[0].actorId()
  795.     }
  796.    
  797.     var party_leader_n = function(id) {
  798.         return $gameParty.members()[0].name()
  799.     }
  800.    
  801.     var actor_is_leader = function(id) {
  802.         if (party_leader() === id) {return true} else {return false}
  803.     }
  804.    
  805.     var event_regionC = function(Id,regionId) {
  806.         if (regionC(event_x(Id),event_y(Id)) === regionId) {
  807.             return true
  808.         } else {
  809.             return false
  810.         }
  811.     }
  812.    
  813.     //V0.33
  814.    
  815.     var armor_param = function(id,paramId) {
  816.         return $dataArmors[id].params[paramId]
  817.     }
  818.    
  819.     var weapon_param = function(id,paramId) {
  820.         return $dataWeapons[id].params[paramId]
  821.     }
  822.    
  823.     var actor_change_sprite = function(actorId, name, index) {
  824.         $gameActors.actor(actorId).setCharacterImage(name, index);
  825.         $gamePlayer.refresh();
  826.     }
  827.    
  828.     var actor_change_face = function(actorId, name, index) {
  829.         $gameActors.actor(actorId).setFaceImage(name, index);
  830.         $gamePlayer.refresh();
  831.     }
  832.    
  833.     var actor_change_battler = function(actorId, name) {
  834.         $gameActors.actor(actorId).setBattlerImage(name);
  835.         $gamePlayer.refresh();
  836.     }
  837.    
  838.     //In battle functions! Don't call these on any other scene!
  839.     //Enemy indexes start at 0
  840.    
  841.     var enemy_change_hp = function(enemyIndex, n) {
  842.         $gameTroop.members()[enemyIndex].gainHp(n);
  843.     }
  844.    
  845.     var enemy_change_mp = function(enemyIndex, n) {
  846.         $gameTroop.members()[enemyIndex].gainMp(n);
  847.     }
  848.    
  849.     var enemy_change_tp = function(enemyIndex, n) {
  850.         $gameTroop.members()[enemyIndex].gainTp(n)
  851.     }
  852.    
  853.     var enemy_state_add = function(enemyIndex, n) {
  854.         $gameTroop.members()[enemyIndex].addState(n);
  855.     }
  856.    
  857.     var enemy_state_remove = function(enemyIndex, n) {
  858.         $gameTroop.members()[enemyIndex].removeState(n)
  859.     }
  860.    
  861.     var enemy_recover = function(enemyIndex) {
  862.         $gameTroop.members()[enemyIndex].recoverAll();
  863.     }
  864.    
  865.     var enemy_appear = function(enemyIndex) {
  866.         $gameTroop.members()[enemyIndex].appear();
  867.     }
  868.    
  869.     var enemy_transform = function(enemyIndex, n) {
  870.         $gameTroop.members()[enemyIndex].transform(n);
  871.     }
  872.    
  873.     var enemy_anim = function(enemyIndex, animationId, bool, delayN) {
  874.         bool = bool || false
  875.         delayN = delayN || 0
  876.         $gameTroop.members()[enemyIndex].startAnimation(animationId, bool, delayN);
  877.     }
  878.    
  879.     var turn_count = function() {
  880.         return $gameTroop.turnCount()
  881.     }
  882.    
  883.     var enemy_collapse = function(enemyIndex) {
  884.         $gameTroop.members()[enemyIndex].performCollapse()
  885.     }
  886.    
  887.     var enemy_hp = function(enemyIndex) {
  888.         return $gameTroop.members()[enemyIndex]._hp
  889.     }
  890.    
  891.     var enemy_mp = function(enemyIndex) {
  892.         return $gameTroop.members()[enemyIndex]._mp
  893.     }
  894.    
  895.     var enemy_tp = function(enemyIndex) {
  896.         return $gameTroop.members()[enemyIndex]._tp
  897.     }
  898.    
  899.     var enemy_states = function(enemyIndex) {
  900.         return $gameTroop.members()[enemyIndex]._states
  901.     }
  902.    
  903.     var enemy_stateC = function(enemyIndex, stateIndex) {
  904.         if (enemy_states(enemyIndex).contains(stateIndex)) {return true} else {return false}
  905.     }
  906.    
  907.     var enemy_xy = function(enemyIndex, x, y) {
  908.         var eI = enemy_sprite_index(enemyIndex)
  909.         if (x === undefined && y === undefined) {
  910.             return [SceneManager._scene._spriteset._enemySprites[eI]._homeX,SceneManager._scene._spriteset._enemySprites[eI]._homeY]
  911.             }
  912.         x = x || SceneManager._scene._spriteset._enemySprites[eI]._homeX;
  913.         y = y || SceneManager._scene._spriteset._enemySprites[eI]._homeY;
  914.         SceneManager._scene._spriteset._enemySprites[eI]._homeX = x;
  915.         SceneManager._scene._spriteset._enemySprites[eI]._homeY = y;
  916.         $gameTroop.members()[enemyIndex]._screenX = x;
  917.         $gameTroop.members()[enemyIndex]._screenY = y;
  918.        
  919.     }
  920.    
  921.     var enemy_angle = function(enemyIndex, angle) {
  922.         var eI = enemy_sprite_index(enemyIndex)
  923.         angle = angle || 0
  924.         SceneManager._scene._spriteset._enemySprites[eI].rotation = angle
  925.     }
  926.    
  927.     /*enemy_alpha = function(enemyIndex, alpha) {
  928.         alpha = alpha || 255
  929.         SceneManager._scene._spriteset._enemySprites[enemyIndex].alpha = alpha
  930.     }*/
  931.    
  932.     var enemy_scale = function(enemyIndex, x, y) {
  933.         var eI = enemy_sprite_index(enemyIndex)
  934.         x = x || 1
  935.         y = y || 1
  936.         SceneManager._scene._spriteset._enemySprites[eI].scale.x = x
  937.         SceneManager._scene._spriteset._enemySprites[eI].scale.y = y
  938.     }
  939.    
  940.     var battle_actor_xy = function(index, x, y) {
  941.         if (x === undefined && y === undefined) {
  942.             return [SceneManager._scene._spriteset._actorSprites[index]._homeX,SceneManager._scene._spriteset._actorSprites[index]._homeY]
  943.         }
  944.         x = x || SceneManager._scene._spriteset._actorSprites[index]._homeX
  945.         y = y || SceneManager._scene._spriteset._actorSprites[index]._homeY
  946.         SceneManager._scene._spriteset._actorSprites[index]._homeX = x
  947.         SceneManager._scene._spriteset._actorSprites[index]._homeY = y
  948.     }
  949.    
  950.     var battle_actor_angle = function(index, angle) {
  951.         angle = angle || 0
  952.         SceneManager._scene._spriteset._actorSprites[index].rotation = angle
  953.     }
  954.    
  955.     /*battle_actor_alpha = function(index, alpha) {
  956.         alpha = alpha || 255
  957.         SceneManager._scene._spriteset._actorSprites[index].alpha = alpha
  958.     }*/
  959.    
  960.     var battle_actor_scale = function(index, x, y) {
  961.         x = x || 1
  962.         y = y || 1
  963.         SceneManager._scene._spriteset._actorSprites[index].scale.x = x
  964.         SceneManager._scene._spriteset._actorSprites[index].scale.y = y
  965.     }
  966.    
  967.     var actor_caster = function() {
  968.         var list, i
  969.         list = []
  970.         i = 0
  971.         while (i < $gameParty.size()) {
  972.             list.push($gameParty.members()[i].actorId())
  973.             i++
  974.             }
  975.         return list.indexOf(BattleManager._subject._actorId)
  976.     }
  977.    
  978.     var actor_target = function() {
  979.         return BattleManager._action._targetIndex
  980.     }
  981.    
  982.     var actor_last_skill = function() {
  983.         return BattleManager._subject._lastBattleSkill._itemId
  984.     }
  985.    
  986.     var actor_last_menu_skill = function(actorId) {
  987.         return $gameParty.members()[actorId]._itemId
  988.     }
  989.    
  990.     //V0.4
  991.    
  992.     var party_last_item = function() {
  993.         return $gameParty._lastItem._itemId
  994.     }
  995.    
  996.     var actor_item_target = function() {
  997.         return $gameParty._targetActorId
  998.     }
  999.    
  1000.     var texts = function(id,text,align) { //arrays: [[x,y,text],[x2,y2,text2],...,[xn,yn,textn]]
  1001.         align = align || "left"
  1002.         var a = text.length
  1003.         var i = 0
  1004.         var rid = $gameScreen.realPictureId(id)
  1005.         var pS = SceneManager._scene._spriteset._pictureContainer.children[rid-1]
  1006.         if (!pS.bitmap) {pS.bitmap = new Bitmap(816, 624)}
  1007.         $gameScreen.showPicture(id, '', 0, 0, 0, 100,100, 255, 0);
  1008.         pS.bitmap.clear();
  1009.         while (i < a) {
  1010.             pS.bitmap.drawText(text[i][2],text[i][0], text[i][1],816, 48, align);
  1011.             i++
  1012.         }
  1013.    
  1014.     }
  1015.    
  1016.     var flash_square = function(id,arrayR,arrayG,arrayB,opacity,border,blendMode) { //arrays: [[x1,y1],[x2,y2],...,[xn,yn]]
  1017.         var i, narrayR, narrayG, narrayB;
  1018.         blendMode = blendMode || 0;
  1019.         opacity = opacity || 255;
  1020.         arrayR = arrayR || [];
  1021.         arrayB = arrayB || [];
  1022.         arrayG = arrayG || [];
  1023.         border = border || 0;
  1024.         var rid = $gameScreen.realPictureId(id);
  1025.         var pS = SceneManager._scene._spriteset._pictureContainer.children[rid-1];
  1026.        
  1027.         narrayB = [];
  1028.         narrayR = [];
  1029.         narrayG = [];
  1030.         i = 0;
  1031.         while (i<arrayB.length) {
  1032.             narrayB.push([arrayB[i][0]*48,arrayB[i][1]*48]);
  1033.             i++;
  1034.         };
  1035.         i = 0;
  1036.         while (i<arrayG.length) {
  1037.             narrayG.push([arrayG[i][0]*48,arrayG[i][1]*48]);
  1038.             i++;
  1039.         };
  1040.         i = 0;
  1041.         while (i<arrayR.length) {
  1042.             narrayR.push([arrayR[i][0]*48,arrayR[i][1]*48]);
  1043.             i++;
  1044.         };
  1045.        
  1046.         if (!pS.bitmap) {pS.bitmap = new Bitmap(816, 624)}
  1047.         $gameScreen.showPicture(id, '', 0, 0, 0, 100,100, opacity, blendMode);
  1048.         pS.bitmap.clear();
  1049.        
  1050.         if (arrayR !== []) {
  1051.             i = 0
  1052.             while (i<narrayR.length) {
  1053.                 pS.bitmap.fillRect(narrayR[i][0]+border,narrayR[i][1]+border,48-border,48-border,'red');
  1054.                 i++
  1055.             }
  1056.         }
  1057.         if (arrayG !== []) {
  1058.             i = 0
  1059.             while (i<narrayG.length) {
  1060.                 pS.bitmap.fillRect(narrayG[i][0]+border,narrayG[i][1]+border,48-border,48-border,'green');
  1061.                 i++
  1062.             }
  1063.         }
  1064.        
  1065.         if (arrayB !== []) {
  1066.             i = 0
  1067.             while (i<narrayB.length) {
  1068.                 pS.bitmap.fillRect(narrayB[i][0]+border,narrayB[i][1]+border,48-border,48-border,'blue');
  1069.                 i++;
  1070.             }
  1071.         }
  1072.     }
  1073.    
  1074.     var region_distance = function(x1,y1,x2,y2) {
  1075.         return distance(x1,y1,x2,y2) + Math.abs(regionC(x1,y1)-regionC(x2,y2))
  1076.     }
  1077.    
  1078.     var actor_name = function(id) {
  1079.         return $gameActors.actor(id).name()
  1080.     }
  1081.    
  1082.     var event_direction = function(id,direction) {
  1083.         if (direction === undefined) {
  1084.             if (id === 0) {
  1085.                 return $gamePlayer._direction
  1086.             } else {
  1087.                 return $gameMap._events[id]._direction
  1088.             }
  1089.         } else {
  1090.             if (id === 0) {
  1091.                 $gamePlayer._direction = direction
  1092.             } else {
  1093.                 $gameMap._events[id]._direction = direction
  1094.             }
  1095.         }
  1096.     }
  1097.    
  1098.     var event_movetype = function(id,type) {
  1099.         if (type === undefined) {
  1100.             return $gameMap._events[id]._moveType
  1101.         } else {
  1102.             $gameMap._events[id]._moveType = type
  1103.             }
  1104.     }
  1105.    
  1106.     var event_opacity = function(id,opacity) {
  1107.         if (opacity === undefined) {
  1108.             if (id === 0) {
  1109.                 return $gamePlayer._opacity
  1110.             } else {
  1111.                 return $gameMap._events[id]._opacity
  1112.             }
  1113.         } else {
  1114.             if (id === 0) {
  1115.                 $gamePlayer._opacity = opacity
  1116.             } else {
  1117.                 $gameMap._events[id]._opacity = opacity
  1118.             }
  1119.         }
  1120.     }
  1121.    
  1122.     var party_order = function(slot, id) {
  1123.         $gameParty.swapOrder(slot,$gameParty.members().indexOf($gameActors.actor(id)))
  1124.     }
  1125.    
  1126.     //V0.50
  1127.    
  1128.     var actor_sprite = function(id) {
  1129.         return [$dataActors[id].characterName,$dataActors[id].characterIndex]
  1130.     }  
  1131.    
  1132.     var event_sprite = function(id,name,index) {
  1133.         if (name === undefined && index === undefined) {
  1134.             return [$gameMap._events[id]._characterName,$gameMap._events[id]._characterIndex]
  1135.         }
  1136.         $gameMap._events[id]._characterName = name
  1137.         $gameMap._events[id]._characterIndex = index
  1138.     }
  1139.    
  1140.     var party_swap = function(id1,id2) {
  1141.         $gameParty.swapOrder($gameParty.members().indexOf($gameActors.actor(id1)),$gameParty.members().indexOf($gameActors.actor(id2)))
  1142.     }
  1143.    
  1144.     var rm_kill = function() {
  1145.         SceneManager.terminate()
  1146.     }
  1147.    
  1148.     var actor_states = function(id) {
  1149.         return $gameActors.actor(id)._states;
  1150.     }
  1151.    
  1152.     var actor_stateC = function (id, stateId) {
  1153.         return $gameActors.actor(id).isStateAffected(stateId);
  1154.     }
  1155.    
  1156.     //V0.6
  1157.    
  1158.     var actor_caster_id = function() {
  1159.         return BattleManager._subject._actorId
  1160.     }
  1161.    
  1162.     var get_event_by_id = function(id) {
  1163.         var i = 0;
  1164.         var e = $gameMap.events();
  1165.         while (i < e.length) {
  1166.             if (e[i]._eventId === id) {
  1167.                 return $gameMap.events()[i];
  1168.             }
  1169.             i++;
  1170.         }
  1171.     }
  1172.    
  1173.     var enemy_sprite_index = function(id) {//get an enemy index via its coordinates... No simpler way sadly, because the spriteset index isn't nicely organized.
  1174.         var eS = SceneManager._scene._spriteset._enemySprites;
  1175.         var eT = $gameTroop.members();
  1176.         var i = 0;
  1177.         while (i < eS.length) {
  1178.             if (eT[id]._screenX === eS[i]._homeX && eT[id]._screenY === eS[i]._homeY) {
  1179.                 return i;
  1180.             }
  1181.             i++;
  1182.         }
  1183.  
  1184.     }
  1185.    
  1186.     var party_member_Id = function(index) {
  1187.         return $gameParty.members()[index]._actorId
  1188.     }
  1189.    
  1190.     var party_member_name = function(index) {
  1191.         return $gameParty.members()[index]._name;
  1192.     }
  1193.    
  1194.     var next_encounter = function() {
  1195.         return $gamePlayer._encounterCount;
  1196.     }
  1197.    
  1198.     var map_Id = function() {
  1199.         return $gameMap.mapId();
  1200.     }
  1201.    
  1202.     var zoom = function(x,y,scale,duration) {
  1203.         $gameScreen.startZoom(x, y, scale, duration);
  1204.     }
  1205.    
  1206.     var shake = function(power, speed, duration) {
  1207.         $gameScreen.startShake(power, speed, duration)
  1208.     }
  1209.    
  1210.     var enemy_Id = function(index) {
  1211.         return $gameTroop.members()[index]._enemyId
  1212.     }
  1213.    
  1214.     var clear_zoom = function() {
  1215.         $gameScreen.clearZoom()
  1216.     }
  1217.    
  1218.     var clear_weather = function() {
  1219.         $gameScreen.clearWeather()
  1220.     }
  1221.    
  1222.     var clear_shake = function() {
  1223.         $gameScreen.clearShake()
  1224.     }
  1225.    
  1226.     var rgb = function(r,g,b) {
  1227.         return Utils.rgbToCssColor(r,g,b)
  1228.     }
  1229.    
  1230.     //From this part on it's not functions from the editor but functions to simplify math
  1231.    
  1232.     var max_ar_index = function(arr) {
  1233.         var max, maxIndex, i
  1234.        
  1235.         if (arr.length === 0) {
  1236.             return -1;
  1237.         }
  1238.  
  1239.         max = arr[0];
  1240.         maxIndex = 0;
  1241.        
  1242.         i=1;
  1243.        
  1244.         while (i<arr.length) {
  1245.             if (arr[i] > max) {
  1246.                 maxIndex=i;
  1247.                 max = arr[i];
  1248.             }
  1249.             i++;
  1250.         }
  1251.        
  1252.         return maxIndex;
  1253.     }
  1254.    
  1255.     var min_ar_index = function(arr) {
  1256.         var min, minIndex
  1257.        
  1258.         if (arr.length === 0) {
  1259.             return -1;
  1260.         }
  1261.  
  1262.         min = arr[0];
  1263.         minIndex = 0;
  1264.  
  1265.         for (var i = 1; i < arr.length; i++) {
  1266.             if (arr[i] < min) {
  1267.                 minIndex = i;
  1268.                 min = arr[i];
  1269.             }
  1270.         }
  1271.  
  1272.         return minIndex;
  1273.     }
  1274.    
  1275.     var ar_all_equal = function(arr) {
  1276.         var i, a;
  1277.        
  1278.         i = 0;
  1279.         a = arr[0];
  1280.        
  1281.         if (arr.length === 0) {return -1};
  1282.        
  1283.         while (i < arr.length) {
  1284.             if (arr[i] === a) { i++; if (i===arr.length){return true; break} }
  1285.             else {return false; break}
  1286.            
  1287.         }
  1288.     }
  1289.    
  1290.     var ar_sum = function(arr) {
  1291.        
  1292.         var total = 0;
  1293.         var i = arr.length;
  1294.  
  1295.         while (i--) {
  1296.           total += arr[i];
  1297.         }
  1298.  
  1299.     return total;
  1300.        
  1301.     }
  1302.    
  1303.     var abs = function(v1) {
  1304.         return Math.abs(v1)
  1305.     }
  1306.    
  1307.     var min = function(v1,v2) {
  1308.         return Math.min(v1,v2)
  1309.     }
  1310.    
  1311.     var max = function(v1,v2) {
  1312.         return Math.max(v1,v2)
  1313.     }
  1314.    
  1315.     var rand = function(min,max) {
  1316.         return Math.floor(Math.random() * (max - min + 1)) + min;
  1317.     }
  1318.    
  1319.     var percent = function(x,max) {
  1320.         return Math.floor((x /max) * 100)
  1321.     }
  1322.    
  1323.     var distance = function(x1,y1,x2,y2) {
  1324.         return Math.abs(x1-x2) + Math.abs(y1-y2)
  1325.     }  
  1326.    
  1327.     //9 commands
  1328.    
  1329.     //Test commands
  1330.        
  1331.     /*var mouseX = function() {
  1332.         return TouchInput.mouseX
  1333.     }*/
  1334.    
  1335.     /*var mouseY = function() {
  1336.         return TouchInput.mouseY
  1337.     }*/
  1338.    
  1339.     /*var mouse_over_event = function(eventId) {
  1340.         if (mouseX() > (event_x(eventId)*48) && mouseX() < ((event_x(eventId)+1)*48) && mouseY() > (event_y(eventId)*48) && mouseY() < ((event_y(eventId)+1)*48)) {
  1341.             return true
  1342.         } else {
  1343.             return false
  1344.         }
  1345.     }*/
  1346.    
  1347.     /*var mouse_in_rect = function(x1,y1,x2,y2) {
  1348.         var a, b, minx, maxx, miny, maxy
  1349.         a = mouseX();
  1350.         b = mouseY()
  1351.         minx = Math.min(x1,x2)
  1352.         maxx = Math.max(x1,x2)
  1353.         miny = Math.min(y1,y2)
  1354.         maxy = Math.max(y1,y2)
  1355.        
  1356.         if (a>= minx && a<= maxx && b>=miny && b<= maxy) {
  1357.             return true
  1358.         } else {
  1359.             return false
  1360.         }
  1361.        
  1362.     }*/
  1363.    
  1364.     /*var mouse_click_event = function(id) {
  1365.         if (TouchInput.isPressed() && mouse_over_event(id)) {
  1366.             return true;
  1367.         } else {
  1368.             return false;
  1369.         }
  1370.     }*/
  1371.    
  1372.     /*var mouse_click_rect = function(rect) {
  1373.         var a = Astfgl_Rects[rect]
  1374.         if (mouse_in_rect(a[0],a[1],a[2],a[3]) && TouchInput.isPressed() ) {
  1375.             return true;
  1376.         } else {
  1377.             return false;
  1378.         }
  1379.     }*/
  1380.    
  1381.     /*var rect = function(id,x1,y1,x2,y2) {
  1382.             Astfgl_Rects[id] = [x1,y1,x2,y2];
  1383.         }*/
  1384.    
  1385.     //Window Related commands
  1386.    
  1387.     var window_add = function(id,x,y,width,height) {
  1388.         var win;
  1389.         win = new Window_Base(eval(x),eval(y),1000,1000);
  1390.         Astfgl_Windows[id] = win;
  1391.         SceneManager._scene.addChild(win);
  1392.         win._commands = [];
  1393.         win._commands.push([-1,id,x,y,width,height]);
  1394.         window_size(id,eval(width),eval(height));
  1395.     }
  1396.    
  1397.     var window_remove = function(id) {
  1398.         SceneManager._scene.removeChild(Astfgl_Windows[id]);
  1399.     }
  1400.    
  1401.     var window_text = function(id,x,y,txt,maxwidth,align) {
  1402.         align = align || "left";
  1403.         maxwidth = maxwidth || Astfgl_Windows[id].width;
  1404.         Astfgl_Windows[id]._windowContentsSprite.bitmap.drawText(eval(txt),eval(x),eval(y),eval(maxwidth),48,align);
  1405.         Astfgl_Windows[id]._commands.push([0,id,x,y,txt,maxwidth,align])
  1406.     }
  1407.    
  1408.     var window_move = function(id,x,y) {
  1409.         if (x === undefined && y === undefined) {
  1410.             return [Astfgl_Windows[id].x,Astfgl_Windows[id].y];
  1411.         }
  1412.         Astfgl_Windows[id].x = eval(x);
  1413.         Astfgl_Windows[id].y = eval(y);
  1414.         Astfgl_Windows[id]._commands.push([1,id,x,y]);
  1415.     }
  1416.    
  1417.     var window_size = function(id,width,height) {
  1418.         if (width === undefined && height === undefined) {
  1419.             return [Astfgl_Windows[id].width,Astfgl_Windows[id].height];
  1420.         }
  1421.         Astfgl_Windows[id].width = eval(width);
  1422.         Astfgl_Windows[id].height = eval(height);
  1423.         Astfgl_Windows[id]._commands.push([2,id,width,height]);
  1424.     }
  1425.    
  1426.     var window_opacity = function(id,a) {
  1427.         if (a === undefined) {
  1428.             return Astfgl_Windows[id].opacity;
  1429.         }
  1430.         Astfgl_Windows[id].opacity = eval(a);
  1431.         Astfgl_Windows[id]._commands.push([3,id,a]);
  1432.     }
  1433.    
  1434.     var window_color = function(id,x,y,color) {
  1435.         Astfgl_Windows[id]._windowContentsSprite.bitmap.fillRect (eval(x), eval(y), 48, 48, color);
  1436.         Astfgl_Windows[id]._commands.push([4,id,x,y,color]);
  1437.  
  1438.     }
  1439.    
  1440.     var window_icon = function(id,x,y,iconId) {
  1441.         Astfgl_Windows[id].drawIcon(eval(iconId), eval(x), eval(y));
  1442.         Astfgl_Windows[id]._commands.push([5,id,x,y,iconId]);
  1443.     }
  1444.    
  1445.     var window_face = function(id,x,y,faceName,index,width,height) {
  1446.         width = width || Astfgl_Windows[id].width;
  1447.         height = height || Astfgl_Windows[id].height;
  1448.         Astfgl_Windows[id].drawFace(eval(faceName) ,eval(index) ,eval(x) ,eval(y) ,eval(width) ,eval(height));
  1449.         Astfgl_Windows[id]._commands.push([6,id,x,y,faceName,index,width,height]);
  1450.     }
  1451.    
  1452.     var window_gauge = function(id,paramMin,paramMax,x,y,width,height,color1,color2,color3) {
  1453.         color1 = color1 || "blue";
  1454.         color2 = color2 || "blue";
  1455.         color3 = color3 || "black";
  1456.         paramMin = paramMin || 50;
  1457.         paramMax = paramMax || 100;
  1458.         width = width || Astfgl_Windows[id].width;
  1459.         height = height || Astfgl_Windows[id].height;
  1460.         var rate = eval(paramMin)/eval(paramMax);
  1461.         var fillW = Math.floor(eval(width) * rate);
  1462.         Astfgl_Windows[id]._windowContentsSprite.bitmap.fillRect(eval(x), eval(y), eval(width), eval(height), color3);
  1463.         Astfgl_Windows[id]._windowContentsSprite.bitmap.gradientFillRect(eval(x), eval(y), eval(fillW), eval(height), color1, color2);
  1464.         Astfgl_Windows[id]._commands.push([7,id,paramMin,paramMax,x,y,width,height,color1,color2,color3]);
  1465.        
  1466.     }
  1467.    
  1468.     var window_text_color = function(id,color) {
  1469.         Astfgl_Windows[id].changeTextColor(color);
  1470.         Astfgl_Windows[id]._commands.push([8,id,color]);
  1471.     }
  1472.    
  1473.     var window_show = function(id) {
  1474.         Astfgl_Windows[id].show();
  1475.     }
  1476.    
  1477.     var window_hide = function(id) {
  1478.         Astfgl_Windows[id].hide();
  1479.     }
  1480.    
  1481.     var window_fill = function(id,color) {
  1482.         var width = Astfgl_Windows[id].width;
  1483.         var height = Astfgl_Windows[id].height;
  1484.         Astfgl_Windows[id]._windowContentsSprite.bitmap.fillRect(0, 0, width, height, color);
  1485.         Astfgl_Windows[id]._commands.push([9,id,color]);
  1486.     }
  1487.    
  1488.     var window_fontsize = function(id,size) {
  1489.         size = size || 28;
  1490.         Astfgl_Windows[id].contents.fontSize = eval(size);
  1491.         Astfgl_Windows[id]._commands.push([10,id,size]);
  1492.     }
  1493.    
  1494.     var window_contents_opacity = function(id,n,bool) {
  1495.         n = n || 255;
  1496.         Astfgl_Windows[id]._commands.push([11,id,n]);
  1497.         if (eval(n) <= 0) {n = 1};
  1498.         Astfgl_Windows[id]._windowContentsSprite.opacity = eval(n);
  1499.     }
  1500.    
  1501.     var window_update = function(id) {
  1502.         var i = 0;
  1503.         window_remove(id);
  1504.         var commandList = Astfgl_Windows[id]._commands
  1505.         for (i = 0; i < commandList.length; i++) {
  1506.             var a = commandList[i]
  1507.             switch (commandList[i][0]) {
  1508.                 case -1:
  1509.                     window_add(a[1],a[2],a[3],a[4],a[5],a[6]);
  1510.                     break;
  1511.                 case 0:
  1512.                     window_text(a[1],a[2],a[3],a[4],a[5],a[6]);
  1513.                     break;
  1514.                 case 1:
  1515.                     window_move(a[1],a[2],a[3]);
  1516.                     break;
  1517.                 case 2:
  1518.                     window_size(a[1],a[2],a[3]);
  1519.                     break;
  1520.                 case 3:
  1521.                     window_opacity(a[1],a[2]);
  1522.                     break;
  1523.                 case 4:
  1524.                     window_color(a[1],a[2],a[3],a[4]);
  1525.                     break;
  1526.                 case 5:
  1527.                     window_icon(a[1],a[2],a[3],a[4]);
  1528.                     break;
  1529.                 case 6:
  1530.                     window_face(a[1],a[2],a[3],a[4],a[5],a[6],a[7]);
  1531.                     break;
  1532.                 case 7:
  1533.                     window_gauge(a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10]);
  1534.                     break;
  1535.                 case 8:
  1536.                     window_text_color(a[1],a[2]);
  1537.                     break;
  1538.                 case 9:
  1539.                     window_fill(a[1],a[2]);
  1540.                     break;
  1541.                 case 10:
  1542.                     window_fontsize(a[1],a[2]);
  1543.                     break;
  1544.                 case 11:
  1545.                     window_contents_opacity(a[1],a[2]);
  1546.                     break;
  1547.                 default:
  1548.                     console.log("improper command")
  1549.                     break;
  1550.             }
  1551.         }
  1552.     }
  1553.    
  1554.     var window_exists = function(id) {
  1555.         if (Astfgl_Windows[id]) {
  1556.             return true;
  1557.         } else {
  1558.             return false;
  1559.         }
  1560.     }
  1561.    
  1562.     var window_update_all = function() {
  1563.         var i = 0;
  1564.         var a = Astfgl_Windows.length
  1565.         for (i=0; i < a; i++) {
  1566.             if (window_exists(i)) {
  1567.                 window_update(i);
  1568.                 }
  1569.         }
  1570.     }
  1571.    
  1572.     eval(script);
  1573.     return true;
  1574. };
  1575.  
  1576. Astfgl_Windows = [];
  1577. //Astfgl_Rects = []
  1578.  
  1579.  
  1580. // Game Variables modifications!
  1581. // This will create the SVA and RVA function for script
  1582. // to use.
  1583.  
  1584.  
  1585. //Below is my script for modifying the value at index from an array
  1586.   //Modifying a value in an array
  1587. Game_Variables.prototype.SVA = function(variableId, index, value) {
  1588.     if (variableId > 0 &&variableId < $dataSystem.variables.length) {
  1589.         var index
  1590.         if (typeof value === 'number') {
  1591.             value = Math.floor(value);
  1592.         }
  1593.         //if (index > this._data[variableId].length-1) {index = this._data[variableId].length-1}
  1594.         //remove the comment tags if you don't want this function to create new indexes
  1595.         if (index < 0) {index = 0}
  1596.         this._data[variableId][index] = value; //Just added [index]
  1597.         this.onChange();
  1598.     }
  1599. };
  1600. //End
  1601.  
  1602. // Below is the script for reading value from an array at index
  1603.  
  1604. Game_Variables.prototype.RVA = function(variableId, index) {
  1605.    //Reading value at index in an array
  1606.     var variableId, index
  1607.     return this._data[variableId][index] || 0; //Just added [index]
  1608. };
  1609.  
  1610.  
  1611. // Game interpreter modifications: creating the jump to label script call
  1612.  
  1613. Game_Interpreter.prototype.jump_to_label = function(label) {
  1614.     for (var i = 0; i < this._list.length; i++) {
  1615.         var command = this._list[i];
  1616.         if (command.code === 118 && command.parameters[0] === label) {
  1617.             this.jumpTo(i);
  1618.             return;
  1619.         }
  1620.     }
  1621.     return true;
  1622. }
  1623.  
  1624.  
  1625. //Touch input modifications
  1626. /*var alias_Astfgl_TIOMM = TouchInput._onMouseMove
  1627. TouchInput._onMouseMove = function(event) {
  1628.     alias_Astfgl_TIOMM.call(this);
  1629.     var x = Graphics.pageToCanvasX(event.pageX);
  1630.     var y = Graphics.pageToCanvasY(event.pageY);
  1631.     this.mouseX = x
  1632.     this.mouseY = y
  1633. }*/
  1634.  
  1635.   })();  // dont touch this.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement