示例#1
0
void EInventory::ReplaceItem(const char *szFromItemName, const char *szToItemName)
{
   EInventoryItem *oOld;
   EInventoryItem *oNew;
   int nCell;

   setItemVisible(szFromItemName);
   nCell = getItemCell(szFromItemName);
   if (nCell == -1) {
      K_LOG("EInventory::ReplaceItem Error:%s not found",szFromItemName);
   }
   if (nCell != -1) {
      oOld = getItemFromInventory(szFromItemName);
      KAssert(oOld != NULL);
      if (oOld) {
         oNew = new EInventoryItem(oOld->_szUniverseName, szToItemName, 1, 1);
         _InventoryCells[nCell]->setItem(oNew);
         EInventoryItem::g_ListInventoryItem.addBefore(oOld,oNew);
         DropItem(szFromItemName);
         BlingItem(szToItemName);
      }
   }
   else {
      // On fait à l'ancienne !
      // !!!:dmekersa:20110615 Un bug semble faire que parfois l'item n'est pas visible parmis les 6 cellules de l'inventaire !
      // !!!:dmekersa:20110701 2ème correction car j'utilisais oOld pour récupérer l'univers et sans l'initialiser
      K_LOG("EInventory::ReplaceItem workaround for %s",szFromItemName);
      DropItem(szFromItemName);
      // Ligne supprimée car oOld non initialisé :
      //oNew = new EInventoryItem(oOld->_szUniverseName, szToItemName, 1, 1);
      oNew = new EInventoryItem(_szUniverseName, szToItemName, 1, 1);
      AddItem(oNew);
   }

}
void CollectionNavigationPane::OnDragDrop(OpWidget* widget, OpDragObject* op_drag_object, INT32 pos, INT32 x, INT32 y)
{
	if (pos == -1 || widget != m_tree_view->GetOpWidget())
		return;

	DesktopDragObject* drag_object = static_cast<DesktopDragObject*>(op_drag_object);
	DropType drop_type = drag_object->GetSuggestedDropType();
	DesktopDragObject::InsertType insert_type = drag_object->GetSuggestedInsertType();
	NavigationItem* target_folder = static_cast<NavigationItem*>(static_cast<OpTreeView*>(widget)->GetItemByPosition(pos));
	if (!target_folder->IsUserEditable() || insert_type != DesktopDragObject::INSERT_INTO)
		return; // If target_folder is not valid, like separator.

	NavigationFolderItem* target_folder_item = static_cast<NavigationFolderItem*>(target_folder);
	BookmarkModel* bookmarks = g_hotlist_manager->GetBookmarksModel();
	HotlistModelItem* bookmark_target = target_folder_item->GetHotlistItem();
	HotlistModelItem* dragged_item = drag_object->GetType() == DRAG_TYPE_BOOKMARK ? bookmarks->GetItemByID(drag_object->GetID()) : NULL;
	if (!dragged_item || bookmarks != dragged_item->GetModel())
	{
		// Handle dragged object whose type doesn't matches to DRAG_TYPE_BOOKMARK
		ExternalDragDrop(target_folder_item, drag_object, drop_type, insert_type, TRUE);
		return;
	}

	INT32 dragged_objects_count = drag_object->GetIDCount();
	if (dragged_objects_count <= 0 && drag_object->GetID() > 0)
		dragged_objects_count = 1;

	GenericTreeModel::ModelLock lock(m_navigation_folder_model);
	for (INT32 i = 0; i < dragged_objects_count; i++)
	{
		if (drop_type == DROP_MOVE && bookmark_target && dragged_item)
		{
			// TODO: Handle trash issues
			// If the source is the trash then MOVE will be MOVE
			if (!dragged_item->GetIsInsideTrashFolder())
			{
				HotlistModelItem *target_parent_folder = dragged_item->GetIsInMoveIsCopy();

				// No moving the target folder itself into the trash, without a message,
				// And then do a direct delete
				if (dragged_item->GetTarget().HasContent() && target_parent_folder->GetIsTrashFolder())
				{
					// If they don't want to delete just stop.
					if (!g_hotlist_manager->ShowTargetDeleteDialog(dragged_item))
						break;
				}
			}
		}

		int dropped_id = -1;
		int ret = 1;
		if (dragged_objects_count == 1)
			ret = DropItem(target_folder, drag_object, insert_type, &dropped_id);
		else
			ret = DropItem(target_folder, drag_object, i, insert_type, &dropped_id);

		if (ret == -1)
			break;
	}
}
示例#3
0
void CNPC_HL1Barney::Event_Killed( const CTakeDamageInfo &info )
{
	if ( m_nBody < BARNEY_BODY_GUNGONE )
	{
		// drop the gun!
		Vector vecGunPos;
		QAngle angGunAngles;
		CBaseEntity *pGun = NULL;

		SetBodygroup( 1, BARNEY_BODY_GUNGONE);

		GetAttachment( "0", vecGunPos, angGunAngles );
		
		angGunAngles.y += 180;
		pGun = DropItem( "weapon_glock", vecGunPos, angGunAngles );
	}

	SetUse( NULL );	
	BaseClass::Event_Killed( info  );

	if ( UTIL_IsLowViolence() )
	{
		SUB_StartLVFadeOut( 0.0f );
	}
}
示例#4
0
bool CDotaItems::PickUpItem (uint32_t nItem)
{
	vector<uint32_t> items;
	CDotaItem* oItem = m_AllItems->find(nItem);
//	CONSOLE_Print( "[CDotaItems:PickUpItem] Start ["+m_AllItems->find(nItem)->name+"] ["+UTIL_ToString(oItem->recipes.size())+"].");
	// update recipe list info and check for a building of a new item.
	for (vector<CDotaItemRecipe*>::iterator it = oItem->recipes.begin(); it != oItem->recipes.end(); it++)
	{
		items = (*it)->PickUpItem(nItem);
		if (!items.empty()) // we have a new item
		{
			uint32_t nItem = items.back();
			items.pop_back();
			// drop all items that in recipe
			while(!items.empty())
			{
				// we cant drop an item that we just try to pick up
				if(items.back() == nItem)
				{
					// but we just do incriment for all the recipes, and now we need to do it back.
					for (vector<CDotaItemRecipe*>::iterator it2 = oItem->recipes.begin(); it2 != oItem->recipes.end(); it2++)
						(*it2)->DropItem(nItem);
				}else
					DropItem(items.back());
				items.pop_back();
			}
			PickUpItem(nItem);
//			CONSOLE_Print( "[CDotaItems:PickUpItem] End with recipe.");
			return true;
		}
	}
//	CONSOLE_Print( "[CDotaItems:PickUpItem] End without recipe.");
	// Pick up a new item
	return PickUpPItem(nItem);
};
示例#5
0
Bool ZFrame::MouseButtonRelease(UShort nButton, float Absolute_x, float Absolute_y)
{
  ZListItem * Item;
  ZFrame * Frame;

  // Drag and drop

  if (GuiManager->DragingFrame)
  {
    if (GuiManager->DragingFrame == this) {return(true);}
    DropItem(GuiManager->DragingFrame, nButton);
  }

  //

  if ((Item = SubFrameList.GetFirst()))
  do
  {
    Frame = (ZFrame *)Item->GetObject();
    if (Absolute_x >= Frame->EffectivePosition.Position_x)
     if (Absolute_y >= Frame->EffectivePosition.Position_y)
       if (Absolute_x <= (Frame->EffectivePosition.Position_x + Frame->EffectivePosition.Width))
         if (Absolute_y <= (Frame->EffectivePosition.Position_y + Frame->EffectivePosition.Height))
         {
           Frame->Event_MouseRelease = true;
           Frame->MouseButtonRelease( nButton, Absolute_x, Absolute_y);
         }

  } while ((Item = SubFrameList.GetNext(Item)));
  return true;
}
示例#6
0
	void RandomDrop()
	{
		for( int i = 0 ; i < kItemNum ; i++ ){
			if( GetRand(2) == 0 ){
				DropItem( static_cast<ItemID>( GetRand(ItemID_Num-2) + 1 ), Vector2( GetRand(1000)+200,GetRand(1000)+200 ) );
			}
		}
	}
