X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fgamemodes%2Fgamemode%2Fonslaught%2Fsv_onslaught.qc;h=6d719eb977c512997131382e30a0698e0fcd14c0;hp=c20a4fac74a160b62e9d876a35092fd6afc5a2b4;hb=70bba988cd32922d29e40235db6ad1d8149bdc67;hpb=aa1c87cd3f79ddaf4e45ebf9428293cfdf2d6733 diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index c20a4fac74..6d719eb977 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -1264,71 +1264,26 @@ void Onslaught_RoundStart() // NOTE: LEGACY CODE, needs to be re-written! -void havocbot_goalrating_ons_offenseitems(entity this, float ratingscale, vector org, float sradius) -{ - bool needarmor = false, needweapons = false; - - // Needs armor/health? - if(GetResourceAmount(this, RESOURCE_HEALTH) < 100) - needarmor = true; - - // Needs weapons? - int c = 0; - FOREACH(Weapons, it != WEP_Null, { - if(STAT(WEAPONS, this) & (it.m_wepset)) - if(++c >= 4) - break; - }); - - if(c<4) - needweapons = true; - - if(!needweapons && !needarmor) - return; - - LOG_DEBUG(this.netname, " needs weapons ", ftos(needweapons)); - LOG_DEBUG(this.netname, " needs armor ", ftos(needarmor)); - - // See what is around - IL_EACH(g_items, it.bot_pickup, - { - // gather health and armor only - if (it.solid) - if ( ((GetResourceAmount(it, RESOURCE_HEALTH) || GetResourceAmount(it, RESOURCE_ARMOR)) && needarmor) || (STAT(WEAPONS, it) && needweapons ) ) - if (vdist(it.origin - org, <, sradius)) - { - int t = it.bot_pickupevalfunc(this, it); - if (t > 0) - navigation_routerating(this, it, t * ratingscale, 500); - } - }); -} - void havocbot_role_ons_setrole(entity this, int role) { - LOG_DEBUG(this.netname," switched to "); switch(role) { case HAVOCBOT_ONS_ROLE_DEFENSE: - LOG_DEBUG("defense"); + LOG_DEBUG(this.netname, " switched to defense"); this.havocbot_role = havocbot_role_ons_defense; - this.havocbot_role_flags = HAVOCBOT_ONS_ROLE_DEFENSE; this.havocbot_role_timeout = 0; break; case HAVOCBOT_ONS_ROLE_ASSISTANT: - LOG_DEBUG("assistant"); + LOG_DEBUG(this.netname, " switched to assistant"); this.havocbot_role = havocbot_role_ons_assistant; - this.havocbot_role_flags = HAVOCBOT_ONS_ROLE_ASSISTANT; this.havocbot_role_timeout = 0; break; case HAVOCBOT_ONS_ROLE_OFFENSE: - LOG_DEBUG("offense"); + LOG_DEBUG(this.netname, " switched to offense"); this.havocbot_role = havocbot_role_ons_offense; - this.havocbot_role_flags = HAVOCBOT_ONS_ROLE_OFFENSE; this.havocbot_role_timeout = 0; break; } - LOG_DEBUG(""); } void havocbot_goalrating_ons_controlpoints_attack(entity this, float ratingscale) @@ -1353,9 +1308,9 @@ void havocbot_goalrating_ons_controlpoints_attack(entity this, float ratingscale // Count team mates interested in this control point // (easier and cleaner than keeping counters per cp and teams) - FOREACH_CLIENT(IS_PLAYER(it), { + FOREACH_CLIENT(it != this && IS_PLAYER(it), { if(SAME_TEAM(it, this)) - if(it.havocbot_role_flags & HAVOCBOT_ONS_ROLE_OFFENSE) + if(it.havocbot_role == havocbot_role_ons_offense) if(it.havocbot_ons_target == cp2) ++c; }); @@ -1366,7 +1321,7 @@ void havocbot_goalrating_ons_controlpoints_attack(entity this, float ratingscale } // We'll consider only the best case - bestvalue = 99999999999; + bestvalue = FLOAT_MAX; cp = NULL; for(cp1 = ons_worldcplist; cp1; cp1 = cp1.ons_worldcpnext) { @@ -1392,23 +1347,21 @@ void havocbot_goalrating_ons_controlpoints_attack(entity this, float ratingscale // Rate waypoints near it found = false; best = NULL; - bestvalue = 99999999999; - for(radius=0; radius<1000 && !found; radius+=500) + bestvalue = FLOAT_MAX; + for (radius = 500; radius <= 1000 && !found; radius += 500) { - for(wp=findradius(cp.origin,radius); wp; wp=wp.chain) + IL_EACH(g_waypoints, vdist(cp.origin - it.origin, <, radius), { - if(!(wp.wpflags & WAYPOINTFLAG_GENERATED)) - if(wp.classname=="waypoint") - if(checkpvs(wp.origin,cp)) + if (!(it.wpflags & WAYPOINTFLAG_GENERATED) && checkpvs(it.origin, cp)) { found = true; - if(wp.cnt