AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Extensions (https://forums.alliedmods.net/forumdisplay.php?f=134)
-   -   [TF2 & L4D & L4D2] Actions (https://forums.alliedmods.net/showthread.php?t=336374)

BHaType 02-15-2022 07:11

[TF2 & L4D & L4D2] Actions
 
1 Attachment(s)
ConVars
PHP Code:

// Logs every action transitions
// 1 - Enable debug, 0 - Disable debug
ext_actions_debug "0"

// Logs every action/behavior/component allocation or deallocation
// Used to track memory leaks
// 1 - Enable memory debug, 0 - Disable memory debug
ext_actions_debug_memory "0" 

Commands
PHP Code:

ext_actions_dump Dumps every nextbot actions to console

Guide Samples

Left 4 Dead 2 Usage Example


Source code

Gold Fish 02-16-2022 08:45

Re: [L4D2] Actions
 
What are the "action" related to? Any actions of survivors and infected (players)?

BHaType 02-16-2022 20:05

Re: [L4D2] Actions
 
Quote:

Originally Posted by Gold Fish (Post 2771621)
What are the "action" related to? Any actions of survivors and infected (players)?

"Actions" are only related to nextbots. I can't give you full list of game actions since there are to many of them

https://developer.valvesoftware.com/...tBot_Behaviors

Updated
PHP Code:

Fixed InitialContainedAction handler for custom actions 


Gold Fish 02-17-2022 03:05

Re: [L4D2] Actions
 
Quote:

Originally Posted by BHaType (Post 2771662)
"Actions" are only related to nextbots. I can't give you full list of game actions since there are to many of them

https://developer.valvesoftware.com/...tBot_Behaviors

Updated
PHP Code:

Fixed InitialContainedAction handler for custom actions 


I understand that with the help of your extension, can force a tank to attack a certain player or make him just stand still or run away from players or even make zombie friends for a survivors, I understand that the extension gives full control over the intelligence of entities that is embedded in the game engine?)

Lux 02-17-2022 04:01

Re: [L4D2] Actions
 
This is a blessing thanks for release

HarryPotter 02-19-2022 16:00

Re: [L4D2] Actions
 
If I write
PHP Code:

#pragma semicolon 1
#pragma newdecls required

#include <actions> 

then compiler will show error
Code:

//// l4d2_bile_out_nav_negate_action.sp
//
// D:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2 Dedicated Server\left4dead2\addons\sourcemod\scripting 1.10\include\actions.inc(37) : error 001: expected token: ";", but found "forward"
// D:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2 Dedicated Server\left4dead2\addons\sourcemod\scripting 1.10\include\actions.inc(39) : error 001: expected token: ";", but found "methodmap"
// D:\Program Files (x86)\Steam\steamapps\common\Left 4 Dead 2 Dedicated Server\left4dead2\addons\sourcemod\scripting 1.10\include\actions.inc(89) : error 001: expected token: ";", but found "<newline>"
//
// 3 Errors.

sm 1.10

BHaType 03-02-2022 04:18

Re: [L4D2] Actions
 
Updated
PHP Code:

Fixed compilation errors for sm 1.10
Allowed to return NULL for InitialContainedAction
Added msvc 


NightlyRaine 03-23-2022 23:39

Re: [L4D2] Actions
 
Using nb_move_to_cursor and nb_move_to_position seems to crash when a bot is spawned in when using this amazing extension.

And I for the life of me can not figure out how to use or what this is even supposed to do, Am somewhat new to messing with plugins at times. Any help on what it is supposed to do and how to use would be amazing!

PHP Code:

/* Used to iterate through all entity actions */
public static native void Actionsint entityActionsIteratorCallback callback ); 

And GetName() doesn't seem to work when getting the name of a result action like
PHP Code:

"result.action.GetName()" 


BHaType 03-24-2022 03:09

Re: [L4D2] Actions
 
Quote:

Originally Posted by NightlyRaine (Post 2775035)
Using nb_move_to_cursor and nb_move_to_position seems to crash when a bot is spawned in when using this amazing extension.

Thanks for report. Fixed

Quote:

Originally Posted by NightlyRaine (Post 2775035)
And I for the life of me can not figure out how to use or what this is even supposed to do, Am somewhat new to messing with plugins at times. Any help on what it is supposed to do and how to use would be amazing!

It will give every action that passed entity contains. There is no way to legally create ArrayList via extension so that's the only way how can you pass multiple objects without creating your own handle type.
How to use

Quote:

Originally Posted by NightlyRaine (Post 2775035)
And GetName() doesn't seem to work when getting the name of a result action like

