monstermanager.cpp
来自「天之炼狱1服务器端源文件游戏服务端不完整」· C++ 代码 · 共 2,206 行 · 第 1/5 页
CPP
2,206 行
// 肺 函版登绢具 且 巴捞促. ///////////////////////////////////////////////////////////////////// /* if(pDeadMonster->getEventMonsterFlag() == true) { ITEM_TEMPLATE ball_template; ball_template.ItemClass = Item::ITEM_CLASS_EVENT_STAR; ball_template.ItemType = 6; ball_template.OptionType=0; //if(g_pVariable->getDebugMode() == "COUT") //cout << "绵备傍 酒捞袍 积己" << endl; Item *pItem = g_pItemFactoryManager->createItem(ball_template.ItemClass, ball_template.ItemType, ball_template.OptionType); Assert(pItem != NULL); pMonsterCorpse->addTreasure(pItem); } */ ////////////////////////////////////////////////////////////////////// // 2002斥 5岿 啊沥狼 崔 捞亥飘/ // 葛电 阁胶磐俊霸辑 喊捞 唱棵 荐 乐栏骨肺, 咯扁俊 窍靛内爹窍看促. // 1/1500 狼 犬伏肺 喊 酒捞袍阑 眠啊肺 积己茄促.(吧府绰 仇篮 犁荐促) ////////////////////////////////////////////////////////////////////// //cout << "Monster Manager: star -> " << g_pVariable->getStar() << endl; //int star_percentage = g_pVariable->getStar(); /* if(rand()%500 == 0) { ITEM_TEMPLATE star_template; star_template.ItemClass = Item::ITEM_CLASS_EVENT_STAR; // 刚历 1/10狼 犬伏肺 混旗夯 促澜, 吧府搁 1/6狼 犬伏肺 阿 喊阑 唱坷霸 茄促. // 9/10狼 犬伏肺绰 八篮喊阑 力寇茄 喊父 唱坷霸 茄促. if(rand() % 1500 == 0) star_template.ItemType = rand() % 6; else star_template.ItemType = (rand() % 5) + 1; star_template.OptionType = 0; cout << "捞亥飘 酒捞袍 积己" << star_template.ItemType << endl; Item* pItem = g_pItemFactoryManager->createItem(star_template.ItemClass,star_template.ItemType, star_template.OptionType); Assert(pItem != NULL); pMonsterCorpse->addTreasure(pItem); } */ __END_CATCH}int MonsterManager::upgradeItemTypeByLuck(int luckLevel, Creature::CreatureClass ownerCreatureClass, ITEM_TEMPLATE& it) throw (Error){ __BEGIN_TRY if (luckLevel==0 || !isPossibleUpgradeItemType(it.ItemClass)) return 0; luckLevel = luckLevel + (rand()%20) - 10; luckLevel = min(MAX_LUCK_LEVEL, luckLevel);// cout << "Apply luck : " << luckLevel << endl; int ratio; switch ( ownerCreatureClass ) { case Creature::CREATURE_CLASS_SLAYER: { if ( luckLevel >= 0 ) { ratio = (int)(( (float)luckLevel / (4.254 + (1.0 + it.ItemType)/5.0) ) * 100); } else { ratio = (int)(( (float)luckLevel / (2.5 - (1.0 + it.ItemType)/20.0) ) * 100); } } break; case Creature::CREATURE_CLASS_VAMPIRE: { if ( luckLevel >= 0 ) { ratio = (int)(( (float)luckLevel / (6.03 + (1.0 + it.ItemType)/5.0) ) * 100); } else { ratio = (int)(( (float)luckLevel / (4.14 - (1.0 + it.ItemType)/20.0) ) * 100); } } break; case Creature::CREATURE_CLASS_OUSTERS: { if ( luckLevel >= 0 ) { ratio = (int)(( (float)luckLevel / (4.936 + (1.0 + it.ItemType)/5.0) ) * 100); } else { ratio = (int)(( (float)luckLevel / (3.05 - (1.0 + it.ItemType)/20.0) ) * 100); } } break; default: return 0; } int value = rand()%10000;// int value = 0;//rand()%10000;// cout << "ratio : " << ratio << endl;// cout << "value : " << value << endl;/* const LuckInfo& luckInfo = g_pLuckInfoManager->getLuckInfo(luckLevel); int upgradeCount = luckInfo.getUpgradeItemTypeCount(); if (upgradeCount==0) return;*/// cout << "before : " << it.ItemClass << "/" << (int)it.ItemType << endl; if ( ratio > 0 && value < ratio ) { it.ItemType = getUpgradeItemType(it.ItemClass, it.ItemType, 1);// cout << "after : " << it.ItemClass << "/" << (int)it.ItemType << endl; return 1; } else if ( ratio < 0 && value < (-ratio) ) { it.ItemType = getDowngradeItemType(it.ItemClass, it.ItemType);// cout << "after : " << it.ItemClass << "/" << (int)it.ItemType << endl; return -1; } return 0; __END_CATCH}int MonsterManager::upgradeOptionByLuck(int luckLevel, Creature::CreatureClass ownerCreatureClass, ITEM_TEMPLATE& it) throw (Error){ __BEGIN_TRY if ( it.OptionType.empty() ) return 0; OptionType_t optionType = it.OptionType.front(); OptionInfo* pOptionInfo = g_pOptionInfoManager->getOptionInfo( optionType ); if ( pOptionInfo == NULL ) return 0; luckLevel = luckLevel + (rand()%20) - 10; luckLevel = min(MAX_LUCK_LEVEL, luckLevel);// cout << "Apply luck to option : " << luckLevel << endl; int grade = pOptionInfo->getGrade() + 1;// cout << "Option Grade : " << grade << endl; int ratio; switch ( ownerCreatureClass ) { case Creature::CREATURE_CLASS_SLAYER: { if ( luckLevel >= 0 ) { ratio = (int)(( (float)luckLevel / (grade*25.0 - 15.2) ) * 100); } else { ratio = (int)(( (float)luckLevel / (7.5 - grade/2.0) ) * 100); } } break; case Creature::CREATURE_CLASS_VAMPIRE: { if ( luckLevel >= 0 ) { ratio = (int)(( (float)luckLevel / (grade*25.0 - 11.3) ) * 100); } else { ratio = (int)(( (float)luckLevel / (10.3 - grade/2.0) ) * 100); } } break; case Creature::CREATURE_CLASS_OUSTERS: { if ( luckLevel >= 0 ) { ratio = (int)(( (float)luckLevel / (grade/25.0 - 13.7) ) * 100); } else { ratio = (int)(( (float)luckLevel / (7.9 - grade/2.0) ) * 100); } } break; default: return 0; } int value = rand()%10000;// int value = 0;//rand()%10000;// cout << "ratio : " << ratio << endl;// cout << "value : " << value << endl;// cout << "before : " << pOptionInfo->getHName() << endl; if ( ratio > 0 && value < ratio && pOptionInfo->getUpgradeType() != optionType && pOptionInfo->isUpgradePossible() ) { (*it.OptionType.begin()) = pOptionInfo->getUpgradeType();// cout << "after : " << g_pOptionInfoManager->getOptionInfo( it.OptionType.front() )->getHName() << endl; return 1; } else if ( ratio < 0 && value < (-ratio) && pOptionInfo->getPreviousType() != optionType ) { if ( pOptionInfo->getPreviousType() != 0 ) (*it.OptionType.begin()) = pOptionInfo->getPreviousType(); else it.OptionType.pop_front();// if ( it.OptionType.front() == 0 ) it.OptionType.pop_front();// cout << "after : " << g_pOptionInfoManager->getOptionInfo( it.OptionType.front() )->getHName() << endl; return -1; } return 0; __END_CATCH}////////////////////////////////////////////////////////////////////////////////// 葛电 农府贸甫 力芭茄促.////////////////////////////////////////////////////////////////////////////////void MonsterManager::deleteAllMonsters (bool bDeleteFromZone) throw (Error){ __BEGIN_TRY __BEGIN_DEBUG hash_map< ObjectID_t , Creature* >::iterator current = m_Creatures.begin(); while (current != m_Creatures.end()) { Creature* pCreature = current->second; Assert(pCreature != NULL); if (bDeleteFromZone) { try { Zone* pZone = pCreature->getZone(); Assert(m_pZone == pZone); //Monster* pMonster = dynamic_cast<Monster*>(pCreature); ZoneCoord_t cx = pCreature->getX(); ZoneCoord_t cy = pCreature->getY(); // 鸥老俊辑 力芭 Tile & tile = m_pZone->getTile(cx , cy); tile.deleteCreature(pCreature->getObjectID()); // 林函狼 PC甸俊霸 农府贸啊 荤扼脸促绰 荤角阑 宏肺靛某胶飘茄促. GCDeleteObject gcDeleteObject(pCreature->getObjectID()); pZone->broadcastPacket(cx, cy, &gcDeleteObject, pCreature); } catch (Throwable& t) { filelog("MonsterManagerBug.txt", "deleteAllCreatures: %s", t.toString().c_str()); } } // 农府媚甫 昏力茄促. SAFE_DELETE(pCreature); current ++; } // 促 力芭茄促. m_Creatures.clear(); m_Monsters.clear(); __END_DEBUG __END_CATCH}////////////////////////////////////////////////////////////////////////////////// 葛电 农府贸甫 磷牢促.////////////////////////////////////////////////////////////////////////////////void MonsterManager::killAllMonsters (const hash_map<ObjectID_t, ObjectID_t>& exceptCreatures) throw (Error){ __BEGIN_TRY __BEGIN_DEBUG hash_map< ObjectID_t , Creature* >::iterator current = m_Creatures.begin(); while (current != m_Creatures.end()) { Creature* pCreature = current->second; Assert(pCreature != NULL); if (pCreature->isAlive()) { if (pCreature->isMonster()) { hash_map<ObjectID_t, ObjectID_t>::const_iterator itr = exceptCreatures.find( pCreature->getObjectID() ); if (itr==exceptCreatures.end()) { Monster* pMonster = dynamic_cast<Monster*>(pCreature); pMonster->setHP(0, ATTR_CURRENT); } } else Assert(false); } } __END_DEBUG __END_CATCH}////////////////////////////////////////////////////////////////////////////////// get debug string////////////////////////////////////////////////////////////////////////////////string MonsterManager::toString () const throw (){ __BEGIN_TRY StringStream msg; msg << "MonsterManager(" << CreatureManager::toString(); hash_map< SpriteType_t , MonsterCounter* >::const_iterator itr = m_Monsters.begin(); for (; itr != m_Monsters.end() ; itr ++) msg << itr->second->toString(); msg << ")" ; return msg.toString(); __END_CATCH}//////////////////////////////////////////////////////////////////////////////// 炔陛 秦榜 凛扁 捞亥飘俊 静看带 内靛狼 老何盒捞促.// 老窜篮 焊扁 饺绢辑 哗初绰单, 唱吝俊扼档 趣矫 促矫 静咯龙鳖 秦辑// 颇老 盖 场栏肺 颗败初绰促.///////////////////////////////////////////////////////////////////////////////*////////////////////////////////////////////////////////////// 捞亥飘 包访 内靛 矫累////////////////////////////////////////////////////////////SpriteType_t SpriteType = pMonsterInfo->getSpriteType();uint event_ratio = rand()%100;uint skull_ratio = rand()%100;switch (SpriteType){ case 5: // 单靛官叼 if (event_ratio < 3) ItemType = 12; break; case 8: // 磐醋单靛 if (event_ratio < 3) ItemType = 12; break; case 7: // 磐醋家匡 if (event_ratio < 3) { if (skull_ratio < 98) ItemType = 12; else ItemType = 15; } break; case 6: // 虐靛 if (event_ratio < 3) { if (skull_ratio < 97) ItemType = 12; else ItemType = 15; } break; case 4: // 贾廉 if (event_ratio < 3) { if (skull_ratio < 96) ItemType = 12; else ItemType = 15; } break; case 9: // 母凭 if (event_ratio < 3) { if (skull_ratio < 94) ItemType = 12; else ItemType = 15; } break; case 42: // 舅沫 if (event_ratio < 4) { if (skull_ratio < 93) ItemType = 12; else if (93 <= skull_ratio && skull_ratio < 99) ItemType = 15; else ItemType = 14; } break; case 43: // 饭靛酒捞 if (event_ratio < 4) { if (skull_ratio < 93) ItemType = 12; else if (93 <= skull_ratio && skull_ratio < 99) ItemType = 15; else ItemType = 14; } break; case 60: // 孤畔飘 if (event_ratio < 4) { if (skull_ratio < 93) ItemType = 12; else if (93 <= skull_ratio && skull_ratio < 99) ItemType = 15; else ItemType = 14; } break; case 64: // 葛单扼胶 if (event_ratio < 4) { if (skull_ratio < 93) ItemType = 12; else if (93 <= skull_ratio && skull_ratio < 99) ItemType = 15; else ItemType = 14; } break; case 41: // 歹萍胶飘扼捞歹 if (event_ratio < 4) { if (skull_ratio < 93) ItemType = 12; else if (93 <= skull_ratio && skull_ratio < 99) ItemType = 15; else ItemType = 14; } break; case 62: // 俊胶飘肺捞歹 if (event_ratio < 4) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?