Original Source
- Original title: Solarflare's Miscellaneous Plugins [SFG]
- Original author: Solar_Flare
- Original date: June 13, 2020
- Source thread: https://forums.rpgmakerweb.com/threads/solarflares-miscellaneous-plugins-sfg.122826/
- Source forum path: Game Development Engines > RPG Maker Javascript Plugins > JS Plugin Releases (RMMV)
Summary
, #2) :When 1 ◆Text:None, Window, Bottom :Text:First time!
Archived First Post
I've posted a few plugins in the Plugin Request forum already, so I thought it would be a good idea to gather them all in one place. This thread will only be for small and simple plugins - if I release something big or complex I'll create another thread. Some of my plugins depend on having SFG_Utils installed above them, so if a plugin doesn't work, try installing SFG_Utils before posting a bug report.
Unless otherwise noted, these plugins are not compatible with MZ. If the links below are broken, all these plugins (plus the work-in-progress localization plugin in my signature) can also be found on my website. Some of my plugins can also be downloaded from itch.io. I'll be adding more there bit by bit.
Download Link
Itch Link
Download Link
This plugin is also compatible with RPGMaker MZ.
Download Link
Download Link
This plugin is also compatible with RPGMaker MZ.
Download Link
Itch Link
This plugin is also compatible with RPGMaker MZ.
Download Link
This plugin is also compatible with RPGMaker MZ.
Download Link
Itch Link
This plugin is also compatible with RPGMaker MZ.
Download Link
Main Thread
This plugin is also compatible with RPGMaker MZ.
Download Link
Download Link
Download Link
This plugin is also compatible with RPGMaker MZ.
Download Link
Itch Link
Main Thread
Download Link
Alternatively, copy-paste the following code into a text file and name it SFG_PassiveStates.js:
/*:
@plugindesc [1.0] Allows you to set states to be applied based on arbitrary conditions.
@author Solarflare Software
@help
Use the following note tag to turn a state into a passive state:
<activeif:true> (states)
This state is automatically added or removed based on the given condition.
As with a damage formula, the actor can be referenced as a.
Game variables are also available as v and switches as s.
The state object itself can be accessed as state.
*/
var Imported = Imported || {};
(function() {
var conditionalStates = [];
var old_startup = Scene_Boot.prototype.start;
Scene_Boot.prototype.start = function() {
old_startup.call(this);
for(var i = 1; i < $dataStates.length; i++) {
if($dataStates[i].meta.activeif)
conditionalStates.push(i);
}
};
Game_BattlerBase.prototype.isStateConditionallyActive = function(stateId) {
if(this.isStateResist(stateId)) return false;
var state = $dataStates[stateId];
if(!state) return false;
var cond = state.meta.activeif;
if(cond) {
let locals = {
state: state,
a: this,
};
try {
return !!Utils.eval(cond, locals);
} catch(e) {}
}
return false;
};
const old_globalUpdate = Scene_Base.prototype.update;
Scene_Base.prototype.update = function() {
old_globalUpdate.call(this);
$gameParty.refreshPassiveStates();
$gameTroop.refreshPassiveStates();
};
const old_isStateAddable = Game_Battler.prototype.isStateAddable;
const old_removeState = Game_Battler.prototype.removeState;
Game_Battler.prototype.isStateAddable = function(state) {
if(conditionalStates.includes(state))
return this.isStateConditionallyActive(state);
return old_isStateAddable.call(this, state);
};
Game_Battler.prototype.removeState = function(state) {
if(conditionalStates.includes(state) && this.isStateConditionallyActive(state))
return;
old_removeState.call(this, state);
};
Game_Battler.prototype.requestPassiveStateRefresh = function() {
this._needsPassiveStateUpdate = true;
this.friendsUnit()._needsPassiveStateUpdate = true;
};
Game_Battler.prototype.refreshPassiveStates = function() {
this._needsPassiveStateUpdate = false;
for(let i = 0; i < conditionalStates.length; i++) {
let stateId = conditionalStates[i];
if(this.isStateConditionallyActive(stateId))
this.addState(stateId);
else this.removeState(stateId);
}
};
// Should also override isStateAddable to return false if the condition is not satisfied, and removeState to not remove it if the condition is still satisfied.
Game_Unit.prototype.requestPassiveStateRefresh = function() {
this._needsPassiveStateUpdate = true;
this.members().forEach(who => who.requestPassiveStateRefresh());
};
Game_Unit.prototype.refreshPassiveStates = function() {
if(!this._needsPassiveStateUpdate) return;
this._needsPassiveStateUpdate = false;
this.members().forEach(function(who) {
if(who._needsPassiveStateUpdate)
who.refreshPassiveStates();
});
};
Game_Troop.prototype.refreshPassiveStates = function() {
if(this.inBattle()) Game_Unit.prototype.refreshPassiveStates.call(this);
};
Game_Party.prototype.refreshPassiveStates = function() {
// Refresh on all members, even in battle
var inBattle = this.inBattle();
this._inBattle = false;
Game_Unit.prototype.refreshPassiveStates.call(this);
this._inBattle = inBattle;
};
const updateParty = () => $gameParty.requestPassiveStateRefresh();
const updateAll = () => {$gameParty.requestPassiveStateRefresh(); $gameTroop.inBattle() && $gameTroop.requestPassiveStateRefresh()};
const refreshMethods = [
{
class: Game_Battler,
methods: ['onAllActionsEnd', 'onTurnEnd', 'onBattleStart', 'onBattleEnd', 'refresh'],
},
{
class: Game_Actor,
check: (self, skill) => self.isLearnedSkill(skill),
methods: ['learnSkill', 'forgetSkill'],
},
{
class: Game_Enemy,
methods: ['appear'],
},
{
class: Game_Party,
methods: ['gainGold', 'gainItem'],
},
{
class: Game_Player,
update: updateParty,
methods: ['refresh'],
},
{
class: Game_Player,
check: (self) => self.isInVehicle(),
update: updateParty,
methods: ['getOnOffVehicle'],
},
{
class: Game_Event,
update: updateParty,
methods: ['refresh'],
},
{
class: Game_CharacterBase,
update: updateParty,
methods: ['increaseSteps', 'setPosition', 'copyPosition'],
},
{
class: Game_Switches,
update: updateAll,
methods: ['onChange'],
},
{
class: Game_Variables,
update: updateAll,
methods: ['onChange'],
},
{
class: Game_SelfSwitches,
update: updateAll,
methods: ['onChange'],
},
];
if(Imported.TH_SelfVariables) {
refreshMethods.push({
class: Game_SelfVariables,
update: updateAll,
methods: ['onChange'],
});
}
for(let cls of refreshMethods) {
let proto = cls.static ? cls.class : cls.class.prototype;
for(let fcn of cls.methods) {
let old = Utils.makeAliasProxy(cls.class, fcn);
let check = cls.check ? cls.check : (self) => {};
let update = cls.update ? cls.update : (self) => self.requestPassiveStateRefresh();
proto[fcn] = function() {
var before = check(this);
old(this, ...arguments);
if(before === undefined || before != check(this, ...arguments)) {
update(this);
}
};
}
}
})()
Main Thread
This plugin is also compatible with RPGMaker MZ.
Download Link
This plugin is also compatible with RPGMaker MZ.
Here's a contrived example of its use:
◆Control Variables:#0019 += 1
◆Plugin Command:switch @19
◆Show Choices:1, 2, 3, #4~8, 9, 10 (Window, Right, #1, #2)
:When 1
◆Text:None, Window, Bottom
:Text:First time!
◆
:When 2
◆Text:None, Window, Bottom
:Text:Second time!
◆
:When 3
◆Text:None, Window, Bottom
:Text:Third time!
◆
:When #4~8
◆Text:None, Window, Bottom
:Text:Maybe you should stop this...
◆
:When 9
◆Text:None, Window, Bottom
:Text:Calm down, that's already nine times!
◆
:When 10
◆Text:None, Window, Bottom
:Text:And now it's your tenth time!
◆
:End
◆Show Choices:#(value % 5 == 1), 20, >30 (Window, Right, #1, -)
:When #(value % 5 == 1)
◆Text:None, Window, Bottom
:Text:I'm really at a loss for words.
◆Plugin Command:switch @19
◆Show Choices:>100, >45 (Window, Right, #1, #2)
:When >100
◆Text:None, Window, Bottom
:Text:Are you serious!? You've exceeeded one hundred!!!
◆
:When >45
◆Text:None, Window, Bottom
:Text:No really, stop it!
◆
:End
◆
:When 20
◆Text:None, Window, Bottom
:Text:Twentieth time already!? Are you mad!?
◆
:When >30
◆Text:None, Window, Bottom
:Text:More than thirty times! Just... just stop!
◆
:When Cancel
◆Text:None, Window, Bottom
:Text:This is starting to get crazy...
◆
:End
And another example using strings:
◆Name Input Processing:Harold, 8 characters
◆Plugin Command:switch $gameActors.actor(1).name()
◆Show Choices:"Harold", #"x"~"zzzzzzz", ~"[aeiou]{3,}" (Window, Right, #1, -)
:When "Harold"
◆Text:None, Window, Bottom
:Text:The default, good choice!
◆
:When #"x"~"zzzzzzz"
◆Text:None, Window, Bottom
:Text:That's quite a rare name...
◆
:When ~"[aeiou]{3,}"
◆Text:None, Window, Bottom
:Text:So many vowels!
◆
:When Cancel
◆Text:None, Window, Bottom
:Text:Not a bad choice!
◆
:End
Download Link
This plugin is also compatible with RPGMaker MZ.
Download Link
Mods or Add-ons to Other Plugins
To enable it, set DataSource Type to Book Files in the TAA_BookMenu configuration.
Download Link
Terms of Use
- You don't need to credit me in the game credits or anything. However, don't remove me from the "author" field in the plugin file. If you do wish to credit me, you can do so as "Solar Flare" or "Solarflare Software".
- You can use these plugins in commercial or non-commercial games, free of charge.
- Feel free to modify these plugins however you need for your game. Exception: Do not modify SFG_Utils for any reason. If you need something added to or altered in SFG_Utils, just create a new plugin.
- If a plugin that I created is not listed in this thread, or if the listing in this thread links to another thread that specifies different terms, these terms of use do not apply to it.
- You may port these plugins to MZ as long as a port isn't already available in my MZ plugins thread and you change the filename to remove the SFG_ prefix (to avoid making it appear to be an official port; you may add your own prefix if you wish). You still need to leave me in the "author" field in the plugin file.
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadLicense / Terms Note
Terms of Use You don't need to credit me in the game credits or anything. However, don't remove me from the "author" field in the plugin file. If you do wish to credit me, you can do so as "Solar Flare" or "Solarflare Software". You can use these plugins in commercial or non-commercial games, free of charge. Feel free to modify these plugins however you need for your game. Exception: Do not modify SFG_Utils for any reason. If you need...
Creator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...