| 1935 | } |
| 1936 | |
| 1937 | void CBot::HearSound(int n, vec *o) |
| 1938 | { |
| 1939 | // Has the bot already an enemy? |
| 1940 | if (m_pMyEnt->enemy) return; |
| 1941 | |
| 1942 | |
| 1943 | //fixmebot |
| 1944 | // Is the sound not interesting? |
| 1945 | if(n == S_DIE1 || n == S_DIE2) return; |
| 1946 | |
| 1947 | int soundvol = m_pBotSkill->iMaxHearVolume - |
| 1948 | (int)(GetDistance(*o)*3*m_pBotSkill->iMaxHearVolume/255); |
| 1949 | |
| 1950 | if (soundvol == 0) return; |
| 1951 | |
| 1952 | // Look who made the sound(check for the nearest enemy) |
| 1953 | float flDist, flNearestDist = 3.0f; // Range of 3 units |
| 1954 | playerent *pNearest = NULL; |
| 1955 | |
| 1956 | // Check all bots first |
| 1957 | loopv(bots) |
| 1958 | { |
| 1959 | playerent *d = bots[i]; |
| 1960 | |
| 1961 | if (d == m_pMyEnt || !d || (d->state != CS_ALIVE) || |
| 1962 | isteam(m_pMyEnt->team, d->team)) |
| 1963 | continue; |
| 1964 | |
| 1965 | flDist = GetDistance(*o, d->o); |
| 1966 | if ((flDist < flNearestDist) && IsVisible(d)) |
| 1967 | { |
| 1968 | pNearest = d; |
| 1969 | flNearestDist = flDist; |
| 1970 | } |
| 1971 | } |
| 1972 | |
| 1973 | // Check local player |
| 1974 | if (player1 && (player1->state == CS_ALIVE) && |
| 1975 | !isteam(m_pMyEnt->team, player1->team)) |
| 1976 | { |
| 1977 | flDist = GetDistance(*o, player1->o); |
| 1978 | if ((flDist < flNearestDist) && IsVisible(player1)) |
| 1979 | { |
| 1980 | pNearest = player1; |
| 1981 | flNearestDist = flDist; |
| 1982 | } |
| 1983 | } |
| 1984 | |
| 1985 | if (pNearest) |
| 1986 | { |
| 1987 | if (m_pMyEnt->enemy != pNearest) |
| 1988 | m_iShootDelay = lastmillis + GetShootDelay(); // Add shoot delay when new enemy found |
| 1989 | |
| 1990 | m_pMyEnt->enemy = pNearest; |
| 1991 | } |
| 1992 | } |
| 1993 | |
| 1994 | bool CBot::IsInFOV(const vec &o) |
no test coverage detected