本文整理汇总了C++中Touch_Item函数的典型用法代码示例。如果您正苦于以下问题:C++ Touch_Item函数的具体用法?C++ Touch_Item怎么用?C++ Touch_Item使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Touch_Item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drop_temp_touch
static void drop_temp_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
{
if (other == ent->owner)
return;
Touch_Item (ent, other, plane, surf);
}
示例2: Touch_Item_Auto
/**
* @brief Auto action when touching an item.
*
* PICKUP_ACTIVATE (0), he will pick up items only when using +activate
* PICKUP_TOUCH (1), he will pickup items when touched
* PICKUP_FORCE (2), he will pickup the next item when touched (and reset to PICKUP_ACTIVATE when done)
*/
void Touch_Item_Auto(gentity_t *ent, gentity_t *other, trace_t *trace)
{
if (other->client->pers.autoActivate == PICKUP_ACTIVATE)
{
return;
}
if (!ent->active && ent->item->giType == IT_WEAPON)
{
if (ent->item->giTag != WP_AMMO)
{
if (!COM_BitCheck(other->client->ps.weapons, ent->item->giTag))
{
return; // force activate only
}
}
}
ent->active = qtrue;
Touch_Item(ent, other, trace);
if (other->client->pers.autoActivate == PICKUP_FORCE) // autoactivate probably forced by the "Cmd_Activate_f()" function
{
other->client->pers.autoActivate = PICKUP_ACTIVATE; // so reset it.
}
}
示例3: Use_Target_Give
/*QUAKED target_give (1 0 0) (-8 -8 -8) (8 8 8)
Gives the activator all the items pointed to.
*/
void Use_Target_Give( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
gentity_t *t;
trace_t trace;
if ( !activator->client ) {
return;
}
if ( !ent->target ) {
return;
}
memset( &trace, 0, sizeof( trace ) );
t = NULL;
while ( (t = G_Find (t, FOFS(targetname), ent->target)) != NULL ) {
if ( !t->item ) {
continue;
}
Touch_Item( t, activator, &trace );
// make sure it isn't going to respawn or show any events
t->nextthink = 0;
trap_UnlinkEntity( t );
}
}
示例4: touched
/*
==============
Touch_Item
if other->client->pers.autoActivate == PICKUP_ACTIVATE (0), he will pick up items only when using +activate
if other->client->pers.autoActivate == PICKUP_TOUCH (1), he will pickup items when touched
if other->client->pers.autoActivate == PICKUP_FORCE (2), he will pickup the next item when touched (and reset to PICKUP_ACTIVATE when done)
==============
*/
void Touch_Item_Auto( gentity_t *ent, gentity_t *other, trace_t *trace ) {
if ( other->client->pers.autoActivate == PICKUP_ACTIVATE ) {
return;
}
ent->active = qtrue;
Touch_Item( ent, other, trace );
if ( other->client->pers.autoActivate == PICKUP_FORCE ) { // autoactivate probably forced by the "Cmd_Activate_f()" function
other->client->pers.autoActivate = PICKUP_ACTIVATE; // so reset it.
}
}
示例5: cash_touch
void cash_touch( edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
float speed;
if (surf && plane && plane->normal[2] > 0.5)
{ // let it rest here
if ((speed = VectorLength( self->velocity )) > 10)
{
self->s.angles[ROLL] = 0;
self->s.angles[PITCH] = 0;
self->avelocity[PITCH] = 0;
self->avelocity[ROLL] = 0;
self->avelocity[YAW] *= 0.5;
// randomize bounce
VectorAdd( self->velocity, tv( crandom()*speed*0.3, crandom()*speed*0.3, random()*speed*0.15 ), self->velocity );
}
else
{
VectorClear( self->velocity );
VectorClear( self->avelocity );
self->s.angles[PITCH] = 0;
self->s.angles[ROLL] = 0;
self->movetype = MOVETYPE_NONE;
}
return;
}
if (other->client)
{
if (other->client->pers.currentcash < MAX_CASH_PLAYER)
{ // they can hold the cash
if ((self->currentcash == CASH_BAG) || (self->movetype != MOVETYPE_NONE) || (other->client->ps.pmove.pm_flags & PMF_DUCKED))
{ // they can pick it up
Touch_Item( self, other, plane, surf );
num_cash_items--;
G_FreeEdict( self );
return;
}
}
}
}
示例6: InitClientCoopPersistant
void
InitClientCoopPersistant(edict_t *ent) // FS: Give some of this back on respawn
{
gclient_t *client;
gitem_t *item;
edict_t *it_ent;
if (!ent || !ent->client)
return;
if (!coop->intValue)
return;
client = ent->client;
client->pers.max_bullets = 200;
client->pers.max_shells = 100;
client->pers.max_rockets = 50;
client->pers.max_grenades = 50;
client->pers.max_cells = 200;
client->pers.max_slugs = 50;
switch(client->resp.coop_respawn.ammoUpgrade)
{
case COOP_BACKPACK:
item = FindItem("ammo pack");
break;
case COOP_BANDOLIER:
item = FindItem("bandolier");
break;
default:
item = NULL;
break;
}
if (item)
{
it_ent = G_Spawn();
it_ent->classname = item->classname;
SpawnItem(it_ent, item);
Touch_Item(it_ent, ent, NULL, NULL);
if (it_ent->inuse)
{
G_FreeEdict(it_ent);
}
}
}
示例7: Tag_KillItBonus
//=================
//=================
void Tag_KillItBonus (edict_t *self)
{
edict_t *armor;
// if the player is hurt, boost them up to max.
if(self->health < self->max_health)
{
self->health += 200;
if(self->health > self->max_health)
self->health = self->max_health;
}
// give the player a body armor
armor = G_Spawn();
armor->spawnflags |= DROPPED_ITEM;
armor->item = FindItem("Body Armor");
Touch_Item(armor, self, NULL, NULL);
if(armor->inuse)
G_FreeEdict(armor);
}
示例8: touched
/*
==============
Touch_Item
if other->client->pers.autoActivate == PICKUP_ACTIVATE (0), he will pick up items only when using +activate
if other->client->pers.autoActivate == PICKUP_TOUCH (1), he will pickup items when touched
if other->client->pers.autoActivate == PICKUP_FORCE (2), he will pickup the next item when touched (and reset to PICKUP_ACTIVATE when done)
==============
*/
void Touch_Item_Auto( gentity_t *ent, gentity_t *other, trace_t *trace )
{
if( other->client->pers.autoActivate == PICKUP_ACTIVATE )
return;
if( !ent->active && ent->item->giType == IT_WEAPON ) {
if( ent->item->giTag != WP_AMMO && ent->item->giTag != WP_BINOCULARS ) {
if ( G_GetPrimaryWeaponForClient(other->client) ||
(!BG_WeaponIsPrimaryForClassAndTeam( other->client->sess.playerType, TEAM_ALLIES, ent->item->giTag ) &&
!BG_WeaponIsPrimaryForClassAndTeam( other->client->sess.playerType, TEAM_AXIS, ent->item->giTag )
) ) {
if( !COM_BitCheck( other->client->ps.weapons, ent->item->giTag ) ) {
return; // force activate only
}
}
}
}
ent->active = qtrue;
Touch_Item( ent, other, trace );
if( other->client->pers.autoActivate == PICKUP_FORCE ) // autoactivate probably forced by the "Cmd_Activate_f()" function
other->client->pers.autoActivate = PICKUP_ACTIVATE; // so reset it.
}
示例9: Cmd_Give_f
//.........这里部分代码省略.........
{
gi.cprintf( ent, PRINT_HIGH,
"All tech abilities are active (Disruptor Shield, Power Amplifier, Time Accel and AutoDoc).\n");
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, "Power Shield") == 0))
{
it = FindItem("Power Shield");
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);
}
if (!give_all)
{
return;
}
}
if (give_all)
{
for (i = 0; i < game.num_items; i++)
{
it = itemlist + i;
if (!it->pickup)
{
continue;
}
if (it->flags & (IT_ARMOR | IT_WEAPON | IT_AMMO))
{
continue;
}
// ace - allow entering a specific ammount when giving "all", otherwise give 1 of everything as usual.
// ent->client->pers.inventory[i] = 1;
if (gi.argc() == 3)
{
示例10: Cmd_Give_f
//.........这里部分代码省略.........
ent->client->ps.inventory[INV_ELECTROBINOCULARS] = 1;
ent->client->ps.inventory[INV_BACTA_CANISTER] = 5;
ent->client->ps.inventory[INV_SEEKER] = 5;
ent->client->ps.inventory[INV_LIGHTAMP_GOGGLES] = 1;
ent->client->ps.inventory[INV_SENTRY] = 5;
ent->client->ps.inventory[INV_GOODIE_KEY] = 5;
ent->client->ps.inventory[INV_SECURITY_KEY] = 5;
if (!give_all)
{
return;
}
}
if (give_all || Q_stricmp(name, "weapons") == 0)
{
ent->client->ps.stats[STAT_WEAPONS] = (1 << (MAX_PLAYER_WEAPONS+1)) - ( 1 << WP_NONE );
// ent->client->ps.stats[STAT_WEAPONS] |= (1 << (WP_MELEE));
if (!give_all)
return;
}
if ( !give_all && Q_stricmp(gi.argv(1), "weaponnum") == 0 )
{
ent->client->ps.stats[STAT_WEAPONS] |= (1 << atoi(gi.argv(2)));
return;
}
if ( Q_stricmp(name, "eweaps") == 0) //for developing, gives you all the weapons, including enemy
{
ent->client->ps.stats[STAT_WEAPONS] = (unsigned)(1 << WP_NUM_WEAPONS) - ( 1 << WP_NONE ); // NOTE: this wasn't giving the last weapon in the list
if (!give_all)
return;
}
if (give_all || Q_stricmp(name, "ammo") == 0)
{
for ( i = 0 ; i < AMMO_MAX ; i++ ) {
ent->client->ps.ammo[i] = ammoData[i].max;
}
if (!give_all)
return;
}
if (give_all || Q_stricmp(gi.argv(1), "batteries") == 0)
{
if (gi.argc() == 3)
ent->client->ps.batteryCharge = atoi(gi.argv(2));
else
ent->client->ps.batteryCharge = MAX_BATTERIES;
if (!give_all)
return;
}
if (give_all || Q_stricmp(gi.argv(1), "armor") == 0)
{
if (gi.argc() == 3)
ent->client->ps.stats[STAT_ARMOR] = atoi(gi.argv(2));
else
ent->client->ps.stats[STAT_ARMOR] = ent->client->ps.stats[STAT_MAX_HEALTH];
if ( ent->client->ps.stats[STAT_ARMOR] > 0 )
{
ent->client->ps.powerups[PW_BATTLESUIT] = Q3_INFINITE;
}
else
{
ent->client->ps.powerups[PW_BATTLESUIT] = 0;
}
if (!give_all)
return;
}
// spawn a specific item right on the player
if ( !give_all ) {
it = FindItem (name);
if (!it) {
name = gi.argv(1);
it = FindItem (name);
if (!it) {
gi.SendServerCommand( ent-g_entities, "print \"unknown item\n\"");
return;
}
}
it_ent = G_Spawn();
VectorCopy( ent->currentOrigin, it_ent->s.origin );
it_ent->classname = it->classname;
G_SpawnItem (it_ent, it);
FinishSpawningItem(it_ent );
memset( &trace, 0, sizeof( trace ) );
Touch_Item (it_ent, ent, &trace);
if (it_ent->inuse) {
G_FreeEntity( it_ent );
}
}
}
示例11: Cmd_Give_f
/*
==================
Cmd_Give_f
Give 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);
//.........这里部分代码省略.........
示例12: G_Give
//.........这里部分代码省略.........
give_all = qtrue;
if ( give_all || !Q_stricmp( name, "health") )
{
if ( argc == 3 )
ent->health = Com_Clampi( 1, ent->client->ps.stats[STAT_MAX_HEALTH], atoi( args ) );
else
ent->health = ent->client->ps.stats[STAT_MAX_HEALTH];
if ( !give_all )
return;
}
if ( give_all || !Q_stricmp( name, "armor" ) || !Q_stricmp( name, "shield" ) )
{
if ( argc == 3 )
ent->client->ps.stats[STAT_ARMOR] = Com_Clampi( 0, ent->client->ps.stats[STAT_MAX_HEALTH], atoi( args ) );
else
ent->client->ps.stats[STAT_ARMOR] = ent->client->ps.stats[STAT_MAX_HEALTH];
if ( !give_all )
return;
}
if ( give_all || !Q_stricmp( name, "force" ) )
{
if ( argc == 3 )
ent->client->ps.forcePower = Com_Clampi( 0, FORCE_POWER_MAX, atoi( args ) );
else
ent->client->ps.forcePower = FORCE_POWER_MAX;
if ( !give_all )
return;
}
if ( give_all || !Q_stricmp( name, "weapons" ) )
{
ent->client->ps.stats[STAT_WEAPONS] = (1 << (WP_MELEE)) - ( 1 << WP_NONE );
if ( !give_all )
return;
}
if ( !give_all && !Q_stricmp( name, "weaponnum" ) )
{
ent->client->ps.stats[STAT_WEAPONS] |= (1 << atoi( args ));
return;
}
if ( !give_all && !Q_stricmp( name, "eweaps" ) ) //for developing, gives you all the weapons, including enemy
{
ent->client->ps.stats[STAT_WEAPONS] = (unsigned)(1 << WP_NUM_WEAPONS) - ( 1 << WP_NONE ); // NOTE: this wasn't giving the last weapon in the list
return;
}
if ( give_all || !Q_stricmp( name, "ammo" ) )
{
int num = 999;
if ( argc == 3 )
num = Com_Clampi( 0, 999, atoi( args ) );
for ( i=AMMO_FORCE; i<MAX_AMMO; i++ )
ent->client->ps.ammo[i] = num != -1 ? num : ammoData[i].max;
if ( !give_all )
return;
}
if ( give_all || !Q_stricmp( name, "batteries" ) )
{
if ( argc == 3 )
ent->client->ps.batteryCharge = Com_Clampi( 0, MAX_BATTERIES, atoi( args ) );
else
ent->client->ps.batteryCharge = MAX_BATTERIES;
if (!give_all)
return;
}
// spawn a specific item right on the player
if ( !give_all ) {
gentity_t *it_ent;
trace_t trace;
it = FindItem (args);
if (!it) {
it = FindItem (name);
if (!it) {
gi.SendServerCommand( ent-g_entities, "print \"unknown item\n\"");
return;
}
}
it_ent = G_Spawn();
VectorCopy( ent->currentOrigin, it_ent->s.origin );
it_ent->classname = G_NewString(it->classname);
G_SpawnItem (it_ent, it);
FinishSpawningItem(it_ent );
memset( &trace, 0, sizeof( trace ) );
Touch_Item (it_ent, ent, &trace);
if (it_ent->inuse) {
G_FreeEntity( it_ent );
}
}
}
示例13: Cmd_Give_f
/*
* Cmd_Give_f
*
* Give items to a client
*/
void
Cmd_Give_f(Gentity *ent)
{
char *name;
Gitem *it;
int i;
qbool give_all;
Gentity *it_ent;
Trace trace;
if(!CheatsOk(ent))
return;
name = ConcatArgs(1);
if(Q_stricmp(name, "all") == 0)
give_all = qtrue;
else
give_all = qfalse;
if(give_all || Q_stricmp(name, "health") == 0){
ent->health = ent->client->ps.stats[STAT_MAX_HEALTH];
if(!give_all)
return;
}
if(give_all || Q_stricmp(name, "weapons") == 0){
/*
* Give all weapons except hook and Wnone
*/
ent->client->ps.stats[STAT_PRIWEAPS] =
(1<<Wnumweaps)
- 1 - (1<<Whook) - (1<<Wnone);
ent->client->ps.stats[STAT_SECWEAPS] =
(1<<Wnumweaps)
- 1 - (1<<Whook) - (1<<Wnone);
if(!give_all)
return;
}
if(give_all || Q_stricmp(name, "ammo") == 0){
for(i = Wnone+1; i < Wnumweaps; i++)
if(i != Whook && i != Wmelee)
ent->client->ps.ammo[i] = 5000;
if(!give_all)
return;
}
if(give_all || Q_stricmp(name, "armor") == 0){
ent->client->ps.stats[STAT_SHIELD] = 5000;
if(!give_all)
return;
}
if(Q_stricmp(name, "excellent") == 0){
ent->client->ps.persistant[PERS_EXCELLENT_COUNT]++;
return;
}
if(Q_stricmp(name, "impressive") == 0){
ent->client->ps.persistant[PERS_IMPRESSIVE_COUNT]++;
return;
}
if(Q_stricmp(name, "gauntletaward") == 0){
ent->client->ps.persistant[PERS_GAUNTLET_FRAG_COUNT]++;
return;
}
if(Q_stricmp(name, "defend") == 0){
ent->client->ps.persistant[PERS_DEFEND_COUNT]++;
return;
}
if(Q_stricmp(name, "assist") == 0){
ent->client->ps.persistant[PERS_ASSIST_COUNT]++;
return;
}
/* spawn a specific item right on the player */
if(!give_all){
it = BG_FindItem(name);
if(!it)
return;
it_ent = G_Spawn();
copyv3(ent->r.currentOrigin, it_ent->s.origin);
it_ent->classname = it->classname;
G_SpawnItem (it_ent, it);
FinishSpawningItem(it_ent);
memset(&trace, 0, sizeof(trace));
Touch_Item (it_ent, ent, &trace);
if(it_ent->inuse)
G_FreeEntity(it_ent);
}
}
示例14: Cmd_Give_f
//.........这里部分代码省略.........
continue;
Add_Ammo (ent, it, 1000);
}
if (!give_all)
return;
}
if (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 (Q_stricmp (name, "Power Shield") == 0)
{
/*it = FindItem("Power Shield");
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);
if (!give_all)
*/
return;
}
/*if (give_all)
{
for (i=0 ; i<game.num_items ; i++)
{
it = itemlist + i;
if (!it->pickup)
continue;
if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO))
continue;
ent->client->pers.inventory[i] = 1;
}
return;
} */
if (give_all)
return;
it = FindItem (name);
if (!it)
{
Q_strncpyz(fixedname, gi.argv (1), sizeof(fixedname));
name = fixedname;
// name = gi.argv (1);
it = FindItem (name);
示例15: Cmd_Give_f
/*
==================
Cmd_Give_f
Give 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;
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();
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, "Power Shield") == 0)
{
it = FindItem("Power Shield");
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);
if (!give_all)
return;
}
//.........这里部分代码省略.........