Bot dont shoots exactly at me
#1

Hey,

I have made it this far to create a bot that runs after me and starts from 5.0 Distance to shoot at me.
But the shoots stop only in the direction he is running .. In my position X, Y, Z, which is updated every 0.2 seconds. For this I use a timer.
But he always shoots slightly wrong. I do not know why :/
Know a way I can improve this code?
It works with: RNPC

I wanted to try that with trigonometry, but that is not possible because only one route exists. The distance from the player to the bot.

Код:
COMMAND:cbot(playerid,params[])
{
	new Name[64];
	if(sscanf(params,"s",Name)) return Fehler(playerid,"[Usage]: /cbot [Name]");
	npc = ConnectRNPC(Name);
	SetTimerEx("AttackerBot",200,true,"ii",npc,playerid);
	return 1;
}
/////////////////////////// COMMANDS /////////////////////////////

forward AttackerBot(npcid, targetid);
public AttackerBot(npcid, targetid)
{
	new Float:x, Float:y, Float:z;
    	
	GetPlayerPos(targetid, x, y, z);
	MoveRNPC(npcid, x, y, z, 0.006);
	if(IsPlayerInRangeOfPoint(npc, 5, x, y, z))
	{
    	RNPC_SetWeaponID(30);
    	RNPC_SetKeys(128 + 4);
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)