void create(fpsent *d) { if(!d->ai) d->ai = new aiinfo; if(d->ai) { d->ai->views[0] = viewfieldx(d->skill); d->ai->views[1] = viewfieldy(d->skill); d->ai->views[2] = viewdist(d->skill); } }
void init(fpsent *d, int at, int ocn, int sk, int bn, int pm, int pc, const char *name, const char *team) { loadwaypoints(); fpsent *o = newclient(ocn); d->aitype = at; bool resetthisguy = false; if(!d->name[0]) { if(aidebug) conoutf("%s assigned to %s at skill %d", colorname(d, name), o ? colorname(o) : "?", sk); else conoutf("\f0join:\f7 %s", colorname(d, name)); resetthisguy = true; } else { if(d->ownernum != ocn) { if(aidebug) conoutf("%s reassigned to %s", colorname(d, name), o ? colorname(o) : "?"); resetthisguy = true; } if(d->skill != sk && aidebug) conoutf("%s changed skill to %d", colorname(d, name), sk); } copystring(d->name, name, MAXNAMELEN+1); copystring(d->team, team, MAXTEAMLEN+1); d->ownernum = ocn; d->skill = sk; d->playermodel = chooserandomplayermodel(pm); if(pc < NUMPCS) d->pclass = pc; else conoutf("ERROR: %d", pc); if(resetthisguy) removeweapons(d); if(d->ownernum >= 0 && player1->clientnum == d->ownernum) { create(d); if(d->ai) { d->ai->views[0] = viewfieldx(d->skill); d->ai->views[1] = viewfieldy(d->skill); d->ai->views[2] = viewdist(d->skill); } } else if(d->ai) destroy(d); }
float viewfieldy(int x) { return viewfieldx(x)*3.f/4.f; }