Remote Event Counting and Control by Name *dead, see Universal Remote Control*
Remote Event Counting and Controlby Dahlys
Download Link
*Update 09/24: This plugin is dead. Please see my Universal Remote Control instead
Introduction:
Count number of events with Event Name = "insert_name" and store their event IDs into an array.
Remotely activate self-switches based on event names.
Features:
[*]Count the number and log the IDs of Event Names containing the word(s) of interest.
[*]e.g. If all NPCs have NPC in their event name, you can store their Event IDs in a variable as an array. The total number of NPCs on the map can also be stored into a variable.
[*]An array of strings ["Tom", "Dick", "Harry"] can be used as input as well as individual strings "Tom", "Dick", "Harry"
[*]Remote control Self-switches by matching Event Names, works for Yanfly's self-switch plugin!
[*]e.g. If all children have "child" in their event name, you can turn on their self-switch to make them all flee from you at once in a game of tag. No need for a common event/global switch and parallel processes all over the place.
[*]e.g. If you type a string or array of strings into a variable (via another plugin (http://biud436.tistory.com/58) or script call), you can drop a lightning bolt on "EnterNameHere" anywhere on the same map.
[*]Set your own conditions to whether the Event ID will be included or not.
[*]Some javascript knowledge required
[*]Script calls from other plugins can be used in conditions. I have not yet found any conflicts with Yanfly, LTN, Galv, Hime, Khas, and Orange.
[*]e.g. Choose to exclude dead NPCs who have self-switch "D" on.
[*]Once Event IDs are stored in a variable, they can be used as a source array for further functions. This prevents having to loop through every single event on the map when you just want to activate/search through a subset of events.
[*]More detail on plugin functions and usage is found in the plugin help box.
[*]Please read carefully especially when using conditions involving Event IDs. e.g. Checking if their dead/alive self-switch is on. Also watch out for special javascript characters.
Screenshots:
https://i.imgur.com/dzPqVdK.gif
How to use:
Dump the .js file in your project plugins folder and add it to your plugin manager. The order this plugin is loaded shouldn't matter.
Thanks to:
Soulpour777 for his scripting tutorial!
Author's Notes:
Spoiler: My Script Calls: Before and AfterMy script calls used to look like:
Code:
//On map entry
var npc = [];
for (i = 1; i < 999; i++) {
if ($dataMap.events == null) {
break;
}
else if ($dataMap.events.name.includes("NPC") && !this.getSelfSwitchValue(this._mapId, i, 18)) {
npc.push(i);
}
}
$gameVariables.setValue(65, npc)
$gameVariables.setValue(64, npc.length)
//Parallel common event
var npc = $gameVariables.value(65);
var nearby = [];
for (i = 0; i < npc.length; i++) {
if (Galv.DETECT.event(npc,$gameVariables.value(11),true) && $dataMap.events].name.includes("Policeman") && !this.getSelfSwitchValue(this._mapId, npc, 18)) {
nearby.push(npc);
}
}
if (nearby.length > 0) {$gameVariables.setValue(83, nearby)}
for (i = 0; i < npc.length; i++) {
if (Galv.DETECT.event(npc,$gameVariables.value(11),true) && $dataMap.events].name.includes("FBI") && !this.getSelfSwitchValue(this._mapId, npc, 18)) {
nearby.push(npc);
}
}
if (nearby.length > 0) {$gameVariables.setValue(84, nearby)}
var victimfamilies = $gameVariables.value(85);
for (i = 0; i < npc.length; i++) {
for (j = 0; j < victimfamilies.length; j++) {
if (Galv.DETECT.event(npc, $gameVariables.value(11), true) && $dataMap.events].name.includes(victimfamilies) && this.getSelfSwitchValue(this._mapId, npc, 18) == false) {
nearby.push(npc);
}
}}
if (nearby.length > 0) {$gameVariables.setValue(86, nearby)}
...Okay, bad. And I do this OVER and OVER again?
What the script calls now look like:
Code:
this.countevent("NPC", 64, 65, "!this.getSelfSwitchValue(this._mapId, id, 18)");
this.counteventarray("Policeman", 0, 83, 65, "Galv.DETECT.event(sourcearray,$gameVariables.value(11),true) && !this.getSelfSwitchValue(this._mapId, sourcearray, 18)");
this.counteventarray("FBI", 0, 84, 65, "Galv.DETECT.event(sourcearray,$gameVariables.value(11),true) && !this.getSelfSwitchValue(this._mapId, sourcearray, 18)");
var victimfamilies = $gameVariables.value(85);
this.counteventarray(victimfamilies, 0, 86, 65, "Galv.DETECT.event(sourcearray,$gameVariables.value(11),true) && !this.getSelfSwitchValue(this._mapId, sourcearray, 18)");
Er... Somewhat better I guess!?
I hope this plugin will be helpful to some people! This has been super useful to me in shortening script calls in my "Police vs Thief" game.
If you look through the script, it's not the most elegant thing. I highly welcome any suggestions to improve. This is my first ever rpg maker plugin, and my first time writing in javascript (I used to use the monster called C++, that was 5 years ago when I was still in school). Perhaps the next update will add more functions such as the ability to activate multiple switches. I've been playing with rmmv for... 2 weeks?
本贴来自国际rpgmaker官方论坛作者:dahlys处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/remote-event-counting-and-control-by-name-dead-see-universal-remote-control.84152/
页:
[1]