当前位置: 首页>>代码示例>>C++>>正文


C++ AvHPlayer类代码示例

本文整理汇总了C++中AvHPlayer的典型用法代码示例。如果您正苦于以下问题:C++ AvHPlayer类的具体用法?C++ AvHPlayer怎么用?C++ AvHPlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AvHPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sendMessage

// int thePlayerIndex, string string (in titles.txt), returns success
static int sendMessage(lua_State* inState)
{
    bool theSuccess = false;

    int theNumArgs = lua_gettop(inState);
    if(theNumArgs == 2)
    {
        int thePlayerIndex = lua_tonumber(inState, 1);
        
        const char* theCString = lua_tostring(inState, 2);
        if(theCString)
        {
            char theCharArray[kMaxStrLen];
            strcpy(theCharArray, theCString);

            CBaseEntity* theEntity = CBaseEntity::Instance(g_engfuncs.pfnPEntityOfEntIndex(thePlayerIndex));
            if(theEntity)
            {
                AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theEntity);
                if(thePlayer)
                {
                    thePlayer->SendMessage(theCString, TOOLTIP);
                    theSuccess = true;
                }
            }
        }
    }

    lua_pushnumber(inState, theSuccess);
    
    return 1;
}
开发者ID:tschumann,项目名称:naturalselection,代码行数:33,代码来源:AvHScriptServer.cpp

示例2: UpdateInventoryEnabledState

void AvHBasePlayerWeapon::UpdateInventoryEnabledState(int inNumActiveHives)
{
    // Process here
    int theEnabledState = 1;
                
    ItemInfo theItemInfo;
    if(this->GetItemInfo(&theItemInfo) != 0)
    {
        int theWeaponFlags = theItemInfo.iFlags;
        AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(this->m_pPlayer);
        ASSERT(thePlayer);
    
        // If we don't have the hives required, or we're ensnared
        if	(/*thePlayer->GetIsTemporarilyInvulnerable() ||*/
            !thePlayer->GetIsAbleToAct() || 
            ((inNumActiveHives < 1) && (theWeaponFlags & ONE_HIVE_REQUIRED)) ||
            ((inNumActiveHives < 2) && (theWeaponFlags & TWO_HIVES_REQUIRED)) ||
            ((inNumActiveHives < 3) && (theWeaponFlags & THREE_HIVES_REQUIRED)) ||
            (this->GetResourceCost() > thePlayer->GetResources(false)) )
        {
            // Disable it
            theEnabledState = 0;
        }
        else
        {
            int a = 0;
        }
    }
    
    // puzl: 497 save the state for when we send the CurWeapon message
    this->m_iEnabled =  theEnabledState;
}
开发者ID:Arkshine,项目名称:NS,代码行数:32,代码来源:AvHBasePlayerWeapon.cpp

示例3: AvHSUEyeToBodyXYDistance

bool AvHTurret::GetIsValidTarget(CBaseEntity* inEntity) const
{
    bool theTargetIsValid = false;
    
    if((inEntity->pev->team != this->pev->team) && (inEntity->pev->team != 0) && (inEntity->pev->takedamage))
    {
        float theDistanceToCurrentEnemy = AvHSUEyeToBodyXYDistance(this->pev, inEntity);
        if(theDistanceToCurrentEnemy <= this->GetXYRange())
        {
            // Players are targettable when 
            AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(inEntity);
            if(!thePlayer || !thePlayer->GetIsCloaked() || !thePlayer->GetIsBeingDigested()) //added digestion - elven
            {
                // TODO: Check to be sure enemy is still visible
                theTargetIsValid = true;
            }
            else
            {
                AvHCloakable* theCloakable = dynamic_cast<AvHCloakable*>(inEntity);
                if(!theCloakable || (theCloakable->GetOpacity() > 0.0f))
                {
                    theTargetIsValid = true;
                }
            }
        }
    }

    return theTargetIsValid;
}
开发者ID:Arkshine,项目名称:NS,代码行数:29,代码来源:AvHTurret.cpp

