Training the Oreons

GSoC Week 4 update

So, we left off last week at a point where an idle Oreon would perform an eating task if hungry or go to sleep at night, given that no there were no pending tasks in the Holding. This week I implemented the Oreon Training System which would make an idling Oreon take up training tasks based on one of its “weak” attributes.

Oreon Training System

The training system assigns tasks based on different attributes of the Oreon, which upon finishing would improve the concerned attribute of the Oreon. This will later be used to obtain different levels of working efficiency from different Oreons based on their attributes, for eg: an Oreon with a higher strength would complete a building task faster than a ‘weaker’ Oreon. Adding the training bit to the Oreon required a new BT node needs_training to be implemented. This node checks for various attributes and assigns task, given that the required building has been built otherwise, sends a notification to the player requesting them to build it.

Oreon notification for a missing Gym

The current advancedTaskAcquiring behavior tree for the Oreon(shown below) defines a priority for the tasks to be taken up. As explained in the previous post, the selector prioritises hunger over training.

{
   "selector" : [
        "needs_food",
        "needs_training",
        "needs_sleep",
        "...",
        "..."
    ]
}

Digressing from the timeline

Since the training task addition to the Oreon behavior proved to be plain sailing and I completed them early on in the week, I decided to implement some features to improve the gameplay experience.

Delayed Notifications

The notifications were being sent to the player when a required for training or the Diner for eating for tasks was not found in the village. Since the Oreon looking for these buildings triggered these notifications the player would recieve one every tick when the behavior tree was run and the concerned node was hit. In order to stop the Oreons from “nagging” the player for missing buildings in the village I implemented a DelayedNotification system, which would check for the difference between the game time when last notification was sent and the current game time, if this difference is greater than the maxDelay variable defined, the notification will be sent. This would not only prevent the clutter in a player’s chat box but also inform the player of a required building in a timely manner.

WorldlyTooltip Integration

The WorldlyTooltip module enables an UI overlay which informs the player about the entity in they are currently pointing at. More information from the various components attached to the entity can also be added to this tooltip. In order to get the tooltip to work for the Oreons in the village, besides the discernible requirements like declaring a dependency on the WorldlyTooltip, I implemented a TooltipSystem in MOO. Whenever a player points at an Oreon the GetTooltipItem event sent is received by this system and various lines related to the Oreon from its OreonAttributesComponent is added to the tooltip. So far it was fairly easy to get a tooltip specialized for the Oreon to show up, but things got a bit tricky since the name of the Oreon and an icon for it were not dispayed correctly. So, I looked at the WildAnimals module for some inspiration since it uses the tooltip for the Deer. Similar to the WildAnimalComponent I attached a OreonTooltipComponent to every Oreon and voila behold the tooltip for an Oreon.

Oreon tooltip.

The Oreon tooltip component defines the two required fields for addition in the tooltip an icon for the Oreon and its name, I used the two events sent by the WorldlyTooltip GetTooltipIcon and GetTooltipName to set the two fields to be displayed.

public class OreonTooltipComponent implements Component {
    public TextureRegionAsset<?> icon;
    public String name;
}