Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // Astfgl's QOL script box improvements v0.2
- // by Astfgl
- // Date: 02/06/2016
- // You are allowed to use this plugin free of charge, both for commercial and
- // non commercial use. If used in a commercial project, a free copy would be
- // nice, but is not required. You are freely allowed to edit this plugin, but
- // you must keep this header intact and readable. You are not allowed to
- // release anything using or based on this plugin without abiding by this
- // license. Your credits must include "Scriptbox QOL Improvements by Astfgl".
- //
- //
- // Credits: template made by Faytless / Thomas Pham. Without that, I
- // would still be making modification in the core files.
- //=============================================================================
- /*:
- * @plugindesc QOL improvements for eventing
- * @author Astfgl
- *
- * @param No params are available
- * @desc -
- * @default -
- */
- (function() {
- var parameters = PluginManager.parameters('Astgfl');
- // Below i define all the functions that can be used while inside a script box
- var _Game_Interpreter_Astfgl = Game_Interpreter.prototype.command355;
- Game_Interpreter.prototype.command355 = function() {
- var variableId, Index, value
- var script = this.currentCommand().parameters[0] + '\n';
- while (this.nextEventCode() === 655) {
- this._index++;
- script += this.currentCommand().parameters[0] + '\n';
- }
- SV = function(variableId, value) {
- var variableId, value
- $gameVariables.setValue(variableId, value)
- }
- SVA = function(variableId, index, value) {
- var variableId, Index, value
- $gameVariables.SVA(variableId, index, value)
- }
- RV = function(variableId) {
- var variableId
- return $gameVariables.value(variableId)
- }
- RVA = function(variableId, index) {
- var variableId, index
- return $gameVariables.RVA(variableId, index)
- }
- SS = function(switchId, value) {
- var switchId, value
- $gameSwitches.setValue(switchId, value)
- }
- RS = function(switchId){
- var switchId
- return $gameSwitches.value(switchId)
- }
- SSelf = function(mapId,eventId,name,bool) {
- var mapId, eventId, name, bool
- $gameSelfSwitches.setValue([mapId,eventId,name], bool);
- }
- RSelf = function(mapId,eventId,name) {
- var mapId, eventId, name
- return $gameSelfSwitches.value([mapId,eventId,name])
- }
- add_gold = function(value) {
- var value
- $gameParty.gainGold(value);
- }
- add_item = function(itemId, n) {
- var itemId,n
- $gameParty.gainItem($dataItems[itemId], n);
- }
- add_weapon = function(weaponId,n,bool) {
- var weaponId, n, bool
- $gameParty.gainItem($dataWeapons[weaponId], n, bool);
- }
- add_armor = function(armorId,n,bool) {
- var armorId, n, bool
- $gameParty.gainItem($dataArmors[armorId], n, bool);
- }
- actor_add = function(actorId) {
- var actorId
- $gameParty.addActor(actorId)
- }
- actor_remove = function(actorId) {
- var actorId
- $gameParty.removeActor(actorId)
- }
- actor_hp_add = function(actorId,n) {
- var actorId, n
- $gameActors.actor(actorId).gainHp(n)
- }
- actor_mp_add = function(actorId,n) {
- var actorId, n
- $gameActors.actor(actorId).gainMp(n)
- }
- actor_tp_add = function(actorId,n) {
- var actorId, n
- $gameActors.actor(actorId).gainTp(n)
- }
- actor_vadd = function(actorId, nHP, nMP, nTP) {
- var actorId, nHP, nMP, nTP
- $gameActors.actor(actorId).gainHp(nHP)
- $gameActors.actor(actorId).gainMp(nMP)
- $gameActors.actor(actorId).gainTp(nTP)
- }
- actor_st_add = function(actorId, n) {
- var actorId, n
- $gameActors.actor(actorId).addState(n);
- }
- actor_st_remove = function(actorId, n) {
- var actorId, n
- $gameActors.actor(actorId).removeState(n)
- }
- actor_change_exp = function(actorId,n) {
- var actorId, n
- $gameActors.actor(actorId).gainExp(n);
- }
- actor_change_lvl = function(actorId, n, bool) {
- var actor_Id, n, bool
- $gameActors.actor(actorId).changeLevel(n, bool);
- }
- actor_change_params = function(actorId, paramId, n) {
- var actor_Id, paramId, n
- $gameActors.actor(actorId).addParam(paramId, n);
- }
- actor_skill_l = function(actorId, n) {
- var actorId, n
- $gameActors.actor(actorId).learnSkill(n);
- }
- actor_skill_f = function(actorId, n) {
- var actorId, n
- $gameActors.actor(actorId).forgetSkill(n);
- }
- actor_equip_w = function(actorId,slotId,item) {
- var actorId, slotId, item
- $gameActors.actor(actorId).changeEquip(slotId, $dataWeapons[item]);
- }
- actor_equip_a = function(actorId,slotId,item) {
- var actorId, slotId, item
- $gameActors.actor(actorId).changeEquip(slotId, $dataArmors[item]);
- }
- actor_change_name = function(actorId,n) {
- var actorId, n
- $gameActors.actor(actorId).setName(n)
- }
- actor_change_class = function(actorId,n,bool) {
- var actorId, n, bool
- $gameActors.actor(actorId).changeClass(n, bool)
- }
- actor_change_handle = function(actorId, n) {
- var actorId, n
- $gameActors.actor(actorId).setNickname(n)
- }
- actor_change_profile = function(actorId, n) {
- var actorId, n
- $gameActors.actor(actorId).setProfile(n)
- }
- transfer = function(mapId, x, y, direction, fadetype) {
- var mapId, x, y, direction, fadetype
- $gamePlayer.reserveTransfer(mapId, x, y, direction, fadetype);
- }
- transfer_event = function(eventId,x,y) {
- var eventId, x, y
- $gameMap.event(eventId).setPosition(x, y)
- }
- equip_id = function(actorId, n) {
- var actorId, n
- if ($gameActors.actor(actorId).equips()[n]) {
- return $gameActors.actor(actorId).equips()[n].id
- }
- }
- equip_name = function(actorId, n) {
- var actorId, n
- if ($gameActors.actor(actorId).equips()[n]) {
- return $gameActors.actor(actorId).equips()[n].name
- }
- }
- actor_weaponC = function(actorId, n) {
- var actorId, n
- return $gameActors.actor(actorId).equips().contains($dataWeapons[n])
- }
- actor_armorC = function(actorId, n) {
- var actorId, n
- return $gameActors.actor(actorId).equips().contains($dataArmors[n])
- }
- actor_skillC = function(actorId, n) {
- var actorId, n
- return $gameActors.actor(actorId).skills().contains($dataSkills[n])
- }
- pic_show = function(pictureId, name, origin, x , y , scaleX, scaleY, opacity, blendMode) {
- var pictureId, name, origin, scaleX, scaleY, opacity, blendMode, x , y
- $gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode)
- }
- pic_move = function(pictureId, origin, x , y, scaleX, scaleY, opacity, blendMode, duration) {
- var pictureId, origin, scaleX, scaleY, opacity, blendMode, x , y , duration
- $gameScreen.movePicture(pictureId, origin, x, y, scaleX, scaleY, opacity, blendMode, duration)
- }
- pic_rotate = function(pictureId, speed) {
- var pictureId, speed
- $gameScreen.rotatePicture(pictureId, speed);
- }
- pic_tint = function(pictureId, tone, duration) {
- var pictureId, tone, duration
- $gameScreen.tintPicture(pictureId, tone, duration);
- }
- pic_erase = function(pictureId) {
- var pictureId
- $gameScreen.erasePicture(pictureId);
- }
- pic_clear = function() {
- $gameScreen.clearPictures()
- }
- player_x = function() {
- return $gamePlayer.x
- }
- player_y = function() {
- return $gamePlayer.y
- }
- event_x = function(eventId) {
- var eventId
- return $gameMap.events()[eventId].x
- }
- event_y = function(eventId) {
- var eventId
- return $gameMap.events()[eventId].y
- }
- gold = function() {
- return $gameParty.gold()
- }
- actor_paramb = function (actorId,paramId) {
- var actorId, paramId
- return $gameActors.actor(actorId).currentClass().params[paramId][$gameActors.actor(actorId)._level]
- }
- //50 Commands!
- actor_param = function(actorId, paramId) {
- var actorId, paramId, calc
- calc = $gameActors.actor(actorId).paramPlus(paramId) + actor_paramb(actorId,paramId)
- return calc
- }
- actor_lvl = function(actorId) {
- var actorId
- return $gameActors.actor(actorId)._level
- }
- actor_equip_clear = function(actorId) {
- var actorId
- $gameActors.actor(actorId).clearEquipments()
- }
- actor_equip_opti = function(actorId) {
- var actorId
- $gameActors.actor(actorId).optimizeEquipments()
- }
- event_jump = function(eventId,xto,yto) {
- var eventId, xto, yto
- $gameMap.events()[eventId-1].forceMoveRoute({
- list:[{code: 14,indent: null,parameters:[xto-event_x(eventId-1),yto-event_y(eventId-1)] }],repeat:false,skippable:true,wait:false})
- }
- event_id = function() {
- return $gameMap._interpreter.eventId()
- }
- jump_to_label = function(label) {
- var label
- $gameMap._interpreter.jump_to_label(label)
- }
- anim_show = function(eventId, animId) {
- var eventId, animId, wait
- if (eventId > 0) {
- $gameMap.events()[eventId].requestAnimation(animId);
- }
- if (eventId === 0) {
- $gamePlayer.requestAnimation(animId)
- }
- }
- regionC = function(x,y) {
- var x, y
- return $gameMap.regionId(x, y);
- }
- event_idat = function(x,y) {
- var x, y
- return $gameMap.eventIdXy(x, y);
- }
- terrain_tag = function(x,y) {
- var x, y
- return $gameMap.terrainTag(x, y);
- }
- equip_note = function(actorId, equipId) {
- var actorId, equipId
- if ($gameActors.actor(actorId).equips()[equipId]) {
- return $gameActors.actor(actorId).equips()[equipId].note
- }
- }
- weapon_note = function(Id) {
- var Id
- return $dataWeapons[Id].note
- }
- armor_note = function(Id) {
- var Id
- return $dataArmors[Id].note
- }
- actor_note = function(Id) {
- var Id
- return $dataActors[Id].note
- }
- item_note = function(Id) {
- var Id
- return $dataItems[Id].note
- }
- skill_note = function(Id) {
- var Id
- return $dataSkills[Id].note
- }
- monster_note = function(Id) {
- var Id
- return $dataEnemies[Id].note
- }
- monster_param = function(Id, paramId) {
- var Id, paramId
- return $dataEnemies[Id].params[paramId]
- }
- /*event_distance = function(Id1, Id2) {
- var Id1, Id2, calc
- calc = Math.abs(event_x(Id1)-event_x(Id2)) + Math.abs(event_y(Id1)-event_y(Id2))
- return calc
- }*/
- //69 commands
- eval(script);
- return true;
- };
- // Game Variables modifications!
- // This will create the SVA and RVA function for script
- // to use.
- //Below is my script for modifying the value at index from an array
- var _Game_Variables_Astfgl66 = Game_Variables.prototype.SVA;
- //Modifying a value in an array
- Game_Variables.prototype.SVA = function(variableId, index, value) {
- if (variableId > 0 &&variableId < $dataSystem.variables.length) {
- var index
- if (typeof value === 'number') {
- value = Math.floor(value);
- }
- //if (index > this._data[variableId].length-1) {index = this._data[variableId].length-1}
- //remove the comment tags if you don't want this function to create new indexes
- if (index < 0) {index = 0}
- this._data[variableId][index] = value; //Just added [index]
- this.onChange();
- }
- };
- //End
- // Below is the script for reading value from an array at index
- var _Game_Variables_Astfgl66 = Game_Variables.prototype.RVA;
- Game_Variables.prototype.RVA = function(variableId, index) {
- //Reading value at index in an array
- var variableId, index
- return this._data[variableId][index] || 0; //Just added [index]
- };
- var Game_Interpreter_Astfgl66 = Game_Interpreter.prototype.jump_to_label;
- // Testing script for jumping to a label
- Game_Interpreter.prototype.jump_to_label = function(label) {
- var label
- for (var i = 0; i < this._list.length; i++) {
- var command = this._list[i];
- if (command.code === 118 && command.parameters[0] === label) {
- this.jumpTo(i);
- return;
- }
- }
- return true;
- }
- })(); // dont touch this.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement