void AimLegit::Work(CUserCmd *usercmd)
{
	this->usercmd = usercmd;

	if (!g_LocalPlayer->m_hActiveWeapon().Get())
		return;

	if (g_LocalPlayer->m_hActiveWeapon().Get()->IsWeaponNonAim() || g_LocalPlayer->m_hActiveWeapon().Get()->m_iClip1() < 1)
		return;

	if (g_Options.legit_enabled && (g_InputSystem->IsButtonDown(static_cast<ButtonCode_t>(g_Options.legit_aimkey1)) || g_InputSystem->IsButtonDown(static_cast<ButtonCode_t>(g_Options.legit_aimkey2))) && !g_LocalPlayer->m_hActiveWeapon().Get()->IsWeaponNonAim())
	{
		GetBestTarget();
		if (HasTarget())
			TargetRegion();
	}

	if (g_Options.legit_trigger || (g_Options.legit_trigger_with_aimkey && (g_InputSystem->IsButtonDown(static_cast<ButtonCode_t>(g_Options.legit_aimkey1)) || g_InputSystem->IsButtonDown(static_cast<ButtonCode_t>(g_Options.legit_aimkey2)))))
		Triggerbot();

	if (g_Options.legit_rcs)
		RecoilControlSystem();

	if (!g_Options.rage_silent) // I dont feel here good, cause of ragebot and stuff and the part inside CM cause of that
		g_EngineClient->SetViewAngles(usercmd->viewangles);
}
Example #2
0
void CFuncTrain::Spawn( void )
{
	Precache();
	if( pev->speed == 0 )
		pev->speed = 100;

	if( !HasTarget() )
		ALERT( at_console, "FuncTrain with no target" );

	if( pev->dmg == 0 )
		pev->dmg = 2;

	pev->movetype = MOVETYPE_PUSH;

	//Remove tracktrain include when changed
	if( FBitSet( pev->spawnflags, SF_TRAIN_PASSABLE ) )
		pev->solid = SOLID_NOT;
	else
		pev->solid = SOLID_BSP;

	SetModel( STRING( pev->model ) );
	SetSize( pev->mins, pev->maxs );
	SetAbsOrigin( GetAbsOrigin() );

	m_activated = false;

	if( m_volume == 0 )
		m_volume = 0.85;
}
BOOL CStupidGladiator::SearchEnemy()
{
	if (!HasTarget())
	{
		CMonsterAI::SearchEnemy();
	}
	return TRUE;
}
Example #4
0
 bool PetAI::OnMove(float destX, float destY)
 {
     if(!BaseAI::OnMove(destX, destY))
     {
         return false;
     }
     CPet *pet = (CPet*) GetOwner();
     // add ai event to search enemy when moving
     if(pet->GetFightType() == PET_FIGHETYPE_FIGHT && !HasTarget())
     {
         Resume(CONTINUE_TIME);
     }
     return true;
 }
