)
if(gamemode==GMODE_CTF || gamemode == GMODE_HUNTTHEFLAG || gamemode == GMODE_TEAMKEEPTHEFLAG || gamemode == GMODE_KEEPTHEFLAG)
{
flaginfos[0].pos = player1->o; // teleport the flags to us
flaginfos[1].pos = player1->o; // as long as noone from
flaginfos[2].pos = player1->o; // our or the enemy team has it
}
)
bool IsVisible(vec v1, vec v2, dynent *tracer = NULL, bool SkipTags=false); float GetDistance(vec v1, vec v2); float Get2DDistance(vec v1, vec v2); vec PredictPos(vec pos, vec vel, float Time);
#include "bot/bot_util.h"
)
)void getyawpitch(const vec &from, const vec &to, float &yaw, float &pitch)
{
float dist = from.dist(to);
yaw = -(float)atan2(to.x-from.x, to.y-from.y)/PI*180+180;
pitch = asin((to.z-from.z)/dist)/RAD;
}
loopv(players)
{
players[i];
}
}
int lasttarget = -1; float lastdist = 0.0f;
)int GetBestTarget()
{
int ttarget=-1;
if(lasttarget != -1 && players[lasttarget]->state == CS_ALIVE && players[lasttarget] != NULL && player1 != NULL && player1->state == CS_ALIVE)
{
if(IsVisible(player1->o, players[lasttarget]->o)==true)
{
return lasttarget; // our old target is visible so lets keep aiming for him =D
}
}
loopv(players)
{
if(players[i] == NULL || player1 == NULL || players[i] == player1) // if player or a possible target is null, or if our possible target is ourselves skip it.
{
continue;
}
if(players[i]->state == CS_ALIVE && player1->state == CS_ALIVE) // if we're both alive.
{
if(isteam(player1->team, players[i]->team)) // if our target is on our team skip it.
{
continue;
}
float tDist = Get2DDistance(player1->o, players[i]->o); // assign tDist with the 2d distance between us and our temporary target
if(IsVisible(player1->o, players[i]->o) && tDist<bestdist) //if he is visible and closer then the previous visible enemies
{
ttarget=i; // set him as our temporary target
bestdist=tDist; // set the last distance as the best distance
}
}
}
if(ttarget==-1)
{
lasttarget=-1;
return -1;
}
lasttarget=ttarget; // assign the current target as last target
bestdist=0.0f; //reset the best distance so we wont fuck up next time we call the target function
return ttarget; // return the temp target
}
int tmptarget = GetBestTarget();
float rX, rY;
if(tmptarget!=-1)
{
getyawpitch(player1->o,players[tmptarget]->o,rX,rY);
player1->pitch = rY;
player1->yaw = rX;
}

)
const struct guninfo &info;
struct guninfo { string modelname; short sound, reload, reloadtime, attackdelay, damage, projspeed, part, spread, recoil, magsize, mdl_kick_rot, mdl_kick_back, recoilincrease, recoilbase, maxrecoil, recoilbackfade, pushfactor; bool isauto; };
static guninfo guns[NUMGUNS] =
{
{ "knife", S_KNIFE, S_NULL, 0, 500, 50, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, false },
{ "pistol", S_PISTOL, S_RPISTOL, 1400, 170, 19, 0, 0, 80, 10, 8, 6, 5, 1, 40, 75, 150, 1, false },
{ "shotgun", S_SHOTGUN, S_RSHOTGUN, 2400, 1000, 5, 0, 0, 1, 35, 7, 9, 9, 10, 60, 60, 100, 1, false },
{ "subgun", S_SUBGUN, S_RSUBGUN, 1650, 80, 16, 0, 0, 70, 15, 30, 1, 2, 5, 15, 55, 250, 1, true },
{ "sniper", S_SNIPER, S_RSNIPER, 1950, 1500, 85, 0, 0, 60, 50, 5, 4, 4, 10, 70, 70, 100, 1, false },
{ "assault", S_ASSAULT, S_RASSAULT, 2000, 130, 24, 0, 0, 20, 40, 15, 0, 2, 2, 25, 60, 150, 1, true },
{ "grenade", S_NULL, S_NULL, 1000, 650, 200, 20, 6, 1, 1, 1, 3, 1, 0, 0, 0, 0, 3, false },
{ "pistol", S_PISTOL, S_RAKIMBO, 1400, 80, 19, 0, 0, 80, 10, 16, 6, 5, 6, 15, 30, 100, 1, true },
};
static guninfo guns[NUMGUNS] =
{
{ "knife", S_KNIFE, S_NULL, 0, 500, 50, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, false },
{ "pistol", S_PISTOL, S_RPISTOL, 1400, 170, 19, 0, 0, 0, 0, 8, 6, 5, 0, 0, 0, 0, 0, false },
{ "shotgun", S_SHOTGUN, S_RSHOTGUN, 2400, 1000, 5, 0, 0, 0, 0, 7, 9, 9, 0, 0, 0, 0, 0, false },
{ "subgun", S_SUBGUN, S_RSUBGUN, 1650, 80, 16, 0, 0, 0, 0, 30, 1, 2, 0, 0, 0, 0, 0, true },
{ "sniper", S_SNIPER, S_RSNIPER, 1950, 1500, 85, 0, 0, 0, 0, 5, 4, 4, 0, 0, 0, 0, 0, false },
{ "assault", S_ASSAULT, S_RASSAULT, 2000, 130, 24, 0, 0, 0, 0, 15, 0, 2, 0, 0, 0, 0, 0, true },
{ "grenade", S_NULL, S_NULL, 1000, 650, 200, 20, 6, 0, 0, 1, 3, 1, 0, 0, 0, 0, 0, false },
{ "pistol", S_PISTOL, S_RAKIMBO, 1400, 80, 19, 0, 0, 0, 0, 16, 6, 5, 0, 0, 0, 0, 0, true },
};

)

virtual bool attack(vec &targ) = 0;
attack(vec &targ)
attackphysics(from, to); hits.setsizenodelete(0); raydamage(from, to, owner); attackfx(from, to, 0); gunwait = info.attackdelay; mag--; sendshoot(from, to);
float tdist=9999999.9; //max distance we want
int target=-1; // temporary target
vec newto; // where our new hit location is
loopv(players)
{
if(players[i]==NULL) continue; //if the pointer is not NULL
if(!isteam(player1->team, players[i]->team) && players[i] != player1 && players[i]->state == CS_ALIVE) // and the team isnt the same, its not pointing to our own player and the enemy is alive
{
if(from.distxy(players[i]->o)<tdist) // check if the distance is below the best distance
{
tdist=from.distxy(players[i]->o);// if it is save our new distance as best distance
target=i; // assign our target
}
}
}
newto = players[target]->o; // the new hit location is our enemys location
attackphysics(from, newto);// send the attack physics
hits.setsizenodelete(0);
raydamage(from, newto, owner); // apply the damage
attackfx(from, newto, 0); // apply the effects
gunwait = info.attackdelay; // apply the gun wait time
mag--; // decrease our ammo
sendshoot(from, newto); // send our shot over to the server
They need some good hacks...