This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[TF2 & L4D & L4D2] Actions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
awesome144
Senior Member
Join Date: Jul 2014
Location: In lala land
Old 10-31-2023 , 06:48   Re: [TF2 & L4D & L4D2] Actions
Reply With Quote #1

So I'm a little perplexed on how the InitialContainedAction callback works. Changing the third parameter with a different return allows a different action to be the child action, but I don't really know what the purpose of the first parameter is for. Also I'm wondering is it possible to get the action it should return (assuming the action it hooked uses InitialContainedAction), if that has to be done using the post hook.
__________________
⎛⎝Officer Spy⎠⎞


awesome144 is offline
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Old 11-02-2023 , 21:41   Re: [TF2 & L4D & L4D2] Actions
Reply With Quote #2

Quote:
Originally Posted by awesome144 View Post
So I'm a little perplexed on how the InitialContainedAction callback works.
Action calls InitialContainedAction to create optional child action and invoked before OnStart of calle action also child action always gets updates first.

Quote:
Originally Posted by awesome144 View Post
Changing the third parameter with a different return allows a different action to be the child action, but I don't really know what the purpose of the first parameter is for.
That's was include issue, I just pushed update to remove this confusion (InitialContainedAction).
First two params are basicly same for all non contextual handlers. The 3rd one represents return value of InitialContainedAction handler.

Quote:
Originally Posted by awesome144 View Post
Also I'm wondering is it possible to get the action it should return (assuming the action it hooked uses InitialContainedAction), if that has to be done using the post hook.
Yep, simply hook InitialContainedActionPost and then child param will be actual return value of original IntialContainedAction.
__________________
cry
BHaType is offline
Send a message via AIM to BHaType
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Old 11-02-2023 , 21:44   Re: [TF2 & L4D & L4D2] Actions
Reply With Quote #3

Updated
PHP Code:
Renamed 3rd param of InitialContainedAction to more appropriate name 
Simplified InitialContainedAction child param routine (before you had to wait 1 frame to use it
__________________
cry

Last edited by BHaType; 11-02-2023 at 21:45.
BHaType is offline
Send a message via AIM to BHaType
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Old 11-03-2023 , 16:02   Re: [TF2 & L4D & L4D2] Actions
Reply With Quote #4

Updated
PHP Code:
Fixed crash caused by prior update 
__________________
cry
BHaType is offline
Send a message via AIM to BHaType
Mystik Spiral
Senior Member
Join Date: Oct 2020
Location: Orlando, FL
Old 01-16-2024 , 18:58   Re: [TF2 & L4D & L4D2] Actions
Reply With Quote #5

Hi BHaType!

In this post, you provided this example. On line 42 of that example is this text:

PrepSDKCall_SetVirtual(284); // 285 linux

Does this mean I need to change 284 to 285 if my code is running on Linux instead of Windows?

I realize that is an index (vtblidx), but I am not sure what it is an index to. There are still many things for me to learn about SourceMod so I apologize if my question seems "basic".

If that is what I need to do, since my plugin also uses Left4DHooksDirect, I thought I would try to use GetOSType to set the value appropriately.
__________________
Mystik Spiral is offline
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Old 01-18-2024 , 15:21   Re: [TF2 & L4D & L4D2] Actions
Reply With Quote #6

Quote:
Originally Posted by Mystik Spiral View Post
Does this mean I need to change 284 to 285 if my code is running on Linux instead of Windows?
Yes, if you don't change it then plugin will call wrong function which most likely cause a crash.

Quote:
Originally Posted by Mystik Spiral View Post
I realize that is an index (vtblidx), but I am not sure what it is an index to. There are still many things for me to learn about SourceMod so I apologize if my question seems "basic".
There is a special keyword in C++ to store function in an array with other functions with same keyword.
If you need to call specific function from that array then you need to know index of the function you want to call.
You can decompile appropriate binary and calculate index by yourself or use VTable Dumper by asherkin.

In your case 284 is an index of "Weapon_Switch" from "CTerrorPlayer" array.
Those indexes are different between Windows and Linux because afaik this is compiler specific stuff.

This is extremely simplified explanation.

Quote:
Originally Posted by Mystik Spiral View Post
If that is what I need to do, since my plugin also uses Left4DHooksDirect, I thought I would try to use GetOSType to set the value appropriately.
There is nothing wrong with GetOSType but actually it's a bad practice.
Anything platform/game specific or ambiguous data is always better to cover up into gamedata if possible.
__________________
cry

Last edited by BHaType; 01-18-2024 at 17:27.
BHaType is offline
Send a message via AIM to BHaType
Mystik Spiral
Senior Member
Join Date: Oct 2020
Location: Orlando, FL
Old 01-19-2024 , 07:38   Re: [TF2 & L4D & L4D2] Actions
Reply With Quote #7

Great info. Thank you @BHaType!
__________________
Mystik Spiral is offline
awesome144
Senior Member
Join Date: Jul 2014
Location: In lala land
Old 02-16-2024 , 03:32   Re: [TF2 & L4D & L4D2] Actions
Reply With Quote #8

SelectMoreDangerousThreat is an optional native, but it doesn't have its own property in the methodmap? Also could I get an explanation of its callback function?
__________________
⎛⎝Officer Spy⎠⎞


awesome144 is offline
caxanga334
Member
Join Date: Nov 2013
Location: Brazil
Old 02-28-2024 , 19:02   Re: [TF2 & L4D & L4D2] Actions
Reply With Quote #9

Quote:
Originally Posted by awesome144 View Post
SelectMoreDangerousThreat is an optional native, but it doesn't have its own property in the methodmap? Also could I get an explanation of its callback function?
When IVision::GetPrimaryKnownThreat is called, IContextualQuery::SelectMoreDangerousThreat is used to filter/select which Known Entity the bot should consider as it's primary threat. Generally used when selecting targets to attack.

IContextualQuery::SelectMoreDangerousThreat returns a CKnownEntity pointer and has 4 parameters: The bot itself, the bot BCC, and two known entities, threat1 and threat2. The function must return if the bot should focus on threat1 or threat2. NULL can be returned for a 'no answer'.

In the extension: function Action (any action, Address nextbot, int entity, Address threat1, Address threat2, Address& knownEntity). You have the address to threat1 and threat2. The result is stored in the last parameter: Address& knownEntity.
caxanga334 is offline
little_froy
Senior Member
Join Date: May 2021
Old 03-09-2024 , 23:54   Re: [TF2 & L4D & L4D2] Actions
Reply With Quote #10

L4D2 how can I get attack target in SurvivorAttack? I want to prevent some attacks.

Solved: https://forums.alliedmods.net/showthread.php?t=346696

Last edited by little_froy; 03-11-2024 at 23:25.
little_froy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:27.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode