/** * @brief Add ammo. * @return whether any ammo was added */ int Add_Ammo(gentity_t *ent, int weapon, int count, qboolean fillClip) { int ammoweap = BG_FindAmmoForWeapon(weapon); int maxammo = BG_MaxAmmoForWeapon(ammoweap, ent->client->sess.skill); int originalCount = ent->client->ps.ammo[ammoweap]; // FIXME: do a switch if (ammoweap == WP_GRENADE_LAUNCHER) // make sure if he picks up a grenade that he get's the "launcher" too { COM_BitSet(ent->client->ps.weapons, WP_GRENADE_LAUNCHER); fillClip = qtrue; // grenades always filter into the "clip" } else if (ammoweap == WP_GRENADE_PINEAPPLE) { COM_BitSet(ent->client->ps.weapons, WP_GRENADE_PINEAPPLE); fillClip = qtrue; // grenades always filter into the "clip" } else if (ammoweap == WP_DYNAMITE) { COM_BitSet(ent->client->ps.weapons, WP_DYNAMITE); fillClip = qtrue; } else if (ammoweap == WP_SATCHEL_DET) { COM_BitSet(ent->client->ps.weapons, WP_SATCHEL_DET); fillClip = qtrue; } if (fillClip) { Fill_Clip(&ent->client->ps, weapon); } if (ammoweap == WP_PANZERFAUST || ammoweap == WP_BAZOOKA || ammoweap == WP_FLAMETHROWER) { ent->client->ps.ammoclip[ammoweap] += count; if (ent->client->ps.ammoclip[ammoweap] > maxammo) { ent->client->ps.ammoclip[ammoweap] = maxammo; // - ent->client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; } } else { ent->client->ps.ammo[ammoweap] += count; if (ent->client->ps.ammo[ammoweap] > maxammo) { ent->client->ps.ammo[ammoweap] = maxammo; // - ent->client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; } } if (count >= 999) // 'really, give /all/' { ent->client->ps.ammo[ammoweap] = count; } return (ent->client->ps.ammo[ammoweap] > originalCount); }
/** * @brief Add ammo. * @param ent * @param weapon * @param count * @param fillClip * @return whether any ammo was added */ int Add_Ammo(gentity_t *ent, weapon_t weapon, int count, qboolean fillClip) { weapon_t ammoweap = GetWeaponTableData(weapon)->ammoIndex; int maxammo = BG_MaxAmmoForWeapon(ammoweap, ent->client->sess.skill); int originalCount = ent->client->ps.ammo[ammoweap]; if (GetWeaponTableData(ammoweap)->isGrenade || ammoweap == WP_DYNAMITE || ammoweap == WP_SATCHEL_DET) // make sure if he picks it up that he get's the "launcher" too { COM_BitSet(ent->client->ps.weapons, ammoweap); fillClip = qtrue; // always filter into the "clip" } if (fillClip) { Fill_Clip(&ent->client->ps, weapon); } if (GetWeaponTableData(ammoweap)->isPanzer || ammoweap == WP_FLAMETHROWER) { ent->client->ps.ammoclip[ammoweap] += count; if (ent->client->ps.ammoclip[ammoweap] > maxammo) { ent->client->ps.ammoclip[ammoweap] = maxammo; // - ent->client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; } } else { ent->client->ps.ammo[ammoweap] += count; if (ent->client->ps.ammo[ammoweap] > maxammo) { ent->client->ps.ammo[ammoweap] = maxammo; // - ent->client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; } } if (count >= 999) // 'really, give /all/' { ent->client->ps.ammo[ammoweap] = count; } return (ent->client->ps.ammo[ammoweap] > originalCount); }
//----(SA) modified void Add_Ammo( gentity_t *ent, int weapon, int count, qboolean fillClip ) { int ammoweap = BG_FindAmmoForWeapon( weapon ); int totalcount; ent->client->ps.ammo[ammoweap] += count; if ( ammoweap == WP_GRENADE_LAUNCHER ) { // make sure if he picks up a grenade that he get's the "launcher" too COM_BitSet( ent->client->ps.weapons, WP_GRENADE_LAUNCHER ); fillClip = qtrue; // grenades always filter into the "clip" } else if ( ammoweap == WP_GRENADE_PINEAPPLE ) { COM_BitSet( ent->client->ps.weapons, WP_GRENADE_PINEAPPLE ); fillClip = qtrue; // grenades always filter into the "clip" } else if ( ammoweap == WP_DYNAMITE || ammoweap == WP_DYNAMITE2 ) { COM_BitSet( ent->client->ps.weapons, WP_DYNAMITE ); fillClip = qtrue; } if ( fillClip ) { Fill_Clip( &ent->client->ps, weapon ); } // cap to max ammo if ( g_dmflags.integer & DF_NO_WEAPRELOAD ) { // no clips totalcount = ent->client->ps.ammo[ammoweap]; if ( totalcount > ammoTable[ammoweap].maxammo ) { ent->client->ps.ammo[ammoweap] = ammoTable[ammoweap].maxammo; } } else { // using clips totalcount = ent->client->ps.ammo[ammoweap] + ent->client->ps.ammoclip[BG_FindClipForWeapon( weapon )]; if ( totalcount > ammoTable[ammoweap].maxammo ) { ent->client->ps.ammo[ammoweap] = ammoTable[ammoweap].maxammo - ent->client->ps.ammoclip[BG_FindClipForWeapon( weapon )]; } } if ( count >= 999 ) { // 'really, give /all/' ent->client->ps.ammo[ammoweap] = count; } // JPW NERVE }
/* ============ AICast_CreateCharacter returns 0 if unable to create the character ============ */ gentity_t *AICast_CreateCharacter( gentity_t *ent, float *attributes, cast_weapon_info_t *weaponInfo, char *castname, char *model, char *head, char *sex, char *color, char *handicap ) { gentity_t *newent; gclient_t *client; cast_state_t *cs; char **ppStr; int j; if (g_gametype.integer != GT_SINGLE_PLAYER) { // no cast AI in multiplayer return NULL; } // are bots enabled? if ( !trap_Cvar_VariableIntegerValue( "bot_enable" ) ) { G_Printf( S_COLOR_RED "ERROR: Unable to spawn %s, 'bot_enable' is not set\n", ent->classname ); return NULL; } // // make sure we have a free slot for them // if (level.numPlayingClients+1 > aicast_maxclients) { G_Error( "Exceeded sv_maxclients (%d), unable to create %s\n", aicast_maxclients, ent->classname ); return NULL; } // // add it to the list (only do this if everything else passed) // newent = AICast_AddCastToGame( ent, castname, model, head, sex, color, handicap ); if (!newent) { return NULL; } client = newent->client; // // setup the character.. // cs = AICast_GetCastState( newent->s.number ); // // setup the attributes memcpy( cs->attributes, attributes, sizeof(cs->attributes) ); ppStr = &ent->aiAttributes; AICast_CheckLevelAttributes( cs, ent, ppStr ); // AICast_SetAASIndex( cs ); // make sure they face the right direction VectorCopy( ent->s.angles, cs->bs->ideal_viewangles ); // factor in the delta_angles for (j = 0; j < 3; j++) { cs->bs->viewangles[j] = AngleMod(newent->s.angles[j] - SHORT2ANGLE(newent->client->ps.delta_angles[j])); } VectorCopy( ent->s.angles, newent->s.angles ); VectorCopy( ent->s.origin, cs->startOrigin ); // cs->lastEnemy = -1; cs->bs->enemy = -1; cs->leaderNum = -1; cs->castScriptStatus.scriptGotoEnt = -1; cs->aiCharacter = ent->aiCharacter; // newent->aiName = ent->aiName; newent->aiTeam = ent->aiTeam; newent->targetname = ent->targetname; // newent->AIScript_AlertEntity = ent->AIScript_AlertEntity; newent->aiInactive = ent->aiInactive; newent->aiCharacter = cs->aiCharacter; // // parse the AI script for this character (if applicable) cs->aiFlags |= AIFL_CORPSESIGHTING; // this is on by default for all characters, disabled if they have a "friendlysightcorpse" script event AICast_ScriptParse( cs ); // // setup bounding boxes //VectorCopy( mins, client->ps.mins ); //VectorCopy( maxs, client->ps.maxs ); AIChar_SetBBox( newent, cs ); client->ps.friction = cs->attributes[RUNNING_SPEED]/300.0; // // clear weapons/ammo client->ps.weapon = 0; memcpy( client->ps.weapons, weaponInfo->startingWeapons, sizeof(weaponInfo->startingWeapons) ); memcpy( client->ps.ammo, weaponInfo->startingAmmo, sizeof(client->ps.ammo) ); // // starting health if (ent->health) { newent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH] = ent->health; } else { newent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH] = cs->attributes[STARTING_HEALTH]; } // cs->weaponInfo = weaponInfo; // cs->lastThink = level.time; // newent->pain = AICast_Pain; newent->die = AICast_Die; // //update the attack inventory values AICast_UpdateBattleInventory(cs, cs->bs->enemy); //----(SA) make sure all clips are loaded so we don't hear everyone loading up // (we don't want to do this inside AICast_UpdateBattleInventory(), only on spawn or giveweapon) for (j=0; j<MAX_WEAPONS; j++) { Fill_Clip (&client->ps, j); } //----(SA) end // select a weapon AICast_ChooseWeapon( cs, qfalse ); // // set the default function, overwrite if necessary cs->aiFlags |= AIFL_JUST_SPAWNED; AIFunc_DefaultStart( cs ); // numcast++; // return newent; }