What's new in the RPG Creation Kit 2
In this page you'll find an explanation of the new systems and changes that arrived with the release of the RPG Creation Kit 2.0.
Show/Hide Demo Files
The first change to the Editor Tools is the addition of a toggle named "Show Demo Files?". When toggled on, the respective Editor (such as "Rck Object Viewer", "Cell View", "Quests", "Rck AI Editor", etc.) will show files related to the Rck Demo. As you can imagine, toggling it off will hide from the lists content related to the demo.
This will be pretty useful when you'll be deep into creating your own content and the Rck items will get in your way as you're trying to find or search for things.
Each asset that can be hidden has now a flag "IS_DEMO_FILE", that will act as the flag that hides/show results:
So as you'll make new content it will be enough to disable this flag for your own items.
You can also set the default value for the "Show Demo Files?" toggle to be on/off whenever you open your project by going in "Edit->Project Settings-RPG Creation Kit" and setting the value of the toggle there. Setting it off will make sure that whenever you open a window like the "Rck AI Editor" the demo files will be set to be hidden by default.
Toolbar Functions
The main toolbar, located in the upper part of the Editor, will now have three more buttons related to the RPG Creation Kit:
- Load Last Save: allows you to Start playing in the Editor and automatically loads the latest savegame (or autosave) you have. It's an incredibly helpful tool that allows you to quickly jump in game to view your edits.
- Load Last Cell: does the opposite. It loads the last cell that you've loaded via the Cell View or Cell Map View. It's best used along with the Load Last Save button t.
- Adjust Time Of Day (ToD) Preview: is a slider that sets the Time of Day for your selected "Time of Day Sky Material" (set in the Project Settings). It sets the "currentTime" value in the Sky's material and it updates the scene lighting in base of this value. It's useful to preview a Cell (or many cells) in the Editor at any given time of the day.
Time of Day
The Time of Day feature adds the concept of time inside of the RCK.
Days consist of 24hrs and there's currently no convention for Days/Months/Years, which is something that can be extended from this system.
A GameObject named "TimeOfDayManager" has been added to the _WorldLoader_ scene, and it has a component with the same name as the Object that is, in fact, the manager of the time system.
- Current Time [0-24]: explicit the current time of the day. This can be set when the game starts, when a save game loads, and it can be arbitrarily set from other scripts. For example, the script "JustAnotherDeliveryStage10".
- Hours and Minutes: are derived from the Current Time, and they're useful for you to read in order to create dynamic scenarios based on the current time (see next section "Dynamic Responses to Current Time") or to display the current time on the UI.
- Current Time Scale: dictates how quickly time passes. The formula that runs on Update is is:A Time Scale of 1 means that one hour passes every second, so for the default value of 0.05, a full day (24hrs) 480 seconds or 8 minutes. You can also set this at runtime whenever you want, although runtime changes are not saved on the save-file (the value you set in the inspector will be loaded when a savegame is loaded).
SetTime(currentTime + (currentTimeScale * Time.deltaTime));
- Skybox Material: is a reference to the material that you're using in your world. If you want a different Skybox material you'll have to change this reference (to update it in game) and the reference in Project Settings (to allow the ToD slider to correctly preview the skybox in the editor). In the RCK default configuration there is only one Skybox Material that contains 3 Cubemaps that represent Day, Dusk, Night, that are blended in base of the Current Time Value. You can swap the Skybox Material reference if you want, even during runtime, but you'll also have to do so in the RenderSettings.
The next values "Sun & Moon" allows you to fine-control the lighting of your scenes as time passes.
- Sun Light: is a reference to your main Directional Light (sun) that is also in the _WorldLoader_ scene.
- Sun Color: is the sun's color.
- Sun Intensity: allows you to set a curve that controls the intensity of the Sun's light as time goes by. So the value at the beginning of the curve would be the sun's intensity at hour 0:00, while the last value is at the very last minute of the day 23:59.
- Ambient Color/Intensity: allows you to define gradients that controls the ambience of your scene at runtime. The gradient is also distributed over the currentTime, so you can have dark ambient settings at night and more light ones during the day.
- Fog Color/Density: allows you to do the same but to the fog setting of your scene.
The values set in here are to be thought as the "default" values.
However, you probably want control over ambience/fog for each worldspace and even for each cell.
The Worldspace data has also been given these properties, to allow you to customize your worldspaces as you wish.
- Global_TOD_ENABLE_SKYBOX_AND_LIGHTING_EDITS: if set to true it will mean that the default 'Time of Day Manager' values we've set previously for Ambient/Fog will be overridden by the Worldspace when the player will be in that worldspace.
- The rest of the values are the same as explained previously, with some additional tweaks such as fog start/end and modes.
The same concept applies for individual Cells:
- Local_Override_ToD_Setting: determines whether to inherit the
TOD_ENABLE_SKYBOX_AND_LIGHTING_EDITSsetting from the parent Worldspace or use the local booleanLocal_TOD_ENABLE_SKYBOX_AND_LIGHTING_EDITSdefined on this Cell. If Local_Override is false,Local_TOD_ENABLE_SKYBOX_AND_LIGHTING_EDITS has obviously no effect. - The rest of the values are the same as explained previously.
So the idea is that you would have ambient/fog responsive to the Time of Day (set at a worldspace level) for exterior worlds, and you can decide to override it for interiors (such as always-dark dungeons). But, you can also make interiors (such as houses with windows) whose Ambient lighting responds to time of day.
Dynamic Responses to Current Time
This whole Time System goes well together with the Scripting System of the RPG Creation Kit and in general with the component-based architecture of Unity.
We can query at anytime the Current Time of day, also as (Hour::Minute) and dynamically make things happen, or prevent things from happening. This allows you to create content that depends on time of day, such as dungeons that are only accessible at night, events that can only happen at a certain time of the day, and this also allows for Dynamic NPCs routines.
In the RCK demo we have 5 examples:
- NPCs equip torches at night. [RckAI_EquipTorchAtNight.cs]
- Shops in the city close at night. [CityInterior_LockShopsAtNight.cs]
- The "Killing Monsters" quest can be only completed during the night (22:00 - 05:00), because the door entrance will be locked during the day [Virrihael_LockUnlockVampiresDungeon.cs].
- Merchants in the City simulate stop working at night and simulate going in their houses [CityInterior_StallOwnersGoToSleep.cs].
- The windows of the houses in the city will be lit at night [CityInterior_TurnHouseLightsOn.cs].
Let's see the NPCs equip torches at night example.
You can attach the RckAI_EquipTorchAtNight component to any NPC prefab you have. Such as "CityGuard004" shown below.
This component acts as a "manager" or "controller" for the NPC actions that have to depend on time.
The logic for this example is very simple, if the CurrentTime is greater or equal of what we consider the start of the day (dayStartHour), and the CurrentTime is lesser than what we consider the start of the night (nightStartHour), we should not have a torch equipped.
Otherwise, we should equip a torch. This simple logic is present in the script "RckAI_EquipTorchAtNight", that subscribes to listen to OnHourChanges event.
So everytime there's an hour change we can run the check to equip/unequip the torch.
public void HandleOnHourChange(int curHour)
{
if (ai == null || ai.equipment == null || ai.isInOfflineMode || !ai.isAlive)
return;
bool isTorchEquipped = ai.equipment.currentTorchInHand != null;
// Equip torch logic
if (curHour >= dayStartHour && curHour < nightStartHour)
{
if (isTorchEquipped)
ai.equipment.Unequip(EquipmentSlots.LHand);
}
else if (!isTorchEquipped)
{
var torch = ai.inventory.GetItem("ITorch001");
if (torch != null)
ai.equipment.Equip(torch);
}
}You can also subscribe functions to the onMinuteChanges or onTimeChanges to have more granular control.
The Scripts are placed on the most suitable GameObject you can think of:
- For RckAI Equip Torch, we place it on the NPC itself.
- For the Door that has to be locked at night, we could place it on the door itself. In my case I prefer to have a "TIME_DEPENDENT_SCRIPTS" GameObject in each Cell, so it will be attached to that game object.
- Same thing for both the houses window's light logic and merchants.
This idea is the whole foundation to build proper NPCs Schedules, that I wish to create and formalize formalized in dedicated assets in a future update.
XP, Leveling & New Attributes System
The Attributes System has been reworked to actually influence in-game actions, for both the player, NPCs and Creatures.
In addition to that, XP and Levels are now a thing. The player can earn XP by killing monsters, completing quests or via Scripting, and also Events & Consequences. As you could expect, the player levels up and he's granted attributes points to improve his attributes. RckAI (and derived) also have a level now, that is defined by their attributes (the more the sum of the attributes values, the greater the level) and the level of the AI is used to compute the XP reward on kill.
Let's see how this is managed:
Default Values
The first thing that you should know are default values.
For the Player, these are set in the RckSettings.cs file, under the name of PLAYER_ATTRIBUTES_DEFAULT_Xwhere "X" is the attribute short name. By default all values are set to 25.
For the AI (when created via the RckAI Editor) they will have the values of the attributes of the RckAI_Prefab (located in your project).
Player XP and Level Up
The XP "curve" to level up is defined as a function the RckSettings file, under the name of "GetNextLevelXPValue(uint level)", and stands as the following:
// Calculates the XP needed to reach the given level
public static ulong GetNextLevelXPValue(uint level)
{
ulong xp = level * level * XP_NEXT_LEVEL_SCALING;
return xp;
}So the value returned by this function is the amount of XP needed for a level up. This amount depends on the player's level.
You can of course change and tweak this function as much as you want.
Player Attributes Point per level
Regarding the player's level up, the RckSettings also defines these constants you may want to tweak:
public static float LEVELLING_UP_ALERT_MESSAGE_DURATION = 5;
public static uint LEVELLING_POINTS_PER_LEVEL = 5; // 5 attributes points per level
public static bool LEVELLING_LEVEL_2_SKILL_TUTORIAL_ENABLED = true;AI Level and XP Awarded On Kill
The AI level is automatically set while you tweak the AI's Attributes in the "RckAI Editor".
The level is calculated in base of a constant set in the RckSettings:
public static uint LEVELLING_AI_ATTRIBUTES_POINTS_PER_LEVEL = 5;Every LEVELLING_AI_ATTRIBUTES_POINTS_PER_LEVEL (value) gave to the AI increases the AI level by 1. AI Level is then used to calculate XP Reward:
public static ulong CalculateXPGainedOnAIKill(uint aiLevel)
{
ulong xp = aiLevel * XP_GAINED_ON_AI_KILL_BASE;
return xp;
}You can edit "XP_GAINED_ON_KILL_BASE" default value as you wish.
The value returned by this function is also multiplied by the XpMultiplier that you can set for each AI:
Thanks to the Xp Mult I was able to tweak the value for all the AI the player would meet in the first tutorial dungeon and make sure that killing everything would gain him exactly 1 level.
Derived Attributes
Derived attributes (such as maxHealth, maxMana, etc.) are now effectively derived from the base attributes. For example, Constitution directly affects the max amount of HPs and Willpower affects the max value of Mana.
The formulas are explicited as static functions inside the RckSettings.cs file.
For example, max health is calculated as the following:
public static float GetMaxHealthCalculation(int attConstitution, int attStrength)
{
float constitutionModifier = 5.25f;
float strengthModifier = 0.5f;
float maxHealth = ATTRIBUTES_DEF_HEALTH + (attConstitution * constitutionModifier) + (attStrength * strengthModifier);
return maxHealth;
}ATTRIBUTES_DEF_HEALTH is by default 1.0f.
There are now a lot of derived attributes, whose definitions are all in the RckSettings file. You can obviously add your own as well.
Sprint Attacks / Skills
Class Selection
Other
AI Aggro Lines
AI Perception Improvements
Sneak attacks
Every UI state can pause the game or not