Just tested and seems to be working fine. Make sure you are not trying to access null action or show code so i can replicate issue.

BHaType 03-24-2022 03:33

Re: [L4D2] Actions
 
Updated
PHP Code:

Fixed crash for nb_move_to_cursor and nb_move_to_position cmds (Thanks to NightlyRaine)
Added new example 


NightlyRaine 03-24-2022 17:49

Re: [L4D2] Actions
 
This is how I was trying to use GetName(), if I change result.action.GetName(name, sizeof name); to action.GetName(name, sizeof name); it works, but I can't get the result name.

PHP Code:

#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

#include <actions>

public void OnActionCreatedBehaviorAction actionint actor, const char[] name )
{
    if ( 
strcmp(name"SurvivorLegsStayClose") == )
    {
        
action.OnUpdatePost SurvivorLegsStayClose_OnUpdatePost;
    }


/* ----------------------------------------------------------------------------------------------------*/
/* SurvivorLegsStayClose */
/* ----------------------------------------------------------------------------------------------------*/
public Action SurvivorLegsStayClose_OnUpdatePostBehaviorAction actionfloat intervalActionResult result )
{    
    if ( 
result.IsRequestingChange() )
    {
        if ( 
result.action != INVALID_ACTION )
        {
            
char name[ACTION_NAME_LENGTH];
            
result.action.GetName(namesizeof name);
            
PrintToServer"%s"name );
        }
    }

    return 
Plugin_Continue;


In game Console
PHP Code:


