.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
switching player/bot:coding question
Old
  (#1)
SamPlay
Member
 
Status: Offline
Posts: 46
Join Date: Jan 2006
Question switching player/bot:coding question - 11-01-2010

Hi,
does anyone know how it would be possible for a human player ( or at least the player having created a local lan game) to switch in-game with a bot ( with a dedicated bind); I mean, I take control of the bot ( its name , its location, making decisions,...) and my former edict is now a bot; sort of like exchanging bodies.
Those who tried Half-life-Decay know that it can be done.
I have been coding my own bot for a long time ( for cs), so I am not afraid of detailed/technical views.
Thanks for help
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#2)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: switching player/bot:coding question - 11-01-2010

I think the HL Decay doesn't actually "switch" edicts but rather "cheats" by switching player models, weapon info, player position, etc. You can notice this at the scoreboard - the player names "Gina" and "Collate" don't actually switch.
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#3)
SamPlay
Member
 
Status: Offline
Posts: 46
Join Date: Jan 2006
Default Re: switching player/bot:coding question - 13-01-2010

Hi,
I am not sure that switching edict member data ( all of it?) solves the issue of redirecting the human player commands ( keyboard,...) to the bot suppposed to be under human control ( what about the different IPs for example).
I remember that podbot had a "cyborg" mode, which may help me.
Thanks for the hint.
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#4)
SamPlay
Member
 
Status: Offline
Posts: 46
Join Date: Jan 2006
Default Re: switching player/bot:coding question - 31-01-2010

Well I have finally done it on my own, but I have still an small issue with client screen update.
For those interested, I would recommend to start by having a look on Amx ModX source code on http://www.alliedmods.net/ for a solution ( in particular on how it gets meaningful info from edict_t. pvPrivatedData...)
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#5)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,618
Join Date: Jul 2004
Location: Bulgaria
Default Re: switching player/bot:coding question - 31-01-2010

Maybe too late but I think the cyborg mode just calls RunPlayerMove() on human edict.
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#6)
SamPlay
Member
 
Status: Offline
Posts: 46
Join Date: Jan 2006
Default Re: switching player/bot:coding question - 01-02-2010

That is right,
The biggest problem ( for me) is the other way round, that is for the human player
1- to control a bot through keyboard,...
2- to keep visual/data consistency when swapping;
I have done it ok, in particular with a "safe" little hack (on CS1.5-WON), ie swapping the first data member of CBaseEntity which is a pointer to associated entvars_t; actually I directly swap on pvPrivateData.
This means this part of my code should work on any Mod.
3- to have the proper screen for the human client( health, ammo,status icon,...); this I failed to do as a whole ( resetHUD does nothing!) and for now I send messages to the mod dll with the actual( current) value of the data ( the core data is ok after swap, it is just that the screen is not updated) ;

Besides, I tried first to re-rout keyboard input using their console keyword( like "+forward","buy",..., but ClientCommand apparently does not
catch/use commands which are hl standards ( like "+forward","+jump").
I had the idea to manipulate bindings config ( forcing binding to my own command names then issue the right command to the right edict within ClientCommand, while keeping the same "apparent" key-mapping for the human client) but did not try and implement it.

I think also about re-routing the usercmd_t data.
thanks
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#7)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,618
Join Date: Jul 2004
Location: Bulgaria
Default Re: switching player/bot:coding question - 03-02-2010

You can't use directly ClientCommand as long as I remeber. Use FakeClientCommand function instead(you can find it in any bot code here), for move commands use RunPlayerMove().

As for swapping bot-player, the easy way is as Whistler pointed out to switch the bot and player data(ammo, weapons, etc) and after that just move the edicts. I mean that after you done the bot-player items switch you just have to move the bot edict at the place of the player one, and place the player edict on the bot previous position, in this way you will not get unproper screen. About the HUD, just do some message tracking to see what messages are sent to the clients to update the HUD and after you got the needed data, just send the same messages to the swappet player. This is the best way I can think off.
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#8)
SamPlay
Member
 
Status: Offline
Posts: 46
Join Date: Jan 2006
Default Re: switching player/bot:coding question - 05-02-2010

Hi,
I agree and that is what I am doing.
-the human player and the bot keep their edict during the swap( my understanding is that the ability to issue command through the keyboard is associated with the edict).
-I swap edict data ( ie the Private data POINTER and the entvars data VALUES), except for FL_CLIENT/FL_FAKECLIENT flags.
-I adjust to maintain pointers consistency
-I send messages to the Human player to update screen data.
The problem I am left with is that I do not know how to adjust crosshair ( swapping between a zoomed sniper rifle and a pistol for example)
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#9)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,618
Join Date: Jul 2004
Location: Bulgaria
Default Re: switching player/bot:coding question - 06-02-2010

RunPlayerMove() again. With flags for secondary attack. There is no problem to run this function on human edict. Or in case that there is no sniper rifle but the zoom is still on just try to switch some weapons, like knife and then again pistol, this should work. For that try to use the FakeClientCommand() on the human edict. Other way is with client command, I believe that there is such function in the HL engine, in this way you can trigger command from the player console, like the bind for key 1("slot1"). Execute it in this order if slot1 is knife and slot2 is pistol - "slot1;wait;slot2" this should do the trick.
  
Reply With Quote
Re: switching player/bot:coding question
Old
  (#10)
SamPlay
Member
 
Status: Offline
Posts: 46
Join Date: Jan 2006
Default Re: switching player/bot:coding question - 07-02-2010

Hi,
thanks for the tips.
1- using IN_ATTACK2 or switching back and forth with knife both work but this resets/changes the zoom level of an AWP; I want to avoid that.
2- I checked again my engine messages and I found "Crosshair", and "HideWeapon" that actually deals with the whole Hud. I tried them but the issue of the crosshair not appearing when switching to an edict with an AWP remains, as well as the AWP crosshair Not disappearing when switching to an edict with pistol. Interestingly, things become OK on the first shot after edict-swap.
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com