OnTakeDamage access violation on DamageEvent

Hi
I am adding a delegate to OnTakeDamage event. I could not find anywhere how to add raw delegates to events so this is how I did it (I am calling this in component’s InitialiseComponent method):

TScriptDelegate<FWeakObjectPtr> delegate;
delegate.BindUFunction(this,FName(TEXT("TakeDamage")));
GetOwner()->OnTakeAnyDamage.Add(delegate));

This is declaration of the TakeDamage method:

UFUNCTION()
float TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser);

I have there UFUNCTION just to be able to use it to create the delegate.
This is working fine without any problems, if I don’t use DamageEvent in the method.
But if I try to use DamageEvent, I have “Access violation executing location”. Just simply calling this, is causing the crash:

auto typeid = DamageEvent.GetTypeID();

Another question, beside the obvious why it is crashing, would be how to bind raw functions (methods) to delegates (in many places there are answers like BindRaw, AddDynamic, but these are not present in OnTakeDamage event).

Thanks

Anicka

Well, I have found out what is the problem. I am doing it entirely wrong.
First, the delegates, at least for multicast, should obviously not return a value. It is an event so there is no way.
The other problem is, the OnTakeDamage declaration is different than my TakeDamage method.
It should not have FDamageEvent& argument, but const UDamageType pointer. The problem is, the method I used to add the delegate using TScriptDelegate, is not checking for arguments (so adding it was passing without any problems). And when broadcasting, it is passing arguments as pointers, which are then reintrepreted as they are in the delegate method. So UDamageType* is casted to FDamageEvent&, and this is failing when I want to access it in runtime.
So that is blunt explanation why I have the access violation crash.

Finally I have found the way how to do it properly. AddDynamic is not a method but it is a macro, that is why I could not find it. So jush use OnTakeDamage.AddDynamic(this,&ClassName::TakeDamage);

The delegate method declaration now looks like this:

void TakeDamage(float Damage, const UDamageType* DamageType, AController* EventInstigator, AActor* DamageCauser);