Action Without Event?

Original Discord Post by ham1ton | 2024-09-17 16:09:48

Is it possible to know if an action was fired without having to have a function by the same name? Say I want to know if an arbitrary action was called that the NPC may not have a function for, is there a way to know what action is being called by it’s name? I’m using Unreal but I imagine this question is relevant to more than just Unreal.
Thanks!

Reply by k3kalinix | 2024-09-18 22:12:10

<@&1163218672580575372>

Reply by mighty_brute | 2024-09-19 05:49:50

Hello <@557253604939923468>,

Yes, you can use the OnActionReceived delegate in the ConvaiChatbotComponent, which will provide you with all the data related to the actions being called.

Let me know if you need further clarification!

Reply by mighty_brute | 2024-09-19 05:50:13

Images:

Reply by ham1ton | 2024-09-19 13:40:15

Great suggestion thanks! I actually just made my own delegate call out from the chatbot component, this way I don’t have to sort through the actions. Since I work in Unreal 4 I’ve had to heavily modify the plugin anyways to get it working, This is what I did"

ConvaiChatbotComponent.h:
/**
Added the FOnActionHasNoEvent declaration
Param Action name ( Action with no matching event or function)
**/
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnActionHasNoEvent, FString, ActionName);

public:
UPROPERTY(BlueprintAssignable, Category = "Convai", meta = (DisplayName = "On Actions ReceivedNoEvent"))
FOnActionHasNoEvent OnActionHAsNoEvent;


ConvaiChatbotComponent.cpp:
/**Added the OnActionHAsNoEvent.Broadcast this is an event disbatcher callable from the convai chatbot object.
the current use case is having the ability to know if the character has spoken on topics necessary for the completeion of scenerio objectives. 
**/
bool UConvaiChatbotComponent::TriggerNamedBlueprintAction(const FString& ActionName, FConvaiResultAction ConvaiActionStruct)

UE_LOG(ConvaiChatbotComponentLog, Log, TEXT("TriggerNamedBlueprintAction: Could not find an event or function with action name: %s"), *ActionName);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Purple, (TEXT("Action Name : %s "), *ActionName));
OnActionHAsNoEvent.Broadcast(ActionName);

Reply by ham1ton | 2024-09-19 13:42:55

Images:

This conversation happened on the Convai Discord Server, so this post will be closed.