Advertisement
Guest User

Script box QOL improvements v0.2

a guest
Jun 2nd, 2016
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Astfgl's QOL script box improvements v0.2
  3. // by Astfgl
  4. // Date: 02/06/2016  
  5. // You are allowed to use this plugin free of charge, both for commercial and
  6. // non commercial use. If used in a commercial project, a free copy would be
  7. // nice, but is not required. You are freely allowed to edit this plugin, but
  8. // you must keep this header intact and readable. You are not allowed to
  9. // release anything using or based on this plugin without abiding by this
  10. // license. Your credits must include "Scriptbox QOL Improvements by Astfgl".
  11. //
  12. //
  13. // Credits: template made by Faytless / Thomas Pham. Without that, I
  14. // would still be making modification in the core files.
  15. //=============================================================================
  16.  
  17.  
  18. /*:
  19.  * @plugindesc QOL improvements for eventing
  20.  * @author Astfgl
  21.  *
  22.  * @param No params are available
  23.  * @desc -
  24.  * @default -  
  25.  
  26.  */
  27.  
  28.   (function() {
  29.   var parameters = PluginManager.parameters('Astgfl');
  30.  
  31.  
  32.  // Below i define all the functions that can be used while inside a script box
  33.  
  34.   var _Game_Interpreter_Astfgl = Game_Interpreter.prototype.command355;
  35.  
  36.   Game_Interpreter.prototype.command355 = function() {
  37.     var variableId, Index, value
  38.     var script = this.currentCommand().parameters[0] + '\n';
  39.     while (this.nextEventCode() === 655) {
  40.         this._index++;
  41.         script += this.currentCommand().parameters[0] + '\n';
  42.     }
  43.    
  44.     SV = function(variableId, value) {
  45.         var variableId, value
  46.         $gameVariables.setValue(variableId, value)
  47.     }
  48.    
  49.     SVA = function(variableId, index, value) {
  50.         var variableId, Index, value
  51.         $gameVariables.SVA(variableId, index, value)
  52.     }
  53.    
  54.     RV = function(variableId) {
  55.         var variableId
  56.         return $gameVariables.value(variableId)
  57.     }
  58.    
  59.     RVA = function(variableId, index) {
  60.         var variableId, index
  61.         return $gameVariables.RVA(variableId, index)
  62.     }
  63.    
  64.     SS = function(switchId, value) {
  65.         var switchId, value
  66.         $gameSwitches.setValue(switchId, value)
  67.     }
  68.    
  69.     RS = function(switchId){
  70.         var switchId
  71.         return $gameSwitches.value(switchId)
  72.     }
  73.    
  74.     SSelf = function(mapId,eventId,name,bool) {
  75.         var mapId, eventId, name, bool
  76.         $gameSelfSwitches.setValue([mapId,eventId,name], bool);
  77.     }
  78.    
  79.     RSelf = function(mapId,eventId,name) {
  80.         var mapId, eventId, name
  81.         return $gameSelfSwitches.value([mapId,eventId,name])
  82.     }
  83.    
  84.     add_gold = function(value) {
  85.         var value
  86.         $gameParty.gainGold(value);
  87.     }
  88.    
  89.     add_item = function(itemId, n) {
  90.         var itemId,n
  91.         $gameParty.gainItem($dataItems[itemId], n);
  92.     }
  93.    
  94.     add_weapon = function(weaponId,n,bool) {
  95.         var weaponId, n, bool
  96.         $gameParty.gainItem($dataWeapons[weaponId], n, bool);
  97.     }
  98.    
  99.     add_armor = function(armorId,n,bool) {
  100.         var armorId, n, bool
  101.         $gameParty.gainItem($dataArmors[armorId], n, bool);
  102.     }
  103.    
  104.     actor_add = function(actorId) {
  105.         var actorId
  106.         $gameParty.addActor(actorId)
  107.     }
  108.    
  109.     actor_remove = function(actorId) {
  110.         var actorId
  111.         $gameParty.removeActor(actorId)
  112.     }
  113.    
  114.     actor_hp_add = function(actorId,n) {
  115.         var actorId, n
  116.         $gameActors.actor(actorId).gainHp(n)   
  117.     }
  118.    
  119.     actor_mp_add = function(actorId,n) {
  120.         var actorId, n
  121.         $gameActors.actor(actorId).gainMp(n)   
  122.     }
  123.    
  124.     actor_tp_add = function(actorId,n) {
  125.         var actorId, n
  126.         $gameActors.actor(actorId).gainTp(n)   
  127.     }
  128.    
  129.     actor_vadd = function(actorId, nHP, nMP, nTP) {
  130.         var actorId, nHP, nMP, nTP
  131.         $gameActors.actor(actorId).gainHp(nHP)
  132.         $gameActors.actor(actorId).gainMp(nMP)
  133.         $gameActors.actor(actorId).gainTp(nTP)
  134.     }
  135.    
  136.     actor_st_add = function(actorId, n) {
  137.          var actorId, n
  138.          $gameActors.actor(actorId).addState(n);
  139.     }
  140.    
  141.     actor_st_remove = function(actorId, n) {
  142.         var actorId, n
  143.         $gameActors.actor(actorId).removeState(n)
  144.     }
  145.    
  146.     actor_change_exp = function(actorId,n) {
  147.         var actorId, n
  148.         $gameActors.actor(actorId).gainExp(n);
  149.     }
  150.    
  151.     actor_change_lvl = function(actorId, n, bool) {
  152.         var actor_Id, n, bool
  153.         $gameActors.actor(actorId).changeLevel(n, bool);
  154.     }
  155.    
  156.     actor_change_params = function(actorId, paramId, n) {
  157.         var actor_Id, paramId, n
  158.         $gameActors.actor(actorId).addParam(paramId, n);
  159.     }
  160.    
  161.     actor_skill_l = function(actorId, n) {
  162.         var actorId, n
  163.         $gameActors.actor(actorId).learnSkill(n);
  164.     }
  165.    
  166.     actor_skill_f = function(actorId, n) {
  167.         var actorId, n
  168.         $gameActors.actor(actorId).forgetSkill(n);
  169.     }
  170.    
  171.     actor_equip_w = function(actorId,slotId,item) {
  172.         var actorId, slotId, item
  173.         $gameActors.actor(actorId).changeEquip(slotId, $dataWeapons[item]);
  174.     }
  175.    
  176.     actor_equip_a = function(actorId,slotId,item) {
  177.         var actorId, slotId, item
  178.         $gameActors.actor(actorId).changeEquip(slotId, $dataArmors[item]);
  179.     }
  180.    
  181.     actor_change_name = function(actorId,n) {
  182.         var actorId, n
  183.         $gameActors.actor(actorId).setName(n)
  184.     }
  185.    
  186.     actor_change_class = function(actorId,n,bool) {
  187.         var actorId, n, bool
  188.         $gameActors.actor(actorId).changeClass(n, bool)
  189.     }
  190.    
  191.     actor_change_handle = function(actorId, n) {
  192.         var actorId, n
  193.         $gameActors.actor(actorId).setNickname(n)
  194.     }
  195.    
  196.     actor_change_profile = function(actorId, n) {
  197.         var actorId, n
  198.         $gameActors.actor(actorId).setProfile(n)
  199.     }  
  200.    
  201.     transfer = function(mapId, x, y, direction, fadetype) {
  202.         var mapId, x, y, direction, fadetype
  203.         $gamePlayer.reserveTransfer(mapId, x, y, direction, fadetype);
  204.     }
  205.    
  206.     transfer_event = function(eventId,x,y) {
  207.         var eventId, x, y
  208.         $gameMap.event(eventId).setPosition(x, y)
  209.     }
  210.    
  211.     equip_id = function(actorId, n) {
  212.         var actorId, n
  213.         if ($gameActors.actor(actorId).equips()[n]) {
  214.         return $gameActors.actor(actorId).equips()[n].id
  215.         }
  216.     }
  217.    
  218.     equip_name = function(actorId, n) {
  219.         var actorId, n
  220.         if ($gameActors.actor(actorId).equips()[n]) {
  221.         return $gameActors.actor(actorId).equips()[n].name
  222.         }
  223.     }
  224.    
  225.     actor_weaponC = function(actorId, n) {
  226.         var actorId, n
  227.         return $gameActors.actor(actorId).equips().contains($dataWeapons[n])
  228.     }
  229.    
  230.     actor_armorC = function(actorId, n) {
  231.         var actorId, n
  232.         return $gameActors.actor(actorId).equips().contains($dataArmors[n])
  233.     }
  234.    
  235.     actor_skillC = function(actorId, n) {
  236.         var actorId, n
  237.         return $gameActors.actor(actorId).skills().contains($dataSkills[n])
  238.     }
  239.    
  240.     pic_show = function(pictureId, name, origin, x , y ,  scaleX, scaleY, opacity, blendMode) {
  241.         var pictureId, name, origin, scaleX, scaleY, opacity, blendMode, x , y
  242.         $gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode)
  243.     }
  244.    
  245.     pic_move = function(pictureId, origin, x , y,  scaleX, scaleY, opacity, blendMode, duration) {
  246.         var pictureId, origin, scaleX, scaleY, opacity, blendMode, x , y , duration
  247.         $gameScreen.movePicture(pictureId, origin, x, y, scaleX, scaleY, opacity, blendMode, duration)
  248.     }
  249.    
  250.     pic_rotate = function(pictureId, speed) {
  251.         var pictureId, speed
  252.         $gameScreen.rotatePicture(pictureId, speed);
  253.     }
  254.    
  255.     pic_tint = function(pictureId, tone, duration) {
  256.         var pictureId, tone, duration
  257.         $gameScreen.tintPicture(pictureId, tone, duration);
  258.     }
  259.    
  260.     pic_erase = function(pictureId) {
  261.         var pictureId
  262.         $gameScreen.erasePicture(pictureId);
  263.     }
  264.    
  265.     pic_clear = function() {
  266.         $gameScreen.clearPictures()
  267.     }
  268.    
  269.     player_x = function() {
  270.         return $gamePlayer.x
  271.     }
  272.  
  273.     player_y = function() {
  274.         return $gamePlayer.y
  275.     }
  276.    
  277.     event_x = function(eventId) {
  278.         var eventId
  279.         return $gameMap.events()[eventId].x
  280.     }
  281.    
  282.     event_y = function(eventId) {
  283.         var eventId
  284.         return $gameMap.events()[eventId].y
  285.     }
  286.    
  287.     gold = function() {
  288.         return $gameParty.gold()
  289.     }
  290.    
  291.     actor_paramb = function (actorId,paramId) {
  292.         var actorId, paramId
  293.         return $gameActors.actor(actorId).currentClass().params[paramId][$gameActors.actor(actorId)._level]
  294.     }
  295.     //50 Commands!
  296.     actor_param = function(actorId, paramId) {
  297.         var actorId, paramId, calc
  298.         calc = $gameActors.actor(actorId).paramPlus(paramId) + actor_paramb(actorId,paramId)
  299.         return calc
  300.     }
  301.    
  302.     actor_lvl = function(actorId) {
  303.         var actorId
  304.         return $gameActors.actor(actorId)._level
  305.     }
  306.    
  307.     actor_equip_clear = function(actorId) {
  308.         var actorId
  309.         $gameActors.actor(actorId).clearEquipments()
  310.     }
  311.    
  312.     actor_equip_opti = function(actorId) {
  313.         var actorId
  314.         $gameActors.actor(actorId).optimizeEquipments()
  315.     }
  316.    
  317.     event_jump = function(eventId,xto,yto) {
  318.         var eventId, xto, yto
  319.         $gameMap.events()[eventId-1].forceMoveRoute({
  320.           list:[{code: 14,indent: null,parameters:[xto-event_x(eventId-1),yto-event_y(eventId-1)] }],repeat:false,skippable:true,wait:false})
  321.         }
  322.    
  323.     event_id = function() {
  324.         return $gameMap._interpreter.eventId()
  325.     }
  326.    
  327.     jump_to_label = function(label) {
  328.         var label
  329.         $gameMap._interpreter.jump_to_label(label)
  330.     }
  331.    
  332.     anim_show = function(eventId, animId) {
  333.         var eventId, animId, wait
  334.         if (eventId > 0) {
  335.         $gameMap.events()[eventId].requestAnimation(animId);
  336.         }
  337.         if (eventId === 0) {
  338.         $gamePlayer.requestAnimation(animId)
  339.         }
  340.     }
  341.    
  342.     regionC = function(x,y) {
  343.         var x, y
  344.         return $gameMap.regionId(x, y);
  345.     }
  346.    
  347.     event_idat = function(x,y) {
  348.         var x, y
  349.         return $gameMap.eventIdXy(x, y);
  350.     }
  351.    
  352.     terrain_tag = function(x,y) {
  353.         var x, y
  354.         return $gameMap.terrainTag(x, y);
  355.     }
  356.    
  357.     equip_note = function(actorId, equipId) {
  358.         var actorId, equipId
  359.         if ($gameActors.actor(actorId).equips()[equipId]) {
  360.         return $gameActors.actor(actorId).equips()[equipId].note
  361.         }
  362.     }
  363.    
  364.     weapon_note = function(Id) {
  365.         var Id
  366.         return $dataWeapons[Id].note
  367.     }
  368.    
  369.     armor_note = function(Id) {
  370.         var Id
  371.         return $dataArmors[Id].note
  372.     }
  373.    
  374.     actor_note = function(Id) {
  375.         var Id
  376.         return $dataActors[Id].note
  377.     }
  378.    
  379.     item_note = function(Id) {
  380.         var Id
  381.         return $dataItems[Id].note
  382.     }
  383.    
  384.     skill_note = function(Id) {
  385.         var Id
  386.         return $dataSkills[Id].note
  387.     }
  388.    
  389.     monster_note = function(Id) {
  390.         var Id
  391.         return $dataEnemies[Id].note
  392.     }
  393.    
  394.     monster_param = function(Id, paramId) {
  395.         var Id, paramId
  396.         return $dataEnemies[Id].params[paramId]
  397.     }
  398.    
  399.     /*event_distance = function(Id1, Id2) {
  400.         var Id1, Id2, calc
  401.         calc = Math.abs(event_x(Id1)-event_x(Id2)) + Math.abs(event_y(Id1)-event_y(Id2))
  402.         return calc
  403.     }*/
  404.    
  405.     //69 commands
  406.    
  407.    
  408.     eval(script);
  409.     return true;
  410. };
  411.  
  412. // Game Variables modifications!
  413. // This will create the SVA and RVA function for script
  414. // to use.
  415.  
  416.  
  417. //Below is my script for modifying the value at index from an array
  418.   var _Game_Variables_Astfgl66 = Game_Variables.prototype.SVA;
  419.   //Modifying a value in an array
  420. Game_Variables.prototype.SVA = function(variableId, index, value) {
  421.     if (variableId > 0 &&variableId < $dataSystem.variables.length) {
  422.         var index
  423.         if (typeof value === 'number') {
  424.             value = Math.floor(value);
  425.         }
  426.         //if (index > this._data[variableId].length-1) {index = this._data[variableId].length-1}
  427.         //remove the comment tags if you don't want this function to create new indexes
  428.         if (index < 0) {index = 0}
  429.         this._data[variableId][index] = value; //Just added [index]
  430.         this.onChange();
  431.     }
  432. };
  433. //End
  434.  
  435. // Below is the script for reading value from an array at index
  436.    var _Game_Variables_Astfgl66 = Game_Variables.prototype.RVA;
  437.  
  438. Game_Variables.prototype.RVA = function(variableId, index) {
  439.    //Reading value at index in an array
  440.     var variableId, index
  441.     return this._data[variableId][index] || 0; //Just added [index]
  442. };
  443.  
  444.    var Game_Interpreter_Astfgl66 = Game_Interpreter.prototype.jump_to_label;
  445.  
  446. // Testing script for jumping to a label
  447.  
  448. Game_Interpreter.prototype.jump_to_label = function(label) {
  449.     var label
  450.     for (var i = 0; i < this._list.length; i++) {
  451.         var command = this._list[i];
  452.         if (command.code === 118 && command.parameters[0] === label) {
  453.             this.jumpTo(i);
  454.             return;
  455.         }
  456.     }
  457.     return true;
  458. }
  459.  
  460.  
  461.  
  462.   })();  // dont touch this.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement