本文整理汇总了C++中GetGameRules函数的典型用法代码示例。如果您正苦于以下问题:C++ GetGameRules函数的具体用法?C++ GetGameRules怎么用?C++ GetGameRules使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetGameRules函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BALANCE_VAR
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();
}
}
示例2: GetGameRules
void AvHHive::SetHasBeenBuilt()
{
AvHBuildable::SetHasBeenBuilt();
GetGameRules()->TriggerAlert((AvHTeamNumber)this->pev->team, ALERT_HIVE_COMPLETE, this->entindex());
// Make hive support any unassigned upgrade technologies (happens after a hive supporting a technology is destroyed and then rebuilt)
AvHTeamNumber theTeam = (AvHTeamNumber)this->pev->team;
AvHTeam* theTeamPointer = GetGameRules()->GetTeam(theTeam);
if(theTeamPointer)
{
AvHAlienUpgradeListType theUpgrades = theTeamPointer->GetAlienUpgrades();
if(AvHGetNumUpgradesInCategoryInList(theUpgrades, ALIEN_UPGRADE_CATEGORY_DEFENSE) > 0)
{
AvHSUUpdateHiveTechology(theTeam, ALIEN_BUILD_DEFENSE_CHAMBER);
}
if(AvHGetNumUpgradesInCategoryInList(theUpgrades, ALIEN_UPGRADE_CATEGORY_MOVEMENT) > 0)
{
AvHSUUpdateHiveTechology(theTeam, ALIEN_BUILD_MOVEMENT_CHAMBER);
}
if(AvHGetNumUpgradesInCategoryInList(theUpgrades, ALIEN_UPGRADE_CATEGORY_SENSORY) > 0)
{
AvHSUUpdateHiveTechology(theTeam, ALIEN_BUILD_SENSORY_CHAMBER);
}
}
}
示例3: GetGameRules
void AvHBaseBuildable::BuildableTouch(CBaseEntity* inEntity)
{
if(inEntity->pev->team != this->pev->team)
{
this->Uncloak();
// GHOSTBUILDING: Destroy and return res.
if (this->mGhost && inEntity->IsAlive() && inEntity->IsPlayer())
{
this->TakeDamage(inEntity->pev, this->pev, 80000, DMG_GENERIC);
AvHTeam* theTeam = GetGameRules()->GetTeam(AvHTeamNumber(this->pev->team));
if (theTeam)
{
float thePercentage = .8f;
float thePointsBack = GetGameRules()->GetCostForMessageID(this->mMessageID) * thePercentage;
theTeam->SetTeamResources(theTeam->GetTeamResources() + thePointsBack);
AvHSUPlayNumericEventAboveStructure(thePointsBack, this);
}
// Uncloak the player
AvHCloakable *theCloakable=dynamic_cast<AvHCloakable *>(inEntity);
if ( theCloakable ) {
theCloakable->Uncloak();
}
}
}
}
示例4: Vector
void AvHHive::HiveAliveThink(void)
{
// For some reason, velocity is non-zero when created (meant they were showing up on motion-tracking)
this->pev->velocity = Vector(0, 0, 0);
if(GetGameRules()->GetGameStarted())
{
if(!this->mActive)
{
bool theIsBuilding, theIsResearching;
float thePercentage;
AvHSHUGetBuildResearchState(this->pev->iuser3, this->pev->iuser4, this->pev->fuser1, theIsBuilding, theIsResearching, thePercentage);
float theBuildTime = GetGameRules()->GetBuildTimeForMessageID(this->GetMessageID());
float theBuildPercentage = kHiveAliveThinkInterval/theBuildTime;
float theNewPercentage = min(thePercentage + theBuildPercentage, 1.0f);
this->SetNormalizedBuildPercentage(theNewPercentage);
}
else
{
this->ProcessHealing();
// Play idle anims
AvHBaseBuildable::AnimateThink();
}
this->UpdateReinforcements();
//this->UpdateUmbra();
}
// Set next think
this->pev->nextthink = gpGlobals->time + kHiveAliveThinkInterval;
}
示例5: processBalanceChange
void AvHTechTree::processBalanceChange(void)
{
// Run through our tech nodes and update cost and build time
TechNodeMap::iterator current, end = mNodesByMsg.end();
for( current = mNodesByMsg.begin(); current != end; ++current )
{
current->second->setBuildTime(GetGameRules()->GetBuildTimeForMessageID(current->first));
current->second->setCost(GetGameRules()->GetCostForMessageID(current->first));
}
}
示例6: GetGameRules
void AvHBaseBuildable::UpdateDamageEffects()
{
if(GetGameRules()->GetGameStarted() && this->GetIsBuilt())
{
// Add special effects for structures that are hurt or almost dead
float theMaxHealth = GetGameRules()->GetBaseHealthForMessageID(this->GetMessageID());
float theHealthScalar = this->pev->health/theMaxHealth;
float theTimeInterval = max(gpGlobals->time - this->mTimeOfLastDamageUpdate, .1f);
const float kParticleSystemLifetime = 5.0f;
int theAverageSoundInterval = -1;
// If we're at 25% health or less, emit black smoke
if(gpGlobals->time > (this->mTimeOfLastDamageEffect + kParticleSystemLifetime))
{
if(theHealthScalar < .25f)
{
AvHSUPlayParticleEvent(kpsBuildableLightDamage, this->edict(), this->pev->origin);
this->mTimeOfLastDamageEffect = gpGlobals->time;
theAverageSoundInterval = 3;
}
// If we're at 50% health or less, emit light smoke
else if(theHealthScalar < .5f)
{
AvHSUPlayParticleEvent(kpsBuildableLightDamage, this->edict(), this->pev->origin);
this->mTimeOfLastDamageEffect = gpGlobals->time;
theAverageSoundInterval = 5;
}
}
// If we're at less then 75% health, spark occasionally
if(theHealthScalar < .75f)
{
int theRandomChance = RANDOM_LONG(0, (float)8/theTimeInterval);
if(theRandomChance == 0)
{
UTIL_Sparks(this->pev->origin);
UTIL_Sparks(this->pev->origin);
const char* theHurtSoundToPlay = kBuildableHurt1Sound;
if(RANDOM_LONG(0, 1) == 1)
{
theHurtSoundToPlay = kBuildableHurt2Sound;
}
float theVolume = .3f;
EMIT_SOUND(this->edict(), CHAN_AUTO, theHurtSoundToPlay, theVolume, ATTN_NORM);
}
}
this->mTimeOfLastDamageUpdate = gpGlobals->time;
}
}
示例7: compareWorldChecksum
// takes filename, returns whether errors were encountered, returns whether checksums are identical or not
static int compareWorldChecksum(lua_State* inState)
{
bool theSuccess = false;
bool theChecksumsAreEqual = false;
const char* theFileName = lua_tostring(inState, 1);
Checksum theOldChecksum;
theSuccess = theOldChecksum.ReadFromFile(theFileName);
Checksum theNewChecksum;
GetGameRules()->ComputeWorldChecksum(theNewChecksum);
if(theSuccess)
{
StringList theErrors;
theChecksumsAreEqual = theNewChecksum.Compare(theOldChecksum, theErrors);
}
// Return function success
lua_pushnumber(inState, theSuccess);
// Return checksums are equal
lua_pushnumber(inState, theChecksumsAreEqual);
return 2;
}
示例8: MAKE_STRING
void AvHUmbraProjectile::Spawn(void)
{
this->Precache();
CBaseEntity::Spawn();
this->pev->movetype = MOVETYPE_FLY;
this->pev->classname = MAKE_STRING(kwsUmbraProjectile);
SET_MODEL(ENT(this->pev), kClientUmbraSprite);
this->pev->solid = SOLID_BBOX;
if(!GetGameRules()->GetDrawInvisibleEntities())
{
this->pev->effects = EF_NODRAW;
}
else
{
this->pev->frame = 0;
this->pev->scale = 0.5;
this->pev->rendermode = kRenderTransAlpha;
this->pev->renderamt = 255;
}
UTIL_SetSize(this->pev, Vector( 0, 0, 0), Vector(0, 0, 0));
SetTouch(&AvHUmbraProjectile::UmbraTouch);
}
示例9: MAKE_STRING
void AvHHive::Spawn()
{
this->Precache();
AvHBaseBuildable::Spawn();
this->pev->classname = MAKE_STRING(kesTeamHive);
//this->pev->movetype = MOVETYPE_FLY;
this->pev->movetype = MOVETYPE_FLY;
this->pev->solid = SOLID_NOT;
this->pev->flags = 0;
this->pev->iuser3 = AVH_USER3_HIVE;
this->mMaxHitPoints = GetGameRules()->GetBaseHealthForMessageID(ALIEN_BUILD_HIVE);
SET_MODEL( ENT(this->pev), kHiveModel);
//this->pev->scale = 2;
// this->pev->sequence = 0;
// this->pev->frame = 0;
// ResetSequenceInfo();
this->ResetEntity();
}
示例10: GetGameRules
void AvHResearchManager::UpdateResearch()
{
// Run through every item in the list and update research, marking any done
for(ResearchListType::iterator theIter = this->mResearchingTech.begin(); theIter != this->mResearchingTech.end(); )
{
if(theIter->GetCanEntityContinueResearch())
{
bool theHighTechCheat = GetGameRules()->GetIsCheatEnabled(kcHighTech);
if(theIter->UpdateResearch() || theHighTechCheat)
{
AvHMessageID theResearchingTech = theIter->GetResearching();
int theEntityIndex = theIter->GetEntityIndex();
this->SetResearchDone(theResearchingTech, theEntityIndex);
theIter = this->mResearchingTech.erase(theIter);
}
else
{
theIter++;
}
}
else
{
theIter = this->mResearchingTech.erase(theIter);
}
}
}
示例11: GetGameRules
void HolidayManager::HookIfNecessary()
{
// Already hooked
if (m_iHookID)
return;
// Nothing wants us
if (m_isHolidayForward->GetFunctionCount() == 0)
return;
void *pGameRules = GetGameRules();
if (!pGameRules)
{
if (m_bInMap)
{
g_pSM->LogError(myself, "Gamerules ptr not found. TF2_OnIsHolidayActive will not be available.");
}
return;
}
static int offset = -1;
if (offset == -1)
{
if (!g_pGameConf->GetOffset("IsHolidayActive", &offset))
{
g_pSM->LogError(myself, "IsHolidayActive gamedata offset missing. TF2_OnIsHolidayActive will not be available.");
return;
}
SH_MANUALHOOK_RECONFIGURE(IsHolidayActive, offset, 0, 0);
}
m_iHookID = SH_ADD_MANUALHOOK(IsHolidayActive, pGameRules, SH_MEMBER(this, &HolidayManager::Hook_IsHolidayActive), false);
}
示例12: MAKE_STRING
void AvHSpike::Spawn()
{
this->Precache();
CBaseEntity::Spawn();
this->pev->movetype = MOVETYPE_FLY;
this->pev->classname = MAKE_STRING(kSpikeProjectileClassName);
SET_MODEL(ENT(this->pev), kSpikeProjectileModel);
this->pev->solid = SOLID_BBOX;
this->mDamage = 0.0f;
// Comment out effects line, uncomment next four, then comment out creation of temp entity in EV_SpikeGun to see server side Spike for testing
if(!GetGameRules()->GetDrawInvisibleEntities())
{
this->pev->effects = EF_NODRAW;
}
else
{
this->pev->frame = 0;
this->pev->scale = 0.5;
this->pev->rendermode = kRenderTransAlpha;
this->pev->renderamt = 255;
}
//UTIL_SetSize(this->pev, Vector( 0, 0, 0), Vector(0, 0, 0));
// UTIL_SetSize(this->pev, Vector( -16, -16, -16), Vector(16, 16, 16));
//UTIL_SetSize(this->pev, Vector( -50, -50, -50), Vector(50, 50, 50));
SetTouch(&AvHSpike::SpikeTouch);
// Enforce short range
SetThink(&AvHSpike::SpikeDeath);
this->pev->nextthink = gpGlobals->time + kSpikeLifetime;
}
示例13: AvHBuildable
AvHBaseBuildable::AvHBaseBuildable(AvHTechID inTechID, AvHMessageID inMessageID, char* inClassName, int inUser3) : AvHBuildable(inTechID), kStartAlpha(128), mAverageUseSoundLength(.5f)
{
this->mClassName = inClassName;
this->mMessageID = inMessageID;
this->mBaseHealth = GetGameRules()->GetBaseHealthForMessageID(inMessageID);
char* theModelName = AvHSHUGetBuildTechModelName(inMessageID);
ASSERT(theModelName);
this->mModelName = theModelName;
this->mSelectID = inUser3;
this->mTimeToConstruct = GetGameRules()->GetBuildTimeForMessageID(inMessageID);
// Very important that this doesn't go in Init(), else mapper-placed structures disappear on map-reset
this->mPersistent = false;
this->Init();
}
示例14: GetGameRules
void AvHBuildable::TriggerAddTech() const
{
AvHTeamNumber theTeamNumber = this->GetTeamNumber();
AvHTeam* theTeam = GetGameRules()->GetTeam(theTeamNumber);
if(theTeam)
{
theTeam->TriggerAddTech(this->mTechID);
}
}
示例15: InitializeBuildable
// Requires mSelectID and mMessageID to be set
// Sets the pev user variables, mBaseHealth, pev->health and pev->armorvalue
void AvHBaseBuildable::InternalInitializeBuildable()
{
// Always buildable
InitializeBuildable(this->pev->iuser3, this->pev->iuser4, this->pev->fuser1, this->mSelectID);
this->mBaseHealth = GetGameRules()->GetBaseHealthForMessageID(this->mMessageID);
this->pev->health = this->mBaseHealth*kBaseHealthPercentage;
this->pev->max_health = this->mBaseHealth;
// Store max health in armorvalue
//this->pev->armorvalue = GetGameRules()->GetBaseHealthForMessageID(this->mMessageID);
}