Adding hurt event to AI NPC¶
In this tutorial, you learn to allow your configured AI NPC to decrease the health points (HP) of the player or an entity in the scene when triggered using Add hurt event to AI NPC assembler. For example, when the AI NPC's favor score hits 30%, the player's HP drops by 500.
Note: To enable health points (HP) on an entity, find and add the Damageable Component by clicking Add Module in Advanced Mode.
YAHAHA Studio version 0.3.66 or later
An AI NPC, created using the Create an AI NPC assembler and placed in the scene Visual Studio Code is installed and integrated with your Studio.
Setting up the assembler¶
Find the Adding hurt event to AI NPC assembler from Asset Library and open it in the scene.
In the assembler setup window, populate its basic settings:a Set the AI NPC to trigger the event: Choose an AI NPC in the scene to trigger the hurt event. In our example, we select the AI NPC we created, Mio.b Set the damage amount: Set the HP amount to be deducted from the player. Ranges from 1 to 5000. We leave it at the default of 500.c Select the trigger event: Choose one of the following events as a trigger event for the hurt event:
d Set the triggered event name: Enter a name for the triggered event. For example, if you set the trigger to Emotion 3 and the event to Hurt, the player's HP will decrease by 500 when your AI NPC's favor score hits 30%.
- Emotion 1-10 represents the AI NPC's favor score, ranging from 10% to 100%. It reflects the NPC's contentment level, with 10 being the least content and 100 being the most content.
- Chat Win indicates that the player wins the chat interaction with the AI NPC.
- Chat Lose indicates when the player loses the chat interaction with the AI NPC.
Click Assemble to start assembling this assembler. Once done, you can modify their properties in the Properties window.
Edit event-related properties¶
In the AI NPC's Properties window, you can customize the damage amount, target to hurt, trigger conditions, and more event-related properties according to your requirements.
To modify the damage amount, condition, and target, go to the Damage Executor pane. For more information, see Damage Executor.
To edit the trigger event, update the properties located in the corresponding AiGameEventRelay pane. For more information on this component, see AiGameEventRelay.