Eventing a Foraging System

You can grab the plugins used in this video here:
你需要使用的插件:
[Event Copier]
[Self Switches & Variables]

Eventing a foraging system might sound pretty basic at first. Just make an event where you can grab some berries from a bush, turn on a self switch, and then call it a day. But once you’ve decided to give them the ability to respawn after a number of days, it suddenly becomes a lot more complex. This tutorial video will cover how to create a foraging system complete with respawning from the ground up!
种植系统核心很简单,从灌木丛中抓取一些浆果,打开自动开关,然后等待。但是,如果你想让让他们在几天之后重新生长,就会有些复杂。本教程将介绍如何创建一个从头开始重新生成的种植系统!

You can grab the copy/paste code here:
For those who wish to acquire the script call used, you can get it from here. Change the values in red to fit your game’s settings.
您可以直接在此处获取复制/粘贴代码:

var mapId = $ gameVariables.value(1); //此变量包含地图ID。
var eventId = $ gameVariables.value(2); //此变量包含事件ID。
var varId = 41 ; //这是您用于重生的自变量ID。

// Update the self variable: Respawn Day's value. 更新自变量重生天数的值。
var value = this.getSelfVariableValue(mapId,eventId,varId);
if(value> 0)value  -  = 1;
this.setSelfVariableValue(mapId,eventId,varId,value);

For those who would like to see the structures of the events and common events used, look below:
对于那些希望深入了解事件的人,请看下面的内容:


Berry Bush – Event


◆Comment:// Calculate a random number to determine yield
◆Control Variables:#0001 Temp Variable 1 = Random 2..8
◆Comment:// Player acquires the random number
◆Change Items:Berry + {Temp Variable 1}
◆Comment:// Set the number of days to wait before respawning berries
◆Control Variables:#0041 Self Var Respawn Days = 3
◆Comment:// Play a sound effect and show a message.
◆Play SE:Item1 (90, 100, 0)
◆Text:None, Dim, Bottom
:Text:
:Text:\>            \

Remember to make a second page with the variable condition set to the Self Variable: Respawn Days.
请记住创建第二页,其中变量条件设置为自变量:Respawn Days。


Sleep – Common Event


◆Comment:// This common event is used whenever the player
:Comment:approaches a bed that they can sleep in. For the
:Comment:time being, it'll only work from the cave's bed.
◆Comment:// Ask player about going to sleep
◆Text:None, Dim, Bottom
:Text:
:Text:\>            \

Night Cycle – Common Event


◆Comment:// The purpose of the Night Cycle common event is to cycle
:Comment:through all of the common events that are used to update
:Comment:the various event systems in place for the game.
◆Common Event:Update Day Respawns

Update Day Respawns – Common Event


◆Comment:// This event is called by the Night Cycle. It is used
:Comment:to update the number of days left on each event that
:Comment:uses the Self Variable: Respawn Days
◆Comment:
:Comment:// Update variable 1 with the Map ID to update the Respawn Days for.
:Comment:Then, run the Respawn Day Cycler common event.
◆Comment:
:Comment:// Map 14: Around the Cave
◆Control Variables:#0001 Temp Variable 1 = 14
◆Common Event:Respawn Day Cycler
◆Comment:
:Comment:// Map 25: Another Map
◆Control Variables:#0001 Temp Variable 1 = 25
◆Common Event:Respawn Day Cycler
◆Comment:
:Comment:// Map 36: Yet Another Map
◆Control Variables:#0001 Temp Variable 1 = 36
◆Common Event:Respawn Day Cycler
◆Comment:
:Comment:// * Note: Don't worry if the Map ID doesn't exist.
:Comment:// This will not crash your game.

Respawn Day Cycler – Common Event


◆Comment:// This event is used to cycle through the many events
:Comment:found on each map and to see if the Self Variable named
:Comment:Respawn Days needs to be updated.
◆Comment:
:Comment:// Variable 2: The current Event ID being checked. Start at 1.
:Comment:   Variable 3: The maximum Event ID that needs to be checked. Usually 999.
◆Control Variables:#0002 Temp Variable 2 = 1
◆Control Variables:#0003 Temp Variable 3 = 999
◆Comment:// Create the loop.
◆Loop
  ◆Comment:// Make a script call that gathers the value of the currently looped event ID.
  ◆Script:var mapId = $gameVariables.value(1); // This variable contains the Map ID.
  :Script:var eventId = $gameVariables.value(2); // This variable contains the Event ID.
  :Script:var varId = 41; // This is the self variable ID you're using for Respawn Days.
  :Script:
  :Script:// Update the self variable: Respawn Day's value.
  :Script:var value = this.getSelfVariableValue(mapId, eventId, varId);
  :Script:if (value > 0) value -= 1;
  :Script:this.setSelfVariableValue(mapId, eventId, varId, value);
  ◆Comment:// Increase the current Event ID at the end of each loop.
  ◆Control Variables:#0002 Temp Variable 2 += 1
  ◆If:Temp Variable 2 > Temp Variable 3
    ◆Comment:// If the current Event ID bypasses the maximum Event ID, break the loop.
    ◆Break Loop
    ◆
  :End
  ◆
:Repeat Above

And that’s all! These are the basic and common events used to event a foraging system!
就这样!这些是用于种植系统的基本和常见事件!

Happy RPG Making!

你可能感兴趣的:(Eventing a Foraging System)