Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // Astfgl's QOL script box improvements v0.7
- // by Astfgl
- // Date: 09/07/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".
- // Furthermore, you are not allowed to release this plugin or any version you
- // have edited, on any forum but the official rpgmakerweb.com forums without my
- // express written permission. Do not claim ownership.
- //
- // I'd much appreciate a PM on the RPGMakerweb.com forums if you find a clever use
- // for one or more event commands I provided: profile Astfgl66. Or write in the
- // thread.
- //
- // If you have any suggestion for a command you'd like referenced, drop me a PM
- // and I'll see what i can do. If you provide me with the exact script call
- // there's a 99% chanche it will make it in!
- //
- // Credits:
- // -Plugin template made by Faytless / Thomas Pham. Without that, I
- // would still be making modification in the core files.
- // -The point in polygon formula was taken from the internet.
- // Credit in comment near the command along with link to the source.
- // It is free to use and redistribute, under MIT license. It means you have
- // to credit them too.
- // -RPG Maker extender project for RPGMaker VXACE, for providing me with the idea
- // and need to do this plugin.
- // -Tsukihime for the plugin jump_to_label via script call for Ace, which
- // inspired me to write the function for MV.
- //=============================================================================
- /*:
- * @plugindesc Script box syntax 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';
- }
- var SV = function(variableId, value) {
- $gameVariables.setValue(variableId, value)
- }
- var SVA = function(variableId, index, value) {
- $gameVariables.SVA(variableId, index, value)
- }
- var RV = function(variableId) {
- return $gameVariables.value(variableId)
- }
- var RVA = function(variableId, index) {
- return $gameVariables.RVA(variableId, index)
- }
- var SS = function(switchId, value) {
- $gameSwitches.setValue(switchId, value)
- }
- var RS = function(switchId){
- return $gameSwitches.value(switchId)
- }
- var SSelf = function(mapId,eventId,name,bool) {
- $gameSelfSwitches.setValue([mapId,eventId,name], bool);
- }
- var RSelf = function(mapId,eventId,name) {
- return $gameSelfSwitches.value([mapId,eventId,name])
- }
- var add_gold = function(value) {
- $gameParty.gainGold(value);
- }
- var add_item = function(itemId, n) {
- $gameParty.gainItem($dataItems[itemId], n);
- }
- var add_weapon = function(weaponId,n,bool) {
- bool = bool || false
- $gameParty.gainItem($dataWeapons[weaponId], n, bool);
- }
- var add_armor = function(armorId,n,bool) {
- bool = bool || false
- $gameParty.gainItem($dataArmors[armorId], n, bool);
- }
- var actor_add = function(actorId) {
- $gameParty.addActor(actorId)
- }
- var actor_remove = function(actorId) {
- $gameParty.removeActor(actorId)
- }
- var actor_hp_add = function(actorId,n) {
- n = n || 0;
- $gameActors.actor(actorId).gainHp(n);
- }
- var actor_mp_add = function(actorId,n) {
- n = n || 0;
- $gameActors.actor(actorId).gainMp(n);
- }
- var actor_tp_add = function(actorId,n) {
- n = n || 0;
- $gameActors.actor(actorId).gainTp(n);
- }
- var actor_vadd = function(actorId, nHP, nMP, nTP) {
- nHP = nHP || 0;
- nMP = nMP || 0;
- nTP = nTP || 0;
- $gameActors.actor(actorId).gainHp(nHP);
- $gameActors.actor(actorId).gainMp(nMP);
- $gameActors.actor(actorId).gainTp(nTP);
- }
- var actor_st_add = function(actorId, n) {
- $gameActors.actor(actorId).addState(n);
- }
- var actor_st_remove = function(actorId, n) {
- $gameActors.actor(actorId).removeState(n)
- }
- var actor_change_exp = function(actorId,n) {
- $gameActors.actor(actorId).gainExp(n);
- }
- var actor_change_lvl = function(actorId, n, bool) {
- bool = bool || false
- $gameActors.actor(actorId).changeLevel(n, bool);
- }
- var actor_change_params = function(actorId, paramId, n) {
- $gameActors.actor(actorId).addParam(paramId, n);
- }
- var actor_skill_l = function(actorId, n) {
- $gameActors.actor(actorId).learnSkill(n);
- }
- var actor_skill_f = function(actorId, n) {
- $gameActors.actor(actorId).forgetSkill(n);
- }
- var actor_equip_w = function(actorId,slotId,item) {
- $gameActors.actor(actorId).changeEquip(slotId, $dataWeapons[item]);
- }
- var actor_equip_a = function(actorId,slotId,item) {
- $gameActors.actor(actorId).changeEquip(slotId, $dataArmors[item]);
- }
- var actor_change_name = function(actorId,n) {
- $gameActors.actor(actorId).setName(n)
- }
- var actor_change_class = function(actorId,n,bool) {
- bool = bool || false
- $gameActors.actor(actorId).changeClass(n, bool)
- }
- var actor_change_handle = function(actorId, n) {
- $gameActors.actor(actorId).setNickname(n)
- }
- var actor_change_profile = function(actorId, n) {
- $gameActors.actor(actorId).setProfile(n)
- }
- var transfer = function(mapId, x, y, direction, fadetype) {
- $gamePlayer.reserveTransfer(mapId, x, y, direction, fadetype);
- }
- var transfer_event = function(eventId,x,y) {
- if (eventId === 0) {
- $gamePlayer.setPosition(x, y)
- } else{
- $gameMap.event(eventId).setPosition(x, y)
- }
- }
- var equip_id = function(actorId, n) {
- if ($gameActors.actor(actorId).equips()[n]) {
- return $gameActors.actor(actorId).equips()[n].id
- }
- }
- var equip_name = function(actorId, n) {
- if ($gameActors.actor(actorId).equips()[n]) {
- return $gameActors.actor(actorId).equips()[n].name
- }
- }
- var actor_weaponC = function(actorId, n) {
- return $gameActors.actor(actorId).equips().contains($dataWeapons[n])
- }
- var actor_armorC = function(actorId, n) {
- return $gameActors.actor(actorId).equips().contains($dataArmors[n])
- }
- var actor_skillC = function(actorId, n) {
- return $gameActors.actor(actorId).skills().contains($dataSkills[n])
- }
- var pic_show = function(pictureId, name, origin, x , y , scaleX, scaleY, opacity, blendMode) {
- blendMode = blendMode || 0;
- opacity = opacity || 255;
- scaleX = scaleX || 100;
- scaleY = scaleY || 100;
- $gameScreen.showPicture(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode)
- }
- var pic_move = function(pictureId, origin, x , y, scaleX, scaleY, opacity, blendMode, duration) {
- duration = duration || 1;
- blendMode = blendMode || 0;
- opacity = opacity || 255;
- scaleX = scaleX || 100;
- scaleY = scaleY || 100;
- $gameScreen.movePicture(pictureId, origin, x, y, scaleX, scaleY, opacity, blendMode, duration)
- }
- var pic_rotate = function(pictureId, speed) {
- $gameScreen.rotatePicture(pictureId, speed);
- }
- var pic_tint = function(pictureId, tone, duration) {
- $gameScreen.tintPicture(pictureId, tone, duration);
- }
- var pic_erase = function(pictureId) {
- $gameScreen.erasePicture(pictureId);
- }
- var pic_clear = function() {
- $gameScreen.clearPictures()
- }
- var player_x = function() {
- return $gamePlayer.x
- }
- var player_y = function() {
- return $gamePlayer.y
- }
- var event_x = function(eventId) {
- return get_event_by_id(eventId).x
- }
- var event_y = function(eventId) {
- return get_event_by_id(eventId).y
- }
- var gold = function() {
- return $gameParty.gold()
- }
- var actor_paramb = function (actorId,paramId) {
- return $gameActors.actor(actorId).currentClass().params[paramId][$gameActors.actor(actorId)._level]
- }
- //50 Commands!
- var actor_param = function(actorId, paramId) {
- var calc
- calc = $gameActors.actor(actorId).paramPlus(paramId) + actor_paramb(actorId,paramId)
- return calc
- }
- var actor_lvl = function(actorId) {
- return $gameActors.actor(actorId)._level
- }
- var actor_equip_clear = function(actorId) {
- $gameActors.actor(actorId).clearEquipments()
- }
- var actor_equip_opti = function(actorId) {
- $gameActors.actor(actorId).optimizeEquipments()
- }
- var event_jump = function(eventId,xto,yto) {
- get_event_by_id(eventId).forceMoveRoute({
- list:[{code: 14,indent: null,parameters:[xto-event_x(eventId),yto-event_y(eventId)] }],repeat:false,skippable:true,wait:false})
- }
- var event_id = function() {
- return $gameMap._interpreter.eventId()
- }
- var jump_to_label = function(label) {
- $gameMap._interpreter.jump_to_label(label)
- }
- var anim_show = function(eventId, animId) {
- if (eventId > 0) {
- $gameMap.events()[eventId].requestAnimation(animId);
- }
- if (eventId === 0) {
- $gamePlayer.requestAnimation(animId)
- }
- }
- var regionC = function(x,y) {
- return $gameMap.regionId(x, y);
- }
- var event_idat = function(x,y) {
- return $gameMap.eventIdXy(x, y);
- }
- var terrain_tag = function(x,y) {
- return $gameMap.terrainTag(x, y);
- }
- var equip_note = function(actorId, equipId) {
- if ($gameActors.actor(actorId).equips()[equipId]) {
- return $gameActors.actor(actorId).equips()[equipId].note
- }
- }
- var weapon_note = function(Id) {
- return $dataWeapons[Id].note
- }
- var armor_note = function(Id) {
- return $dataArmors[Id].note
- }
- var actor_note = function(Id) {
- return $dataActors[Id].note
- }
- var item_note = function(Id) {
- return $dataItems[Id].note
- }
- var skill_note = function(Id) {
- return $dataSkills[Id].note
- }
- var monster_note = function(Id) {
- return $dataEnemies[Id].note
- }
- var monster_param = function(Id, paramId) {
- return $dataEnemies[Id].params[paramId]
- }
- var event_distance = function(Id1, Id2) {
- var calc
- calc = Math.abs(event_x(Id1)-event_x(Id2))
- calc += Math.abs(event_y(Id1)-event_y(Id2))
- return calc
- }
- //V 0.2 02/06/2016 70 Functions
- var items = function() {
- var a = $gameParty.items().length
- var i, list
- i = 0
- list = []
- while (i < a) {
- list.push($gameParty.items()[i].id)
- i++
- }
- return list
- }
- var items_name = function() {
- var a = $gameParty.items().length
- var i, list
- i = 0
- list = []
- while (i < a) {
- list.push($gameParty.items()[i].name)
- i++
- }
- return list
- }
- var itemC = function(id) {
- if (items().contains(id)) {
- return true
- } else {
- return false
- }
- }
- var actor_skills = function(actorId) {
- var a, i, list
- a = $gameActors.actor(actorId).skills().length
- i = 0
- list = []
- while (i < a) {
- list.push($gameActors.actor(actorId).skills()[i].id)
- i++
- }
- return list
- }
- var actor_skills_name = function(actorId) {
- var a, i, list
- a = $gameActors.actor(actorId).skills().length
- i = 0
- list = []
- while (i < a) {
- list.push($gameActors.actor(actorId).skills()[i].name)
- i++
- }
- return list
- }
- var item_scope = function(id) {
- return $dataItems[id].scope
- }
- var item_scope_n = function(id) {
- var a
- a = item_scope(id)
- if (a === 0) {return "None"}
- if (a === 1) {return "1 Enemy"}
- if (a === 2) {return "All Enemies"}
- if (a === 3) {return "1 Random Enemy"}
- if (a === 4) {return "2 Random Enemies"}
- if (a === 5) {return "3 Random Enemies"}
- if (a === 6) {return "4 Random Enemies"}
- if (a === 7) {return "1 Ally"}
- if (a === 8) {return "All Allies"}
- if (a === 9) {return "1 Dead Ally"}
- if (a === 10) {return "All Dead Allies"}
- if (a === 11) {return "User"}
- }
- var item_price = function(id) {
- return $dataItems[id].price
- }
- var item_name = function(id) {
- return $dataItems[id].name
- }
- var currency = function() {
- return $dataSystem.currencyUnit
- }
- var save = function(id) {
- $gameSystem.onBeforeSave();
- DataManager.saveGame(id);
- }
- var weapons = function () {
- var a = $gameParty.weapons().length
- var i, list
- i = 0
- list = []
- while (i < a) {
- list.push($gameParty.weapons()[i].id)
- i++
- }
- return list
- }
- var weapons_name = function () {
- var a = $gameParty.weapons().length
- var i, list
- i = 0
- list = []
- while (i < a) {
- list.push($gameParty.weapons()[i].name)
- i++
- }
- return list
- }
- var armors = function () {
- var a = $gameParty.armors().length
- var i, list
- i = 0
- list = []
- while (i < a) {
- list.push($gameParty.armors()[i].id)
- i++
- }
- return list
- }
- var armors_name = function () {
- var a = $gameParty.armors().length
- var i, list
- i = 0
- list = []
- while (i < a) {
- list.push($gameParty.armors()[i].name)
- i++
- }
- return list
- }
- var armor_desc = function(id) {
- return $dataArmors[id].description
- }
- var weapon_desc = function(id) {
- return $dataWeapons[id].description
- }
- var item_desc = function(id) {
- return $dataItems[id].description
- }
- var monster_gold = function(Id) {
- return $dataEnemies[Id].gold
- }
- var monster_exp = function(Id) {
- return $dataEnemies[Id].exp
- }
- var actor_class_id = function(actorId) {
- return $gameActors.actor(actorId).currentClass().id
- }
- var actor_class_name = function(actorId) {
- return $gameActors.actor(actorId).currentClass().name
- }
- var skill_desc = function(id) {
- return $dataSkills[id].description
- }
- var skill_scope = function(id) {
- return $dataSkills[id].scope
- }
- var skill_scope_n = function(id) {
- var a
- a = skill_scope(id)
- if (a === 0) {return "None"}
- if (a === 1) {return "1 Enemy"}
- if (a === 2) {return "All Enemies"}
- if (a === 3) {return "1 Random Enemy"}
- if (a === 4) {return "2 Random Enemies"}
- if (a === 5) {return "3 Random Enemies"}
- if (a === 6) {return "4 Random Enemies"}
- if (a === 7) {return "1 Ally"}
- if (a === 8) {return "All Allies"}
- if (a === 9) {return "1 Dead Ally"}
- if (a === 10) {return "All Dead Allies"}
- if (a === 11) {return "User"}
- }
- var skill_cost_mp = function(id) {
- return $dataSkills[id].mpCost
- }
- var skill_cost_tp = function(id) {
- return $dataSkills[id].tpCost
- }
- var monster_desc = function(id) {
- return $dataEnemies[id].description
- }
- //100 commands
- var event_in_rect = function(eventId,x1,y1,x2,y2) {
- var a, b, minx, maxx, miny, maxy
- if (eventId === 0) {
- a = player_x();
- b = player_y();
- } else {
- a = event_x(eventId);
- b = event_y(eventId);
- };
- minx = Math.min(x1,x2)
- maxx = Math.max(x1,x2)
- miny = Math.min(y1,y2)
- maxy = Math.max(y1,y2)
- if (a>= minx && a<= maxx && b>=miny && b<= maxy) {
- return true
- } else {
- return false
- }
- }
- var event_in_circle = function(eventId,x,y,radius) {
- var ex, ey
- if (eventId === 0) {
- ex = player_x();
- ey = player_y();
- } else {
- ex = event_x(eventId)
- ey = event_y(eventId)
- }
- if ((ex-x)^2+(ey-y)^2 <= radius^2) {
- return true
- } else {
- return false
- }
- }
- var event_in_polygon = function(eventId,polygon) { // Polygons are defined using an array of their coordinates [[x1,y1],[x2,y2],...[xn,yn]].
- // ray-casting algorithm based on
- // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
- // credit: https://github.com/substack/point-in-polygon MIT license
- var x, y
- if (eventId === 0) {x = player_x(); y = player_y()}
- else {x = event_x(eventId); y = event_y(eventId)}
- var inside = false;
- for (var i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
- var xi = polygon[i][0], yi = polygon[i][1];
- var xj = polygon[j][0], yj = polygon[j][1];
- var intersect = ((yi > y) != (yj > y))
- && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
- if (intersect) inside = !inside;
- }
- return inside;
- }
- var actor_in_party = function(actorId) {
- var list, i
- list = []
- i = 0
- while (i < $gameParty.size()) {
- list.push($gameParty.members()[i].actorId())
- i++
- }
- if (list.contains(actorId)) {
- return true
- } else {
- return false
- }
- }
- var actor_in_party_n = function(actorName) {
- var list, i
- list = []
- i = 0
- while (i < $gameParty.size()) {
- list.push($gameParty.members()[i].name())
- i++
- }
- if (list.contains(actorName)) {
- return true
- } else {
- return false
- }
- }
- var weaponC = function(id,bool) {
- if (bool === undefined) {bool = false}
- return $gameParty.hasItem($dataWeapons[id], bool)
- }
- var armorC = function(id,bool) {
- if (bool === undefined) {bool = false}
- return $gameParty.hasItem($dataArmors[id], bool)
- }
- var actor_armors_type = function(id) {
- var i,list
- i = 0
- list = []
- while (i < $gameActors.actor(id).armors().length) {
- list.push($gameActors.actor(id).armors()[i].atypeId)
- i++
- }
- return list
- }
- var actor_armors_contains = function(actorId, typeId) {
- var list
- list = actor_armors_type(actorId)
- if (list.contains(typeId)) {
- return true
- } else {
- return false
- }
- }
- var actor_weapons_type = function(id) {
- var i,list
- i = 0
- list = []
- while (i < $gameActors.actor(id).weapons().length) {
- list.push($gameActors.actor(id).weapons()[i].wtypeId)
- i++
- }
- return list
- }
- var actor_weapons_contains = function(actorId, typeId) {
- var list
- list = actor_weapons_type(actorId)
- if (list.contains(typeId)) {
- return true
- } else {
- return false
- }
- }
- //V0.32
- var actor_hp = function(id) {
- return $gameActors.actor(id).hp
- }
- var actor_mp = function(id) {
- return $gameActors.actor(id).mp
- }
- var actor_tp = function(id) {
- return $gameActors.actor(id).tp
- }
- var actor_weapons = function(id) {
- var i,list
- i = 0
- list = []
- while (i < $gameActors.actor(id).weapons().length) {
- list.push($gameActors.actor(id).weapons()[i].id)
- i++
- }
- return list
- }
- var actor_armors = function(id) {
- var i,list
- i = 0
- list = []
- while (i < $gameActors.actor(id).armors().length) {
- list.push($gameActors.actor(id).armors()[i].id)
- i++
- }
- return list
- }
- var party_leader = function() {
- return $gameParty.members()[0].actorId()
- }
- var party_leader_n = function(id) {
- return $gameParty.members()[0].name()
- }
- var actor_is_leader = function(id) {
- if (party_leader() === id) {return true} else {return false}
- }
- var event_regionC = function(Id,regionId) {
- if (regionC(event_x(Id),event_y(Id)) === regionId) {
- return true
- } else {
- return false
- }
- }
- //V0.33
- var armor_param = function(id,paramId) {
- return $dataArmors[id].params[paramId]
- }
- var weapon_param = function(id,paramId) {
- return $dataWeapons[id].params[paramId]
- }
- var actor_change_sprite = function(actorId, name, index) {
- $gameActors.actor(actorId).setCharacterImage(name, index);
- $gamePlayer.refresh();
- }
- var actor_change_face = function(actorId, name, index) {
- $gameActors.actor(actorId).setFaceImage(name, index);
- $gamePlayer.refresh();
- }
- var actor_change_battler = function(actorId, name) {
- $gameActors.actor(actorId).setBattlerImage(name);
- $gamePlayer.refresh();
- }
- //In battle functions! Don't call these on any other scene!
- //Enemy indexes start at 0
- var enemy_change_hp = function(enemyIndex, n) {
- $gameTroop.members()[enemyIndex].gainHp(n);
- }
- var enemy_change_mp = function(enemyIndex, n) {
- $gameTroop.members()[enemyIndex].gainMp(n);
- }
- var enemy_change_tp = function(enemyIndex, n) {
- $gameTroop.members()[enemyIndex].gainTp(n)
- }
- var enemy_state_add = function(enemyIndex, n) {
- $gameTroop.members()[enemyIndex].addState(n);
- }
- var enemy_state_remove = function(enemyIndex, n) {
- $gameTroop.members()[enemyIndex].removeState(n)
- }
- var enemy_recover = function(enemyIndex) {
- $gameTroop.members()[enemyIndex].recoverAll();
- }
- var enemy_appear = function(enemyIndex) {
- $gameTroop.members()[enemyIndex].appear();
- }
- var enemy_transform = function(enemyIndex, n) {
- $gameTroop.members()[enemyIndex].transform(n);
- }
- var enemy_anim = function(enemyIndex, animationId, bool, delayN) {
- bool = bool || false
- delayN = delayN || 0
- $gameTroop.members()[enemyIndex].startAnimation(animationId, bool, delayN);
- }
- var turn_count = function() {
- return $gameTroop.turnCount()
- }
- var enemy_collapse = function(enemyIndex) {
- $gameTroop.members()[enemyIndex].performCollapse()
- }
- var enemy_hp = function(enemyIndex) {
- return $gameTroop.members()[enemyIndex]._hp
- }
- var enemy_mp = function(enemyIndex) {
- return $gameTroop.members()[enemyIndex]._mp
- }
- var enemy_tp = function(enemyIndex) {
- return $gameTroop.members()[enemyIndex]._tp
- }
- var enemy_states = function(enemyIndex) {
- return $gameTroop.members()[enemyIndex]._states
- }
- var enemy_stateC = function(enemyIndex, stateIndex) {
- if (enemy_states(enemyIndex).contains(stateIndex)) {return true} else {return false}
- }
- var enemy_xy = function(enemyIndex, x, y) {
- var eI = enemy_sprite_index(enemyIndex)
- if (x === undefined && y === undefined) {
- return [SceneManager._scene._spriteset._enemySprites[eI]._homeX,SceneManager._scene._spriteset._enemySprites[eI]._homeY]
- }
- x = x || SceneManager._scene._spriteset._enemySprites[eI]._homeX;
- y = y || SceneManager._scene._spriteset._enemySprites[eI]._homeY;
- SceneManager._scene._spriteset._enemySprites[eI]._homeX = x;
- SceneManager._scene._spriteset._enemySprites[eI]._homeY = y;
- $gameTroop.members()[enemyIndex]._screenX = x;
- $gameTroop.members()[enemyIndex]._screenY = y;
- }
- var enemy_angle = function(enemyIndex, angle) {
- var eI = enemy_sprite_index(enemyIndex)
- angle = angle || 0
- SceneManager._scene._spriteset._enemySprites[eI].rotation = angle
- }
- /*enemy_alpha = function(enemyIndex, alpha) {
- alpha = alpha || 255
- SceneManager._scene._spriteset._enemySprites[enemyIndex].alpha = alpha
- }*/
- var enemy_scale = function(enemyIndex, x, y) {
- var eI = enemy_sprite_index(enemyIndex)
- x = x || 1
- y = y || 1
- SceneManager._scene._spriteset._enemySprites[eI].scale.x = x
- SceneManager._scene._spriteset._enemySprites[eI].scale.y = y
- }
- var battle_actor_xy = function(index, x, y) {
- if (x === undefined && y === undefined) {
- return [SceneManager._scene._spriteset._actorSprites[index]._homeX,SceneManager._scene._spriteset._actorSprites[index]._homeY]
- }
- x = x || SceneManager._scene._spriteset._actorSprites[index]._homeX
- y = y || SceneManager._scene._spriteset._actorSprites[index]._homeY
- SceneManager._scene._spriteset._actorSprites[index]._homeX = x
- SceneManager._scene._spriteset._actorSprites[index]._homeY = y
- }
- var battle_actor_angle = function(index, angle) {
- angle = angle || 0
- SceneManager._scene._spriteset._actorSprites[index].rotation = angle
- }
- /*battle_actor_alpha = function(index, alpha) {
- alpha = alpha || 255
- SceneManager._scene._spriteset._actorSprites[index].alpha = alpha
- }*/
- var battle_actor_scale = function(index, x, y) {
- x = x || 1
- y = y || 1
- SceneManager._scene._spriteset._actorSprites[index].scale.x = x
- SceneManager._scene._spriteset._actorSprites[index].scale.y = y
- }
- var actor_caster = function() {
- var list, i
- list = []
- i = 0
- while (i < $gameParty.size()) {
- list.push($gameParty.members()[i].actorId())
- i++
- }
- return list.indexOf(BattleManager._subject._actorId)
- }
- var actor_target = function() {
- return BattleManager._action._targetIndex
- }
- var actor_last_skill = function() {
- return BattleManager._subject._lastBattleSkill._itemId
- }
- var actor_last_menu_skill = function(actorId) {
- return $gameParty.members()[actorId]._itemId
- }
- //V0.4
- var party_last_item = function() {
- return $gameParty._lastItem._itemId
- }
- var actor_item_target = function() {
- return $gameParty._targetActorId
- }
- var texts = function(id,text,align) { //arrays: [[x,y,text],[x2,y2,text2],...,[xn,yn,textn]]
- align = align || "left"
- var a = text.length
- var i = 0
- var rid = $gameScreen.realPictureId(id)
- var pS = SceneManager._scene._spriteset._pictureContainer.children[rid-1]
- if (!pS.bitmap) {pS.bitmap = new Bitmap(816, 624)}
- $gameScreen.showPicture(id, '', 0, 0, 0, 100,100, 255, 0);
- pS.bitmap.clear();
- while (i < a) {
- pS.bitmap.drawText(text[i][2],text[i][0], text[i][1],816, 48, align);
- i++
- }
- }
- var flash_square = function(id,arrayR,arrayG,arrayB,opacity,border,blendMode) { //arrays: [[x1,y1],[x2,y2],...,[xn,yn]]
- var i, narrayR, narrayG, narrayB;
- blendMode = blendMode || 0;
- opacity = opacity || 255;
- arrayR = arrayR || [];
- arrayB = arrayB || [];
- arrayG = arrayG || [];
- border = border || 0;
- var rid = $gameScreen.realPictureId(id);
- var pS = SceneManager._scene._spriteset._pictureContainer.children[rid-1];
- narrayB = [];
- narrayR = [];
- narrayG = [];
- i = 0;
- while (i<arrayB.length) {
- narrayB.push([arrayB[i][0]*48,arrayB[i][1]*48]);
- i++;
- };
- i = 0;
- while (i<arrayG.length) {
- narrayG.push([arrayG[i][0]*48,arrayG[i][1]*48]);
- i++;
- };
- i = 0;
- while (i<arrayR.length) {
- narrayR.push([arrayR[i][0]*48,arrayR[i][1]*48]);
- i++;
- };
- if (!pS.bitmap) {pS.bitmap = new Bitmap(816, 624)}
- $gameScreen.showPicture(id, '', 0, 0, 0, 100,100, opacity, blendMode);
- pS.bitmap.clear();
- if (arrayR !== []) {
- i = 0
- while (i<narrayR.length) {
- pS.bitmap.fillRect(narrayR[i][0]+border,narrayR[i][1]+border,48-border,48-border,'red');
- i++
- }
- }
- if (arrayG !== []) {
- i = 0
- while (i<narrayG.length) {
- pS.bitmap.fillRect(narrayG[i][0]+border,narrayG[i][1]+border,48-border,48-border,'green');
- i++
- }
- }
- if (arrayB !== []) {
- i = 0
- while (i<narrayB.length) {
- pS.bitmap.fillRect(narrayB[i][0]+border,narrayB[i][1]+border,48-border,48-border,'blue');
- i++;
- }
- }
- }
- var region_distance = function(x1,y1,x2,y2) {
- return distance(x1,y1,x2,y2) + Math.abs(regionC(x1,y1)-regionC(x2,y2))
- }
- var actor_name = function(id) {
- return $gameActors.actor(id).name()
- }
- var event_direction = function(id,direction) {
- if (direction === undefined) {
- if (id === 0) {
- return $gamePlayer._direction
- } else {
- return $gameMap._events[id]._direction
- }
- } else {
- if (id === 0) {
- $gamePlayer._direction = direction
- } else {
- $gameMap._events[id]._direction = direction
- }
- }
- }
- var event_movetype = function(id,type) {
- if (type === undefined) {
- return $gameMap._events[id]._moveType
- } else {
- $gameMap._events[id]._moveType = type
- }
- }
- var event_opacity = function(id,opacity) {
- if (opacity === undefined) {
- if (id === 0) {
- return $gamePlayer._opacity
- } else {
- return $gameMap._events[id]._opacity
- }
- } else {
- if (id === 0) {
- $gamePlayer._opacity = opacity
- } else {
- $gameMap._events[id]._opacity = opacity
- }
- }
- }
- var party_order = function(slot, id) {
- $gameParty.swapOrder(slot,$gameParty.members().indexOf($gameActors.actor(id)))
- }
- //V0.50
- var actor_sprite = function(id) {
- return [$dataActors[id].characterName,$dataActors[id].characterIndex]
- }
- var event_sprite = function(id,name,index) {
- if (name === undefined && index === undefined) {
- return [$gameMap._events[id]._characterName,$gameMap._events[id]._characterIndex]
- }
- $gameMap._events[id]._characterName = name
- $gameMap._events[id]._characterIndex = index
- }
- var party_swap = function(id1,id2) {
- $gameParty.swapOrder($gameParty.members().indexOf($gameActors.actor(id1)),$gameParty.members().indexOf($gameActors.actor(id2)))
- }
- var rm_kill = function() {
- SceneManager.terminate()
- }
- var actor_states = function(id) {
- return $gameActors.actor(id)._states;
- }
- var actor_stateC = function (id, stateId) {
- return $gameActors.actor(id).isStateAffected(stateId);
- }
- //V0.6
- var actor_caster_id = function() {
- return BattleManager._subject._actorId
- }
- var get_event_by_id = function(id) {
- var i = 0;
- var e = $gameMap.events();
- while (i < e.length) {
- if (e[i]._eventId === id) {
- return $gameMap.events()[i];
- }
- i++;
- }
- }
- 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.
- var eS = SceneManager._scene._spriteset._enemySprites;
- var eT = $gameTroop.members();
- var i = 0;
- while (i < eS.length) {
- if (eT[id]._screenX === eS[i]._homeX && eT[id]._screenY === eS[i]._homeY) {
- return i;
- }
- i++;
- }
- }
- var party_member_Id = function(index) {
- return $gameParty.members()[index]._actorId
- }
- var party_member_name = function(index) {
- return $gameParty.members()[index]._name;
- }
- var next_encounter = function() {
- return $gamePlayer._encounterCount;
- }
- var map_Id = function() {
- return $gameMap.mapId();
- }
- var zoom = function(x,y,scale,duration) {
- $gameScreen.startZoom(x, y, scale, duration);
- }
- var shake = function(power, speed, duration) {
- $gameScreen.startShake(power, speed, duration)
- }
- var enemy_Id = function(index) {
- return $gameTroop.members()[index]._enemyId
- }
- var clear_zoom = function() {
- $gameScreen.clearZoom()
- }
- var clear_weather = function() {
- $gameScreen.clearWeather()
- }
- var clear_shake = function() {
- $gameScreen.clearShake()
- }
- var rgb = function(r,g,b) {
- return Utils.rgbToCssColor(r,g,b)
- }
- //From this part on it's not functions from the editor but functions to simplify math
- var max_ar_index = function(arr) {
- var max, maxIndex, i
- if (arr.length === 0) {
- return -1;
- }
- max = arr[0];
- maxIndex = 0;
- i=1;
- while (i<arr.length) {
- if (arr[i] > max) {
- maxIndex=i;
- max = arr[i];
- }
- i++;
- }
- return maxIndex;
- }
- var min_ar_index = function(arr) {
- var min, minIndex
- if (arr.length === 0) {
- return -1;
- }
- min = arr[0];
- minIndex = 0;
- for (var i = 1; i < arr.length; i++) {
- if (arr[i] < min) {
- minIndex = i;
- min = arr[i];
- }
- }
- return minIndex;
- }
- var ar_all_equal = function(arr) {
- var i, a;
- i = 0;
- a = arr[0];
- if (arr.length === 0) {return -1};
- while (i < arr.length) {
- if (arr[i] === a) { i++; if (i===arr.length){return true; break} }
- else {return false; break}
- }
- }
- var ar_sum = function(arr) {
- var total = 0;
- var i = arr.length;
- while (i--) {
- total += arr[i];
- }
- return total;
- }
- var abs = function(v1) {
- return Math.abs(v1)
- }
- var min = function(v1,v2) {
- return Math.min(v1,v2)
- }
- var max = function(v1,v2) {
- return Math.max(v1,v2)
- }
- var rand = function(min,max) {
- return Math.floor(Math.random() * (max - min + 1)) + min;
- }
- var percent = function(x,max) {
- return Math.floor((x /max) * 100)
- }
- var distance = function(x1,y1,x2,y2) {
- return Math.abs(x1-x2) + Math.abs(y1-y2)
- }
- //9 commands
- //Test commands
- /*var mouseX = function() {
- return TouchInput.mouseX
- }*/
- /*var mouseY = function() {
- return TouchInput.mouseY
- }*/
- /*var mouse_over_event = function(eventId) {
- if (mouseX() > (event_x(eventId)*48) && mouseX() < ((event_x(eventId)+1)*48) && mouseY() > (event_y(eventId)*48) && mouseY() < ((event_y(eventId)+1)*48)) {
- return true
- } else {
- return false
- }
- }*/
- /*var mouse_in_rect = function(x1,y1,x2,y2) {
- var a, b, minx, maxx, miny, maxy
- a = mouseX();
- b = mouseY()
- minx = Math.min(x1,x2)
- maxx = Math.max(x1,x2)
- miny = Math.min(y1,y2)
- maxy = Math.max(y1,y2)
- if (a>= minx && a<= maxx && b>=miny && b<= maxy) {
- return true
- } else {
- return false
- }
- }*/
- /*var mouse_click_event = function(id) {
- if (TouchInput.isPressed() && mouse_over_event(id)) {
- return true;
- } else {
- return false;
- }
- }*/
- /*var mouse_click_rect = function(rect) {
- var a = Astfgl_Rects[rect]
- if (mouse_in_rect(a[0],a[1],a[2],a[3]) && TouchInput.isPressed() ) {
- return true;
- } else {
- return false;
- }
- }*/
- /*var rect = function(id,x1,y1,x2,y2) {
- Astfgl_Rects[id] = [x1,y1,x2,y2];
- }*/
- //Window Related commands
- var window_add = function(id,x,y,width,height) {
- var win;
- win = new Window_Base(eval(x),eval(y),1000,1000);
- Astfgl_Windows[id] = win;
- SceneManager._scene.addChild(win);
- win._commands = [];
- win._commands.push([-1,id,x,y,width,height]);
- window_size(id,eval(width),eval(height));
- }
- var window_remove = function(id) {
- SceneManager._scene.removeChild(Astfgl_Windows[id]);
- }
- var window_text = function(id,x,y,txt,maxwidth,align) {
- align = align || "left";
- maxwidth = maxwidth || Astfgl_Windows[id].width;
- Astfgl_Windows[id]._windowContentsSprite.bitmap.drawText(eval(txt),eval(x),eval(y),eval(maxwidth),48,align);
- Astfgl_Windows[id]._commands.push([0,id,x,y,txt,maxwidth,align])
- }
- var window_move = function(id,x,y) {
- if (x === undefined && y === undefined) {
- return [Astfgl_Windows[id].x,Astfgl_Windows[id].y];
- }
- Astfgl_Windows[id].x = eval(x);
- Astfgl_Windows[id].y = eval(y);
- Astfgl_Windows[id]._commands.push([1,id,x,y]);
- }
- var window_size = function(id,width,height) {
- if (width === undefined && height === undefined) {
- return [Astfgl_Windows[id].width,Astfgl_Windows[id].height];
- }
- Astfgl_Windows[id].width = eval(width);
- Astfgl_Windows[id].height = eval(height);
- Astfgl_Windows[id]._commands.push([2,id,width,height]);
- }
- var window_opacity = function(id,a) {
- if (a === undefined) {
- return Astfgl_Windows[id].opacity;
- }
- Astfgl_Windows[id].opacity = eval(a);
- Astfgl_Windows[id]._commands.push([3,id,a]);
- }
- var window_color = function(id,x,y,color) {
- Astfgl_Windows[id]._windowContentsSprite.bitmap.fillRect (eval(x), eval(y), 48, 48, color);
- Astfgl_Windows[id]._commands.push([4,id,x,y,color]);
- }
- var window_icon = function(id,x,y,iconId) {
- Astfgl_Windows[id].drawIcon(eval(iconId), eval(x), eval(y));
- Astfgl_Windows[id]._commands.push([5,id,x,y,iconId]);
- }
- var window_face = function(id,x,y,faceName,index,width,height) {
- width = width || Astfgl_Windows[id].width;
- height = height || Astfgl_Windows[id].height;
- Astfgl_Windows[id].drawFace(eval(faceName) ,eval(index) ,eval(x) ,eval(y) ,eval(width) ,eval(height));
- Astfgl_Windows[id]._commands.push([6,id,x,y,faceName,index,width,height]);
- }
- var window_gauge = function(id,paramMin,paramMax,x,y,width,height,color1,color2,color3) {
- color1 = color1 || "blue";
- color2 = color2 || "blue";
- color3 = color3 || "black";
- paramMin = paramMin || 50;
- paramMax = paramMax || 100;
- width = width || Astfgl_Windows[id].width;
- height = height || Astfgl_Windows[id].height;
- var rate = eval(paramMin)/eval(paramMax);
- var fillW = Math.floor(eval(width) * rate);
- Astfgl_Windows[id]._windowContentsSprite.bitmap.fillRect(eval(x), eval(y), eval(width), eval(height), color3);
- Astfgl_Windows[id]._windowContentsSprite.bitmap.gradientFillRect(eval(x), eval(y), eval(fillW), eval(height), color1, color2);
- Astfgl_Windows[id]._commands.push([7,id,paramMin,paramMax,x,y,width,height,color1,color2,color3]);
- }
- var window_text_color = function(id,color) {
- Astfgl_Windows[id].changeTextColor(color);
- Astfgl_Windows[id]._commands.push([8,id,color]);
- }
- var window_show = function(id) {
- Astfgl_Windows[id].show();
- }
- var window_hide = function(id) {
- Astfgl_Windows[id].hide();
- }
- var window_fill = function(id,color) {
- var width = Astfgl_Windows[id].width;
- var height = Astfgl_Windows[id].height;
- Astfgl_Windows[id]._windowContentsSprite.bitmap.fillRect(0, 0, width, height, color);
- Astfgl_Windows[id]._commands.push([9,id,color]);
- }
- var window_fontsize = function(id,size) {
- size = size || 28;
- Astfgl_Windows[id].contents.fontSize = eval(size);
- Astfgl_Windows[id]._commands.push([10,id,size]);
- }
- var window_contents_opacity = function(id,n,bool) {
- n = n || 255;
- Astfgl_Windows[id]._commands.push([11,id,n]);
- if (eval(n) <= 0) {n = 1};
- Astfgl_Windows[id]._windowContentsSprite.opacity = eval(n);
- }
- var window_update = function(id) {
- var i = 0;
- window_remove(id);
- var commandList = Astfgl_Windows[id]._commands
- for (i = 0; i < commandList.length; i++) {
- var a = commandList[i]
- switch (commandList[i][0]) {
- case -1:
- window_add(a[1],a[2],a[3],a[4],a[5],a[6]);
- break;
- case 0:
- window_text(a[1],a[2],a[3],a[4],a[5],a[6]);
- break;
- case 1:
- window_move(a[1],a[2],a[3]);
- break;
- case 2:
- window_size(a[1],a[2],a[3]);
- break;
- case 3:
- window_opacity(a[1],a[2]);
- break;
- case 4:
- window_color(a[1],a[2],a[3],a[4]);
- break;
- case 5:
- window_icon(a[1],a[2],a[3],a[4]);
- break;
- case 6:
- window_face(a[1],a[2],a[3],a[4],a[5],a[6],a[7]);
- break;
- case 7:
- window_gauge(a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10]);
- break;
- case 8:
- window_text_color(a[1],a[2]);
- break;
- case 9:
- window_fill(a[1],a[2]);
- break;
- case 10:
- window_fontsize(a[1],a[2]);
- break;
- case 11:
- window_contents_opacity(a[1],a[2]);
- break;
- default:
- console.log("improper command")
- break;
- }
- }
- }
- var window_exists = function(id) {
- if (Astfgl_Windows[id]) {
- return true;
- } else {
- return false;
- }
- }
- var window_update_all = function() {
- var i = 0;
- var a = Astfgl_Windows.length
- for (i=0; i < a; i++) {
- if (window_exists(i)) {
- window_update(i);
- }
- }
- }
- eval(script);
- return true;
- };
- Astfgl_Windows = [];
- //Astfgl_Rects = []
- // 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
- //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
- 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]
- };
- // Game interpreter modifications: creating the jump to label script call
- Game_Interpreter.prototype.jump_to_label = function(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;
- }
- //Touch input modifications
- /*var alias_Astfgl_TIOMM = TouchInput._onMouseMove
- TouchInput._onMouseMove = function(event) {
- alias_Astfgl_TIOMM.call(this);
- var x = Graphics.pageToCanvasX(event.pageX);
- var y = Graphics.pageToCanvasY(event.pageY);
- this.mouseX = x
- this.mouseY = y
- }*/
- })(); // dont touch this.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement