1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | //=============================================================================// Yanfly Engine Plugins - Footstep Sounds// YEP_FootstepSounds.js//=============================================================================var Imported = Imported || {};Imported.YEP_FootstepSounds = true;var Yanfly = Yanfly || {};Yanfly.Footsteps = Yanfly.Footsteps || {};Yanfly.Footsteps.version = 1.01;//============================================================================= /*: * @plugindesc v1.01 Set footstep sounds to play when the player and/or * events walk over specific tiles. * @author Yanfly Engine Plugins + Chickie Collaboration * * @param ---Default--- * @default * * @param Default Sound * @parent ---Default--- * @type file * @dir audio/se/ * @require 1 * @desc The default SE sound used for all tiles. * @default Move1 * * @param Default Volume * @parent ---Default--- * @desc Volume of the footsteps made by default. * Insert a number value. * @default 10 * * @param Default Pitch * @parent ---Default--- * @desc Pitch of the footsteps made by default. * Insert a number value. * @default 150 * * @param ---Player Settings--- * @default * * @param Player Enable * @parent ---Player Settings--- * @type boolean * @on Enable * @off Disable * @desc Play footstep sounds for the player character? * Disable - false Enable - true * @default true * * @param Player Volume * @parent ---Player Settings--- * @desc What volume rate to play the footsteps at for player? * Use a float value. 1.00 = 100% 0.50 = 50% * @default 1.00 * * @param Player Pitch * @parent ---Player Settings--- * @desc What pitch rate to play the footsteps at for player? * Use a float value. 1.00 = 100% 0.50 = 50% * @default 1.00 * * @param ---Event Settings--- * @default * * @param Event Enable * @parent ---Event Settings--- * @type boolean * @on Enable * @off Disable * @desc Play footstep sounds for the events? * Disable - false Enable - true * @default true * * @param Event Volume * @parent ---Event Settings--- * @desc What volume rate to play the footsteps at for events? * Use a float value. 1.00 = 100% 0.50 = 50% * @default 1.00 * * @param Distance Volume * @parent ---Event Settings--- * @desc Change the volume by this much per tile difference * from event to player. Use a float value. * @default -0.10 * * @param Event Pitch * @parent ---Event Settings--- * @desc What pitch rate to play the footsteps at for events? * Use a float value. 1.00 = 100% 0.50 = 50% * @default 1.00 * * @param Distance Pitch * @parent ---Event Settings--- * @desc Change the pitch by this much per tile difference * from event to player. Use a float value. * @default -0.00 * * @param Distance Pan * @parent ---Event Settings--- * @desc Change the pan by this much per tile difference * from event to player. Use an int value. * @default 10 * * @help * ============================================================================ * Introduction * ============================================================================ * * This plugin gives your player and/or events footsteps when they walk onto * tiles. These footsteps made by players and/or events can have different * sounds based on regions, tilesets, and/or terrain tags. If footsteps are * enabled for events, they can have distance based volumes and pitches to * immerse the player further. * * This is a collaboration plugin by Chickie and Yanfly to ensure compatibility * with the Yanfly Engine Plugins library. * * ============================================================================ * Instructions * ============================================================================ * * This plugin requires a bit of setup. Adjust the plugin parameters to set up * a default set of footsteps that are to be played when nothing else has been * set. These sound effects will be played when there are no region-specific * sound effects or terrain tag-specific sound effects. * * That said, if you go into your project's database and go to the Tilesets tab * you can set footsteps for each tileset. The tiles can play specific footstep * sounds based on their terrain tag ID. Look in the notetags section below for * the notetag setup on how to make a set of tiles play certain footsteps. The * footsteps made here have higher priority than the default sound effects and * if the player or event steps on a tile that has a footstep sound tied to a * terrain tag, that footstep sound will be played instead. * * Even higher on the priority level are the region-based footstep sounds. If * the player or an event steps on a tile that has a region-based footstep * sound, then that sound will be played regardless of the terrain tag setting * made for that specific tile. Look in the notetags section below for the * notetag setup on how to make a specific region ID play a footstep sound. * * To sum it up, from lowest to highest priority: * * LOWEST - Default Footstep Sound * Terrain Tag Footstep Sound * HIGHEST - Region-Based Footstep Sound * * If you wish to give a whole map a certain footsteps sound, use the notetag * to set a region-based footstep sound for region ID 0. * * ============================================================================ * Notetags * ============================================================================ * * Insert the following notetags to add footsteps to your maps. * * Event Notetag: * * <No Footsteps> * - Insert this into the notebox of any event you wish to not make any * footsteps when moving. * * Tileset Notetags: * * <Terrain Tag x Footstep Sound: filename> * <Terrain Tag x Footstep Sound: filename, volume> * <Terrain Tag x Footstep Sound: filename, volume, pitch> * - Replace 'x' with the terrain tag ID (from 1 to 7). If 0 is used, it will * be ignored. When inserting the filename, the filename must be case * sensitive and must not include the extension. The 'volume' and 'pitch' * variables must be integar values between 0 and 100 if they are used. * * Examples: * * <Terrain Tag 1 Footstep Sound: Move1> * <Terrain Tag 2 Footstep Sound: Move2, 80> * <Terrain Tag 3 Footstep Sound: Move3, 75, 150> * * In the above examples, the tiles marked by terrain tags 1, 2, or 3 will * play their respective sound effect when stepped on by the player or an * event that can trigger footsteps. * * Map Notetags: * * <Region x Footstep Sound: filename> * <Region x Footstep Sound: filename, volume> * <Region x Footstep Sound: filename, volume, pitch> * - Replace 'x' with the region tag ID (from 1 to 255). If 0 is used, it * will become the default footstep sound. When inserting the filename, the * filename must be case sensitive and must not include the extension. The * 'volume' and 'pitch' variables must be integar values between 0 and 100 if * they are used. * * Examples: * * <Region 10 Footstep Sound: Move1> * <Region 20 Footstep Sound: Move2, 80> * <Region 30 Footstep Sound: Move3, 75, 150> * * In the above examples, the tiles marked by regions 10, 20, or 30 will play * their respective sound effect when stepped on by the player or an event * that can trigger footsteps. * * ============================================================================ * Plugin Commands * ============================================================================ * * If at any time you wish to enable/disable footstep sounds in your game, you * can use some plugin commands to do so. * * Plugin Commands: * * EnableFootsteps * - Turns on footstep sounds. * * DisableFootsteps * - Turns off footstep sounds. *///=============================================================================//=============================================================================// Parameter Variables//=============================================================================Yanfly.Parameters = PluginManager.parameters('YEP_FootstepSounds');Yanfly.Param = Yanfly.Param || {};Yanfly.Param.Footsteps = { defaultSound: String(Yanfly.Parameters['Default Sound']), defaultVolume: Number(Yanfly.Parameters['Default Volume']), defaultPitch: Number(Yanfly.Parameters['Default Pitch']), PlayerEnable: eval(String(Yanfly.Parameters['Player Enable'])), PlayerVolume: parseFloat(Yanfly.Parameters['Player Volume']), PlayerPitch: parseFloat(Yanfly.Parameters['Player Pitch']), EventEnable: eval(String(Yanfly.Parameters['Event Enable'])), EventVolume: parseFloat(Yanfly.Parameters['Event Volume']), DistanceVolume: parseFloat(Yanfly.Parameters['Distance Volume']), EventPitch: parseFloat(Yanfly.Parameters['Event Pitch']), DistancePitch: parseFloat(Yanfly.Parameters['Distance Pitch']), DistancePan: parseInt(Yanfly.Parameters['Distance Pan'])};//=============================================================================// DataManager//=============================================================================Yanfly.Footsteps.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;DataManager.isDatabaseLoaded = function() { if (!Yanfly.Footsteps.DataManager_isDatabaseLoaded.call(this)) return false; if (!Yanfly._loaded_YEP_FootstepSounds) { this.processFootstepNotetags($dataTilesets); Yanfly._loaded_YEP_FootstepSounds = true; } return true;};DataManager.processFootstepNotetags = function(group) { for (var n = 1; n < group.length; n++) { var obj = group[n]; var notedata = obj.note.split(/[\r\n]+/); obj.terrainTagFootstepSounds = { 0: [ Yanfly.Param.Footsteps.defaultSound, Yanfly.Param.Footsteps.defaultVolume, Yanfly.Param.Footsteps.defaultPitch ] }; for (var i = 0; i < notedata.length; i++) { var line = notedata[i]; if (line.match(/<TERRAIN[ ]TAG[ ](\d+)[ ]FOOTSTEP SOUND:[ ](.*)>/i)) { var tagId = parseInt(RegExp.$1).clamp(1, 7); var footstepData = String(RegExp.$2).split(','); footstepData[0] = footstepData[0].trim(); footstepData[1] = footstepData[1] || Yanfly.Param.Footsteps.defaultVolume; footstepData[1] = parseInt(footstepData[1]); footstepData[2] = footstepData[2] || Yanfly.Param.Footsteps.defaultPitch; footstepData[2] = parseInt(footstepData[2]); obj.terrainTagFootstepSounds[tagId] = footstepData; } } }};DataManager.processMapFootstepNotetags = function() { if (!$dataMap) return; $dataMap.regionFootstepSounds = { 0: [ Yanfly.Param.Footsteps.defaultSound, Yanfly.Param.Footsteps.defaultVolume, Yanfly.Param.Footsteps.defaultPitch ] }; if (!$dataMap.note) return; var notedata = $dataMap.note.split(/[\r\n]+/); for (var i = 0; i < notedata.length; i++) { var line = notedata[i]; if (line.match(/<REGION[ ](\d+)[ ]FOOTSTEP SOUND:[ ](.*)>/i)) { var regionId = parseInt(RegExp.$1).clamp(0, 255); var footstepData = String(RegExp.$2).split(','); footstepData[0] = footstepData[0].trim(); footstepData[1] = footstepData[1] || Yanfly.Param.Footsteps.defaultVolume; footstepData[1] = parseInt(footstepData[1]); footstepData[2] = footstepData[2] || Yanfly.Param.Footsteps.defaultPitch; footstepData[2] = parseInt(footstepData[2]); $dataMap.regionFootstepSounds[regionId] = footstepData; } }};//=============================================================================// Game_System//=============================================================================Yanfly.Footsteps.Game_System_initialize = Game_System.prototype.initialize;Game_System.prototype.initialize = function() { Yanfly.Footsteps.Game_System_initialize.call(this); this.initFootstepSettings();};Game_System.prototype.initFootstepSettings = function() { this._footstepsEnabled = true;};Game_System.prototype.canHearFootsteps = function() { if (this._footstepsEnabled === undefined) this.initFootstepSettings(); return this._footstepsEnabled;};Game_System.prototype.setHearFootsteps = function(value) { if (this._footstepsEnabled === undefined) this.initFootstepSettings(); this._footstepsEnabled = value;};//=============================================================================// Game_Interpreter//=============================================================================Yanfly.Footsteps.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;Game_Interpreter.prototype.pluginCommand = function(command, args) { Yanfly.Footsteps.Game_Interpreter_pluginCommand.call(this, command, args); if (command === 'EnableFootsteps') { $gameSystem.setHearFootsteps(true); } else if (command === 'DisableFootsteps') { $gameSystem.setHearFootsteps(false); }};Game_Interpreter.prototype.argsToString = function(args) { var str = ''; var length = args.length; for (var i = 0; i < length; ++i) { str += args[i] + ' '; } return str.trim();};//=============================================================================// Game_Map//=============================================================================Yanfly.FootstepsGame_Map_setup = Game_Map.prototype.setup;Game_Map.prototype.setup = function(mapId) { if ($dataMap) DataManager.processMapFootstepNotetags(); Yanfly.FootstepsGame_Map_setup.call(this, mapId);};//=============================================================================// Game_CharacterBase//=============================================================================Yanfly.Footsteps.Game_CharacterBase_increaseSteps = Game_CharacterBase.prototype.increaseSteps;Game_CharacterBase.prototype.increaseSteps = function() { Yanfly.Footsteps.Game_CharacterBase_increaseSteps.call(this); if (this !== $gamePlayer) { this.processFootstepSound(); }};Game_CharacterBase.prototype.canPlayFootsteps = function() { if (!$gameSystem.canHearFootsteps()) return false; if (this._canPlayFootsteps !== undefined) return this._canPlayFootsteps; this._canPlayFootsteps = Yanfly.Param.Footsteps.EventEnable; return this._canPlayFootsteps;};Game_CharacterBase.prototype.processFootstepSound = function() { if (this.canPlayFootsteps() && $gameSystem.canHearFootsteps()) { var player = $gamePlayer; var distance = $gameMap.distance(this.x, this.y, player.x, player.y); var volume = Yanfly.Param.Footsteps.EventVolume || 0; volume += distance * Yanfly.Param.Footsteps.DistanceVolume; var pitch = Yanfly.Param.Footsteps.EventPitch || 0; pitch += distance * Yanfly.Param.Footsteps.DistancePitch; var pan = 0; pan -= $gameMap.deltaX(this.x, player.x); this.playFootstepSound(volume, pitch, pan); };};Game_CharacterBase.prototype.playFootstepSound = function(volume, pitch, pan) { if (volume <= 0) return; if (pitch <= 0) return; if (!$dataMap) return; if (!$dataMap.regionFootstepSounds) DataManager.processMapFootstepNotetags(); var x = this.x; if (this.x === 6) { x += 1; } else if (this.x === 4) { x -= 1; } var y = this.y; if (this.y === 2) { y += 1; } else if (this.y === 8) { y -= 1; } var regionId = $gameMap.regionId(x, y) var terrainTag = $gameMap.terrainTag(x, y); if (regionId > 0) { var footstepData = $dataMap.regionFootstepSounds[regionId]; } if (!footstepData && terrainTag > 0) { var footstepData = $gameMap.tileset().terrainTagFootstepSounds[terrainTag]; } if (!footstepData) footstepData = $dataMap.regionFootstepSounds[0]; var se = { name: footstepData[0], volume: footstepData[1] * volume, pitch: footstepData[2] * pitch, pan: pan.clamp(-100, 100) }; AudioManager.playSe(se);};//=============================================================================// Game_Player//=============================================================================Yanfly.Footsteps.Game_Player_increaseSteps = Game_Player.prototype.increaseSteps;Game_Player.prototype.increaseSteps = function() { Yanfly.Footsteps.Game_Player_increaseSteps.call(this); this.processFootstepSound();};Game_Player.prototype.canPlayFootsteps = function() { if (!$gameSystem.canHearFootsteps()) return false; if (!this.isNormal()) return false; return Yanfly.Param.Footsteps.PlayerEnable;};Game_Player.prototype.processFootstepSound = function() { if (this.canPlayFootsteps()) { var volume = Yanfly.Param.Footsteps.PlayerVolume || 0; var pitch = Yanfly.Param.Footsteps.PlayerPitch || 0; var pan = 0; this.playFootstepSound(volume, pitch, pan); };};//=============================================================================// Game_Event//=============================================================================Game_Event.prototype.canPlayFootsteps = function() { if (!$gameSystem.canHearFootsteps()) return false; if (this._canPlayFootsteps !== undefined) return this._canPlayFootsteps; this._canPlayFootsteps = Yanfly.Param.Footsteps.EventEnable; var note = this.event().note; if (note.match(/<NO FOOTSTEPS>/i)) this._canPlayFootsteps = false; return this._canPlayFootsteps;};//=============================================================================// Game_Follower//=============================================================================Game_Follower.prototype.canPlayFootsteps = function() { if (!this.isVisible()) return false; return Game_Character.prototype.canPlayFootsteps.call(this);};//=============================================================================// End of File//============================================================================= |