L 03
/24/2022 16:36:31: [SMException reportedInvalid action passed (66C1B5F0)
L 03/24/2022 16:36:31: [SMBlamingGetNameExample.smx
L 03
/24/2022 16:36:31: [SMCall stack trace:
L 03/24/2022 16:36:31: [SM]   [0BehaviorAction.GetName
L 03
/24/2022 16:36:31: [SM]   [1Line 27F:\SteamLibrary\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\GetNameExample.sp::SurvivorLegsStayClose_OnUpdatePost
133.27
Rochelle:: SurvivorLegsStayClose caused SurvivorLegsStayClose to SUSPEND_FOR SurvivorLegsRegroup  (I'm too far away from the closest human survivor)
133.27: Rochelle::  SUSPENDING SurvivorLegsStayClose
133.27: Rochelle::  SUSPENDING SurvivorLegsMoveOn
133.27: Rochelle::  STARTING SurvivorLegsRegroup
SurvivorLegsRegroup<<SurvivorLegsStayClose( SurvivorLegsMoveOn ) 


And side question, would it be possible to change actions to other existing exactions?
Like when SurvivorLegsMoveOn Suspends_For SurvivorLegsBattleStations, would it be possible to get it to suspend for L4D1SurvivorLegsBattlesStations? Or SurvivorLegsWait? Asking so I know what all is possible.

BHaType 03-26-2022 01:21

Re: [L4D2] Actions
 
Quote:

Originally Posted by NightlyRaine (Post 2775091)
I can't get the result name.

Thanks for report. Fixed.

Quote:

Originally Posted by NightlyRaine (Post 2775091)
And side question, would it be possible to change actions to other existing exactions?
Like when SurvivorLegsMoveOn Suspends_For SurvivorLegsBattleStations, would it be possible to get it to suspend for L4D1SurvivorLegsBattlesStations? Or SurvivorLegsWait? Asking so I know what all is possible.

Yep, but you need to create SDKCall for SurvivorLegsBattleStations constructor

Spoiler

BHaType 03-26-2022 01:23

Re: [L4D2] Actions
 
Updated
PHP Code:

Added IsSuspended native
Added IsStarted native
Fixed "Invalid action" error for runtime actions (Thanks to NightlyRaine


Marttt 03-27-2022 23:28

Re: [L4D2] Actions
 
Just a cool note, if someone wants debug to see some action stuff, you can use "nb_debug BEHAVIOR" in console (in a listen server) to watch.

ThatKidWhoGames 03-29-2022 14:29

Re: [L4D2] Actions
 
Quote:

Originally Posted by NightlyRaine (Post 2775091)
This is how I was trying to use GetName(), if I change result.action.GetName(name, sizeof name); to action.GetName(name, sizeof name); it works, but I can't get the result name.

PHP Code:

#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

#include <actions>

public void OnActionCreatedBehaviorAction actionint actor, const char[] name )
{
    if ( 
strcmp(name"SurvivorLegsStayClose") == )
    {
        
action.OnUpdatePost SurvivorLegsStayClose_OnUpdatePost;
    }


/* ----------------------------------------------------------------------------------------------------*/
/* SurvivorLegsStayClose */
/* ----------------------------------------------------------------------------------------------------*/
public Action SurvivorLegsStayClose_OnUpdatePostBehaviorAction actionfloat intervalActionResult result )
{    
    if ( 
result.IsRequestingChange() )
    {
        if ( 
result.action != INVALID_ACTION )
        {
            
char name[ACTION_NAME_LENGTH];
            
result.action.GetName(namesizeof name);
            
PrintToServer"%s"name );
        }
    }

    return 
Plugin_Continue;


In game Console
PHP Code:


L 03
/24/2022 16:36:31: [SMException reportedInvalid action passed (66C1B5F0)
L 03/24/2022 16:36:31: [SMBlamingGetNameExample.smx
L 03
/24/2022 16:36:31: [SMCall stack trace:
L 03/24/2022 16:36:31: [SM]   [0BehaviorAction.GetName
L 03
/24/2022 16:36:31: [SM]   [1Line 27F:\SteamLibrary\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\GetNameExample.sp::SurvivorLegsStayClose_OnUpdatePost
133.27
Rochelle:: SurvivorLegsStayClose caused SurvivorLegsStayClose to SUSPEND_FOR SurvivorLegsRegroup  (I'm too far away from the closest human survivor)
133.27: Rochelle::  SUSPENDING SurvivorLegsStayClose
133.27: Rochelle::  SUSPENDING SurvivorLegsMoveOn
133.27: Rochelle::  STARTING SurvivorLegsRegroup
SurvivorLegsRegroup<<SurvivorLegsStayClose( SurvivorLegsMoveOn ) 


And side question, would it be possible to change actions to other existing exactions?
Like when SurvivorLegsMoveOn Suspends_For SurvivorLegsBattleStations, would it be possible to get it to suspend for L4D1SurvivorLegsBattlesStations? Or SurvivorLegsWait? Asking so I know what all is possible.

Just a suggestion, but when writing code, you should define the include files before adding these lines:
Code:

#pragma newdecls required
#pragma semicolon 1

This way, any include files which may be old or do not use semicolons for whatever reason should still allow your plugin to compile without errors.

E.4H 03-29-2022 23:55

Re: [L4D2] Actions
 
Very cood Extension. If possible, could it support l4d1 please?

objir 03-30-2022 02:07

Re: [L4D2] Actions
 
Getting a crash when the player is pounced by a SI, if Using this with Advanced Bot AI (https://steamcommunity.com/sharedfil...?id=1968764163). Any help please?

BHaType 03-30-2022 03:12

Re: [L4D2] Actions
 
Quote:

Originally Posted by E.4H (Post 2775514)
Very cood Extension. If possible, could it support l4d1 please?

I have almost made done l4d1 version, will be released when I'll make sure that it works correctly.

Quote:

Originally Posted by objir (Post 2775515)
Getting a crash when the player is pounced by a SI, if Using this with Advanced Bot AI (https://steamcommunity.com/sharedfil...?id=1968764163). Any help please?

It's doesn't make any sense. I have no idea how this vscript addon can cause crash. Try to test it without 3rd party plugins also you can post accelerator crash id and i will try to find out what caused your crash.

objir 03-30-2022 04:44

Re: [L4D2] Actions
 
@BHaType Thanks for pointing me to Accelerator.

A log (Tested at the beginning of Dead Center Ch.2.):
Got a presubmit token from server: 06b4ba61cd32830875e139b3001bacbd
Uploaded crash dump: Crash ID: EXQT-QIAX-MQFE

Before posting here, I have done some tests and it appears that the only way to stop the crash is to disable either the ai mod or this extension:
1. Tried to launch the game without -insecure: the crash is gone.
2. Launched the game with -insecure but with no smx plugins (even without the ones that come with Sourcemod and the ones that require this extension, like the Shove Direction Fix): still crashed.
(Will this extension be loaded at all if no plugins that require it are enabled?)
3. Launched the game with -insecure and smx plugins, but without this extension: the crash is gone.
4. Launched the game with -insecure and smx plugins, with this extension but without the ai mod: the crash is gone.

Edit:
a result for EXQT-QIAX-MQFE from crash.limetech.org:
https://i.imgur.com/5blfEuW.png

BHaType 03-30-2022 06:16

Re: [L4D2] Actions
 
Quote:

Originally Posted by objir (Post 2775520)
@BHaType Thanks for pointing me to Accelerator.

A log (Tested at the beginning of Dead Center Ch.2.):
Got a presubmit token from server: 06b4ba61cd32830875e139b3001bacbd
Uploaded crash dump: Crash ID: EXQT-QIAX-MQFE

Before posting here, I have done some tests and it appears that the only way to stop the crash is to disable either the ai mod or this extension:
1. Tried to launch the game without -insecure: the crash is gone.
2. Launched the game with -insecure but with no smx plugins (even without the ones that come with Sourcemod and the ones that require this extension, like the Shove Direction Fix): still crashed.
(Will this extension be loaded at all if no plugins that require it are enabled?)
3. Launched the game with -insecure and smx plugins, but without this extension: the crash is gone.
4. Launched the game with -insecure and smx plugins, with this extension but without the ai mod: the crash is gone.

Thanks for accelerator crash report but I played 3 campaigns and survival for 9 minutes and not a single crash happened. Are you sure that you have installed latest version if it's not then can you also attach version that you are using?

Quote:

Originally Posted by objir (Post 2775520)
Will this extension be loaded at all if no plugins that require it are enabled?

Yep, this is necessary because the extension intercepts actions by their "inheritance" system. If some action is lost then subsequent actions will also be lost.

objir 03-30-2022 06:49

Re: [L4D2] Actions
 
1 Attachment(s)
@BHaType Oh Shit... Completely Missed the new version. No more crashes after updating to the latest version. Sorry, my bad.

The old version I was using is last edited on March 2nd.

Dragokas 04-13-2022 11:22

Re: [L4D2] Actions
 
Wow! Very very nice!
Thanks for making this !!!

Is it per-action specific value? :

Quote:

Originally Posted by BHaType (Post 2771520)
Code:

public Action OnFriendAction( BehaviorAction action, float interval, ActionResult result )
{
...
        int target = action.Get(0x34) & 0xFFF;
...


Can we know more useful offsets?

PS. Surely, looking forward for l4d1 version.
Nice job!

BHaType 04-15-2022 19:24

Re: [L4D2] Actions
 
Quote:

Originally Posted by Dragokas (Post 2776681)
Is it per-action specific value? :

Yep, this is offset to member of action class so another action probably will have some another data rather than entity handle.

Quote:

Originally Posted by Dragokas (Post 2776681)
Can we know more useful offsets?

There is no way to find them except reverse engineering but there is "pattern" for same actions type. In other words if you find offset to some data then probably similiar actions will store same data for that offset.
For example TankAttack stores tank's target at 0x34 offset which means there is a high chance that other attack actions(SpitterAttack, SmokerAttack etc...) will also store target at 0x34.

BHaType 05-06-2022 23:07

Re: [L4D2] Actions
 
Updated
PHP Code:

Fully rewritten version (no backward supportsorry)
Added new natives
Added some debug commands
Added Left 4 Dead support 


Dragokas 05-07-2022 06:21

Re: [L4D2] Actions
 
Best!

BHaType 05-07-2022 09:55

Re: [L4D2] Actions
 
Updated
PHP Code:

Fixed issue where hooks called the wrong handler 


HarryPotter 05-10-2022 06:25

Re: [L4D2] Actions
 
Quote:

Originally Posted by BHaType (Post 2778819)
Updated
PHP Code:

Fully rewritten version (no backward supportsorry)
Added new natives
Added some debug commands
Added Left 4 Dead support 


nice, glad to see you support l4d1 :)

Voevoda 05-15-2022 15:33

Re: [L4D2] Actions
 
Quote:

L 05/15/2022 - 03:15:28: SourceMod error session started
L 05/15/2022 - 03:15:28: Info (map "c5m1_waterfront") (file "/home/l4d2server/serverfiles/left4dead2/addons/sourcemod/logs/errors_20220515.log")
L 05/15/2022 - 03:15:28: [SM] Unable to load extension "actions.ext": /home/l4d2server/serverfiles/left4dead2/addons/sourcemod/extensions/actions.ext.so: cannot open shared object file: No such file or directory
L 05/15/2022 - 03:150: [SM] Unable to load plugin "l4d2_shove_fix.smx": Native "BehaviorAction.OnShoved.set" was not found
L 05/15/2022 - 03:152: Error log file session closed.

BHaType 05-15-2022 19:02

Re: [L4D2] Actions
 
Quote:

Originally Posted by Voevoda (Post 2779500)
...

Error is quite clear. Read it

Voevoda 05-15-2022 19:07

Re: [L4D2] Actions
 
Quote:

Originally Posted by BHaType (Post 2779511)
Error is quite clear. Read it

installed everything still error

BHaType 05-15-2022 19:33

Re: [L4D2] Actions
 
Quote:

Originally Posted by Voevoda (Post 2779512)
installed everything still error

Atleast provide some info about your server. I have no idea what you did to install it but error clearly says that it can't find extension.

Just so you know installation steps:
1. Download archive
2. Put extension and autoload file to sourcemod/extension folder (Make sure you placed right extension since they all depends by game and OS)
3. Put gamedata file to sourcemod/gamedata folder
4. Restart server
5. Done

BHaType 05-16-2022 02:22

Re: [L4D2] Actions
 
Updated

PHP Code:

Change std::vector to std::deque in actions_manager
Fix runtime action not working properly
Fix passing CBaseEntity args
Add runtime action check to deallocate native
Fixed post hooks 


Voevoda 05-16-2022 05:37

Re: [L4D2] Actions
 
Quote:

Originally Posted by BHaType (Post 2779514)
Atleast provide some info about your server. I have no idea what you did to install it but error clearly says that it can't find extension.

Just so you know installation steps:
1. Download archive
2. Put extension and autoload file to sourcemod/extension folder (Make sure you placed right extension since they all depends by game and OS)
3. Put gamedata file to sourcemod/gamedata folder
4. Restart server
5. Done


PHP Code:

L 05/16/2022 12:36:01SourceMod error session started
L 05
/16/2022 12:36:01Info (map "c5m1_waterfront") (file "/home/l4d2server/serverfiles/left4dead2/addons/sourcemod/logs/errors_20220516.log")
L 05/16/2022 12:36:01: [SMUnable to load extension "actions.ext": /home/l4d2server/serverfiles/left4dead2/addons/sourcemod/extensions/actions.ext.2.l4d2.soundefined symbol_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERjj
L 05
/16/2022 12:36:04: [SMUnable to load plugin "l4d2_shove_fix.smx"Native "BehaviorAction.OnShoved.set" was not found 

Quote:

[01] Stripper (1.2.2) by BAILOPAN
[02] L4DToolZ (1.0.0.9r1) by Ivailosp
[03] SourceMod (1.10.0.6538) by AlliedModders LLC
[04] DHooks (2.2.0-detours17) by Dr!fter and Peace-Maker
[05] SDK Tools (1.10.0.6538) by AlliedModders LLC
[06] SDK Hooks (1.10.0.6538) by AlliedModders LLC
[07] VoiceHook (3.0) by Accelerator
[08] SteamWorks Extension (1.2.3) by Kyle Sanderson

BHaType 05-16-2022 07:03

Re: [L4D2] Actions
 
Quote:

Originally Posted by Voevoda (Post 2779530)
PHP Code:

/home/l4d2server/serverfiles/left4dead2/addons/sourcemod/extensions/actions.ext.2.l4d2.soundefined symbol_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERjj 


Just tested with linux server and extension loaded without any errors. I have no idea how to fix it.
It was issue with latest compilers

BHaType 05-18-2022 01:34

Re: [L4D2] Actions
 
Updated
PHP Code:

Fixed link issue for latest compilers 


BHaType 05-20-2022 02:46

Re: [L4D2] Actions
 
Updated
PHP Code:

CMake reconfigure
Add pending actions
Add handlers result safety check
Fix actor for OnActionCreated callback
Fix custom actions 


Psyk0tik 05-27-2022 03:17

Re: [L4D2] Actions
 
I would like to request adding information to the include file to make the whole library optional. This will allow plugins to make the extension an optional dependency.

Something like this:
Spoiler


Also, I think the thread title should be renamed with the prefix "[L4D & L4D2]" or something similar since you added support for L4D1.

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.

Also, also, also, what are the different function prototypes for the callback functions? In your examples, you use different prototypes so I don't know which one to use for "TankAttack". Maybe a "typedef" or "typeset" in the include will help.
Spoiler


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.

BHaType 05-27-2022 06:50

Re: [L4D2] Actions
 
Quote:

Originally Posted by Psyk0tik (Post 2780227)
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

BHaType 05-27-2022 06:52

Re: [L4D & L4D2] Actions
 
Updated
PHP Code:

Docs reconfigure
Fixed crash for multiple hooks on same event handler and default action result
Renamed thread
Added extension optionality (Thanks to Psyk0tik

Edit:
Updated
PHP Code:

Added typeset to include 


Psyk0tik 05-27-2022 07:23

Re: [L4D2] Actions
 
Quote:

Originally Posted by BHaType (Post 2780242)
...

Alright, thank you for all the information.

(Also thank you for the latest update!)


All times are GMT -4. The time now is 02:55.

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