int CItemEnhancement::GetDamageAdj (const DamageDesc &Damage) const // GetDamageAdj // // Returns the damage adjustment confered by this mod { switch (GetType()) { case etResist: return Level2DamageAdj(GetLevel(), IsDisadvantage()); case etResistEnergy: return (Damage.IsEnergyDamage() ? Level2DamageAdj(GetLevel(), IsDisadvantage()) : 100); case etResistMatter: return (Damage.IsMatterDamage() ? Level2DamageAdj(GetLevel(), IsDisadvantage()) : 100); case etResistByLevel: { if (Damage.GetDamageType() == GetDamageType() || Damage.GetDamageType() == GetDamageType() + 1) return Level2DamageAdj(GetLevel(), IsDisadvantage()); else return 100; } case etResistByDamage: return (Damage.GetDamageType() == GetDamageType() ? Level2DamageAdj(GetLevel(), IsDisadvantage()) : 100); case etResistByDamage2: { if (Damage.GetDamageType() == GetDamageType()) // 0 = 100 100 // 1 = 90 111 // 2 = 80 125 // 3 = 70 143 return Level2DamageAdj(GetLevel(), IsDisadvantage()); else if (Damage.GetDamageType() == GetDamageType() + 2) // 0 = 100 100 // 1 = 95 105 // 2 = 90 112 // 3 = 85 121 return 100 + ((Level2DamageAdj(GetLevel(), IsDisadvantage()) - 100) / 2); else return 100; } default: return 100; } }
void UIListTreeType::SetTree(UIListGenericTree *toplevel) { if (treetop) { listLevels.clear(); currentlevel = NULL; treetop = NULL; currentpos = NULL; levels = 0; curlevel = -1; } levels = - 1; currentpos = (UIListGenericTree *)toplevel->getChildAt(0); if (!currentpos) { // // Not really an error, as UIListTreeType is perfectly capable of drawing an empty list. // // cerr << "No top-level children?\n"; return; } treetop = toplevel; CreateLevel(0); currentlevel = GetLevel(0); if (!currentlevel) { cerr << "Something is seriously wrong (currentlevel = NULL)\n"; return; } FillLevelFromTree(toplevel, currentlevel); currentlevel->SetVisible(true); currentlevel->SetActive(true); currentpos = (UIListGenericTree *)(currentlevel->GetItemFirst()->getData()); curlevel = 0; emit requestUpdate(); emit itemEntered(this, currentpos); }
int GetLevel(int v, const ClusterStructure& clusterStructure, std::vector<int>& levels) { if (levels[v] != -1) return levels[v]; auto vCluster = clusterStructure.GetVertexInfos()[v].clusterIndex; auto pivotVertex = clusterStructure.GetClusterInfos()[vCluster].cycleStates.front(); int level = 0; if (v == pivotVertex) level = 0; else level = GetLevel(clusterStructure.GetSingleLetterGraph()[v], clusterStructure, levels) + 1; levels[v] = level; return level; }
int32 Client::GetACMit() { int mitigation = 0; if (m_pp.class_ == WIZARD || m_pp.class_ == MAGICIAN || m_pp.class_ == NECROMANCER || m_pp.class_ == ENCHANTER) { mitigation = (GetSkill(SkillDefense))/4 + (itembonuses.AC+1); mitigation -= 4; } else { mitigation = (GetSkill(SkillDefense))/3 + ((itembonuses.AC*4)/3); if(m_pp.class_ == MONK) mitigation += GetLevel() * 13/10; //the 13/10 might be wrong, but it is close... } return(mitigation*1000/847); }
void Game::SaveMap(string PathToMap) { ofstream File(PathToMap + "Enemies.txt"); File.clear(); for(auto itr = Enemies.begin(); itr != Enemies.end(); ++itr) { File << itr->ID << " " << itr->GetAttack() << " " << itr->GetDefense() << " " << itr->GetHealth() << " " << itr->GetLevel() << " " << RemoveSpaces(itr->GetName()) << " " << itr->GetWealth() << " " << itr->GetX() << " " << itr->GetY() << " " << itr->MapTextureFileName << " " << itr->Combat << endl; } File.close(); File.open(PathToMap + "RandomEncounters.txt"); File.clear(); for(auto itr = RandomEncounters.begin(); itr != RandomEncounters.end(); ++itr) { File << itr->ID << " " << itr->GetAttack() << " " << itr->GetDefense() << " " << itr->GetHealth() << " " << itr->GetLevel() << " " << RemoveSpaces(itr->GetName()) << " " << itr->GetWealth() << " " << itr->Combat << endl; } File.close(); File.open(PathToMap + "QuestGivers.txt"); File.clear(); for(auto itr = QuestGivers.begin(); itr != QuestGivers.end(); ++itr) { File << itr->ID << " " << itr->x << " " << itr->y << " " << itr->TextureFileName << " " << itr->Quests.size(); for(auto iitr = itr->Quests.begin(); iitr != itr->Quests.end(); ++iitr) { File << " " << iitr->ID; } File << endl; } File.close(); }
void qCtx::Parse(qStr *in, qStr *out) { if (GetLevel() > myEnv->GetMaxLevels()) { CStr s; while (!(s = in->GetS()).IsEmpty()) { out->PutS(s); } Throw(out, 99, "Maximum nesting level reached."); } else { char c; while ( (c = in->GetC()) != EOF ) { ParseC(in, out, c); } } }
int StoneMine::GameMsg(int msg, int par1, void * par2, uint npar2) { #ifndef BECHER_EDITOR switch (msg) { case BMSG_Select: GetLevel()->GetPanel()->SetObjectHud("scripts/mine.menu",this); GetLua()->func("s_stonemine"); break; case BMSG_GetSur: return -1; } #endif return SourceBuilding::GameMsg(msg, par1, par2, npar2); }
bool Conditional::Elif(bool b) { Level *l = GetLevel(); if (!l->fElseAllowed) return false; if (l->fState == Level::kPending) { l->fState = (b ? Level::kActive : Level::kPending); } else l->fState = Level::kInactive; return true; }
//! 判断当前能否解散 eFactionOptErrInfo GameFaction::CanDisban(void) { LONG lNeedLevel = COrganizingParam::getInstance().GetFacPurviewNeedLevel(eFPI_Disband); if (lNeedLevel > GetLevel(eUT_FactionLevel)) { return eFOEI_Err_Level_Noenough; } if(NULL_GUID != m_FacBaseData.SuperiorGuid) { return eFOEI_Err_HadUnion; } return eFOEI_NotErr; }
int CItemEnhancement::GetEnhancedRate (int iRate) const // GetEnhancedRate // // Returns the enhanced rate { switch (GetType()) { case etSpeed: return Max(1, (iRate * Level2DamageAdj(GetLevel(), IsDisadvantage()) + 50) / 100); default: return iRate; } }
int CItemEnhancement::GetActivateRateAdj (void) const // GetActivateRateAdj // // Returns the adj to activate/fire delay { switch (GetType()) { case etSpeed: return Level2DamageAdj(GetLevel(), IsDisadvantage()); default: return 100; } }
int CItemEnhancement::GetDamageBonus (void) const // GetDamageBonus // // Returns the damage bonus for the weapon { switch (GetType()) { case etStrengthen: return Level2Bonus(GetLevel(), IsDisadvantage()); default: return 0; } }
int32 Client::CalcBaseManaRegen() { uint8 clevel = GetLevel(); int32 regen = 0; if (IsSitting() || (GetHorseId() != 0)) { if(HasSkill(SkillMeditate)) regen = (((GetSkill(SkillMeditate) / 10) + (clevel - (clevel / 4))) / 4) + 4; else regen = 2; } else { regen = 2; } return regen; }
int CGridTreeCellBase::GetTreeIndent() // returns: device units to indent within a cell for a tree at this level { ASSERT( m_pTreeColumn != NULL); CGridCtrl* pGridCtrl = GetGrid(); ASSERT( pGridCtrl != NULL); unsigned char ucLevel = GetLevel(); if( ucLevel == 0) return 0; if( !m_pTreeColumn->GetTreeLines() ) ucLevel--; return (m_pTreeColumn->GetDefTreeIndent() * ucLevel) + (pGridCtrl->GetDefCellMargin() * 2); }
bool Client::UseDiscipline(uint8 disc_id) { // Dont let client waste a reuse timer if they can't use the disc if (IsStunned() || IsFeared() || IsMezzed() || IsAmnesiad() || IsPet()) { return(false); } //Check the disc timer uint32 remain = p_timers.GetRemainingTime(pTimerDisciplineReuseStart); if(remain > 0 && !GetGM()) { char val1[20]= {0}; char val2[20]= {0}; Message_StringID(CC_User_Disciplines, DISCIPLINE_CANUSEIN, ConvertArray((remain)/60,val1), ConvertArray(remain%60,val2)); return(false); } bool active = disc_ability_timer.Enabled(); if(active) { Message(CC_User_Disciplines, "You must wait before using this discipline."); //find correct message return(false); } //can we use the disc? the client checks this for us, but we should also confirm server side. uint8 level_to_use = DisciplineUseLevel(disc_id); if(level_to_use > GetLevel() || level_to_use == 0) { Message_StringID(CC_User_Disciplines, DISC_LEVEL_USE_ERROR); return(false); } // Disciplines with no ability timer (ashenhand, silentfist, thunderkick, and unholyaura) will remain on the player until they either // use the skill the disc affects successfully, camp/zone, or attempt to use another disc. If we're here, clear that disc so they can // cast a new one. if(GetActiveDisc() != 0) { Log.Out(Logs::General, Logs::Discs, "Clearing disc %d so that disc %d can be cast.", GetActiveDisc(), disc_id); FadeDisc(); } //cast the disc if(CastDiscipline(disc_id, level_to_use)) return(true); else return(false); }
RealFde CFormulaNode::getAscent( const SizeFde &sz ) { RealFde vc = sz.height() / 2.0; switch( getAlignmentType() ) { case FBtnChildPos::TableCenter2Baseline: if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() ) { CNode *pNode = GetChild( getAlignmentValue() - 1 ); if( pNode != NULL ) vc = pNode->GetPosition().y() + pNode->GetSize().height() / 2.0; } break; case FBtnChildPos::TableTop2Baseline: if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() ) { CNode *pNode = GetChild( getAlignmentValue() - 1 ); if( pNode != NULL ) vc = pNode->GetPosition().y(); else vc = 0.0; } else vc = 0.0; break; case FBtnChildPos::TableBottom2Baseline: if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() ) { CNode *pNode = GetChild( getAlignmentValue() - 1 ); if( pNode != NULL ) vc = pNode->GetPosition().y() + pNode->GetSize().height(); else vc = sz.height(); } else vc = sz.height(); break; default: vc = sz.height() - ::calculateCurrentTextDescent( GetLevel() ); break; } return vc; }
bool IRCCmd::CanUse(std::string USER, int nLevel) { if(IsLoggedIn(USER)) { if(GetLevel(USER) >= nLevel) return true; else return false; } else if(nLevel == 0) { return true; } else sIRC.Send_IRC_Channel(USER, "\0034[ERROR] : You Are Not Logged In!", true, "ERROR"); return false; }
TError TContainerHolder::Create(TScopedLock &holder_lock, const std::string &name, const TCred &cred, std::shared_ptr<TContainer> &container) { TError error; error = ValidName(name); if (error) return error; if (Containers.find(name) != Containers.end()) return TError(EError::ContainerAlreadyExists, "container " + name + " already exists"); if (Containers.size() + 1 > config().container().max_total()) return TError(EError::ResourceNotAvailable, "number of created containers exceeds limit"); auto parent = GetParent(name); if (!parent && name != ROOT_CONTAINER) return TError(EError::InvalidValue, "invalid parent container"); if (parent && parent->GetLevel() == CONTAINER_LEVEL_MAX) return TError(EError::InvalidValue, "You shall not go deeper!"); if (parent && !parent->IsRoot() && !parent->IsPortoRoot()) { error = parent->CheckPermission(cred); if (error) return error; } int id; error = IdMap.Get(id); if (error) return error; auto c = std::make_shared<TContainer>(shared_from_this(), Storage, name, parent, id); error = c->Create(cred); if (error) return error; Containers[name] = c; Statistics->Created++; if (parent) parent->AddChild(c); container = c; return TError::Success(); }
void CRPGPlayer::ShowSkillMenu() { if (GetCurrentClass() == RPG_CLASS_NONE ) { ShowClassMenu( GetPlayerInfo()->GetTeamIndex()); return; } if (GetFreeSkills() < 0) { ResetAccount(); gamehelpers->TextMsg(GetIndex(), HUD_PRINTTALK, "[ZPS-RPG] Your skills have been reset because of an error.\n"); } IMenuStyle *style = menus->GetDefaultStyle(); IBaseMenu *menu = style->CreateMenu(&g_RPGPlugin, myself->GetIdentity()); menu->SetDefaultTitle(MENU_SKILL_TITLE); char skillname[64]; unsigned int menustyle = ITEMDRAW_DEFAULT; for (int i = 0; i < MAX_SKILLS; i++) { sprintf(skillname, "%s (Level %d)", SkillNames[skills[i].iIndex], skills[i].iLevel); menustyle = ITEMDRAW_DEFAULT; if ((skills[i].iLevel >= 3) || (GetFreeSkills() == 0)) menustyle = ITEMDRAW_DISABLED; if( i == 3 ) // ULTIMATE { if ((skills[i].iLevel >= 1) || (GetLevel() < 6) || (GetFreeSkills() == 0)) { menustyle = ITEMDRAW_DISABLED; } } menu->AppendItem(SkillNames[skills[i].iIndex], ItemDrawInfo(skillname, menustyle)); } menu->AppendItem(MENU_ITEM_RESET, ItemDrawInfo("Reset Skills")); menu->InsertItem(6, MENU_ITEM_RETURN, ItemDrawInfo(MENU_ITEM_RETURN)); menu->SetMenuOptionFlags( menu->GetMenuOptionFlags() | MENUFLAG_BUTTON_EXIT ); menu->Display(this->GetIndex(), MENU_TIME_FOREVER); }
void Level1::Update() { LOG_D("[Level1] Updating"); auto cells = Engine::GetInstance().GetAllEntitiesWithComponentOfClass("GrowthComponent"); for (int i = cells.size(); i < CFG_GETI("LEVEL_1_INITIAL_NUM_CELLS"); ++i) { Random r; float x = r.GenerateFloat(CFG_GETF("LEVEL_1_MIN_X"), CFG_GETF("LEVEL_1_MAX_X")); float y = r.GenerateFloat(CFG_GETF("LEVEL_1_MIN_Y"), CFG_GETF("LEVEL_1_MAX_Y")); auto cell = EntityFactory::CreateCell(Vector(x, y)); auto growthComponent = std::static_pointer_cast<GrowthComponent>(Engine::GetInstance().GetEntityManager()->GetSingleComponentOfClass(cell, "GrowthComponent")); if (r.GenerateFloat() < 0.1) growthComponent->SetLevel(2); Engine::GetInstance().AddComponent( std::make_shared<AIComponent>("EatableComponent"), cell); } if (finished) { ZoomOutEffect(); } else { if (!Engine::GetInstance().HasEntityWithComponentOfClass("PlayerComponent")) { Engine::GetInstance().SetNextLevel(std::make_shared<LoseLevel>()); SetFinished(); } else { auto playerEntity = Engine::GetInstance().GetEntityWithComponentOfClass("PlayerComponent"); auto growthComponent = std::static_pointer_cast<GrowthComponent>(Engine::GetInstance().GetEntityManager()->GetSingleComponentOfClass(playerEntity, "GrowthComponent")); if (growthComponent->GetLevel() == CFG_GETI("LEVEL_1_GOAL_SIZE")) { finished = true; Engine::GetInstance().DeleteSystem("GrowthSystem"); } } } }
int16 Client::CalcSTR() { int16 val = m_pp.STR + itembonuses.STR + spellbonuses.STR + CalcAlcoholPhysicalEffect(); int16 mod = aabonuses.STR; if(val>255 && GetLevel() <= 60) val = 255; STR = val + mod; if(STR < 1) STR = 1; int m = GetMaxSTR(); if(STR > m) STR = m; return(STR); }
/** * @brief Gets NPC information for use in various NPC packets. * * @param pkt The packet the information will be stored in. */ void CNpc::GetNpcInfo(Packet & pkt) { pkt << GetProtoID() << uint8(isMonster() ? 1 : 2) // Monster = 1, NPC = 2 (need to use a better flag) << m_sPid << GetType() << m_iSellingGroup << m_sSize << m_iWeapon_1 << m_iWeapon_2 // Monsters require 0 regardless, otherwise they'll act as NPCs. << uint8(isMonster() ? 0 : GetNation()) << GetLevel() << GetSPosX() << GetSPosZ() << GetSPosY() << uint32(isGateOpen()) << m_byObjectType << uint16(0) << uint16(0) // unknown << int16(m_byDirection); }
int16 Client::CalcDEX() { int16 val = m_pp.DEX + itembonuses.DEX + spellbonuses.DEX - CalcAlcoholPhysicalEffect();; int16 mod = aabonuses.DEX; if(val>255 && GetLevel() <= 60) val = 255; DEX = val + mod; if(DEX < 1) DEX = 1; int m = GetMaxDEX(); if(DEX > m) DEX = m; return(DEX); }
int16 Client::CalcCHA() { int16 val = m_pp.CHA + itembonuses.CHA + spellbonuses.CHA; int16 mod = aabonuses.CHA; if(val>255 && GetLevel() <= 60) val = 255; CHA = val + mod; if(CHA < 1) CHA = 1; int m = GetMaxCHA(); if(CHA > m) CHA = m; return(CHA); }
void cPlayer::Send_PlayerInfo() { MyPlayerInfoAq* pInfo = (MyPlayerInfoAq*)PrepareSendPacket( sizeof( MyPlayerInfoAq ) ); if( NULL == pInfo ) return; pInfo->s_sType = MyPlayerInfo_Aq; pInfo->s_byDur = GetDur(); pInfo->s_byLevel = GetLevel(); pInfo->s_byStr = GetStr(); pInfo->s_dwExp = GetExp(); pInfo->s_dwHp = GetHp(); pInfo->s_dwPKey = GetPKey(); pInfo->s_dwPos = GetPos(); strncpy( pInfo->s_szId , GetId() , MAX_ID_LENGTH ); strncpy( pInfo->s_szName , GetName() , MAX_NAME_LENGTH ); strncpy( pInfo->s_szNickName , GetNickName() , MAX_NICKNAME_LENGTH ); SendPost( sizeof( MyPlayerInfoAq ) ); }
int16 Client::CalcSTA() { int16 val = m_pp.STA + itembonuses.STA + spellbonuses.STA + CalcAlcoholPhysicalEffect();; int16 mod = aabonuses.STA; if(val>255 && GetLevel() <= 60) val = 255; STA = val + mod; if(STA < 1) STA = 1; int m = GetMaxSTA(); if(STA > m) STA = m; return(STA); }
/***************************************************************************** For mouse hit test want to know if user clicked on the "+" / "-" box. Also for drawing the box *****************************************************************************/ void CGridTreeCellBase::TreeGetBoxRelCoords(CRect* apRect) // returns: relative coordinates { ASSERT( apRect != NULL); ASSERT( m_pTreeColumn != NULL); int iMargin = GetMargin(); int iDefTreeIndent = m_pTreeColumn->GetDefTreeIndent(); unsigned char ucLevel = GetLevel(); if( ucLevel < 1) return; apRect->left = iMargin + (iDefTreeIndent * ( ucLevel - 1) ) + TREE_BOX_MARGIN; apRect->right = apRect->left + iDefTreeIndent - TREE_BOX_MARGIN; apRect->top = iMargin; apRect->bottom = apRect->top + iDefTreeIndent - (2*TREE_BOX_MARGIN); }
void ALevelBounds::UpdateLevelBounds() { FBox LevelBounds = CalculateLevelBounds(GetLevel()); if (LevelBounds.IsValid) { FVector LevelCenter = LevelBounds.GetCenter(); FVector LevelSize = LevelBounds.GetSize(); SetActorTransform(FTransform(FQuat::Identity, LevelCenter, LevelSize)); bUsingDefaultBounds = false; } else { SetActorTransform(FTransform(FQuat::Identity, FVector::ZeroVector, DefaultLevelSize)); bUsingDefaultBounds = true; } BroadcastLevelBoundsUpdated(); }
int CItemEnhancement::GetHPAdj (void) const // GetHPAdj // // Get increase/decrease in HP { switch (GetType()) { case etHPBonus: { int iData = GetDataX(); if (IsDisadvantage()) { if (iData >= 0 && iData <= 90) return 100 - iData; else return 10; } else return 100 + iData; } case etStrengthen: { int iLevel = GetLevel(); if (IsDisadvantage()) { if (iLevel >= 0 && iLevel <= 9) return 100 - (10 * iLevel); else return 10; } else return 100 + (10 * iLevel); } default: return 100; } }
bool CZipCompression::DecompressFile(const string& src_file, const string& dst_file, size_t buf_size) { CZipCompressionFile cf(GetLevel(), m_WindowBits, m_MemLevel, m_Strategy); cf.SetFlags(cf.GetFlags() | GetFlags()); bool need_restore_attr = false; SFileInfo info; // Open compressed file, and define name of the destination file if ( F_ISSET(fRestoreFileAttr) ) { if ( !cf.Open(src_file, CCompressionFile::eMode_Read, &info) ) { SetError(cf.GetErrorCode(), cf.GetErrorDescription()); return false; } if ( !info.name.empty() ) { need_restore_attr = true; } } else { if ( !cf.Open(src_file, CCompressionFile::eMode_Read, 0) ) { SetError(cf.GetErrorCode(), cf.GetErrorDescription()); return false; } } // Decompress file if ( !CCompression::x_DecompressFile(cf, dst_file, buf_size) ) { if ( cf.GetErrorCode() ) { SetError(cf.GetErrorCode(), cf.GetErrorDescription()); } cf.Close(); return false; } // Close output file and return result bool status = cf.Close(); SetError(cf.GetErrorCode(), cf.GetErrorDescription()); // Restore time stamp if needed if ( status && need_restore_attr ) { CFile(dst_file).SetTimeT(&info.mtime); } return status; }