View Single Post
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Old 05-27-2022 , 06:50   Re: [L4D2] Actions
Reply With Quote #38

Quote:
Originally Posted by Psyk0tik View Post
Also, also, is there a consistent/reliable way to get the target of an action? In your example callback for "OnShovedPost" you have a "shover" param but I don't know where you got that. Then, in your block example, you use an offset to retrieve the target for the "OnFriendAction" callback, and I am wondering if that offset is always the same for every action or not.

For my use case, I am experimenting with setting a Tank's target when his current behavior is "TankAttack" so my plugin can decide which survivors to focus.
In most cases offsets will be same for every action but it's still better to check it yourself if you not sure. I have already mentioned some pattern info about offsets.

Every special infected chooses his target by calling ChooseVictim in ...Attack::Update action handler and return of ChooseVictim is always stored by 0x34 offset. Actually getting current tank target via action is more reliable and proper way since game directly uses this var to make path and it also considers OnContact event handler which makes tank attack who touched him.

About event handlers params. Their params are always same for every action but event handlers in plugins have some differences/additions. First param is always action, then arguments of the default handler, the last is always ActionResult/ActionDesiredResult. I will add typeset soon.

For example default OnShoved handler looks like this
PHP Code:
OnShoved(Infected* <- actorCBaseEntity* <- shover
so in plugin OnShoved callback will look like this
PHP Code:
/* First param is always action, then arguments of the default handler, the last is always ActionResult/ActionDesiredResult */
OnShoved(BehaviorAction actionint actorint shoverActionDesiredResult result
ActionResult is used only for OnStart, Update, OnEnd, OnSuspend, OnResume others use ActionDesiredResult (reference)

Event handlers dump

typeset
__________________
cry
BHaType is offline
Send a message via AIM to BHaType