// 파티 단위로 버프 주는 함수. // 같은 맵에 있는 파티원만 영향을 받는다. int party_give_buff (lua_State* L) { CQuestManager & q = CQuestManager::instance(); LPCHARACTER ch = q.GetCurrentCharacterPtr(); if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3) || !lua_isnumber(L, 4) || !lua_isnumber(L, 5) || !lua_isnumber(L, 6) || !lua_isboolean(L, 7) || !lua_isboolean(L, 8)) { lua_pushboolean (L, false); return 1; } DWORD dwType = lua_tonumber(L, 1); BYTE bApplyOn = lua_tonumber(L, 2); long lApplyValue = lua_tonumber(L, 3); DWORD dwFlag = lua_tonumber(L, 4); long lDuration = lua_tonumber(L, 5); long lSPCost = lua_tonumber(L, 6); bool bOverride = lua_toboolean(L, 7); bool IsCube = lua_toboolean(L, 8); FGiveBuff f (dwType, bApplyOn, lApplyValue, dwFlag, lDuration, lSPCost, bOverride, IsCube); if (ch->GetParty()) ch->GetParty()->ForEachOnMapMember(f, ch->GetMapIndex()); else f(ch); lua_pushboolean (L, true); return 1; }
int party_is_map_member_flag_lt(lua_State* L) { if (!lua_isstring(L, 1) || !lua_isnumber(L, 2)) { lua_pushnumber(L, 0); return 1; } CQuestManager& q = CQuestManager::Instance(); LPPARTY pParty = q.GetCurrentCharacterPtr()->GetParty(); LPCHARACTER ch = q.GetCurrentCharacterPtr(); PC* pPC = q.GetCurrentPC(); const char* sz = lua_tostring(L,1); if (pParty) { FPartyCheckFlagLt f; f.flagname = pPC->GetCurrentQuestName() + "."+sz; f.value = (int) rint(lua_tonumber(L, 2)); bool returnBool = pParty->ForEachOnMapMemberBool(f, ch->GetMapIndex()); lua_pushboolean(L, returnBool); } return 1; }
void CParty::Link(LPCHARACTER pkChr) { TMemberMap::iterator it; if (pkChr->IsPC()) it = m_memberMap.find(pkChr->GetPlayerID()); else it = m_memberMap.find(pkChr->GetVID()); if (it == m_memberMap.end()) { sys_err("%s is not member of this party", pkChr->GetName()); return; } // 플레이어 파티일 경우 업데이트 이벤트 생성 if (m_bPCParty && !m_eventUpdate) { party_update_event_info* info = AllocEventInfo<party_update_event_info>(); info->pid = m_dwLeaderPID; m_eventUpdate = event_create(party_update_event, info, PASSES_PER_SEC(3)); } if (it->second.bRole == PARTY_ROLE_LEADER) m_pkChrLeader = pkChr; sys_log(2, "PARTY[%d] %s linked to party", GetLeaderPID(), pkChr->GetName()); it->second.pCharacter = pkChr; pkChr->SetParty(this); if (pkChr->IsPC()) { if (it->second.strName.empty()) { it->second.strName = pkChr->GetName(); } SendPartyJoinOneToAll(pkChr->GetPlayerID()); SendPartyJoinAllToOne(pkChr); SendPartyLinkOneToAll(pkChr); SendPartyLinkAllToOne(pkChr); SendPartyInfoAllToOne(pkChr); SendPartyInfoOneToAll(pkChr); SendParameter(pkChr); //sys_log(0, "PARTY-DUNGEON connect %p %p", this, GetDungeon()); if (GetDungeon() && GetDungeon()->GetMapIndex() == pkChr->GetMapIndex()) { pkChr->SetDungeon(GetDungeon()); } RequestSetMemberLevel(pkChr->GetPlayerID(), pkChr->GetLevel()); } }
void CDragonLairManager::OnDragonDead(LPCHARACTER pDragon, DWORD KillerGuildID) { if (NULL == pDragon) return; if (false == pDragon->IsMonster()) return; boost::unordered_map<DWORD, CDragonLair*>::iterator iter = LairMap_.find( KillerGuildID ); if (LairMap_.end() == iter) { return; } LPSECTREE_MAP pMap = SECTREE_MANAGER::instance().GetMap( pDragon->GetMapIndex() ); if (NULL == iter->second || NULL == pMap) { LairMap_.erase( iter ); return; } iter->second->OnDragonDead( pDragon ); // ѕЦµй ґЩ БэАё·О єёі»°н ёК ѕшѕЦ±в tag_DragonLair_Collapse_EventInfo* info; info = AllocEventInfo<tag_DragonLair_Collapse_EventInfo>(); info->step = 0; info->pLair = iter->second; info->InstanceMapIndex = pDragon->GetMapIndex(); event_create(DragonLair_Collapse_Event, info, PASSES_PER_SEC(10)); LairMap_.erase( iter ); }
int marriage_in_my_wedding(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); marriage::TMarriage* pMarriage = marriage::CManager::instance().Get(ch->GetPlayerID()); if (pMarriage->pWeddingInfo) { lua_pushboolean(L, (DWORD)ch->GetMapIndex() == pMarriage->pWeddingInfo->dwMapIndex); } else { lua_pushboolean(L, 0); } return 1; }
bool COXEventManager::CheckIpAddress(LPCHARACTER ch) { for (itertype(m_map_attender) it = m_map_attender.begin(); it != m_map_attender.end(); ++it) { LPCHARACTER tch = CHARACTER_MANAGER::Instance().FindByPID(it->second); if (!tch || !tch->GetDesc()) continue; if (!strcmp(ch->GetDesc()->GetHostName(), tch->GetDesc()->GetHostName()) && ch->GetMapIndex() == tch->GetMapIndex()) { LogManager::Instance().HackLog("MULTI_IP_OX", ch); ch->GoHome(); return false; } } return true; }
int party_get_member_pids(lua_State *L) { CQuestManager & q = CQuestManager::instance(); LPCHARACTER ch = q.GetCurrentCharacterPtr(); LPPARTY pParty = ch->GetParty(); if (NULL == pParty) { return 0; } FPartyPIDCollector f; pParty->ForEachOnMapMember(f, ch->GetMapIndex()); for (std::vector <DWORD>::iterator it = f.vecPIDs.begin(); it != f.vecPIDs.end(); it++) { lua_pushnumber(L, *it); } return f.vecPIDs.size(); }
bool battle_is_attackable(LPCHARACTER ch, LPCHARACTER victim) { // 상대방이 죽었으면 중단한다. if (victim->IsDead()) return false; // 안전지대면 중단 { SECTREE *sectree = NULL; sectree = ch->GetSectree(); if (sectree && sectree->IsAttr(ch->GetX(), ch->GetY(), ATTR_BANPK)) return false; sectree = victim->GetSectree(); if (sectree && sectree->IsAttr(victim->GetX(), victim->GetY(), ATTR_BANPK)) return false; } // 내가 죽었으면 중단한다. if (ch->IsStun() || ch->IsDead()) return false; if (ch->IsPC() && victim->IsPC()) { CGuild* g1 = ch->GetGuild(); CGuild* g2 = victim->GetGuild(); if (g1 && g2) { if (g1->UnderWar(g2->GetID())) return true; } } if (IS_CASTLE_MAP(ch->GetMapIndex()) && false==castle_can_attack(ch, victim)) return false; if (CArenaManager::instance().CanAttack(ch, victim) == true) return true; return CPVPManager::instance().CanAttack(ch, victim); }
void CLand::PutData(const TLand * data) { memcpy(&m_data, data, sizeof(TLand)); if (m_data.dwGuildID) { const TMapRegion * r = SECTREE_MANAGER::instance().GetMapRegion(m_data.lMapIndex); if (r) { CharacterVectorInteractor i; if (CHARACTER_MANAGER::instance().GetCharactersByRaceNum(20040, i)) { CharacterVectorInteractor::iterator it = i.begin(); while (it != i.end()) { LPCHARACTER ch = *(it++); if (ch->GetMapIndex() != m_data.lMapIndex) continue; int x = ch->GetX() - r->sx; int y = ch->GetY() - r->sy; if (x > m_data.x + m_data.width || x < m_data.x) continue; if (y > m_data.y + m_data.height || y < m_data.y) continue; M2_DESTROY_CHARACTER(ch); } } } } }
void CParty::SummonToLeader(DWORD pid) { int xy[12][2] = { { 250, 0 }, { 216, 125 }, { 125, 216 }, { 0, 250 }, { -125, 216 }, { -216, 125 }, { -250, 0 }, { -216, -125 }, { -125, -216 }, { 0, -250 }, { 125, -216 }, { 216, -125 }, }; int n = 0; int x[12], y[12]; SECTREE_MANAGER & s = SECTREE_MANAGER::instance(); LPCHARACTER l = GetLeaderCharacter(); if (m_memberMap.find(pid) == m_memberMap.end()) { l->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<파티> 소환하려는 대상을 찾을 수 없습니다.")); return; } LPCHARACTER ch = m_memberMap[pid].pCharacter; if (!ch) { l->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<파티> 소환하려는 대상을 찾을 수 없습니다.")); return; } if (!ch->CanSummon(m_iLeadership)) { l->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<파티> 대상을 소환할 수 없습니다.")); return; } for (int i = 0; i < 12; ++i) { PIXEL_POSITION p; if (s.GetMovablePosition(l->GetMapIndex(), l->GetX() + xy [i][0], l->GetY() + xy[i][1], p)) { x[n] = p.x; y[n] = p.y; n++; } } if (n == 0) l->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<파티> 파티원을 현재 위치로 소환할 수 없습니다.")); else { int i = number(0, n - 1); ch->Show(l->GetMapIndex(), x[i], y[i]); ch->Stop(); } }
bool CPVPManager::CanAttack(LPCHARACTER pkChr, LPCHARACTER pkVictim) { switch (pkVictim->GetCharType()) { case CHAR_TYPE_NPC: case CHAR_TYPE_WARP: case CHAR_TYPE_GOTO: return false; } if (pkChr == pkVictim) // 내가 날 칠라고 하네 -_- return false; if (pkVictim->IsNPC() && pkChr->IsNPC() && !pkChr->IsGuardNPC()) return false; if( true == pkChr->IsHorseRiding() ) { if( pkChr->GetHorseLevel() > 0 && 1 == pkChr->GetHorseGrade() ) return false; } else { switch( pkChr->GetMountVnum() ) { case 0: case 20030: case 20110: case 20111: case 20112: case 20113: case 20114: case 20115: case 20116: case 20117: case 20118: //신규 탈것 고급 case 20205: case 20206: case 20207: case 20208: case 20209: case 20210: case 20211: case 20212: case 20119: // 라마단 흑마 case 20219: // 라마단 흑마 클론 (할로윈용) case 20220: // 크리스마스 탈것 case 20221: // 전갑 백웅 case 20222: // 전갑 팬더 case 20120: case 20121: case 20122: case 20123: case 20124: case 20125: case 20214: // 난폭한 전갑순순록 case 20215: // 용맹한 전갑순순록 case 20217: // 난폭한 전갑암순록 case 20218: // 용맹한 전갑암순록 case 20224: // 난폭한 전갑석룡자 case 20225: // 용맹한 전갑석룡자 case 20226: // 유니콘 case 20227: break; default: return false; } } if (pkVictim->IsNPC() || pkChr->IsNPC()) { return true; } if (pkVictim->IsObserverMode() || pkChr->IsObserverMode()) return false; { BYTE bMapEmpire = SECTREE_MANAGER::instance().GetEmpireFromMapIndex(pkChr->GetMapIndex()); if ( pkChr->GetPKMode() == PK_MODE_PROTECT && pkChr->GetEmpire() == bMapEmpire || pkVictim->GetPKMode() == PK_MODE_PROTECT && pkVictim->GetEmpire() == bMapEmpire ) { return false; } } if (pkChr->GetEmpire() != pkVictim->GetEmpire()) { if ( LC_IsYMIR() == true || LC_IsKorea() == true ) { if ( pkChr->GetPKMode() == PK_MODE_PROTECT || pkVictim->GetPKMode() == PK_MODE_PROTECT ) { return false; } } return true; } bool beKillerMode = false; if (pkVictim->GetParty() && pkVictim->GetParty() == pkChr->GetParty()) { return false; // Cannot attack same party on any pvp model } else { if (pkVictim->IsKillerMode()) { return true; } if (pkChr->GetAlignment() < 0 && pkVictim->GetAlignment() >= 0) { if (g_protectNormalPlayer) { // 범법자는 평화모드인 착한사람을 공격할 수 없다. if (PK_MODE_PEACE == pkVictim->GetPKMode()) return false; } } switch (pkChr->GetPKMode()) { case PK_MODE_PEACE: case PK_MODE_REVENGE: // Cannot attack same guild if (pkVictim->GetGuild() && pkVictim->GetGuild() == pkChr->GetGuild()) break; if (pkChr->GetPKMode() == PK_MODE_REVENGE) { //if (!g_iUseLocale) if (1) { if (pkChr->GetAlignment() < 0 && pkVictim->GetAlignment() >= 0) { pkChr->SetKillerMode(true); return true; } else if (pkChr->GetAlignment() >= 0 && pkVictim->GetAlignment() < 0) return true; } else { if (pkChr->GetAlignment() < 0 && pkVictim->GetAlignment() < 0) break; else if (pkChr->GetAlignment() >= 0 && pkVictim->GetAlignment() >= 0) break; beKillerMode = true; } } break; case PK_MODE_GUILD: // Same implementation from PK_MODE_FREE except for attacking same guild if (!pkChr->GetGuild() || (pkVictim->GetGuild() != pkChr->GetGuild())) { if (1) //if (!g_iUseLocale) { if (pkVictim->GetAlignment() >= 0) pkChr->SetKillerMode(true); else if (pkChr->GetAlignment() < 0 && pkVictim->GetAlignment() < 0) pkChr->SetKillerMode(true); return true; } else beKillerMode = true; } break; case PK_MODE_FREE: //if (!g_iUseLocale) if (1) { if (pkVictim->GetAlignment() >= 0) pkChr->SetKillerMode(true); else if (pkChr->GetAlignment() < 0 && pkVictim->GetAlignment() < 0) pkChr->SetKillerMode(true); return true; } else beKillerMode = true; break; } } CPVP kPVP(pkChr->GetPlayerID(), pkVictim->GetPlayerID()); CPVP * pkPVP = Find(kPVP.m_dwCRC); if (!pkPVP || !pkPVP->IsFight()) { if (beKillerMode) pkChr->SetKillerMode(true); return (beKillerMode); } pkPVP->SetLastFightTime(); return true; }
void CThreeWayWar::onDead(LPCHARACTER pChar, LPCHARACTER pkKiller) { if (false == pChar->IsPC()) return; if (GM_PLAYER != pChar->GetGMLevel() && false == test_server) return; if (-1 == GetRegenFlag()) return; DecreaseReviveTokenForPlayer( pChar->GetPlayerID() ); if (false == IsSungZiMapIndex(pChar->GetMapIndex())) return; if (NULL == pkKiller || true != pkKiller->IsPC()) return; // °°Ає Б¦±№Ає °и»кЗПБц ѕКАЅ if (pChar->GetEmpire() == pkKiller->GetEmpire()) return; int nKillScore = GetKillScore(pkKiller->GetEmpire()); // Б¦±№ Еі ЅєДЪѕо°Ў -1АП°жїмґВ Е»¶ф±№°ЎА̱⶧№®їЎ БЎјц ГјЕ©ё¦ ЗПёй ѕИµИґЩ. if (nKillScore >= 0) { nKillScore += GetKillValue(pChar->GetLevel()); SetKillScore(pkKiller->GetEmpire(), nKillScore); } if (nKillScore != 0 && (test_server || (nKillScore % 5) == 0)) { char szBuf[64 + 1]; snprintf(szBuf, sizeof(szBuf), LC_TEXT("ЗцАз ЅєДЪѕо ЅЕјц±№:%d ГµБ¶±№:%d Бшіл±№:%d"), GetKillScore(1), GetKillScore(2), GetKillScore(3)); SendNoticeMap(szBuf, GetSungziMapIndex(), false); } const int nVictoryScore = quest::CQuestManager::instance().GetEventFlag("threeway_war_kill_count"); if (0 == GetRegenFlag()) { int nEliminatedEmpireCount = 0; BYTE bLoseEmpire = 0; for (int n = 1; n < 4; ++n) { if (nVictoryScore > GetKillScore(n)) { ++nEliminatedEmpireCount; bLoseEmpire = n; } } if (1 != nEliminatedEmpireCount) return; //---------------------- //Д«їоЖ® ГК±вИ //---------------------- SetKillScore(1, 0); SetKillScore(2, 0); SetKillScore(3, 0); SetKillScore(bLoseEmpire, -1); quest::warp_all_to_map_my_empire_event_info * info; //---------------------- //Е»¶ф±№°Ў ЕрАе ЅГЕ°±в : јєБцїЎј //---------------------- info = AllocEventInfo<quest::warp_all_to_map_my_empire_event_info>(); info->m_lMapIndexFrom = GetSungziMapIndex(); info->m_lMapIndexTo = EMPIRE_START_MAP(bLoseEmpire); info->m_x = EMPIRE_START_X(bLoseEmpire); info->m_y = EMPIRE_START_Y(bLoseEmpire); info->m_bEmpire = bLoseEmpire; event_create(quest::warp_all_to_map_my_empire_event, info, PASSES_PER_SEC(10)); //---------------------- //Е»¶ф±№°Ў ЕрАе ЅГЕ°±в : Ел·ОїЎј //---------------------- info = AllocEventInfo<quest::warp_all_to_map_my_empire_event_info>(); info->m_lMapIndexFrom = GetPassMapIndex(bLoseEmpire); info->m_lMapIndexTo = EMPIRE_START_MAP(bLoseEmpire); info->m_x = EMPIRE_START_X(bLoseEmpire); info->m_y = EMPIRE_START_Y(bLoseEmpire); info->m_bEmpire = bLoseEmpire; event_create(quest::warp_all_to_map_my_empire_event, info, PASSES_PER_SEC(10)); //---------------------- //јєБцїЎ ЖГ±вґВ ±№°ЎїЎ ґлЗС АМѕЯ±вё¦ ё¶їХАМ ЗФ! //---------------------- const std::string Nation(EMPIRE_NAME(bLoseEmpire)); const std::string Script( LC_TEXT("јєБцАЗ ё¶їХ: іКИс ") + Nation + LC_TEXT("іај®µйАє АМ°ч јєБцїЎ АЦА» АЪ°ЭА» АТѕъґЩ. ёрµО јєБцїЎј №°·ЇіЄ°Е¶у~~[ENTER][ENTER] 10ГК ИДїЎ ёрµО ё¶А»·О АМµїЗП°Ф µЛґПґЩ. ") + "[ENTER][DONE]" ); CHARACTER_MANAGER::instance().SendScriptToMap(pChar->GetMapIndex(), Script); //---------------------- // °шБц ЗС№ж іЇ·ББЬ. //---------------------- char szNotice[512+1]; snprintf(szNotice, sizeof(szNotice), LC_TEXT("»п°Её® АьЕхїЎј %s ±№°Ў°Ў °ЎАеёХАъ Е»¶фА» ЗПїґЅАґПґЩ"), Nation.c_str()); BroadcastNotice(szNotice); snprintf(szNotice, sizeof(szNotice), "First Step: %s exclusion", Nation.c_str()); LogManager::instance().CharLog(0, 0, 0, 0, "THREEWAY", szNotice, NULL); //---------------------- // ёчА» ё®БЁЗСґЩ. //---------------------- regen_mob_event_info* regen_info = AllocEventInfo<regen_mob_event_info>(); regen_info->dwMapIndex = pChar->GetMapIndex(); event_create(regen_mob_event, regen_info, PASSES_PER_SEC(10)); SetRegenFlag(1); } else if (1 == GetRegenFlag()) { int nVictoryEmpireIndex = 0; for (int n = 1; n < 4; ++n) { nKillScore = GetKillScore(n); if (nKillScore == -1) continue; if (nVictoryScore <= nKillScore) { nVictoryEmpireIndex = n; break; } } if (0 == nVictoryEmpireIndex) return; for (int n = 1; n < 4; ++n) { if (n != nVictoryEmpireIndex) { BYTE bLoseEmpire = n; quest::warp_all_to_map_my_empire_event_info * info; //---------------------- //Е»¶ф±№°Ў ЕрАе ЅГЕ°±в : јєБцїЎј //---------------------- info = AllocEventInfo<quest::warp_all_to_map_my_empire_event_info>(); info->m_lMapIndexFrom = GetSungziMapIndex(); info->m_lMapIndexTo = EMPIRE_START_MAP(bLoseEmpire); info->m_x = EMPIRE_START_X(bLoseEmpire); info->m_y = EMPIRE_START_Y(bLoseEmpire); info->m_bEmpire = bLoseEmpire; event_create(quest::warp_all_to_map_my_empire_event, info, PASSES_PER_SEC(5)); //---------------------- //Е»¶ф±№°Ў ЕрАе ЅГЕ°±в : Ел·ОїЎј //---------------------- info = AllocEventInfo<quest::warp_all_to_map_my_empire_event_info>(); info->m_lMapIndexFrom = GetPassMapIndex(bLoseEmpire); info->m_lMapIndexTo = EMPIRE_START_MAP(bLoseEmpire); info->m_x = EMPIRE_START_X(bLoseEmpire); info->m_y = EMPIRE_START_Y(bLoseEmpire); info->m_bEmpire = bLoseEmpire; event_create(quest::warp_all_to_map_my_empire_event, info, PASSES_PER_SEC(5)); } } //------------------------------ // ГЦБѕ ЅєДЪѕо ЗҐЅГ //------------------------------ { char szBuf[64 + 1]; snprintf(szBuf, sizeof(szBuf), LC_TEXT("ЗцАз ЅєДЪѕо ЅЕјц±№:%d ГµБ¶±№:%d Бшіл±№:%d"), GetKillScore(1), GetKillScore(2), GetKillScore(3)); SendNoticeMap(szBuf, GetSungziMapIndex(), false); } // ёЮјјБцё¦ ¶зїцБШґЩ. LPSECTREE_MAP pSecMap = SECTREE_MANAGER::instance().GetMap(pChar->GetMapIndex()); if (NULL != pSecMap) { const std::string EmpireName(EMPIRE_NAME(nVictoryEmpireIndex)); const std::string Script( EmpireName + LC_TEXT(". іКИс°Ў јєБцАЗ јцИЈАЪё¦ Ав°Ф µИґЩёй іКИсґВ јєБцАЗ БЦАОАМ µИґЩ.[ENTER][ENTER] ") + "[ENTER][DONE]"); struct packet_script pack_script; pack_script.header = HEADER_GC_SCRIPT; pack_script.skin = 1; pack_script.src_size = Script.size(); quest::FSendPacketToEmpire fSend; fSend.bEmpire = nVictoryEmpireIndex; pack_script.size = pack_script.src_size + sizeof(struct packet_script); fSend.buf.write(&pack_script, sizeof(struct packet_script)); fSend.buf.write(&Script[0], Script.size()); pSecMap->for_each(fSend); char szBuf[512]; snprintf(szBuf, sizeof(szBuf), "Second Step: %s remain", EMPIRE_NAME( nVictoryEmpireIndex )); LogManager::instance().CharLog(0, 0, 0, 0, "THREEWAY", szBuf, NULL); } //------------------------------ // ё¶Бцё· єё»у : Бш±ё№МИЈ јТИЇ //----------------------------- for (int n = 0; n < quest::CQuestManager::instance().GetEventFlag("threeway_war_boss_count");) { int x = pChar->GetX(); int y = pChar->GetY(); x = (thecore_random() & 1) ? x - number(200, 1000) : x + number(200, 1000); y = (thecore_random() & 1) ? y - number(200, 1000) : y + number(200, 1000); if (x < 0) x = pChar->GetX(); if (y < 0) y = pChar->GetY(); LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob( GetEventSungZiMapInfo().m_iBossMobVnum, pChar->GetMapIndex(), x, y, 0, false); if (NULL != ch) { ch->SetAggressive(); ++n; } } SetRegenFlag(-1); } }
int mob_spawn_group(lua_State* L) { if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3) || !lua_isnumber(L, 4) || !lua_isnumber(L, 6)) { sys_err("invalid argument"); lua_pushnumber(L, 0); return 1; } DWORD group_vnum = (DWORD)lua_tonumber(L, 1); long local_x = (long) lua_tonumber(L, 2) * 100; long local_y = (long) lua_tonumber(L, 3) * 100; float radius = (float) lua_tonumber(L, 4) * 100; bool bAggressive = lua_toboolean(L, 5); DWORD count = (DWORD) lua_tonumber(L, 6); if (count == 0) count = 1; else if (count > 10) { sys_err("count bigger than 10"); count = 10; } LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); LPSECTREE_MAP pMap = SECTREE_MANAGER::instance().GetMap(ch->GetMapIndex()); if (pMap == NULL) { lua_pushnumber(L, 0); return 1; } DWORD dwQuestIdx = CQuestManager::instance().GetCurrentPC()->GetCurrentQuestIndex(); bool ret = false; LPCHARACTER mob = NULL; while (count--) { for (int loop = 0; loop < 8; ++loop) { float angle = number(0, 999) * M_PI * 2 / 1000; float r = number(0, 999)*radius/1000; long x = local_x + pMap->m_setting.iBaseX + (long)(r * cos(angle)); long y = local_y + pMap->m_setting.iBaseY + (long)(r * sin(angle)); mob = CHARACTER_MANAGER::instance().SpawnGroup(group_vnum, ch->GetMapIndex(), x, y, x, y, NULL, bAggressive); if (mob) break; } if (mob) { mob->SetQuestBy(dwQuestIdx); if (!ret) { ret = true; lua_pushnumber(L, (DWORD) mob->GetVID()); } } } if (!ret) lua_pushnumber(L, 0); return 1; }
void CTargetManager::CreateTarget(DWORD dwPID, DWORD dwQuestIndex, const char * c_pszTargetName, int iType, int iArg1, int iArg2, int iMapIndex, const char * c_pszTargetDesc, int iSendFlag) { sys_log(0, "CreateTarget : target pid %u quest %u name %s arg %d %d %d", dwPID, dwQuestIndex, c_pszTargetName, iType, iArg1, iArg2); LPCHARACTER pkChr = CHARACTER_MANAGER::instance().FindByPID(dwPID); if (!pkChr) { sys_err("Cannot find character ptr by PID %u", dwPID); return; } if (pkChr->GetMapIndex() != iMapIndex) return; itertype(m_map_kListEvent) it = m_map_kListEvent.find(dwPID); if (it != m_map_kListEvent.end()) { std::list<LPEVENT>::const_iterator it2 = it->second.begin(); while (it2 != it->second.end()) { LPEVENT pkEvent = *(it2++); TargetInfo* existInfo = dynamic_cast<TargetInfo*>(pkEvent->info); if (NULL == existInfo) { sys_err("CreateTarget : event already exist, but have no info"); return; } if (existInfo->dwQuestIndex == dwQuestIndex && !strcmp(existInfo->szTargetName, c_pszTargetName)) { sys_log(0, "CreateTarget : same target will be replaced"); if (existInfo->bSendToClient) SendTargetDeletePacket(pkChr->GetDesc(), existInfo->iID); if (c_pszTargetDesc) { strlcpy(existInfo->szTargetDesc, c_pszTargetDesc, sizeof(existInfo->szTargetDesc)); } else { *existInfo->szTargetDesc = '\0'; } existInfo->iID = ++m_iID; existInfo->iType = iType; existInfo->iArg1 = iArg1; existInfo->iArg2 = iArg2; existInfo->iOldX = 0; existInfo->iOldY = 0; existInfo->bSendToClient = iSendFlag ? true : false; SendTargetCreatePacket(pkChr->GetDesc(), existInfo); return; } } } TargetInfo* newInfo = AllocEventInfo<TargetInfo>(); if (c_pszTargetDesc) { strlcpy(newInfo->szTargetDesc, c_pszTargetDesc, sizeof(newInfo->szTargetDesc)); } else { *newInfo->szTargetDesc = '\0'; } newInfo->iID = ++m_iID; // <Factor> Removed pkChr //newInfo->pkChr = pkChr; newInfo->dwPID = dwPID; newInfo->dwQuestIndex = dwQuestIndex; strlcpy(newInfo->szTargetName, c_pszTargetName, sizeof(newInfo->szTargetName)); newInfo->iType = iType; newInfo->iArg1 = iArg1; newInfo->iArg2 = iArg2; newInfo->iMapIndex = iMapIndex; newInfo->iOldX = 0; newInfo->iOldY = 0; newInfo->bSendToClient = iSendFlag ? true : false; LPEVENT event = event_create(target_event, newInfo, PASSES_PER_SEC(1)); if (NULL != event) { m_map_kListEvent[dwPID].push_back(event); SendTargetCreatePacket(pkChr->GetDesc(), newInfo); } }