コード例 #1
0
ファイル: buttons.cpp プロジェクト: Chuvi-w/ReGameDLL_CS
void CMultiSource::Register()
{
	m_iTotal = 0;
	Q_memset(m_rgEntities, 0, MS_MAX_TARGETS * sizeof(EHANDLE));

	SetThink(&CMultiSource::SUB_DoNothing);

	// search for all entities which target this multisource (pev->targetname)
#ifdef REGAMEDLL_FIXES
	CBaseEntity *pTarget = nullptr;
	while (m_iTotal < MS_MAX_TARGETS && (pTarget = UTIL_FindEntityByString(pTarget, "target", STRING(pev->targetname)))) {
		m_rgEntities[m_iTotal++] = pTarget;
	}

	pTarget = nullptr;
	while (m_iTotal < MS_MAX_TARGETS && (pTarget = UTIL_FindEntityByClassname(pTarget, "multi_manager")))
	{
		if (pTarget->HasTarget(pev->targetname)) {
			m_rgEntities[m_iTotal++] = pTarget;
		}
	}
#else
	edict_t *pentTarget = FIND_ENTITY_BY_STRING(NULL, "target", STRING(pev->targetname));

	while (!FNullEnt(pentTarget) && m_iTotal < MS_MAX_TARGETS)
	{
		CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget);

		if (pTarget != NULL)
		{
			m_rgEntities[m_iTotal++] = pTarget;
		}

		pentTarget = FIND_ENTITY_BY_STRING(pentTarget, "target", STRING(pev->targetname));
	}

	pentTarget = FIND_ENTITY_BY_STRING(NULL, "classname", "multi_manager");

	while (!FNullEnt(pentTarget) && m_iTotal < MS_MAX_TARGETS)
	{
		CBaseEntity *pTarget = CBaseEntity::Instance(pentTarget);
		if (pTarget != NULL && pTarget->HasTarget(pev->targetname))
		{
			m_rgEntities[m_iTotal++] = pTarget;
		}

		pentTarget = FIND_ENTITY_BY_STRING(pentTarget, "classname", "multi_manager");
	}
#endif
	pev->spawnflags &= ~SF_MULTI_INIT;
}
コード例 #2
0
void CTriggerChangeTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	CBaseEntity *pTarget = UTIL_FindEntityByString( NULL, "targetname", GetTarget() );

	if( pTarget )
	{
		pTarget->SetTarget( m_iszNewTarget );
		CBaseMonster *pMonster = pTarget->MyMonsterPointer();
		if( pMonster )
		{
			pMonster->m_hGoalEnt = NULL;
		}
	}
}
コード例 #3
0
ファイル: utils.cpp プロジェクト: reuben/amxmodx
/**
 * Scans through all hives and finds the one currently building
 */
