Esempio n. 1
0
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);
					}
				}
			}
		}
	}
}