.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Bot Coding (http://forums.bots-united.com/forumdisplay.php?f=24)
-   -   switching player/bot:coding question (http://forums.bots-united.com/showthread.php?t=7478)

SamPlay 11-01-2010 02:07

switching player/bot:coding question
 
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

Whistler 11-01-2010 03:56

Re: switching player/bot:coding question
 
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.

SamPlay 13-01-2010 13:50

Re: switching player/bot:coding question
 
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.

SamPlay 31-01-2010 02:07

Re: switching player/bot:coding question
 
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...)

The Storm 31-01-2010 17:47

Re: switching player/bot:coding question
 
Maybe too late but I think the cyborg mode just calls RunPlayerMove() on human edict. :)

SamPlay 01-02-2010 11:27

Re: switching player/bot:coding question
 
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

The Storm 03-02-2010 20:15

Re: switching player/bot:coding question
 
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.

SamPlay 05-02-2010 21:30

Re: switching player/bot:coding question
 
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)

The Storm 06-02-2010 15:58

Re: switching player/bot:coding question
 
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. :)

SamPlay 07-02-2010 11:30

Re: switching player/bot:coding question
 
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.


All times are GMT +2. The time now is 11:14.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.