Exemplo n.º 1
0
void AvHBaseBuildable::StartRecycle()
{
	if(!GetHasUpgrade(this->pev->iuser4, MASK_RECYCLING))
	{
        int theRecycleTime = (GetGameRules()->GetCheatsEnabled() && !GetGameRules()->GetIsCheatEnabled(kcSlowResearch)) ? 2 : BALANCE_VAR(kRecycleTime);

        // Play recycle animation in reverse (would like to play them slower according to recycle time, but it doesn't work for all structures, seems dependent on # of keyframes)
        int theAnimation = this->GetRecycleAnimation();
        float theTimeForAnim = this->GetTimeForAnimation(theAnimation);
        float theFrameRate = -1;//-theTimeForAnim/theRecycleTime;
        this->PlayAnimationAtIndex(theAnimation, true, theFrameRate);
		
		// Schedule time to give points back
		SetThink(&AvHBaseBuildable::RecycleComplete);

		this->mTimeRecycleStarted = gpGlobals->time;
		
		this->mTimeRecycleDone = gpGlobals->time + theRecycleTime;
		
		this->pev->nextthink = this->mTimeRecycleDone;

		float theVolume = .5f;
		EMIT_SOUND(this->edict(), CHAN_AUTO, kBuildableRecycleSound, theVolume, ATTN_NORM);

        SetUpgradeMask(&this->pev->iuser4, MASK_RECYCLING);

		// run any events for this class on recycling the structure
		this->UpdateOnRecycle();

        // Remove tech immediately, so research or building isn't started using this tech
        this->TriggerRemoveTech();
	}
}
Exemplo n.º 2
0
void AvHBaseBuildable::RecycleComplete()
{
	// Look at whether it has been built and health to determine how many points to give back
	float thePercentage = BALANCE_VAR(kRecycleResourcePercentage);

	if(!this->GetIsBuilt())
	{
		thePercentage = .8f;
	}

	// Make sure the building is still alive, can't get points back if it's dead
	if(this->pev->health <= 0)
	{
		thePercentage = 0.0f;
	}

	// Look up team
	AvHTeam* theTeam = GetGameRules()->GetTeam((AvHTeamNumber)this->pev->team);
	if(theTeam)
	{
		bool theIsEnergyTech = AvHSHUGetDoesTechCostEnergy(this->mMessageID);
		ASSERT(!theIsEnergyTech);

		float thePointsBack = GetGameRules()->GetCostForMessageID(this->mMessageID)*thePercentage;
		theTeam->SetTeamResources(theTeam->GetTeamResources() + thePointsBack);

        // Play "+ resources" event
        AvHSUPlayNumericEventAboveStructure(thePointsBack, this);

		// puzl: 980
		// Less smoke and more sparks  for recycled buildings
		this->Killed(this->pev, GIB_RECYCLED);
		// :puzl
	}
}
Exemplo n.º 3
0
void AvHHive::SetHasBeenBuilt()
{
	AvHBuildable::SetHasBeenBuilt();

	GetGameRules()->TriggerAlert((AvHTeamNumber)this->pev->team, ALERT_HIVE_COMPLETE, this->entindex());

	// Make hive support any unassigned upgrade technologies (happens after a hive supporting a technology is destroyed and then rebuilt)
	AvHTeamNumber theTeam = (AvHTeamNumber)this->pev->team;
	AvHTeam* theTeamPointer = GetGameRules()->GetTeam(theTeam);
	if(theTeamPointer)
	{
		AvHAlienUpgradeListType theUpgrades = theTeamPointer->GetAlienUpgrades();

		if(AvHGetNumUpgradesInCategoryInList(theUpgrades, ALIEN_UPGRADE_CATEGORY_DEFENSE) > 0)
		{
			AvHSUUpdateHiveTechology(theTeam, ALIEN_BUILD_DEFENSE_CHAMBER);
		}

		if(AvHGetNumUpgradesInCategoryInList(theUpgrades, ALIEN_UPGRADE_CATEGORY_MOVEMENT) > 0)
		{
			AvHSUUpdateHiveTechology(theTeam, ALIEN_BUILD_MOVEMENT_CHAMBER);
		}

		if(AvHGetNumUpgradesInCategoryInList(theUpgrades, ALIEN_UPGRADE_CATEGORY_SENSORY) > 0)
		{
			AvHSUUpdateHiveTechology(theTeam, ALIEN_BUILD_SENSORY_CHAMBER);
		}
	}
}
Exemplo n.º 4
0
void AvHBaseBuildable::BuildableTouch(CBaseEntity* inEntity)
{
    if(inEntity->pev->team != this->pev->team)
    {
        this->Uncloak();

		// GHOSTBUILDING: Destroy and return res.
		if (this->mGhost && inEntity->IsAlive() && inEntity->IsPlayer())
		{
			this->TakeDamage(inEntity->pev, this->pev, 80000, DMG_GENERIC);

			AvHTeam* theTeam = GetGameRules()->GetTeam(AvHTeamNumber(this->pev->team));

			if (theTeam)
			{
				float thePercentage = .8f;
				float thePointsBack = GetGameRules()->GetCostForMessageID(this->mMessageID) * thePercentage;
				theTeam->SetTeamResources(theTeam->GetTeamResources() + thePointsBack);

				AvHSUPlayNumericEventAboveStructure(thePointsBack, this);
			}

			// Uncloak the player
			AvHCloakable *theCloakable=dynamic_cast<AvHCloakable *>(inEntity);
			if ( theCloakable ) {
				theCloakable->Uncloak();
			}
		}
    }
}
Exemplo n.º 5
0
void AvHHive::HiveAliveThink(void)
{
	// For some reason, velocity is non-zero when created (meant they were showing up on motion-tracking)
	this->pev->velocity = Vector(0, 0, 0);

	if(GetGameRules()->GetGameStarted())
	{
        if(!this->mActive)
        {
		    bool theIsBuilding, theIsResearching;
		    float thePercentage;
		    AvHSHUGetBuildResearchState(this->pev->iuser3, this->pev->iuser4, this->pev->fuser1, theIsBuilding, theIsResearching, thePercentage);
		    
		    float theBuildTime = GetGameRules()->GetBuildTimeForMessageID(this->GetMessageID());
		    float theBuildPercentage = kHiveAliveThinkInterval/theBuildTime;
		    
		    float theNewPercentage = min(thePercentage + theBuildPercentage, 1.0f);
            this->SetNormalizedBuildPercentage(theNewPercentage);
        }
        else
		{
			this->ProcessHealing();

            // Play idle anims
            AvHBaseBuildable::AnimateThink();
		}

		this->UpdateReinforcements();

		//this->UpdateUmbra();
	}
	
	// Set next think
	this->pev->nextthink = gpGlobals->time + kHiveAliveThinkInterval;
}
Exemplo n.º 6
0
void AvHTechTree::processBalanceChange(void)
{
	// Run through our tech nodes and update cost and build time
	TechNodeMap::iterator current, end = mNodesByMsg.end();
	for( current = mNodesByMsg.begin(); current != end; ++current )
	{
		current->second->setBuildTime(GetGameRules()->GetBuildTimeForMessageID(current->first));
		current->second->setCost(GetGameRules()->GetCostForMessageID(current->first));
	}
}
Exemplo n.º 7
0
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);
	}
}
Exemplo n.º 8
0
void AvHBaseBuildable::UpdateDamageEffects()
{
	if(GetGameRules()->GetGameStarted() && this->GetIsBuilt())
	{
		// Add special effects for structures that are hurt or almost dead
		float theMaxHealth = GetGameRules()->GetBaseHealthForMessageID(this->GetMessageID());
		float theHealthScalar = this->pev->health/theMaxHealth;
		float theTimeInterval = max(gpGlobals->time - this->mTimeOfLastDamageUpdate, .1f);

		const float kParticleSystemLifetime = 5.0f;
		int theAverageSoundInterval = -1;
		
		// If we're at 25% health or less, emit black smoke
		if(gpGlobals->time > (this->mTimeOfLastDamageEffect + kParticleSystemLifetime))
		{
			if(theHealthScalar < .25f)
			{
				AvHSUPlayParticleEvent(kpsBuildableLightDamage, this->edict(), this->pev->origin);
				this->mTimeOfLastDamageEffect = gpGlobals->time;
				theAverageSoundInterval = 3;
			}
			// If we're at 50% health or less, emit light smoke
			else if(theHealthScalar < .5f)
			{
				AvHSUPlayParticleEvent(kpsBuildableLightDamage, this->edict(), this->pev->origin);
				this->mTimeOfLastDamageEffect = gpGlobals->time;
				theAverageSoundInterval = 5;
			}
		}
		
		// If we're at less then 75% health, spark occasionally
		if(theHealthScalar < .75f)
		{
			int theRandomChance = RANDOM_LONG(0, (float)8/theTimeInterval);
			if(theRandomChance == 0)
			{
				UTIL_Sparks(this->pev->origin);
				UTIL_Sparks(this->pev->origin);

				const char* theHurtSoundToPlay = kBuildableHurt1Sound;
				if(RANDOM_LONG(0, 1) == 1)
				{
					theHurtSoundToPlay = kBuildableHurt2Sound;
				}
				
				float theVolume = .3f;
				EMIT_SOUND(this->edict(), CHAN_AUTO, theHurtSoundToPlay, theVolume, ATTN_NORM);
			}
		}
		
		this->mTimeOfLastDamageUpdate = gpGlobals->time;
	}
}
// takes filename, returns whether errors were encountered, returns whether checksums are identical or not
static int compareWorldChecksum(lua_State* inState)
{
	bool theSuccess = false;
	bool theChecksumsAreEqual = false;
	
	const char* theFileName = lua_tostring(inState, 1);
	Checksum theOldChecksum;
	theSuccess = theOldChecksum.ReadFromFile(theFileName);

	Checksum theNewChecksum;
	GetGameRules()->ComputeWorldChecksum(theNewChecksum);
	if(theSuccess)
	{
		StringList theErrors;
		theChecksumsAreEqual = theNewChecksum.Compare(theOldChecksum, theErrors);
	}
	
	// Return function success
	lua_pushnumber(inState, theSuccess);

	// Return checksums are equal
	lua_pushnumber(inState, theChecksumsAreEqual);
	
	return 2;
}
Exemplo n.º 10
0
void AvHUmbraProjectile::Spawn(void)
{
	this->Precache();

	CBaseEntity::Spawn();
	
	this->pev->movetype = MOVETYPE_FLY;
	this->pev->classname = MAKE_STRING(kwsUmbraProjectile);
	
	SET_MODEL(ENT(this->pev), kClientUmbraSprite);
	this->pev->solid = SOLID_BBOX;
	
	if(!GetGameRules()->GetDrawInvisibleEntities())
	{
		this->pev->effects = EF_NODRAW;
	}
	else
	{
		this->pev->frame = 0;
		this->pev->scale = 0.5;
		this->pev->rendermode = kRenderTransAlpha;
		this->pev->renderamt = 255;
	}
	
	UTIL_SetSize(this->pev, Vector( 0, 0, 0), Vector(0, 0, 0));

	SetTouch(&AvHUmbraProjectile::UmbraTouch);
}
Exemplo n.º 11
0
void AvHHive::UpdateUmbra()
{
	bool theIsUnderAttack = GetGameRules()->GetIsEntityUnderAttack(this->entindex());
	if(theIsUnderAttack)
	{
		if(this->mTimeOfNextUmbra == -1)
		{
			this->mTimeOfNextUmbra = gpGlobals->time + RANDOM_LONG(5, 15);
		}
	}

	if((this->mTimeOfNextUmbra != -1) && (gpGlobals->time > this->mTimeOfNextUmbra))
	{
		// If we're under attack, sometimes create umbra at hive
		vec3_t theUmbraOrigin = this->pev->origin;
		
		// else create umbra at random spawn
//		if(!theIsUnderAttack)
//		{
//			CBaseEntity* theSpawnPoint = GetGameRules()->GetRandomHiveSpawnPoint(this, this->pev->origin, this->GetMaxSpawnDistance());
//			if(theSpawnPoint)
//			{
//				VectorCopy(theSpawnPoint->pev->origin, theUmbraOrigin);
//			}
//		}

		// Create umbra around it, play "scared" anim
		//this->CreateUmbra(theUmbraOrigin);

		this->PlayAnimationAtIndex(kScaredAnimationIndex, true);
	}
}
Exemplo n.º 12
0
void AvHHive::Spawn()
{
	this->Precache();
	
	AvHBaseBuildable::Spawn();
    
	this->pev->classname = MAKE_STRING(kesTeamHive);
	//this->pev->movetype	= MOVETYPE_FLY;

	this->pev->movetype	= MOVETYPE_FLY;
	this->pev->solid = SOLID_NOT;
	this->pev->flags = 0;
	this->pev->iuser3 = AVH_USER3_HIVE;

	this->mMaxHitPoints = GetGameRules()->GetBaseHealthForMessageID(ALIEN_BUILD_HIVE);
	
	SET_MODEL( ENT(this->pev), kHiveModel);
	//this->pev->scale = 2;

//	this->pev->sequence = 0;
//	this->pev->frame = 0;
//	ResetSequenceInfo();

	this->ResetEntity();

}
Exemplo n.º 13
0
void AvHResearchManager::UpdateResearch()
{
	// Run through every item in the list and update research, marking any done 
	for(ResearchListType::iterator theIter = this->mResearchingTech.begin(); theIter != this->mResearchingTech.end(); )
	{
		if(theIter->GetCanEntityContinueResearch())
		{
			bool theHighTechCheat = GetGameRules()->GetIsCheatEnabled(kcHighTech);
			if(theIter->UpdateResearch() || theHighTechCheat)
			{
				AvHMessageID theResearchingTech = theIter->GetResearching();
				int theEntityIndex = theIter->GetEntityIndex();

				this->SetResearchDone(theResearchingTech, theEntityIndex);

				theIter = this->mResearchingTech.erase(theIter);
			}
			else
			{
				theIter++;
			}
		}
		else
		{
			theIter = this->mResearchingTech.erase(theIter);
		}
	}
}
Exemplo n.º 14
0
void HolidayManager::HookIfNecessary()
{
	// Already hooked
	if (m_iHookID)
		return;

	// Nothing wants us
	if (m_isHolidayForward->GetFunctionCount() == 0)
		return;

	void *pGameRules = GetGameRules();
	if (!pGameRules)
	{
		if (m_bInMap)
		{
			g_pSM->LogError(myself, "Gamerules ptr not found. TF2_OnIsHolidayActive will not be available.");
		}
		return;
	}

	static int offset = -1;
	if (offset == -1)
	{
		if (!g_pGameConf->GetOffset("IsHolidayActive", &offset))
		{
			g_pSM->LogError(myself, "IsHolidayActive gamedata offset missing. TF2_OnIsHolidayActive will not be available.");
			return;
		}

		SH_MANUALHOOK_RECONFIGURE(IsHolidayActive, offset, 0, 0);
	}

	m_iHookID = SH_ADD_MANUALHOOK(IsHolidayActive, pGameRules, SH_MEMBER(this, &HolidayManager::Hook_IsHolidayActive), false);
}
Exemplo n.º 15
0
void AvHSpike::Spawn()
{
	this->Precache();
	CBaseEntity::Spawn();
	
	this->pev->movetype = MOVETYPE_FLY;
	this->pev->classname = MAKE_STRING(kSpikeProjectileClassName);
	
	SET_MODEL(ENT(this->pev), kSpikeProjectileModel);
	this->pev->solid = SOLID_BBOX;
	this->mDamage = 0.0f;
	
	// Comment out effects line, uncomment next four, then comment out creation of temp entity in EV_SpikeGun to see server side Spike for testing
	if(!GetGameRules()->GetDrawInvisibleEntities())
	{
		this->pev->effects = EF_NODRAW;
	}
	else
	{
		this->pev->frame = 0;
		this->pev->scale = 0.5;
		this->pev->rendermode = kRenderTransAlpha;
		this->pev->renderamt = 255;
	}
	
	//UTIL_SetSize(this->pev, Vector( 0, 0, 0), Vector(0, 0, 0));
//	UTIL_SetSize(this->pev, Vector( -16, -16, -16), Vector(16, 16, 16));
	//UTIL_SetSize(this->pev, Vector( -50, -50, -50), Vector(50, 50, 50));
	
	SetTouch(&AvHSpike::SpikeTouch);
	
	// Enforce short range
	SetThink(&AvHSpike::SpikeDeath);
	this->pev->nextthink = gpGlobals->time + kSpikeLifetime;
}
Exemplo n.º 16
0
int	AvHHive::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{
	const float kWoundSoundInterval = 1.0f;

	int theReturnCode = 0;
	
	if(this->mActive || this->mSpawning)
	{
		//CBaseEntity* theAttackingEntity = CBaseEntity::Instance(pevAttacker);
		//if(GetGameRules()->CanEntityDoDamageTo(theAttackingEntity, this))
		//{
			theReturnCode = AvHBaseBuildable::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType);

			if(theReturnCode > 0)
			{	
				const float kDyingThreshold = .4f;
				if(this->pev->health < kDyingThreshold*this->mMaxHitPoints)
				{
					GetGameRules()->TriggerAlert((AvHTeamNumber)this->pev->team, ALERT_HIVE_DYING, this->entindex());
				}
				else
				{
					if ( pevAttacker->team != this->pev->team ) 
						GetGameRules()->TriggerAlert((AvHTeamNumber)this->pev->team, ALERT_UNDER_ATTACK, this->entindex());
				}

				if((this->mTimeLastWoundSound == -1) || ((this->mTimeLastWoundSound + kWoundSoundInterval) < gpGlobals->time))
				{
					// Pick a random wound sound to play
					//int theIndex = RANDOM_LONG(0, kNumWoundSounds - 1);
					//char* theSoundToPlay = kWoundSoundList[theIndex];
					//EMIT_SOUND(ENT(this->pev), CHAN_AUTO, kHiveDeathSound, 1.0, ATTN_IDLE);	
					
					//EMIT_SOUND(ENT(this->pev), CHAN_AUTO, "misc/hive_wound1.wav", 1.0, ATTN_IDLE);	
					
					// Emit hive damaged sound
					gSoundListManager.PlaySoundInList(kHiveWoundSoundList, this, CHAN_BODY);
					
					this->mTimeLastWoundSound = gpGlobals->time;
				}
			}
		//}
	}
	
	return theReturnCode;
}
Exemplo n.º 17
0
AvHBaseBuildable::AvHBaseBuildable(AvHTechID inTechID, AvHMessageID inMessageID, char* inClassName, int inUser3) : AvHBuildable(inTechID), kStartAlpha(128), mAverageUseSoundLength(.5f)
{
	this->mClassName = inClassName;
	this->mMessageID = inMessageID;

	this->mBaseHealth = GetGameRules()->GetBaseHealthForMessageID(inMessageID);

	char* theModelName = AvHSHUGetBuildTechModelName(inMessageID);
	ASSERT(theModelName);
	this->mModelName = theModelName;

	this->mSelectID = inUser3;
	this->mTimeToConstruct = GetGameRules()->GetBuildTimeForMessageID(inMessageID);

	// Very important that this doesn't go in Init(), else mapper-placed structures disappear on map-reset
	this->mPersistent = false;

	this->Init();
}
Exemplo n.º 18
0
void AvHBuildable::TriggerAddTech() const
{
	AvHTeamNumber theTeamNumber = this->GetTeamNumber();
	AvHTeam* theTeam = GetGameRules()->GetTeam(theTeamNumber);
	
	if(theTeam)
	{
		theTeam->TriggerAddTech(this->mTechID);
	}
}
Exemplo n.º 19
0
// Requires mSelectID and mMessageID to be set
// Sets the pev user variables, mBaseHealth, pev->health and pev->armorvalue
void AvHBaseBuildable::InternalInitializeBuildable()
{
	// Always buildable
	InitializeBuildable(this->pev->iuser3, this->pev->iuser4, this->pev->fuser1, this->mSelectID);
	this->mBaseHealth = GetGameRules()->GetBaseHealthForMessageID(this->mMessageID);
	this->pev->health = this->mBaseHealth*kBaseHealthPercentage;
	this->pev->max_health = this->mBaseHealth;

	// Store max health in armorvalue
	//this->pev->armorvalue = GetGameRules()->GetBaseHealthForMessageID(this->mMessageID);
}
Exemplo n.º 20
0
int	AvHPlayer::GetExperienceLevel() const
{
	int theLevel = 1;
	
	if(GetGameRules()->GetIsCombatMode())
	{
		theLevel = AvHPlayerUpgrade::GetPlayerLevel(this->GetExperience());
	}
	
	return theLevel;
}
Exemplo n.º 21
0
void AvHPlayer::SetExperience(float inExperience)
{
	if(GetGameRules()->GetIsCombatMode())
	{
		int theCurrentLevel = AvHPlayerUpgrade::GetPlayerLevel(this->GetExperience());
		
		this->mExperience = inExperience;

		// Update server player data in case we get disconnected
		AvHTeam* theTeam = this->GetTeamPointer();
		if(theTeam)
		{
			AvHServerPlayerData* theServerPlayerData = this->GetServerPlayerData();
			if(theServerPlayerData)
			{
				theServerPlayerData->SetExperience(this->mExperience);
			}
		}
		
		int theNewLevel = AvHPlayerUpgrade::GetPlayerLevel(this->GetExperience());
		
		if(theCurrentLevel != theNewLevel)
		{
			int theIsMarine = this->GetIsMarine();
			PLAYBACK_EVENT_FULL(0, this->edict(), gLevelUpEventID, 0, this->pev->origin, (float *)&g_vecZero, 0.0, 0.0, theIsMarine, 0, 0, 0 );
			
			// Give player health and armor back on level-up, to allow more soloing, heroics, and reduce dependence on hives/resupply
			AvHUser3 theUser3 = AvHUser3(this->pev->iuser3);
            float theMaxHealth = AvHPlayerUpgrade::GetMaxHealth(this->pev->iuser4, theUser3, theCurrentLevel);
			float theHealthPercentage = this->pev->health/theMaxHealth;
			
            float theLevelUpHealthPercentage = BALANCE_IVAR(kCombatLevelupHealthIncreasePercent)/100.0f;
            theHealthPercentage = min(theHealthPercentage + theLevelUpHealthPercentage, 1.0f);
			this->pev->health = theHealthPercentage*theMaxHealth;

            float theMaxArmor = AvHPlayerUpgrade::GetMaxArmorLevel(this->pev->iuser4, theUser3);
            float theArmorPercentage = this->pev->armorvalue/theMaxArmor;

            float theLevelUpArmorPercentage = BALANCE_IVAR(kCombatLevelupArmorIncreasePercent)/100.0f;
            theArmorPercentage = min(theArmorPercentage + theLevelUpArmorPercentage, 1.0f);
			this->pev->armorvalue = theArmorPercentage*theMaxArmor;
			
			// Unlock tiers as player levels up
	//		if(theNewLevel >= 4)
	//		{
	//			this->mCombatNodes.SetResearchDone(COMBAT_TIER2_UNLOCK);
	//		}
	//		if(theNewLevel >= 7)
	//		{
	//			this->mCombatNodes.SetResearchDone(COMBAT_TIER3_UNLOCK);
	//		}
		}
	}
}
Exemplo n.º 22
0
void AvHBuildable::TriggerRemoveTech() const
{
	AvHTeamNumber theTeamNumber = this->GetTeamNumber();
	AvHTeam* theTeam = GetGameRules()->GetTeam(theTeamNumber);
	
	if(theTeam)
	{
		theTeam->TriggerRemoveTech(this->mTechID);
		if ( this->mTechID == TECH_ADVANCED_ARMORY )
			theTeam->TriggerRemoveTech(TECH_ARMORY);
	}
}
Exemplo n.º 23
0
bool AvHResearchNode::UpdateResearch()
{
	bool theResearchDone = false;
	
	AvHMessageID theResearchingTech = this->GetResearching();
	if(theResearchingTech != MESSAGE_NULL)
	{
		CBaseEntity* theResearchEntity = AvHSUGetEntityFromIndex(this->mEntityIndex);
		ASSERT(theResearchEntity);
		
		float theTimeResearchDone = this->GetTimeResearchDone();
		
		// Set time during the first update
		if(theTimeResearchDone < 0)
		{
			this->mTimeResearchStarted = gpGlobals->time;
			theTimeResearchDone = this->mTimeResearchStarted + GetGameRules()->GetBuildTimeForMessageID(theResearchingTech);
			this->mTimeResearchDone = theTimeResearchDone;
			theResearchEntity->pev->iuser2 = (int)this->mResearch;
		}
		
		if((gpGlobals->time >= theTimeResearchDone) || GetGameRules()->GetIsTesting())
		{
			theResearchDone = true;
			//AvHSHUSetBuildResearchState(theResearchEntity->pev->iuser3, theResearchEntity->pev->iuser4, theResearchEntity->pev->fuser1, false, 0.0f);
			//			theResearchEntity->pev->fuser1 = 0.0f;
			//			theResearchEntity->pev->iuser2 = 0;
		}
		else
		{
			float theNormalizedResearchFactor = (gpGlobals->time - this->mTimeResearchStarted)/(this->mTimeResearchDone - this->mTimeResearchStarted);
			theNormalizedResearchFactor = min(max(theNormalizedResearchFactor, 0.0f), 1.0f);

			//theResearchEntity->pev->fuser1 = (kResearchFuser1Base + theNormalizedResearchFactor)*kNormalizationNetworkFactor;
			AvHSHUSetBuildResearchState(theResearchEntity->pev->iuser3, theResearchEntity->pev->iuser4, theResearchEntity->pev->fuser1, false, theNormalizedResearchFactor);
		}
	}
	
	return theResearchDone;
}
Exemplo n.º 24
0
bool AvHHive::GetSpawnLocationForPlayer(CBaseEntity* inPlayer, Vector& outLocation) const
{
	bool theSuccess = false;

	CBaseEntity* theSpawnPoint = GetGameRules()->GetRandomHiveSpawnPoint(inPlayer, this->pev->origin, this->GetMaxSpawnDistance());
	if(theSpawnPoint)
	{
		outLocation = theSpawnPoint->pev->origin;
		theSuccess = true;
	}

	return theSuccess;
}
Exemplo n.º 25
0
void AvHHive::CueRespawnEffect(AvHPlayer* inPlayer)
{
	// Play hive animation, play effect for player?
	this->pev->sequence = 4;
	this->pev->frame = 0;
	ResetSequenceInfo();

	// Create umbra around spawning players, but not until after late-join period (to avoid a ton of umbras all at once)
	if(!GetGameRules()->GetArePlayersAllowedToJoinImmediately())
	{
		//this->CreateUmbra(inPlayer->pev->origin);
	}
}
Exemplo n.º 26
0
void AvHBaseBuildable::UpdateAutoHeal()
{
	if(GetGameRules()->GetGameStarted() && this->GetIsBuilt())
	{
		if((this->mTimeOfLastAutoHeal != -1) && (gpGlobals->time > this->mTimeOfLastAutoHeal))
		{
			float theMaxHealth = GetGameRules()->GetBaseHealthForMessageID(this->GetMessageID());
			if(this->pev->health < theMaxHealth)
			{
				float theTimePassed = (gpGlobals->time - this->mTimeOfLastAutoHeal);
				float theHitPointsToGain = theTimePassed*BALANCE_VAR(kOrganicStructureHealRate);
			
				this->pev->health += theHitPointsToGain;
				this->pev->health = min(this->pev->health, theMaxHealth);
			
				this->HealthChanged();
			}
		}

		this->mTimeOfLastAutoHeal = gpGlobals->time;
	}
}
Exemplo n.º 27
0
bool AvHResearchManager::SetResearchDone(AvHMessageID inTech, int inEntityIndex)
{
	bool theFoundIt = false;
	
	if(this->mTechNodes.SetResearchDone(inTech))
	{
		edict_t* theEdict = g_engfuncs.pfnPEntityOfEntIndex(inEntityIndex);
		ASSERT(!theEdict->free);
		CBaseEntity* theEntity = CBaseEntity::Instance(theEdict);
		ASSERT(theEntity);

		// Potentially inform all entities and team of upgrade
		GetGameRules()->ProcessTeamUpgrade(inTech, this->mTeamNumber, inEntityIndex, true);
		
		// Hook research complete
		AvHSUResearchComplete(theEntity, inTech);

		// No longer researching
		//theEntity->pev->fuser1 = kResearchFuser1Base*kNormalizationNetworkFactor;
		AvHSHUSetBuildResearchState(theEntity->pev->iuser3, theEntity->pev->iuser4, theEntity->pev->fuser1, true, 0.0f);
		
		// Tell entity that it's no longer researching
		AvHBuildable* theBuildable = dynamic_cast<AvHBuildable*>(theEntity);
		if(theBuildable)
		{
			theBuildable->SetResearching(false);
		}
		
		// Send message indicating research is done
		GetGameRules()->TriggerAlert(this->mTeamNumber, ALERT_RESEARCH_COMPLETE, inEntityIndex);
		
		theFoundIt = true;
	}
	
	return theFoundIt;
}
Exemplo n.º 28
0
float AvHHive::GetReinforceTime() const
{
	const float kMaxRespawnTime = BALANCE_VAR(kAlienRespawnTime);

	float theRespawnTime = (kMaxRespawnTime - kMaxRespawnTime*this->mEnergy);

	// puzl 0000854 
	//  Decrease respawn wait time for aliens (NS: Classic)
	//	With one hive, for every player above six on the alien team, 
	//  reduce the per-player respawn wait time by two-thirds of a second. 
	//  With two hives, make the reduction one-third of a second. 
	//  With three (or more, in the case of weird custom maps) hives, do not apply it.

	AvHTeam* theTeam = GetGameRules()->GetTeam(GetTeamNumber());
	ASSERT(theTeam);

	int thePlayerModifier = theTeam->GetPlayerCount() - BALANCE_VAR(kAlienRespawnPlayerModifier);
	int theHiveCount = GetGameRules()->GetNumActiveHives(GetTeamNumber());
	
	if ( thePlayerModifier > 0 && theHiveCount < 3 ) 
	{
		float theTimeModifier = BALANCE_VAR(kAlienRespawnTimeModifier);

		// For one hive double the modifier
		if ( theHiveCount == 1 ) 
		{
			theTimeModifier *= 2.0f;
		}

		theRespawnTime -= theTimeModifier * (float)thePlayerModifier;
	}

	theRespawnTime = min(max(theRespawnTime, 0.0f), kMaxRespawnTime);

	return theRespawnTime;
}
Exemplo n.º 29
0
void AvHPlayer::AwardExperienceForObjective(float inHealthChange, AvHMessageID inMessageID)
{
    bool theAwardExperience = false;

    if(GetGameRules()->GetIsCombatMode())
    {
        switch(inMessageID)
        {
        case ALIEN_BUILD_HIVE:
        case BUILD_COMMANDSTATION:
            theAwardExperience = true;
            break;
        }
    }

    if(theAwardExperience)
    {
        int theMaxHealth = GetGameRules()->GetBaseHealthForMessageID(inMessageID);
        float thePercentageOfHealth = inHealthChange/theMaxHealth;
        int theCombatObjectiveExperienceScalar = BALANCE_IVAR(kCombatObjectiveExperienceScalar);
        float theExperienceGained = thePercentageOfHealth*theCombatObjectiveExperienceScalar;
        this->SetExperience(this->GetExperience() + theExperienceGained);
    }
}
Exemplo n.º 30
0
// takes filename, returns success
static int saveWorldChecksum(lua_State* inState)
{
	bool theSuccess = false;

	Checksum theChecksum;
	GetGameRules()->ComputeWorldChecksum(theChecksum);

	const char* theFileName = lua_tostring(inState, 1);
	theSuccess = theChecksum.SaveToFile(theFileName);

	// Return success
	lua_pushnumber(inState, theSuccess);

	return 1;
}