void AvHPushableBuildable::SetConstructionComplete()
{
	AvHBaseBuildable::SetConstructionComplete();

//	if ( pev->spawnflags & SF_PUSH_BREAKABLE )
//		AvHBaseBuildable::Spawn();
//	else
//		Precache( );

	//pev->movetype	= MOVETYPE_PUSHSTEP;
	this->pev->movetype = MOVETYPE_TOSS;
	pev->solid		= SOLID_BBOX;
	//SET_MODEL( ENT(pev), STRING(pev->model) );
	SET_MODEL( ENT(pev), this->GetModelName());

	Vector theMinSize, theMaxSize;
	AvHSHUGetSizeForTech(this->GetMessageID(), theMinSize, theMaxSize);
	UTIL_SetSize(this->pev, theMinSize, theMaxSize); 

	if ( pev->friction > 399 )
		pev->friction = 399;

	m_maxSpeed = 100;//400 - pev->friction;
	SetBits( pev->flags, FL_FLOAT );
	pev->friction = 0;
	
	pev->origin.z += 1;	// Pick up off of the floor
	UTIL_SetOrigin( pev, pev->origin );

	// Multiply by area of the box's cross-section (assume 1000 units^3 standard volume)
	pev->skin = ( pev->skin * (pev->maxs.x - pev->mins.x) * (pev->maxs.y - pev->mins.y) ) * 0.0005;
	m_soundTime = 0;
}
Example #2
0
void AvHBaseBuildable::Materialize()
{
	this->pev->solid = SOLID_BBOX;

	this->pev->movetype = this->GetMoveType();
	
	this->pev->classname = MAKE_STRING(this->mClassName);
	
	this->pev->takedamage = DAMAGE_YES;
	SetBits(this->pev->flags, FL_MONSTER);
	
	// Always buildable
	this->InternalInitializeBuildable();
	
	this->SetNormalizedBuildPercentage(0.0f);
	
	// NOTE: fuser2 is used for repairing structures

	Vector theMinSize, theMaxSize;
	//int theSequence = this->GetSequenceForBoundingBox();

	// Get height needed for model
	//this->ExtractBbox(theSequence, (float*)&theMinSize, (float*)&theMaxSize);
	//float theHeight = theMaxSize.z - theMinSize.z;

	AvHSHUGetSizeForTech(this->GetMessageID(), theMinSize, theMaxSize);

	UTIL_SetSize(pev, theMinSize, theMaxSize);

	this->PlayAnimationAtIndex(this->GetSpawnAnimation(), true);
		
	SetUse(&AvHBaseBuildable::ConstructUse);
}
Example #3
0
int	AvHBaseBuildable::TakeDamage(entvars_t* inInflictor, entvars_t* inAttacker, float inDamage, int inBitsDamageType)
{
	if(GetGameRules()->GetIsCheatEnabled(kcHighDamage))
	{
		inDamage *= 50;
	}

	if(!inAttacker)
	{
		inAttacker = inInflictor;
	}
	
	if(!inInflictor)
	{
		inInflictor = inAttacker;
	}

	// Take into account handicap
	AvHTeam* theTeam = GetGameRules()->GetTeam(AvHTeamNumber(inAttacker->team));
	if(theTeam)
	{
		float theHandicap = theTeam->GetHandicap();
		inDamage *= theHandicap;
	}
	
	CBaseEntity* inInflictorEntity = CBaseEntity::Instance(inInflictor);
	float theDamage = 0;

	// Take half damage from piercing
	if(inBitsDamageType & NS_DMG_PIERCING)
	{
		inDamage /= 2.0f;
	}

	// Take double damage from blast
	if(inBitsDamageType & NS_DMG_BLAST)
	{
		inDamage *= 2.0f;
	}
	
	if((inBitsDamageType & NS_DMG_ORGANIC) && !this->GetIsOrganic())
	{
		inDamage = 0.0f;
	}

	theDamage = AvHPlayerUpgrade::CalculateDamageLessArmor((AvHUser3)this->pev->iuser3, this->pev->iuser4, inDamage, this->pev->armorvalue, inBitsDamageType, GetGameRules()->GetNumActiveHives((AvHTeamNumber)this->pev->team));
	if(theDamage > 0)
	{
        int theAnimationIndex = this->GetTakeDamageAnimation();
        if(theAnimationIndex >= 0)
        {
            this->PlayAnimationAtIndex(theAnimationIndex, true);
        }

        // Award experience to attacker
        CBaseEntity* theEntity = CBaseEntity::Instance(ENT(inAttacker));
        AvHPlayer* inAttacker = dynamic_cast<AvHPlayer*>(theEntity);
        if(inAttacker && (inAttacker->pev->team != this->pev->team))
        {
            inAttacker->AwardExperienceForObjective(theDamage, this->GetMessageID());
        }
	}
	
	int theReturnValue = 0;
	
	if(theDamage > 0.0f)
	{
		if(this->GetTriggerAlertOnDamage())
			GetGameRules()->TriggerAlert((AvHTeamNumber)this->pev->team, ALERT_UNDER_ATTACK, this->entindex());
		
		theDamage = CBaseAnimating::TakeDamage(inInflictor, inAttacker, inDamage, inBitsDamageType);

		bool theDrawDamage = (CVAR_GET_FLOAT(kvDrawDamage) > 0);

		if(theDrawDamage)
		{
			Vector theMinSize;
			Vector theMaxSize;
			AvHSHUGetSizeForTech(this->GetMessageID(), theMinSize, theMaxSize);
			
			Vector theStartPos = this->pev->origin;
			theStartPos.z += theMaxSize.z;
			
			// Draw for everyone (team is 0 after inDamage parameter)
			AvHSUPlayNumericEvent(-inDamage, this->edict(), theStartPos, 0, kNumericalInfoHealthEvent, 0);
		}
	}

	// Structures uncloak when damaged
	this->Uncloak();

	this->HealthChanged();
	
	return theDamage;
}