这篇教程C++ Add_Ammo函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中Add_Ammo函数的典型用法代码示例。如果您正苦于以下问题:C++ Add_Ammo函数的具体用法?C++ Add_Ammo怎么用?C++ Add_Ammo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了Add_Ammo函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: Pickup_Weapon/** Pickup_Weapon*/bool Pickup_Weapon( edict_t *other, const gsitem_t *item, int flags, int ammo_count ){ int ammo_tag; gs_weapon_definition_t *weapondef; weapondef = GS_GetWeaponDef( item->tag ); other->r.client->ps.inventory[item->tag]++; // never allow the player to carry more than 2 copies of the same weapon if( other->r.client->ps.inventory[item->tag] > item->inventory_max ) other->r.client->ps.inventory[item->tag] = item->inventory_max; if( !(flags & DROPPED_ITEM) ) { // give them some ammo with it ammo_tag = item->ammo_tag; if( ammo_tag ) Add_Ammo( other->r.client, GS_FindItemByTag( ammo_tag ), weapondef->firedef.weapon_pickup, true ); } else { // it's a dropped weapon ammo_tag = item->ammo_tag; if( ammo_count && ammo_tag ) Add_Ammo( other->r.client, GS_FindItemByTag( ammo_tag ), ammo_count, true ); } return true;}
开发者ID:codetwister,项目名称:qfusion,代码行数:33,
示例2: Pickup_Weaponint Pickup_Weapon (gentity_t *ent, gentity_t *other) { // add the weapon other->client->ps.stats[STAT_WEAPONS] |= ( 1 << ent->item->giTag ); //Lookup how much ammo we need rather then just giving it quantity /*Add_Ammo( other, ent->item->giTag, quantity );*/// quantity = ClipAmountForWeapon(ent->item->giTag);// if (other->client->clipammo[ent->item->giTag] > 0 )// Add_Ammo( other, ent->item->giTag, quantity );// else if (ent->item->giTag == WP_SHOTGUN) { other->client->ammo_in_clip[ent->item->giTag] = 12; Add_Ammo( other, ent->item->giTag, 24 ); } else { //Set the number of shots in a clip for that weapon. other->client->ammo_in_clip[ent->item->giTag] = G_ClipAmountForWeapon( ent->item->giTag ); //Add two clips when you pickup a weapon. Add_Ammo( other, ent->item->giTag, 2 * G_ClipAmountForWeapon( ent->item->giTag ) ); } switch (ent->item->giTag) { case WP_C4: other->client->ammo_in_clip[ent->item->giTag] = G_ClipAmountForWeapon( ent->item->giTag ); other->client->ps.ammo[ent->item->giTag] = 0; case WP_GRENADE: other->client->ammo_in_clip[ent->item->giTag] = G_ClipAmountForWeapon( ent->item->giTag ); other->client->ps.ammo[ent->item->giTag] = 4; } if (ent->item->giTag == WP_GRAPPLING_HOOK || ent->item->giTag == WP_GAUNTLET) other->client->ps.ammo[ent->item->giTag] = G_MaxTotalAmmo(ent->item->giTag); return g_weaponRespawn.integer;}
开发者ID:ballju,项目名称:SpaceTrader-GPL-1.1.14,代码行数:35,
示例3: Pickup_Ammoint Pickup_Ammo (gentity_t *ent, gentity_t *other){ int quantity; if ( ent->count ) { quantity = ent->count; } else { quantity = ent->item->quantity; } if (!Q_stricmp(ent->item->classname, "ammo_pack")) { int i; for (i = 0; i < bg_numItems; i++) { const gitem_t *item; item = &bg_itemlist[i]; if (item->giType != IT_AMMO) { // skip continue; } if (!Q_stricmp(item->classname, "ammo_pack")) { // skip continue; } Add_Ammo(other, item->giTag, item->quantity); } } else { Add_Ammo (other, ent->item->giTag, quantity); } return RESPAWN_AMMO;}
开发者ID:brugal,项目名称:wolfcamql,代码行数:34,
示例4: Pickup_Weapon/** Pickup_Weapon*/qboolean Pickup_Weapon( edict_t *ent, edict_t *other ){ int ammo_tag; other->r.client->ps.inventory[ent->item->tag]++; // never allow the player to carry more than 2 copies of the same weapon if( other->r.client->ps.inventory[ent->item->tag] > ent->item->inventory_max ) other->r.client->ps.inventory[ent->item->tag] = ent->item->inventory_max; if( !( ent->spawnflags & DROPPED_ITEM ) ) { // give them some ammo with it ammo_tag = ent->item->weakammo_tag; if( ammo_tag ) Add_Ammo( other->r.client, GS_FindItemByTag( ammo_tag ), GS_FindItemByTag( ammo_tag )->quantity, qtrue ); } else { //it's a dropped weapon ammo_tag = ent->item->weakammo_tag; if( ent->count && ammo_tag ) Add_Ammo( other->r.client, GS_FindItemByTag( ammo_tag ), ent->count, qtrue ); } return qtrue;}
开发者ID:TyounanMOTI,项目名称:warsow_mac,代码行数:30,
示例5: Give_Class_Ammo//this function is for giving the player ammo...void Give_Class_Ammo(edict_t *ent){ gitem_t *item,*item2; if (ent->client->resp.team_on->mos[ent->client->resp.mos]->ammo1 ) { if ((mauser_only->value == 1) && !(ent->client->resp.mos == MEDIC)) item= FindTeamItem(team_list[1]->teamid, LOC_RIFLE); else if ((sniper_only->value == 1) && !(ent->client->resp.mos == MEDIC)) item= FindTeamItem(team_list[(ent->client->resp.team_on->index)]->teamid, LOC_SNIPER); else item=FindItem(ent->client->resp.team_on->mos[ent->client->resp.mos]->weapon1); item2=FindItem(item->ammo); Add_Ammo(ent,item2,ent->client->resp.team_on->mos[ent->client->resp.mos]->ammo1); } if (ent->client->resp.team_on->mos[ent->client->resp.mos]->ammo2 ) { item=FindItem(ent->client->resp.team_on->mos[ent->client->resp.mos]->weapon2); item2=FindItem(item->ammo); Add_Ammo(ent,item2,ent->client->resp.team_on->mos[ent->client->resp.mos]->ammo2); } }
开发者ID:basecq,项目名称:q2dos,代码行数:27,
示例6: Pickup_Weaponqboolean Pickup_Weapon (edict_t *ent, edict_t *other){ int index; gitem_t *ammo; index = ITEM_INDEX(ent->item); if ( ( ((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) && other->client->pers.inventory[index]) { if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM) ) ) return false; // leave the weapon for others to pickup } other->client->pers.inventory[index]++; //WF if(ent->spawnflags & DROPPED_ITEM) { ammo = FindItem(ent->item->ammo); Add_Ammo(other, ammo, (int)((float)ammo->quantity * dropweapammo->value)); } //WF if (!(ent->spawnflags & DROPPED_ITEM) ) { // give them some ammo with it ammo = FindItem (ent->item->ammo); if ( (int)dmflags->value & DF_INFINITE_AMMO ) Add_Ammo (other, ammo, 1000); else Add_Ammo (other, ammo, ammo->quantity); if (! (ent->spawnflags & DROPPED_PLAYER_ITEM) ) { if (deathmatch->value) { if ((int)(dmflags->value) & DF_WEAPONS_STAY) ent->flags |= FL_RESPAWN; else SetRespawn (ent, 30); } if (coop->value) ent->flags |= FL_RESPAWN; } } //WF other->safety_time = 0; Weapon_PickBest(ent, other); /* if (other->client->pers.weapon != ent->item && (other->client->pers.inventory[index] == 1) && ( !deathmatch->value || other->client->pers.weapon == FindItem("blaster") ) ) other->client->newweapon = ent->item; */ //WF return true;}
开发者ID:mattayres,项目名称:li2mod,代码行数:59,
示例7: Pickup_Ammo/*==============Pickup_Ammo==============*/int Pickup_Ammo (gentity_t *ent, gentity_t *other) { // added some ammo pickups, so I'll use ent->item->quantity if no ent->count if (ent->count) { Add_Ammo (other, ent->item->giTag, ent->count, qfalse); } else { Add_Ammo (other, ent->item->giTag, ent->item->quantity, qfalse); } return RESPAWN_AMMO;}
开发者ID:BackupTheBerlios,项目名称:et-flf-svn,代码行数:18,
示例8: Pickup_Weaponqboolean Pickup_Weapon(edict_t *ent, edict_t *other){ int index; gitem_t *ammo; if (!ent || !other) { return false; } index = ITEM_INDEX(ent->item); if ((((int) (dmflags->value) & DF_WEAPONS_STAY) || coop->value) && other->client->pers.inventory[index]) { if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM))) { return false; /* leave the weapon for others to pickup */ } } other->client->pers.inventory[index]++; if (!(ent->spawnflags & DROPPED_ITEM)) { /* give them some ammo with it */ ammo = FindItem(ent->item->ammo); if ((int) dmflags->value & DF_INFINITE_AMMO) { Add_Ammo(other, ammo, 1000); } else { Add_Ammo(other, ammo, ammo->quantity); } if (!(ent->spawnflags & DROPPED_PLAYER_ITEM)) { if (deathmatch->value) { if ((int) (dmflags->value) & DF_WEAPONS_STAY) { ent->flags |= FL_RESPAWN; } else { SetRespawn(ent, 30); } } if (coop->value) { ent->flags |= FL_RESPAWN; } } } if ((other->client->pers.weapon != ent->item) && (other->client->pers.inventory[index] == 1) && (!deathmatch->value || (other->client->pers.weapon == FindItem("blaster")))) { other->client->newweapon = ent->item; } return true;}
开发者ID:greck2908,项目名称:qengine,代码行数:51,
示例9: Pickup_Weaponqboolean Pickup_Weapon (edict_t *ent, edict_t *other){ int index; gitem_t *ammo; index = ITEM_INDEX(ent->item); if ( ( ((int)(dmflags->value) & DF_WEAPONS_STAY) || coop->value) && other->client->pers.inventory[index]) { if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM) ) ) return false; // leave the weapon for others to pickup } other->client->pers.inventory[index]++; if (!(ent->spawnflags & DROPPED_ITEM) && (ent->item->ammo != NULL)) { // give them some ammo with it ammo = FindItem (ent->item->ammo); if ( (int)dmflags->value & DF_INFINITE_AMMO ) Add_Ammo (other, ammo, 1000); else Add_Ammo (other, ammo, ammo->quantity); if (! (ent->spawnflags & DROPPED_PLAYER_ITEM) ) { if (deathmatch->value) { if ((int)(dmflags->value) & DF_WEAPONS_STAY) ent->flags |= FL_RESPAWN; else SetRespawn (ent, 30); } if (coop->value) ent->flags |= FL_RESPAWN; } } if (other->client->pers.weapon != ent->item && !(ent->item->hideFlags & HIDE_FROM_SELECTION) && (other->client->pers.inventory[index] == 1) && ( !deathmatch->value || other->client->pers.weapon == FindItem("blaster") ) ) other->client->newweapon = ent->item; return true;}
开发者ID:yquake2,项目名称:zaero,代码行数:48,
示例10: Pickup_Ammo/*==============Pickup_Ammo==============*/int Pickup_Ammo( gentity_t *ent, gentity_t *other ) { int quantity; if ( ent->count ) { quantity = ent->count; } else { // quantity = ent->item->quantity; quantity = ent->item->gameskillnumber[( g_gameskill.integer ) - 1]; // FIXME just for now if ( !quantity ) { quantity = ent->item->quantity; } } Add_Ammo( other, ent->item->giTag, quantity, qfalse ); //----(SA) modified // single player has no respawns (SA) if ( g_gametype.integer == GT_SINGLE_PLAYER ) { return RESPAWN_SP; } return RESPAWN_AMMO;}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:30,
示例11: Pickup_Weaponint Pickup_Weapon (gentity_t *ent, gentity_t *other) { int quantity; if ( ent->count < 0 ) { quantity = 0; // None for you, sir! } else { if ( ent->count ) { quantity = ent->count; } else { quantity = ent->item->quantity; } if (ent->flags & FL_DROPPED_ITEM) { // TODO: Give the player a second copy of their weapon if applicable. // TODO: Set quantity to how ever much was left in the gun (backend stuff likely required for that) } } // add the weapon Q_AddWeapon(other->player->ps.weapons, ent->item->giTag); Add_Ammo( other, ent->item->giWeaponData.ammoType, quantity ); // LM: Give the ammo this uses. // !TODO: Make weapons with infinite ammo use AM_NONE for ammo, then remove this: if (ent->item->giWeaponData.ammoType == AM_NONE) other->player->ps.ammo[ ent->item->giWeaponData.ammoType ] = -1; // unlimited ammo // team deathmatch has slow weapon respawns if ( g_gametype.integer == GT_TEAM ) { return g_weaponTeamRespawn.integer; } return g_weaponRespawn.integer;}
开发者ID:LavenderMoon,项目名称:mint-arena,代码行数:35,
示例12: Pickup_Weaponint Pickup_Weapon (gentity_t *ent, gentity_t *other){ int quantity; if (ent->count < 0) { quantity = 0; // None for you, sir! } else { if (ent->flags & FL_DROPPED_ITEM) quantity = ent->count; //Too: else quantity = ent->item->quantity; } // add the weapon other->client->ps.stats[STAT_WEAPONS] |= (1 << ent->item->giTag); Add_Ammo(other, ent->item->giTag, quantity); if (ent->item->giTag == WP_GRAPPLING_HOOK) other->client->ps.ammo[ent->item->giTag] = -1; // unlimited ammo // team deathmatch has slow weapon respawns if (g_gametype.integer == GT_TEAM) { return g_weaponTeamRespawn.integer; } return g_weaponRespawn.integer;}
开发者ID:ElderPlayerX,项目名称:Invasion,代码行数:32,
示例13: Pickup_Ammoqboolean Pickup_Ammo (edict_t *ent, edict_t *other){ int oldcount; int count; qboolean weapon; weapon = (ent->item->flags & IT_WEAPON); if ( (weapon) && ( (int)dmflags->value & DF_INFINITE_AMMO ) ) count = 1000; else if (ent->count) count = ent->count; else count = ent->item->quantity; oldcount = other->client->pers.inventory[ITEM_INDEX(ent->item)]; if (!Add_Ammo (other, ent->item, count)) return false; if (weapon && !oldcount) { if (other->client->pers.weapon != ent->item && ( !deathmatch->value || other->client->pers.weapon == FindItem("Colt .45") ) ) other->client->newweapon = ent->item; } if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM)) && (deathmatch->value)) SetRespawn (ent, 30); WeighPlayer(other); return true; }
开发者ID:basecq,项目名称:q2dos,代码行数:33,
示例14: Pickup_Weaponint Pickup_Weapon( gentity_t *ent, gentity_t *other ) { int quantity; if ( ent->count < 0 ) quantity = 0; // None for you, sir! else { if ( ent->count ) quantity = ent->count; else quantity = ent->item->quantity; // dropped items and teamplay weapons always have full ammo if ( !(ent->flags & FL_DROPPED_ITEM) && level.gametype != GT_TEAMBLOOD ) { // respawning rules // drop the quantity if the already have over the minimum if ( other->client->ps.ammo[ent->item->giTag] < quantity ) quantity = quantity - other->client->ps.ammo[ ent->item->giTag ]; else quantity = 1; // only add a single shot } } // add the weapon other->client->ps.stats[STAT_WEAPONS] |= ( 1 << ent->item->giTag ); Add_Ammo( other, ent->item->giTag, quantity ); return g_weaponRespawnTime->integer;}
开发者ID:Razish,项目名称:QtZ,代码行数:29,
示例15: Pickup_Weaponqboolean Pickup_Weapon (edict_t *ent, edict_t *other){ int index; const gitem_t *ammo; index = ITEM_INDEX(ent->item); if ( ( ((int)(dmflags->value) & DF_WEAPONS_STAY)) && other->client->inventory[index]) { if (!(ent->spawnflags & (DROPPED_ITEM | DROPPED_PLAYER_ITEM) ) ) return false; // leave the weapon for others to pickup } other->client->inventory[index]++; if (!(ent->spawnflags & DROPPED_ITEM) ) { // give them some ammo with it ammo = GETITEM (ent->item->ammoindex); if ( (int)dmflags->value & DF_INFINITE_AMMO ) Add_Ammo (other, ammo, 1000); else Add_Ammo (other, ammo, ammo->quantity); if (! (ent->spawnflags & DROPPED_PLAYER_ITEM) ) { if ((int)(dmflags->value) & DF_WEAPONS_STAY) ent->flags |= FL_RESPAWN; else SetRespawn (ent, 30); } } if (other->client->weapon != ent->item && (other->client->inventory[index] == 1) && other->client->weapon == GETITEM (ITEM_WEAPON_BLASTER)) other->client->newweapon = ent->item; return true;}
开发者ID:AndreyNazarov,项目名称:opentdm,代码行数:41,
示例16: Pickup_Ammoint Pickup_Ammo (gentity_t *ent, gentity_t *other){ int quantity; if ( ent->count ) { quantity = ent->count; } else { quantity = ent->item->quantity; } if(ent->item->giTag == WP_SPRAYPISTOL) { if((!strcmp(ent->item->classname,"ammo_spray_b") || !strcmp(ent->item->classname,"ammo_spray_r")) && ent->s.otherEntityNum == other->s.number) { return 0; // leave the item in the world ... } if(!strcmp(ent->item->classname,"ammo_spray_n") && ent->s.otherEntityNum == other->s.number) { if((level.time-other->client->lastOwnCartMSGtime)>5000) { trap_SendServerCommand( other->s.clientNum, "cp /"You can't grab your own cartridge!/n/"" ); other->client->lastOwnCartMSGtime=level.time; } return 0; // leave the item in the world ... } if( ((!strcmp(ent->item->classname,"ammo_spray_b") && other->client->sess.sessionTeam==TEAM_BLUE) || (!strcmp(ent->item->classname,"ammo_spray_r") && other->client->sess.sessionTeam==TEAM_RED) || !strcmp(ent->item->classname,"ammo_spray_n")) && other->client->ps.ammo[WP_SPRAYPISTOL]>=8 ) { if((level.time-other->client->lastOwnCartMSGtime)>5000) // I know the variablename doesn't fit for this :P (#@) { trap_SendServerCommand( other->s.clientNum, "cp /"You can't grab more than 8 cartridges!/n/"" ); other->client->lastOwnCartMSGtime=level.time; } return 0; // leave the item in the world ... } if( (!strcmp(ent->item->classname,"ammo_spray_b") && other->client->sess.sessionTeam==TEAM_RED) || (!strcmp(ent->item->classname,"ammo_spray_r") && other->client->sess.sessionTeam==TEAM_BLUE) ) { return RESPAWN_AMMO; // remove item from world ... but no Add_Ammo } } Add_Ammo (other, ent->item->giTag, quantity); other->client->ps.generic1=other->client->ps.ammo[WP_SPRAYPISTOL]; return RESPAWN_AMMO;}
开发者ID:PadWorld-Entertainment,项目名称:wop-gamesource,代码行数:53,
示例17: Pickup_Ammoint Pickup_Ammo(gentity_t * ent, gentity_t * other, int bandolierFactor){ int quantity; if (ent->count) { quantity = ent->count; } else { quantity = ent->item->quantity; } Add_Ammo(other, ent->item->giTag, quantity, bandolierFactor); return RESPAWN_AMMO;}
开发者ID:zturtleman,项目名称:reaction,代码行数:13,
示例18: Pickup_Ammostatic bool Pickup_Ammo( edict_t *other, const gsitem_t *item, int count, const int *invpack ){ // ammo packs are special if( item->tag == AMMO_PACK || item->tag == AMMO_PACK_WEAK || item->tag == AMMO_PACK_STRONG ) return Pickup_AmmoPack( other, invpack ); if( !count ) count = item->quantity; if( !Add_Ammo( other->r.client, item, count, true ) ) return false; return true;}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:14,
示例19: Pickup_Ammostatic intPickup_Ammo(Gentity *ent, Gentity *other){ int quantity; if(ent->count) quantity = ent->count; else quantity = ent->item->quantity; Add_Ammo (other, ent->item->tag, quantity); return RESPAWN_AMMO;}
开发者ID:icanhas,项目名称:yantar,代码行数:14,
示例20: Pickup_AmmoPackstatic qboolean Pickup_AmmoPack( edict_t *ent, edict_t *other ){ gsitem_t *item; int i; if( !other->r.client ) return qfalse; for( i = AMMO_GUNBLADE; i < AMMO_TOTAL; i++ ) { item = GS_FindItemByTag( i ); if( item ) Add_Ammo( other->r.client, item, ent->invpak[i], qtrue ); } return qtrue;}
开发者ID:hettoo,项目名称:racesow,代码行数:17,
示例21: switchvoid menuFunction::weapon_menu(modmenu_s* menu, int32_t client, int32_t scroll){ gentity_s* self = &g_entities[client]; gclient_s* gclient = self->client; char weapName[0x100]; /* "Take Weapon", "Take All Weapons", "Weapon Selector", "Weapon List", "Drop Weapon", "Give Ammo", "Dump Weapons", */ switch (scroll) { case 0: takeWeapon(client, self->client->ps.weapon); break; case 1: takeAllWeapons(client); break; case 2: menu->freeze(); handleAlloc(NULL, client, menu, weaponSelector, 20, 0); break; case 3: menu->freeze(); handleAlloc(NULL, client, menu, weaponList, 20, 0); break; case 4: handleAllocTemp(client, menu, weaponDrop, 0); break; case 5: Add_Ammo(self, gclient->ps.weapon, 999, 1); break; case 6: for (int32_t i = 0; i < 0xF; i++) { DBGPRINTF("weapon_%d:/t%s/n", i, BG_WeaponName(gclient->ps.heldWeapon[i].weapon, weapName, sizeof(weapName))); } break; }}
开发者ID:therifboy,项目名称:echelon-bo2,代码行数:44,
示例22: Pickup_AmmoPackstatic bool Pickup_AmmoPack( edict_t *other, const int *invpack ){ gsitem_t *item; int i; if( !other->r.client ) return false; if( !invpack ) return false; for( i = AMMO_GUNBLADE + 1; i < AMMO_TOTAL; i++ ) { item = GS_FindItemByTag( i ); if( item ) Add_Ammo( other->r.client, item, invpack[i], true ); } return true;}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:19,
示例23: Pickup_Weaponint Pickup_Weapon (gentity_t *ent, gentity_t *other) { int quantity; if ( ent->count < 0 ) { quantity = 0; // None for you, sir! } else { if ( ent->count ) { quantity = ent->count; } else { quantity = ent->item->quantity; } // dropped items and teamplay weapons always have full ammo if ( ! (ent->flags & FL_DROPPED_ITEM) && g_gametype.integer != GT_TEAM ) { // respawning rules // drop the quantity if the already have over the minimum if ( other->client->ps.ammo[ ent->item->giTag ] < quantity ) { quantity = quantity - other->client->ps.ammo[ ent->item->giTag ]; } else { quantity = 1; // only add a single shot } } } // add the weapon other->client->ps.stats[STAT_WEAPONS] |= ( 1 << ent->item->giTag ); Add_Ammo( other, ent->item->giTag, quantity ); if (ent->item->giTag == WP_GRAPPLING_HOOK) other->client->ps.ammo[ent->item->giTag] = -1; // unlimited ammo // team deathmatch has slow weapon respawns if ( g_gametype.integer == GT_TEAM ) { return g_weaponTeamRespawn.integer; } return g_weaponRespawn.integer;}
开发者ID:Garey27,项目名称:quake3-brainworks,代码行数:39,
示例24: Pickup_Ammostatic qboolean Pickup_Ammo( edict_t *ent, edict_t *other ){ int oldcount; int count; qboolean weapon; // ammo packs are special if( ent->item->tag == AMMO_PACK || ent->item->tag == AMMO_PACK_WEAK || ent->item->tag == AMMO_PACK_STRONG ) return Pickup_AmmoPack( ent, other ); weapon = ( ent->item->type & IT_WEAPON ); if( ent->count ) count = ent->count; else count = ent->item->quantity; oldcount = other->r.client->ps.inventory[ent->item->tag]; if( !Add_Ammo( other->r.client, ent->item, count, qtrue ) ) return qfalse; return qtrue;}
开发者ID:hettoo,项目名称:racesow,代码行数:24,
示例25: Cmd_Give_f/** Cmd_Give_f* * Give items to a client*/static void Cmd_Give_f( edict_t *ent ){ char *name; gsitem_t *it; int i; bool give_all; if( !sv_cheats->integer ) { G_PrintMsg( ent, "Cheats are not enabled on this server./n" ); return; } name = trap_Cmd_Args(); if( !Q_stricmp( name, "all" ) ) give_all = true; else give_all = false; if( give_all || !Q_stricmp( trap_Cmd_Argv( 1 ), "health" ) ) { if( trap_Cmd_Argc() == 3 ) ent->health = atoi( trap_Cmd_Argv( 2 ) ); else ent->health = ent->max_health; if( !give_all ) return; } if( give_all || !Q_stricmp( name, "weapons" ) ) { for( i = 0; i < GS_MAX_ITEM_TAGS; i++ ) { it = GS_FindItemByTag( i ); if( !it ) continue; if( !( it->flags & ITFLAG_PICKABLE ) ) continue; if( !( it->type & IT_WEAPON ) ) continue; ent->r.client->ps.inventory[i] += 1; } if( !give_all ) return; } if( give_all || !Q_stricmp( name, "ammo" ) ) { for( i = 0; i < GS_MAX_ITEM_TAGS; i++ ) { it = GS_FindItemByTag( i ); if( !it ) continue; if( !( it->flags & ITFLAG_PICKABLE ) ) continue; if( !( it->type & IT_AMMO ) ) continue; Add_Ammo( ent->r.client, it, 1000, true ); } if( !give_all ) return; } if( give_all || !Q_stricmp( name, "armor" ) ) { ent->r.client->resp.armor = GS_Armor_MaxCountForTag( ARMOR_RA ); if( !give_all ) return; } if( give_all ) { for( i = 0; i < GS_MAX_ITEM_TAGS; i++ ) { it = GS_FindItemByTag( i ); if( !it ) continue; if( !( it->flags & ITFLAG_PICKABLE ) ) continue; if( it->type & ( IT_ARMOR|IT_WEAPON|IT_AMMO ) ) continue; ent->r.client->ps.inventory[i] = 1; } return; }//.........这里部分代码省略.........
开发者ID:codetwister,项目名称:qfusion,代码行数:101,
示例26: Cmd_Give_f/*==================Cmd_Give_fGive items to a client==================*/void Cmd_Give_f (edict_t *ent){ char *name; gitem_t *it; int index; int i; qboolean give_all; edict_t *it_ent; int numargs; char tryname[256]; if (deathmatch->value && !sv_cheats->value) { gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command./n"); return; } name = gi.args(); numargs = gi.argc(); if (Q_stricmp(name, "all") == 0) give_all = true; else give_all = false; if (give_all || Q_stricmp(gi.argv(1), "health") == 0) { if (gi.argc() == 3) ent->health = atoi(gi.argv(2)); else ent->health = ent->max_health; if (!give_all) return; } if (give_all || Q_stricmp(name, "weapons") == 0) { for (i=0 ; i<game.num_items ; i++) { it = itemlist + i; if (!it->pickup) continue; if (!(it->flags & IT_WEAPON)) continue; ent->client->pers.inventory[i] += 1; } if (!give_all) return; } if (give_all || Q_stricmp(name, "ammo") == 0) { for (i=0 ; i<game.num_items ; i++) { it = itemlist + i; if (!it->pickup) continue; if (!(it->flags & IT_AMMO)) continue; Add_Ammo (ent, it, 1000); } if (!give_all) return; } if (give_all || Q_stricmp(name, "armor") == 0) { gitem_armor_t *info; it = FindItem("Jacket Armor"); ent->client->pers.inventory[ITEM_INDEX(it)] = 0; it = FindItem("Combat Armor"); ent->client->pers.inventory[ITEM_INDEX(it)] = 0; it = FindItem("Body Armor"); info = (gitem_armor_t *)it->info; ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count; if (!give_all) return; } if (give_all || Q_stricmp(name, "Visor") == 0) { it = FindItem("Visor"); it_ent = G_Spawn(); it_ent->classname = it->classname; SpawnItem (it_ent, it); Touch_Item (it_ent, ent, NULL, NULL); if (it_ent->inuse) G_FreeEdict(it_ent);//.........这里部分代码省略.........
开发者ID:alexey-lysiuk,项目名称:quake2,代码行数:101,
示例27: emplaced_gun_use//----------------------------------------------------------void emplaced_gun_use( gentity_t *self, gentity_t *other, gentity_t *activator ){ vec3_t fwd1, fwd2; if ( self->health <= 0 ) { // can't use a dead gun. return; } if ( self->svFlags & SVF_INACTIVE ) { return; // can't use inactive gun } if ( !activator->client ) { return; // only a client can use it. } if ( self->activator ) { // someone is already in the gun. return; } if ( other && other->client && G_IsRidingVehicle( other ) ) {//can't use eweb when on a vehicle return; } if ( activator && activator->client && G_IsRidingVehicle( activator ) ) {//can't use eweb when on a vehicle return; } // We'll just let the designers duke this one out....I mean, as to whether they even want to limit such a thing. if ( self->spawnflags & EMPLACED_FACING ) { // Let's get some direction vectors for the users AngleVectors( activator->client->ps.viewangles, fwd1, NULL, NULL ); // Get the guns direction vector AngleVectors( self->pos1, fwd2, NULL, NULL ); float dot = DotProduct( fwd1, fwd2 ); // Must be reasonably facing the way the gun points ( 90 degrees or so ), otherwise we don't allow to use it. if ( dot < 0.0f ) { return; } } // don't allow using it again for half a second if ( self->delay + 500 < level.time ) { int oldWeapon = activator->s.weapon; if ( oldWeapon == WP_SABER ) { self->alt_fire = activator->client->ps.SaberActive(); } // swap the users weapon with the emplaced gun and add the ammo the gun has to the player activator->client->ps.weapon = self->s.weapon; Add_Ammo( activator, WP_EMPLACED_GUN, self->count ); activator->client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_EMPLACED_GUN ); // Allow us to point from one to the other activator->owner = self; // kind of dumb, but when we are locked to the weapon, we are owned by it. self->activator = activator; G_RemoveWeaponModels( activator );extern void ChangeWeapon( gentity_t *ent, int newWeapon ); if ( activator->NPC ) { ChangeWeapon( activator, WP_EMPLACED_GUN ); } else if ( activator->s.number == 0 ) { // we don't want for it to draw the weapon select stuff cg.weaponSelect = WP_EMPLACED_GUN; CG_CenterPrint( "@SP_INGAME_EXIT_VIEW", SCREEN_HEIGHT * 0.95 ); } // Since we move the activator inside of the gun, we reserve a solid spot where they were standing in order to be able to get back out without being in solid if ( self->nextTrain ) {//you never know G_FreeEntity( self->nextTrain ); } self->nextTrain = G_Spawn(); //self->nextTrain->classname = "emp_placeholder"; self->nextTrain->contents = CONTENTS_MONSTERCLIP|CONTENTS_PLAYERCLIP;//hmm... playerclip too now that we're doing it for NPCs? G_SetOrigin( self->nextTrain, activator->client->ps.origin ); VectorCopy( activator->mins, self->nextTrain->mins ); VectorCopy( activator->maxs, self->nextTrain->maxs ); gi.linkentity( self->nextTrain );//.........这里部分代码省略.........
开发者ID:kikili,项目名称:OpenJK,代码行数:101,
示例28: eweb_usevoid eweb_use( gentity_t *self, gentity_t *other, gentity_t *activator ){ if ( !eweb_can_be_used( self, other, activator ) ) { return; } int oldWeapon = activator->s.weapon; if ( oldWeapon == WP_SABER ) { self->alt_fire = activator->client->ps.SaberActive(); } // swap the users weapon with the emplaced gun and add the ammo the gun has to the player activator->client->ps.weapon = self->s.weapon; Add_Ammo( activator, WP_EMPLACED_GUN, self->count ); activator->client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_EMPLACED_GUN ); // Allow us to point from one to the other activator->owner = self; // kind of dumb, but when we are locked to the weapon, we are owned by it. self->activator = activator; G_RemoveWeaponModels( activator );extern void ChangeWeapon( gentity_t *ent, int newWeapon ); if ( activator->NPC ) { ChangeWeapon( activator, WP_EMPLACED_GUN ); } else if ( activator->s.number == 0 ) { // we don't want for it to draw the weapon select stuff cg.weaponSelect = WP_EMPLACED_GUN; CG_CenterPrint( "@SP_INGAME_EXIT_VIEW", SCREEN_HEIGHT * 0.95 ); } VectorCopy( activator->currentOrigin, self->pos4 );//keep this around so we know when to make them play the strafe anim // the gun will track which weapon we used to have self->s.weapon = oldWeapon; // Lock the player activator->client->ps.eFlags |= EF_LOCKED_TO_WEAPON; activator->owner = self; // kind of dumb, but when we are locked to the weapon, we are owned by it. self->activator = activator; self->delay = level.time; // can't disconnect from the thing for half a second // Let the gun be considered an enemy //Ugh, so much AI code seems to assume enemies are clients, maybe this shouldn't be on, but it's too late in the game to change it now without knowing what side-effects this will have self->svFlags |= SVF_NONNPC_ENEMY; self->noDamageTeam = activator->client->playerTeam; //FIXME: should really wait a bit after spawn and get this just once? self->waypoint = NAV::GetNearestNode(self);#ifdef _DEBUG if ( self->waypoint == -1 ) { gi.Printf( S_COLOR_RED"ERROR: no waypoint for emplaced_gun %s at %s/n", self->targetname, vtos(self->currentOrigin) ); }#endif G_Sound( self, G_SoundIndex( "sound/weapons/eweb/eweb_mount.mp3" )); if ( !(self->spawnflags&EMPLACED_PLAYERUSE) || activator->s.number == 0 ) {//player-only usescript or any usescript // Run use script G_ActivateBehavior( self, BSET_USE ); }}
开发者ID:kikili,项目名称:OpenJK,代码行数:70,
示例29: Pickup_Weapon//.........这里部分代码省略......... } if ( other->client->ps.ammoclip[BG_FindClipForWeapon( weapon )] < i ) { other->client->ps.ammoclip[BG_FindClipForWeapon( weapon )]++; } COM_BitSet( other->client->ps.weapons,weapon ); // TTimo - add 8 pistol bullets if ( other->client->sess.sessionTeam == TEAM_RED ) { weapon = WP_LUGER; } else { weapon = WP_COLT; }// G_Printf("filling magazine for weapon %d colt/luger (%d rounds)/n", weapon, ammoTable[weapon].maxclip); other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] += ammoTable[weapon].maxclip; if ( other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] > ammoTable[weapon].maxclip * 4 ) { other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] = ammoTable[weapon].maxclip * 4; } // and some two-handed ammo for ( i = 0; i < MAX_WEAPS_IN_BANK_MP; i++ ) { weapon = weapBanksMultiPlayer[3][i]; if ( COM_BitCheck( other->client->ps.weapons, weapon ) ) {// G_Printf("filling magazine for weapon %d (%d rounds)/n",weapon,ammoTable[weapon].maxclip); if ( weapon == WP_FLAMETHROWER ) { // FT doesn't use magazines so refill tank other->client->ps.ammoclip[BG_FindAmmoForWeapon( WP_FLAMETHROWER )] = ammoTable[weapon].maxclip; } else { other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] += ammoTable[weapon].maxclip; if ( other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] > ammoTable[weapon].maxclip * 3 ) { other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] = ammoTable[weapon].maxclip * 3; } } return RESPAWN_SP; } } return RESPAWN_SP; }// jpw if ( ent->count < 0 ) { quantity = 0; // None for you, sir! } else { if ( ent->count ) { quantity = ent->count; } else {//----(SA) modified// JPW NERVE did this so ammocounts work right on dropped weapons if ( g_gametype.integer != GT_SINGLE_PLAYER ) { quantity = ent->item->quantity; } else {// jpw quantity = ( random() * ( ent->item->quantity - 1 ) ) + 1; // giving 1-<item default count> } } } // check if player already had the weapon alreadyHave = COM_BitCheck( other->client->ps.weapons, ent->item->giTag ); // add the weapon COM_BitSet( other->client->ps.weapons, ent->item->giTag ); // DHM - Fixup mauser/sniper issues if ( ent->item->giTag == WP_MAUSER ) { COM_BitSet( other->client->ps.weapons, WP_SNIPERRIFLE ); } if ( ent->item->giTag == WP_SNIPERRIFLE ) { COM_BitSet( other->client->ps.weapons, WP_MAUSER ); } //----(SA) added // snooper == automatic garand mod if ( ent->item->giTag == WP_SNOOPERSCOPE ) { COM_BitSet( other->client->ps.weapons, WP_GARAND ); } // fg42scope == automatic fg42 mod else if ( ent->item->giTag == WP_FG42SCOPE ) { COM_BitSet( other->client->ps.weapons, WP_FG42 ); } else if ( ent->item->giTag == WP_GARAND ) { COM_BitSet( other->client->ps.weapons, WP_SNOOPERSCOPE ); } //----(SA) end// JPW NERVE prevents drop/pickup weapon "quick reload" exploit if ( alreadyHave ) { Add_Ammo( other, ent->item->giTag, quantity, !alreadyHave ); } else { other->client->ps.ammoclip[BG_FindClipForWeapon( ent->item->giTag )] = quantity; }// jpw // single player has no respawns (SA) if ( g_gametype.integer == GT_SINGLE_PLAYER ) { return RESPAWN_SP; } if ( g_gametype.integer == GT_TEAM ) { return g_weaponTeamRespawn.integer; } return g_weaponRespawn.integer;}
开发者ID:MAN-AT-ARMS,项目名称:iortcw-archive,代码行数:101,
注:本文中的Add_Ammo函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ AddedElement函数代码示例 C++ AddWorldScripts函数代码示例 |