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); } } } } } }
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 }
void AvHEggLayer::FireProjectiles(void) { #ifdef AVH_SERVER // Make sure we have enough points to shoot this thing AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(this->m_pPlayer); ASSERT(thePlayer); if(thePlayer->GetResources() > kEggLayerPointCost) { // Now check to make sure the space is big enough to hold the egg UTIL_MakeVectors(this->m_pPlayer->pev->v_angle); //Vector vecAiming = gpGlobals->v_forward; Vector vecSrc = this->m_pPlayer->GetGunPosition();// + vecAiming; if(AvHSUIsAreaFree(vecSrc, kEggRadius, this->m_pPlayer)) { // Decrement kEggLayerPointCost points thePlayer->SetResources(thePlayer->GetResources() - kEggLayerPointCost); AvHEgg* theEgg = GetClassPtr((AvHEgg*)NULL ); theEgg->Spawn(); theEgg->pev->angles.x = 0; theEgg->pev->angles.z = 0; //theEgg->pev->velocity = gpGlobals->v_forward * 300 + gpGlobals->v_forward * 100; UTIL_SetOrigin(theEgg->pev, vecSrc); // Set owner //theEgg->pev->owner = ENT(this->m_pPlayer->pev); // Set egg's team theEgg->pev->team = this->m_pPlayer->pev->team; } } #endif }