示例#7
0
void ACPP_VRPawn::StopInteracting(class UMotionControllerComponent* withHand)
{
	if (withHand == LeftHand)
	{
		if (LHandItem != NULL)
		{
			DropItem(withHand);
		}
	}
	else
	{
		if (RHandItem != NULL)
		{
			DropItem(withHand);
		}
	}
}
示例#8
0
bool psSlotManager::HandleEvent( iEvent& ev )
{
    if(isDragging)
    {
        if(ev.Name == MouseMove)
        {
            if(isPlacing)
            {
                // Update item position.
                UpdateItem();
            }
        }
        else if(ev.Name == MouseDown)
        {
          uint button = csMouseEventHelper::GetButton(&ev);
          
          if(button == 0) // Left
          {
              if(isPlacing)
              {
                  // Drop the item at the current position.
                  if(isRotating)
                  {
                      DropItem();
                      return true;
                  }

                  // Else begin rotate...
                  isRotating = true;
                  basePoint = PawsManager::GetSingleton().GetMouse()->GetPosition();
                  psengine->GetSceneManipulator()->SaveCoordinates(csVector2(basePoint.x, basePoint.y));
                  return false;
              }

              // Else place...
              PlaceItem();
          }
          else
          {
              CancelDrag();

              // Show the inventory window, remove outline mesh etc. if we're placing.
              if(isPlacing)
              {
                  PawsManager::GetSingleton().GetMainWidget()->FindWidget("InventoryWindow")->Show();

                  // Remove outline mesh.
                  psengine->GetSceneManipulator()->RemoveSelected();

                  isPlacing = false;
                  isRotating = false;
              }
          }
        }
    }

    return false;
}
示例#9
0
文件: Item.cpp 项目: angjminer/deamos
/*
================
idMoveableItem::DropItems

  The entity should have the following key/value pairs set:
	"def_drop<type>Item"			"item def"
	"drop<type>ItemJoint"			"joint name"
	"drop<type>ItemRotation"		"pitch yaw roll"
	"drop<type>ItemOffset"			"x y z"
	"skin_drop<type>"				"skin name"
  To drop multiple items the following key/value pairs can be used:
	"def_drop<type>Item<X>"			"item def"
	"drop<type>Item<X>Joint"		"joint name"
	"drop<type>Item<X>Rotation"		"pitch yaw roll"
	"drop<type>Item<X>Offset"		"x y z"
  where <X> is an aribtrary string.
================
*/
void idMoveableItem::DropItems( idAnimatedEntity  *ent, const char *type, idList<idEntity *> *list ) {
	const idKeyValue *kv;
	const char *skinName, *c, *jointName;
	idStr key, key2;
	idVec3 origin;
	idMat3 axis;
	idAngles angles;
	const idDeclSkin *skin;
	jointHandle_t joint;
	idEntity *item;

	// drop all items
	kv = ent->spawnArgs.MatchPrefix( va( "def_drop%sItem", type ), NULL );
	while ( kv ) {

		c = kv->GetKey().c_str() + kv->GetKey().Length();
		if ( idStr::Icmp( c - 5, "Joint" ) != 0 && idStr::Icmp( c - 8, "Rotation" ) != 0 ) {

			key = kv->GetKey().c_str() + 4;
			key2 = key;
			key += "Joint";
			key2 += "Offset";
			jointName = ent->spawnArgs.GetString( key );
			joint = ent->GetAnimator()->GetJointHandle( jointName );
			if ( !ent->GetJointWorldTransform( joint, gameLocal.time, origin, axis ) ) {
				gameLocal.Warning( "%s refers to invalid joint '%s' on entity '%s'\n", key.c_str(), jointName, ent->name.c_str() );
				origin = ent->GetPhysics()->GetOrigin();
				axis = ent->GetPhysics()->GetAxis();
			}
			if ( g_dropItemRotation.GetString()[0] ) {
				angles.Zero();
				sscanf( g_dropItemRotation.GetString(), "%f %f %f", &angles.pitch, &angles.yaw, &angles.roll );
			} else {
				key = kv->GetKey().c_str() + 4;
				key += "Rotation";
				ent->spawnArgs.GetAngles( key, "0 0 0", angles );
			}
			axis = angles.ToMat3() * axis;

			origin += ent->spawnArgs.GetVector( key2, "0 0 0" );

			item = DropItem( kv->GetValue(), origin, axis, vec3_origin, 0, 0 );
			if ( list && item ) {
				list->Append( item );
			}
		}

		kv = ent->spawnArgs.MatchPrefix( va( "def_drop%sItem", type ), kv );
	}

	// change the skin to hide all items
	skinName = ent->spawnArgs.GetString( va( "skin_drop%s", type ) );
	if ( skinName[0] ) {
		skin = declManager->FindSkin( skinName );
		ent->SetSkin( skin );
	}
}
void CScriptGameObject::DropItemAndTeleport	(CScriptGameObject* pItem, Fvector position)
{
	DropItem						(pItem);

	NET_Packet						PP;
	CGameObject::u_EventGen			(PP,GE_CHANGE_POS, pItem->object().ID());
	PP.w_vec3						(position);
	CGameObject::u_EventSend		(PP);
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &info - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
void CNPC_CombineShot::Event_Killed(const CTakeDamageInfo &info)
{
	// Don't bother if we've been told not to, or the player has a megaphyscannon
	if ( combine_shot_spawn_health.GetBool() == false || PlayerHasMegaPhysCannon() )
	{
		BaseClass::Event_Killed( info );
		return;
	}

	CBasePlayer *pPlayer = ToBasePlayer( info.GetAttacker() );

	if ( !pPlayer )
	{
		CPropVehicleDriveable *pVehicle = dynamic_cast<CPropVehicleDriveable *>( info.GetAttacker() ) ;
		if ( pVehicle && pVehicle->GetDriver() && pVehicle->GetDriver()->IsPlayer() )
		{
			pPlayer = assert_cast<CBasePlayer *>( pVehicle->GetDriver() );
		}
	}

	if ( pPlayer != NULL )
	{
		CHalfLife2 *pHL2GameRules = static_cast<CHalfLife2 *>(g_pGameRules);

		// Attempt to drop health
		if ( pHL2GameRules->NPC_ShouldDropHealth( pPlayer ) )
		{
			DropItem( "item_healthvial", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) );
			pHL2GameRules->NPC_DroppedHealth();
		}
		
		if ( HasSpawnFlags( SF_COMBINE_NO_GRENADEDROP ) == false )
		{
			// Attempt to drop a grenade
			if ( pHL2GameRules->NPC_ShouldDropGrenade( pPlayer ) )
			{
				DropItem( "weapon_frag", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) );
				pHL2GameRules->NPC_DroppedGrenade();
			}
		}
	}

	BaseClass::Event_Killed( info );
}
示例#12
0
//=========================================================
// GibMonster - make gun fly through the air.
//=========================================================
//sys: esto es rarisimo, porque son raros los casos de gibbeo...Vamos a ponerlo
//igual de todas formas:
void CFriend :: GibMonster ( void )
{
	Vector	vecGunPos;
	Vector	vecGunAngles;

	// Si tiene arma ... y si NO tiene el flag de "no tirar arma"
	if ( GetBodygroup( 2 ) != 2 && !(pev->spawnflags & SF_MONSTER_NO_WPN_DROP))
	{// throw a gun if the grunt has one
		GetAttachment( 0, vecGunPos, vecGunAngles );
		
		CBaseEntity *pGun;
	//	if (FBitSet( pev->weapons, HGRUNT_SHOTGUN ))
		if (pev->frags)
		{
			pGun = DropItem( "weapon_spas12", vecGunPos, vecGunAngles );
			pGun->pev->spawnflags |= SF_NORESPAWN;
		}
		else //sino tiene 9mmAR
		{
			pGun = DropItem( "weapon_m16", vecGunPos, vecGunAngles );
			pGun->pev->spawnflags |= SF_NORESPAWN;
		}
		if ( pGun )
		{
			pGun->pev->velocity = Vector (RANDOM_FLOAT(-100,100), RANDOM_FLOAT(-100,100), RANDOM_FLOAT(200,300));
			pGun->pev->avelocity = Vector ( 0, RANDOM_FLOAT( 200, 400 ), 0 );
		}
/*	
		if (FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER ))
		{
			pGun = DropItem( "ammo_ARgrenades", vecGunPos, vecGunAngles );
			if ( pGun )
			{
				pGun->pev->velocity = Vector (RANDOM_FLOAT(-100,100), RANDOM_FLOAT(-100,100), RANDOM_FLOAT(200,300));
				pGun->pev->avelocity = Vector ( 0, RANDOM_FLOAT( 200, 400 ), 0 );
			}
		}
*/
	}

	CBaseMonster :: GibMonster();
}
示例#13
0
文件: barney.cpp 项目: FWGS/XashXT
void CBarney::Killed( entvars_t *pevAttacker, int iGib )
{
	if ( pev->body < m_iBaseBody + BARNEY_BODY_GUNGONE && !(pev->spawnflags & SF_MONSTER_NO_WPN_DROP))
	{// drop the gun!
		Vector vecGunPos;
		Vector vecGunAngles;

		pev->body = m_iBaseBody + BARNEY_BODY_GUNGONE;

		GetAttachment( 0, vecGunPos, vecGunAngles );
		
		CBaseEntity *pGun;
		if (pev->frags)
			pGun = DropItem( "weapon_357", vecGunPos, vecGunAngles );
		else
			pGun = DropItem( "weapon_9mmhandgun", vecGunPos, vecGunAngles );
	}

	SetUse( NULL );	
	CTalkMonster::Killed( pevAttacker, iGib );
}
示例#14
0
void CAGrunt::Killed( entvars_t *pevAttacker, int iGib )
{
	if ( pev->spawnflags & SF_MONSTER_NO_WPN_DROP )
	{// drop the hornetgun!
		Vector vecGunPos;
		Vector vecGunAngles;

		pev->body = AGRUNT_BODY_NOGUN;

		GetAttachment( 0, vecGunPos, vecGunAngles );
		
		DropItem( "weapon_hornetgun", vecGunPos, vecGunAngles );
	}

	CBaseMonster::Killed( pevAttacker, iGib );
}
示例#15
0
void CBarney::Killed( entvars_t *pevAttacker, int iGib )
{
	if ( pev->body < BARNEY_BODY_GUNGONE )
	{// drop the gun!
		Vector vecGunPos;
		Vector vecGunAngles;

		pev->body = BARNEY_BODY_GUNGONE;

		GetAttachment( 0, vecGunPos, vecGunAngles );
		
		CBaseEntity *pGun = DropItem( "weapon_9mmhandgun", vecGunPos, vecGunAngles );
	}

	SetUse( NULL );	
	CTalkMonster::Killed( pevAttacker, iGib );
}
void CDragDropListCtrl::OnLButtonUp(UINT nFlags, CPoint point) 
{
	if (m_pDragImage)
	{
		KillScrollTimer();

		// Release the mouse capture and end the dragging.
		::ReleaseCapture();
		m_pDragImage->DragLeave(CWnd::GetDesktopWindow());
		m_pDragImage->EndDrag();

		delete m_pDragImage;
		m_pDragImage = NULL;

		// Drop the item on the list.
		DropItem();
	}
	
	CListCtrl::OnLButtonUp(nFlags, point);
}
示例#17
0
int InventoryManager::Drop(bool *keys)
{
    int find = 0;

    for (int i = 65; i < 91; i++) //a - w
    {
        if (keys[i] == true)
        {
            Unequip(i - 65);

            if (DropItem(i - 65))
            {
                ShowInventory(-1);
                mState = eDisplay;
            }
            keys[i] = false;
        }
    }
    return 1;
}
void COtis::Killed( entvars_t *pevAttacker, int iGib )
{
	if ( GetBodygroup( OT_GUN_GROUP ) != OT_GUN_HOLSTER )
	{// drop the gun!
		Vector vecGunPos;
		Vector vecGunAngles;

		SetBodygroup( OT_GUN_GROUP , OT_GUN_HOLSTER );
		GetAttachment( 0, vecGunPos, vecGunAngles );
		CBaseEntity *pGun = DropItem( "weapon_357", vecGunPos, vecGunAngles );
	}

	SetUse( NULL );	

	// make sure friends talk about it if player hurts talkmonsters...
	if( !m_fHostile )
		CTalkMonster::Killed( pevAttacker, iGib );
	else
		CBaseMonster::Killed( pevAttacker, iGib );
}
示例#19
0
void Player::TakeItem()
{
	if (_position->GetItem() != nullptr)
	{
		Item * item = _position->GetItem();
		if (_inventory[0] == nullptr || _inventory[1] == nullptr ||
			_inventory[2] == nullptr || _inventory[3] == nullptr)
			{
				if		(_inventory[0] == nullptr) _inventory[0] = item;
				else if	(_inventory[1] == nullptr) _inventory[1] = item;
				else if	(_inventory[2] == nullptr) _inventory[2] = item;
				else if	(_inventory[3] == nullptr) _inventory[3] = item;
				_position->RemoveItem();
			}
			else if (_selectedItem != nullptr)
			{
				DropItem();
			}
	}
}
/*
================
idMoveableItem::DropRandomItems

  The entity should have the following key/value pairs set:
	"def_drop<type>Item"			"item def"
	"drop<type>ItemJoint"			"joint name"
	"drop<type>ItemRotation"		"pitch yaw roll"
	"drop<type>ItemOffset"			"x y z"
	"skin_drop<type>"				"skin name"
  To drop multiple items the following key/value pairs can be used:
	"def_drop<type>Item<X>"			"item def"
	"drop<type>Item<X>Joint"		"joint name"
	"drop<type>Item<X>Rotation"		"pitch yaw roll"
	"drop<type>Item<X>Offset"		"x y z"
  where <X> is an aribtrary string.
================
*/
void idMoveableItem::DropRandomItems( idAnimatedEntity  *ent, const char *type, idList<idEntity *> *list ) {
	const idKeyValue *kv;
	idStr key;
	idVec3 origin;
	idVec3 offset;
	idMat3 axis;
	idAngles angles;
	idEntity *item;

	int num = 0;
	kv = ent->spawnArgs.MatchPrefix( va( "def_drop%sItem", type ), NULL );
	while ( kv ) {
		num++;
		kv = ent->spawnArgs.MatchPrefix( va( "def_drop%sItem", type ), kv );
	}

	// drop all items
	float pct = 1.0f / ( ent->spawnArgs.GetFloat( "dropRandomItemNum" ) + 1.0f );
	float f = pct;
	kv = ent->spawnArgs.MatchPrefix( va( "drop%sItemOffset", type ), NULL );
	while ( kv ) {
		if ( f < gameLocal.random.RandomFloat() ) {
			key = kv->GetKey();
			ent->spawnArgs.GetVector( key, "0 0 0", offset );
			origin = ent->GetPhysics()->GetAbsBounds().GetCenter() + offset;
			axis = ent->GetPhysics()->GetAxis();
			angles.Zero();
			axis = angles.ToMat3() * axis;

			int n = gameLocal.random.RandomInt( num ) + 1;
			
			item = DropItem( ent->spawnArgs.GetString( va( "def_drop%sItem%i", type, n ) ), origin, axis, vec3_origin, 0, 0 );
			if ( list && item ) {
				list->Append( item );
			}
		}
		f += pct;
	
		kv = ent->spawnArgs.MatchPrefix( va( "drop%sItemOffset", type ), kv );
	}
}
示例#21
0
bool Monster::Action_in(Game_Manager* gm_)
{
	if(!isLive())
	{	
		DropItem(gm_);
		return true;
	}
	if(GetWarning()>0)
		UpDownWarning(-5);

	if(weapon && GetFocus()>0)
	{
		UpDownFocus(-weapon->GetFocusCalm());
		if(GetFocus()<0)
			SetFocus(0);
	}
	
	if(!nonmove_delay && !GetFly()/*!fly.fly*/)
	{
		if(ai)
			ai->Action();
	}
	else
	{
	
		if(nonmove_delay)
			nonmove_delay--;
	}

	if(target_continue>0)
		target_continue--;
	
	if(weapon) //현재 주아이템이 있다.
		weapon->Passive(gm_, NULL, true);//발휘되는 패시브 효과		

	Special_Action(gm_);
	CommonAction(gm_);
	return false;
}
//Spawn Player
void snDungeon2::SpawnPlayer()
{
	//Add Player
	int random = rand() % 4;
	if (random == 0)
		App->game->player->SetPosition({ 1442, 1530 });
	else if (random == 1)
		App->game->player->SetPosition({ 120, 2169 });
	else if (random == 2)
		App->game->player->SetPosition({ -1262, 3101 });
	else if (random == 3)
		App->game->player->SetPosition({ -2340, 1961 });

	//Add Boss
	int random2 = rand() % 4;
	while (random2 == random)
	{
		random2 = rand() % 4;
	}
	Entity* to_add = NULL;
	iPoint pos;
	if (random2 == 0)
	{
		pos = { 1442, 1530 };
		to_add = AddBoss(pos);
		entity_list.push_back(to_add);
	}	
	else if (random2 == 1)
	{
		pos = { 120, 2169 };
		to_add = AddBoss(pos);
		entity_list.push_back(to_add);
	}	
	else if (random2 == 2)
	{
		pos = { -1262, 3101 };
		to_add = AddBoss(pos);
		entity_list.push_back(to_add);
	}	
	else if (random2 == 3)
	{
		pos = { -2340, 1961 };
		to_add = AddBoss(pos);
		entity_list.push_back(to_add);
	}
	
	//Add Enemies 1
	if (random != 0 && random2 != 0)
	{
		pos = { 109, 40 };
		for (int i = 0; i < 3; i++)
		{
			for (int i = 0; i < 2; i++)
			{
				to_add = AddEnemy(pos);
				entity_list.push_back(to_add);
				pos.y += 3;
			}
			pos.x += 2;
			pos.y = 40;
		}
	}
	if (random != 1 && random2 != 1)
	{
		pos = { 105, 102 };
		for (int i = 0; i < 3; i++)
		{
			for (int i = 0; i < 2; i++)
			{
				to_add = AddEnemy(pos);
				entity_list.push_back(to_add);
				pos.y += 3;
			}
			pos.x += 2;
			pos.y = 102;
		}
	}
		
	if (random != 2 && random2 != 2)
	{
		pos = { 120, 182 };
		for (int i = 0; i < 3; i++)
		{
			for (int i = 0; i < 2; i++)
			{
				to_add = AddEnemy(pos);
				entity_list.push_back(to_add);
				pos.y += 3;
			}
			pos.x += 2;
			pos.y = 182;
		}
	}
	if (random != 3 && random2 != 3)
	{
		pos = { 35, 153 };
		for (int i = 0; i < 3; i++)
		{
			for (int i = 0; i < 2; i++)
			{
				to_add = AddEnemy(pos);
				entity_list.push_back(to_add);
				pos.y += 3;
			}
			pos.x += 2;
			pos.y = 153;
		}
	}

	//Add Enemies 2
	pos = { 109, 123 };
	for (int i = 0; i < 2; i++)
	{
		for (int i = 0; i < 2; i++)
		{
			to_add = AddEnemy(pos);
			entity_list.push_back(to_add);
			pos.y += 4;
		}
		pos.x += 3;
		pos.y = 123;
	}

	pos = { 117, 153 };
	for (int i = 0; i < 2; i++)
	{
		for (int i = 0; i < 2; i++)
		{
			to_add = AddEnemy(pos);
			entity_list.push_back(to_add);
			pos.y += 4;
		}
		pos.x += 3;
		pos.y = 153;
	}

	pos = { 62, 182 };
	for (int i = 0; i < 2; i++)
	{
		for (int i = 0; i < 2; i++)
		{
			to_add = AddEnemy(pos);
			entity_list.push_back(to_add);
			pos.y += 4;
		}
		pos.x += 3;
		pos.y = 182;
	}

	pos = { 178, 46 };
	for (int i = 0; i < 2; i++)
	{
		for (int i = 0; i < 2; i++)
		{
			to_add = AddEnemy(pos);
			entity_list.push_back(to_add);
			pos.y += 4;
		}
		pos.x += 3;
		pos.y = 46;
	}

	//Add Enemies 3
	//Y lines
	pos = { 109, 67 };
	for (int i = 0; i < 3; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.y += 4;
	}

	pos = { 61, 142 };
	for (int i = 0; i < 3; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.y += 4;
	}

	pos = { 185, 70 };
	for (int i = 0; i < 3; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.y += 4;
	}

	//X lines
	pos = { 87, 177 };
	for (int i = 0; i < 3; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.x += 3;
	}

	pos = { 191, 125 };
	for (int i = 0; i < 3; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.x += 3;
	}

	pos = { 144, 33 };
	for (int i = 0; i < 3; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.x += 3;
	}

	//Add Enemies 4
	pos = { 77, 121 };
	for (int i = 0; i < 2; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.x += 3;
	}
	pos = { 79, 124 };
	to_add = AddEnemy(pos);
	entity_list.push_back(to_add);

	pos = { 95, 155 };
	for (int i = 0; i < 2; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.x += 3;
	}
	pos = { 97, 158 };
	to_add = AddEnemy(pos);
	entity_list.push_back(to_add);

	pos = { 142, 155 };
	for (int i = 0; i < 2; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.x += 3;
	}
	pos = { 144, 158 };
	to_add = AddEnemy(pos);
	entity_list.push_back(to_add);

	pos = { 166, 141 };
	for (int i = 0; i < 2; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.x += 3;
	}
	pos = { 168, 144 };
	to_add = AddEnemy(pos);
	entity_list.push_back(to_add);

	pos = { 153, 105 };
	for (int i = 0; i < 2; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.x += 3;
	}
	pos = { 155, 108 };
	to_add = AddEnemy(pos);
	entity_list.push_back(to_add);

	pos = { 178, 105 };
	for (int i = 0; i < 2; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.x += 3;
	}
	pos = { 180, 108 };
	to_add = AddEnemy(pos);
	entity_list.push_back(to_add);

	pos = { 150, 73 };
	for (int i = 0; i < 2; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.x += 3;
	}
	pos = { 152, 76 };
	to_add = AddEnemy(pos);
	entity_list.push_back(to_add);

	pos = { 68, 57 };
	for (int i = 0; i < 2; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.x += 3;
	}
	pos = { 70, 60 };
	to_add = AddEnemy(pos);
	entity_list.push_back(to_add);

	pos = { 89, 35 };
	for (int i = 0; i < 2; i++)
	{
		to_add = AddEnemy(pos);
		entity_list.push_back(to_add);
		pos.x += 3;
	}
	pos = { 91, 38 };
	to_add = AddEnemy(pos);
	entity_list.push_back(to_add);

	//Items
	DropItem({ 380, 3118 });
	DropItem({ 1402, 2270 });
	DropItem({ 61, 1265 });
	DropItem({ -2182, 2524 });
	DropItem({ -701, 2083 });
	DropItem({ -1379, 2543 });

}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &info - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
void CNPC_CombineAce::Event_Killed( const CTakeDamageInfo &info )
{
	if (!(g_Language.GetInt() == LANGUAGE_GERMAN || UTIL_IsLowViolence()) && info.GetDamageType() & (DMG_BLAST | DMG_CRUSH) && !(info.GetDamageType() & (DMG_DISSOLVE)) && !PlayerHasMegaPhysCannon())
	{
		Vector vecDamageDir = info.GetDamageForce();
		SpawnBlood(GetAbsOrigin(), g_vecAttackDir, BloodColor(), info.GetDamage());
		DispatchParticleEffect("headshotspray", GetAbsOrigin(), GetAbsAngles(), this);
		EmitSound("Gore.Headshot");
		float flFadeTime = 25.0;

		CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/soldier_ace_head.mdl", flFadeTime);

		Vector vecRagForce;
		vecRagForce.x = random->RandomFloat(-400, 400);
		vecRagForce.y = random->RandomFloat(-400, 400);
		vecRagForce.z = random->RandomFloat(0, 250);

		Vector vecRagDmgForce = (vecRagForce + vecDamageDir);

		CBaseEntity *pLeftArmGib = CreateRagGib("models/gibs/soldier_ace_left_arm.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pLeftArmGib)
		{
			color32 color = pLeftArmGib->GetRenderColor();
			pLeftArmGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pRightArmGib = CreateRagGib("models/gibs/soldier_ace_right_arm.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pRightArmGib)
		{
			color32 color = pRightArmGib->GetRenderColor();
			pRightArmGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pTorsoGib = CreateRagGib("models/gibs/soldier_ace_torso.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pTorsoGib)
		{
			color32 color = pTorsoGib->GetRenderColor();
			pTorsoGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pPelvisGib = CreateRagGib("models/gibs/soldier_ace_pelvis.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pPelvisGib)
		{
			color32 color = pPelvisGib->GetRenderColor();
			pPelvisGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pLeftLegGib = CreateRagGib("models/gibs/soldier_ace_left_leg.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pLeftLegGib)
		{
			color32 color = pLeftLegGib->GetRenderColor();
			pLeftLegGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pRightLegGib = CreateRagGib("models/gibs/soldier_ace_right_leg.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pRightLegGib)
		{
			color32 color = pRightLegGib->GetRenderColor();
			pRightLegGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		//now add smaller gibs.
		CGib::SpawnSpecificGibs(this, 3, 750, 1500, "models/gibs/pgib_p3.mdl", flFadeTime);
		CGib::SpawnSpecificGibs(this, 3, 750, 1500, "models/gibs/pgib_p4.mdl", flFadeTime);

		if (!m_bNoArmor && combine_ace_shieldspawnmode.GetInt() > 0)
		{
			pArmor->Remove();
			DropItem("item_shield", WorldSpaceCenter() + RandomVector(-4, 4), RandomAngle(0, 360));
		}

		Vector forceVector = CalcDamageForceVector(info);

		// Drop any weapon that I own
		if (VPhysicsGetObject())
		{
			Vector weaponForce = forceVector * VPhysicsGetObject()->GetInvMass();
			Weapon_Drop(m_hActiveWeapon, NULL, &weaponForce);
		}
		else
		{
			Weapon_Drop(m_hActiveWeapon);
		}

		if (info.GetAttacker()->IsPlayer())
		{
			((CSingleplayRules*)GameRules())->NPCKilled(this, info);
		}

		UTIL_Remove(this);
		SetThink(NULL);
		return;
	}

	// Don't bother if we've been told not to, or the player has a megaphyscannon
	if ( combine_ace_spawn_health.GetBool() == false || PlayerHasMegaPhysCannon() )
	{
		BaseClass::Event_Killed( info );
		return;
	}

	SetEyeState(ACE_EYE_DEAD);

	if (!m_bNoArmor && combine_ace_shieldspawnmode.GetInt() > 0)
	{
		pArmor->Remove();
	}

	CBasePlayer *pPlayer = ToBasePlayer( info.GetAttacker() );

	if ( !pPlayer )
	{
		CPropVehicleDriveable *pVehicle = dynamic_cast<CPropVehicleDriveable *>( info.GetAttacker() ) ;
		if ( pVehicle && pVehicle->GetDriver() && pVehicle->GetDriver()->IsPlayer() )
		{
			pPlayer = assert_cast<CBasePlayer *>( pVehicle->GetDriver() );
		}
	}

	if ( pPlayer != NULL )
	{
		// Elites drop alt-fire ammo, so long as they weren't killed by dissolving.
#ifdef HL2_EPISODIC
		if (HasSpawnFlags(SF_COMBINE_NO_AR2DROP) == false)
#endif
		{
			if (FClassnameIs(GetActiveWeapon(), "weapon_ar2"))
			{
				CBaseEntity *pItem = DropItem("item_ammo_ar2_altfire", WorldSpaceCenter() + RandomVector(-4, 4), RandomAngle(0, 360));

				if (pItem)
				{
					IPhysicsObject *pObj = pItem->VPhysicsGetObject();

					if (pObj)
					{
						Vector			vel = RandomVector(-64.0f, 64.0f);
						AngularImpulse	angImp = RandomAngularImpulse(-300.0f, 300.0f);

						vel[2] = 0.0f;
						pObj->AddVelocity(&vel, &angImp);
					}

					if (info.GetDamageType() & DMG_DISSOLVE)
					{
						CBaseAnimating *pAnimating = dynamic_cast<CBaseAnimating*>(pItem);

						if (pAnimating)
						{
							pAnimating->Dissolve(NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL);
						}
					}
					else
					{
						WeaponManager_AddManaged(pItem);
					}
				}
			}
			else if (FClassnameIs(GetActiveWeapon(), "weapon_smg1"))
			{
				CBaseEntity *pItem = DropItem("item_ammo_smg1_grenade", WorldSpaceCenter() + RandomVector(-4, 4), RandomAngle(0, 360));

				if (pItem)
				{
					IPhysicsObject *pObj = pItem->VPhysicsGetObject();

					if (pObj)
					{
						Vector			vel = RandomVector(-64.0f, 64.0f);
						AngularImpulse	angImp = RandomAngularImpulse(-300.0f, 300.0f);

						vel[2] = 0.0f;
						pObj->AddVelocity(&vel, &angImp);
					}

					if (info.GetDamageType() & DMG_DISSOLVE)
					{
						CBaseAnimating *pAnimating = dynamic_cast<CBaseAnimating*>(pItem);

						if (pAnimating)
						{
							pAnimating->Dissolve(NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL);
						}
					}
					else
					{
						WeaponManager_AddManaged(pItem);
					}
				}
			}
		}

		CHalfLife2 *pHL2GameRules = static_cast<CHalfLife2 *>(g_pGameRules);

		// Attempt to drop health
		if ( pHL2GameRules->NPC_ShouldDropHealth( pPlayer ) )
		{
			DropItem( "item_healthvial", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) );
			pHL2GameRules->NPC_DroppedHealth();
		}

		if (!m_bNoArmor && combine_ace_shieldspawnmode.GetInt() > 0)
		{
			DropItem("item_shield", WorldSpaceCenter() + RandomVector(-4, 4), RandomAngle(0, 360));
		}
	}

	BaseClass::Event_Killed( info );
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &info - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
void CNPC_CombineS::Event_Killed( const CTakeDamageInfo &info )
{
	if (!(g_Language.GetInt() == LANGUAGE_GERMAN || UTIL_IsLowViolence()) && info.GetDamageType() & (DMG_BLAST | DMG_CRUSH) && !(info.GetDamageType() & (DMG_DISSOLVE)) && !PlayerHasMegaPhysCannon())
	{
		Vector vecDamageDir = info.GetDamageForce();
		SpawnBlood(GetAbsOrigin(), g_vecAttackDir, BloodColor(), info.GetDamage());
		DispatchParticleEffect("headshotspray", GetAbsOrigin(), GetAbsAngles(), this);
		EmitSound("Gore.Headshot");
		float flFadeTime = 25.0;

		CGib::SpawnSpecificGibs(this, 1, 750, 1500, "models/gibs/soldier_head.mdl", flFadeTime);
		
		Vector vecRagForce;
		vecRagForce.x = random->RandomFloat(-400, 400);
		vecRagForce.y = random->RandomFloat(-400, 400);
		vecRagForce.z = random->RandomFloat(0, 250);

		Vector vecRagDmgForce = (vecRagForce + vecDamageDir);

		CBaseEntity *pLeftArmGib = CreateRagGib("models/gibs/soldier_left_arm.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pLeftArmGib)
		{ 
			color32 color = pLeftArmGib->GetRenderColor();
			pLeftArmGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pRightArmGib = CreateRagGib("models/gibs/soldier_right_arm.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pRightArmGib)
		{
			color32 color = pRightArmGib->GetRenderColor();
			pRightArmGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pTorsoGib = CreateRagGib("models/gibs/soldier_torso.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pTorsoGib)
		{
			color32 color = pTorsoGib->GetRenderColor();
			pTorsoGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pPelvisGib = CreateRagGib("models/gibs/soldier_pelvis.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pPelvisGib)
		{
			color32 color = pPelvisGib->GetRenderColor();
			pPelvisGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pLeftLegGib = CreateRagGib("models/gibs/soldier_left_leg.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pLeftLegGib)
		{
			color32 color = pLeftLegGib->GetRenderColor();
			pLeftLegGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		CBaseEntity *pRightLegGib = CreateRagGib("models/gibs/soldier_right_leg.mdl", GetAbsOrigin(), GetAbsAngles(), vecRagDmgForce, flFadeTime, IsOnFire());
		if (pRightLegGib)
		{
			color32 color = pRightLegGib->GetRenderColor();
			pRightLegGib->SetRenderColor(color.r, color.g, color.b, color.a);
		}

		//now add smaller gibs.
		CGib::SpawnSpecificGibs(this, 3, 750, 1500, "models/gibs/pgib_p3.mdl", flFadeTime);
		CGib::SpawnSpecificGibs(this, 3, 750, 1500, "models/gibs/pgib_p4.mdl", flFadeTime);

		Vector forceVector = CalcDamageForceVector(info);

		// Drop any weapon that I own
		if (VPhysicsGetObject())
		{
			Vector weaponForce = forceVector * VPhysicsGetObject()->GetInvMass();
			Weapon_Drop(m_hActiveWeapon, NULL, &weaponForce);
		}
		else
		{
			Weapon_Drop(m_hActiveWeapon);
		}

		if (info.GetAttacker()->IsPlayer())
		{
			((CSingleplayRules*)GameRules())->NPCKilled(this, info);
		}

		UTIL_Remove(this);
		SetThink(NULL);
		return;
	}

	// Don't bother if we've been told not to, or the player has a megaphyscannon
	if ( combine_spawn_health.GetBool() == false || PlayerHasMegaPhysCannon() )
	{
		BaseClass::Event_Killed( info );
		return;
	}

	CBasePlayer *pPlayer = ToBasePlayer( info.GetAttacker() );

	if ( !pPlayer )
	{
		CPropVehicleDriveable *pVehicle = dynamic_cast<CPropVehicleDriveable *>( info.GetAttacker() ) ;
		if ( pVehicle && pVehicle->GetDriver() && pVehicle->GetDriver()->IsPlayer() )
		{
			pPlayer = assert_cast<CBasePlayer *>( pVehicle->GetDriver() );
		}
	}

	if ( pPlayer != NULL )
	{
		CHalfLife2 *pHL2GameRules = static_cast<CHalfLife2 *>(g_pGameRules);

		// Attempt to drop health
		if ( pHL2GameRules->NPC_ShouldDropHealth( pPlayer ) )
		{
			DropItem( "item_healthvial", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) );
			pHL2GameRules->NPC_DroppedHealth();
		}
		
		if ( HasSpawnFlags( SF_COMBINE_NO_GRENADEDROP ) == false )
		{
			// Attempt to drop a grenade
			if ( pHL2GameRules->NPC_ShouldDropGrenade( pPlayer ) )
			{
				DropItem( "weapon_frag", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) );
				pHL2GameRules->NPC_DroppedGrenade();
			}
		}
	}

	BaseClass::Event_Killed( info );
}
示例#25
0
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//
// Returns number of events handled, 0 if none.
//=========================================================
void CFriend :: HandleAnimEvent( MonsterEvent_t *pEvent )
{
	Vector	vecGunPos;
	Vector	vecGunAngles;

	GetAttachment( 0, vecGunPos, vecGunAngles );

	switch( pEvent->event )
	{
	case HGRUNT_AE_BURST1:
		BarneyFirePistol();
		break;
//sys	
	case HGRUNT_AE_BURST2:
	case HGRUNT_AE_BURST3:
		BarneyFirePistol();
		break;
/*
	case HGRUNT_AE_KICK:
	{
		CBaseEntity *pHurt = Kick();

		if ( pHurt )
		{
			// SOUND HERE!
			UTIL_MakeVectors( pev->angles );
			pHurt->pev->punchangle.x = 15;
			pHurt->pev->velocity = pHurt->pev->velocity + gpGlobals->v_forward * 100 + gpGlobals->v_up * 50;
			pHurt->TakeDamage( pev, pev, gSkillData.hgruntDmgKick, DMG_CLUB );
		}
	}
	break;
*/
		case HGRUNT_AE_DROP_GUN:
			{
				//SP: si tiene el flag de "no tirar arma" cerrar con break y no ejecutar
				//mas codigo
				if (pev->spawnflags & SF_MONSTER_NO_WPN_DROP) break; //LRC

				Vector	vecGunPos;
				Vector	vecGunAngles;

				GetAttachment( 0, vecGunPos, vecGunAngles );

				SetBodygroup( GUN_GROUP, GUN_NONE );

				CBaseEntity *pItem;

				// now spawn a gun.
				//if (FBitSet( pev->weapons, HGRUNT_SHOTGUN ))
				if (pev->frags)
				{
					pItem = DropItem( "weapon_shotgun", vecGunPos, vecGunAngles );
					pItem->pev->spawnflags |= SF_NORESPAWN; // No respawn
				}
				else
				{
					pItem = DropItem( "weapon_m16", vecGunPos, vecGunAngles );
					pItem->pev->spawnflags |= SF_NORESPAWN; // No respawn
				}
				
			//if -> crash, remove the following	
			//	pItem->pev->avelocity = Vector ( RANDOM_FLOAT( -222, 222 ), RANDOM_FLOAT( -222, 222 ),RANDOM_FLOAT( -222, 222 ) );
			}
		break;

	case HGRUNT_AE_RELOAD:
		EMIT_SOUND( ENT(pev), CHAN_WEAPON, "hgrunt/gr_reload1.wav", 1, ATTN_NORM );
		m_cAmmoLoaded = m_cClipSize;
		ClearConditions(bits_COND_NO_AMMO_LOADED);
				
//		DropItem( "item_clip_rifle", vecGunPos, vecGunAngles );//test
		break;

	case FBARNEY_AE_DRAW:
		if (pev->frags)//shotgun
		SetBodygroup( GUN_GROUP, GUN_SHOTGUN );
		else
		SetBodygroup( GUN_GROUP, GUN_MP5 );

		m_fGunDrawn = TRUE;
		break;
	
	case HGRUNT_AE_GREN_DROP:
		{
			UTIL_MakeVectors( pev->angles );		
		
			CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 17 - gpGlobals->v_right * 27 + gpGlobals->v_up * 6, g_vecZero, 3 );
		}
		break;
	
	case HGRUNT_AE_GREN_TOSS:
		{
			UTIL_MakeVectors( pev->angles );
			// CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 34 + Vector (0, 0, 32), m_vecTossVelocity, 3.5 );
			
			CGrenade::ShootTimed( pev, GetGunPosition(), m_vecTossVelocity, 3.5 );

			m_fThrowGrenade = FALSE;
			m_flNextGrenadeCheck = gpGlobals->time + 6;// wait six seconds before even looking again to see if a grenade can be thrown.
		}
		break;

	default:
		CTalkMonster::HandleAnimEvent( pEvent );
	}
}
void CFootBotForagingNR::ReturnToNest() {
  // Don't actually return, just drop what you hold.
  DropItem();
}
示例#27
0
bool psSlotManager::HandleEvent( iEvent& ev )
{
    if(isDragging)
    {
        int button = csMouseEventHelper::GetButton(&ev);
        if(ev.Name == MouseMove)
        {
            if(isPlacing)
            {
                // Update item position.
                UpdateItem();
            }
        }
        else if(ev.Name == MouseDown)
        {
            if(button == csmbLeft) // Left
            {
                if(isPlacing)
                {
                    // Drop the item at the current position.
                    DropItem(!(csMouseEventHelper::GetModifiers(&ev) & CSMASK_SHIFT));
                    return true;
                }
                else
                {
                    PlaceItem();
                }
            }
            else if(button == csmbRight) // right
            {
                if(!isRotating)
                {
                    basePoint = PawsManager::GetSingleton().GetMouse()->GetPosition();
                    isRotating = true;
                    if(csMouseEventHelper::GetModifiers(&ev) & CSMASK_SHIFT)
                    {
                        psengine->GetSceneManipulator()->SetRotation(PS_MANIPULATE_PITCH,PS_MANIPULATE_YAW);
                    }
                    else
                    {
                        psengine->GetSceneManipulator()->SetRotation(PS_MANIPULATE_ROLL,PS_MANIPULATE_NONE);
                    }
                    return true;
                }
            }
            else
            {
                CancelDrag();
            }
        }
        else if(ev.Name == MouseUp)
        {
            if(button == csmbRight) // right
            {
                if(isRotating)
                {
                    //PawsManager::GetSingleton().GetMouse()->SetPosition(basePoint.x, basePoint.y);
                    psengine->GetG2D()->SetMousePosition(basePoint.x, basePoint.y);
                    psengine->GetSceneManipulator()->SetPosition(csVector2(basePoint.x, basePoint.y));
                    isRotating = false;
                    return true;
                }
            }
        }
        /*else if(ev.Name == KeyDown)
        {
        }
        else if(ev.Name == KeyUp)
        {
        }*/
    }

    return false;
}
示例#28
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &info - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
void CNPC_CombineS::Event_Killed( const CTakeDamageInfo &info )
{
	// Don't bother if we've been told not to, or the player has a megaphyscannon
	if ( combine_spawn_health.GetBool() == false || PlayerHasMegaPhysCannon() )
	{
		BaseClass::Event_Killed( info );
		return;
	}

	CBasePlayer *pPlayer = ToBasePlayer( info.GetAttacker() );

	if ( !pPlayer )
	{
		CPropVehicleDriveable *pVehicle = dynamic_cast<CPropVehicleDriveable *>( info.GetAttacker() ) ;
		if ( pVehicle && pVehicle->GetDriver() && pVehicle->GetDriver()->IsPlayer() )
		{
			pPlayer = assert_cast<CBasePlayer *>( pVehicle->GetDriver() );
		}
	}

	if ( pPlayer != NULL )
	{
		// Elites drop alt-fire ammo, so long as they weren't killed by dissolving.
		if( IsElite() )
		{
#ifdef HL2_EPISODIC
			if ( HasSpawnFlags( SF_COMBINE_NO_AR2DROP ) == false )
#endif
			{
				CBaseEntity *pItem = DropItem( "item_ammo_ar2_altfire", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) );

				if ( pItem )
				{
					IPhysicsObject *pObj = pItem->VPhysicsGetObject();

					if ( pObj )
					{
						Vector			vel		= RandomVector( -64.0f, 64.0f );
						AngularImpulse	angImp	= RandomAngularImpulse( -300.0f, 300.0f );

						vel[2] = 0.0f;
						pObj->AddVelocity( &vel, &angImp );
					}

					if( info.GetDamageType() & DMG_DISSOLVE )
					{
						CBaseAnimating *pAnimating = dynamic_cast<CBaseAnimating*>(pItem);

						if( pAnimating )
						{
							pAnimating->Dissolve( NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL );
						}
					}
					else
					{
						WeaponManager_AddManaged( pItem );
					}
				}
			}
		}

		CHalfLife2 *pHL2GameRules = static_cast<CHalfLife2 *>(g_pGameRules);

		// Attempt to drop health
		if ( pHL2GameRules->NPC_ShouldDropHealth( pPlayer ) )
		{
			DropItem( "item_healthvial", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) );
			pHL2GameRules->NPC_DroppedHealth();
		}
		
		if ( HasSpawnFlags( SF_COMBINE_NO_GRENADEDROP ) == false )
		{
			// Attempt to drop a grenade
			if ( pHL2GameRules->NPC_ShouldDropGrenade( pPlayer ) )
			{
				DropItem( "weapon_frag", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) );
				pHL2GameRules->NPC_DroppedGrenade();
			}
		}
	}

	BaseClass::Event_Killed( info );
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : &info - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
void CTDP_NPC_CombineS::Event_Killed( const CTakeDamageInfo &info )
{
	// Don't bother if we've been told not to, or the player has a megaphyscannon
/*	if ( combine_spawn_health.GetBool() == false || PlayerHasMegaPhysCannon() )
	{
		BaseClass::Event_Killed( info );
		return;
	}*/

	CBasePlayer *pPlayer = ToBasePlayer( info.GetAttacker() );

	if ( pPlayer != NULL )
	{
		// Elites drop alt-fire ammo, so long as they weren't killed by dissolving.
		if( IsElite() )
		{
			CBaseEntity *pItem = DropItem( "item_ammo_ar2_altfire", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) );

			if ( pItem )
			{
				IPhysicsObject *pObj = pItem->VPhysicsGetObject();

				if ( pObj )
				{
					Vector			vel		= RandomVector( -64.0f, 64.0f );
					AngularImpulse	angImp	= RandomAngularImpulse( -300.0f, 300.0f );

					vel[2] = 0.0f;
					pObj->AddVelocity( &vel, &angImp );
				}

				if( info.GetDamageType() & DMG_DISSOLVE )
				{
					CBaseAnimating *pAnimating = dynamic_cast<CBaseAnimating*>(pItem);

					if( pAnimating )
					{
						pAnimating->Dissolve( NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL );
					}
				}
			}
		}

		//CTDPGameRules *pTDPGameRules = static_cast<CTDPGameRules *>(g_pGameRules);

		// Attempt to drop health
		/*if ( pTDPGameRules->NPC_ShouldDropHealth( pPlayer ) )
		{
			DropItem( "item_healthvial", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) );
			pTDPGameRules->NPC_DroppedHealth();
		}*/
		
		// Attempt to drop a grenade
		/*if ( pTDPGameRules->NPC_ShouldDropGrenade( pPlayer ) )
		{
			DropItem( "weapon_frag", WorldSpaceCenter()+RandomVector(-4,4), RandomAngle(0,360) );
			pTDPGameRules->NPC_DroppedGrenade();
		}*/
	}

	BaseClass::Event_Killed( info );
}