示例4: PROFILE_START

// This function takes a lot of CPU, so make sure it's not called often!  Don't call this function directly, use UpdateEnemy instead whenever possible.
CBaseEntity* AvHTurret::FindBestEnemy()
{
    PROFILE_START()
    CBaseEntity* theEntityList[100];
    
    int theMaxRange = this->GetXYRange();
    
    Vector delta = Vector(theMaxRange, theMaxRange, theMaxRange);
    CBaseEntity* theCurrentEntity = NULL;
    CBaseEntity* theBestPlayer = NULL;
    CBaseEntity* theBestStructure = NULL;

    float theCurrentEntityRange = 100000;
    
    // Find only monsters/clients in box, NOT limited to PVS
    int theCount = UTIL_EntitiesInBox(theEntityList, 100, this->pev->origin - delta, this->pev->origin + delta, FL_CLIENT | FL_MONSTER);
    for(int i = 0; i < theCount; i++ )
    {
        theCurrentEntity = theEntityList[i];
        if((theCurrentEntity != this) && theCurrentEntity->IsAlive())
        {
            // the looker will want to consider this entity
            // don't check anything else about an entity that can't be seen, or an entity that you don't care about.
            if(this->IRelationship(theCurrentEntity ) != R_NO && FInViewCone(theCurrentEntity) && !FBitSet(theCurrentEntity->pev->flags, FL_NOTARGET))
            {
                AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theCurrentEntity);
                if(!thePlayer || thePlayer->GetCanBeAffectedByEnemies())
                {
                    if(this->GetIsValidTarget(theCurrentEntity))
                    {
                        // Find nearest enemy
                        float theRangeToTarget = VectorDistance2D(this->pev->origin, theCurrentEntity->pev->origin);
                        if(theRangeToTarget < theCurrentEntityRange)
                        {
                            // FVisible is expensive, so defer until necessary
                            if(!this->GetRequiresLOS() || FVisible(theCurrentEntity))
                            {
                                theCurrentEntityRange = theRangeToTarget;
                                if ( thePlayer ) 
                                {
                                    theBestPlayer = theCurrentEntity;
                                }
                                else
                                {
                                    theBestStructure = theCurrentEntity;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    PROFILE_END(kAvHTurretFindBestEnemy);

    return (theBestPlayer != NULL ) ? theBestPlayer : theBestStructure;
}
开发者ID:Arkshine,项目名称:NS,代码行数:58,代码来源:AvHTurret.cpp

示例5: GetGameRules

void AvHBaseBuildable::Killed(entvars_t* pevAttacker, int iGib)
{
    bool theInReset = GetGameRules()->GetIsGameInReset();
    
    AvHBaseBuildable::SetHasBeenKilled();
    GetGameRules()->RemoveEntityUnderAttack( this->entindex() );

    this->mKilled = true;
    this->mInternalSetConstructionComplete = false;
    this->mTimeOfLastAutoHeal = -1;

    if (!theInReset)
    {
        // : 980
        // Less smoke for recycled buildings
        this->TriggerDeathAudioVisuals(iGib == GIB_RECYCLED);
        
        if(!this->GetIsOrganic())
        {
            // More sparks for recycled buildings
            int numSparks = ( iGib == GIB_RECYCLED ) ? 7 : 3;
            for ( int i=0; i < numSparks; i++ ) {
                Vector vecSrc = Vector( (float)RANDOM_FLOAT( pev->absmin.x, pev->absmax.x ), (float)RANDOM_FLOAT( pev->absmin.y, pev->absmax.y ), (float)0 );
                vecSrc = vecSrc + Vector( (float)0, (float)0, (float)RANDOM_FLOAT( pev->origin.z, pev->absmax.z ) );
                UTIL_Sparks(vecSrc);
            }
        }
        // :
    }
    this->TriggerRemoveTech();

    AvHSURemoveEntityFromHotgroupsAndSelection(this->entindex());

    if(pevAttacker)
    {
        const char* theClassName = STRING(this->pev->classname);
        AvHPlayer* inPlayer = dynamic_cast<AvHPlayer*>(CBaseEntity::Instance(ENT(pevAttacker)));
        if(inPlayer && theClassName)
        {
            inPlayer->LogPlayerAction("structure_destroyed", theClassName);
            GetGameRules()->RewardPlayerForKill(inPlayer, this);
        }
    }
    
    if(this->GetIsPersistent())
    {
        this->SetInactive();
    }
    else
    {
        CBaseAnimating::Killed(pevAttacker, iGib);
    }
}
开发者ID:Arkshine,项目名称:NS,代码行数:53,代码来源:AvHBaseBuildable.cpp

示例6: SetUse

void AvHMovementChamber::EnergyAliensThink()
{
    // Don't teleport until it's "warmed up"
    SetUse(&AvHMovementChamber::TeleportUse);

    // Loop through all players
    CBaseEntity* theBaseEntity = NULL;
    int theNumEntsProcessed = 0;
    
    while(((theBaseEntity = UTIL_FindEntityInSphere(theBaseEntity, this->pev->origin, BALANCE_VAR(kMovementChamberEnergyRange))) != NULL) && (theNumEntsProcessed < BALANCE_VAR(kAlienChamberMaxPlayers)))
    {
        if(theBaseEntity->pev->team == this->pev->team)
        {
            float theEnergizeAmount = BALANCE_VAR(kMovementChamberEnergyAmount);
            AvHBaseBuildable* theBuildable = dynamic_cast<AvHBaseBuildable*>(theBaseEntity);
            AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theBaseEntity);
            if(thePlayer && thePlayer->IsAlive())
            {
                if(thePlayer->Energize(theEnergizeAmount))
                {
                    theNumEntsProcessed++;
                }
            }
            // Energize alien buildables
//			else if(theBuildable)
//			{
//				if(theBuildable->Energize(theEnergizeAmount))
//				{
//					theNumEntsProcessed++;
//				}
//			}
        }
    }

    // Play an animation (spin the arms if energizing)
    int theIdle = this->GetIdle2Animation();

    // Play sound
    if(theNumEntsProcessed > 0)
    {
        EMIT_SOUND(this->edict(), CHAN_AUTO, kAlienEnergySound, 1.0f, ATTN_NORM);

        theIdle = this->GetIdle1Animation();
    }

    this->PlayAnimationAtIndex(theIdle);
    
    // Set next think
    this->pev->nextthink = gpGlobals->time + BALANCE_VAR(kMovementChamberThinkInterval);
}
开发者ID:Arkshine,项目名称:NS,代码行数:50,代码来源:AvHAlienEquipment.cpp

示例7: FireProjectiles

void AvHLeap::FireProjectiles(void)
{
#ifdef AVH_SERVER
    AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(this->m_pPlayer);
    if(thePlayer)
    {
        thePlayer->TriggerUncloak();
    }
#endif
#ifdef AVH_CLIENT
    if(g_runfuncs)
    {
        //IN_Attack2Down();
        //CBasePlayerWeapon::SendWeaponAnim(3);
        gHUD.SetAlienAbility(this->GetAbilityImpulse());
    }
#endif
}
开发者ID:Arkshine,项目名称:NS,代码行数:18,代码来源:AvHAlienAbilities.cpp

示例8: while

void AvHDefenseChamber::RegenAliensThink()
{
    // Loop through all players
    CBaseEntity* theBaseEntity = NULL;
    int theNumEntsHealed = 0;
    
    while(((theBaseEntity = UTIL_FindEntityInSphere(theBaseEntity, this->pev->origin, BALANCE_VAR(kDefensiveChamberHealRange))) != NULL) && (theNumEntsHealed < BALANCE_VAR(kAlienChamberMaxPlayers)))
    {
        if(theBaseEntity->pev->team == this->pev->team)
        {
            AvHBaseBuildable* theBuildable = dynamic_cast<AvHBaseBuildable*>(theBaseEntity);
            AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theBaseEntity);
            float thePercent=BALANCE_VAR(kDefensiveChamberRegenPercent)/100.0f;
            float amount=BALANCE_VAR(kDefensiveChamberRegenAmount) + (theBaseEntity->pev->max_health*thePercent);
            if(thePlayer && thePlayer->IsAlive())
            {
                if(thePlayer->Heal(amount, true, true))
                {
                    theNumEntsHealed++;
                }
            }
            else if(theBuildable && theBuildable->GetIsBuilt() && (theBuildable != this))
            {
                if(theBuildable->Regenerate(amount, true, true))
                {
                    theNumEntsHealed++;
                }
            }
        }
    }
    
    // Set next think
    this->pev->nextthink = gpGlobals->time + BALANCE_VAR(kDefenseChamberThinkInterval);
    
    // Play a random idle animation
    int theIdle = this->GetIdle1Animation();
    
    if(RANDOM_LONG(0, 1))
    {
        theIdle = this->GetIdle2Animation();
    }
    
    this->PlayAnimationAtIndex(theIdle);
}
开发者ID:Arkshine,项目名称:NS,代码行数:44,代码来源:AvHAlienEquipment.cpp

示例9: BALANCE_VAR

void AvHHive::ProcessHealing()
{
    // Regenerate nearby friendly aliens
    CBaseEntity* theEntity = NULL;
    const int theHiveHealRadius = BALANCE_VAR(kHiveHealRadius);

    while((theEntity = UTIL_FindEntityInSphere(theEntity, this->pev->origin, theHiveHealRadius)) != NULL)
    {
        AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theEntity);
        if(thePlayer)
        {
            if(thePlayer->GetIsRelevant() && (thePlayer->GetTeam() == this->GetTeamNumber()) && !thePlayer->GetIsBeingDigested())
            {
                // Hive heals percentage of player health
                float theRegenPercentage = BALANCE_VAR(kHiveRegenerationPercentage);
                int theMaxHealth = AvHPlayerUpgrade::GetMaxHealth(thePlayer->pev->iuser4, (AvHUser3)thePlayer->pev->iuser3, thePlayer->GetExperienceLevel());
                float theRegenAmount = (theRegenPercentage*theMaxHealth);
                thePlayer->Heal(theRegenAmount, true);
            }
        }
    }
    
    // Regenerate self
    bool theDidHeal = false;
    
    // If we aren't at full health, heal health
    if(this->pev->health < this->mMaxHitPoints)
    {
        float theHiveRegenAmount = BALANCE_VAR(kHiveRegenerationAmount);
        float theCombatModeScalar = /*GetGameRules()->GetIsCombatMode() ? (1.0f/BALANCE_VAR(kCombatModeTimeScalar)) :*/ 1.0f;

        this->pev->health = min((float)this->mMaxHitPoints, this->pev->health + theHiveRegenAmount*theCombatModeScalar);
        theDidHeal = true;
    }
    
    // Play regen event
    if(theDidHeal)
    {
        // Play regeneration event
        PLAYBACK_EVENT_FULL(0, this->edict(), gRegenerationEventID, 0, this->pev->origin, (float *)&g_vecZero, 1.0f, 0.0, /*theWeaponIndex*/ 0, 0, 0, 0 );
    }
}
开发者ID:Arkshine,项目名称:NS,代码行数:42,代码来源:AvHHive.cpp

示例10: BALANCE_IVAR

void AvHGamerules::AwardExperience(AvHPlayer* inPlayer, int inTargetLevel, bool inAwardFriendliesInRange)
{
    PlayerListType thePlayerList;
    thePlayerList.push_back(inPlayer);

    if(inAwardFriendliesInRange)
    {
        // Award experience to player, and any other players nearby
        int theExperienceRadius = BALANCE_IVAR(kCombatFriendlyNearbyRange);

        // Make list of players to split it between.  If a player is at full experience, extra is wasted.
        CBaseEntity* theEntity = NULL;
        while ((theEntity = UTIL_FindEntityInSphere(theEntity, inPlayer->pev->origin, theExperienceRadius)) != NULL)
        {
            const char* theClassName = STRING(theEntity->pev->classname);
            if(!AvHSUGetIsExternalClassName(theClassName))
            {
                AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theEntity);
                if(thePlayer && (thePlayer != inPlayer) && (thePlayer->pev->team == inPlayer->pev->team) && thePlayer->GetIsRelevant() && !thePlayer->GetIsBeingDigested())
                {
                    thePlayerList.push_back(thePlayer);
                }
            }
        }
    }
    
    ASSERT(thePlayerList.size() > 0);

    float theExperienceFactor = GetGameRules()->GetIsIronMan() ? BALANCE_FVAR(kCombatIronManExperienceScalar) : 1.0f;

    int theExperienceToAward = BALANCE_IVAR(kCombatExperienceBaseAward) + inTargetLevel*BALANCE_IVAR(kCombatExperienceLevelAward);

    float theExperienceForEach = (theExperienceToAward/(float)thePlayerList.size() + BALANCE_IVAR(kCombatExperienceCrowdAward))*theExperienceFactor;

    for(PlayerListType::iterator thePlayerIter = thePlayerList.begin(); thePlayerIter != thePlayerList.end(); thePlayerIter++)
    {
        AvHPlayer* theCurrentPlayer = (*thePlayerIter);
        theCurrentPlayer->SetExperience(theCurrentPlayer->GetExperience() + theExperienceForEach);
    }
}
开发者ID:Arkshine,项目名称:NS,代码行数:40,代码来源:AvHCombat.cpp

示例11: DonateUse

void AvHHive::DonateUse(CBaseEntity* inActivator, CBaseEntity* inCaller, USE_TYPE inUseType, float inValue)
{
    // Player is trying to donate his resources to the pool
    if(this->GetIsActive())
    {
        AvHPlayer* inActivatingPlayer = dynamic_cast<AvHPlayer*>(inActivator);
        if(inActivatingPlayer && (inActivator->pev->team == this->pev->team))
        {
            // Take some resources, give some resources
            const float kResourcesToDonatePerUse = .4f;
            float theResourcesToGive = min(inActivatingPlayer->GetResources(), kResourcesToDonatePerUse);
            
            if(theResourcesToGive > 0.0f)
            {
                AvHTeam* theTeam = inActivatingPlayer->GetTeamPointer();
                if(theTeam)
                {
                    inActivatingPlayer->SetResources(inActivatingPlayer->GetResources() - theResourcesToGive);
                    theTeam->SetTeamResources(theTeam->GetTeamResources() + theResourcesToGive);

                    if(g_engfuncs.pfnRandomLong(0, 20) == 0)
                    {
                        PLAYBACK_EVENT_FULL(0, this->edict(), gRegenerationEventID, 0, this->pev->origin, (float *)&g_vecZero, 1.0f, 0.0, /*theWeaponIndex*/ 0, 0, 0, 0 );

                        // Just say "resources donated"
                        inActivatingPlayer->PlaybackNumericalEvent(kNumericalInfoResourcesDonatedEvent, 0);
                    }
                }
            }
        }
    }
}
开发者ID:Arkshine,项目名称:NS,代码行数:32,代码来源:AvHHive.cpp

示例12: IRelationship

int BabblerProjectile::IRelationship(CBaseEntity* inTarget)
{
    int theRelationship = R_NO;

    // Don't attack cloaked players
    AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(inTarget);
    if(thePlayer && thePlayer->GetIsCloaked())
    {
        theRelationship = R_NO;
    }
    else
    {
        // Attack all monsters that aren't on our team
        CBaseMonster* theMonsterPointer = dynamic_cast<CBaseMonster*>(inTarget);
        if(theMonsterPointer && (theMonsterPointer->pev->team != this->pev->team))
        {
            theRelationship = R_DL;
        }
        else
        {
            // Look at own team vs. incoming team
            AvHTeamNumber inTeam = (AvHTeamNumber)inTarget->pev->team;
            if(inTeam != TEAM_IND)
            {
                if(inTeam == this->pev->team)
                {
                    theRelationship = R_AL;
                }
                else
                {
                    // Don't keep switching targets constantly
                    theRelationship = R_DL;
                }
            }
        }
    }
    
    return theRelationship;
}
开发者ID:Arkshine,项目名称:NS,代码行数:39,代码来源:AvHBabblerGun.cpp

示例13: DeductCostForShot

void AvHBasePlayerWeapon::DeductCostForShot(void)
{
    this->m_iClip--;

    // On a successful attack, decloak the player if needed
    #ifdef AVH_SERVER
    AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(this->m_pPlayer);
    if(thePlayer)
    {
        thePlayer->TriggerUncloak();
    }

    int theResourceCost = this->GetResourceCost();
    if(theResourceCost > 0)
    {
        float theNewResources = (thePlayer->GetResources(false) - theResourceCost);
        theNewResources = max(theNewResources, 0.0f);
        thePlayer->SetResources(theNewResources);
    }

    #endif
}
开发者ID:Arkshine,项目名称:NS,代码行数:22,代码来源:AvHBasePlayerWeapon.cpp

示例14: FireProjectiles

void AvHBlinkGun::FireProjectiles(void)
{
#ifdef AVH_CLIENT
    if(g_runfuncs)
    {
        gHUD.SetAlienAbility(this->GetAbilityImpulse());
    }
#endif
#ifdef AVH_SERVER
    AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(this->m_pPlayer);
    if(thePlayer)
    {
        thePlayer->TriggerUncloak();
    }
#endif
//	if(this->mTimeOfNextBlinkEvent <= 0)
//	{
//		const float kEventDelay = 2.0f;
//		this->PlaybackEvent(this->mBlinkSuccessEvent, this->GetShootAnimation());
//		this->mTimeOfNextBlinkEvent = UTIL_WeaponTimeBase() + kEventDelay;
//	}
}
开发者ID:Arkshine,项目名称:NS,代码行数:22,代码来源:AvHBlink.cpp

示例15: UTIL_MakeVectors

void AvHParalysisGun::FireProjectiles(void)
{
#ifdef AVH_SERVER
    
    UTIL_MakeVectors(this->m_pPlayer->pev->v_angle);
    
    Vector vecAiming = gpGlobals->v_forward;
    Vector vecSrc = this->m_pPlayer->GetGunPosition( ) + vecAiming;
    Vector vecEnd = vecSrc + vecAiming*kParalysisRange;
    
    const float kParalysisTime = 6;
    
    // Treat damage upgrade as modifier onto paralysis
    //int theTracerFreq;
    //float theDamageMultiplier;
    //AvHPlayerUpgrade::GetWeaponUpgrade(this->m_pPlayer->pev->iuser4, &theDamageMultiplier, &theTracerFreq);

    // Perform trace to hit victim
    TraceResult tr;
    UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, dont_ignore_glass, this->m_pPlayer->edict(), &tr);
    CBaseEntity* theEntityHit = CBaseEntity::Instance(tr.pHit);
    if(theEntityHit)
    {
        AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theEntityHit);
        if(thePlayer)
        {
            // Check teams (hit friendly in tourny mode)
            if((thePlayer->pev->team != this->m_pPlayer->pev->team) || (GetGameRules()->GetIsTournamentMode()))
            {
                thePlayer->SetIsParalyzed(true, kParalysisTime/**theDamageMultiplier*/);

                // Play hit event
                PLAYBACK_EVENT_FULL(0, thePlayer->edict(), gParalysisStartEventID, 0, thePlayer->pev->origin, (float *)&g_vecZero, 0.0, 0.0, /*theWeaponIndex*/ 0, 0, 0, 0);
            }
        }
    }

    #endif	
}
开发者ID:tschumann,项目名称:naturalselection,代码行数:39,代码来源:AvHParalysisGun.cpp


注:本文中的AvHPlayer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。