├── LICENSE ├── README.md ├── SnowGather ├── SnowGather.js └── SnowGather.v1.js └── SnowQuest ├── Quests.json └── SnowQuest.js /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Kyle Donaldson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SnowMV 2 | A collection of scripts I've created for RPG Maker MV 3 | 4 | -------------------------------------------------------------------------------- /SnowGather/SnowGather.js: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | // SnowMV - Simple Gathering 3 | // SnowGather.v2.js 4 | // Version: 2.3.1 5 | //============================================================================= 6 | 7 | "use strict"; 8 | 9 | PluginManager.register("SnowGather", "2.3.2", { 10 | "email": "", 11 | "website": "", 12 | "name": "Sn0wCrack" 13 | }, "2018-10-28") 14 | 15 | //============================================================================= 16 | /*: 17 | * @plugindesc A simple way to manage "gathering" type events. 18 | * @author Sn0wCrack 19 | * 20 | * @param Successful Harvest Message 21 | * @desc Message to display upon sucessful harvest, %1 is the amount, %2 is the item name 22 | * @default You gathered %1 %2. 23 | * 24 | * @param Unsuccessful Harvest Message 25 | * @desc Message to display upon failing to harvest items 26 | * @default Failed to harvest any resources. 27 | * 28 | * @param Item Broken Message 29 | * @desc Message to display when an item breaks upon harvesting, %1 is the item name 30 | * @default Your %1 broke while harvesting! 31 | * 32 | * @param Incorrect Tools Message 33 | * @desc Message to display when you don't have the right tools 34 | * @default You don't have any tools that can be used here. 35 | * 36 | * @param Select Tool Message 37 | * @desc Help window message you want to display when player is selecting a tool 38 | * @default Please select the tool you wish to use 39 | * 40 | * @param Hand Tool ID 41 | * @desc The item ID of the tool that will be used as your hand 42 | * @default 10 43 | * 44 | * @param Hand Tool Last 45 | * @desc Do you want the hand tool to appear first or last in the items list. true = yes, false = no 46 | * @default false 47 | * 48 | * @param Respawning Events 49 | * @desc Override the default option when having a time system installed, true = ON, false = OFF 50 | * @default true 51 | * 52 | * @param Manual Self Switches 53 | * @desc If you wish to manually set self switches in your event for despawning them, true = ON, false = OFF 54 | * @default false 55 | * 56 | * @param Last Result Store 57 | * @desc If you want to store the last result of a harvest as a variable, true = ON, false = OFF 58 | * @default true 59 | * 60 | * @param Last Result Variable ID 61 | * @desc The variable to store the last result in, 0 = success, 1 = failure, 2 = incorrect tools 62 | * @default 1 63 | * 64 | * @help 65 | * ============================================================================ 66 | * Introduction 67 | * ============================================================================ 68 | * 69 | * Welcome to the Simple Gathering System by Sn0wCrack, this script allows you 70 | * to create gathering events in which you players to search for resources using 71 | * tools (or not if you want!) 72 | * 73 | * Please see https://github.com/Sn0wCrack/SnowMV/blob/master/LICENSE for license 74 | * details. 75 | * 76 | * If you use this script, please give credit! 77 | * 78 | * ============================================================================ 79 | * Setup 80 | * ============================================================================ 81 | * In your items database you can tag any item (this means only normal items, 82 | * not weapons, armour, etc.) with the following tags: 83 | * 84 | * Havesting Tools: 85 | * THESE ARE PUT ON THE ITEMS YOU WANT TO USE TO HARVEST WITH IN THE NOTE TAG SECTION 86 | * 87 | * - Not Required 88 | * This tag allows you to set an amount this particular item will boost 89 | * the chances of you finding items. 90 | * 91 | * 92 | * itemId: percentage% 93 | * 94 | * 95 | * You can set the chance for harvesting different materials for an item 96 | * by something like this: 97 | * 98 | * 7: 100% 99 | * 8: 10% 100 | * 101 | * 102 | * 103 | * 104 | * 105 | * Same as above however the values are how often the item will break when 106 | * trying to harvest the resource. 107 | * 108 | * Harvestables: 109 | * THESE ARE PUT ON THE ITEMS YOU WANT TO BE GATHERED IN THE NOTE TAG SECTION 110 | * 111 | * - Required 112 | * The minimum amount of the item to be found upon the successful harvesting of 113 | * it. 114 | * 115 | * - Required 116 | * The maximum amount of the item to be found upon the successful harvesting of 117 | * it. 118 | * 119 | * Events: 120 | * THESE ARE PUT ON EVENTS (in the event editor page) YOU WANT TO RESPAWN IN THE NOTE TAG SECTION 121 | * 122 | * - Required if you want respawing events (Requires OrangeTimeSystem) 123 | * Sets how long in hours you want the event to respawn in 124 | * 125 | * ============================================================================ 126 | * Usage 127 | * ============================================================================ 128 | * To call the script, create an event with a plugin command 129 | * SnowGather require tools [recieveable item ids] commonEventId this 130 | * 131 | * Replace require tools with true if you want the player to need tools to gather 132 | * items at this event, or false if you don't want them to use any tools on this 133 | * particular event spot. 134 | * 135 | * Recievable item ids is an array that you replace with something like [7,8] 136 | * please note how there are not spaces in this, keep it this way or it will not 137 | * function correctly. This sets the items taht you can get from this event. 138 | * 139 | * commonEventId is the id of the common event you want to run after selecting a tool 140 | * to harvest with. You may ignore this if you don't want to use it. 141 | * 142 | * this is well, always the word this, this is only required if you're using 143 | * a time system. 144 | * 145 | * Repsawning Events: 146 | * 147 | * In order for an event to actually despawn and then respawn after the allotted 148 | * time, you must first create second event page, on this page you just have to 149 | * have the self switch for "A" checked as a condition, leave everything else 150 | * blank. 151 | * 152 | */ 153 | //============================================================================= 154 | 155 | var Snow = Snow || {}; 156 | Snow.Gather = Snow.Gather || {}; 157 | Snow.Gather.Windows = Snow.Gather.Windows || {}; 158 | Snow.Gather.Scenes = Snow.Gather.Scenes || {}; 159 | Snow.Gather.Parameters = PluginManager.parameters("SnowGather"); 160 | Snow.Gather.PopEvents = false; 161 | 162 | Snow.Gather.TempItems = []; 163 | Snow.Gather.TempRecItems = []; 164 | Snow.Gather.TempEvent = 0; 165 | Snow.Gather.TempCommonEvent = 0; 166 | 167 | Snow.Gather.WaitingEvents = []; 168 | 169 | // Note Tag Stuff 170 | 171 | Snow.Gather.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; 172 | DataManager.isDatabaseLoaded = function() { 173 | if (!Snow.Gather.DataManager_isDatabaseLoaded.call(this)) { 174 | return false; 175 | } 176 | this.processNotetagsSnowGather($dataItems); 177 | return true; 178 | }; 179 | 180 | // Save and Load Stuff 181 | 182 | var Snow_Gather_DataManager_makeSaveContents = DataManager.makeSaveContents; 183 | DataManager.makeSaveContents = function() { 184 | var contents = Snow_Gather_DataManager_makeSaveContents.call(this); 185 | contents.gathering = Snow.Gather.WaitingEvents; 186 | return contents; 187 | } 188 | 189 | var Snow_Gather_DataManager_extractSaveContents = DataManager.extractSaveContents; 190 | DataManager.extractSaveContents = function(contents) { 191 | Snow_Gather_DataManager_extractSaveContents.call(this, contents); 192 | Snow.Gather.WaitingEvents = contents.gathering; 193 | } 194 | 195 | // Time System Stuff 196 | 197 | if (Imported["OrangeTimeSystem"] && MVC.Boolean(String(Snow.Gather.Parameters["Respawning Events"]))) { 198 | Snow.Gather.PopEvents = true; 199 | Snow.Gather.onChangeHour = function() { 200 | console.log("1 Hour Passess..."); 201 | for (var i = 0; i < Snow.Gather.WaitingEvents.length; i++) { 202 | Snow.Gather.WaitingEvents[i].timeRemaining -= 1; 203 | if($gameMap.mapId() == Snow.Gather.WaitingEvents[i].mapId && Snow.Gather.WaitingEvents[i].timeRemaining <= 0) { 204 | var key = [$gameMap.mapId(), Snow.Gather.WaitingEvents[i].eventData.id, "A"]; 205 | $gameSelfSwitches.setValue(key, false); 206 | Snow.Gather.WaitingEvents.splice(i, 1); 207 | } 208 | } 209 | } 210 | OrangeTimeSystem.on('changeHour', Snow.Gather.onChangeHour); 211 | } 212 | 213 | // More Note Tag Stuff 214 | 215 | DataManager.processNotetagsSnowGather = function(group) { 216 | var note1 = /<(?:HARVEST CHANCE BOOST):[ ](\d+)([%%])>/i; 217 | var note2 = /<(?:CHANCE BREAK [\d+]):[ ](\d+)([%%])>/i; 218 | var note2_1 = /<(?:CHANCE BREAK)>/i; 219 | var note2_2 = /<\/(?:CHANCE BREAK)>/i; 220 | var note3 = /<(?:HARVEST CHANCE [\d+]):[ ](\d+)([%%])>/i; 221 | var note3_1 = /<(?:HARVEST CHANCE)>/i; 222 | var note3_2 = /<\/(?:HARVEST CHANCE)>/i; 223 | var note4 = /<(?:HARVEST MINIMUM):[ ](\d+)>/i; 224 | var note5 = /<(?:HARVEST MAXIMUM):[ ](\d+)>/i; 225 | 226 | var chanceBreakFlag = false; 227 | var harvestChanceFlag = false; 228 | 229 | for (var i = 1; i < group.length; i++) { 230 | var obj = group[i]; 231 | obj.harvestChance = []; 232 | obj.chanceBreak = []; 233 | var notedata = obj.note.split(/[\r\n]+/); 234 | for (var n = 0; n < notedata.length; n++) { 235 | var line = notedata[n]; 236 | if (line.match(note1)) { 237 | obj.harvestChanceBoost = parseFloat(RegExp.$1 * 0.01); 238 | } 239 | else if (line.match(note2_2)) { 240 | chanceBreakFlag = false; 241 | } 242 | else if (line.match(note2_1)) { 243 | chanceBreakFlag = true; 244 | } 245 | else if (chanceBreakFlag) { 246 | var data = line.split(": "); 247 | if (data[1]) 248 | data[1] = data[1].replace("%", ""); 249 | obj.chanceBreak.push({itemId: Number(data[0]), chanceBreak: parseFloat(Number(data[1]) * 0.01)}); 250 | } 251 | else if (line.match(note3_2)) { 252 | harvestChanceFlag = false; 253 | } 254 | else if (line.match(note3_1)) { 255 | harvestChanceFlag = true; 256 | } 257 | else if (harvestChanceFlag) { 258 | var data = line.split(": "); 259 | if (data[1]) 260 | data[1] = data[1].replace("%", ""); 261 | obj.harvestChance.push({itemId: Number(data[0]), harvestChance: parseFloat(Number(data[1]) * 0.01)}); 262 | } 263 | 264 | else if (line.match(note4)) { 265 | obj.harvestMinimum = parseInt(RegExp.$1); 266 | } 267 | else if (line.match(note5)) { 268 | obj.harvestMaximum = parseInt(RegExp.$1); 269 | } 270 | } 271 | } 272 | } 273 | 274 | // Helper Functons 275 | 276 | Snow.Gather.idIntoItem = function(id) { 277 | return $dataItems[id]; 278 | } 279 | 280 | Snow.Gather.RandomInt = function() { 281 | return Math.random(); 282 | } 283 | 284 | Snow.Gather.RandomIntRange = function(min, max) { 285 | return Math.floor(Math.random() * (max - min + 1)) + min; 286 | } 287 | 288 | Snow.Gather.Round = function(value, decimals) { 289 | return Number(Math.round(value + "e" + decimals) + "e-" + decimals); 290 | } 291 | 292 | // Windows 293 | 294 | var ItemChoiceWindow = function() { 295 | this.initialize.apply(this, arguments); 296 | } 297 | 298 | ItemChoiceWindow.prototype = Object.create(Window_ItemList.prototype); 299 | ItemChoiceWindow.prototype.constructor = ItemChoiceWindow; 300 | 301 | ItemChoiceWindow.prototype.initialize = function(x, y, width, height) { 302 | Window_ItemList.prototype.initialize.call(this, x, y, width, height); 303 | this._data = []; 304 | this.activate(); 305 | this.refresh(); 306 | this.select(0); 307 | } 308 | 309 | ItemChoiceWindow.prototype.isEnabled = function(item) { 310 | return true; 311 | } 312 | 313 | ItemChoiceWindow.prototype.makeItemList = function() { 314 | this._data = Snow.Gather.TempItems; 315 | } 316 | 317 | ItemChoiceWindow.prototype.drawItemNumber = function(item, x, y, width) { 318 | if (this.needsNumber() && item.id != Number(Snow.Gather.Parameters["Hand Tool ID"])) { 319 | this.drawText(':', x, y, width - this.textWidth('00'), 'right'); 320 | this.drawText($gameParty.numItems(item), x, y, width, 'right'); 321 | } 322 | } 323 | 324 | Snow.Gather.Windows.ItemChoiceWindow = ItemChoiceWindow; 325 | 326 | 327 | var ItemChoiceHelpWindow = function() { 328 | this.initialize.apply(this, arguments); 329 | } 330 | 331 | ItemChoiceHelpWindow.prototype = Object.create(Window_Help.prototype); 332 | ItemChoiceHelpWindow.prototype.constructor = ItemChoiceHelpWindow; 333 | 334 | ItemChoiceHelpWindow.prototype.initialize = function(numLines) { 335 | Window_Help.prototype.initialize.call(this, numLines); 336 | } 337 | 338 | Snow.Gather.Windows.ItemChoiceHelpWindow = ItemChoiceHelpWindow; 339 | 340 | // Scenes 341 | 342 | var ToolChoice = function() { 343 | this.initialize.apply(this, arguments); 344 | } 345 | 346 | ToolChoice.prototype = Object.create(Scene_ItemBase.prototype); 347 | ToolChoice.prototype.constructor = ToolChoice; 348 | 349 | ToolChoice.prototype.initialize = function(data) { 350 | Scene_ItemBase.prototype.initialize.call(this); 351 | } 352 | 353 | ToolChoice.prototype.create = function() { 354 | Scene_ItemBase.prototype.create.call(this); 355 | this._createItemChoiceHelpWindow(); 356 | this._createItemChoiceWindow(); 357 | } 358 | 359 | ToolChoice.prototype.start = function() { 360 | Scene_ItemBase.prototype.start.call(this); 361 | } 362 | 363 | ToolChoice.prototype._createItemChoiceWindow = function() { 364 | this._itemChoiceWindow = new Snow.Gather.Windows.ItemChoiceWindow(0, this._itemChoiceHelpWindow.height, Graphics.boxWidth, Graphics.boxHeight - this._itemChoiceHelpWindow.height); 365 | this._itemChoiceWindow.setHandler('ok', this._onItemChoiceWindowOK.bind(this)); 366 | this._itemChoiceWindow.setHandler('cancel', this._onItemChoiceWindowCancel.bind(this)); 367 | this.addWindow(this._itemChoiceWindow); 368 | } 369 | 370 | ToolChoice.prototype._createItemChoiceHelpWindow = function() { 371 | this._itemChoiceHelpWindow = new Snow.Gather.Windows.ItemChoiceHelpWindow(1); 372 | this._itemChoiceHelpWindow.setText(Snow.Gather.Parameters["Select Tool Message"]); 373 | this.addWindow(this._itemChoiceHelpWindow); 374 | } 375 | 376 | ToolChoice.prototype._onItemChoiceWindowOK = function() { 377 | var selected = this._itemChoiceWindow.item(); 378 | Snow.Gather.Gather2(selected, Snow.Gather.TempRecItems, Snow.Gather.TempEvent, Snow.Gather.TempCommonEvent); 379 | this.popScene(); 380 | } 381 | 382 | ToolChoice.prototype._onItemChoiceWindowCancel = function() { 383 | this.popScene(); 384 | } 385 | 386 | Snow.Gather.Scenes.ToolChoice = ToolChoice; 387 | 388 | // Actual Gathering Stuff 389 | 390 | Snow.Gather.Gather = function(requireItem, recievableItems, commonEvent, event) { 391 | event = event || {_eventId: 0}; 392 | commonEvent = commonEvent || 0; 393 | var eventId = event._eventId; 394 | if (requireItem == false) { 395 | var itemisedRecievableItems = []; 396 | for (var i = 0; i < recievableItems.length; i++) { 397 | itemisedRecievableItems[i] = Snow.Gather.idIntoItem(recievableItems[i]); 398 | } 399 | 400 | var resourceGet = 0; 401 | var hand = Snow.Gather.idIntoItem(Number(Snow.Gather.Parameters["Hand Tool ID"])); 402 | 403 | for (var i = 0; i < itemisedRecievableItems.length; i++) { 404 | var gen = Snow.Gather.Round(Snow.Gather.RandomInt(), 2); 405 | for (var j = 0; j < hand.harvestChance.length; j++) { 406 | if (hand.harvestChance[j].itemId == itemisedRecievableItems[i].id) { 407 | if (gen <= hand.chaceHarvest[j].harvestChance) { 408 | var itemGathered = Snow.Gather.RandomIntRange(itemisedRecievableItems[i].harvestMinimum, itemisedRecievableItems[i].harvestMaximum); 409 | $gameParty.gainItem(itemisedRecievableItems[i], itemGathered); 410 | if (MVC.Boolean(String(Snow.Gather.Parameters["Last Result Store"]))) { 411 | $gameVariables.setValue(Number(Snow.Gather.Parameters["Last Result Variable ID"]), 0); 412 | } 413 | $gameMessage.add(Snow.Gather.Parameters["Successful Harvest Message"].replace("%1", itemGathered).replace("%2", itemisedRecievableItems[i].name)); 414 | resourceGet++; 415 | } else { 416 | if (MVC.Boolean(String(Snow.Gather.Parameters["Last Result Store"]))) { 417 | $gameVariables.setValue(Number(Snow.Gather.Parameters["Last Result Variable ID"]), 1); 418 | } 419 | } 420 | } 421 | } 422 | } 423 | 424 | if (resourceGet == 0) { 425 | $gameMessage.add(Snow.Gather.Parameters["Unsuccessful Harvest Message"]); 426 | } 427 | 428 | if (Snow.Gather.PopEvents) { 429 | Snow.Gather.WaitingEvents.push({ 430 | mapId: $gameMap.mapId(), 431 | eventData: $dataMap.events[eventId], 432 | timeRemaining: Number($dataMap.events[eventId].meta["Respawn Time"]) 433 | }); 434 | 435 | if (!MVC.Boolean(String(Snow.Gather.Parameters["Manual Self Switches"]))) 436 | { 437 | $gameSelfSwitches.setValue([$gameMap.mapId(), eventId, "A"], true); 438 | } 439 | } 440 | } else { 441 | var playerUsableItems = []; 442 | var itemisedRecievableItems = []; 443 | var playerInventory = $gameParty.items(); 444 | 445 | for (var i = 0; i < recievableItems.length; i++) { 446 | itemisedRecievableItems[i] = Snow.Gather.idIntoItem(recievableItems[i]); 447 | } 448 | 449 | var hand = Snow.Gather.idIntoItem(Number(Snow.Gather.Parameters["Hand Tool ID"])); 450 | 451 | if (!MVC.Boolean(Snow.Gather.Parameters["Hand Tool Last"])) { 452 | for (var j = 0; j < recievableItems.length; j++) { 453 | for (var k = 0; k < hand.harvestChance.length; k++) { 454 | if (hand.harvestChance[k].itemId == recievableItems[j]) { 455 | if (!playerUsableItems.contains(hand)) { 456 | playerUsableItems.push(hand); 457 | } 458 | } 459 | } 460 | } 461 | } 462 | 463 | 464 | for (var i = 0; i < playerInventory.length; i++) { 465 | if (playerInventory[i].harvestChance !== []) { 466 | for (var j = 0; j < recievableItems.length; j++) { 467 | for (var k = 0; k < playerInventory[i].harvestChance.length; k++) { 468 | if (playerInventory[i].harvestChance[k].itemId == recievableItems[j]) { 469 | if (!playerUsableItems.contains(playerInventory[i])) { 470 | playerUsableItems.push(playerInventory[i]); 471 | } 472 | } 473 | } 474 | } 475 | } 476 | } 477 | 478 | if (MVC.Boolean(Snow.Gather.Parameters["Hand Tool Last"])) { 479 | for (var j = 0; j < recievableItems.length; j++) { 480 | for (var k = 0; k < hand.harvestChance.length; k++) { 481 | if (hand.harvestChance[k].itemId == recievableItems[j]) { 482 | if (!playerUsableItems.contains(hand)) { 483 | playerUsableItems.push(hand); 484 | } 485 | } 486 | } 487 | } 488 | } 489 | 490 | if (playerUsableItems.length == 0) { 491 | if (MVC.Boolean(String(Snow.Gather.Parameters["Last Result Store"]))) { 492 | $gameVariables.setValue(Number(Snow.Gather.Parameters["Last Result Variable ID"]), 2); 493 | } 494 | $gameMessage.add(Snow.Gather.Parameters["Incorrect Tools Message"]); 495 | return; 496 | } 497 | 498 | Snow.Gather.TempItems = playerUsableItems; 499 | Snow.Gather.TempRecItems = itemisedRecievableItems; 500 | Snow.Gather.TempEvent = eventId; 501 | Snow.Gather.TempCommonEvent = commonEvent; 502 | 503 | SceneManager.push(Snow.Gather.Scenes.ToolChoice); 504 | } 505 | } 506 | 507 | Snow.Gather.Gather2 = function(chosenItem, recieveableItems, eventId, commonEvent) { 508 | var resourceGet = 0; 509 | 510 | var harvestChanceBoost = chosenItem.harvestChanceBoost || 0.0; 511 | 512 | if (commonEvent > 0) { 513 | $gameTemp.reserveCommonEvent(commonEvent); 514 | } 515 | 516 | for (var i = 0; i < recieveableItems.length; i++) { 517 | var gen = Snow.Gather.Round(Math.max(0, Snow.Gather.RandomInt() - harvestChanceBoost), 2); 518 | for (var j = 0; j < chosenItem.harvestChance.length; j++) { 519 | if (recieveableItems[i].id == chosenItem.harvestChance[j].itemId) { 520 | if (gen <= chosenItem.harvestChance[j].harvestChance) { 521 | var itemGathered = Snow.Gather.RandomIntRange(recieveableItems[i].harvestMinimum, recieveableItems[i].harvestMaximum); 522 | $gameParty.gainItem(recieveableItems[i], itemGathered); 523 | if (MVC.Boolean(String(Snow.Gather.Parameters["Last Result Store"]))) { 524 | $gameVariables.setValue(Number(Snow.Gather.Parameters["Last Result Variable ID"]), 0); 525 | } 526 | $gameMessage.add(Snow.Gather.Parameters["Successful Harvest Message"].replace("%1", itemGathered).replace("%2", recieveableItems[i].name)); 527 | resourceGet++; 528 | } else { 529 | if (MVC.Boolean(String(Snow.Gather.Parameters["Last Result Store"]))) { 530 | $gameVariables.setValue(Number(Snow.Gather.Parameters["Last Result Variable ID"]), 1); 531 | } 532 | } 533 | } 534 | } 535 | } 536 | 537 | if (chosenItem.chanceBreak !== undefined) { 538 | var itemBroken = false; 539 | for (var i = 0; i < recieveableItems.length; i++) { 540 | for (var j = 0; j < chosenItem.chanceBreak.length; j++) { 541 | if (chosenItem.chanceBreak[j].itemId == recieveableItems[i].id) { 542 | var gen = Snow.Gather.Round(Snow.Gather.RandomInt(), 2); 543 | if (chosenItem.chanceBreak[j].chanceBreak >= gen && !itemBroken) { 544 | itemBroken = true; 545 | $gameParty.loseItem(chosenItem, 1); 546 | $gameMessage.add(Snow.Gather.Parameters["Item Broken Message"].replace("%1", chosenItem.name)); 547 | } 548 | } 549 | } 550 | } 551 | } 552 | 553 | if (resourceGet == 0) { 554 | $gameMessage.add(Snow.Gather.Parameters["Unsuccessful Harvest Message"]); 555 | } 556 | 557 | if (Snow.Gather.PopEvents) { 558 | Snow.Gather.WaitingEvents.push({ 559 | mapId: $gameMap.mapId(), 560 | eventData: $dataMap.events[eventId], 561 | timeRemaining: Number($dataMap.events[eventId].meta["Respawn Time"]) 562 | }); 563 | 564 | if (!MVC.Boolean(String(Snow.Gather.Parameters["Manual Self Switches"]))) 565 | { 566 | $gameSelfSwitches.setValue([$gameMap.mapId(), eventId, "A"], true); 567 | } 568 | } 569 | } 570 | 571 | 572 | 573 | var Snow_Gather_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand; 574 | Game_Interpreter.prototype.pluginCommand = function(command, args) { 575 | Snow_Gather_Game_Interpreter_pluginCommand.call(this, command, args); 576 | if (command === "SnowGather") { 577 | if (args.length == 4) { 578 | Snow.Gather.Gather(JSON.parse(args[0]), JSON.parse(args[1]), JSON.parse(args[2]), eval(args[3])); 579 | } else if (args.length == 3) { 580 | Snow.Gather.Gather(JSON.parse(args[0]), JSON.parse(args[1]), 0, eval(args[2])); 581 | } else { 582 | Snow.Gather.Gather(JSON.parse(args[0]), JSON.parse(args[1])) 583 | } 584 | } 585 | } 586 | -------------------------------------------------------------------------------- /SnowGather/SnowGather.v1.js: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | // SnowMV - Simple Gathering 3 | // SnowGather.v1.js 4 | // Version: 1.3.3 5 | //============================================================================= 6 | 7 | "use strict"; 8 | 9 | PluginManager.register("SnowGather", "1.3.3", { 10 | "email": "", 11 | "website": "", 12 | "name": "Sn0wCrack" 13 | }, "2015-10-25") 14 | 15 | //============================================================================= 16 | /*: 17 | * @plugindesc A simple way to manage "gathering" type events. 18 | * @author Sn0wCrack 19 | * 20 | * @param Successful Harvest Message 21 | * @desc Message to display upon sucessful harvest, %1 is the amount, %2 is the item name 22 | * @default You gathered %1 %2. 23 | * 24 | * @param Unsuccessful Harvest Message 25 | * @desc Message to display upon failing to harvest items 26 | * @default Failed to harvest any resources. 27 | * 28 | * @param Item Broken Message 29 | * @desc Message to display when an item breaks upon harvesting, %1 is the item name 30 | * @default Your %1 broke while harvesting! 31 | * 32 | * @param Incorrect Tools Message 33 | * @desc Message to display when you don't have the right tools, %1 is the tools formatted for grammar 34 | * @default You don't have the right tool for the job, you need\n%1\nTo gather items here. 35 | * 36 | * @param Respawning Events 37 | * @desc Override the default option when having a time system installed, true = ON, false = OFF 38 | * @default true 39 | * 40 | * @param Manual Self Switches 41 | * @desc If you wish to manually set self switches in your event for despawning them, true = ON, false = OFF 42 | * @default false 43 | * 44 | * @param Last Result Store 45 | * @desc If you want to store the last result of a harvest as a variable, true = ON, false = OFF 46 | * @default true 47 | * 48 | * @param Last Result Variable ID 49 | * @desc The variable to store the last result in, 0 = success, 1 = failure, 2 = incorrect tools 50 | * @default 1 51 | * 52 | * @help 53 | * ============================================================================ 54 | * Introduction 55 | * ============================================================================ 56 | * 57 | * Welcome to the Simple Gathering System by Sn0wCrack, this script allows you 58 | * to create gathering events in which you players to search for resources using 59 | * tools (or not if you want!) 60 | * 61 | * Please see https://github.com/Sn0wCrack/SnowMV/blob/master/LICENSE for license 62 | * details. 63 | * 64 | * If you use this script, please give credit! 65 | * 66 | * ============================================================================ 67 | * Setup 68 | * ============================================================================ 69 | * In your items database you can tag any item (this means only normal items, 70 | * not weapons, armour, etc.) with the following tags: 71 | * 72 | * Havesting Tools: 73 | * 74 | * - Not Required 75 | * This tag allows you to set an amount this particular item will boost 76 | * the chances of you finding items. 77 | * 78 | * - Required 79 | * This tag allows you to set the percentage of the time the tool will, 80 | * break after use, e.g. 90% will break 90% of the time, 0% will never break. 81 | * 82 | * 83 | * Harvestables: 84 | * 85 | * - Required 86 | * The percentage chance of finding the item from gathering, e.g 87 | * 90% wil be found 90% of the time, 100% will always be found. 88 | * 89 | * - Required 90 | * The minimum amount of the item to be found upon the successful harvesting of 91 | * it. 92 | * 93 | * - Required 94 | * The maximum amount of the item to be found upon the successful harvesting of 95 | * it. 96 | * 97 | * Events: 98 | * 99 | * - Required if you want respawing events (Requires OrangeTimeSystem) 100 | * Sets how long in hours you want the event to respawn in 101 | * 102 | * ============================================================================ 103 | * Usage 104 | * ============================================================================ 105 | * To call the script, create an event with a plugin command 106 | * SnowGather [x] [y] this 107 | * Let me explain how this works: replace x with the id of the item you want 108 | * the player to use, if you want them to use more than one item replace it 109 | * with something like: [x,y,z] NO SPACES BETWEEN THE ITEMS. 110 | * 111 | * y is the id of the item you want the player to harvest from this event, 112 | * again if you want them to have a chance of getting more than one item 113 | * use something like this: [x,y,z] NO SPACES BETWEEN THE ITEMS. 114 | * 115 | * this is well, always the word this, this is only required if you're using 116 | * a time system. 117 | * 118 | * If you don't want the event to require the usage of a tool, replace [x] with 119 | * false. 120 | * 121 | * Repsawning Events: 122 | * 123 | * In order for an event to actually despawn and then respawn afte the allotted 124 | * time, you must first create second event page, on this page you just have to 125 | * have the self switch for "A" checked as a condition, leave everything else 126 | * blank. 127 | * 128 | */ 129 | //============================================================================= 130 | 131 | var Snow = Snow || {}; 132 | Snow.Gather = Snow.Gather || {}; 133 | Snow.Gather.Parameters = PluginManager.parameters("SnowGather"); 134 | Snow.Gather.PopEvents = false; 135 | 136 | Snow.Gather.WaitingEvents = []; 137 | 138 | Snow.Gather.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded; 139 | DataManager.isDatabaseLoaded = function() { 140 | if (!Snow.Gather.DataManager_isDatabaseLoaded.call(this)) { 141 | return false; 142 | } 143 | this.processNotetagsSnowGather($dataItems); 144 | return true; 145 | }; 146 | 147 | if (Imported["OrangeTimeSystem"] && MVC.Boolean(String(Snow.Gather.Parameters["Respawning Events"]))) { 148 | Snow.Gather.PopEvents = true; 149 | Snow.Gather.onChangeHour = function() { 150 | console.log("1 Hour Passess..."); 151 | for (var i = 0; i < Snow.Gather.WaitingEvents.length; i++) { 152 | Snow.Gather.WaitingEvents[i].timeRemaining -= 1; 153 | if($dataMap.events[Snow.Gather.WaitingEvents[i].eventData.id] == Snow.Gather.WaitingEvents[i].eventData && Snow.Gather.WaitingEvents[i].timeRemaining == 0) 154 | { 155 | var key = [$gameMap.mapId(), Snow.Gather.WaitingEvents[i].eventData.id, "A"]; 156 | $gameSelfSwitches.setValue(key, false); 157 | Snow.Gather.WaitingEvents.splice(i, 1); 158 | } 159 | } 160 | } 161 | OrangeTimeSystem.on('changeHour', Snow.Gather.onChangeHour); 162 | } 163 | 164 | DataManager.processNotetagsSnowGather = function(group) { 165 | var note1 = /<(?:HARVEST CHANCE BOOST):[ ](\d+)([%%])>/i; 166 | var note2 = /<(?:CHANCE BREAK):[ ](\d+)([%%])>/i; 167 | var note3 = /<(?:HARVEST CHANCE):[ ](\d+)([%%])>/i; 168 | var note4 = /<(?:HARVEST MINIMUM):[ ](\d+)>/i; 169 | var note5 = /<(?:HARVEST MAXIMUM):[ ](\d+)>/i; 170 | 171 | for (var i = 1; i < group.length; i++) { 172 | var obj = group[i]; 173 | var notedata = obj.note.split(/[\r\n]+/); 174 | for (var n = 0; n < notedata.length; n++) { 175 | var line = notedata[n]; 176 | if (line.match(note1)) { 177 | obj.harvestChanceBoost = parseFloat(RegExp.$1 * 0.01); 178 | } 179 | if (line.match(note2)) { 180 | obj.chanceBreak = parseFloat(RegExp.$1 * 0.01); 181 | } 182 | if (line.match(note3)) { 183 | obj.chanceHarvest = parseFloat(RegExp.$1 * 0.01); 184 | } 185 | if (line.match(note4)) { 186 | obj.harvestMinimum = parseInt(RegExp.$1); 187 | } 188 | if (line.match(note5)) { 189 | obj.harvestMaximum = parseInt(RegExp.$1); 190 | } 191 | } 192 | } 193 | } 194 | 195 | Snow.Gather.idIntoItem = function(id) { 196 | return $dataItems[id]; 197 | } 198 | 199 | Snow.Gather.RandomInt = function() { 200 | return Math.random(); 201 | } 202 | 203 | Snow.Gather.RandomIntRange = function(min, max) { 204 | return Math.floor(Math.random() * (max - min + 1)) + min; 205 | } 206 | 207 | Snow.Gather.Round = function(value, decimals) { 208 | return Number(Math.round(value + "e" + decimals) + "e-" + decimals); 209 | } 210 | 211 | Snow.Gather.Gather = function(requiredItems, recievableItems, event) { 212 | event = event || {_eventId: 0}; 213 | var eventId = event._eventId; 214 | if (requiredItems == false) { 215 | var itemisedRecievableItems = []; 216 | for (var i = 0; i < recievableItems.length; i++) { 217 | itemisedRecievableItems[i] = Snow.Gather.idIntoItem(recievableItems[i]); 218 | } 219 | 220 | for (var i = 0; i < itemisedRecievableItems.length; i++) { 221 | var gen = Snow.Gather.Round(Snow.Gather.RandomInt(), 2); 222 | if (gen <= itemisedRecievableItems[i].chanceHarvest) { 223 | var itemGathered = Snow.Gather.RandomIntRange(itemisedRecievableItems[i].harvestMinimum, itemisedRecievableItems[i].harvestMaximum); 224 | $gameParty.gainItem(itemisedRecievableItems[i], itemGathered); 225 | if (MVC.Boolean(String(Snow.Gather.Parameters["Last Result Store"]))) { 226 | $gameVariables.setValue(Number(Snow.Gather.Parameters["Last Result Variable ID"]), 0); 227 | } 228 | $gameMessage.add(Snow.Gather.Parameters["Successful Harvest Message"].replace("%1", itemGathered).replace("%2", itemisedRecievableItems[i].name)); 229 | } else { 230 | if (MVC.Boolean(String(Snow.Gather.Parameters["Last Result Store"]))) { 231 | $gameVariables.setValue(Number(Snow.Gather.Parameters["Last Result Variable ID"]), 1); 232 | } 233 | $gameMessage.add(Snow.Gather.Parameters["Unsuccessful Harvest Message"]); 234 | } 235 | } 236 | if (Snow.Gather.PopEvents) { 237 | Snow.Gather.WaitingEvents.push({ 238 | eventData: $dataMap.events[eventId], 239 | timeRemaining: Number($dataMap.events[eventId].meta["Respawn Time"]) 240 | }); 241 | if (!MVC.Boolean(String(Snow.Gather.Parameters["Manual Self Switches"]))) 242 | { 243 | $gameSelfSwitches.setValue([$gameMap.mapId(), eventId, "A"], true); 244 | } 245 | } 246 | } else { 247 | var itemisedRequiredItems = []; 248 | var itemisedRecievableItems = []; 249 | for (var i = 0; i < requiredItems.length; i++) { 250 | itemisedRequiredItems[i] = Snow.Gather.idIntoItem(requiredItems[i]); 251 | } 252 | for (var i = 0; i < recievableItems.length; i++) { 253 | itemisedRecievableItems[i] = Snow.Gather.idIntoItem(recievableItems[i]); 254 | } 255 | 256 | var gotItems = []; 257 | for (var i = 0; i < requiredItems.length; i++) { 258 | if ($gameParty.hasItem(itemisedRequiredItems[i])) { 259 | gotItems[i] = itemisedRequiredItems[i]; 260 | } 261 | } 262 | 263 | if (gotItems.length == requiredItems.length) { 264 | var totalHarvestBoost = 0.0; 265 | for (var i = 0; i < itemisedRequiredItems.length; i++) { 266 | if (itemisedRequiredItems[i].harvestChanceBoost) { 267 | totalHarvestBoost += itemisedRequiredItems[i].harvestChanceBoost; 268 | } 269 | } 270 | 271 | var resourceGet = 0; 272 | 273 | for (var i = 0; i < itemisedRecievableItems.length; i++) { 274 | var gen = Snow.Gather.Round(Math.max(0, Snow.Gather.RandomInt() - totalHarvestBoost), 2); 275 | if (gen <= itemisedRecievableItems[i].chanceHarvest) { 276 | var itemGathered = Snow.Gather.RandomIntRange(itemisedRecievableItems[i].harvestMinimum, itemisedRecievableItems[i].harvestMaximum); 277 | $gameParty.gainItem(itemisedRecievableItems[i], itemGathered); 278 | if (MVC.Boolean(String(Snow.Gather.Parameters["Last Result Store"]))) { 279 | $gameVariables.setValue(Number(Snow.Gather.Parameters["Last Result Variable ID"]), 0); 280 | } 281 | $gameMessage.add(Snow.Gather.Parameters["Successful Harvest Message"].replace("%1", itemGathered).replace("%2", itemisedRecievableItems[i].name)); 282 | resourceGet++; 283 | } else { 284 | if (MVC.Boolean(String(Snow.Gather.Parameters["Last Result Store"]))) { 285 | $gameVariables.setValue(Number(Snow.Gather.Parameters["Last Result Variable ID"]), 1); 286 | } 287 | } 288 | } 289 | 290 | if (resourceGet == 0) { 291 | $gameMessage.add(Snow.Gather.Parameters["Unsuccessful Harvest Message"]); 292 | } 293 | 294 | for (var i = 0; i < itemisedRequiredItems.length; i++) { 295 | if (Snow.Gather.RandomInt() < itemisedRequiredItems[i].chanceBreak) { 296 | $gameParty.loseItem(itemisedRequiredItems[i], 1); 297 | $gameMessage.add(Snow.Gather.Parameters["Item Broken Message"].replace("%1", itemisedRequiredItems[i].name)); 298 | } 299 | } 300 | 301 | if (Snow.Gather.PopEvents) { 302 | Snow.Gather.WaitingEvents.push({ 303 | eventData: $dataMap.events[eventId], 304 | timeRemaining: Number($dataMap.events[eventId].meta["Respawn Time"]) 305 | }); 306 | if (!MVC.Boolean(String(Snow.Gather.Parameters["Manual Self Switches"]))) 307 | { 308 | $gameSelfSwitches.setValue([$gameMap.mapId(), eventId, "A"], true); 309 | } 310 | } 311 | 312 | } else { 313 | var concatItems = ""; 314 | for (var i = 0; i < itemisedRequiredItems.length; i++) 315 | { 316 | if (i == itemisedRequiredItems.length - 1) 317 | { 318 | concatItems += "and "; 319 | } 320 | concatItems += "a " + itemisedRequiredItems[i].name; 321 | if (i != itemisedRequiredItems.length - 1) 322 | { 323 | concatItems += ", "; 324 | } 325 | } 326 | var lines = String(Snow.Gather.Parameters["Incorrect Tools Message"]).split("\\n"); 327 | if (MVC.Boolean(String(Snow.Gather.Parameters["Last Result Store"]))) { 328 | $gameVariables.setValue(Number(Snow.Gather.Parameters["Last Result Variable ID"]), 2); 329 | } 330 | for (var i = 0; i < lines.length; i++) { 331 | $gameMessage.add(lines[i].replace("%1", concatItems)); 332 | } 333 | } 334 | } 335 | } 336 | 337 | var Snow_Gather_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand; 338 | Game_Interpreter.prototype.pluginCommand = function(command, args) { 339 | Snow_Gather_Game_Interpreter_pluginCommand.call(this, command, args); 340 | if (command === "SnowGather") { 341 | if (args[2]) { 342 | Snow.Gather.Gather(JSON.parse(args[0]), JSON.parse(args[1]), eval(args[2])); 343 | } else { 344 | Snow.Gather.Gather(JSON.parse(args[0]), JSON.parse(args[1])) 345 | } 346 | 347 | } 348 | } -------------------------------------------------------------------------------- /SnowQuest/Quests.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Sample Quest", 4 | "questGiver": "Mrs. Sampleton", 5 | "description": "Mrs. Sameplton wants you to find some shit for her, becasue she's so lazy." 6 | "questLevel": 1, 7 | "objectives": [ 8 | { "text": "Find the shit" }, 9 | { "text": "Give Mrs. Sampleton the shit" } 10 | ] 11 | }, 12 | 13 | { 14 | "name": "More Sample Quest", 15 | "questGiver": "Mr. Sampleton", 16 | "description": "I don't know, find the shit" 17 | "questLevel": 7, 18 | "objectives": [ 19 | { "text": "Find the shit" }, 20 | { "text": "Give Mr. Sampleton the shit" } 21 | ] 22 | } 23 | ] -------------------------------------------------------------------------------- /SnowQuest/SnowQuest.js: -------------------------------------------------------------------------------- 1 | //============================================================================= 2 | // SnowMV - Quest Journal 3 | // SnowQuest.js 4 | // Version: 1.0.0 5 | //============================================================================= 6 | 7 | "use strict"; 8 | 9 | PluginManager.register("SnowQuest", "1.0.0", { 10 | "email": "", 11 | "website": "", 12 | "name": "Sn0wCrack" 13 | }, "2015-10-26") 14 | 15 | //============================================================================= 16 | /*: 17 | * @plugindesc A quest journal system 18 | * @author Sn0wCrack 19 | * 20 | * @param Menu Title 21 | * @desc Text to display for the menu command 22 | * @default Quest Journal 23 | * 24 | * @param Complete Quests Icon 25 | * @desc ID of icon to display for completed quests 26 | * @deafult 1 27 | * 28 | * @param All Quests Icon 29 | * @desc ID of icon to display for all quests 30 | * @default 2 31 | * 32 | * @param Incomplete Quests Icon 33 | * @desc 34 | * @default 3 35 | * 36 | * @param Completed Quest Colour 37 | * @desc Hexidecimal colour that completed quests show up in 38 | * @default #0099ff 39 | * 40 | * @help 41 | * ============================================================================ 42 | * Introduction 43 | * ============================================================================ 44 | * 45 | * Please see https://github.com/Sn0wCrack/SnowMV/blob/master/LICENSE for license 46 | * details. 47 | * 48 | * If you use this script, please give credit! 49 | * 50 | * ============================================================================ 51 | * Setup 52 | * ============================================================================ 53 | * 54 | * Place Quests.json in the data folder of your project. 55 | * 56 | * ============================================================================ 57 | * Usage 58 | * ============================================================================ 59 | * 60 | * 61 | * 62 | */ 63 | //============================================================================= 64 | var Snow = Snow || {}; 65 | Snow.Quest = Snow.Quest || {}; 66 | Snow.Quest.Scenes = Snow.Quest.Scenes || {}; 67 | Snow.Quest.Windows = Snow.Quest.Windows || {}; 68 | Snow.Quest.Parameters = PluginManager.parameters("SnowQuest"); 69 | 70 | Snow.Quest.QuestData = JSON.parse(MVC.ajaxLoadFile("data/Quests.json", "application/json")); 71 | Snow.Quest.PlayerQuestData = Snow.Quest.QuestData; 72 | 73 | //============================================================================== 74 | // Quest Functions 75 | //============================================================================== 76 | 77 | Snow.Quest.RefreshQuests = function() { 78 | console.warn("This may take a long time!"); 79 | for (var i = 0; i < Snow.Quest.PlayerQuestData.length; i++) { 80 | var objectivesComplete = 0; 81 | for (var j = 0; i < Snow.Quest.PlayerQuestData[i].objectives.length; j++) { 82 | if (Snow.Quest.PlayerQuestData[i].objectives[j].status == 2) { 83 | objectivesComplete++; 84 | } 85 | } 86 | if (Snow.Quest.PlayerQuestData[i].objectives.length == objectivesComplete) { 87 | Snow.Quest.QuestUpdate(i, true); 88 | } 89 | } 90 | } 91 | 92 | Snow.Quest.QuestUpdate = function(questId, status) { 93 | Snow.Quest.PlayerQuestData[questId].status = status; 94 | } 95 | 96 | Snow.Quest.QuestObjectiveUpdate = function(questId, questObjective, status) { 97 | Snow.Quest.PlayerQuestData[questId].objectives[questObjective].status = status; 98 | } 99 | 100 | //============================================================================== 101 | // Windows 102 | //============================================================================== 103 | 104 | // Quest Information Window 105 | 106 | var QuestInformation = function() { 107 | this.initialize.apply(this, arguments); 108 | 109 | } 110 | 111 | QuestInformation.prototype = Object.create(Window_Base.prototype); 112 | QuestInformation.prototype.constructor = QuestInformation; 113 | 114 | QuestInformation.prototype.initialize = function(wx, wy, wh, ww) { 115 | Window_Base.prototype.initialize.call(this, wx, wy, ww, wh); 116 | this._handlers = []; 117 | this.deactivate(); 118 | } 119 | 120 | QuestInformation.prototype.refresh = function() { 121 | this.contents.clear(); 122 | } 123 | 124 | QuestInformation.prototype.update = function() { 125 | Window_Base.prototype.update.call(this); 126 | this.processHandling(); 127 | } 128 | 129 | QuestInformation.prototype.isOpenAndActive = function() { 130 | return this.isOpen() && this.active; 131 | } 132 | 133 | QuestInformation.prototype.processHandling = function() { 134 | if (this.isOpenAndActive()) { 135 | if (this.isCancelEnabled() && this.isCancelTriggered()) { 136 | this.processCancel(); 137 | } 138 | } 139 | } 140 | 141 | QuestInformation.prototype.setHandler = function(symbol, method) { 142 | this._handlers[symbol] = method; 143 | } 144 | 145 | QuestInformation.prototype.isHandled = function(symbol) { 146 | return !!this._handlers[symbol]; 147 | } 148 | 149 | QuestInformation.prototype.isCancelEnabled = function() { 150 | return this.isHandled('cancel'); 151 | } 152 | 153 | QuestInformation.prototype.isCancelTriggered = function() { 154 | return Input.isRepeated('cancel'); 155 | } 156 | 157 | QuestInformation.prototype.callHandler = function(symbol) { 158 | if (this.isHandled(symbol)) { 159 | this._handlers[symbol](); 160 | } 161 | } 162 | 163 | QuestInformation.prototype.processCancel = function() { 164 | SoundManager.playCancel(); 165 | this.deactivate(); 166 | this.callCancelHandler(); 167 | }; 168 | 169 | QuestInformation.prototype.callCancelHandler = function() { 170 | this.callHandler('cancel'); 171 | }; 172 | 173 | 174 | Snow.Quest.Windows.QuestInformation = QuestInformation; 175 | 176 | // Quest List Window 177 | 178 | var QuestList = function() { 179 | this.initialize.apply(this, arguments); 180 | } 181 | 182 | QuestList.prototype = Object.create(Window_Command.prototype); 183 | QuestList.prototype.constructor = QuestList; 184 | 185 | QuestList.prototype.initialize = function(wx, wy) { 186 | Window_Command.prototype.initialize.call(this, wx, wy); 187 | this.deactivate(); 188 | this.deselect(); 189 | } 190 | 191 | QuestList.prototype.windowWidth = function() { 192 | return 245; 193 | } 194 | 195 | QuestList.prototype.windowHeight = function() { 196 | return Graphics.boxHeight - 100; 197 | } 198 | 199 | QuestList.prototype.drawText = function(text, x, y, maxWidth, align, color) { 200 | this.changeTextColor(color); 201 | this.contents.drawText(text, x, y, maxWidth, this.lineHeight(), align); 202 | } 203 | 204 | QuestList.prototype.drawItem = function(index, color) { 205 | var rect = this.itemRectForText(index); 206 | var align = this.itemTextAlign(); 207 | this.resetTextColor(); 208 | this.changePaintOpacity(this.isCommandEnabled(index)); 209 | this.drawText(this.commandName(index), rect.x, rect.y, rect.width, align, color); 210 | } 211 | 212 | QuestList.prototype._addQuestsAll = function() { 213 | for (var i = 0; i < Snow.Quest.PlayerQuestData.length; i++) { 214 | this.addCommand(Snow.Quest.PlayerQuestData[i].name, "quest" + i); 215 | } 216 | } 217 | 218 | QuestList.prototype._addQuestsComplete = function() { 219 | for (var i = 0; i < Snow.Quest.PlayerQuestData.length; i++) { 220 | if (Snow.Quest.PlayerQuestData[i].status) { 221 | this.addCommand(Snow.Quest.PlayerQuestData[i].name, "quest" + i); 222 | } 223 | } 224 | } 225 | 226 | QuestList.prototype._addQuestsIncomplete = function() { 227 | for (var i = 0; i < Snow.Quest.PlayerQuestData.length; i++) { 228 | if (!Snow.Quest.PlayerQuestData[i].status || Snow.Quest.PlayerQuestData[i].status === undefined) { 229 | this.addCommand(Snow.Quest.PlayerQuestData[i].name, "quest" + i); 230 | } 231 | } 232 | } 233 | 234 | Snow.Quest.Windows.QuestList = QuestList; 235 | 236 | // Quest Type Choice 237 | 238 | var QuestTypeChoice = function() { 239 | this.initialize.apply(this, arguments); 240 | } 241 | 242 | QuestTypeChoice.prototype = Object.create(Window_Selectable.prototype); 243 | QuestTypeChoice.prototype.constructor = QuestTypeChoice; 244 | 245 | QuestTypeChoice.prototype.initialize = function(wx, wy, ww, wh) { 246 | Window_Selectable.prototype.initialize.call(this, wx, wy, ww, wh); 247 | this._index = 0; 248 | this.activate(); 249 | this.refresh(); 250 | } 251 | 252 | QuestTypeChoice.prototype.refresh = function() { 253 | this.makeItemList(); 254 | this.createContents(); 255 | this.drawAllItems(); 256 | } 257 | 258 | QuestTypeChoice.prototype.makeItemList = function() { 259 | this._data = ["All Quests", "Incomplete Quests", "Complete Quests"]; 260 | } 261 | 262 | QuestTypeChoice.prototype.isCurrentItemEnabled = function() { 263 | return true; 264 | } 265 | 266 | QuestTypeChoice.prototype.isEnabled = function(index) { 267 | return true; 268 | } 269 | 270 | QuestTypeChoice.prototype.maxItems = function() { 271 | return this._data ? this._data.length : 1; 272 | } 273 | 274 | QuestTypeChoice.prototype.drawItem = function(index) { 275 | var type = this._data[index], 276 | rect = this.itemRect(index); 277 | 278 | if (type === "All Quests") { 279 | this.drawText(type, rect.x + 35, rect.y, rect.width, 'left'); 280 | this.drawIcon(Number(Snow.Quest.Parameters["All Quests Icon"]), rect.x, rect.y + 2); 281 | } 282 | 283 | if (type === "Incomplete Quests") { 284 | this.drawText(type, rect.x + 35, rect.y, rect.width, 'left'); 285 | this.drawIcon(Number(Snow.Quest.Parameters["Incomplete Quests Icon"]), rect.x, rect.y + 2); 286 | } 287 | 288 | if (type === "Complete Quests") { 289 | this.drawText(type, rect.x + 35, rect.y, rect.width, 'left'); 290 | this.drawIcon(Number(Snow.Quest.Parameters["Complete Quests Icon"]), rect.x, rect.y + 2); 291 | } 292 | } 293 | 294 | Snow.Quest.Windows.QuestTypeChoice = QuestTypeChoice; 295 | 296 | //============================================================================== 297 | // Scenes 298 | //============================================================================== 299 | 300 | var Journal = function() { 301 | this.initialize.apply(this, arguments); 302 | } 303 | 304 | Journal.prototype = Object.create(Scene_MenuBase.prototype); 305 | Journal.prototype.constructor = Journal; 306 | 307 | Journal.prototype.initialize = function() { 308 | Scene_MenuBase.prototype.initialize.call(this); 309 | } 310 | 311 | Journal.prototype.create = function() { 312 | Scene_MenuBase.prototype.create.call(this); 313 | this._createQuestListTypeChoiceWindow(); 314 | this._createQuestListCommandWindow(); 315 | this._createQuestInformationWindow(); 316 | } 317 | 318 | Journal.prototype.start = function() { 319 | Scene_MenuBase.prototype.start.call(this); 320 | } 321 | 322 | Journal.prototype._createQuestListTypeChoiceWindow = function() { 323 | var wx = 0, 324 | wy = 0, 325 | ww = 245, 326 | wh = 100; 327 | this._questTypeChoiceWindow = new Snow.Quest.Windows.QuestTypeChoice(wx, wy, ww, wh); 328 | this._questTypeChoiceWindow.setHandler('ok', this._onQuestListTypeChoiceOK.bind(this)); 329 | this._questTypeChoiceWindow.setHandler('cancel', this._onQuestListTypeChoiceCancel.bind(this)) 330 | this.addWindow(this._questTypeChoiceWindow); 331 | } 332 | 333 | Journal.prototype._createQuestListCommandWindow = function() { 334 | var wx = 0, 335 | wy = 100; 336 | this._questListCommandWindow = new Snow.Quest.Windows.QuestList(wx, wy); 337 | this._questListCommandWindow.setHandler('ok', this._onQuestListOK.bind(this)); 338 | this._questListCommandWindow.setHandler('cancel', this._onQuestListCancel.bind(this)); 339 | this.addWindow(this._questListCommandWindow); 340 | } 341 | 342 | Journal.prototype._createQuestInformationWindow = function() { 343 | var wx = this._questListCommandWindow.windowWidth(), 344 | wy = 0, 345 | wh = Graphics.boxHeight, 346 | ww = Graphics.boxWidth - this._questListCommandWindow.windowWidth(); 347 | this._questInformationWindow = new Snow.Quest.Windows.QuestInformation(wx, wy, wh, ww); 348 | this._questInformationWindow.setHandler('cancel', this._onQuestInformationCancel.bind(this)); 349 | this.addWindow(this._questInformationWindow); 350 | } 351 | 352 | Journal.prototype._onQuestListOK = function() { 353 | var questId = Number(this._questListCommandWindow.currentSymbol().replace("quest", "")); 354 | this._questInformationWindow.drawText(Snow.Quest.PlayerQuestData[questId].name, 0, 0, this._questInformationWindow.contentsWidth(), 'left'); 355 | this._questInformationWindow.activate(); 356 | } 357 | 358 | Journal.prototype._onQuestListCancel = function() { 359 | this._questTypeChoiceWindow.activate(); 360 | this._questListCommandWindow.clearCommandList(); 361 | this._questListCommandWindow.deselect(); 362 | } 363 | 364 | Journal.prototype._onQuestInformationCancel = function() { 365 | this._questInformationWindow.refresh(); 366 | this._questListCommandWindow.activate(); 367 | } 368 | 369 | Journal.prototype._onQuestListTypeChoiceOK = function() { 370 | var index = this._questTypeChoiceWindow._index; 371 | this._questListCommandWindow.refresh(); 372 | switch(this._questTypeChoiceWindow._data[index]) { 373 | case "All Quests": 374 | this._questListCommandWindow._addQuestsAll(); 375 | break; 376 | case "Complete Quests": 377 | this._questListCommandWindow._addQuestsComplete(); 378 | break; 379 | case "Incomplete Quests": 380 | this._questListCommandWindow._addQuestsIncomplete(); 381 | break; 382 | default: 383 | break; 384 | } 385 | if (this._questListCommandWindow.maxItems() > 0) { 386 | for (var i = 0; i < this._questListCommandWindow._list.length; i++) { 387 | var index = Number(this._questListCommandWindow._list[i].symbol.replace("quest", "")); 388 | if (Snow.Quest.PlayerQuestData[index].status && Snow.Quest.PlayerQuestData[index].status !== undefined) { 389 | this._questListCommandWindow.drawItem(i, Snow.Quest.Parameters["Completed Quest Colour"]); 390 | } else { 391 | this._questListCommandWindow.drawItem(i, "#ffffff"); 392 | } 393 | } 394 | this._questListCommandWindow.activate(); 395 | this._questListCommandWindow.select(0); 396 | } else { 397 | SoundManager.playBuzzer(); 398 | this._questTypeChoiceWindow.activate(); 399 | } 400 | } 401 | 402 | Journal.prototype._onQuestListTypeChoiceCancel = function() { 403 | this.popScene(); 404 | } 405 | 406 | Snow.Quest.Scenes.Journal = Journal; 407 | 408 | //============================================================================== 409 | // Menu Override 410 | //============================================================================== 411 | 412 | // Use Yanfly's Main Menu Manager 413 | 414 | //============================================================================== 415 | // Plugin Commands 416 | //============================================================================== 417 | 418 | Snow.Quest.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand; 419 | Game_Interpreter.prototype.pluginCommand = function(command, args) { 420 | Snow.Gather.Game_Interpreter_pluginCommand.call(this, command, args); 421 | if (command === "SnowQuestObjectiveUpdate") { 422 | Snow.Quest.QuestObjectiveUpdate(Number(args[0]), Number(args[1]), Number(args[2])); 423 | } 424 | if (command === "SnowQuestUpdate") { 425 | Snow.Quest.QuestUpdate(Number(args[0]), MVC.Boolean(args[1])); 426 | } 427 | if (command === "SnowQuestRefresh") { 428 | Snow.Quest.RefreshQuests(); 429 | } 430 | if (command === "SnowQuestJournal") { 431 | SceneManager.push(Snow.Quest.Scenes.Journal); 432 | } 433 | } --------------------------------------------------------------------------------