Hallo.
Ich bin nach diesem Tut hier vorgegangen:
Bitte melden Sie sich an, um diesen Link zu sehen.
Bekomme aber folgenden Fehler:
in Member function 'GetMostAttacked()':
battle.cpp:2656/2658/2661 error: 'It' does not name y type
battle.cpp2681 error 'iDam' was not declared in this scope
Mein Code-Schnipsel:
Code
- #ifdef __ENABLE_KILL_EVENT_FIX__
- LPCHARACTER CHARACTER::GetMostAttacked() {
- int iMostDam=-1;
- LPCHARACTER pkChrMostAttacked = NULL;
- auto it = m_map_kDamage.begin();
- while (it != m_map_kDamage.end()){
- //* getting information from the iterator
- const VID & c_VID = it->first;
- const it iDam = it->second.iTotalDamage;
- //* increasing the iterator
- ++it;
- //* finding the character from his vid
- LPCHARACTER pAttacker = CHARACTER_MANAGER::instance().Find(c_VID);
- //* if the attacked is now offline
- if (!pAttacker)
- continue;
- //* if the attacker is not a player
- if( pAttacker->IsNPC())
- continue;
- //* if the player is too far
- if(DISTANCE_APPROX(GetX()-pAttacker->GetX(), GetY()-pAttacker->GetY())>5000)
- continue;
- if (iDam > iMostDam){
- pkChrMostAttacked = pAttacker;
- iMostDam = iDam;
- }
- }
- return pkChrMostAttacked;
- }
- #endif
- LPCHARACTER CHARACTER::DistributeExp()
- {
- int iExpToDistribute = GetExp();
- if (iExpToDistribute <= 0)
- return NULL;
- int iTotalDam = 0;
- LPCHARACTER pkChrMostAttacked = NULL;
- int iMostDam = 0;
- typedef std::vector<TDamageInfo> TDamageInfoTable;
- TDamageInfoTable damage_info_table;
- std::map<LPPARTY, TDamageInfo> map_party_damage;
- damage_info_table.reserve(m_map_kDamage.size());
- TDamageMap::iterator it = m_map_kDamage.begin();
- // 일단 주위에 없는 사람을 걸러 낸다. (50m)
- while (it != m_map_kDamage.end())
- {
- const VID & c_VID = it->first;
- int iDam = it->second.iTotalDamage;
- ++it;
- LPCHARACTER pAttacker = CHARACTER_MANAGER::instance().Find(c_VID);
- // NPC가 때리기도 하나? -.-;
- if (!pAttacker || pAttacker->IsNPC() || DISTANCE_APPROX(GetX()-pAttacker->GetX(), GetY()-pAttacker->GetY())>5000)
- continue;
- iTotalDam += iDam;
- if (!pkChrMostAttacked || iDam > iMostDam)
- {
- pkChrMostAttacked = pAttacker;
- iMostDam = iDam;
- }
- if (pAttacker->GetParty())
- {
- std::map<LPPARTY, TDamageInfo>::iterator it = map_party_damage.find(pAttacker->GetParty());
- if (it == map_party_damage.end())
- {
- TDamageInfo di;
- di.iDam = iDam;
- di.pAttacker = NULL;
- di.pParty = pAttacker->GetParty();
- map_party_damage.insert(std::make_pair(di.pParty, di));
- }
- else
- {
- it->second.iDam += iDam;
- }
- }
- else
- {
- TDamageInfo di;
- di.iDam = iDam;
- di.pAttacker = pAttacker;
- di.pParty = NULL;
- //sys_log(0, "__ pq_damage %s %d", pAttacker->GetName(), iDam);
- //pq_damage.push(di);
- damage_info_table.push_back(di);
- }
- }
- for (std::map<LPPARTY, TDamageInfo>::iterator it = map_party_damage.begin(); it != map_party_damage.end(); ++it)
- {
- damage_info_table.push_back(it->second);
- //sys_log(0, "__ pq_damage_party [%u] %d", it->second.pParty->GetLeaderPID(), it->second.iDam);
- }
- SetExp(0);
- //m_map_kDamage.clear();
- if (iTotalDam == 0) // 데미지 준게 0이면 리턴
- return NULL;
- if (m_pkChrStone) // 돌이 있을 경우 경험치의 반을 돌에게 넘긴다.
- {
- //sys_log(0, "__ Give half to Stone : %d", iExpToDistribute>>1);
- int iExp = iExpToDistribute >> 1;
- m_pkChrStone->SetExp(m_pkChrStone->GetExp() + iExp);
- iExpToDistribute -= iExp;
- }
- sys_log(1, "%s total exp: %d, damage_info_table.size() == %d, TotalDam %d",
- GetName(), iExpToDistribute, damage_info_table.size(), iTotalDam);
- //sys_log(1, "%s total exp: %d, pq_damage.size() == %d, TotalDam %d",
- //GetName(), iExpToDistribute, pq_damage.size(), iTotalDam);
- if (damage_info_table.empty())
- return NULL;
- // 제일 데미지를 많이 준 사람이 HP 회복을 한다.
- DistributeHP(pkChrMostAttacked); // 만두 시스템
- {
- // 제일 데미지를 많이 준 사람이나 파티가 총 경험치의 20% + 자기가 때린만큼의 경험치를 먹는다.
- TDamageInfoTable::iterator di = damage_info_table.begin();
- {
- TDamageInfoTable::iterator it;
- for (it = damage_info_table.begin(); it != damage_info_table.end();++it)
- {
- if (it->iDam > di->iDam)
- di = it;
- }
- }
- int iExp = iExpToDistribute / 5;
- iExpToDistribute -= iExp;
- float fPercent = (float) di->iDam / iTotalDam;
- if (fPercent > 1.0f)
- {
- sys_err("DistributeExp percent over 1.0 (fPercent %f name %s)", fPercent, di->pAttacker->GetName());
- fPercent = 1.0f;
- }
- iExp += (int) (iExpToDistribute * fPercent);
- //sys_log(0, "%s given exp percent %.1f + 20 dam %d", GetName(), fPercent * 100.0f, di.iDam);
- di->Distribute(this, iExp);
- // 100% 다 먹었으면 리턴한다.
- if (fPercent == 1.0f)
- return pkChrMostAttacked;
- di->Clear();
- }
- {
- // 남은 80%의 경험치를 분배한다.
- TDamageInfoTable::iterator it;
- for (it = damage_info_table.begin(); it != damage_info_table.end(); ++it)
- {
- TDamageInfo & di = *it;
- float fPercent = (float) di.iDam / iTotalDam;
- if (fPercent > 1.0f)
- {
- sys_err("DistributeExp percent over 1.0 (fPercent %f name %s)", fPercent, di.pAttacker->GetName());
- fPercent = 1.0f;
- }
- //sys_log(0, "%s given exp percent %.1f dam %d", GetName(), fPercent * 100.0f, di.iDam);
- di.Distribute(this, (int) (iExpToDistribute * fPercent));
- }
- }
- return pkChrMostAttacked;
- }
Ich hoffe mir kann da jemand helfen.
LG.