void AvHMUUpdateAlienEnergy(float inTimePassed, int inUser3, int inUser4, float& ioFuser) { if( (inUser3 == AVH_USER3_ALIEN_PLAYER1) || (inUser3 == AVH_USER3_ALIEN_PLAYER2) || (inUser3 == AVH_USER3_ALIEN_PLAYER3) || (inUser3 == AVH_USER3_ALIEN_PLAYER4) || (inUser3 == AVH_USER3_ALIEN_PLAYER5) || (inUser3 == AVH_USER3_ALIEN_PLAYER6)) { if(!GetHasUpgrade(inUser4, MASK_PLAYER_STUNNED)) { // Percentage (0-1) per second float theAlienEnergyRate = (float)BALANCE_VAR(kAlienEnergyRate); //float kFadeChargingDeplectionRate = -2.8f*kAlienEnergyRate; float kChargingDepletionRate = -BALANCE_VAR(kChargingEnergyScalar)*theAlienEnergyRate; const float kMultiplier = GetHasUpgrade(inUser4, MASK_BUFFED) ? (1.0f + BALANCE_VAR(kPrimalScreamEnergyFactor)) : 1.0f; float theEnergyRate = theAlienEnergyRate*kMultiplier; float theUpgradeFactor = 1.0f; int theNumLevels = AvHGetAlienUpgradeLevel(inUser4, MASK_UPGRADE_5); if(theNumLevels > 0) { theUpgradeFactor += theNumLevels*BALANCE_VAR(kAdrenalineEnergyPercentPerLevel); } float theCurrentEnergy = ioFuser/kNormalizationNetworkFactor; float theNewEnergy = theCurrentEnergy + inTimePassed*theAlienEnergyRate*theUpgradeFactor; // // If we're charging, reduce energy // // Removed: Charge only reduces energy when active // if(GetHasUpgrade(inUser4, MASK_ALIEN_MOVEMENT)) // { // if(inUser3 == AVH_USER3_ALIEN_PLAYER4) // { // theNewEnergy += inTimePassed*kFadeChargingDeplectionRate; // } // else // { // theNewEnergy += inTimePassed*kChargingDepletionRate; // } // } theNewEnergy = min(max(theNewEnergy, 0.0f), 1.0f); ioFuser = theNewEnergy*kNormalizationNetworkFactor; } } }
// Changing this? Make sure to change AvHCommanderModeHandler::ActionButtonActivated also. bool AvHGetTechSlotEnabled(int inSlot, int inUser4) { bool theSlotIsEnabled = false; switch(inSlot) { case 0: theSlotIsEnabled = GetHasUpgrade(inUser4, MASK_UPGRADE_1); break; case 1: theSlotIsEnabled = GetHasUpgrade(inUser4, MASK_UPGRADE_2); break; case 2: theSlotIsEnabled = GetHasUpgrade(inUser4, MASK_UPGRADE_3); break; case 3: theSlotIsEnabled = GetHasUpgrade(inUser4, MASK_UPGRADE_4); break; case 4: theSlotIsEnabled = GetHasUpgrade(inUser4, MASK_UPGRADE_5); break; case 5: theSlotIsEnabled = GetHasUpgrade(inUser4, MASK_UPGRADE_6); break; case 6: theSlotIsEnabled = GetHasUpgrade(inUser4, MASK_UPGRADE_7); break; case 7: theSlotIsEnabled = GetHasUpgrade(inUser4, MASK_UPGRADE_8); break; } return theSlotIsEnabled; }
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(); } }
bool AvHBaseBuildable::GetIsTechActive() const { bool theIsActive = false; if(this->GetIsBuilt() && (this->pev->health > 0) && !GetHasUpgrade(this->pev->iuser4, MASK_RECYCLING)) { theIsActive = true; } return theIsActive; }
int AvHGetAlienUpgradeLevel(int inUser4, AvHUpgradeMask inMask) { int theLevel = 0; if(GetHasUpgrade(inUser4, inMask)) { theLevel = 1; switch(inMask) { // Defensive upgrades case MASK_UPGRADE_1: case MASK_UPGRADE_2: case MASK_UPGRADE_3: if(GetHasUpgrade(inUser4, MASK_UPGRADE_10)) { theLevel = 2; } if(GetHasUpgrade(inUser4, MASK_UPGRADE_11)) { theLevel = 3; } break; // Movement upgrades case MASK_UPGRADE_4: case MASK_UPGRADE_5: case MASK_UPGRADE_6: if(GetHasUpgrade(inUser4, MASK_UPGRADE_12)) { theLevel = 2; } if(GetHasUpgrade(inUser4, MASK_UPGRADE_13)) { theLevel = 3; } break; // Sensory upgrades case MASK_UPGRADE_7: case MASK_UPGRADE_8: case MASK_UPGRADE_9: if(GetHasUpgrade(inUser4, MASK_UPGRADE_14)) { theLevel = 2; } if(GetHasUpgrade(inUser4, MASK_UPGRADE_15)) { theLevel = 3; } break; } } return theLevel; }
float AvHMarineWeapon::ComputeAttackInterval() const { float theROF = this->GetRateOfFire(); int theUser4 = this->m_pPlayer->pev->iuser4; // Speed attack if in range of primal scream if(GetHasUpgrade(theUser4, MASK_BUFFED)) { float theCatalystROFFactor = 1.0f + BALANCE_VAR(kCatalystROFFactor); theROF /= theCatalystROFFactor; } return theROF; }
void AvHBaseBuildable::UpdateTechSlots() { // Get tech slot for this structure AvHGamerules* theGameRules = GetGameRules(); const AvHTeam* theTeam = theGameRules->GetTeam((AvHTeamNumber)this->pev->team); if(theTeam) { // Update tech slots AvHTechSlots theTechSlots; if(theTeam->GetTechSlotManager().GetTechSlotList((AvHUser3)this->pev->iuser3, theTechSlots)) { // Clear the existing slots int theMasks[kNumTechSlots] = {MASK_UPGRADE_1, MASK_UPGRADE_2, MASK_UPGRADE_3, MASK_UPGRADE_4, MASK_UPGRADE_5, MASK_UPGRADE_6, MASK_UPGRADE_7, MASK_UPGRADE_8}; // Each slot if we technology is available for(int i = 0; i < kNumTechSlots; i++) { int theCurrentMask = theMasks[i]; this->pev->iuser4 &= ~theCurrentMask; AvHMessageID theMessage = theTechSlots.mTechSlots[i]; if(theMessage != MESSAGE_NULL) { if(this->GetIsTechnologyAvailable(theMessage)) { this->pev->iuser4 |= theCurrentMask; } } } } // Update recycling status bar if(GetHasUpgrade(this->pev->iuser4, MASK_RECYCLING)) { float theNormalizedRecyclingFactor = (gpGlobals->time - this->mTimeRecycleStarted)/(this->mTimeRecycleDone - this->mTimeRecycleStarted); theNormalizedRecyclingFactor = min(max(theNormalizedRecyclingFactor, 0.0f), 1.0f); //theResearchEntity->pev->fuser1 = (kResearchFuser1Base + theNormalizedResearchFactor)*kNormalizationNetworkFactor; AvHSHUSetBuildResearchState(this->pev->iuser3, this->pev->iuser4, this->pev->fuser1, false, theNormalizedRecyclingFactor); } } }
void AvHSiegeTurret::CheckEnabledState() { bool theEnabledState = false; if(this->GetHasBeenBuilt() && !this->GetIsRecycling()) { FOR_ALL_ENTITIES(kwsAdvancedTurretFactory, AvHTurretFactory*) if((theEntity->pev->team == this->pev->team) && theEntity->GetIsBuilt() && !GetHasUpgrade(theEntity->pev->iuser4, MASK_RECYCLING)) { // If they are a friendly, alive, turret factory float the2DDistance = VectorDistance2D(this->pev->origin, theEntity->pev->origin); // Enabled state is true if(the2DDistance <= BALANCE_IVAR(kTurretFactoryBuildDistance)) { theEnabledState = true; break; } } END_FOR_ALL_ENTITIES(kwsAdvancedTurretFactory) }
bool AvHBaseBuildable::GetIsTechnologyAvailable(AvHMessageID inMessageID) const { bool theTechnologyAvailable = false; const AvHTeam* theTeam = GetGameRules()->GetTeam((AvHTeamNumber)this->pev->team); if(theTeam) { // Don't allow electrical upgrade if we're already electrified if((inMessageID != RESEARCH_ELECTRICAL) || !GetHasUpgrade(this->pev->iuser4, MASK_UPGRADE_11)) { theTechnologyAvailable = (theTeam->GetIsTechnologyAvailable(inMessageID) && this->GetIsBuilt() && !GetHasUpgrade(this->pev->iuser4, MASK_RECYCLING)); // Enable recycle button for unbuilt structures if(!this->GetIsBuilt() && (inMessageID == BUILD_RECYCLE)) { theTechnologyAvailable = true; } } } return theTechnologyAvailable; }
// Used for context sensitive mouse and for processing right-click // Must be shared, uses prediction code // Fill in target index or target point, depending on type of order decided upon AvHOrderType AvHGetDefaultOrderType(AvHTeamNumber inTeam, const vec3_t& inOrigin, const vec3_t& inNormRay, int& outTargetIndex, vec3_t& outTargetPoint, AvHUser3& outUser3, AvHOrderTargetType& outTargetType) { vec3_t theTraceStart; vec3_t theTraceEnd; AvHOrderType theOrderType = ORDERTYPE_UNDEFINED; // // Look for a player order // if(!AvHOrderTracePlayers(inTeam, inOrigin, inNormRay, theOrderType, outTargetIndex)) // { // // If couldn't find one, create a non-player order if possible // //AvHOrderTraceNonPlayers(inTeam, inOrigin, inNormRay, theOrderType, outTargetIndex, outTargetPoint); // } // Offset a little so we don't hit the commander VectorMA(inOrigin, kSelectionStartRange, inNormRay, theTraceStart); VectorMA(inOrigin, kSelectionEndRange, inNormRay, theTraceEnd); int theFoundIndex = -1; vec3_t theFoundLocation; AvHTeamNumber theTeamOfThingHit; bool thePlayerHit = false; int theUserThree = 0; int theUserFour = 0; if(AvHSHUTraceTangible(theTraceStart, theTraceEnd, theFoundIndex, theFoundLocation, theTeamOfThingHit, thePlayerHit, theUserThree, theUserFour)) { float theHealthPercentage=100.0f; float theArmorPercentage=100.0f; bool theSighted=false; #ifdef AVH_SERVER CBaseEntity *theEntity=AvHSUGetEntityFromIndex(theFoundIndex); if ( theEntity ) { theHealthPercentage=theEntity->pev->health/theEntity->pev->max_health; } else { ALERT(at_console, "Not a buildable\n"); } theArmorPercentage = theEntity->pev->armorvalue/AvHPlayerUpgrade::GetMaxArmorLevel(theEntity->pev->iuser4, (AvHUser3)theEntity->pev->iuser3); theSighted=GetHasUpgrade(theEntity->pev->iuser4, MASK_VIS_SIGHTED); #endif // Did we hit an enemy? If so, issue an attack order on him, then we're done, it's highest priority if(thePlayerHit ) { // Did we hit a player on our team? If so check for welding, if not guard if((theTeamOfThingHit == inTeam ) && (theTeamOfThingHit != TEAM_IND) ) { theOrderType = ORDERTYPET_GUARD; if ( theArmorPercentage < 0.90f ) { theOrderType = ORDERTYPET_WELD; outTargetType = ORDERTARGETTYPE_TARGET; } outTargetIndex = theFoundIndex; outUser3 = (AvHUser3)theUserThree; } } // Something to pick up? if(!thePlayerHit ) { // if ( ( theTeamOfThingHit ) != inTeam && (theTeamOfThingHit != TEAM_IND) && theSighted ) // { // // Use it's center for the height // VectorCopy(theFoundLocation, outTargetPoint); // theOrderType = ORDERTYPET_ATTACK; // outTargetIndex = theFoundIndex; // outUser3 = (AvHUser3)theUserThree; // outTargetType = ORDERTARGETTYPE_LOCATION; // } // else if ( theUserThree == AVH_USER3_MARINEITEM) { // Use it's center for the height VectorCopy(theFoundLocation, outTargetPoint); outTargetIndex = theFoundIndex; outUser3 = (AvHUser3)theUserThree; // We're done theOrderType = ORDERTYPET_GET; } // Buildable? else if(GetHasUpgrade(theUserFour, MASK_BUILDABLE) && (theTeamOfThingHit == inTeam) && (theTeamOfThingHit != TEAM_IND)) { // Use it's center for the height VectorCopy(theFoundLocation, outTargetPoint); outTargetIndex = theFoundIndex; outUser3 = (AvHUser3)theUserThree; // We're done theOrderType = ORDERTYPET_BUILD; } // Weldable? else if(theUserThree == AVH_USER3_WELD ) { // Use it's center for the height VectorCopy(theFoundLocation, outTargetPoint); outTargetIndex = theFoundIndex; // We're done theOrderType = ORDERTYPET_WELD; } // Hit the ground? Move to, we're done else if(theUserThree == AVH_USER3_WAYPOINT || (( theTeamOfThingHit != inTeam) && !theSighted )) { // Use it's center for the height VectorCopy(theFoundLocation, outTargetPoint); // We're done theOrderType = ORDERTYPEL_MOVE; } // Did we hit an entity on our team? Repair/guard it, we're done else if((theTeamOfThingHit == inTeam) && (theTeamOfThingHit != TEAM_IND)) { theOrderType = ORDERTYPET_GUARD; if ( theHealthPercentage < 0.90f ) { theOrderType = ORDERTYPET_WELD; VectorCopy(theFoundLocation, outTargetPoint); outTargetType = ORDERTARGETTYPE_LOCATION; } outTargetIndex = theFoundIndex; outUser3 = (AvHUser3)theUserThree; } } // else if(!thePlayerHit && (theUserThree == AVH_USER3_USEABLE)) // { // // Use it's center for the height // VectorCopy(theFoundLocation, outTargetPoint); // outTargetIndex = theFoundIndex; // // // We're done // theOrderType = ORDERTYPEL_USE; // } } return theOrderType; }
void AvHBaseBuildable::WorldUpdate() { this->UpdateTechSlots(); // Organic buildings heal themselves if(this->GetIsOrganic()) { this->UpdateAutoHeal(); } else { //this->UpdateDamageEffects(); } // If we're electrified, set render mode if(GetHasUpgrade(this->pev->iuser4, MASK_UPGRADE_11)) { // Base marine building const int kElectrifyRenderMode = kRenderFxGlowShell; const int kElectrifyRenderAmount = 40; this->pev->renderfx = kElectrifyRenderMode; this->pev->renderamt = kElectrifyRenderAmount; this->pev->rendercolor.x = kTeamColors[this->pev->team][0]; this->pev->rendercolor.y = kTeamColors[this->pev->team][1]; this->pev->rendercolor.z = kTeamColors[this->pev->team][2]; // Check for enemy players/structures nearby CBaseEntity* theBaseEntity = NULL; int theNumEntsDamaged = 0; while(((theBaseEntity = UTIL_FindEntityInSphere(theBaseEntity, this->pev->origin, BALANCE_VAR(kElectricalRange))) != NULL) && (theNumEntsDamaged < BALANCE_VAR(kElectricalMaxTargets))) { // When "electric" cheat is enabled, shock all non-self entities, else shock enemies if((GetGameRules()->GetIsCheatEnabled(kcElectric) && (theBaseEntity != this)) || ((theBaseEntity->pev->team != this->pev->team) && theBaseEntity->IsAlive())) { // Make sure it's not blocked TraceResult theTraceResult; UTIL_TraceLine(this->pev->origin, theBaseEntity->pev->origin, ignore_monsters, dont_ignore_glass, this->edict(), &theTraceResult); if(theTraceResult.flFraction == 1.0f) { CBaseEntity* theAttacker = this->GetAttacker(); ASSERT(theAttacker); if(theBaseEntity->TakeDamage(this->pev, theAttacker->pev, BALANCE_VAR(kElectricalDamage), DMG_GENERIC) > 0) { MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE(TE_BEAMENTPOINT); WRITE_SHORT(theBaseEntity->entindex()); WRITE_COORD( this->pev->origin.x); WRITE_COORD( this->pev->origin.y); WRITE_COORD( this->pev->origin.z); WRITE_SHORT( this->mElectricalSprite ); WRITE_BYTE( 0 ); // framestart WRITE_BYTE( (int)15); // framerate WRITE_BYTE( (int)(2) ); // life WRITE_BYTE( 60 ); // width WRITE_BYTE( 15 ); // noise WRITE_BYTE( (int)this->pev->rendercolor.x ); // r, g, b WRITE_BYTE( (int)this->pev->rendercolor.y ); // r, g, b WRITE_BYTE( (int)this->pev->rendercolor.z ); // r, g, b WRITE_BYTE( 200 ); // brightness WRITE_BYTE( 10 ); // speed MESSAGE_END(); gSoundListManager.PlaySoundInList(kElectricSparkSoundList, this, CHAN_AUTO, .7f); UTIL_Sparks(theBaseEntity->pev->origin); theNumEntsDamaged++; } } } } } }
void AvHCommanderModeHandler::SetMenuFromTechSlots(const AvHTechSlots& inTechSlots, int inUser3, int inUser4, float inFuser1) { AvHActionButtons* theActionButtons = NULL; if(gHUD.GetManager().GetVGUIComponentNamed(kActionButtonsComponents, theActionButtons)) { //string theNotFullyBuiltText; //if(LocalizeString(kNotFullyBuilt, theNotFullyBuiltText)) theActionButtons->ClearButtons(); bool theIsBuilding, theIsResearching; float thePercentage; AvHSHUGetBuildResearchState(inUser3, inUser4, inFuser1, theIsBuilding, theIsResearching, thePercentage); bool theDisplayingSpecialMenu = false; switch(inUser3) { case AVH_USER3_MENU_BUILD: case AVH_USER3_MENU_BUILD_ADVANCED: case AVH_USER3_MENU_ASSIST: case AVH_USER3_MENU_EQUIP: theDisplayingSpecialMenu = true; break; } // if recycling, draw nothing (check if something is selected, as otherwise inUser3 could be MENU_ something and MASK_RECYCLING won't make sense) if(!theDisplayingSpecialMenu && (this->mSelected.size() > 0) && GetHasUpgrade(inUser4, MASK_RECYCLING)) { } // else if we're placing a building or researching, don't display anything but cancel else if((gHUD.GetGhostBuilding() != MESSAGE_NULL) || (theIsResearching && !theIsBuilding)) { // Set last button as cancel theActionButtons->SetButton(0, MENU_BUILD); theActionButtons->SetButton(1, MENU_BUILD_ADVANCED); theActionButtons->SetButton(2, MENU_ASSIST); theActionButtons->SetButton(3, MENU_EQUIP); theActionButtons->SetButton(kNumActionButtonRows*kNumActionButtonCols - 1, MESSAGE_CANCEL); } // else use the menu the server specifies else { // Set hard-coded top bar theActionButtons->SetButton(0, MENU_BUILD); theActionButtons->SetButton(1, MENU_BUILD_ADVANCED); theActionButtons->SetButton(2, MENU_ASSIST); theActionButtons->SetButton(3, MENU_EQUIP); const int kBaseButtonIndex = 4; // else, query for rest of state for(int i=0; i < kNumTechSlots; i++) { AvHMessageID theMessageID = inTechSlots.mTechSlots[i]; if(theMessageID != MESSAGE_NULL) { int theCurrentButtonIndex = kBaseButtonIndex + i; theActionButtons->SetButton(theCurrentButtonIndex, theMessageID); // Now set it's enabled state generically bool theEnabledState = AvHGetTechSlotEnabled(i, inUser4); theActionButtons->SetEnabledState(theCurrentButtonIndex, theEnabledState); } } } theActionButtons->Localize(); } }
// Look at currently selected units and set up our menus void AvHCommanderModeHandler::RecalculateMenus() { bool theSuccess = false; int theUser4 = 0; float theFuser1 = 0; // If we have only one thing selected, it can be a building int theNumUnits = (int)this->mSelected.size(); if(theNumUnits > 0) { // Assumes all of selected is of same type int theIndex = *this->mSelected.begin(); cl_entity_s* theEntity = gEngfuncs.GetEntityByIndex(theIndex); if(theEntity) { // Display icons for this type of structure AvHUser3 theUser3 = (AvHUser3)(theEntity->curstate.iuser3); if((theUser3 == AVH_USER3_MARINE_PLAYER) || GetHasUpgrade(theEntity->curstate.iuser4, MASK_RECYCLING)) { // Set to base marine menu if current isn't compatible with it switch(this->mDisplayMenu) { case AVH_USER3_MENU_BUILD: case AVH_USER3_MENU_BUILD_ADVANCED: case AVH_USER3_MENU_ASSIST: case AVH_USER3_MENU_EQUIP: // Do nothing, keep current menu break; default: this->mDisplayMenu = AVH_USER3_MENU_BUILD; } theSuccess = true; } else { this->mDisplayMenu = theUser3; theUser4 = theEntity->curstate.iuser4; theFuser1 = theEntity->curstate.fuser1; theSuccess = true; } } } // Menu takes precedence over player selection, to allow ordering selected players to construct // else if(this->mDisplayMenu == AVH_USER3_NONE) // { // int theCommonUser4 = 0; // if(this->GetIsSelectionAllPlayers(&theCommonUser4)) // { // this->mDisplayMenu = AVH_USER3_COMMANDER_PLAYER; // theUser4 = theCommonUser4; // } // } if(this->mDisplayMenu == AVH_USER3_NONE) { this->mDisplayMenu = AVH_USER3_MENU_BUILD; } // Recalculate iuser4 for special menu options int theMenuTechSlots = gHUD.GetMenuTechSlots(); switch(this->mDisplayMenu) { case AVH_USER3_MENU_BUILD: //case AVH_USER3_COMMANDER_PLAYER: theUser4 = theMenuTechSlots << 3; break; case AVH_USER3_MENU_BUILD_ADVANCED: theUser4 = theMenuTechSlots >> 5; break; case AVH_USER3_MENU_ASSIST: theUser4 = theMenuTechSlots >> 13; break; case AVH_USER3_MENU_EQUIP: theUser4 = theMenuTechSlots >> 21; break; } // Show menu according to our current mode and data this->SetMenuFromUserVariables(this->mDisplayMenu, theUser4, theFuser1); }
// Look at currently selected units and set our help text. This is only used for research currently void AvHCommanderModeHandler::RecalculateBuildResearchText() { this->mBuildResearchText = ""; if(this->mSelected.size() == 1) { // Get entity int theEntityIndex = *this->mSelected.begin(); cl_entity_s* theEntity = gEngfuncs.GetEntityByIndex(theEntityIndex); if(theEntity) { bool theIsBuilding, theIsResearching; float thePercentage; string theHelpPrefix; AvHSHUGetBuildResearchState(theEntity->curstate.iuser3, theEntity->curstate.iuser4, theEntity->curstate.fuser1, theIsBuilding, theIsResearching, thePercentage); // Special-case for energy if(theIsBuilding && theIsResearching && (thePercentage > 0.0f)) { LocalizeString(kEnergyPrefix, theHelpPrefix); // Read energy int theEnergy = thePercentage*kMarineStructureMaxEnergy; this->mBuildResearchText = theHelpPrefix + string(" ") + MakeStringFromInt(theEnergy); } // Check if it's recycling else if(!theIsBuilding && theIsResearching && GetHasUpgrade(theEntity->curstate.iuser4, MASK_RECYCLING)) { LocalizeString("Recycling", this->mBuildResearchText); } // Check to see if it's being built else if((theIsBuilding || theIsResearching) && (thePercentage < 1.0f)) { if(theIsBuilding) { // Set help text to "Building: <tech name>" LocalizeString(kBuildingPrefix, theHelpPrefix); } else if(theIsResearching) { // Set help text to "Researching: <tech name>" LocalizeString(kResearchingPrefix, theHelpPrefix); } string theHelpText; AvHMessageID theResearchID = (AvHMessageID)(theEntity->curstate.iuser2); if(theResearchID != MESSAGE_NULL) { if(ActionButton::GetLabelForMessage(theResearchID, theHelpText)) { string theFinalMessage = theHelpPrefix + theHelpText; this->mBuildResearchText = theFinalMessage; } } } else { if(GetHasUpgrade(theEntity->curstate.iuser4, MASK_BUILDABLE)) { // Look up name for entity and show it AvHMessageID theResearchID = (AvHMessageID)(theEntity->curstate.iuser2); if(theResearchID != MESSAGE_NULL) { ActionButton::GetLabelForMessage(theResearchID, this->mBuildResearchText); } } // If we have a resource selected, set the resource level else if(theEntity->curstate.iuser3 == AVH_USER3_FUNC_RESOURCE) { int theResources = (int)(theEntity->curstate.fuser1/kNormalizationNetworkFactor); if(theResources > 0) { if(LocalizeString(kResourcesTitle, this->mBuildResearchText)) { char theResourceMessage[64]; sprintf(theResourceMessage, "%d", theResources); this->mBuildResearchText += string(theResourceMessage); } } else { LocalizeString(kResourcesDepletedTitle, this->mBuildResearchText); } } else if(theEntity->curstate.iuser3 == AVH_USER3_INFANTRYPORTAL) { // int the = (int)(theEntity->curstate.fuser1/kNormalizationNetworkFactor); // if(theResources > 0) // { if(LocalizeString(kReinforcementsTitle, this->mBuildResearchText)) { // TODO: Read this number correctly //char theMessage[64]; //sprintf(theMessage, "%d", 100); //this->mBuildResearchText += string(theMessage); } // } // else // { // LocalizeString(kResourcesDepletedTitle, this->mBuildResearchText); // } } } } } }
void AvHEntityHierarchy::BuildForSpec(BaseEntityListType& inBaseEntityList) { this->Clear(); // Loop through all entities in the world for(BaseEntityListType::iterator theIter = inBaseEntityList.begin(); theIter != inBaseEntityList.end(); theIter++) { CBaseEntity* theBaseEntity = *theIter; int theEntityIndex = theBaseEntity->entindex(); bool theEntityIsVisible = false; if ( theBaseEntity->pev->team == TEAM_ONE || theBaseEntity->pev->team == TEAM_TWO || theBaseEntity->pev->team == TEAM_THREE || theBaseEntity->pev->team == TEAM_FOUR ) theEntityIsVisible=true; bool theEntityIsUnderAttack = GetGameRules()->GetIsEntityUnderAttack(theEntityIndex); // Don't send ammo, health, weapons, or scans bool theIsTransient = ((AvHUser3)(theBaseEntity->pev->iuser3) == AVH_USER3_MARINEITEM) || (theBaseEntity->pev->classname == MAKE_STRING(kwsScan)); MapEntity mapEntity; mapEntity.mX = theBaseEntity->pev->origin.x; mapEntity.mY = theBaseEntity->pev->origin.y; mapEntity.mUser3 = (AvHUser3)(theBaseEntity->pev->iuser3); mapEntity.mAngle = theBaseEntity->pev->angles[1]; mapEntity.mTeam = (AvHTeamNumber)(theBaseEntity->pev->team); mapEntity.mSquadNumber = 0; mapEntity.mUnderAttack = theEntityIsUnderAttack ? 1 : 0; bool sendEntity = false; if (mapEntity.mUser3 == AVH_USER3_HIVE) { if (!theEntityIsVisible) { mapEntity.mTeam = TEAM_IND; } sendEntity = true; } else if (mapEntity.mUser3 == AVH_USER3_WELD) { vec3_t theEntityOrigin = AvHSHUGetRealLocation(theBaseEntity->pev->origin, theBaseEntity->pev->mins, theBaseEntity->pev->maxs); mapEntity.mX = theEntityOrigin.x; mapEntity.mY = theEntityOrigin.y; sendEntity = true; } else if (mapEntity.mUser3 == AVH_USER3_FUNC_RESOURCE) { sendEntity = true; } else if (theEntityIsVisible && !(theBaseEntity->pev->effects & EF_NODRAW) && !theIsTransient) { AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theBaseEntity); if (thePlayer) { ASSERT(theEntityIndex > 0); ASSERT(theEntityIndex <= 32); mapEntity.mSquadNumber = GetHotkeyGroupContainingPlayer(thePlayer) + 1; if ((thePlayer->GetPlayMode() == PLAYMODE_PLAYING) && !thePlayer->GetIsSpectator()) { sendEntity = true; // If the player has the heavy armor upgrade switch the // user3 to something that will let us reconstruct that later. if (thePlayer->pev->iuser3 == AVH_USER3_MARINE_PLAYER && GetHasUpgrade(thePlayer->pev->iuser4, MASK_UPGRADE_13)) { mapEntity.mUser3 = AVH_USER3_HEAVY; } } } else { if (mapEntity.mUser3 != AVH_USER3_HEAVY) { sendEntity = true; } } } if (sendEntity) { //const AvHMapExtents& theMapExtents = GetGameRules()->GetMapExtents(); // commented this out here, commented out corresponding shift in AvHOverviewMap::Draw at line 771 // float theMinMapX = theMapExtents.GetMinMapX(); // float theMinMapY = theMapExtents.GetMinMapY(); // mapEntity.mX -= theMinMapX; // mapEntity.mY -= theMinMapY; mEntityList[theEntityIndex] = mapEntity; // debug the entity hierarchy message size // if ( mapEntity.mUser3 == AVH_USER3_COMMANDER_STATION ) { // for (int i=0; i<200; i++ ) { // mEntityList[100+i] = mapEntity; // } // } } } }
void AvHEntityHierarchy::BuildFromTeam(const AvHTeam* inTeam, BaseEntityListType& inBaseEntityList) { this->Clear(); int mc=0, sc=0, dc=0; if (inTeam->GetTeamType() == AVH_CLASS_TYPE_MARINE || inTeam->GetTeamType() == AVH_CLASS_TYPE_ALIEN) { // Loop through all entities in the world for(BaseEntityListType::iterator theIter = inBaseEntityList.begin(); theIter != inBaseEntityList.end(); theIter++) { CBaseEntity* theBaseEntity = *theIter; int theEntityIndex = theBaseEntity->entindex(); bool theEntityIsVisible = (theBaseEntity->pev->team == (int)(inTeam->GetTeamNumber())) || GetHasUpgrade(theBaseEntity->pev->iuser4, MASK_VIS_SIGHTED); bool theEntityIsDetected = GetHasUpgrade(theBaseEntity->pev->iuser4, MASK_VIS_DETECTED); bool theEntityIsUnderAttack = GetGameRules()->GetIsEntityUnderAttack(theEntityIndex); if ( theEntityIsUnderAttack ) { int a=0; } // Don't send ammo, health, weapons, or scans bool theIsTransient = ((AvHUser3)(theBaseEntity->pev->iuser3) == AVH_USER3_MARINEITEM) || (theBaseEntity->pev->classname == MAKE_STRING(kwsScan)); if ( inTeam->GetTeamType() == AVH_CLASS_TYPE_ALIEN && theBaseEntity->pev->team == (int)(inTeam->GetTeamNumber()) ) { AvHBuildable *theBuildable=dynamic_cast<AvHBuildable *>(theBaseEntity); if ( theBuildable && theBuildable->GetHasBeenBuilt() ) { if ( theBaseEntity->pev->iuser3 == AVH_USER3_MOVEMENT_CHAMBER ) { mc++; } if ( theBaseEntity->pev->iuser3 == AVH_USER3_SENSORY_CHAMBER ) { sc++; } if ( theBaseEntity->pev->iuser3 == AVH_USER3_DEFENSE_CHAMBER ) { dc++; } } } MapEntity mapEntity; mapEntity.mX = theBaseEntity->pev->origin.x; mapEntity.mY = theBaseEntity->pev->origin.y; mapEntity.mUser3 = (AvHUser3)(theBaseEntity->pev->iuser3); // Don't draw detected blips as their real selves if(!theEntityIsVisible && theEntityIsDetected) mapEntity.mUser3 = AVH_USER3_UNKNOWN; mapEntity.mAngle = theBaseEntity->pev->angles[1]; mapEntity.mTeam = (AvHTeamNumber)(theBaseEntity->pev->team); mapEntity.mSquadNumber = 0; mapEntity.mUnderAttack = theEntityIsUnderAttack ? 1 : 0; bool sendEntity = false; if (mapEntity.mUser3 == AVH_USER3_HIVE) { if (!theEntityIsVisible) { mapEntity.mTeam = TEAM_IND; } sendEntity = true; } else if (mapEntity.mUser3 == AVH_USER3_WELD) { vec3_t theEntityOrigin = AvHSHUGetRealLocation(theBaseEntity->pev->origin, theBaseEntity->pev->mins, theBaseEntity->pev->maxs); mapEntity.mX = theEntityOrigin.x; mapEntity.mY = theEntityOrigin.y; sendEntity = true; } else if (mapEntity.mUser3 == AVH_USER3_FUNC_RESOURCE) { sendEntity = true; } else if ((theEntityIsVisible || theEntityIsDetected) && !(theBaseEntity->pev->effects & EF_NODRAW) && !theIsTransient) { AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theBaseEntity); if (thePlayer) { ASSERT(theEntityIndex > 0); ASSERT(theEntityIndex <= 32); mapEntity.mSquadNumber = GetHotkeyGroupContainingPlayer(thePlayer) + 1; if ((thePlayer->GetPlayMode() == PLAYMODE_PLAYING) && !thePlayer->GetIsSpectator()) { sendEntity = true; // If the player has the heavy armor upgrade switch the // user3 to something that will let us reconstruct that later. if (thePlayer->pev->iuser3 == AVH_USER3_MARINE_PLAYER && GetHasUpgrade(thePlayer->pev->iuser4, MASK_UPGRADE_13)) { mapEntity.mUser3 = AVH_USER3_HEAVY; } } } else { if (mapEntity.mUser3 != AVH_USER3_HEAVY) { sendEntity = true; } } } if (sendEntity) { const AvHMapExtents& theMapExtents = GetGameRules()->GetMapExtents(); // commented this out here, commented out corresponding shift in AvHOverviewMap::Draw at line 771 // float theMinMapX = theMapExtents.GetMinMapX(); // float theMinMapY = theMapExtents.GetMinMapY(); // mapEntity.mX -= theMinMapX; // mapEntity.mY -= theMinMapY; mEntityList[theEntityIndex] = mapEntity; } } if ( inTeam->GetTeamType() == AVH_CLASS_TYPE_ALIEN ) { sc=min(3, sc); dc=min(3,dc); mc=min(3,mc); if ( this->mNumSensory != sc || this->mNumDefence != dc || this->mNumMovement != mc ) { this->mNumSensory=sc; this->mNumDefence=dc; this->mNumMovement=mc; } } } }
char* AvHMarineWeapon::GetActiveViewModel() const { char* theViewModel = this->GetViewModel(); // If we're a marine with heavy armor, use the heavy view model if(this->m_pPlayer && (this->m_pPlayer->pev->iuser3 == AVH_USER3_MARINE_PLAYER || this->m_pPlayer->pev->iuser3 == AVH_USER3_COMMANDER_PLAYER) && (GetHasUpgrade(this->m_pPlayer->pev->iuser4, MASK_UPGRADE_13))) { char* theHeavyViewModel = this->GetHeavyViewModel(); if(theHeavyViewModel) { theViewModel = theHeavyViewModel; } } return theViewModel; }
int AvHGetNumUpgradesInCategory(AvHAlienUpgradeCategory inUpgradeCategory, int inUser4) { int theNumUpgrades = 0; ASSERT(inUpgradeCategory != ALIEN_UPGRADE_CATEGORY_INVALID); switch(inUpgradeCategory) { case ALIEN_UPGRADE_CATEGORY_DEFENSE: theNumUpgrades = 0; theNumUpgrades += (GetHasUpgrade(inUser4, MASK_UPGRADE_1) || GetHasUpgrade(inUser4, MASK_UPGRADE_2) || GetHasUpgrade(inUser4, MASK_UPGRADE_3)) ? 1 : 0; if(GetHasUpgrade(inUser4, MASK_UPGRADE_10)) { theNumUpgrades = 2; } else if(GetHasUpgrade(inUser4, MASK_UPGRADE_11)) { theNumUpgrades = 3; } break; // case ALIEN_UPGRADE_CATEGORY_OFFENSE: // theNumUpgrades = 0; // theNumUpgrades += (GetHasUpgrade(inUser4, MASK_PLACEHOLDER1) || GetHasUpgrade(inUser4, MASK_PLACEHOLDER2) || GetHasUpgrade(inUser4, MASK_PLACEHOLDER3)) ? 1 : 0; // TODO: Add these when neeeded //theNumUpgrades += GetHasUpgrade(inUser4, MASK_UPGRADE_10) ? 1 : 0; //theNumUpgrades += GetHasUpgrade(inUser4, MASK_UPGRADE_11) ? 1 : 0; // break; case ALIEN_UPGRADE_CATEGORY_MOVEMENT: theNumUpgrades = 0; theNumUpgrades += (GetHasUpgrade(inUser4, MASK_UPGRADE_4) || GetHasUpgrade(inUser4, MASK_UPGRADE_5) || GetHasUpgrade(inUser4, MASK_UPGRADE_6)) ? 1 : 0; if(GetHasUpgrade(inUser4, MASK_UPGRADE_12)) { theNumUpgrades = 2; } else if(GetHasUpgrade(inUser4, MASK_UPGRADE_13)) { theNumUpgrades = 3; } break; case ALIEN_UPGRADE_CATEGORY_SENSORY: theNumUpgrades = 0; theNumUpgrades += (GetHasUpgrade(inUser4, MASK_UPGRADE_7) || GetHasUpgrade(inUser4, MASK_UPGRADE_8) || GetHasUpgrade(inUser4, MASK_UPGRADE_9)) ? 1 : 0; if(GetHasUpgrade(inUser4, MASK_UPGRADE_14)) { theNumUpgrades = 2; } else if(GetHasUpgrade(inUser4, MASK_UPGRADE_15)) { theNumUpgrades = 3; } break; } return theNumUpgrades; }
bool AvHBaseBuildable::GetIsRecycling() const { return GetHasUpgrade(this->pev->iuser4, MASK_RECYCLING); }