I did something very similar with iHalo a long time ago, there may be a better way of doing it, but what I did was:
In this section of bot_fight.qc
Code: Select all
// decide if I should shoot
foedist = vlen(org - self.origin);
v = weapon_range(self.weapon);
if (foedist > v_y && foedist < v_z)
{
traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * v_z, FALSE, self);
if (vlen(trace_endpos - (self.origin + self.view_ofs)) >= v_y)
{
// try to avoid shooting teammates
if (trace_ent.classname == "player")
if ((trace_ent.team == self.team && teamplay) || (coop))
return;
bot_shoot();
}
}
See the bot_shoot? Well what I did was add an argument
Code: Select all
if( (vlen(self.origin - self.enemy.orgin) < 64) || (random() < 0.2) ) //We want to be close enough to attack, but we dont always want to melee when close
KnifeAttck();
else
bot_shooot();
I can't seem to find my iHalo source anywhere, but thats about what I did and got the effect I wanted. There may be a better way however.
But if your knife attack is a replacement to the IT_AXE and is its own IT_WEAPON then you would have to edit the weapon_range code in bot_fight.qc and the frikbots should be able to use it then, same goes for the betty. The code I showed you assumes that your melee is a secondary attack like Halo.