Skip to content

Instantly share code, notes, and snippets.

@triacontane
Created October 19, 2023 14:30
Show Gist options
  • Save triacontane/118577fcf035a880aa0ba47d349624d3 to your computer and use it in GitHub Desktop.
Save triacontane/118577fcf035a880aa0ba47d349624d3 to your computer and use it in GitHub Desktop.
天候に応じたスイッチの自動切り替え
/*:
* @plugindesc 天候に応じたスイッチの自動切り替え
* @author ChatGPT
* @target MZ
*
* @param Rain Switch
* @text 雨スイッチID
* @desc 雨のときにONになるスイッチのID
* @type switch
* @default 1
*
* @param Storm Switch
* @text 嵐スイッチID
* @desc 嵐のときにONになるスイッチのID
* @type switch
* @default 2
*
* @param Snow Switch
* @text 雪スイッチID
* @desc 雪のときにONになるスイッチのID
* @type switch
* @default 3
*
* @help
* このプラグインを使うと、天候に応じてスイッチが自動で切り替わります。
*/
(() => {
const parameters = PluginManager.parameters('WeatherSwitch');
const rainSwitch = Number(parameters['Rain Switch'] || 1);
const stormSwitch = Number(parameters['Storm Switch'] || 2);
const snowSwitch = Number(parameters['Snow Switch'] || 3);
const _Game_Screen_changeWeather = Game_Screen.prototype.changeWeather;
Game_Screen.prototype.changeWeather = function(type, power, duration) {
_Game_Screen_changeWeather.call(this, type, power, duration);
this.updateWeatherSwitch(type);
};
Game_Screen.prototype.updateWeatherSwitch = function(weatherType) {
$gameSwitches.setValue(rainSwitch, false);
$gameSwitches.setValue(stormSwitch, false);
$gameSwitches.setValue(snowSwitch, false);
switch (weatherType) {
case 'rain':
$gameSwitches.setValue(rainSwitch, true);
break;
case 'storm':
$gameSwitches.setValue(stormSwitch, true);
break;
case 'snow':
$gameSwitches.setValue(snowSwitch, true);
break;
}
};
})();
@triacontane
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment