Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
//============================================================================= // Maliki's Random Encounter Step Options // MalEncounterRateOptions.js // version 1.7 //============================================================================= /*: * @plugindesc ver1.6a - Allows players to set a general random encounter rate in the Options Menu. * @author Maliki79 * * @param RateUpperLimit * @desc The highest percentage the Encounter Rate can reach. This number MUST be at or above 100. * Default: 100 * @default 100 * * @param RateLowerLimit * @desc The lowest percentage the Encounter Rate can reach. This number MUST be at or below 100. * Default: 0 * @default 0 * * @param EncounterOffset * @desc The value that the Encounter Rate will change when a direction or ok is pressed. * Default: 50 * @default 50 * * @param EncounterRateShow * @desc Forces Encounter rate to be shown in Options even when locked. 0 = true 1 = false * Default: 0 * @default 0 * * @param EncounterSpeed * @desc Enter an Interger higher than 0 to allow encounters to occur even when standing still. * Default: 0 * @default 0 * * @help Allows players to set a general random encounter rate in the Options Menu. * This rate can be reduced to 0 to eliminate ALL random encounters. * Also allows developers to lock/unlock the encounter rate directly and set * values to whatever they want. * * Once installed, run your game and go to Options to find the * Encounter Rate setting. (If EncounterRateShow is NOT set to 0, the encounter rate will NOT appear * on the Title Screen's Option Menu as the rate is considered locked when on the Title Screen.) * * Optional: You can set the Upper limit of the Encounter rate to any number over 100. * If set below, or to a non-number, it will default to 100. * * Optional: You can set the amount the Encounter Rate rises or falls via the Encounter Offset Param. * * You can set a timer to allow encounters while standing still. * If the param EncounterSpeed is set to a number higher than 0, encounters will be able to occur * even while players are not moving! * Increasing the number will speed up the enocounter rate. * Leaving it at 0 will disable this option. * (Other encounter rate option will still be in effect) * * This plugin now also allows you to adjust the "weight" of random encounters by enemy troop Id. * In map notes, you can add the notetag: * * <malEncAdj: troopId, amount, condition >>> * with troopId being the troop Id number in the database, * amount being the amount the weight will be adjusted (this can be negative, but it must be an integer.) * and condition can be a javascript eval that returns true or false. * (And note the 3 >>> at the end of the tag.) * * For example, the tag <malEncAdj: 1, 10, $gameSwitches.value(1)>>> * will increase the weight of all instances of troop one on that map by 10 if switch 1 is turned ON. * * <malEncAdj: 4, -25, $gameVariables.value(1) > 10>>> * will decrease the weight of all instances of troop 4 on that map by 25 if variable 1 is greater than 10. * * <malEncAdj: 7, $gameVariables.value(2) * 5, $gameVariables.value(2) > 0>>> * will increase the weight of all instances of troop 7 on that map by 5 * variable 2 if variable 2 is greater than 0. * * If you set the troop ID to -1, it will affect ALL troops on that map if the conditions are met. * * weights are cumulative, meaning you could potentially have a troop affected by multiple tages. * Note that any weight values that change to a value below 0 will NOT be encountered at all. * Conversely, any troops initially set to 0 in the database but brought above 1 or higher CAN be encountered. * (You can eval weight to an integer) * * <malNulRegionEnc: regionID, condition >>> * with region ID being the region ID of the tile the player is standing on. * (Using -1 will effect ALL regions AND regionless areas (basically the entire map) * * This note tag will REMOVE ALL encounters on the specified region ID on that map if the conditions are true. * * Note that this tag supersides the malEncAdj tag meaning if you negate all encounters, their weight will hot matter. * * SCRIPT CALLS * * $gameSystem.lockEncounterRate(); * This call will LOCK the Encounter Rate setting at whatever number it was when called. * You can add a number in the () to set the rate while locking it. * Note: Unless EncounterRateShow is set to 0, the Encounter Rate will not show on the Option * Menu while locked. * * $gameSystem.unlockEncounterRate(); * This call will allow players to change the Encounter Rate again after it hs been locked. * You can add a number in the () to set the rate while unlocking it. * * $gameSystem.setEncounterRate(x); * This call will change the Encounter Rate to any positive integer. * Note that the player can change the number if the Encounter Rate is not locked. * * $gameSystem.getEncounterRate(); * This call will return the current Encounter Rate. */ ConfigManager.commandEncounter = 100; var MalEncounterTitle = Scene_Title.prototype.create; Scene_Title.prototype.create = function() { MalEncounterTitle.call(this); $gameSystem._encountersLocked = true; } var MalEncounterInitialize = Game_System.prototype.initialize; Game_System.prototype.initialize = function() { MalEncounterInitialize.call(this); this._encountersLocked = false; } Game_System.prototype.lockEncounterRate = function(setting) { $gameSystem._encountersLocked = true; if (setting) this.setEncounterRate(setting); } Game_System.prototype.unlockEncounterRate = function(setting) { $gameSystem._encountersLocked = false; if (setting) this.setEncounterRate(setting); } Game_System.prototype.getEncounterRate = function() { return $gameSystem._encounterRate; } Game_System.prototype.setEncounterRate = function(setting) { var numb = Number(eval(setting)) || 100; if (numb < 0) numb = 0; ConfigManager['commandEncounterVolume'] = numb; $gameSystem._encounterRate = numb; } Object.defineProperty(ConfigManager, 'encounterRate', { get: function() { return ConfigManager.commandEncounterVolume; }, set: function(value) { ConfigManager.commandEncounterVolume = value; }, configurable: true }); var Mal_Config_MakeData = ConfigManager.makeData; ConfigManager.makeData = function() { var config = Mal_Config_MakeData.call(this); config.encounterRate = this.encounterRate; return config; }; var Mal_Config_applyData = ConfigManager.applyData; ConfigManager.applyData = function(config) { Mal_Config_applyData.call(this, config); this.encounterRate = this.readEncounter(config, 'encounterRate'); }; ConfigManager.readEncounter = function(config, name) { var value = config[name]; if (value !== undefined) { return Number(value); } else { return 100; } }; Window_Options.prototype.encounterOffset = function() { var num = Number(PluginManager.parameters('MalEncounterRateOptions')['EncounterOffset']) || 50; if (num !== undefined) { return Math.floor(num); } else { return 50; } }; var Mal_Window_addGeneralOptions = Window_Options.prototype.addGeneralOptions; Window_Options.prototype.addGeneralOptions = function() { Mal_Window_addGeneralOptions.call(this); if (PluginManager.parameters('MalEncounterRateOptions')['EncounterRateShow'] == 0 || $gameSystem._encountersLocked == false ) this.addCommand("Encounter Rate", 'commandEncounterVolume'); }; Game_Player.prototype.encounterProgressValue = function() { var value = $gameMap.isBush(this.x, this.y) ? 2 : 1; var val2 = ConfigManager.encounterRate; if ($gameParty.hasEncounterHalf()) { value *= 0.5; } if (this.isInShip()) { value *= 0.5; } return value * (val2 / 100.0); }; ConfigManager.readEncounter = function(config, name) { var value = config[name]; var limit = Number(PluginManager.parameters('MalEncounterRateOptions')['RateUpperLimit']); var lowLimit = Number(PluginManager.parameters('MalEncounterRateOptions')['RateLowerLimit']); if (limit < 100) limit = 100; if (lowLimit < 0) lowLimit = 0; if (value !== undefined) { return Number(value).clamp(lowLimit, limit); } else { return 100; } }; Window_Options.prototype.isEncounterSymbol = function(symbol) { return symbol.contains('Encounter'); }; var Mal_Win_Options_processOk = Window_Options.prototype.processOk Window_Options.prototype.processOk = function() { var index = this.index(); var symbol = this.commandSymbol(index); if (this.isEncounterSymbol(symbol) ) { var value = this.getConfigValue(symbol); var offset = this.encounterOffset(); var limit = Math.floor(Number(PluginManager.parameters('MalEncounterRateOptions')['RateUpperLimit'])) || 100; var lowLimit = Math.floor(Number(PluginManager.parameters('MalEncounterRateOptions')['RateLowerLimit'])) || 0; if (limit < 100) limit = 100; if ($gameSystem._encountersLocked == false){ if (value + offset > limit && value != limit) { value = limit; } else { value += offset; } if (value > limit) value = lowLimit; this.changeValue(symbol, value); $gameSystem._encounterRate = value; } else { SoundManager.playBuzzer(); } } else { Mal_Win_Options_processOk.call(this); } }; var Mal_Win_Options_cursorRight = Window_Options.prototype.cursorRight Window_Options.prototype.cursorRight = function(wrap) { var index = this.index(); var symbol = this.commandSymbol(index); if (this.isEncounterSymbol(symbol)) { var value = this.getConfigValue(symbol); var offset = this.encounterOffset(); var limit = Math.floor(Number(PluginManager.parameters('MalEncounterRateOptions')['RateUpperLimit'])) || 100; var lowLimit = Math.floor(Number(PluginManager.parameters('MalEncounterRateOptions')['RateLowerLimit'])) || 0; if (limit < 100) limit = 100; if ($gameSystem._encountersLocked == false){ if (value + offset > limit && value != limit) { value = limit; } else { value += offset; } if (value > limit) value = lowLimit; this.changeValue(symbol, value); $gameSystem._encounterRate = value; } else { SoundManager.playBuzzer(); } } else { Mal_Win_Options_cursorRight.call(this, wrap); } }; var Mal_Win_Options_cursorLeft = Window_Options.prototype.cursorLeft Window_Options.prototype.cursorLeft = function(wrap) { var index = this.index(); var symbol = this.commandSymbol(index); if (this.isEncounterSymbol(symbol)) { var value = this.getConfigValue(symbol); var offset = this.encounterOffset(); var limit = Math.floor(Number(PluginManager.parameters('MalEncounterRateOptions')['RateUpperLimit'])) || 100; var lowLimit = Math.floor(Number(PluginManager.parameters('MalEncounterRateOptions')['RateLowerLimit'])) || 0; if (limit < 100) limit = 100; if ($gameSystem._encountersLocked == false){ if (value - offset < lowLimit && value != lowLimit) { value = lowLimit; } else { value -= offset; } if (value < lowLimit) value = limit; this.changeValue(symbol, value); $gameSystem._encounterRate = value; } else { SoundManager.playBuzzer(); } } else { Mal_Win_Options_cursorLeft.call(this, wrap); } }; var MalEncounter_onLoadSuccess = Scene_Load.prototype.onLoadSuccess; Scene_Load.prototype.onLoadSuccess = function() { MalEncounter_onLoadSuccess.call(this); ConfigManager['commandEncounterVolume'] = $gameSystem._encounterRate || 100; //$gamePlayer.encounterTick = 0; } //var MalEncounter_updateNonmoving = Game_Player.prototype.updateNonmoving; Game_Player.prototype.updateNonmoving = function(wasMoving) { if (!$gamePlayer.encounterTick) $gamePlayer.encounterTick = 0; if (!$gameMap.isEventRunning()) { if (wasMoving) { $gameParty.onPlayerWalk(); this._firstStep = false; this.checkEventTriggerHere([1,2]); if ($gameMap.setupStartingEvent()) { return; } } if (this.triggerAction()) { return; } if ($gamePlayer.encounterTick >= 1000) { this.updateEncounterCount(); $gamePlayer.encounterTick = 0; } else { if(!this._firstStep) $gamePlayer.encounterTick += 1 * Math.floor(Number(PluginManager.parameters('MalEncounterRateOptions')['EncounterSpeed'])); //console.log($gamePlayer.encounterTick); } if (wasMoving) { this.updateEncounterCount(); } else { $gameTemp.clearDestination(); } } }; var MalEncounterCount = Game_Player.prototype.makeEncounterCount; Game_Player.prototype.makeEncounterCount = function() { MalEncounterCount.call(this); if(PluginManager.parameters('MalEncounterRateOptions')['EncounterSpeed'] != 0) this._encounterCount += 3; this._firstStep = true; }; var malEncounterGMSetup = Game_Map.prototype.setup; Game_Map.prototype.setup = function(mapId) { if (!$dataMap) { throw new Error('The map data is not available'); } malEncounterGMSetup.call(this, mapId); this.setupEncounterAdjusts(); }; Game_Map.prototype.setupEncounterAdjusts = function() { this._encounterAdjusts = []; this._regionCond = []; var noteread = $dataMap.note; while(noteread.indexOf("malEncAdj") > -1) { var notereg = noteread.split("<malEncAdj: "); var match = notereg[1].split(">>>"); match = match[0].split(", "); match[0] = parseInt(match[0]); //match[1] = parseInt(match[1]); this._encounterAdjusts.push(match); noteread = noteread.replace("<malEncAdj: ", " "); } var noteread = $dataMap.note; while(noteread.indexOf("malNulRegionEnc") > -1) { var notereg = noteread.split("<malNulRegionEnc: "); var match = notereg[1].split(">>>"); var match2 = match[0].split(","); match2[0] = Number(match2[0]); this._regionCond.push(match2); noteread = noteread.replace("<malNulRegionEnc: ", " "); } }; Game_Player.prototype.makeEncounterTroopId = function() { var encounterList = []; var weightSum = 0; $gameMap.encounterList().forEach(function(encounter) { if (this.meetsEncounterConditions(encounter)) { var encounterCopy = encounter; encounterCopy = this.malEncounterAdjust(encounterCopy); if (encounterCopy.weight > 0) { encounterList.push(encounterCopy); weightSum += encounterCopy.weight; } } }, this); if (weightSum > 0) { var value = Math.randomInt(weightSum); for (var i = 0; i < encounterList.length; i++) { value -= encounterList[i].weight; if (value < 0) { return encounterList[i].troopId; } } } return 0; }; Game_Player.prototype.malEncounterAdjust = function (encounter) { var ec = encounter; var id = ec.troopId; var ea = $gameMap._encounterAdjusts; for (var i = 0; i < ea.length; i++) { var line = ea[i]; var value = Number(eval(line[1])) || 0; var check = eval(line[2]); if ((line[0] == id || line[0] == -1) && check) ec.weight += value; } return ec; } var MalGPMeetsEncCond = Game_Player.prototype.meetsEncounterConditions Game_Player.prototype.meetsEncounterConditions = function(encounter) { if ($gameMap.nulRegion(this.regionId())) return false; return MalGPMeetsEncCond.call(this, encounter); }; Game_Map.prototype.nulRegion = function(region) { if (this._regionCond.length < 1) return false; var region = Number(region); for (var i = 0; i < this._regionCond.length; i++) { if ((this._regionCond[i][0] == region || this._regionCond[i][0] == -1) && eval(this._regionCond[i][1])) return true; } return false; };
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Die 7 wichtigsten Aktionen diese Woche
7 hours ago | 4.17 KB
Untitled
8 hours ago | 13.34 KB
Untitled
9 hours ago | 13.59 KB
VNC SCRIPT 2/2: autoinput.vbs
VBScript | 18 hours ago | 0.23 KB
VNC SCRIPT 1/2: vncauto.bat
Batch | 18 hours ago | 0.72 KB
videoscheomedia
XML | 21 hours ago | 1.00 KB
Untitled
1 day ago | 14.91 KB
autconnectVNC.bat
Batch | 1 day ago | 0.93 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!