Raised This Month: $ Target: $400
 0% 

[TF2/All] Record user's actions and let a bot reproducing it.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Plaffy46
Junior Member
Join Date: Mar 2014
Old 03-24-2016 , 14:43   [TF2/All] Record user's actions and let a bot reproducing it.
Reply With Quote #1

So I'm trying to write a plugin allowing users to record their actions and let a bot reproduce them on demand, pretty much like a bot_mimic imitation that works on demand, or that one feature in SFM where you can record yourself playing, except that this plugin is also useful for gameplay purposes.
Right now, I can properly set up listeners to note my actions such as walking, jumping and attacking, that I then write to a specific cfg file, so I can tell a bot to execute that cfg so it reproduces what I did.

My issue is how to handle the view angle of the bot. I can't really use the +left, +right, and all other usercmds related to camera to properly "save" where I was looking.

In short, is there any way to record the view position and angles of a player so that a bot can then imitates it later?



Plaffy46 is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 03-24-2016 , 14:54   Re: [TF2/All] Record user's actions and let a bot reproducing it.
Reply With Quote #2

The 5th parameter of OnPlayerRunCmd() are viewangles of the client. I'm pretty sure it would be better to use that for everything else rather than setting up so many listeners.
Phil25 is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 03-24-2016 , 14:54   Re: [TF2/All] Record user's actions and let a bot reproducing it.
Reply With Quote #3

Instead of recording all those events you can try just recording the player position, view angles, and buttons. I've made a replay bot and that is how I have it working

Last edited by blaacky; 03-24-2016 at 14:55.
blaacky is offline
Plaffy46
Junior Member
Join Date: Mar 2014
Old 03-24-2016 , 15:23   Re: [TF2/All] Record user's actions and let a bot reproducing it.
Reply With Quote #4

Thanks for the replies!
@blaacky, would you mind giving me your code or at least a snippet? I'm not totally sure about how I could retranscript the informations I get into an "executable" cfg file (I'll probably have to find another way for that), and this'll certainly save me some precious time!
Plaffy46 is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 03-24-2016 , 17:20   Re: [TF2/All] Record user's actions and let a bot reproducing it.
Reply With Quote #5

PHP Code:
            any data[REPLAY_FRAME_SIZE];
            
GetArrayArray(g_hReplayFrame[Type][style][tas], g_ReplayCurrentFramedatasizeof(data));
            
            
float vPos[3];
            
Array_Copy(datavPos3);
            
            
float vAng[3];
            
vAng[0] = data[3];
            
vAng[1] = data[4];
            
vAng[2] = 0.0;
            
            
buttons data[5];
            
            
float vCurrentPos[3];
            
Entity_GetAbsOrigin(clientvCurrentPos);
            
            if(
GetVectorDistance(vPosvCurrentPos) > 50.0)
            {
                
TeleportEntity(clientvPosvAngNULL_VECTOR);
            }
            else
            {
                
// Get the new velocity from the the 2 points
                
float vVel[3];
                
MakeVectorFromPoints(vCurrentPosvPosvVel);
                
ScaleVector(vVel1.0/GetTickInterval());
                    
                
TeleportEntity(clientNULL_VECTORvAngvVel);
            }
            
            
g_ReplayCurrentFrame++;
            if(
g_ReplayCurrentFrame >= g_ReplayMaxFrame)
                
StopCurrentReplay(); 
This goes under OnPlayerRunCmd when the client is a replay bot. I use SMLib for some of that code in case you don't know

Last edited by blaacky; 03-24-2016 at 17:21.
blaacky is offline
Plaffy46
Junior Member
Join Date: Mar 2014
Old 03-26-2016 , 06:02   Re: [TF2/All] Record user's actions and let a bot reproducing it.
Reply With Quote #6

Thanks! Now my only problem is still about how to save each individual frame for future replay and not just a live one. My guess is making another file affiliated with the cfg file containing every frame and the corresponding views and use OnGameFrame () to read this file and update the view of the bot when the cfg with all the other commands is being read. I'll put feedback when I try this.

Last edited by Plaffy46; 03-26-2016 at 06:02.
Plaffy46 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 04:36.


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