MCPcopy Create free account
hub / github.com/assaultcube/AC / GetEnemyPos

Method GetEnemyPos

source/src/bot/bot_ai.cpp:18–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16extern weaponinfo_s WeaponInfoTable[MAX_WEAPONS];
17
18vec CBot::GetEnemyPos(playerent *d)
19{
20 // Aim offset idea by botman
21 vec o = m_pMyEnt->weaponsel->type == GUN_SNIPER && d->head.x >= 0 ? d->head : d->o, offset;
22 float flDist = GetDistance(o), flScale;
23
24 if (m_pBotSkill->bCanPredict)
25 {
26 // How higher the skill, how 'more' the bot predicts
27 float flPredictTime = RandomFloat(0.8f, 1.2f) / (m_sSkillNr+1);
28 o = PredictPos(o, d->vel, flPredictTime);
29 }
30
31 if (flDist > 60.0f)
32 flScale = 1.0f;
33 else if (flDist > 6.0f)
34 flScale = flDist / 60.0f;
35 else
36 flScale = 0.1f;
37
38 switch (m_sSkillNr)
39 {
40 case 0:
41 // no offset
42 offset.x = 0;
43 offset.y = 0;
44 offset.z = 0;
45 break;
46 case 1:
47 // GOOD, offset a little for x, y, and z
48 offset.x = RandomFloat(-3, 3) * flScale;
49 offset.y = RandomFloat(-3, 3) * flScale;
50 offset.z = RandomFloat(-6, 6) * flScale;
51 break;
52 case 2:
53 // FAIR, offset somewhat for x, y, and z
54 offset.x = RandomFloat(-8, 8) * flScale;
55 offset.y = RandomFloat(-8, 8) * flScale;
56 offset.z = RandomFloat(-12, 12) * flScale;
57 break;
58 case 3:
59 // POOR, offset for x, y, and z
60 offset.x = RandomFloat(-15, 15) * flScale;
61 offset.y = RandomFloat(-15, 15) * flScale;
62 offset.z = RandomFloat(-25, 25) * flScale;
63 break;
64 case 4:
65 // BAD, offset lots for x, y, and z
66 offset.x = RandomFloat(-20, 20) * flScale;
67 offset.y = RandomFloat(-20, 20) * flScale;
68 offset.z = RandomFloat(-35, 35) * flScale;
69 break;
70 }
71
72 o.add(offset);
73 return o;
74}
75

Callers

nothing calls this directly

Calls 4

GetDistanceFunction · 0.85
RandomFloatFunction · 0.85
PredictPosFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected