Jump to content

How do I listen for combat on a prefab?


Somnei

Recommended Posts

Hi!

I want to know how to write a hook for when a mob starts to fight.

I'm guessing it's possible to simply add a "listenforevent" to the mob, but I'm unsure what events trigger during combat or how to find what events are available to listen for. Are there any files I can read that contain all events or something like that?

Or, if there is another, better, way - please let me know!

I just want to make the royal pig guards swap their torches if they fight during the night - which should be easy enough provided I can make a function trigger whenever they start to fight.

 

edit: So far I have tried listening for "attack", "onattack", "onattackother", "onhitother" and "doattack" with no luck.

Link to comment
Share on other sites

Hm, that is strange. I wonder if the royal guards are just bugged somehow...

I wrote some code based on your example and it didn't work, so I then tried copying your code so mine was identical (replacing "the_pig_prefab" with "pigman_city" and "pigman_royalguard" as well to be on the safe side - still nothing.

I've made a workaround by instead adding an attackcallback on their weapon, but I'm just a bit puzzled as to why the other way isn't working for me.

Link to comment
Share on other sites

On 8/30/2022 at 7:50 AM, Somnei said:

Hm, that is strange. I wonder if the royal guards are just bugged somehow...

I wrote some code based on your example and it didn't work, so I then tried copying your code so mine was identical (replacing "the_pig_prefab" with "pigman_city" and "pigman_royalguard" as well to be on the safe side - still nothing.

I've made a workaround by instead adding an attackcallback on their weapon, but I'm just a bit puzzled as to why the other way isn't working for me.

You can try to print something and see if it shows on console.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...