@@ -1263,7 +1263,7 @@ qboolean BOT_DMclass_FindEnemy(edict_t* self)
12631263 if (AIEnemies [i ] == NULL || AIEnemies [i ] == self )
12641264 continue ;
12651265
1266- if (!G_ValidTargetEnt (AIEnemies [i ], true))
1266+ if (!G_ValidTargetEnt (self , AIEnemies [i ], true))
12671267 continue ;
12681268
12691269 dist = entdist (self , AIEnemies [i ]);
@@ -1756,10 +1756,17 @@ void BOT_DMclass_WeightPlayers(edict_t *self)
17561756 {
17571757 // GHz: chase enemies!
17581758 if (self -> enemy && self -> enemy -> inuse && AIEnemies [i ] == self -> enemy )
1759- self -> ai .status .playersWeights [i ] = 0.9 ;
1759+ self -> ai .status .playersWeights [i ] = 0.9 ; // active enemy always has the highest priority/weight
1760+ else if (AIEnemies [i ]-> client )
1761+ {
1762+ if (AIEnemies [i ]-> myskills .streak >= SPREE_START )
1763+ self -> ai .status .playersWeights [i ] = 0.6 ; // spreeing players are weighed much higher
1764+ else
1765+ self -> ai .status .playersWeights [i ] = 0.3 ; // players have more weight than non-clients (e.g. monsters)
1766+ }
17601767 else
17611768 //if not at ctf every player has some value
1762- self -> ai .status .playersWeights [i ] = 0.3 ;
1769+ self -> ai .status .playersWeights [i ] = 0.2 ;
17631770 }
17641771 }
17651772
@@ -1840,10 +1847,14 @@ void AI_AdjustAmmoNeedFactor(edict_t *self, gitem_t *ammoItem, ...)
18401847 }
18411848
18421849 // does the bot need cells for power screen/shield?
1843- if (ammo_index == cell_index && AI_GetPSlevel (self ))
1850+ if (ammo_index == cell_index && AI_GetPSlevel (self ) && self -> client -> pers .inventory [cell_index ] < self -> client -> pers .max_cells )
1851+ {
1852+ self -> ai .status .inventoryWeights [ammo_index ] = 0.5 ;
18441853 return ; // don't reduce cells weight
1854+ }
18451855
18461856 // morphed players don't typically need ammo (except for summoners, e.g. engy)
1857+ // note: this adjustment may be redundant if the bot is a poltergeist, since the weight should already be 0 in ai.pers.inventoryWeights
18471858 if (self -> mtype || PM_PlayerHasMonster (self ))
18481859 {
18491860 self -> ai .status .inventoryWeights [ammo_index ] = 0.0 ;
@@ -1998,6 +2009,8 @@ void BOT_DMclass_WeightInventory(edict_t *self)
19982009 //shards are ALWAYS accepted but still...
19992010 if (!AI_CanUseArmor ( FindItemByClassname ("item_armor_shard" ), self ))
20002011 self -> ai .status .inventoryWeights [armor_shard_index ] = 0.0 ;
2012+ else if (self -> client -> pers .inventory [power_cube_index ] < 50 ) // low on power cubes?
2013+ self -> ai .status .inventoryWeights [armor_shard_index ] *= 2.0 ; // increase weight of armor shards
20012014
20022015 if (!AI_CanUseArmor ( FindItemByClassname ("item_armor_jacket" ), self ))
20032016 self -> ai .status .inventoryWeights [jacket_armor_index ] = 0.0 ;
@@ -2007,7 +2020,8 @@ void BOT_DMclass_WeightInventory(edict_t *self)
20072020
20082021 if (!AI_CanUseArmor ( FindItemByClassname ("item_armor_body" ), self ))
20092022 self -> ai .status .inventoryWeights [body_armor_index ] = 0.0 ;
2010-
2023+ //gi.dprintf("sh:%.1f ja:%.1f co:%.1f bo:%.1f\n", self->ai.status.inventoryWeights[armor_shard_index], self->ai.status.inventoryWeights[jacket_armor_index],
2024+ // self->ai.status.inventoryWeights[combat_armor_index], self->ai.status.inventoryWeights[body_armor_index]);
20112025
20122026 //TECH :
20132027 //-----------------------------------------------------
@@ -2218,6 +2232,105 @@ void BOT_DMclass_RunFrame( edict_t *self )
22182232 self -> nextthink = level .time + FRAMETIME ;
22192233}
22202234
2235+ void BOT_PrintItemWeights (edict_t * self )
2236+ {
2237+ gi .dprintf ("sh:%.1f bu:%.1f ce:%.1f ro:%.1f sl:%.1f gr:%.1f\n" , self -> ai .pers .inventoryWeights [shell_index ], self -> ai .pers .inventoryWeights [bullet_index ],
2238+ self -> ai .pers .inventoryWeights [cell_index ], self -> ai .pers .inventoryWeights [rocket_index ], self -> ai .pers .inventoryWeights [slug_index ],
2239+ self -> ai .pers .inventoryWeights [grenade_index ]);
2240+ }
2241+
2242+ void BOT_DMclass_InitPersistantWeights (edict_t * self )
2243+ {
2244+ //Persistant Inventory Weights (0 = can not pick)
2245+ memset (self -> ai .pers .inventoryWeights , 0 , sizeof (self -> ai .pers .inventoryWeights ));
2246+
2247+ // note: the weights below are baseline and will later be adjusted based on bot status/need by BOT_DMclass_WeightInventory
2248+
2249+ if (self -> myskills .class_num == CLASS_KNIGHT || self -> myskills .class_num == CLASS_POLTERGEIST ) // knights and poltergeists don't use weapons and ammo
2250+ {
2251+ //weapons
2252+ self -> ai .pers .inventoryWeights [blaster_index ] = 0.0 ;
2253+ self -> ai .pers .inventoryWeights [sword_index ] = 0.0 ;
2254+ self -> ai .pers .inventoryWeights [_20mmcannon_index ] = 0.0 ;
2255+ self -> ai .pers .inventoryWeights [shotgun_index ] = 0.0 ;
2256+ self -> ai .pers .inventoryWeights [supershotgun_index ] = 0.0 ;
2257+ self -> ai .pers .inventoryWeights [machinegun_index ] = 0.0 ;
2258+ self -> ai .pers .inventoryWeights [chaingun_index ] = 0.0 ;
2259+ self -> ai .pers .inventoryWeights [grenadelauncher_index ] = 0.0 ;
2260+ self -> ai .pers .inventoryWeights [rocketlauncher_index ] = 0.0 ;
2261+ self -> ai .pers .inventoryWeights [hyperblaster_index ] = 0.0 ;
2262+ self -> ai .pers .inventoryWeights [railgun_index ] = 0.0 ;
2263+ self -> ai .pers .inventoryWeights [bfg10k_index ] = 0.0 ;
2264+
2265+ //ammo
2266+ self -> ai .pers .inventoryWeights [shell_index ] = 0.0 ;
2267+ self -> ai .pers .inventoryWeights [bullet_index ] = 0.0 ;
2268+ self -> ai .pers .inventoryWeights [cell_index ] = 0.0 ;
2269+ self -> ai .pers .inventoryWeights [rocket_index ] = 0.0 ;
2270+ self -> ai .pers .inventoryWeights [slug_index ] = 0.0 ;
2271+ self -> ai .pers .inventoryWeights [grenade_index ] = 0.0 ;
2272+ }
2273+ else
2274+ {
2275+ //weapons
2276+ self -> ai .pers .inventoryWeights [blaster_index ] = 0.0 ;
2277+ self -> ai .pers .inventoryWeights [sword_index ] = 0.0 ;
2278+ self -> ai .pers .inventoryWeights [_20mmcannon_index ] = 0.0 ;
2279+ self -> ai .pers .inventoryWeights [shotgun_index ] = 0.5 ;
2280+ self -> ai .pers .inventoryWeights [supershotgun_index ] = 0.7 ;
2281+ self -> ai .pers .inventoryWeights [machinegun_index ] = 0.5 ;
2282+ self -> ai .pers .inventoryWeights [chaingun_index ] = 0.7 ;
2283+ self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_GRENADES ].weaponItem )] = 0.5 ;// isn't this redundant with grenade_index below?
2284+ self -> ai .pers .inventoryWeights [grenadelauncher_index ] = 0.6 ;
2285+ self -> ai .pers .inventoryWeights [rocketlauncher_index ] = 0.8 ;
2286+ self -> ai .pers .inventoryWeights [hyperblaster_index ] = 0.7 ;
2287+ self -> ai .pers .inventoryWeights [railgun_index ] = 0.8 ;
2288+ self -> ai .pers .inventoryWeights [bfg10k_index ] = 0.5 ;
2289+
2290+ //ammo
2291+ self -> ai .pers .inventoryWeights [shell_index ] = 0.5 ;
2292+ self -> ai .pers .inventoryWeights [bullet_index ] = 0.5 ;
2293+ self -> ai .pers .inventoryWeights [cell_index ] = 0.5 ;
2294+ self -> ai .pers .inventoryWeights [rocket_index ] = 0.5 ;
2295+ self -> ai .pers .inventoryWeights [slug_index ] = 0.5 ;
2296+ self -> ai .pers .inventoryWeights [grenade_index ] = 0.5 ;
2297+ }
2298+
2299+ //armor
2300+ if (self -> myskills .class_num == CLASS_POLTERGEIST ) // poltergeists don't use body armor
2301+ {
2302+ self -> ai .pers .inventoryWeights [body_armor_index ] = 0.0 ;
2303+ self -> ai .pers .inventoryWeights [combat_armor_index ] = 0.0 ;
2304+ self -> ai .pers .inventoryWeights [jacket_armor_index ] = 0.0 ;
2305+ self -> ai .pers .inventoryWeights [armor_shard_index ] = 0.2 ; // for powercubes
2306+ }
2307+ else
2308+ {
2309+ self -> ai .pers .inventoryWeights [body_armor_index ] = 0.9 ;
2310+ self -> ai .pers .inventoryWeights [combat_armor_index ] = 0.8 ;
2311+ self -> ai .pers .inventoryWeights [jacket_armor_index ] = 0.5 ;
2312+ self -> ai .pers .inventoryWeights [armor_shard_index ] = 0.2 ;
2313+ }
2314+
2315+ //techs
2316+ self -> ai .pers .inventoryWeights [resistance_index ] = 0.5 ;
2317+ self -> ai .pers .inventoryWeights [strength_index ] = 0.5 ;
2318+ self -> ai .pers .inventoryWeights [regeneration_index ] = 0.5 ;
2319+ self -> ai .pers .inventoryWeights [haste_index ] = 0.5 ;
2320+
2321+ //GHz: misc items and powerups
2322+ self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("item_pack" ))] = 0.6 ;
2323+ self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("item_quad" ))] = 2.0 ;
2324+ self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("item_invulnerability" ))] = 2.0 ;
2325+
2326+ if (ctf -> value ) {
2327+ redflag = FindItemByClassname ("item_flag_team1" ); // store pointers to flags gitem_t, for
2328+ blueflag = FindItemByClassname ("item_flag_team2" );// simpler comparisons inside this archive
2329+ self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("item_flag_team1" ))] = 3.0 ;
2330+ self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("item_flag_team2" ))] = 3.0 ;
2331+ }
2332+ //BOT_PrintItemWeights(self);//TESTING!!!!!!!!!!!!!!!
2333+ }
22212334
22222335//==========================================
22232336// BOT_DMclass_InitPersistant
@@ -2242,54 +2355,7 @@ void BOT_DMclass_InitPersistant(edict_t *self)
22422355 //available moveTypes for this class
22432356 self -> ai .pers .moveTypesMask = (LINK_MOVE |LINK_STAIRS |LINK_FALL |LINK_WATER |LINK_WATERJUMP |LINK_JUMPPAD |LINK_PLATFORM |LINK_TELEPORT |LINK_LADDER |LINK_JUMP |LINK_CROUCH );
22442357
2245- //Persistant Inventory Weights (0 = can not pick)
2246- memset (self -> ai .pers .inventoryWeights , 0 , sizeof (self -> ai .pers .inventoryWeights ));
2247-
2248- //weapons
2249- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_BLASTER ].weaponItem )] = 0.0 ;
2250- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_SWORD ].weaponItem )] = 0.0 ;
2251- //self->bot.pers.inventoryWeights[ITEM_INDEX(FindItemByClassname("weapon_blaster"))] = 0.0; //it's the same thing
2252- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_20MM ].weaponItem )] = 0.0 ;
2253- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_SHOTGUN ].weaponItem )] = 0.5 ;
2254- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_SUPERSHOTGUN ].weaponItem )] = 0.7 ;
2255- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_MACHINEGUN ].weaponItem )] = 0.5 ;
2256- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_CHAINGUN ].weaponItem )] = 0.7 ;
2257- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_GRENADES ].weaponItem )] = 0.5 ;
2258- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_GRENADELAUNCHER ].weaponItem )] = 0.6 ;
2259- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_ROCKETLAUNCHER ].weaponItem )] = 0.8 ;
2260- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_HYPERBLASTER ].weaponItem )] = 0.7 ;
2261- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_RAILGUN ].weaponItem )] = 0.8 ;
2262- self -> ai .pers .inventoryWeights [ITEM_INDEX (AIWeapons [WEAP_BFG ].weaponItem )] = 0.5 ;
2263-
2264- //ammo
2265- self -> ai .pers .inventoryWeights [shell_index ] = 0.5 ;
2266- self -> ai .pers .inventoryWeights [bullet_index ] = 0.5 ;
2267- self -> ai .pers .inventoryWeights [cell_index ] = 0.5 ;
2268- self -> ai .pers .inventoryWeights [rocket_index ] = 0.5 ;
2269- self -> ai .pers .inventoryWeights [slug_index ] = 0.5 ;
2270- self -> ai .pers .inventoryWeights [grenade_index ] = 0.5 ;
2271-
2272- //armor
2273- self -> ai .pers .inventoryWeights [body_armor_index ] = 0.9 ;
2274- self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("item_armor_combat" ))] = 0.8 ;
2275- self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("item_armor_jacket" ))] = 0.5 ;
2276- self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("item_armor_shard" ))] = 0.2 ;
2277-
2278- //techs
2279- self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("tech_resistance" ))] = 0.5 ;
2280- self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("tech_strength" ))] = 0.5 ;
2281- self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("tech_regeneration" ))] = 0.5 ;
2282- self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("tech_haste" ))] = 0.5 ;
2283-
2284- //GHz: misc
2285- self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("item_pack" ))] = 0.6 ;
2286-
2287- if ( ctf -> value ) {
2288- redflag = FindItemByClassname ("item_flag_team1" ); // store pointers to flags gitem_t, for
2289- blueflag = FindItemByClassname ("item_flag_team2" );// simpler comparisons inside this archive
2290- self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("item_flag_team1" ))] = 3.0 ;
2291- self -> ai .pers .inventoryWeights [ITEM_INDEX (FindItemByClassname ("item_flag_team2" ))] = 3.0 ;
2292- }
2358+ //BOT_DMclass_InitPersistantWeights(self);
22932359}
22942360
22952361//==========================================
0 commit comments