じ☆ve冰风 发表于 4 天前

Eventing Respawning Foraging Nodes and Enemies Using Script Calls

Hello! In this tutorial we will be using events to represent on-map enemy encounters and foraging/mining nodes, turning on their self switch after the event executes, then call a common event at some point (like using an inn) to reset the self switches for those events on their map to allow them to "respawn" or "replenish".

The alternative method I've heard of to do this and have previously used involves designating a variable for each node/enemy to check if they've been depleted/killed (set to 1) and the empty 2nd event page triggers when the var is 1, then resetting (all the variables within a range) to zero in a common event for them to respawn. It is probably easier to do that, but it would take up valuable variable slots if you expect a looooooot of forage/ore nodes and enemies in your game, so I tested the script call to modify self switches "remotely" in a common event, it worked, and I use this system now.

According to the script call megasheet, this tutorial could also work in MZ since MZ seems to use the same script calls as MV. Some more useful script calls like the one in this tutorial can be found there too. I found that it's sometimes faster to fill in the blank for some of these rather than clicking a hundred times in the eventing commands menu to do something simple lol.






For enemies, the first page should look like the first picture, and the second event page should look like the second.
The first page turns on the self switch A after winning the battle so that event page 2 triggers and the enemy despawns.




Making foraging and ore nodes should have similar event pages just without the battle processing.

https://forums.rpgmakerweb.com/attachments/1629856670743-png.199484/


Take note of the event id on the upper left corner within the event editor.




Exit the event editor and check the lower left corner of the map editor, take note of the map id the event is located on.





Now we will put these values in a script call in the common event you designate to reset these events.





Paste and modify the template into the script call box.

var key = $gameSelfSwitches.setValue(key, false);

Replace map Id and eventId with their respective numbers.

Example:
var key = $gameSelfSwitches.setValue(key, false);

((The comment is just there to provide a template for you to be able to quickly copy and paste from instead of having to refer to the script call sheet again and again.





Add another script call for each event that needs to respawn within that common event.

And call that common event whenever you need them to respawn.





There you have it, a way to use control self switch script calls to remotely reset self switches of events.
I'd also recommend keeping track of these event and map ids on a spreadsheet so you know which events whose self switches need to be turned back off, or whenever you want to make a change to any of them.

If you would like to do it the more efficient way, you could also directly use the script call:

$gameSelfSwitches.setValue(, false)


本贴来自国际rpgmaker官方论坛作者:desertbriar处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/eventing-respawning-foraging-nodes-and-enemies-using-script-calls.139863/
页: [1]
查看完整版本: Eventing Respawning Foraging Nodes and Enemies Using Script Calls