Example #5
0
BOOL Guard::CanAttackCurrent()
{
	if( !HasTarget() )
	{
		return FALSE;
	}

	CMoveShape *pTarget = GetTarget();
	long dis = m_pOwner->Distance( pTarget );
	long attack_range = static_cast<CMonster*>( m_pOwner )->GetAttribute( string( "C_GuardRange" ) );

	if( dis > attack_range )
	{
		return FALSE;
	}

	CMonster *pSelf = static_cast<CMonster*>( m_pOwner );
	DWORD ai_ref = 0;
	
	if( pTarget->GetType() == TYPE_PLAYER )
	{
		CPlayer *pPlayer = static_cast<CPlayer*>( pTarget );
		// ai reference 1
		ai_ref = pSelf->GetAIReferrence( 0 );
		if( ai_ref >= 0 )
		{
			if( pPlayer->GetPVPValue() >= ai_ref && !IsSameCamp( pPlayer, pSelf ) )
			{
				return TRUE;
			}
		}
		// ai reference 2
		ai_ref = pSelf->GetAIReferrence( 1 );
		if( ai_ref > 0 )
		{
			if( pPlayer->GetPkValue() >= ai_ref )
			{
				return TRUE;
			}
		}
	}
	
	// actually, it's not necessary to judge monsters, that because the property for the monsters will
	// not changed .So ignored here.
	// ...

	return FALSE;
}
bool RPG_AiControllerComponent::HasValidTarget() const
{
  if (HasTarget())
  {
    VArray<RPG_DamageableEntity*> const& attackableEntities = RPG_GameManager::s_instance.GetAttackableEntities();
    if(attackableEntities.Find(m_target) < 0)
    {
      return false;
    }

    if(m_target->IsFrom(RPG_Character))
    {
      RPG_Character* targetCharacter = static_cast<RPG_Character*>(m_target);
      return !targetCharacter->IsDead() && !targetCharacter->IsFeigningDeath();
    }
    else
    {
      return true;
    }
  }
  return false;
}
Example #7
0
BOOL Guard::SearchEnemy()
{
	if( !CanSearchEnemy() )
	{
		return FALSE;
	}

	if( CanAttackCurrent() )
	{
		return FALSE;
	}

	ShapeListType player_list;
	ShapeListType monster_list;
	CServerRegion *pRegion = static_cast<CServerRegion*>( m_pOwner->GetFather() );
	CMonster *pSelf = static_cast<CMonster*>( m_pOwner );
	CMoveShape *pTarget = NULL;

	// find the around players
	pRegion->FindAroundObject( m_pOwner, TYPE_PLAYER, player_list );
	// find the around monsters including the guards.
	pRegion->FindAroundObject( m_pOwner, TYPE_MONSTER, monster_list );

	// filter the result
	Filter filter( static_cast<CMonster*>( m_pOwner ) );
	filter_shape( player_list, filter );
	filter_shape( monster_list, filter );


	// retrieve the ai reference
	DWORD ai_ref = pSelf->GetAIReferrence( 0 );
	if( ai_ref >= 0 )
	{
		pTarget = SearchByAIRef1( player_list, ai_ref );
	}

	if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 1 ) ) > 0 )
	{
		pTarget = SearchByAIRef2( player_list, ai_ref );
	}	

	if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 2 ) ) > 0 )
	{
		pTarget = SearchByAIRef3( monster_list, ai_ref );
	}

	if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 3 ) ) > 0 )
	{
		pTarget = SearchByAIRef4( monster_list, ai_ref );
	}

	if( pTarget != NULL )
	{
		// search successfully
		SetTarget( pTarget->GetType(), pTarget->GetExID() );
		return TRUE; 
	}
	else if( HasTarget() )
	{
		WhenLoseTarget();
	}

	return FALSE;	
}
Example #8
0
//=========================================================
// MakeMonster-  this is the code that drops the monster
//=========================================================
void CMonsterMaker::MakeMonster( void )
{
	if ( m_iMaxLiveChildren > 0 && m_cLiveChildren >= m_iMaxLiveChildren )
	{// not allowed to make a new one yet. Too many live ones out right now.
		return;
	}

	if ( !m_flGround )
	{
		// set altitude. Now that I'm activated, any breakables, etc should be out from under me. 
		TraceResult tr;

		UTIL_TraceLine ( GetAbsOrigin(), GetAbsOrigin() - Vector ( 0, 0, 2048 ), ignore_monsters, ENT(pev), &tr );
		m_flGround = tr.vecEndPos.z;
	}

	Vector mins = GetAbsOrigin() - Vector( 34, 34, 0 );
	Vector maxs = GetAbsOrigin() + Vector( 34, 34, 0 );
	maxs.z = GetAbsOrigin().z;
	mins.z = m_flGround;

	CBaseEntity *pList[2];
	int count = UTIL_EntitiesInBox( pList, 2, mins, maxs, FL_CLIENT|FL_MONSTER );
	if ( count )
	{
		// don't build a stack of monsters!
		return;
	}

	CBaseEntity* pEntity = CBaseEntity::Create( STRING( m_iszMonsterClassname ), GetAbsOrigin(), GetAbsAngles(), nullptr, false );

	if( !pEntity )
	{
		ALERT( at_console, "NULL Ent in MonsterMaker!\n" );
		return;
	}
	
	// If I have a target, fire!
	if ( HasTarget() )
	{
		// delay already overloaded for this entity, so can't call SUB_UseTargets()
		FireTargets( GetTarget(), this, this, USE_TOGGLE, 0 );
	}

	pEntity->SetAbsOrigin( GetAbsOrigin() );
	pEntity->SetAbsAngles( GetAbsAngles() );
	pEntity->GetSpawnFlags() |= SF_MONSTER_FALL_TO_GROUND;

	// Children hit monsterclip brushes
	if ( GetSpawnFlags().Any(SF_MONSTERMAKER_MONSTERCLIP ) )
		pEntity->GetSpawnFlags() |= SF_MONSTER_HITMONSTERCLIP;

	DispatchSpawn( pEntity->edict() );

	pEntity->SetOwner( this );

	if ( HasNetName() )
	{
		// if I have a netname (overloaded), give the child monster that name as a targetname
		pEntity->SetTargetname( GetNetName() );
	}

	m_cLiveChildren++;// count this monster
	m_cNumMonsters--;

	if ( m_cNumMonsters == 0 )
	{
		// Disable this forever.  Don't kill it because it still gets death notices
		SetThink( NULL );
		SetUse( NULL );
	}
}
Example #9
0
/*
==============================
SUB_UseTargets

If self.delay is set, a DelayedUse entity will be created that will actually
do the SUB_UseTargets after that many seconds have passed.

Removes all entities with a targetname that match self.killtarget,
and removes them, so some events can remove other triggers.

Search for (string)targetname in all entities that
match (string)self.target and call their .use function (if they have one)

==============================
*/
void CBaseDelay::SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value )
{
	//
	// exit immediatly if we don't have a target or kill target
	//
	if( !HasTarget() && !m_iszKillTarget )
		return;

	//
	// check for a delay
	//
	if( m_flDelay != 0 )
	{
		// create a temp object to fire at a later time
		auto pTemp = static_cast<CBaseDelay*>( UTIL_CreateNamedEntity( "DelayedUse" ) );

		pTemp->SetNextThink( gpGlobals->time + m_flDelay );

		pTemp->SetThink( &CBaseDelay::DelayThink );

		// Save the useType
		pTemp->GetButtons().Set( ( int ) useType );
		pTemp->m_iszKillTarget = m_iszKillTarget;
		pTemp->m_flDelay = 0; // prevent "recursion"
		pTemp->SetTarget( GetTarget() );

		// HACKHACK
		// This wasn't in the release build of Half-Life.  We should have moved m_hActivator into this class
		// but changing member variable hierarchy would break save/restore without some ugly code.
		// This code is not as ugly as that code
		if( pActivator && pActivator->IsPlayer() )		// If a player activates, then save it
		{
			pTemp->SetOwner( pActivator );
		}
		else
		{
			pTemp->SetOwner( NULL );
		}

		return;
	}

	//
	// kill the killtargets
	//

	if( m_iszKillTarget )
	{
		CBaseEntity* pKillTarget = nullptr;

		ALERT( at_aiconsole, "KillTarget: %s\n", STRING( m_iszKillTarget ) );
		while( ( pKillTarget = UTIL_FindEntityByTargetname( pKillTarget, STRING( m_iszKillTarget ) ) ) != nullptr )
		{
			UTIL_Remove( pKillTarget );

			ALERT( at_aiconsole, "killing %s\n", pKillTarget->GetClassname() );
		}
	}

	//
	// fire targets
	//
	if( HasTarget() )
	{
		FireTargets( GetTarget(), pActivator, this, useType, value );
	}
}