// // Name: ItemPickup() // Class: Armor // // Description: Handles Sentients Picking up armor... In this case, however, // Only Actors are allowed to actually pick up armor // // Parameters: Entity *other - The entity doing the picking up // qboolean add_to_inventory - Here to make parameters match // // Returns: NULL -- This function doesn't actually return the armor, instead // it has the entity picking it up process and armor event // Item *Armor::ItemPickup( Entity *other, qboolean add_to_inventory, qboolean ) { Sentient *sent; str realname; Q_UNUSED(add_to_inventory); // For right now, we only want players to pick up armor if ( !other->isSubclassOf( Player ) ) return NULL; if ( !Pickupable( other ) ) return NULL; sent = (Sentient*)other; // Check if we NEED to pick up the armor, if the armor we are about to pick up is // less than the armor we have, we don't want to pick it up if ( !_needThisArmor(sent) ) return NULL; // Handle the actual "Picking Up" _pickupArmor(sent); // Give the Sentient the Armor Event *armorEvent; armorEvent = new Event(EV_Sentient_GiveArmor); armorEvent->AddString( item_name.c_str() ); armorEvent->AddFloat( amount ); armorEvent->AddInteger( true ); sent->ProcessEvent(armorEvent); return NULL; // This doesn't create any items }
Item *Rune::ItemPickup( Entity *other, qboolean add_to_inventory, qboolean ) { Player *player; if ( !Pickupable( other ) ) return NULL; if ( !other->isSubclassOf( Player ) ) return NULL; player = ( Player * )other; if ( player->hasRune() ) return NULL; return PowerupBase::ItemPickup( other, add_to_inventory, false ); }
Item *PowerupBase::ItemPickup( Entity *other, qboolean add_to_inventory, qboolean ) { Player *player; str realname; Q_UNUSED(add_to_inventory); if ( !other->isSubclassOf( Player ) ) return NULL; if ( !Pickupable( other ) ) return NULL; if ( multiplayerManager.inMultiplayer() ) { if ( !multiplayerManager.canPickup( (Player *)other, getMultiplayerItemType(), item_name ) ) return NULL; } player = ( Player * )other; // Play pickup sound realname = GetRandomAlias( "snd_pickup" ); if ( realname.length() > 1 ) player->Sound( realname, CHAN_ITEM ); // Cancel some events CancelEventsOfType( EV_Item_DropToFloor ); CancelEventsOfType( EV_Item_Respawn ); CancelEventsOfType( EV_FadeOut ); // Hide the model setSolidType( SOLID_NOT ); if ( _missingSkin ) { ChangeSkin( _missingSkin, true ); } else { hideModel(); } // Respawn? if ( !Respawnable() ) PostEvent( EV_Remove, FRAMETIME ); else PostEvent( EV_Item_Respawn, RespawnTime() ); // fire off any pickup_thread's if ( pickup_thread.length() ) { ExecuteThread( pickup_thread ); } givePlayerItem( player ); if ( multiplayerManager.inMultiplayer() ) { multiplayerManager.pickedupItem( (Player *)other, MP_ITEM_TYPE_POWERUP, item_name ); } return NULL; // This doesn't create any items }
Item * Item::ItemPickup( Entity *other, qboolean add_to_inventory, qboolean checkautopickup ) { Sentient * sent; Item * item = NULL; str realname; // Query the gameplay manager and see if we should not auto-pickup this item if ( checkautopickup ) { GameplayManager *gpm = GameplayManager::getTheGameplayManager(); if ( gpm->hasProperty(getArchetype(), "noautopickup") ) return NULL; } if ( !Pickupable( other ) ) { return NULL; } sent = ( Sentient * )other; if ( add_to_inventory ) { item = sent->giveItem( model, getAmount(), true ); if ( !item ) return NULL; } else { item = this; } // // make sure to copy over the coolness factor :) // item->coolitem = coolitem; item->cool_dialog = cool_dialog; item->cool_anim = cool_anim; item->coolitemforced = coolitemforced; // // let our sent know they received it // we put this here so we can transfer information from the original item we picked up // if ( !isSubclassOf( Weapon ) || add_to_inventory ) sent->ReceivedItem( item ); realname = GetRandomAlias( "snd_pickup" ); if ( realname.length() > 1 ) sent->Sound( realname, CHAN_ITEM ); if ( !Removable() ) { // leave the item for others to pickup return item; } look_at_me = false; CancelEventsOfType( EV_Item_DropToFloor ); CancelEventsOfType( EV_Item_Respawn ); CancelEventsOfType( EV_FadeOut ); setSolidType( SOLID_NOT ); if ( animate && animate->HasAnim( "pickup" ) ) animate->RandomAnimate( "pickup", EV_Item_PickupDone ); else { if ( !no_remove ) { if ( _missingSkin ) { ChangeSkin( _missingSkin, true ); } else { hideModel(); } if ( !Respawnable() ) PostEvent( EV_Remove, FRAMETIME ); } } if ( Respawnable() ) PostEvent( EV_Item_Respawn, RespawnTime() ); // fire off any pickup_thread's if ( pickup_thread.length() ) { ExecuteThread( pickup_thread ); } if ( item && multiplayerManager.checkFlag( MP_FLAG_INSTANT_ITEMS ) ) { Event *ev; ev = new Event( EV_InventoryItem_Use ); ev->AddEntity( other ); item->ProcessEvent( ev ); } return item; }