void PowerupBase::init( const str &modelName, Sentient *owner ) { _modelName = modelName; _owner = owner; setModel( modelName ); CancelEventsOfType( EV_ProcessInitCommands ); ProcessInitCommands( gi.modelindex( modelName.c_str() ) ); CancelEventsOfType( EV_Item_DropToFloor ); setSolidType( SOLID_NOT ); hideModel(); }
void SoundManager::Show( void ) { CurrentGainsFocus(); CancelEventsOfType( EV_SoundManager_ShowingSounds ); PostEvent( EV_SoundManager_ShowingSounds, FRAMETIME ); UpdateUI(); }
void SoundManager::Hide ( Event *ev ) { CurrentLostFocus(); CancelEventsOfType( EV_SoundManager_ShowingSounds ); UpdateUI(); }
void Item::SetOwner( Sentient *ent ) { assert( ent ); if ( !ent ) { // return to avoid any buggy behaviour return; } owner = ent; edict->s.parent = ent->entnum; setRespawn( false ); setSolidType( SOLID_NOT ); hideModel(); CancelEventsOfType( EV_Touch ); CancelEventsOfType( EV_Item_DropToFloor ); CancelEventsOfType( EV_Remove ); // ItemPickup( ent ); }
// // Name: _pickupArmor() // Class: Armor // // Description: Takes care of "Picking Up" the armor, by playing the // appropriate sounds, removing the model... // // Parameters: None // // Returns: None // void Armor::_pickupArmor( Sentient *sentient) { str realname; // Play pickup sound realname = GetRandomAlias( "snd_pickup" ); if ( realname.length() > 1 ) sentient->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 ); }
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; }
void GooProjectile::Explode( Event *ev ) { int i; Entity *owner; Entity *ignoreEnt=NULL; if ( ev->NumArgs() == 1 ) ignoreEnt = ev->GetEntity( 1 ); // Get the owner of this projectile owner = G_GetEntity( this->owner ); // If the owner's not here, make the world the owner if ( !owner ) owner = world; takedamage = DamageNo; // Spawn an explosion model if ( explosionmodel.length() ) { // Move the projectile back off the surface a bit so we can see // explosion effects. Vector dir, v; v = velocity; v.normalize(); dir = v; v = origin - v * 36.0f; setOrigin( v ); ExplosionAttack( v, owner, explosionmodel, dir, ignoreEnt ); } CancelEventsOfType( EV_Projectile_UpdateBeam ); // Kill the beam if ( m_beam ) { m_beam->ProcessEvent( EV_Remove ); m_beam = NULL; } // When the goo hits something, spawn debris for ( i=0; i<m_debriscount; i++ ) { GooDebris *proj; Vector dir; dir = Vector( level.impact_trace.plane.normal ); dir += Vector( crandom() * 0.5, crandom() * 0.5f, 0.0f ); proj = ( GooDebris * )ProjectileAttack( this->origin, dir, this, m_debrismodel, 1.0f ); if ( !proj ) { warning( "GooProjectile::Explode", "Could not create debris projectile" ); return; } proj->owner = ENTITYNUM_WORLD; proj->setSolidType( SOLID_TRIGGER ); proj->avelocity = Vector( G_CRandom( 360.0f ), G_CRandom( 360.0f ), G_CRandom( 360.0f ) ); proj->setSize( Vector( -16.0f, -16.0f, 0.0f ) * proj->edict->s.scale, Vector( 16.0f ,16.0f ,32.0f ) * proj->edict->s.scale ); proj->setMoveType( MOVETYPE_TOSS ); proj->PostEvent( EV_GooDebris_Prethink, level.frametime ); } // Change to the splat if ( level.impact_trace.ent && ( level.impact_trace.ent->solid == SOLID_BSP ) ) { GooDebris *p; Vector ang; p = new GooDebris; vectoangles( level.impact_trace.plane.normal, ang ); p->setAngles( ang ); p->setModel( this->model ); p->ProcessInitCommands( p->edict->s.modelindex ); p->setSize( Vector( -16.0f, -16.0f, 0.0f ) * p->edict->s.scale, Vector( 16.0f, 16.0f, 32.0f ) * p->edict->s.scale ); p->setOrigin( this->origin ); p->velocity = Vector( 0.0f, 0.0f, 0.0f ); p->setMoveType( MOVETYPE_FLY ); p->setSolidType( SOLID_TRIGGER ); p->animate->RandomAnimate( "splat" ); p->owner = this->owner; p->PostEvent( EV_GooDebris_Prethink, level.frametime ); // shrink out } }