Author Topic: Spawning a fake player object w/ inventory  (Read 848 times)

I'm trying to make a gamemode where you can control different bots and make them do things, in the form of a strategy game. When I spawn a bot and setControlObject over it, I am able to fully control it, but it has no inventory / it allows me to access my inventory.

Is there some way to add a player object that can be controlled with its own inventory, without having to use a player object that is used by someone else? Kind of like a dummy/mannequin player.

set the bots tools like

Code: [Select]
%bot.tool[0] = nameToId(gunItem);
this sets the bots inventory items on the server side, but you need to tell the client side what to draw in the hud

so you want to tell the client controlling the bot to get the bots inventory

Code: [Select]
for(%i=0;%i<%bot.getDatablock().maxTools;%i++)
{
    messageClient(%controllingClient,'MsgItemPickup','',%i,nameToId(%bot.tool[%i]),1);
}

if the bot gains a new item while it is being controlled you will also have to update the controlling client

messageClient(controllingClient,'MsgItemPickup','',slot,itemID,playBoopNoise?);

problem: the HUD is updated and I can see the gun in the bots inventory. However, whenever I try to access the actual inventory it causes the controlling object (ie me) to open up their inventory. So instead of the bot equipping the gun, the controlling player equips their inventory item.
« Last Edit: December 03, 2016, 04:00:06 PM by Perry »

oh ya then you need to package serverCmdUseTool(%cl,%slot) and serverCmdUnUseTool(%cl)
and if the client is controlling one of your special bots override the default code and instead mount the image corresponding to the slot on the bot