.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
What about this......
Old
  (#1)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default What about this...... - 25-02-2004

Code:
 int UTIL_GetTeam(edict_t *pEntity)
 {
    char t = g_engfuncs.pfnInfoKeyValue(g_engfuncs.pfnGetInfoKeyBuffer(pEntity), "model")[2];
    if (t == 'r' || t == 'a' || t == 'e' || t == 'c')
 	  return TEAM_TERRORIST;
    return TEAM_CT;
 }
  
Reply With Quote
Re: What about this......
Old
  (#2)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: What about this...... - 25-02-2004

Überl33t!

consider your post copy/pasted 'n' credited

...

me too, I have something to show you, guys <jump></jump>:
Code:
// weapon classes
#define WEAPON_CLASS_PRIMARY 1 // primary (main) weapon
#define WEAPON_CLASS_SECONDARY 2 // side weapon, instant hit capability
#define WEAPON_CLASS_GRENADE 3 // side weapon, explosive

// weapon rail properties
#define WEAPONRAIL_PROPERTY_DISABLER (1 << 0) // disabling effect (e.g, blinds or freezes enemy)
#define WEAPONRAIL_PROPERTY_WATERPROOF (1 << 1) // can be used underwater
#define WEAPONRAIL_PROPERTY_LIGHTDAMAGE (1 << 2) // light damage, almost never lethal
#define WEAPONRAIL_PROPERTY_MEDIUMDAMAGE (1 << 3) // medium damage, may be lethal
#define WEAPONRAIL_PROPERTY_HEAVYDAMAGE (1 << 4) // heavy damage, almost always lethal
#define WEAPONRAIL_PROPERTY_RADIUSEFFECT (1 << 5) // radius effect (e.g, grenade blast)
#define WEAPONRAIL_PROPERTY_AUTOMATIC (1 << 6) // automatic firing capability
#define WEAPONRAIL_PROPERTY_BUCKSHOT (1 << 7) // bucket firing capability (several impacts at once)
#define WEAPONRAIL_PROPERTY_SCOPED (1 << 8) // scoping capability (medium range lens)
#define WEAPONRAIL_PROPERTY_SNIPER (1 << 9) // zooming capability (long range lens)
#define WEAPONRAIL_PROPERTY_SILENCED (1 << 10) // silent shot capability
#define WEAPONRAIL_PROPERTY_MISSILE (1 << 11) // missile (no instant hit)
#define WEAPONRAIL_PROPERTY_HOMING (1 << 12) // homing capability (only relevant on missiles)
#define WEAPONRAIL_PROPERTY_TOSS (1 << 13) // needs to be tossed at target
#define WEAPONRAIL_PROPERTY_PLACE (1 << 14) // needs to be placed (proximity bomb)
#define WEAPONRAIL_PROPERTY_BIT16 (1 << 15) // unused yet

// weapon rail ranges
#define WEAPONRAIL_RANGE_MELEE (1 << 0) // melee only (close combat)
#define WEAPONRAIL_RANGE_CLOSE (1 << 1) // close range (0 - 6 meters)
#define WEAPONRAIL_RANGE_MEDIUM (1 << 2) // medium range (6 - 40 meters)
#define WEAPONRAIL_RANGE_FAR (1 << 3) // long range (> 40 meters)
 
// game weapons structure definition
typedef struct
{
   short properties; // bitmask of available properties (see WEAPONRAIL_PROPERTY_xx #define's)
   char range; // best range for maximum rail efficiency (WEAPONRAIL_RANGE_xx)
   char type_of_ammo; // type of ammo this rail uses (i.e, index to use in the ammo array)
   short min_ammo; // minimum ammout of ammo this rail needs to fire
   short max_ammo; // maximum amount of ammo this rail can hold
   float charge_delay; // amount of time needed to charge the rail before firing
   char sound1[64]; // relative path to sound sample for normal mode firing in this rail
   char sound2[64]; // relative path to sound sample for alternate mode firing in this rail
   float min_delay[5]; // array of 5 skill-dependent minimal reaction delay values for the AI
   float max_delay[5]; // array of 5 skill-dependent maximal reaction delay values for the AI
} weapon_rail_t;

typedef struct
{
   char classname[64]; // the weapon entity classname, in all letters
   char model[64]; // relative path to the weapon model ("models/p_" model)
   int id; // weapon ID
   float weight; // weight of weapon, if appliable
   char weapon_class; // class of weapon (primary, secondary, grenade - see WEAPON_CLASS_xx)
   int price; // price of weapon, if it needs to be bought
   char buy_command[64]; // command to be issued by a player in order to buy this weapon
   weapon_rail_t primary; // primary weapon rail
   weapon_rail_t secondary; // secondary weapon rail
} weapon_t;
and
Quote:
# RACC - Bot weapons configuration file
#
# This file contains information needed by the knowledge system
# about the weapons used in the game. The syntax is explicit.
#
# Any weapon can have up to 2 rails (fire modes). For example,
# a MP5 automatic submachinegun in the primary rail, and a
# grenade launcher in the secondary one.
#
# weapon classes:
# "primary": primary weapon
# "secondary": side weapon, firable
# "grenade": side weapon, tossable
#
# weapon rail properties (combinations are possible):
# "disabler": disabling effect (e.g, blinds or freezes enemy)
# "waterproof": can be used underwater
# "lightdamage": light damage, almost never lethal
# "mediumdamage": medium damage, may be lethal
# "heavydamage": heavy damage, almost always lethal
# "radiuseffect": damage radius effect (e.g, grenade blast)
# "automatic": automatic firing capability
# "buckshot": bucket firing capability (several impacts at once)
# "scoped": scoping capability (medium range lens)
# "sniper": zooming capability (long range lens)
# "silenced": silent shot capability
# "missile": missile (no instant hit)
# "homing": homing capability (only relevant on missiles)
# "toss": needs to be tossed at target
# "place": needs to be placed (proximity bomb)
#
# weapon rail ranges:
# "melee": melee only (close combat)
# "close": most efficient at close range (0 - 6 meters)
# "medium": most efficient at medium range (6 - 60 meters)
# "far": most efficient at long range (60 meters - infinity)
#
# Any void or sharp-prepended line will be ignored.

[weapon_flashbang]
model="models/p_flashbang.mdl"
id=25
slot=3
position=2
weight=
class="grenade"
price=300
buy_command="buyequip;menuselect 3"
primary.properties="disabler,radiuseffect,silenced ,missile,toss"
primary.range="medium"
primary.type_of_ammo=11
primary.min_ammo=1
primary.max_ammo=2
primary.charge_delay=0.0
primary.sound1="weapons/pinpull.wav"
primary.sound2="weapons/pinpull.wav"
primary.min_delay="0.5 0.4 0.3 0.2 0.1"
primary.max_delay="0.6 0.5 0.4 0.3 0.2"
secondary.properties=
secondary.range=
secondary.type_of_ammo=
secondary.min_ammo=
secondary.max_ammo=
secondary.charge_delay=
secondary.sound1=
secondary.sound2=
secondary.min_delay=
secondary.max_delay=

[weapon_g3sg1]
model="models/p_g3sg1.mdl"
id=24
weight=
class="primary"
price=5000
buy_command="buy;menuselect 4;menuselect 7"
primary.properties="waterproof,mediumdamage,automa tic,scoped,sniper"
primary.range="far"
primary.type_of_ammo=2
primary.min_ammo=1
primary.max_ammo=90
primary.charge_delay=0.2
primary.sound1="weapons/g3sg1-1.wav"
primary.sound2="weapons/g3sg1-1.wav"
primary.min_delay="0.5 0.4 0.3 0.2 0.1"
primary.max_delay="0.6 0.5 0.4 0.3 0.2"
secondary.properties=
secondary.range=
secondary.type_of_ammo=
secondary.min_ammo=
secondary.max_ammo=
secondary.charge_delay=
secondary.sound1=
secondary.sound2=
secondary.min_delay=
secondary.max_delay=
and
Code:
// example of use
 
	  // is the bot camping AND does this weapon NOT fit for the job ?
	  if ((pPlayer->Bot.f_camp_time > server.time)
		  && (PlayerHoldsWeaponOfClass (pPlayer, WEAPON_CLASS_GRENADE)
			  || PlayerHoldsWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_BUCKSHOT)
			  || PlayerHoldsWeaponOfRange (pPlayer, WEAPONRAIL_RANGE_MELEE)))
I have written a set of utility functions to deal with weapons in a MOD-independent fashion. These are:
Code:
// weapons.cpp function prototypes
void InitWeapons (void);
weapon_t *FindWeaponByName (const char *weapon_name);
weapon_t *FindWeaponByModel (const char *weapon_model);
weapon_t *FindWeaponById (const int weapon_id);
int WeaponIndexOf (weapon_t *weapon);
bool PlayerHasWeaponOfClass (player_t *pPlayer, char weapon_class);
bool PlayerHoldsWeaponOfClass (player_t *pPlayer, char weapon_class);
bool ItemIsWeaponOfClass (edict_t *pItem, char weapon_class);
bool BotSelectWeaponOfClass (player_t *pPlayer, char weapon_class);
bool PlayerHasWeaponOfType (player_t *pPlayer, short weaponrail_property);
bool PlayerHoldsWeaponOfType (player_t *pPlayer, short weaponrail_property);
bool ItemIsWeaponOfType (edict_t *pItem, short weaponrail_property);
bool BotSelectWeaponOfType (player_t *pPlayer, short weaponrail_property);
bool PlayerHasWeaponOfRange (player_t *pPlayer, char weaponrail_range);
bool PlayerHoldsWeaponOfRange (player_t *pPlayer, char weaponrail_range);
bool ItemIsWeaponOfRange (edict_t *pItem, char weaponrail_range);
bool BotSelectWeaponOfRange (player_t *pPlayer, char weaponrail_range);
int BotRateWeapon (player_t *pPlayer, weapon_t *weapon);
I have NOT a SINGLE thing such as "CS_WEAPON_XXX" or any other MOD-specific weapon reasoning code in my bot code now. Totally MOD-independent. Change the weapons config in the weapons.cfg file, plug the bot into the new MOD, and here ya go



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com