Author Topic: Making A Bot Identical To A Player  (Read 862 times)

What would be the best way to make a bot that is identical to a player?

I can't see any negative things resulting from this method, but something like this should work

function copyAppearance(%bot,%player)
{
    %player.client.aplayer = %player;
    %player.client.player = %bot;
    %player.client.applyBodyParts();
    %player.client.applyBodyColors();
    %player.client.player = %player.client.aplayer;
}




EDIT: Actually you should probably just create %bot.client as a copy of %player.client and then applyBodyParts/Colors on that. Will edit with code.

EDIT2: So using a function I wrote a while ago, haven't tested it extensively but it seems to work from what I've done.
Code: [Select]
function copy(%obj)
{
%obj.copyFunction_oldName = %obj.getName();
%obj.setName("copyFunction_CopyObj");

%newObj = new (%obj.getClassName())(:copyFunction_CopyObj);

%obj.setName(%obj.copyFunction_oldName);
%obj.copyFunction_oldName = "";
%newObj.copyFunction_oldName = "";

return %newObj;
}
function copyBotAppearance(%bot,%client)
{
%bot.client = copy(%client);
%bot.client.player = %bot;
%bot.client.applyBodyParts();
%bot.client.applyBodyColors();
}
Other than the copy function this is untested.
That copy function would create a GameConnection instead of an AiConnection; I don't know if this will result in anything unwanted or not. Also, this code wouldn't work well if the bod would ever switch to another player's appearance after the client is created; you may want to edit with some slightly different code.
« Last Edit: January 23, 2013, 01:58:18 PM by Headcrab Zombie »