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	
}
Esempio n. 2
0
void AvHMovementChamber::TeleportUse(CBaseEntity* inActivator, CBaseEntity* inCaller, USE_TYPE inUseType, float inValue)
{
	const float kHiveScanInterval = 1.0f;

	AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(inActivator);
	if(thePlayer && (thePlayer->pev->team == this->pev->team) && (thePlayer->GetUser3() != AVH_USER3_ALIEN_EMBRYO))
	{
		if((this->mLastTimeScannedHives == -1) || (gpGlobals->time > (this->mLastTimeScannedHives + kHiveScanInterval)))
		{
			this->mTeleportHiveIndex = -1;
			float theFarthestDistance = 0.0f; //sqrt((kMaxMapDimension*2)*(kMaxMapDimension*2));
			bool theIsDone = false;
		
			// Loop through the hives for this team, look for the farthest one (hives under attack take precedence)
			FOR_ALL_ENTITIES(kesTeamHive, AvHHive*)
				if((theEntity->pev->team == this->pev->team) && !theIsDone)
				{
					bool theHiveIsUnderAttack = GetGameRules()->GetIsEntityUnderAttack(theEntity->entindex());

					if(theEntity->GetIsActive() || theHiveIsUnderAttack || theEntity->GetEmergencyUse() )
					{
						float theCurrentDistance = VectorDistance(theEntity->pev->origin, inActivator->pev->origin);
						bool theHiveIsFarther = (theCurrentDistance > theFarthestDistance);

						// Undefined which attacked hive is chosen if multiples are under attack
						if((this->mTeleportHiveIndex == -1) || theHiveIsFarther || theHiveIsUnderAttack)
						{
							this->mTeleportHiveIndex = theEntity->entindex();
							theFarthestDistance = theCurrentDistance;

							// If there's a hive under attack, we're done
							if(theHiveIsUnderAttack)
							{
								theIsDone = true;
							}
						}
					}
				}
			END_FOR_ALL_ENTITIES(kesTeamHive)
		
			this->mLastTimeScannedHives = gpGlobals->time;
		}
		
		// If we have a valid hive index, jump the player to it
		if(this->mTeleportHiveIndex != -1)
		{
			// Play sound at this entity
			EMIT_SOUND(this->edict(), CHAN_AUTO, kAlienSightOnSound, 1.0f, ATTN_NORM);
		
			// Move him to it!
			AvHHive* theHive = NULL;
			AvHSUGetEntityFromIndex(this->mTeleportHiveIndex, theHive);
			if(theHive)
			{
				CBaseEntity* theSpawnEntity = GetGameRules()->GetRandomHiveSpawnPoint(thePlayer, theHive->pev->origin, theHive->GetMaxSpawnDistance());
				if(theSpawnEntity)
				{
					Vector theMinSize;
					Vector theMaxSize;
					thePlayer->GetSize(theMinSize, theMaxSize);

					int theOffset = AvHMUGetOriginOffsetForUser3(AvHUser3(thePlayer->pev->iuser3));
					Vector theOriginToSpawn = theSpawnEntity->pev->origin;
					theOriginToSpawn.z += theOffset;

					if(AvHSUGetIsEnoughRoomForHull(theOriginToSpawn, AvHMUGetHull(false, thePlayer->pev->iuser3), thePlayer->edict()))
					{
						thePlayer->SetPosition(theOriginToSpawn);
						thePlayer->pev->velocity = Vector(0, 0, 0);
						thePlayer->TriggerUncloak();
						// Play teleport sound before and after
						EMIT_SOUND(inActivator->edict(), CHAN_AUTO, kAlienSightOffSound, 1.0f, ATTN_NORM);
					}
				}
			}
		}
	}