guiismiti
30th March 2017, 05:33
Hi again,
Today I thought of a way to increase the difficulty of meatbot. I know there are people here who use it in their servers.
If you run around bots, they will keep shooting at the position where you just were, and that makes it too easy to dodge their attacks.
What I did is simple - I made bots predict where the target will be and shoot at this predicted position.
In an infinite loop, I save the player position and time of saving.
When the bot finds the player, it uses the current position at current time + saved position at saved time to get a movement rate for the target.
Extrapolating at this rate to a certain moment in the future (the delay of the bot's shot), we have a predicted position of the player.
If you want to make it even harder, remove the spread from the bots weapons.
Now, the code may be a bit messy and may have a couple of unnecessary things, I'm very tired.
onPlayerConnect:
self thread definePreviousPos();
onPlayerSpawn:
self.previouspos[0] = self getOrigin();
self.previouspos[1] = self getOrigin();
self.previouspostime = getTime();
The infinite loop:
definePreviousPos()
{
self.previousposold = [];
self.previousposnew = [];
self.previouspostime = getTime();;
for(;;)
{
if
(
(
(self.pers["team"] == "allies") ||
(self.pers["team"] == "axis")
) &&
(isAlive(self))
)
{
self.previousposold = self.previousposnew;
self.previousposnew = self.origin;
self.previouspostime = getTime();
}
wait(0.1);
}
}
Now, in _mbot_tdm.gsc::checkEnemy()
Replace
vtarget = vectorNormalize(target_mark - eye);
With
botdelay = 150;
interval = getTime() - (target.previouspostime - 100);
extrapolationfactor = botdelay / interval;
deltapos = [];
for(k = 0; k < 3; k++)
{
deltapos[k] = (target.origin[k] - target.previousposold[k]) * extrapolationfactor;
// deltapos[k] = (target.previousposnew[k] - target.previousposold[k]) * 100;
}
vtarget = vectorNormalize((target_mark[0] + deltapos[0], target_mark[1] + deltapos[1], target_mark[2] + deltapos[2]) - eye);
botdelay is the delay of the bot's shot (in ms). I have it roughly calibrated at 150 ms.
Have fun
Today I thought of a way to increase the difficulty of meatbot. I know there are people here who use it in their servers.
If you run around bots, they will keep shooting at the position where you just were, and that makes it too easy to dodge their attacks.
What I did is simple - I made bots predict where the target will be and shoot at this predicted position.
In an infinite loop, I save the player position and time of saving.
When the bot finds the player, it uses the current position at current time + saved position at saved time to get a movement rate for the target.
Extrapolating at this rate to a certain moment in the future (the delay of the bot's shot), we have a predicted position of the player.
If you want to make it even harder, remove the spread from the bots weapons.
Now, the code may be a bit messy and may have a couple of unnecessary things, I'm very tired.
onPlayerConnect:
self thread definePreviousPos();
onPlayerSpawn:
self.previouspos[0] = self getOrigin();
self.previouspos[1] = self getOrigin();
self.previouspostime = getTime();
The infinite loop:
definePreviousPos()
{
self.previousposold = [];
self.previousposnew = [];
self.previouspostime = getTime();;
for(;;)
{
if
(
(
(self.pers["team"] == "allies") ||
(self.pers["team"] == "axis")
) &&
(isAlive(self))
)
{
self.previousposold = self.previousposnew;
self.previousposnew = self.origin;
self.previouspostime = getTime();
}
wait(0.1);
}
}
Now, in _mbot_tdm.gsc::checkEnemy()
Replace
vtarget = vectorNormalize(target_mark - eye);
With
botdelay = 150;
interval = getTime() - (target.previouspostime - 100);
extrapolationfactor = botdelay / interval;
deltapos = [];
for(k = 0; k < 3; k++)
{
deltapos[k] = (target.origin[k] - target.previousposold[k]) * extrapolationfactor;
// deltapos[k] = (target.previousposnew[k] - target.previousposold[k]) * 100;
}
vtarget = vectorNormalize((target_mark[0] + deltapos[0], target_mark[1] + deltapos[1], target_mark[2] + deltapos[2]) - eye);
botdelay is the delay of the bot's shot (in ms). I have it roughly calibrated at 150 ms.
Have fun