-
-#ifdef 0
- // TODO: This disabled code is not working well and got replaced by custom weapon priorities.
- // However, this logic should be refactored and moved to weapons code so each new weapon can be
- // evaluated dynamically by bots without updating the "ai" or config files. --mand1nga
- float s, distancefromfloor, currentscore;
-
-
- // Formula:
- // (Damage/Sec * Weapon spefic change to get that damage)
- // *(Time to get to target * weapon specfic hitchange bonus) / (in a time of maxdelaytime)
- // *(Spread change of hit) // if it applies
- // *(Penality for target beeing in air)
- // %weaponaddpoint
-
- traceline(self.enemy.origin,self.enemy.origin-'0 0 1000',TRUE,world);
- distancefromfloor = self.enemy.origin_z - trace_endpos_z;
-
- if (client_hasweapon(self, WEP_MINSTANEX, TRUE, FALSE))
- minstanex = (1000/cvar("g_balance_minstanex_refire")*1.0)
- * (0.5);
-
- if (client_hasweapon(self, WEP_ROCKET_LAUNCHER, TRUE, FALSE) &&
- !( cvar("bot_ai_weapon_combo") && self.weapon == WEP_ROCKET_LAUNCHER &&
- af > combo_time
- )
- )
- rocket = (cvar("g_balance_rocketlauncher_damage")/cvar("g_balance_rocketlauncher_refire")*0.75)
- * bound(0,(cvar("g_balance_rocketlauncher_speed")/distance*maxdelaytime),1)*1.5;
-
- if (client_hasweapon(self, WEP_NEX, TRUE, FALSE) &&
- !( cvar("bot_ai_weapon_combo") && self.weapon == WEP_NEX &&
- af > combo_time
- )
- )
- nex = (cvar("g_balance_nex_damage")/cvar("g_balance_nex_refire")*1.0)
- * (0.5);
-
- if (client_hasweapon(self, WEP_HAGAR, TRUE, FALSE) ) // &&
- // !( cvar("bot_ai_weapon_combo") && self.weapon == WEP_HAGAR && time < self.bot_lastshot + cvar("g_balance_hagar_primary_refire") ))
- hagar = (cvar("g_balance_hagar_primary_damage")/cvar("g_balance_hagar_primary_refire")*1.0)
- * bound(0,(cvar("g_balance_hagar_primary_speed")/distance*maxdelaytime),1)*0.2;
-
- if (client_hasweapon(self, WEP_GRENADE_LAUNCHER, TRUE, FALSE) &&
- !(
- cvar("bot_ai_weapon_combo") && self.weapon == WEP_GRENADE_LAUNCHER &&
- af > combo_time
- )
- )
- grenade = (cvar("g_balance_grenadelauncher_primary_damage")/cvar("g_balance_grenadelauncher_primary_refire")*1.0)
- * bound(0,(cvar("g_balance_grenadelauncher_primary_speed")/distance*maxdelaytime),1)*1.1;
-
- if (client_hasweapon(self, WEP_MINE_LAYER, TRUE, FALSE) &&
- !(
- cvar("bot_ai_weapon_combo") && self.weapon == WEP_MINE_LAYER &&
- af > combo_time
- )
- )
- mine = (cvar("g_balance_minelayer_damage")/cvar("g_balance_minelayer_refire")*1.0)
- * bound(0,(cvar("g_balance_minelayer_speed")/distance*maxdelaytime),1)*1.1;
-
- if (client_hasweapon(self, WEP_ELECTRO, TRUE, FALSE) &&
- !( cvar("bot_ai_weapon_combo") && self.weapon == WEP_ELECTRO &&
- af > combo_time
- )
- )
- electro = (cvar("g_balance_electro_primary_damage")/cvar("g_balance_electro_primary_refire")*0.75)
- * bound(0,(cvar("g_balance_electro_primary_speed")/distance*maxdelaytime),1)*1.0;
-
- if (client_hasweapon(self, WEP_CRYLINK, TRUE, FALSE) ) // &&
- // !( self.weapon == WEP_CRYLINK && time < self.bot_lastshot + cvar("g_balance_crylink_primary_refire") ))
- crylink = (cvar("g_balance_crylink_primary_damage")/cvar("g_balance_crylink_primary_refire")*1.0)
- * bound(0,(cvar("g_balance_crylink_primary_speed")/distance*maxdelaytime),1)*(64/(32+cvar("g_balance_crylink_primary_spread")*distance))*1.0;
-
- if (client_hasweapon(self, WEP_UZI, TRUE, FALSE) ) // &&
- // !( self.weapon == WEP_UZI && time < self.bot_lastshot + cvar("g_balance_uzi_sustained_refire") ))
- uzi = (cvar("g_balance_uzi_sustained_damage")/cvar("g_balance_uzi_sustained_refire")*1.0)
- * bound(0,32/(32+cvar("g_balance_uzi_sustained_spread")*distance),1);
-
- if (client_hasweapon(self, WEP_SHOTGUN, TRUE, FALSE) &&
- !( cvar("bot_ai_weapon_combo") && self.weapon == WEP_SHOTGUN &&
- af > combo_time
- )
- )
- shotgun = (cvar("g_balance_shotgun_primary_damage")*cvar("g_balance_shotgun_primary_bullets")/cvar("g_balance_shotgun_primary_refire")*1.0)
- * bound(0,32/(32+cvar("g_balance_shotgun_primary_spread")*distance),1);
-
- if (client_hasweapon(self, WEP_LASER, FALSE, FALSE) &&
- !( cvar("bot_ai_weapon_combo") && self.weapon == WEP_LASER &&
- af > combo_time
- )
- )
- laser = (cvar("g_balance_laser_primary_damage")/cvar("g_balance_laser_primary_refire")*1.0)
- * bound(0,cvar("g_balance_laser_primary_speed")/distance*maxdelaytime,1);
-
- if((self.enemy.flags & FL_ONGROUND)==FALSE){
- rocket = rocket * (1.5-bound(0, distancefromfloor/cvar("g_balance_rocketlauncher_radius" ),0.9)); //slight bigger change
- grenade = grenade * (1.5-bound(0,distancefromfloor/cvar("g_balance_grenadelauncher_primary_radius"),0.95));
- electro = electro * (1.5-bound(0,distancefromfloor/cvar("g_balance_electro_primary_radius" ),0.95));
- laser = laser * (1.5-bound(0,distancefromfloor/cvar("g_balance_laser_primary_radius" ),0.95));
- }
- /*
- dprint("Floor distance: ",ftos(distancefromfloor),"\n");
- dprint("Rocket: " , ftos(rocket ), "\n");
- dprint("Nex: " , ftos(nex ), "\n");
- dprint("Hagar: " , ftos(hagar ), "\n");
- dprint("Grenade: ", ftos(grenade ), "\n");
- dprint("Mine: " , ftos(mine ), "\n");
- dprint("Electro: ", ftos(electro ), "\n");
- dprint("Crylink: ", ftos(crylink ), "\n");
- dprint("Uzi: " , ftos(uzi ), "\n");
- dprint("Shotgun :", ftos(shotgun ), "\n");
- dprint("Laser :", ftos(laser ), "\n\n");
- */
- currentscore = -1;
- w = WEP_MINSTANEX ;s = minstanex;if (s > bestscore){bestscore = s;bestweapon = w;} if (self.switchweapon == w) currentscore = s;
- w = WEP_ROCKET_LAUNCHER ;s = rocket ;if (s > bestscore){bestscore = s;bestweapon = w;} if (self.switchweapon == w) currentscore = s;
- w = WEP_NEX ;s = nex ;if (s > bestscore){bestscore = s;bestweapon = w;} if (self.switchweapon == w) currentscore = s;
- w = WEP_HAGAR ;s = hagar ;if (s > bestscore){bestscore = s;bestweapon = w;} if (self.switchweapon == w) currentscore = s;
- w = WEP_GRENADE_LAUNCHER ;s = grenade ;if (s > bestscore){bestscore = s;bestweapon = w;} if (self.switchweapon == w) currentscore = s;
- w = WEP_MINE_LAYER ;s = mine ;if (s > bestscore){bestscore = s;bestweapon = w;} if (self.switchweapon == w) currentscore = s;
- w = WEP_ELECTRO ;s = electro ;if (s > bestscore){bestscore = s;bestweapon = w;} if (self.switchweapon == w) currentscore = s;
- w = WEP_CRYLINK ;s = crylink ;if (s > bestscore){bestscore = s;bestweapon = w;} if (self.switchweapon == w) currentscore = s;
- w = WEP_UZI ;s = uzi ;if (s > bestscore){bestscore = s;bestweapon = w;} if (self.switchweapon == w) currentscore = s;
- w = WEP_SHOTGUN ;s = shotgun ;if (s > bestscore){bestscore = s;bestweapon = w;} if (self.switchweapon == w) currentscore = s;
- w = WEP_LASER ;s = laser ;if (s > bestscore){bestscore = s;bestweapon = w;} if (self.switchweapon == w) currentscore = s;
-
- // switch if the best weapon would provide a significant damage increase
- if (bestscore > currentscore*1.5){
- self.switchweapon = bestweapon;
-
- // buys time for detonating the rocket. not tested yet
- if ( cvar("bot_ai_weapon_combo") && bestweapon == WEP_ROCKET_LAUNCHER )
- self.bot_chooseweapontime += (distance / cvar("g_balance_rocketlauncher_speed"));
- }
-#endif