int UTIL_FindBuildingHive(void)
{
	edict_t			*Entity=NULL;

	while ((Entity = UTIL_FindEntityByString(Entity,"classname","team_hive")))
	{
		//    is alive                   active                  not fully built
		if (Entity->v.health > 0 && Entity->v.solid > 0 && Entity->v.fuser1 < 1000)
		{
			return ENTINDEX_NEW(Entity);
		}
	}
	return 0;
}
コード例 #4
0
ファイル: islave.cpp プロジェクト: Sh1ft0x0EF/HLSDKRevamp
void CISlave::CallForHelp(char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation)
{
	// ALERT( at_aiconsole, "help " );

	// skip ones not on my netname
	if(FStringNull(pev->netname))
		return;

	CBaseEntity *pEntity = NULL;

	while((pEntity = UTIL_FindEntityByString(pEntity, "netname", STRING(pev->netname))) != NULL)
	{
		float d = (pev->origin - pEntity->pev->origin).Length();
		if(d < flDist)
		{
			CBaseMonster *pMonster = pEntity->MyMonsterPointer();
			if(pMonster)
			{
				pMonster->m_afMemory |= bits_MEMORY_PROVOKED;
				pMonster->PushEnemy(hEnemy, vecLocation);
			}
		}
	}
}
コード例 #5
0
ファイル: squadmonster.cpp プロジェクト: jlecorre/hlinvasion
//=========================================================
//
// SquadRecruit(), get some monsters of my classification and
// link them as a group.  returns the group size
//
//=========================================================
int CSquadMonster :: SquadRecruit( int searchRadius, int maxMembers )
{
    int squadCount;
    int iMyClass = Classify();// cache this monster's class


    // Don't recruit if I'm already in a group
    if ( InSquad() )
        return 0;

    if ( maxMembers < 2 )
        return 0;

    // I am my own leader
    m_hSquadLeader = this;
    squadCount = 1;

    CBaseEntity *pEntity = NULL;

    if ( !FStringNull( pev->netname ) )
    {
        // I have a netname, so unconditionally recruit everyone else with that name.
        pEntity = UTIL_FindEntityByString( pEntity, "netname", STRING( pev->netname ) );
        while ( pEntity )
        {
            CSquadMonster *pRecruit = pEntity->MySquadMonsterPointer();

            if ( pRecruit )
            {
                if ( !pRecruit->InSquad() && pRecruit->Classify() == iMyClass && pRecruit != this )
                {
                    // minimum protection here against user error.in worldcraft.
                    if (!SquadAdd( pRecruit ))
                        break;
                    squadCount++;
                }
            }

            pEntity = UTIL_FindEntityByString( pEntity, "netname", STRING( pev->netname ) );
        }
    }
    else
    {
        while ((pEntity = UTIL_FindEntityInSphere( pEntity, pev->origin, searchRadius )) != NULL)
        {
            CSquadMonster *pRecruit = pEntity->MySquadMonsterPointer( );

            if ( pRecruit && pRecruit != this && pRecruit->IsAlive() && !pRecruit->m_pCine )
            {
                // Can we recruit this guy?
                if ( !pRecruit->InSquad() && pRecruit->Classify() == iMyClass &&
                        ( (iMyClass != CLASS_ALIEN_MONSTER) || FStrEq(STRING(pev->classname), STRING(pRecruit->pev->classname))) &&
                        FStringNull( pRecruit->pev->netname ) )
                {
                    TraceResult tr;
                    UTIL_TraceLine( pev->origin + pev->view_ofs, pRecruit->pev->origin + pev->view_ofs, ignore_monsters, pRecruit->edict(), &tr );// try to hit recruit with a traceline.
                    if ( tr.flFraction == 1.0 )
                    {
                        if (!SquadAdd( pRecruit ))
                            break;

                        squadCount++;
                    }
                }
            }
        }
    }

    // no single member squads
    if (squadCount == 1)
    {
        m_hSquadLeader = NULL;
    }

    return squadCount;
}
コード例 #6
0
ファイル: util.cpp プロジェクト: CryoKeen/HLEnhanced
CBaseEntity *UTIL_FindEntityByTargetname( CBaseEntity *pStartEntity, const char *szName )
{
	return UTIL_FindEntityByString( pStartEntity, "targetname", szName );
}
コード例 #7
0
ファイル: util.cpp プロジェクト: CryoKeen/HLEnhanced
CBaseEntity *UTIL_FindEntityByClassname( CBaseEntity *pStartEntity, const char *szName )
{
	return UTIL_FindEntityByString( pStartEntity, "classname", szName );
}
コード例 #8
0
ファイル: util.cpp プロジェクト: APGRoboCop/RicoBot
edict_t *UTIL_FindEntityByTargetname( edict_t *pentStart, const char *szName )
{
   return UTIL_FindEntityByString( pentStart, "targetname", szName );
}
コード例 #9
0
ファイル: util.cpp プロジェクト: APGRoboCop/RicoBot
edict_t *UTIL_FindEntityByClassname( edict_t *pentStart, const char *szName )
{
   return UTIL_FindEntityByString( pentStart, "classname", szName );
}
コード例 #10
0
ファイル: weapons.cpp プロジェクト: reuben/amxmodx
// ns_find_weapon_offset(idPlayer,"primweapon","lastinvweapon")
static cell AMX_NATIVE_CALL ns_find_weapon_offset(AMX *amx, cell *params)
{
	char *SPrimWeapon=MF_GetAmxString(amx,params[2],0,NULL);
	char *SLastInv=MF_GetAmxString(amx,params[3],1,NULL);
	edict_t *ePlayer=INDEXENT_NEW(params[1]);

	// Locate entities by name
	edict_t *PrimWeapon=NULL;
	edict_t *LastInv=NULL;

	edict_t *Temp=NULL;

	while ((Temp=UTIL_FindEntityByString(Temp,"classname",SPrimWeapon))!=NULL)
	{
		if (Temp->v.owner==ePlayer)
		{
			PrimWeapon=Temp;
			break;
		}
	}
	Temp=NULL;
	while ((Temp=UTIL_FindEntityByString(Temp,"classname",SLastInv))!=NULL)
	{
		if (Temp->v.owner==ePlayer)
		{
			LastInv=Temp;
			break;
		}
	}

	if (LastInv == NULL || PrimWeapon == NULL)
	{
		if (LastInv==NULL)
		{
			MF_Log("LastInv==NULL");
		}
		if (PrimWeapon==NULL)
		{
			MF_Log("PrimWeapon=NULL");
		}
		return 0;
	}

	// now iterate through the client's private data until we find the pointer to PrimWeapon/LastInv's offset
	unsigned int *Ptr=(unsigned int*)ePlayer->pvPrivateData;

	int FoundLastInv=0;
	int FoundPrim=0;
	size_t count=0;
	unsigned int iPrim;
	unsigned int iLast;

	// so nasty D: this is basically horrible_cast
	union bleh
	{
		void *ptr;
		unsigned int ival;
	}blah;
	
	blah.ptr=PrimWeapon->pvPrivateData;
	iPrim=blah.ival;

	blah.ptr=LastInv->pvPrivateData;
	iLast=blah.ival;

	while (count<4000)
	{
		if (*Ptr==iLast)
		{
			MF_Log("Found LastInv: %d",count);
			FoundLastInv=1;
		}
		if (*Ptr==iPrim)
		{
			MF_Log("Found Primary: %d",count);
			FoundPrim=1;
		}

		if (FoundLastInv && FoundPrim)
		{
			//break;
		}
		count+=4;
		Ptr++;
	}
	return 1;
}