#include "stdafx.h" #include "../../common/teen_packet.h" #include "../../common/VnumHelper.h" #include "char.h" #include "config.h" #include "utils.h" #include "crc32.h" #include "char_manager.h" #include "desc_client.h" #include "desc_manager.h" #include "buffer_manager.h" #include "item_manager.h" #include "motion.h" #include "vector.h" #include "packet.h" #include "cmd.h" #include "fishing.h" #include "exchange.h" #include "battle.h" #include "affect.h" #include "shop.h" #include "shop_manager.h" #include "safebox.h" #include "regen.h" #include "pvp.h" #include "party.h" #include "start_position.h" #include "questmanager.h" #include "log.h" #include "p2p.h" #include "guild.h" #include "guild_manager.h" #include "dungeon.h" #include "messenger_manager.h" #include "unique_item.h" #include "priv_manager.h" #include "war_map.h" #include "xmas_event.h" #include "banword.h" #include "target.h" #include "wedding.h" #include "mob_manager.h" #include "mining.h" #include "monarch.h" #include "castle.h" #include "arena.h" #include "dev_log.h" #include "horsename_manager.h" #include "pcbang.h" #include "gm.h" #include "map_location.h" #include "BlueDragon_Binder.h" #include "HackShield.h" #include "skill_power.h" #include "XTrapManager.h" #include "buff_on_attributes.h" #ifdef ENABLE_MOUNT_COSTUME_SYSTEM #include "MountSystem.h" #endif #ifdef __ENABLE_NEW_OFFLINESHOP__ #include "new_offlineshop.h" #include "new_offlineshop_manager.h" #endif #ifdef ENABLE_NEW_PET_SYSTEM #include "New_PetSystem.h" #endif #ifdef __PET_SYSTEM__ #include "PetSystem.h" #endif #include "DragonSoul.h" #include "../../common/CommonDefines.h" #ifdef ENABLE_SWITCHBOT #include "new_switchbot.h" #endif #ifdef ENABLE_TARGET_INFORMATION_SYSTEM #include #include using namespace std; #endif #ifdef BOSS_ARENA #include "bossarena.h" #endif extern const BYTE g_aBuffOnAttrPoints; extern bool RaceToJob(unsigned race, unsigned* ret_job); extern bool IS_SUMMONABLE_ZONE(int map_index); // char_item.cpp bool CAN_ENTER_ZONE(const LPCHARACTER& ch, int map_index); bool CAN_ENTER_ZONE(const LPCHARACTER& ch, int map_index) { switch (map_index) { case 301: case 302: case 303: case 304: if (ch->GetLevel() < 90) return false; } return true; } #ifdef NEW_ICEDAMAGE_SYSTEM const DWORD CHARACTER::GetNoDamageRaceFlag() { return m_dwNDRFlag; } void CHARACTER::SetNoDamageRaceFlag(DWORD dwRaceFlag) { if (dwRaceFlag >= MAIN_RACE_MAX_NUM) return; if (IS_SET(m_dwNDRFlag, 1 << dwRaceFlag)) return; SET_BIT(m_dwNDRFlag, 1 << dwRaceFlag); } void CHARACTER::UnsetNoDamageRaceFlag(DWORD dwRaceFlag) { if (dwRaceFlag >= MAIN_RACE_MAX_NUM) return; if (!IS_SET(m_dwNDRFlag, 1 << dwRaceFlag)) return; REMOVE_BIT(m_dwNDRFlag, 1 << dwRaceFlag); } void CHARACTER::ResetNoDamageRaceFlag() { m_dwNDRFlag = 0; } const std::set& CHARACTER::GetNoDamageAffectFlag() { return m_setNDAFlag; } void CHARACTER::SetNoDamageAffectFlag(DWORD dwAffectFlag) { m_setNDAFlag.insert(dwAffectFlag); } void CHARACTER::UnsetNoDamageAffectFlag(DWORD dwAffectFlag) { m_setNDAFlag.erase(dwAffectFlag); } void CHARACTER::ResetNoDamageAffectFlag() { m_setNDAFlag.clear(); } #endif // DynamicCharacterPtr member function definitions LPCHARACTER DynamicCharacterPtr::Get() const { LPCHARACTER p = NULL; if (is_pc) { p = CHARACTER_MANAGER::instance().FindByPID(id); } else { p = CHARACTER_MANAGER::instance().Find(id); } return p; } DynamicCharacterPtr& DynamicCharacterPtr::operator=(LPCHARACTER character) { if (character == NULL) { Reset(); return *this; } if (character->IsPC()) { is_pc = true; id = character->GetPlayerID(); } else { is_pc = false; id = character->GetVID(); } return *this; } CHARACTER::CHARACTER() { m_stateIdle.Set(this, &CHARACTER::BeginStateEmpty, &CHARACTER::StateIdle, &CHARACTER::EndStateEmpty); m_stateMove.Set(this, &CHARACTER::BeginStateEmpty, &CHARACTER::StateMove, &CHARACTER::EndStateEmpty); m_stateBattle.Set(this, &CHARACTER::BeginStateEmpty, &CHARACTER::StateBattle, &CHARACTER::EndStateEmpty); Initialize(); } CHARACTER::~CHARACTER() { Destroy(); } void CHARACTER::Initialize() { CEntity::Initialize(ENTITY_CHARACTER); m_bNoOpenedShop = true; m_bOpeningSafebox = false; m_fSyncTime = get_float_time() - 3; m_dwPlayerID = 0; m_dwKillerPID = 0; #ifdef BOSS_ARENA m_bBossArenaTest = false; m_dungeoncd = 0; #endif m_iMoveCount = 0; #ifdef TITLE_SYSTEM m_title_time = 0; #endif m_pkRegen = NULL; regen_id_ = 0; m_posRegen.x = m_posRegen.y = m_posRegen.z = 0; m_posStart.x = m_posStart.y = 0; m_posDest.x = m_posDest.y = 0; m_fRegenAngle = 0.0f; m_pkMobData = NULL; m_pkMobInst = NULL; m_pkShop = NULL; m_pkChrShopOwner = NULL; m_pkMyShop = NULL; m_pkExchange = NULL; m_pkParty = NULL; m_pkPartyRequestEvent = NULL; m_pGuild = NULL; m_pkChrTarget = NULL; m_pkMuyeongEvent = NULL; m_pkWarpNPCEvent = NULL; m_pkDeadEvent = NULL; m_pkStunEvent = NULL; m_pkSaveEvent = NULL; m_pkRecoveryEvent = NULL; m_pkTimedEvent = NULL; m_pkFishingEvent = NULL; m_pkWarpEvent = NULL; #ifdef BOSS_ARENA m_pkBossInfoEvent = NULL; #endif // MINING m_pkMiningEvent = NULL; // END_OF_MINING m_pkPoisonEvent = NULL; #ifdef ENABLE_WOLFMAN_CHARACTER m_pkBleedingEvent = NULL; #endif m_pkFireEvent = NULL; m_pkCheckSpeedHackEvent = NULL; m_speed_hack_count = 0; m_pkAffectEvent = NULL; m_afAffectFlag = TAffectFlag(0, 0); m_pkDestroyWhenIdleEvent = NULL; m_pkChrSyncOwner = NULL; m_points = {}; m_pointsInstant = {}; memset(&m_quickslot, 0, sizeof(m_quickslot)); #ifdef ENABLE_KILL_STATISTICS memset(&m_killstatistics, 0, sizeof(m_killstatistics)); #endif m_bCharType = CHAR_TYPE_MONSTER; SetPosition(POS_STANDING); m_dwPlayStartTime = m_dwLastMoveTime = get_dword_time(); GotoState(m_stateIdle); m_dwStateDuration = 1; #ifdef ENABLE_LAST_ATTACK_TIME_FIX m_dwLastAttackTime = std::min(0UL, static_cast(get_dword_time()) - 120000UL); //2m ago (for some reason?) #else m_dwLastAttackTime = get_dword_time() - 20000; #endif m_bAddChrState = 0; m_pkChrStone = NULL; m_pkSafebox = NULL; m_iSafeboxSize = -1; m_iSafeboxLoadTime = 0; m_pkMall = NULL; m_iMallLoadTime = 0; m_posWarp.x = m_posWarp.y = m_posWarp.z = 0; m_lWarpMapIndex = 0; m_posExit.x = m_posExit.y = m_posExit.z = 0; m_lExitMapIndex = 0; m_pSkillLevels = NULL; m_dwMoveStartTime = 0; m_dwMoveDuration = 0; m_dwFlyTargetID = 0; m_dwNextStatePulse = 0; m_dwLastDeadTime = get_dword_time() - 180000; m_bSkipSave = false; m_bItemLoaded = false; m_bHasPoisoned = false; #ifdef ENABLE_WOLFMAN_CHARACTER m_bHasBled = false; #endif m_pkDungeon = NULL; m_iEventAttr = 0; m_kAttackLog.dwVID = 0; m_kAttackLog.dwTime = 0; m_bNowWalking = m_bWalking = false; ResetChangeAttackPositionTime(); m_bDetailLog = false; m_bMonsterLog = false; m_bDisableCooltime = false; m_iAlignment = 0; m_iRealAlignment = 0; m_iKillerModePulse = 0; m_bPKMode = PK_MODE_PEACE; m_dwQuestNPCVID = 0; m_dwQuestByVnum = 0; m_pQuestItem = NULL; m_szMobileAuth[0] = '\0'; m_dwUnderGuildWarInfoMessageTime = get_dword_time() - 60000; m_bUnderRefine = false; // REFINE_NPC m_dwRefineNPCVID = 0; // END_OF_REFINE_NPC m_dwPolymorphRace = 0; m_bStaminaConsume = false; ResetChainLightningIndex(); m_dwMountVnum = 0; m_chHorse = NULL; m_chRider = NULL; #ifdef __ENABLE_NEW_OFFLINESHOP__ m_pkOfflineShop = NULL; m_pkShopSafebox = NULL; m_pkAuction = NULL; m_pkAuctionGuest = NULL; //offlineshop-updated 03/08/19 m_pkOfflineShopGuest = NULL; //offlineshop-updated 05/08/19 m_bIsLookingOfflineshopOfferList = false; #endif m_pWarMap = NULL; #ifdef FATE_ROULETTE m_fatereward = 0; m_faterewardcount = 0; #endif m_pWeddingMap = NULL; m_bChatCounter = 0; ResetStopTime(); m_dwLastVictimSetTime = get_dword_time() - 3000; m_iMaxAggro = -100; m_bSendHorseLevel = 0; m_bSendHorseHealthGrade = 0; m_bSendHorseStaminaGrade = 0; m_dwLoginPlayTime = 0; m_pkChrMarried = NULL; m_posSafeboxOpen.x = -1000; m_posSafeboxOpen.y = -1000; // EQUIP_LAST_SKILL_DELAY m_dwLastSkillTime = get_dword_time(); // END_OF_EQUIP_LAST_SKILL_DELAY // MOB_SKILL_COOLTIME memset(m_adwMobSkillCooltime, 0, sizeof(m_adwMobSkillCooltime)); // END_OF_MOB_SKILL_COOLTIME m_isinPCBang = false; #ifdef ENABLE_CAMP_FIRE_FIX LastCampFireUse = 0; #endif // ARENA m_pArena = NULL; m_nPotionLimit = quest::CQuestManager::instance().GetEventFlag("arena_potion_limit_count"); // END_ARENA //PREVENT_TRADE_WINDOW m_isOpenSafebox = 0; //END_PREVENT_TRADE_WINDOW //PREVENT_REFINE_HACK m_iRefineTime = 0; //END_PREVENT_REFINE_HACK //RESTRICT_USE_SEED_OR_MOONBOTTLE m_iSeedTime = 0; //END_RESTRICT_USE_SEED_OR_MOONBOTTLE //PREVENT_PORTAL_AFTER_EXCHANGE m_iExchangeTime = 0; //END_PREVENT_PORTAL_AFTER_EXCHANGE // m_iSafeboxLoadTime = 0; m_iMyShopTime = 0; InitMC(); m_deposit_pulse = 0; SET_OVER_TIME(this, OT_NONE); #ifdef ENABLE_STR_NEW_NAME_FIX m_strNewName.clear(); #else m_strNewName = ""; #endif m_known_guild.clear(); m_dwLogOffInterval = 0; m_bComboSequence = 0; m_dwLastComboTime = 0; m_bComboIndex = 0; m_iComboHackCount = 0; m_dwSkipComboAttackByTime = 0; m_dwMountTime = 0; m_dwLastGoldDropTime = 0; #ifdef ENABLE_NEWSTUFF m_dwLastItemDropTime = 0; m_dwLastBoxUseTime = 0; m_dwLastBuySellTime = 0; #endif m_HackShieldCheckEvent = NULL; m_HackShieldCheckMode = false; m_bIsLoadedAffect = false; cannot_dead = false; #ifdef __PET_SYSTEM__ m_petSystem = 0; m_bIsPet = false; #endif #ifdef NEW_ICEDAMAGE_SYSTEM m_dwNDRFlag = 0; m_setNDAFlag.clear(); #endif m_fAttMul = 1.0f; m_fDamMul = 1.0f; m_pointsInstant.iDragonSoulActiveDeck = -1; #ifdef ENABLE_ANTI_CMD_FLOOD m_dwCmdAntiFloodCount = 0; m_dwCmdAntiFloodPulse = 0; #endif #ifdef ENABLE_ITEM_AWARD_FIX itemAward_vnum = 0; memset(itemAward_cmd, 0, 20); #endif memset(&m_tvLastSyncTime, 0, sizeof(m_tvLastSyncTime)); m_iSyncHackCount = 0; #ifdef ENABLE_ACCE_SYSTEM m_bAcceCombination = false; m_bAcceAbsorption = false; #endif #ifdef ENABLE_AURA_SYSTEM m_bAuraRefine = false; m_bAuraAbsorption = false; #endif #ifdef ENABLE_TARGET_INFORMATION_SYSTEM dwLastTargetInfoPulse = 0; #endif #ifdef ENABLE_MOUNT_COSTUME_SYSTEM m_mountSystem = 0; m_bIsMount = false; m_bMountCounter = 0; #endif #ifdef ENABLE_NEW_PET_SYSTEM m_stImmortalSt = 0; m_newpetskillcd[0] = 0; m_newpetskillcd[1] = 0; m_newpetskillcd[2] = 0; m_newpetSystem = 0; m_bIsNewPet = false; m_eggvid = 0; #endif #ifdef ENABLE_SWITCHBOT //ENABLE_SWITCHBOT_OPTIMIZE switchbotwin = false; #endif #ifdef ENABLE_SKILL_COLOR_SYSTEM memset(&m_dwSkillColor, 0, sizeof(m_dwSkillColor)); #endif #ifdef ENABLE_HIDE_COSTUME_SYSTEM m_bHideBodyCostume = false; m_bHideHairCostume = false; m_bHideAcceCostume = false; m_bHideWeaponCostume = false; #endif #ifdef ENABLE_CHANGELOOK_SYSTEM m_bChangeLook = false; #ifdef ENABLE_MOUNT_CHANGELOOK_SYSTEM m_bMountChangeLook = false; #endif #endif #ifdef ENABLE_REBIRT_SYSTEM m_dwRebirtLastTime = 0; #endif #ifdef ENABLE_REBORN_SYSTEM m_dwRebornLastTime = 0; #endif #ifdef ENABLE_TIME_CONTROL m_iDsLoadTime = 0; m_iPetLoadTime = 0; m_iEquipLoadTime = 0; #endif #ifdef ENABLE_NEW_RANKING m_iRankGiftTime = 0; #endif #ifdef ENABLE_BIOLOG_SYSTEM m_pkBiologManager = NULL; #endif analyze_protect = 0; analyze_protect_count = 0; analyze_protect_other_count = 0; #ifdef MODERATED_NPC m_iModeratedVnum = 0; m_iQuestNpcVnum = 0; #endif } void CHARACTER::Create(const char* c_pszName, DWORD vid, bool isPC) { static int s_crc = 172814; char crc_string[128 + 1]; snprintf(crc_string, sizeof(crc_string), "%s%p%d", c_pszName, this, ++s_crc); m_vid = VID(vid, GetCRC32(crc_string, strlen(crc_string))); if (isPC) m_stName = c_pszName; } void CHARACTER::Destroy() { CloseMyShop(); if (m_pkRegen) { if (m_pkDungeon) { // Dungeon regen may not be valid at this point if (m_pkDungeon->IsValidRegen(m_pkRegen, regen_id_)) { --m_pkRegen->count; } } else { // Is this really safe? --m_pkRegen->count; } m_pkRegen = NULL; } #ifdef ENABLE_MOUNT_COSTUME_SYSTEM if (m_mountSystem) { m_mountSystem->Destroy(); delete m_mountSystem; m_mountSystem = 0; } if (GetMountVnum()) { RemoveAffect(AFFECT_MOUNT); RemoveAffect(AFFECT_MOUNT_BONUS); } HorseSummon(false); #endif if (m_pkDungeon) { SetDungeon(NULL); } #ifdef __PET_SYSTEM__ if (m_petSystem) { m_petSystem->Destroy(); delete m_petSystem; m_petSystem = 0; } #endif #ifdef ENABLE_NEW_PET_SYSTEM if (m_newpetSystem) { m_newpetSystem->Destroy(); delete m_newpetSystem; m_newpetSystem = 0; } #endif HorseSummon(false); if (GetRider()) GetRider()->ClearHorseInfo(); if (IsPC()) { if (isHackShieldEnable) { CHackShieldManager::instance().DeleteClientHandle(GetPlayerID()); } } if (GetDesc()) { GetDesc()->BindCharacter(NULL); // BindDesc(NULL); } if (m_pkExchange) m_pkExchange->Cancel(); SetVictim(NULL); if (GetShop()) { GetShop()->RemoveGuest(this); SetShop(NULL); } ClearStone(); ClearSync(); ClearTarget(); if (NULL == m_pkMobData) { DragonSoul_CleanUp(); ClearItem(); } // m_pkParty becomes NULL after CParty destructor call! LPPARTY party = m_pkParty; if (party) { if (party->GetLeaderPID() == GetVID() && !IsPC()) { M2_DELETE(party); } else { party->Unlink(this); if (!IsPC()) party->Quit(GetVID()); } SetParty(NULL); } if (m_pkMobInst) { M2_DELETE(m_pkMobInst); m_pkMobInst = NULL; } m_pkMobData = NULL; if (m_pkSafebox) { M2_DELETE(m_pkSafebox); m_pkSafebox = NULL; } if (m_pkMall) { M2_DELETE(m_pkMall); m_pkMall = NULL; } for (TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.begin(); it != m_map_buff_on_attrs.end(); it++) { if (NULL != it->second) { M2_DELETE(it->second); } } m_map_buff_on_attrs.clear(); m_set_pkChrSpawnedBy.clear(); StopMuyeongEvent(); event_cancel(&m_pkWarpNPCEvent); event_cancel(&m_pkRecoveryEvent); event_cancel(&m_pkDeadEvent); event_cancel(&m_pkSaveEvent); event_cancel(&m_pkTimedEvent); event_cancel(&m_pkStunEvent); event_cancel(&m_pkFishingEvent); event_cancel(&m_pkPoisonEvent); #ifdef BOSS_ARENA event_cancel(&m_pkBossInfoEvent); #endif #ifdef ENABLE_WOLFMAN_CHARACTER event_cancel(&m_pkBleedingEvent); #endif event_cancel(&m_pkFireEvent); event_cancel(&m_pkPartyRequestEvent); //DELAYED_WARP event_cancel(&m_pkWarpEvent); event_cancel(&m_pkCheckSpeedHackEvent); //END_DELAYED_WARP // RECALL_DELAY //event_cancel(&m_pkRecallEvent); // END_OF_RECALL_DELAY // MINING event_cancel(&m_pkMiningEvent); // END_OF_MINING StopHackShieldCheckCycle(); for (itertype(m_mapMobSkillEvent) it = m_mapMobSkillEvent.begin(); it != m_mapMobSkillEvent.end(); ++it) { LPEVENT pkEvent = it->second; event_cancel(&pkEvent); } m_mapMobSkillEvent.clear(); //event_cancel(&m_pkAffectEvent); ClearAffect(); event_cancel(&m_pkDestroyWhenIdleEvent); if (m_pSkillLevels) { M2_DELETE_ARRAY(m_pSkillLevels); m_pSkillLevels = NULL; } CEntity::Destroy(); if (GetSectree()) GetSectree()->RemoveEntity(this); if (m_bMonsterLog) CHARACTER_MANAGER::instance().UnregisterForMonsterLog(this); } const char* CHARACTER::GetName() const { return m_stName.empty() ? (m_pkMobData ? m_pkMobData->m_table.szLocaleName : "") : m_stName.c_str(); } #ifdef ENABLE_ITEM_COUNT_LIMIT_SYSTEM void CHARACTER::OpenMyShop(const char* c_pszSign, TShopItemTable* pTable, WORD bItemCount) #else void CHARACTER::OpenMyShop(const char* c_pszSign, TShopItemTable* pTable, BYTE bItemCount) #endif { if (!CanHandleItem()) // @fixme149 { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("´Ù¸¥ °Å·¡Áß(â°í,±³È¯,»óÁ¡)¿¡´Â °³ÀλóÁ¡À» »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; } #ifndef ENABLE_OPEN_SHOP_WITH_ARMOR if (GetPart(PART_MAIN) > 2) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("°©¿ÊÀ» ¹ş¾î¾ß °³ÀÎ »óÁ¡À» ¿­ ¼ö ÀÖ½À´Ï´Ù.")); return; } #endif if (!(GetMapIndex() == 1 || GetMapIndex() == 21 || GetMapIndex() == 41))// @fixme189 { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Bu haritada pazar acamazsin.")); return; } if (GetMyShop()) { CloseMyShop(); return; } quest::PC* pPC = quest::CQuestManager::instance().GetPCForce(GetPlayerID()); if (pPC->IsRunning()) return; if (bItemCount == 0) return; #ifdef ENABLE_YANG_LIMIT_SYSTEM long long nTotalMoney = 0; for (int n = 0; n < bItemCount; ++n) { nTotalMoney += (pTable + n)->price; } nTotalMoney += GetGold(); if (GOLD_MAX <= nTotalMoney) { sys_err("[OVERFLOW_GOLD] Overflow (GOLD_MAX) id %u name %s", GetPlayerID(), GetName()); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("20¾ï ³ÉÀ» ÃÊ°úÇÏ¿© »óÁ¡À» ¿­¼ö°¡ ¾ø½À´Ï´Ù")); return; } #else int64_t nTotalMoney = 0; for (int n = 0; n < bItemCount; ++n) { nTotalMoney += static_cast((pTable + n)->price); } nTotalMoney += static_cast(GetGold()); if (GOLD_MAX <= nTotalMoney) { sys_err("[OVERFLOW_GOLD] Overflow (GOLD_MAX) id %u name %s", GetPlayerID(), GetName()); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("20¾ï ³ÉÀ» ÃÊ°úÇÏ¿© »óÁ¡À» ¿­¼ö°¡ ¾ø½À´Ï´Ù")); return; } #endif char szSign[SHOP_SIGN_MAX_LEN + 1]; strlcpy(szSign, c_pszSign, sizeof(szSign)); m_stShopSign = szSign; if (m_stShopSign.length() == 0) return; if (CBanwordManager::instance().CheckString(m_stShopSign.c_str(), m_stShopSign.length())) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ºñ¼Ó¾î³ª Àº¾î°¡ Æ÷ÇÔµÈ »óÁ¡ À̸§À¸·Î »óÁ¡À» ¿­ ¼ö ¾ø½À´Ï´Ù.")); return; } // MYSHOP_PRICE_LIST std::map itemkind; // END_OF_MYSHOP_PRICE_LIST std::set cont; #ifdef ENABLE_ITEM_COUNT_LIMIT_SYSTEM for (WORD i = 0; i < bItemCount; ++i) #else for (BYTE i = 0; i < bItemCount; ++i) #endif { if (cont.find((pTable + i)->pos) != cont.end()) { sys_err("MYSHOP: duplicate shop item detected! (name: %s)", GetName()); return; } // ANTI_GIVE, ANTI_MYSHOP check LPITEM pkItem = GetItem((pTable + i)->pos); if (pkItem) { const TItemTable* item_table = pkItem->GetProto(); if (item_table && (IS_SET(item_table->dwAntiFlags, ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_MYSHOP))) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("À¯·áÈ­ ¾ÆÀÌÅÛÀº °³ÀλóÁ¡¿¡¼­ ÆǸÅÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; } if (pkItem->IsEquipped() == true) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ÀåºñÁßÀÎ ¾ÆÀÌÅÛÀº °³ÀλóÁ¡¿¡¼­ ÆǸÅÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; } if (true == pkItem->isLocked()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»ç¿ëÁßÀÎ ¾ÆÀÌÅÛÀº °³ÀλóÁ¡¿¡¼­ ÆǸÅÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; } #ifdef ENABLE_BASIC_ITEM_SYSTEM if (pkItem->IsBasicItem()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Can't trade with sealed item.")); return; } #endif // MYSHOP_PRICE_LIST itemkind[pkItem->GetVnum()] = (pTable + i)->price / pkItem->GetCount(); // END_OF_MYSHOP_PRICE_LIST } cont.insert((pTable + i)->pos); } // MYSHOP_PRICE_LIST if (CountSpecifyItem(71049)) { // @fixme403 BEGIN TItemPriceListTable header; memset(&header, 0, sizeof(TItemPriceListTable)); header.dwOwnerID = GetPlayerID(); header.byCount = itemkind.size(); size_t idx = 0; for (itertype(itemkind) it = itemkind.begin(); it != itemkind.end(); ++it) { header.aPriceInfo[idx].dwVnum = it->first; #ifdef ENABLE_YANG_LIMIT_SYSTEM header.aPriceInfo[idx].llPrice = it->second; #else header.aPriceInfo[idx].dwPrice = it->second; #endif idx++; } db_clientdesc->DBPacket(HEADER_GD_MYSHOP_PRICELIST_UPDATE, GetDesc()->GetHandle(), &header, sizeof(TItemPriceListTable)); // @fixme403 END } // END_OF_MYSHOP_PRICE_LIST else if (CountSpecifyItem(50200)) RemoveSpecifyItem(50200, 1); else return; if (m_pkExchange) m_pkExchange->Cancel(); TPacketGCShopSign p; p.bHeader = HEADER_GC_SHOP_SIGN; p.dwVID = GetVID(); strlcpy(p.szSign, c_pszSign, sizeof(p.szSign)); PacketAround(&p, sizeof(TPacketGCShopSign)); m_pkMyShop = CShopManager::instance().CreatePCShop(this, pTable, bItemCount); if (IsPolymorphed() == true) { RemoveAffect(AFFECT_POLYMORPH); } if (GetHorse()) { HorseSummon(false, true); } else if (GetMountVnum()) { RemoveAffect(AFFECT_MOUNT); RemoveAffect(AFFECT_MOUNT_BONUS); } SetPolymorph(30000, true); } void CHARACTER::CloseMyShop() { if (GetMyShop()) { m_stShopSign.clear(); CShopManager::instance().DestroyPCShop(this); m_pkMyShop = NULL; TPacketGCShopSign p; p.bHeader = HEADER_GC_SHOP_SIGN; p.dwVID = GetVID(); p.szSign[0] = '\0'; PacketAround(&p, sizeof(p)); #ifdef ENABLE_WOLFMAN_CHARACTER SetPolymorph(m_points.job, true); // SetPolymorph(0, true); #else SetPolymorph(GetJob(), true); #endif } } void EncodeMovePacket(TPacketGCMove& pack, DWORD dwVID, BYTE bFunc, BYTE bArg, DWORD x, DWORD y, DWORD dwDuration, DWORD dwTime, BYTE bRot) { pack.bHeader = HEADER_GC_MOVE; pack.bFunc = bFunc; pack.bArg = bArg; pack.dwVID = dwVID; pack.dwTime = dwTime ? dwTime : get_dword_time(); pack.bRot = bRot; pack.lX = x; pack.lY = y; pack.dwDuration = dwDuration; } void CHARACTER::RestartAtSamePos() { if (m_bIsObserver) return; EncodeRemovePacket(this); EncodeInsertPacket(this); ENTITY_MAP::iterator it = m_map_view.begin(); while (it != m_map_view.end()) { LPENTITY entity = (it++)->first; EncodeRemovePacket(entity); if (!m_bIsObserver) EncodeInsertPacket(entity); if (entity->IsType(ENTITY_CHARACTER)) { LPCHARACTER lpChar = (LPCHARACTER)entity; if (lpChar->IsPC() || lpChar->IsNPC() || lpChar->IsMonster()) { if (!entity->IsObserverMode()) entity->EncodeInsertPacket(this); } } else { if (!entity->IsObserverMode()) { entity->EncodeInsertPacket(this); } } } } // #define ENABLE_SHOWNPCLEVEL void CHARACTER::EncodeInsertPacket(LPENTITY entity) { LPDESC d; if (!(d = entity->GetDesc())) return; LPCHARACTER ch = (LPCHARACTER)entity; ch->SendGuildName(GetGuild()); TPacketGCCharacterAdd pack; pack.header = HEADER_GC_CHARACTER_ADD; pack.dwVID = m_vid; pack.bType = GetCharType(); pack.angle = GetRotation(); pack.x = GetX(); pack.y = GetY(); pack.z = GetZ(); pack.wRaceNum = GetRaceNum(); #ifdef ENABLE_MOUNT_COSTUME_SYSTEM #ifdef ENABLE_NEW_PET_SYSTEM if (IsPet() || IsMount() || IsNewPet()) #else if (IsPet() || IsMount()) #endif #else if (IsPet()) #endif { pack.bMovingSpeed = 200; } else { pack.bMovingSpeed = GetLimitPoint(POINT_MOV_SPEED); } #if defined(WJ_SHOP_MOB_INFO) if (IsMonster() || IsStone()) { pack.dwLevel = GetLevel(); pack.dwAIFlag = IsMonster() ? GetAIFlag() : 0; } else { pack.dwLevel = 0; pack.dwAIFlag = 0; } #endif pack.bAttackSpeed = GetLimitPoint(POINT_ATT_SPEED); pack.dwAffectFlag[0] = m_afAffectFlag.bits[0]; pack.dwAffectFlag[1] = m_afAffectFlag.bits[1]; pack.bStateFlag = m_bAddChrState; int iDur = 0; if (m_posDest.x != pack.x || m_posDest.y != pack.y) { iDur = (m_dwMoveStartTime + m_dwMoveDuration) - get_dword_time(); if (iDur <= 0) { pack.x = m_posDest.x; pack.y = m_posDest.y; } } d->Packet(&pack, sizeof(pack)); if (IsPC() == true || m_bCharType == CHAR_TYPE_NPC #ifdef MODERATED_NPC || IsModeratedNPC() #endif ) { TPacketGCCharacterAdditionalInfo addPacket; memset(&addPacket, 0, sizeof(TPacketGCCharacterAdditionalInfo)); addPacket.header = HEADER_GC_CHAR_ADDITIONAL_INFO; addPacket.dwVID = m_vid; addPacket.awPart[CHR_EQUIPPART_ARMOR] = GetPart(PART_MAIN); addPacket.awPart[CHR_EQUIPPART_WEAPON] = GetPart(PART_WEAPON); addPacket.awPart[CHR_EQUIPPART_HEAD] = GetPart(PART_HEAD); addPacket.awPart[CHR_EQUIPPART_HAIR] = GetPart(PART_HAIR); #ifdef ENABLE_ACCE_SYSTEM # ifdef ENABLE_WINGS_NEW const LPITEM pWing = GetWear(WEAR_COSTUME_WING); addPacket.awPart[CHR_EQUIPPART_ACCE] = pWing ? 0 : GetPart(PART_ACCE); # else addPacket.awPart[CHR_EQUIPPART_ACCE] = GetPart(PART_ACCE); # endif #endif #ifdef ENABLE_WINGS_NEW addPacket.awPart[CHR_EQUIPPART_WING] = GetPart(PART_WING); #endif #ifdef ENABLE_AURA_SYSTEM addPacket.awPart[CHR_EQUIPPART_AURA] = GetPart(PART_AURA); #endif addPacket.bPKMode = m_bPKMode; addPacket.dwMountVnum = GetMountVnum(); addPacket.dwNewPlayTime = GetRealPoint(POINT_PLAYTIME); addPacket.bEmpire = m_bEmpire; #ifdef ENABLE_REBIRT_SYSTEM if (IsPC() == true) addPacket.bRebirt = GetRebirt(); else addPacket.bRebirt = 0; #endif #ifdef ENABLE_REBORN_SYSTEM if (IsPC() == true) addPacket.bReborn = GetReborn(); else addPacket.bReborn = 0; #endif #ifdef ENABLE_SHOWNPCLEVEL if (1) #else if (IsPC() == true || IsNewPet() == true) #endif { addPacket.dwLevel = GetLevel(); } else { addPacket.dwLevel = 0; } if (false) { LPCHARACTER ch = (LPCHARACTER)entity; if (GetEmpire() == ch->GetEmpire() || ch->GetGMLevel() > GM_PLAYER || m_bCharType == CHAR_TYPE_NPC) { goto show_all_info; } else { memset(addPacket.name, 0, CHARACTER_NAME_MAX_LEN); addPacket.dwGuildID = 0; #ifdef ENABLE_GUILD_LEADER_GRADE_NAME addPacket.bGuildLeaderGrade = 0; #endif addPacket.sAlignment = 0; } } else { show_all_info: strlcpy(addPacket.name, GetName(), sizeof(addPacket.name)); if (GetGuild() != NULL) { #ifdef TITLE_SYSTEM if (IsPC()) { addPacket.title = GetTitle(); } else { addPacket.title = 0; } #endif addPacket.dwGuildID = GetGuild()->GetID(); #ifdef ENABLE_GUILD_LEADER_GRADE_NAME CGuild* pGuild = this->GetGuild(); if (pGuild->GetMasterPID() == GetPlayerID()) addPacket.bGuildLeaderGrade = 3; else if (pGuild->GetGeneralPID(GetPlayerID()) == true) addPacket.bGuildLeaderGrade = 2; else addPacket.bGuildLeaderGrade = 1; #endif } else { addPacket.dwGuildID = 0; #ifdef ENABLE_GUILD_LEADER_GRADE_NAME addPacket.bGuildLeaderGrade = 0; #endif } addPacket.sAlignment = m_iAlignment / 10; if (IsPC()) { #ifdef ENABLE_SKILL_COLOR_SYSTEM thecore_memcpy(addPacket.dwSkillColor, GetSkillColor(), sizeof(addPacket.dwSkillColor)); #endif } } d->Packet(&addPacket, sizeof(TPacketGCCharacterAdditionalInfo)); } if (iDur) { TPacketGCMove pack; EncodeMovePacket(pack, GetVID(), FUNC_MOVE, 0, m_posDest.x, m_posDest.y, iDur, 0, (BYTE)(GetRotation() / 5)); d->Packet(&pack, sizeof(pack)); TPacketGCWalkMode p; p.vid = GetVID(); p.header = HEADER_GC_WALK_MODE; p.mode = m_bNowWalking ? WALKMODE_WALK : WALKMODE_RUN; d->Packet(&p, sizeof(p)); } if (entity->IsType(ENTITY_CHARACTER) && GetDesc()) { LPCHARACTER ch = (LPCHARACTER)entity; if (ch->IsWalking()) { TPacketGCWalkMode p; p.vid = ch->GetVID(); p.header = HEADER_GC_WALK_MODE; p.mode = ch->m_bNowWalking ? WALKMODE_WALK : WALKMODE_RUN; GetDesc()->Packet(&p, sizeof(p)); } } if (GetMyShop()) { TPacketGCShopSign p; p.bHeader = HEADER_GC_SHOP_SIGN; p.dwVID = GetVID(); strlcpy(p.szSign, m_stShopSign.c_str(), sizeof(p.szSign)); d->Packet(&p, sizeof(TPacketGCShopSign)); } if (entity->IsType(ENTITY_CHARACTER)) { sys_log(3, "EntityInsert %s (RaceNum %d) (%d %d) TO %s", GetName(), GetRaceNum(), GetX() / SECTREE_SIZE, GetY() / SECTREE_SIZE, ((LPCHARACTER)entity)->GetName()); } } void CHARACTER::EncodeRemovePacket(LPENTITY entity) { if (entity->GetType() != ENTITY_CHARACTER) return; LPDESC d; if (!(d = entity->GetDesc())) return; TPacketGCCharacterDelete pack; pack.header = HEADER_GC_CHARACTER_DEL; pack.id = m_vid; d->Packet(&pack, sizeof(TPacketGCCharacterDelete)); if (entity->IsType(ENTITY_CHARACTER)) sys_log(3, "EntityRemove %s(%d) FROM %s", GetName(), (DWORD)m_vid, ((LPCHARACTER)entity)->GetName()); } void CHARACTER::UpdatePacket() { if (GetSectree() == NULL) return; if (IsPC() && (!GetDesc() || !GetDesc()->GetCharacter())) return;// @fixme190 #ifdef ENABLE_COMPUTE_POINT_FIX // UpdatePacket() is called several times during ComputePoints(), // e.g. when re-applying the equipped items. Since that happens for every // item equipped, the first update packets will contain invalid parts etc. if (!m_pointsInstant.computed) return; #endif TPacketGCCharacterUpdate pack; // TPacketGCCharacterUpdate pack2; pack.header = HEADER_GC_CHARACTER_UPDATE; pack.dwVID = m_vid; pack.awPart[CHR_EQUIPPART_ARMOR] = GetPart(PART_MAIN); pack.awPart[CHR_EQUIPPART_WEAPON] = GetPart(PART_WEAPON); pack.awPart[CHR_EQUIPPART_HEAD] = GetPart(PART_HEAD); pack.awPart[CHR_EQUIPPART_HAIR] = GetPart(PART_HAIR); #ifdef ENABLE_ACCE_SYSTEM # ifdef ENABLE_WINGS_NEW const LPITEM pWing = GetWear(WEAR_COSTUME_WING); pack.awPart[CHR_EQUIPPART_ACCE] = pWing ? 0 : GetPart(PART_ACCE); # else pack.awPart[CHR_EQUIPPART_ACCE] = GetPart(PART_ACCE); # endif #endif #ifdef ENABLE_WINGS_NEW pack.awPart[CHR_EQUIPPART_WING] = GetPart(PART_WING); #endif #ifdef ENABLE_AURA_SYSTEM pack.awPart[CHR_EQUIPPART_AURA] = GetPart(PART_AURA); #endif pack.bMovingSpeed = GetLimitPoint(POINT_MOV_SPEED); pack.bAttackSpeed = GetLimitPoint(POINT_ATT_SPEED); pack.bStateFlag = m_bAddChrState; pack.dwAffectFlag[0] = m_afAffectFlag.bits[0]; pack.dwAffectFlag[1] = m_afAffectFlag.bits[1]; pack.dwGuildID = 0; pack.sAlignment = m_iAlignment / 10; #ifdef TITLE_SYSTEM pack.title = GetTitle(); #endif pack.bPKMode = m_bPKMode; #ifdef ENABLE_TEXT_LEVEL_REFRESH pack.dwLevel = GetLevel(); #endif #ifdef ENABLE_REBIRT_SYSTEM pack.bRebirt = GetRebirt(); #endif #ifdef ENABLE_REBORN_SYSTEM pack.bReborn = GetReborn(); #endif if (GetGuild()) pack.dwGuildID = GetGuild()->GetID(); pack.dwMountVnum = GetMountVnum(); if (IsPC()) { #ifdef ENABLE_SKILL_COLOR_SYSTEM thecore_memcpy(pack.dwSkillColor, GetSkillColor(), sizeof(pack.dwSkillColor)); #endif } // pack2 = pack; // pack2.dwGuildID = 0; // pack2.sAlignment = 0; // #ifdef ENABLE_NEW_PET_SYSTEM // pack2.dwLevel = 0; // #endif #ifdef ENABLE_GUILD_LEADER_GRADE_NAME CGuild* pGuild = this->GetGuild(); if (pGuild) { if (pGuild->GetMasterPID() == GetPlayerID()) pack.bGuildLeaderGrade = 3; else if (pGuild->GetGeneralPID(GetPlayerID()) == true) pack.bGuildLeaderGrade = 2; else pack.bGuildLeaderGrade = 1; } else { pack.bGuildLeaderGrade = 0; } #endif PacketAround(&pack, sizeof(pack)); // if (false) // { // if (m_bIsObserver != true) // { // for (ENTITY_MAP::iterator iter = m_map_view.begin(); iter != m_map_view.end(); iter++) // { // LPENTITY pEntity = iter->first; // if (pEntity != NULL) // { // if (pEntity->IsType(ENTITY_CHARACTER) == true) // { // if (pEntity->GetDesc() != NULL) // { // LPCHARACTER pChar = (LPCHARACTER)pEntity; // if (GetEmpire() == pChar->GetEmpire() || pChar->GetGMLevel() > GM_PLAYER) // { // pEntity->GetDesc()->Packet(&pack, sizeof(pack)); // } // else // { // pEntity->GetDesc()->Packet(&pack2, sizeof(pack2)); // } // } // } // else // { // if (pEntity->GetDesc() != NULL) // { // pEntity->GetDesc()->Packet(&pack, sizeof(pack)); // } // } // } // } // } // if (GetDesc() != NULL) // { // GetDesc()->Packet(&pack, sizeof(pack)); // } // } // else // { // PacketAround(&pack, sizeof(pack)); // } } LPCHARACTER CHARACTER::FindCharacterInView(const char* c_pszName, bool bFindPCOnly) { ENTITY_MAP::iterator it = m_map_view.begin(); for (; it != m_map_view.end(); ++it) { if (!it->first->IsType(ENTITY_CHARACTER)) continue; LPCHARACTER tch = (LPCHARACTER)it->first; if (bFindPCOnly && tch->IsNPC()) continue; if (!strcasecmp(tch->GetName(), c_pszName)) return (tch); } return NULL; } void CHARACTER::SetPosition(int pos) { if (pos == POS_STANDING) { REMOVE_BIT(m_bAddChrState, ADD_CHARACTER_STATE_DEAD); REMOVE_BIT(m_pointsInstant.instant_flag, INSTANT_FLAG_STUN); event_cancel(&m_pkDeadEvent); event_cancel(&m_pkStunEvent); } else if (pos == POS_DEAD) SET_BIT(m_bAddChrState, ADD_CHARACTER_STATE_DEAD); if (!IsStone()) { switch (pos) { case POS_FIGHTING: if (!IsState(m_stateBattle)) MonsterLog("[BATTLE] ½Î¿ì´Â »óÅÂ"); GotoState(m_stateBattle); break; default: if (!IsState(m_stateIdle)) MonsterLog("[IDLE] ½¬´Â »óÅÂ"); GotoState(m_stateIdle); break; } } m_pointsInstant.position = pos; } void CHARACTER::Save() { if (!m_bSkipSave) CHARACTER_MANAGER::instance().DelayedSave(this); } void CHARACTER::CreatePlayerProto(TPlayerTable& tab) { memset(&tab, 0, sizeof(TPlayerTable)); if (GetNewName().empty()) { strlcpy(tab.name, GetName(), sizeof(tab.name)); } else { strlcpy(tab.name, GetNewName().c_str(), sizeof(tab.name)); } strlcpy(tab.ip, GetDesc()->GetHostName(), sizeof(tab.ip)); tab.id = m_dwPlayerID; tab.voice = GetPoint(POINT_VOICE); tab.level = GetLevel(); tab.level_step = GetPoint(POINT_LEVEL_STEP); tab.exp = GetExp(); tab.gold = GetGold(); tab.job = m_points.job; tab.part_base = m_pointsInstant.bBasePart; tab.skill_group = m_points.skill_group; #ifdef ENABLE_REBIRT_SYSTEM tab.rebirt = GetRebirt(); #endif #ifdef ENABLE_REBORN_SYSTEM tab.reborn = GetReborn(); #endif DWORD dwPlayedTime = (get_dword_time() - m_dwPlayStartTime); if (dwPlayedTime > 60000) { if (GetSectree() && !GetSectree()->IsAttr(GetX(), GetY(), ATTR_BANPK)) { if (GetRealAlignment() < 0) { if (IsEquipUniqueItem(UNIQUE_ITEM_FASTER_ALIGNMENT_UP_BY_TIME)) UpdateAlignment(120 * (dwPlayedTime / 60000)); else UpdateAlignment(60 * (dwPlayedTime / 60000)); } else UpdateAlignment(5 * (dwPlayedTime / 60000)); } SetRealPoint(POINT_PLAYTIME, GetRealPoint(POINT_PLAYTIME) + dwPlayedTime / 60000); ResetPlayTime(dwPlayedTime % 60000); } tab.playtime = GetRealPoint(POINT_PLAYTIME); #ifdef ENABLE_ALIGNMENT_SYSTEM tab.llAlignment = m_iRealAlignment; #else tab.lAlignment = m_iRealAlignment; #endif if (m_posWarp.x != 0 || m_posWarp.y != 0) { tab.x = m_posWarp.x; tab.y = m_posWarp.y; tab.z = 0; tab.lMapIndex = m_lWarpMapIndex; } else { tab.x = GetX(); tab.y = GetY(); tab.z = GetZ(); tab.lMapIndex = GetMapIndex(); } if (m_lExitMapIndex == 0) { tab.lExitMapIndex = tab.lMapIndex; tab.lExitX = tab.x; tab.lExitY = tab.y; } else { tab.lExitMapIndex = m_lExitMapIndex; tab.lExitX = m_posExit.x; tab.lExitY = m_posExit.y; } sys_log(0, "SAVE: %s %dx%d", GetName(), tab.x, tab.y); tab.st = GetRealPoint(POINT_ST); tab.ht = GetRealPoint(POINT_HT); tab.dx = GetRealPoint(POINT_DX); tab.iq = GetRealPoint(POINT_IQ); tab.stat_point = GetPoint(POINT_STAT); tab.skill_point = GetPoint(POINT_SKILL); tab.sub_skill_point = GetPoint(POINT_SUB_SKILL); tab.horse_skill_point = GetPoint(POINT_HORSE_SKILL); tab.stat_reset_count = GetPoint(POINT_STAT_RESET_COUNT); tab.hp = GetHP(); tab.sp = GetSP(); tab.stamina = GetStamina(); tab.sRandomHP = m_points.iRandomHP; tab.sRandomSP = m_points.iRandomSP; #ifdef TITLE_SYSTEM tab.title = m_points.title; #endif for (int i = 0; i < QUICKSLOT_MAX_NUM; ++i) tab.quickslot[i] = m_quickslot[i]; if (m_stMobile.length() && !*m_szMobileAuth) strlcpy(tab.szMobile, m_stMobile.c_str(), sizeof(tab.szMobile)); thecore_memcpy(tab.parts, m_pointsInstant.parts, sizeof(tab.parts)); // REMOVE_REAL_SKILL_LEVLES thecore_memcpy(tab.skills, m_pSkillLevels, sizeof(TPlayerSkill) * SKILL_MAX_NUM); // END_OF_REMOVE_REAL_SKILL_LEVLES tab.horse = GetHorseData(); #ifdef ENABLE_NEW_RANKING tab.kesilenMetin = GetKesilenMetin(); tab.kesilenBoss = GetKesilenBoss(); tab.acilanSandik = GetAcilanSandik(); tab.metinHasar = GetmetinHasar(); tab.patronHasar = GetpatronHasar(); #endif #ifdef ENABLE_KILL_STATISTICS tab.iJinnoKills = GetJinnoKills(); tab.iShinsooKills = GetShinsooKills(); tab.iChunjoKills = GetChunjoKills(); tab.iTotalKills = GetTotalKills(); tab.iTotalDeaths = GetTotalDeaths(); tab.iDuelsWon = GetDuelsWon(); tab.iDuelsLost = GetDuelsLost(); tab.iBossesKills = GetBossesKills(); tab.iStonesKills = GetStonesKills(); tab.iMobsKills = GetMobsKills(); tab.top_damage = GetTopDamage(); #endif #ifdef ENABLE_BIOLOG_SYSTEM tab.m_BiologActualMission = GetBiologMissions(); tab.m_BiologCollectedItems = GetBiologCollectedItems(); tab.m_BiologCooldownReminder = GetBiologCooldownReminder(); tab.m_BiologCooldown = GetBiologCooldown(); #endif } void CHARACTER::SaveReal() { if (m_bSkipSave) return; if (!GetDesc()) { sys_err("Character::Save : no descriptor when saving (name: %s)", GetName()); return; } TPlayerTable table; CreatePlayerProto(table); db_clientdesc->DBPacket(HEADER_GD_PLAYER_SAVE, GetDesc()->GetHandle(), &table, sizeof(TPlayerTable)); quest::PC* pkQuestPC = quest::CQuestManager::instance().GetPCForce(GetPlayerID()); if (!pkQuestPC) sys_err("CHARACTER::Save : null quest::PC pointer! (name %s)", GetName()); else { pkQuestPC->Save(); } marriage::TMarriage* pMarriage = marriage::CManager::instance().Get(GetPlayerID()); if (pMarriage) pMarriage->Save(); } void CHARACTER::FlushDelayedSaveItem() { LPITEM item; for (int i = 0; i < INVENTORY_AND_EQUIP_SLOT_MAX; ++i) if ((item = GetInventoryItem(i))) ITEM_MANAGER::instance().FlushDelayedSave(item); } void CHARACTER::Disconnect(const char* c_pszReason) { assert(GetDesc() != NULL); sys_log(0, "DISCONNECT: %s (%s)", GetName(), c_pszReason ? c_pszReason : "unset"); if (GetShop()) { GetShop()->RemoveGuest(this); SetShop(NULL); } if (GetArena() != NULL) { GetArena()->OnDisconnect(GetPlayerID()); } if (GetParty() != NULL) { GetParty()->UpdateOfflineState(GetPlayerID()); } marriage::CManager::instance().Logout(this); // P2P Logout TPacketGGLogout p; p.bHeader = HEADER_GG_LOGOUT; strlcpy(p.szName, GetName(), sizeof(p.szName)); P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGLogout)); LogManager::instance().CharLog(this, 0, "LOGOUT", ""); #ifdef ENABLE_PCBANG_FEATURE // @warme006 { long playTime = GetRealPoint(POINT_PLAYTIME) - m_dwLoginPlayTime; LogManager::instance().LoginLog(false, GetDesc()->GetAccountTable().id, GetPlayerID(), GetLevel(), GetJob(), playTime); if (0) CPCBangManager::instance().Log(GetDesc()->GetHostName(), GetPlayerID(), playTime); } #endif if (m_pWarMap) SetWarMap(NULL); if (m_pWeddingMap) { SetWeddingMap(NULL); } #ifdef __ENABLE_NEW_OFFLINESHOP__ offlineshop::GetManager().RemoveSafeboxFromCache(GetPlayerID()); offlineshop::GetManager().RemoveGuestFromShops(this); if (m_pkAuctionGuest) m_pkAuctionGuest->RemoveGuest(this); if (GetOfflineShop()) SetOfflineShop(NULL); SetShopSafebox(NULL); m_pkAuction = NULL; m_pkAuctionGuest = NULL; //offlineshop-updated 05/08/19 m_bIsLookingOfflineshopOfferList = false; #endif #ifdef ENABLE_BIOLOG_SYSTEM if (m_pkBiologManager) { delete m_pkBiologManager; m_pkBiologManager = NULL; } #endif if (GetGuild()) GetGuild()->LogoutMember(this); quest::CQuestManager::instance().LogoutPC(this); if (GetParty()) GetParty()->Unlink(this); if (IsStun() || IsDead()) { DeathPenalty(0); PointChange(POINT_HP, 50 - GetHP()); } if (!CHARACTER_MANAGER::instance().FlushDelayedSave(this)) { SaveReal(); } FlushDelayedSaveItem(); SaveAffect(); m_bIsLoadedAffect = false; m_bSkipSave = true; quest::CQuestManager::instance().DisconnectPC(this); CloseSafebox(); CloseMall(); CPVPManager::instance().Disconnect(this); CTargetManager::instance().Logout(GetPlayerID()); MessengerManager::instance().Logout(GetName()); if (g_TeenDesc) { int offset = 0; char buf[245] = { 0 }; buf[0] = HEADER_GT_LOGOUT; offset += 1; memset(buf + offset, 0x00, 2); offset += 2; TAccountTable& acc_table = GetDesc()->GetAccountTable(); memcpy(buf + offset, &acc_table.id, 4); offset += 4; g_TeenDesc->Packet(buf, offset); } #ifdef ENABLE_MOUNT_COSTUME_SYSTEM if (GetMountVnum()) { RemoveAffect(AFFECT_MOUNT); RemoveAffect(AFFECT_MOUNT_BONUS); } #endif if (GetDesc()) { //////////////////////////////////////////////////////////////////////////////////////////// packet_point_change pack; pack.header = HEADER_GC_CHARACTER_POINT_CHANGE; pack.dwVID = m_vid; pack.type = POINT_PLAYTIME; pack.value = GetRealPoint(POINT_PLAYTIME) + (get_dword_time() - m_dwPlayStartTime) / 60000; pack.amount = 0; GetDesc()->Packet(&pack, sizeof(struct packet_point_change)); //////////////////////////////////////////////////////////////////////////////////////////// GetDesc()->BindCharacter(NULL); // BindDesc(NULL); } CXTrapManager::instance().DestroyClientSession(this); M2_DESTROY_CHARACTER(this); } bool CHARACTER::Show(long lMapIndex, long x, long y, long z, bool bShowSpawnMotion/* = false */) { LPSECTREE sectree = SECTREE_MANAGER::instance().Get(lMapIndex, x, y); if (!sectree) { sys_log(0, "cannot find sectree by %dx%d mapindex %d", x, y, lMapIndex); return false; } SetMapIndex(lMapIndex); bool bChangeTree = false; if (!GetSectree() || GetSectree() != sectree) bChangeTree = true; if (bChangeTree) { if (GetSectree()) GetSectree()->RemoveEntity(this); ViewCleanup(); } if (!IsNPC()) { sys_log(0, "SHOW: %s %dx%dx%d", GetName(), x, y, z); if (GetStamina() < GetMaxStamina()) StartAffectEvent(); } else if (m_pkMobData) { m_pkMobInst->m_posLastAttacked.x = x; m_pkMobInst->m_posLastAttacked.y = y; m_pkMobInst->m_posLastAttacked.z = z; } if (bShowSpawnMotion) { SET_BIT(m_bAddChrState, ADD_CHARACTER_STATE_SPAWN); m_afAffectFlag.Set(AFF_SPAWN); } SetXYZ(x, y, z); m_posDest.x = x; m_posDest.y = y; m_posDest.z = z; m_posStart.x = x; m_posStart.y = y; m_posStart.z = z; if (bChangeTree) { EncodeInsertPacket(this); sectree->InsertEntity(this); UpdateSectree(); } else { ViewReencode(); sys_log(0, " in same sectree"); } REMOVE_BIT(m_bAddChrState, ADD_CHARACTER_STATE_SPAWN); SetValidComboInterval(0); return true; } // BGM_INFO struct BGMInfo { std::string name; float vol; }; typedef std::map BGMInfoMap; static BGMInfoMap gs_bgmInfoMap; static bool gs_bgmVolEnable = false; void CHARACTER_SetBGMVolumeEnable() { gs_bgmVolEnable = true; sys_log(0, "bgm_info.set_bgm_volume_enable"); } void CHARACTER_AddBGMInfo(unsigned mapIndex, const char* name, float vol) { BGMInfo newInfo; newInfo.name = name; newInfo.vol = vol; gs_bgmInfoMap[mapIndex] = newInfo; sys_log(0, "bgm_info.add_info(%d, '%s', %f)", mapIndex, name, vol); } const BGMInfo& CHARACTER_GetBGMInfo(unsigned mapIndex) { BGMInfoMap::iterator f = gs_bgmInfoMap.find(mapIndex); if (gs_bgmInfoMap.end() == f) { static BGMInfo s_empty = { "", 0.0f }; return s_empty; } return f->second; } bool CHARACTER_IsBGMVolumeEnable() { return gs_bgmVolEnable; } // END_OF_BGM_INFO void CHARACTER::MainCharacterPacket() { const unsigned mapIndex = GetMapIndex(); const BGMInfo& bgmInfo = CHARACTER_GetBGMInfo(mapIndex); // SUPPORT_BGM if (!bgmInfo.name.empty()) { if (CHARACTER_IsBGMVolumeEnable()) { sys_log(1, "bgm_info.play_bgm_vol(%d, name='%s', vol=%f)", mapIndex, bgmInfo.name.c_str(), bgmInfo.vol); TPacketGCMainCharacter4_BGM_VOL mainChrPacket; mainChrPacket.header = HEADER_GC_MAIN_CHARACTER4_BGM_VOL; mainChrPacket.dwVID = m_vid; mainChrPacket.wRaceNum = GetRaceNum(); mainChrPacket.lx = GetX(); mainChrPacket.ly = GetY(); mainChrPacket.lz = GetZ(); mainChrPacket.empire = GetDesc()->GetEmpire(); mainChrPacket.skill_group = GetSkillGroup(); strlcpy(mainChrPacket.szChrName, GetName(), sizeof(mainChrPacket.szChrName)); mainChrPacket.fBGMVol = bgmInfo.vol; strlcpy(mainChrPacket.szBGMName, bgmInfo.name.c_str(), sizeof(mainChrPacket.szBGMName)); GetDesc()->Packet(&mainChrPacket, sizeof(TPacketGCMainCharacter4_BGM_VOL)); } else { sys_log(1, "bgm_info.play(%d, '%s')", mapIndex, bgmInfo.name.c_str()); TPacketGCMainCharacter3_BGM mainChrPacket; mainChrPacket.header = HEADER_GC_MAIN_CHARACTER3_BGM; mainChrPacket.dwVID = m_vid; mainChrPacket.wRaceNum = GetRaceNum(); mainChrPacket.lx = GetX(); mainChrPacket.ly = GetY(); mainChrPacket.lz = GetZ(); mainChrPacket.empire = GetDesc()->GetEmpire(); mainChrPacket.skill_group = GetSkillGroup(); strlcpy(mainChrPacket.szChrName, GetName(), sizeof(mainChrPacket.szChrName)); strlcpy(mainChrPacket.szBGMName, bgmInfo.name.c_str(), sizeof(mainChrPacket.szBGMName)); GetDesc()->Packet(&mainChrPacket, sizeof(TPacketGCMainCharacter3_BGM)); } //if (m_stMobile.length()) // ChatPacket(CHAT_TYPE_COMMAND, "sms"); } // END_OF_SUPPORT_BGM else { sys_log(0, "bgm_info.play(%d, DEFAULT_BGM_NAME)", mapIndex); TPacketGCMainCharacter pack; pack.header = HEADER_GC_MAIN_CHARACTER; pack.dwVID = m_vid; pack.wRaceNum = GetRaceNum(); pack.lx = GetX(); pack.ly = GetY(); pack.lz = GetZ(); pack.empire = GetDesc()->GetEmpire(); pack.skill_group = GetSkillGroup(); strlcpy(pack.szName, GetName(), sizeof(pack.szName)); GetDesc()->Packet(&pack, sizeof(TPacketGCMainCharacter)); if (m_stMobile.length()) ChatPacket(CHAT_TYPE_COMMAND, "sms"); } } void CHARACTER::PointsPacket() { if (!GetDesc()) return; TPacketGCPoints pack; pack.header = HEADER_GC_CHARACTER_POINTS; pack.points[POINT_LEVEL] = GetLevel(); pack.points[POINT_EXP] = GetExp(); pack.points[POINT_NEXT_EXP] = GetNextExp(); pack.points[POINT_HP] = GetHP(); pack.points[POINT_MAX_HP] = GetMaxHP(); pack.points[POINT_SP] = GetSP(); pack.points[POINT_MAX_SP] = GetMaxSP(); pack.points[POINT_GOLD] = GetGold(); pack.points[POINT_STAMINA] = GetStamina(); pack.points[POINT_MAX_STAMINA] = GetMaxStamina(); #ifdef ENABLE_REBIRT_SYSTEM pack.points[POINT_REBIRT] = GetRebirt(); #endif #ifdef ENABLE_REBORN_SYSTEM pack.points[POINT_REBORN] = GetReborn(); #endif for (int i = POINT_ST; i < POINT_MAX_NUM; ++i) pack.points[i] = GetPoint(i); GetDesc()->Packet(&pack, sizeof(TPacketGCPoints)); } bool CHARACTER::ChangeSex() { if (GetWear(WEAR_COSTUME_BODY) || GetWear(WEAR_COSTUME_HAIR))// @fixme191 { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Kostum varken bu islemi gerceklestiremezsin")); return false; } int src_race = GetRaceNum(); switch (src_race) { case MAIN_RACE_WARRIOR_M: m_points.job = MAIN_RACE_WARRIOR_W; break; case MAIN_RACE_WARRIOR_W: m_points.job = MAIN_RACE_WARRIOR_M; break; case MAIN_RACE_ASSASSIN_M: m_points.job = MAIN_RACE_ASSASSIN_W; break; case MAIN_RACE_ASSASSIN_W: m_points.job = MAIN_RACE_ASSASSIN_M; break; case MAIN_RACE_SURA_M: m_points.job = MAIN_RACE_SURA_W; break; case MAIN_RACE_SURA_W: m_points.job = MAIN_RACE_SURA_M; break; case MAIN_RACE_SHAMAN_M: m_points.job = MAIN_RACE_SHAMAN_W; break; case MAIN_RACE_SHAMAN_W: m_points.job = MAIN_RACE_SHAMAN_M; break; #ifdef ENABLE_WOLFMAN_CHARACTER case MAIN_RACE_WOLFMAN_M: m_points.job = MAIN_RACE_WOLFMAN_M; break; #endif default: sys_err("CHANGE_SEX: %s unknown race %d", GetName(), src_race); return false; } sys_log(0, "CHANGE_SEX: %s (%d -> %d)", GetName(), src_race, m_points.job); return true; } WORD CHARACTER::GetRaceNum() const { if (m_dwPolymorphRace) return m_dwPolymorphRace; #ifdef MODERATED_NPC if (m_iModeratedVnum) return m_points.job; #endif if (m_pkMobData) return m_pkMobData->m_table.dwVnum; return m_points.job; } void CHARACTER::SetRace(BYTE race) { if (race >= MAIN_RACE_MAX_NUM) { sys_err("CHARACTER::SetRace(name=%s, race=%d).OUT_OF_RACE_RANGE", GetName(), race); return; } m_points.job = race; } BYTE CHARACTER::GetJob() const { unsigned race = m_points.job; unsigned job; if (RaceToJob(race, &job)) return job; sys_err("CHARACTER::GetJob(name=%s, race=%d).OUT_OF_RACE_RANGE", GetName(), race); return JOB_WARRIOR; } void CHARACTER::SetLevel(BYTE level) { m_points.level = level; if (IsPC()) { if (level < PK_PROTECT_LEVEL) SetPKMode(PK_MODE_PROTECT); else if (GetGMLevel() != GM_PLAYER) SetPKMode(PK_MODE_PROTECT); else if (m_bPKMode == PK_MODE_PROTECT) SetPKMode(PK_MODE_PEACE); } } #ifdef ENABLE_REBIRT_SYSTEM void CHARACTER::SetRebirt(BYTE rebirt) { m_points.rebirt = rebirt; if (IsPC()) UpdatePacket(); } #endif #ifdef ENABLE_REBORN_SYSTEM void CHARACTER::SetReborn(BYTE reborn) { m_points.reborn = reborn; if (IsPC()) UpdatePacket(); } #endif void CHARACTER::SetEmpire(BYTE bEmpire) { m_bEmpire = bEmpire; } #define ENABLE_GM_FLAG_IF_TEST_SERVER #define ENABLE_GM_FLAG_FOR_LOW_WIZARD void CHARACTER::SetPlayerProto(const TPlayerTable* t) { if (!GetDesc() || !*GetDesc()->GetHostName()) sys_err("cannot get desc or hostname"); else SetGMLevel(); m_bCharType = CHAR_TYPE_PC; m_dwPlayerID = t->id; #ifdef ENABLE_ALIGNMENT_SYSTEM m_iAlignment = t->llAlignment; m_iRealAlignment = t->llAlignment; #else m_iAlignment = t->lAlignment; m_iRealAlignment = t->lAlignment; #endif m_points.voice = t->voice; m_points.skill_group = t->skill_group; m_pointsInstant.bBasePart = t->part_base; SetPart(PART_HAIR, t->parts[PART_HAIR]); #ifdef ENABLE_ACCE_SYSTEM SetPart(PART_ACCE, t->parts[PART_ACCE]); #endif #ifdef ENABLE_AURA_SYSTEM SetPart(PART_AURA, t->parts[PART_AURA]); #endif #ifdef ENABLE_WINGS_NEW SetPart(PART_WING, t->parts[PART_WING]); #endif m_points.iRandomHP = t->sRandomHP; m_points.iRandomSP = t->sRandomSP; #ifdef TITLE_SYSTEM m_points.title = t->title; #endif #ifdef ENABLE_KILL_STATISTICS m_killstatistics.iJinnoKills = t->iJinnoKills; m_killstatistics.iShinsooKills = t->iShinsooKills; m_killstatistics.iChunjoKills = t->iChunjoKills; m_killstatistics.iTotalKills = t->iTotalKills; m_killstatistics.iTotalDeaths = t->iTotalDeaths; m_killstatistics.iDuelsWon = t->iDuelsWon; m_killstatistics.iDuelsLost = t->iDuelsLost; m_killstatistics.iBossesKills = t->iBossesKills; m_killstatistics.iStonesKills = t->iStonesKills; m_killstatistics.iMobsKills = t->iMobsKills; m_killstatistics.top_damage = t->top_damage; #endif // REMOVE_REAL_SKILL_LEVLES if (m_pSkillLevels) M2_DELETE_ARRAY(m_pSkillLevels); m_pSkillLevels = M2_NEW TPlayerSkill[SKILL_MAX_NUM]; thecore_memcpy(m_pSkillLevels, t->skills, sizeof(TPlayerSkill) * SKILL_MAX_NUM); // END_OF_REMOVE_REAL_SKILL_LEVLES if (t->lMapIndex >= 10000) { m_posWarp.x = t->lExitX; m_posWarp.y = t->lExitY; m_lWarpMapIndex = t->lExitMapIndex; } SetRealPoint(POINT_PLAYTIME, t->playtime); m_dwLoginPlayTime = t->playtime; SetRealPoint(POINT_ST, t->st); SetRealPoint(POINT_HT, t->ht); SetRealPoint(POINT_DX, t->dx); SetRealPoint(POINT_IQ, t->iq); SetPoint(POINT_ST, t->st); SetPoint(POINT_HT, t->ht); SetPoint(POINT_DX, t->dx); SetPoint(POINT_IQ, t->iq); SetPoint(POINT_STAT, t->stat_point); SetPoint(POINT_SKILL, t->skill_point); SetPoint(POINT_SUB_SKILL, t->sub_skill_point); SetPoint(POINT_HORSE_SKILL, t->horse_skill_point); SetPoint(POINT_STAT_RESET_COUNT, t->stat_reset_count); SetPoint(POINT_LEVEL_STEP, t->level_step); SetRealPoint(POINT_LEVEL_STEP, t->level_step); SetRace(t->job); SetLevel(t->level); #ifdef ENABLE_REBIRT_SYSTEM SetRebirt(t->rebirt); #endif #ifdef ENABLE_REBORN_SYSTEM SetReborn(t->reborn); #endif SetExp(t->exp); SetGold(t->gold); #ifdef ENABLE_NEW_RANKING SetKesilenMetin(t->kesilenMetin); SetKesilenBoss(t->kesilenBoss); SetAcilanSandik(t->acilanSandik); SetmetinHasar(t->metinHasar); SetpatronHasar(t->patronHasar); #endif SetMapIndex(t->lMapIndex); SetXYZ(t->x, t->y, t->z); ComputePoints(); SetHP(t->hp); SetSP(t->sp); SetStamina(t->stamina); #ifndef ENABLE_GM_FLAG_IF_TEST_SERVER if (!test_server) #endif { #ifdef ENABLE_GM_FLAG_FOR_LOW_WIZARD if (GetGMLevel() > GM_PLAYER) #else if (GetGMLevel() > GM_LOW_WIZARD) #endif { m_afAffectFlag.Set(AFF_YMIR); m_bPKMode = PK_MODE_PROTECT; } } if (GetLevel() < PK_PROTECT_LEVEL) m_bPKMode = PK_MODE_PROTECT; m_stMobile = t->szMobile; SetHorseData(t->horse); if (GetHorseLevel() > 0) UpdateHorseDataByLogoff(t->logoff_interval); thecore_memcpy(m_aiPremiumTimes, t->aiPremiumTimes, sizeof(t->aiPremiumTimes)); m_dwLogOffInterval = t->logoff_interval; sys_log(0, "PLAYER_LOAD: %s PREMIUM %d %d, LOGGOFF_INTERVAL %u PTR: %p", t->name, m_aiPremiumTimes[0], m_aiPremiumTimes[1], t->logoff_interval, this); if (GetGMLevel() != GM_PLAYER) { LogManager::instance().CharLog(this, GetGMLevel(), "GM_LOGIN", ""); sys_log(0, "GM_LOGIN(gmlevel=%d, name=%s(%d), pos=(%d, %d)", GetGMLevel(), GetName(), GetPlayerID(), GetX(), GetY()); } #ifdef ENABLE_MOUNT_COSTUME_SYSTEM if (m_mountSystem) { m_mountSystem->Destroy(); delete m_mountSystem; } m_mountSystem = M2_NEW CMountSystem(this); #endif #ifdef __PET_SYSTEM__ if (m_petSystem) { m_petSystem->Destroy(); delete m_petSystem; } m_petSystem = M2_NEW CPetSystem(this); #endif #ifdef ENABLE_NEW_PET_SYSTEM if (m_newpetSystem) { m_newpetSystem->Destroy(); delete m_newpetSystem; } m_newpetSystem = M2_NEW CNewPetSystem(this); #endif #ifdef ENABLE_BIOLOG_SYSTEM if (m_pkBiologManager) { sys_err("Biolog manager already exist for owner %u %s", GetPlayerID(), GetName()); delete m_pkBiologManager; } m_pkBiologManager = M2_NEW CBiologSystem(this); SetBiologMissions(t->m_BiologActualMission); SetBiologCollectedItems(t->m_BiologCollectedItems); SetBiologCooldownReminder(t->m_BiologCooldownReminder); SetBiologCooldown(t->m_BiologCooldown); #endif } EVENTFUNC(kill_ore_load_event) { char_event_info* info = dynamic_cast(event->info); if (info == NULL) { sys_err("kill_ore_load_even> Null pointer"); return 0; } LPCHARACTER ch = info->ch; if (ch == NULL) { // return 0; } ch->m_pkMiningEvent = NULL; M2_DESTROY_CHARACTER(ch); return 0; } void CHARACTER::SetProto(const CMob* pkMob) { if (m_pkMobInst) M2_DELETE(m_pkMobInst); m_pkMobData = pkMob; m_pkMobInst = M2_NEW CMobInstance; m_bPKMode = PK_MODE_FREE; const TMobTable* t = &m_pkMobData->m_table; m_bCharType = t->bType; SetLevel(t->bLevel); SetEmpire(t->bEmpire); SetExp(t->dwExp); SetRealPoint(POINT_ST, t->bStr); SetRealPoint(POINT_DX, t->bDex); SetRealPoint(POINT_HT, t->bCon); SetRealPoint(POINT_IQ, t->bInt); ComputePoints(); SetHP(GetMaxHP()); SetSP(GetMaxSP()); //////////////////// m_pointsInstant.dwAIFlag = t->dwAIFlag; SetImmuneFlag(t->dwImmuneFlag); AssignTriggers(t); ApplyMobAttribute(t); if (IsStone()) { DetermineDropMetinStone(); } if (IsWarp() || IsGoto()) { StartWarpNPCEvent(); } // @fixme216 BEGIN try { CHARACTER_MANAGER::instance().RegisterRaceNumMap(this); } catch (...) { sys_err("Catched exception on RegisterRaceNumMap %s %d", this->GetName(), this->GetRaceNum()); } // @fixme216 END if (GetRaceNum() == xmas::MOB_SANTA_VNUM) { SetPoint(POINT_ATT_GRADE_BONUS, 10); SetPoint(POINT_DEF_GRADE_BONUS, 6); //m_dwPlayStartTime = get_dword_time() + 10 * 60 * 1000; m_dwPlayStartTime = get_dword_time() + 30 * 1000; if (test_server) m_dwPlayStartTime = get_dword_time() + 30 * 1000; } // XXX CTF GuildWar hardcoding if (warmap::IsWarFlag(GetRaceNum())) { m_stateIdle.Set(this, &CHARACTER::BeginStateEmpty, &CHARACTER::StateFlag, &CHARACTER::EndStateEmpty); m_stateMove.Set(this, &CHARACTER::BeginStateEmpty, &CHARACTER::StateFlag, &CHARACTER::EndStateEmpty); m_stateBattle.Set(this, &CHARACTER::BeginStateEmpty, &CHARACTER::StateFlag, &CHARACTER::EndStateEmpty); } if (warmap::IsWarFlagBase(GetRaceNum())) { m_stateIdle.Set(this, &CHARACTER::BeginStateEmpty, &CHARACTER::StateFlagBase, &CHARACTER::EndStateEmpty); m_stateMove.Set(this, &CHARACTER::BeginStateEmpty, &CHARACTER::StateFlagBase, &CHARACTER::EndStateEmpty); m_stateBattle.Set(this, &CHARACTER::BeginStateEmpty, &CHARACTER::StateFlagBase, &CHARACTER::EndStateEmpty); } if (m_bCharType == CHAR_TYPE_HORSE || GetRaceNum() == 20101 || GetRaceNum() == 20102 || GetRaceNum() == 20103 || GetRaceNum() == 20104 || GetRaceNum() == 20105 || GetRaceNum() == 20106 || GetRaceNum() == 20107 || GetRaceNum() == 20108 || GetRaceNum() == 20109 ) { m_stateIdle.Set(this, &CHARACTER::BeginStateEmpty, &CHARACTER::StateHorse, &CHARACTER::EndStateEmpty); m_stateMove.Set(this, &CHARACTER::BeginStateEmpty, &CHARACTER::StateMove, &CHARACTER::EndStateEmpty); m_stateBattle.Set(this, &CHARACTER::BeginStateEmpty, &CHARACTER::StateHorse, &CHARACTER::EndStateEmpty); } // MINING if (mining::IsVeinOfOre(GetRaceNum())) { char_event_info* info = AllocEventInfo(); info->ch = this; m_pkMiningEvent = event_create(kill_ore_load_event, info, PASSES_PER_SEC(number(7 * 60, 15 * 60))); } // END_OF_MINING } const TMobTable& CHARACTER::GetMobTable() const { return m_pkMobData->m_table; } bool CHARACTER::IsRaceFlag(DWORD dwBit) const { return m_pkMobData ? IS_SET(m_pkMobData->m_table.dwRaceFlag, dwBit) : 0; } DWORD CHARACTER::GetMobDamageMin() const { return m_pkMobData->m_table.dwDamageRange[0]; } DWORD CHARACTER::GetMobDamageMax() const { return m_pkMobData->m_table.dwDamageRange[1]; } float CHARACTER::GetMobDamageMultiply() const { float fDamMultiply = GetMobTable().fDamMultiply; if (IsBerserk()) fDamMultiply = fDamMultiply * 2.0f; return fDamMultiply; } DWORD CHARACTER::GetMobDropItemVnum() const { return m_pkMobData->m_table.dwDropItemVnum; } bool CHARACTER::IsSummonMonster() const { return GetSummonVnum() != 0; } DWORD CHARACTER::GetSummonVnum() const { return m_pkMobData ? m_pkMobData->m_table.dwSummonVnum : 0; } DWORD CHARACTER::GetPolymorphItemVnum() const { return m_pkMobData ? m_pkMobData->m_table.dwPolymorphItemVnum : 0; } DWORD CHARACTER::GetMonsterDrainSPPoint() const { return m_pkMobData ? m_pkMobData->m_table.dwDrainSP : 0; } BYTE CHARACTER::GetMobRank() const { if (!m_pkMobData) return MOB_RANK_KNIGHT; return m_pkMobData->m_table.bRank; } BYTE CHARACTER::GetMobSize() const { if (!m_pkMobData) return MOBSIZE_MEDIUM; return m_pkMobData->m_table.bSize; } WORD CHARACTER::GetMobAttackRange() const { switch (GetMobBattleType()) { case BATTLE_TYPE_RANGE: case BATTLE_TYPE_MAGIC: return m_pkMobData->m_table.wAttackRange + GetPoint(POINT_BOW_DISTANCE); default: return m_pkMobData->m_table.wAttackRange; } } BYTE CHARACTER::GetMobBattleType() const { if (!m_pkMobData) return BATTLE_TYPE_MELEE; return (m_pkMobData->m_table.bBattleType); } void CHARACTER::ComputeBattlePoints() { if (IsPolymorphed()) { DWORD dwMobVnum = GetPolymorphVnum(); const CMob* pMob = CMobManager::instance().Get(dwMobVnum); int iAtt = 0; int iDef = 0; if (pMob) { iAtt = GetLevel() * 2 + GetPolymorphPoint(POINT_ST) * 2; // lev + con iDef = GetLevel() + GetPolymorphPoint(POINT_HT) + pMob->m_table.wDef; } SetPoint(POINT_ATT_GRADE, iAtt); SetPoint(POINT_DEF_GRADE, iDef); SetPoint(POINT_MAGIC_ATT_GRADE, GetPoint(POINT_ATT_GRADE)); SetPoint(POINT_MAGIC_DEF_GRADE, GetPoint(POINT_DEF_GRADE)); } else if (IsPC()) { SetPoint(POINT_ATT_GRADE, 0); SetPoint(POINT_DEF_GRADE, 0); SetPoint(POINT_CLIENT_DEF_GRADE, 0); SetPoint(POINT_MAGIC_ATT_GRADE, GetPoint(POINT_ATT_GRADE)); SetPoint(POINT_MAGIC_DEF_GRADE, GetPoint(POINT_DEF_GRADE)); // // ATK = 2lev + 2str // int iAtk = GetLevel() * 2; int iStatAtk = 0; switch (GetJob()) { case JOB_WARRIOR: case JOB_SURA: iStatAtk = (2 * GetPoint(POINT_ST)); break; case JOB_ASSASSIN: iStatAtk = (4 * GetPoint(POINT_ST) + 2 * GetPoint(POINT_DX)) / 3; break; case JOB_SHAMAN: iStatAtk = (4 * GetPoint(POINT_ST) + 2 * GetPoint(POINT_IQ)) / 3; break; #ifdef ENABLE_WOLFMAN_CHARACTER case JOB_WOLFMAN: iStatAtk = (2 * GetPoint(POINT_ST)); break; #endif default: sys_err("invalid job %d", GetJob()); iStatAtk = (2 * GetPoint(POINT_ST)); break; } if (GetMountVnum() && iStatAtk < 2 * GetPoint(POINT_ST)) iStatAtk = (2 * GetPoint(POINT_ST)); iAtk += iStatAtk; if (GetMountVnum()) { if (GetJob() == JOB_SURA && GetSkillGroup() == 1) { iAtk += (iAtk * GetHorseLevel()) / 60; } else { iAtk += (iAtk * GetHorseLevel()) / 30; } } // // ATK Setting // iAtk += GetPoint(POINT_ATT_GRADE_BONUS); PointChange(POINT_ATT_GRADE, iAtk); // DEF = LEV + CON + ARMOR int iShowDef = GetLevel() + GetPoint(POINT_HT); int iDef = GetLevel() + (int)(GetPoint(POINT_HT) / 1.25); // For Other int iArmor = 0; LPITEM pkItem; for (int i = 0; i < WEAR_MAX_NUM; ++i) if ((pkItem = GetWear(i)) && pkItem->GetType() == ITEM_ARMOR) { if (pkItem->GetSubType() == ARMOR_BODY || pkItem->GetSubType() == ARMOR_HEAD || pkItem->GetSubType() == ARMOR_FOOTS || pkItem->GetSubType() == ARMOR_SHIELD) { iArmor += pkItem->GetValue(1); iArmor += (2 * pkItem->GetValue(5)); } } if (true == IsHorseRiding()) { if (iArmor < GetHorseArmor()) iArmor = GetHorseArmor(); const char* pHorseName = CHorseNameManager::instance().GetHorseName(GetPlayerID()); if (pHorseName != NULL && strlen(pHorseName)) { iArmor += 20; } } iArmor += GetPoint(POINT_DEF_GRADE_BONUS); iArmor += GetPoint(POINT_PARTY_DEFENDER_BONUS); // INTERNATIONAL_VERSION PointChange(POINT_DEF_GRADE, iDef + iArmor); PointChange(POINT_CLIENT_DEF_GRADE, (iShowDef + iArmor) - GetPoint(POINT_DEF_GRADE)); // END_OF_INTERNATIONAL_VERSION PointChange(POINT_MAGIC_ATT_GRADE, GetLevel() * 2 + GetPoint(POINT_IQ) * 2 + GetPoint(POINT_MAGIC_ATT_GRADE_BONUS)); PointChange(POINT_MAGIC_DEF_GRADE, GetLevel() + (GetPoint(POINT_IQ) * 3 + GetPoint(POINT_HT)) / 3 + iArmor / 2 + GetPoint(POINT_MAGIC_DEF_GRADE_BONUS)); } else { // 2lev + str * 2 long long iAtt = GetLevel() * 2 + GetPoint(POINT_ST) * 2; long long iDef = GetLevel() + GetPoint(POINT_HT) + GetMobTable().wDef; SetPoint(POINT_ATT_GRADE, iAtt); SetPoint(POINT_DEF_GRADE, iDef); SetPoint(POINT_MAGIC_ATT_GRADE, GetPoint(POINT_ATT_GRADE)); SetPoint(POINT_MAGIC_DEF_GRADE, GetPoint(POINT_DEF_GRADE)); } } void CHARACTER::ComputePoints() { long lStat = GetPoint(POINT_STAT); long lStatResetCount = GetPoint(POINT_STAT_RESET_COUNT); long lSkillActive = GetPoint(POINT_SKILL); long lSkillSub = GetPoint(POINT_SUB_SKILL); long lSkillHorse = GetPoint(POINT_HORSE_SKILL); long lLevelStep = GetPoint(POINT_LEVEL_STEP); long lAttackerBonus = GetPoint(POINT_PARTY_ATTACKER_BONUS); long lTankerBonus = GetPoint(POINT_PARTY_TANKER_BONUS); long lBufferBonus = GetPoint(POINT_PARTY_BUFFER_BONUS); long lSkillMasterBonus = GetPoint(POINT_PARTY_SKILL_MASTER_BONUS); long lHasteBonus = GetPoint(POINT_PARTY_HASTE_BONUS); long lDefenderBonus = GetPoint(POINT_PARTY_DEFENDER_BONUS); long long lHPRecovery = GetPoint(POINT_HP_RECOVERY); long lSPRecovery = GetPoint(POINT_SP_RECOVERY); #ifdef ENABLE_COMPUTE_POINT_FIX m_pointsInstant.computed = false; #endif memset(m_pointsInstant.points, 0, sizeof(m_pointsInstant.points)); BuffOnAttr_ClearAll(); m_SkillDamageBonus.clear(); SetPoint(POINT_STAT, lStat); SetPoint(POINT_SKILL, lSkillActive); SetPoint(POINT_SUB_SKILL, lSkillSub); SetPoint(POINT_HORSE_SKILL, lSkillHorse); SetPoint(POINT_LEVEL_STEP, lLevelStep); SetPoint(POINT_STAT_RESET_COUNT, lStatResetCount); SetPoint(POINT_ST, GetRealPoint(POINT_ST)); SetPoint(POINT_HT, GetRealPoint(POINT_HT)); SetPoint(POINT_DX, GetRealPoint(POINT_DX)); SetPoint(POINT_IQ, GetRealPoint(POINT_IQ)); SetPart(PART_MAIN, GetOriginalPart(PART_MAIN)); SetPart(PART_WEAPON, GetOriginalPart(PART_WEAPON)); SetPart(PART_HEAD, GetOriginalPart(PART_HEAD)); SetPart(PART_HAIR, GetOriginalPart(PART_HAIR)); #ifdef ENABLE_ACCE_SYSTEM SetPart(PART_ACCE, GetOriginalPart(PART_ACCE)); #endif #ifdef ENABLE_AURA_SYSTEM SetPart(PART_AURA, GetOriginalPart(PART_AURA)); #endif #ifdef ENABLE_WINGS_NEW SetPart(PART_WING, GetOriginalPart(PART_WING)); #endif SetPoint(POINT_PARTY_ATTACKER_BONUS, lAttackerBonus); SetPoint(POINT_PARTY_TANKER_BONUS, lTankerBonus); SetPoint(POINT_PARTY_BUFFER_BONUS, lBufferBonus); SetPoint(POINT_PARTY_SKILL_MASTER_BONUS, lSkillMasterBonus); SetPoint(POINT_PARTY_HASTE_BONUS, lHasteBonus); SetPoint(POINT_PARTY_DEFENDER_BONUS, lDefenderBonus); SetPoint(POINT_HP_RECOVERY, lHPRecovery); SetPoint(POINT_SP_RECOVERY, lSPRecovery); // PC_BANG_ITEM_ADD SetPoint(POINT_PC_BANG_EXP_BONUS, 0); SetPoint(POINT_PC_BANG_DROP_BONUS, 0); // END_PC_BANG_ITEM_ADD long long iMaxHP, iMaxSP; int iMaxStamina; if (IsPC()) { #ifdef ENABLE_MOUNT_COSTUME_SYSTEM if (GetMountVnum() && !GetWear(WEAR_COSTUME_MOUNT)) #else if (GetMountVnum()) #endif { if (GetHorseST() > GetPoint(POINT_ST)) PointChange(POINT_ST, GetHorseST() - GetPoint(POINT_ST)); if (GetHorseDX() > GetPoint(POINT_DX)) PointChange(POINT_DX, GetHorseDX() - GetPoint(POINT_DX)); if (GetHorseHT() > GetPoint(POINT_HT)) PointChange(POINT_HT, GetHorseHT() - GetPoint(POINT_HT)); if (GetHorseIQ() > GetPoint(POINT_IQ)) PointChange(POINT_IQ, GetHorseIQ() - GetPoint(POINT_IQ)); } iMaxHP = JobInitialPoints[GetJob()].max_hp + m_points.iRandomHP + GetPoint(POINT_HT) * JobInitialPoints[GetJob()].hp_per_ht; iMaxSP = JobInitialPoints[GetJob()].max_sp + m_points.iRandomSP + GetPoint(POINT_IQ) * JobInitialPoints[GetJob()].sp_per_iq; iMaxStamina = JobInitialPoints[GetJob()].max_stamina + GetPoint(POINT_HT) * JobInitialPoints[GetJob()].stamina_per_con; { CSkillProto* pkSk = CSkillManager::instance().Get(SKILL_ADD_HP); if (NULL != pkSk) { pkSk->SetPointVar("k", 1.0f * GetSkillPower(SKILL_ADD_HP) / 100.0f); iMaxHP += /*static_cast*/(pkSk->kPointPoly.Eval()); } } SetPoint(POINT_MOV_SPEED, 330); SetPoint(POINT_ATT_SPEED, 284); PointChange(POINT_ATT_SPEED, GetPoint(POINT_PARTY_HASTE_BONUS)); SetPoint(POINT_CASTING_SPEED, 100); } else { iMaxHP = m_pkMobData->m_table.dwMaxHP; iMaxSP = 0; iMaxStamina = 0; SetPoint(POINT_ATT_SPEED, m_pkMobData->m_table.sAttackSpeed); SetPoint(POINT_MOV_SPEED, m_pkMobData->m_table.sMovingSpeed); SetPoint(POINT_CASTING_SPEED, m_pkMobData->m_table.sAttackSpeed); } /*if (IsPC()) { #ifdef ENABLE_MOUNT_COSTUME_SYSTEM if (GetMountVnum() && !GetWear(WEAR_COSTUME_MOUNT)) #else if (GetMountVnum()) #endif { if (GetHorseST() > GetPoint(POINT_ST)) PointChange(POINT_ST, GetHorseST() - GetPoint(POINT_ST)); if (GetHorseDX() > GetPoint(POINT_DX)) PointChange(POINT_DX, GetHorseDX() - GetPoint(POINT_DX)); if (GetHorseHT() > GetPoint(POINT_HT)) PointChange(POINT_HT, GetHorseHT() - GetPoint(POINT_HT)); if (GetHorseIQ() > GetPoint(POINT_IQ)) PointChange(POINT_IQ, GetHorseIQ() - GetPoint(POINT_IQ)); } }*/ ComputeBattlePoints(); if (iMaxHP != GetMaxHP()) { SetRealPoint(POINT_MAX_HP, iMaxHP); } PointChange(POINT_MAX_HP, 0); if (iMaxSP != GetMaxSP()) { SetRealPoint(POINT_MAX_SP, iMaxSP); } PointChange(POINT_MAX_SP, 0); SetMaxStamina(iMaxStamina); // @fixme118 part1 long long iCurHP = this->GetHP(); int iCurSP = this->GetSP(); m_pointsInstant.dwImmuneFlag = 0; for (int i = 0; i < WEAR_MAX_NUM; i++) { LPITEM pItem = GetWear(i); if (pItem) { pItem->ModifyPoints(true); SET_BIT(m_pointsInstant.dwImmuneFlag, GetWear(i)->GetImmuneFlag()); } } if (DragonSoul_IsDeckActivated()) { for (int i = WEAR_MAX_NUM + DS_SLOT_MAX * DragonSoul_GetActiveDeck(); i < WEAR_MAX_NUM + DS_SLOT_MAX * (DragonSoul_GetActiveDeck() + 1); i++) { LPITEM pItem = GetWear(i); if (pItem) { if (DSManager::instance().IsTimeLeftDragonSoul(pItem)) pItem->ModifyPoints(true); } } } if (GetHP() > GetMaxHP()) PointChange(POINT_HP, GetMaxHP() - GetHP()); if (GetSP() > GetMaxSP()) PointChange(POINT_SP, GetMaxSP() - GetSP()); ComputeSkillPoints(); #if defined(__NEW_PASSIVE_SKILLS__) ComputeNewPassiveSkills(); #endif RefreshAffect(); #ifndef ENABLE_EXTENDED_PET_SYSTEM CPetSystem* pPetSystem = GetPetSystem(); if (NULL != pPetSystem) pPetSystem->RefreshBuff(); #endif #ifdef ENABLE_COMPUTE_POINT_FIX m_pointsInstant.computed = true; #endif // @fixme118 part2 (after petsystem stuff) if (IsPC()) { if (this->GetHP() != iCurHP) this->PointChange(POINT_HP, iCurHP - this->GetHP()); if (this->GetSP() != iCurSP) this->PointChange(POINT_SP, iCurSP - this->GetSP()); } UpdatePacket(); } void CHARACTER::ResetPlayTime(DWORD dwTimeRemain) { m_dwPlayStartTime = get_dword_time() - dwTimeRemain; } const int aiRecoveryPercents[10] = { 1, 5, 5, 5, 5, 5, 5, 5, 5, 5 }; EVENTFUNC(recovery_event) { char_event_info* info = dynamic_cast(event->info); if (info == NULL) { sys_err("recovery_event> Null pointer"); return 0; } LPCHARACTER ch = info->ch; if (ch == NULL) { // return 0; } if (!ch->IsPC()) { if (ch->IsAffectFlag(AFF_POISON)) return PASSES_PER_SEC(MAX(1, ch->GetMobTable().bRegenCycle)); #ifdef ENABLE_WOLFMAN_CHARACTER if (ch->IsAffectFlag(AFF_BLEEDING)) return PASSES_PER_SEC(MAX(1, ch->GetMobTable().bRegenCycle)); #endif if (2493 == ch->GetMobTable().dwVnum) { long long regenPct = BlueDragon_GetRangeFactor("hp_regen", ch->GetHPPct()); regenPct += ch->GetMobTable().bRegenPercent; for (int i = 1; i <= 4; ++i) { if (REGEN_PECT_BONUS == BlueDragon_GetIndexFactor("DragonStone", i, "effect_type")) { DWORD dwDragonStoneID = BlueDragon_GetIndexFactor("DragonStone", i, "vnum"); size_t val = BlueDragon_GetIndexFactor("DragonStone", i, "val"); size_t cnt = SECTREE_MANAGER::instance().GetMonsterCountInMap(ch->GetMapIndex(), dwDragonStoneID); regenPct += (val * cnt); break; } } ch->PointChange(POINT_HP, MAX(1, (ch->GetMaxHP() * regenPct) / 100)); } else if (!ch->IsDoor()) { ch->MonsterLog("HP_REGEN +%d", MAX(1, (ch->GetMaxHP() * ch->GetMobTable().bRegenPercent) / 100)); ch->PointChange(POINT_HP, MAX(1, (ch->GetMaxHP() * ch->GetMobTable().bRegenPercent) / 100)); } if (ch->GetHP() >= ch->GetMaxHP()) { ch->m_pkRecoveryEvent = NULL; return 0; } if (2493 == ch->GetMobTable().dwVnum) { for (int i = 1; i <= 4; ++i) { if (REGEN_TIME_BONUS == BlueDragon_GetIndexFactor("DragonStone", i, "effect_type")) { DWORD dwDragonStoneID = BlueDragon_GetIndexFactor("DragonStone", i, "vnum"); size_t val = BlueDragon_GetIndexFactor("DragonStone", i, "val"); size_t cnt = SECTREE_MANAGER::instance().GetMonsterCountInMap(ch->GetMapIndex(), dwDragonStoneID); return PASSES_PER_SEC(MAX(1, (ch->GetMobTable().bRegenCycle - (val * cnt)))); } } } return PASSES_PER_SEC(MAX(1, ch->GetMobTable().bRegenCycle)); } else { ch->CheckTarget(); //ch->UpdateSectree(); ch->UpdateKillerMode(); if (ch->IsAffectFlag(AFF_POISON) == true) { return 3; } #ifdef ENABLE_WOLFMAN_CHARACTER if (ch->IsAffectFlag(AFF_BLEEDING)) return 3; #endif int iSec = (get_dword_time() - ch->GetLastMoveTime()) / 3000; ch->DistributeSP(ch); if (ch->GetMaxHP() <= ch->GetHP()) return PASSES_PER_SEC(3); int iPercent = 0; long long iAmount = 0; { iPercent = aiRecoveryPercents[MIN(9, iSec)]; iAmount = 15 + (ch->GetMaxHP() * iPercent) / 100; } iAmount += (iAmount * ch->GetPoint(POINT_HP_REGEN)) / 100; sys_log(1, "RECOVERY_EVENT: %s %d HP_REGEN %d HP +%d", ch->GetName(), iPercent, ch->GetPoint(POINT_HP_REGEN), iAmount); ch->PointChange(POINT_HP, iAmount, false); return PASSES_PER_SEC(3); } } void CHARACTER::StartRecoveryEvent() { if (m_pkRecoveryEvent) return; if (IsDead() || IsStun()) return; if (IsNPC() && GetHP() >= GetMaxHP()) return; char_event_info* info = AllocEventInfo(); info->ch = this; int iSec = IsPC() ? 3 : (MAX(1, GetMobTable().bRegenCycle)); m_pkRecoveryEvent = event_create(recovery_event, info, PASSES_PER_SEC(iSec)); } #ifdef BOSS_ARENA EVENTFUNC(bossarena_event) { char_event_info* info = dynamic_cast(event->info); if (info == NULL) { sys_err("recovery_event> Null pointer"); return 0; } LPCHARACTER ch = info->ch; if (ch == NULL) { return 0; } CBossArena::instance().Notification(ch); return PASSES_PER_SEC(60); } void CHARACTER::StartBossArenaEvent() { if (m_pkBossInfoEvent) return; char_event_info* info = AllocEventInfo(); info->ch = this; m_pkBossInfoEvent = event_create(bossarena_event, info, PASSES_PER_SEC(60)); } #endif void CHARACTER::Standup() { struct packet_position pack_position; if (!IsPosition(POS_SITTING)) return; SetPosition(POS_STANDING); sys_log(1, "STANDUP: %s", GetName()); pack_position.header = HEADER_GC_CHARACTER_POSITION; pack_position.vid = GetVID(); pack_position.position = POSITION_GENERAL; PacketAround(&pack_position, sizeof(pack_position)); } void CHARACTER::Sitdown(int is_ground) { struct packet_position pack_position; if (IsPosition(POS_SITTING)) return; SetPosition(POS_SITTING); sys_log(1, "SITDOWN: %s", GetName()); pack_position.header = HEADER_GC_CHARACTER_POSITION; pack_position.vid = GetVID(); pack_position.position = POSITION_SITTING_GROUND; PacketAround(&pack_position, sizeof(pack_position)); } void CHARACTER::SetRotation(float fRot) { m_pointsInstant.fRot = fRot; } void CHARACTER::SetRotationToXY(long x, long y) { SetRotation(GetDegreeFromPositionXY(GetX(), GetY(), x, y)); } bool CHARACTER::CannotMoveByAffect() const { return (IsAffectFlag(AFF_STUN)); } bool CHARACTER::CanMove() const { if (CannotMoveByAffect()) return false; if (GetMyShop()) return false; /* if (get_float_time() - m_fSyncTime < 0.2f) return false; */ return true; } bool CHARACTER::Sync(long x, long y) { if (!GetSectree()) return false; if (IsPC() && IsDead())// @fixme192 return false; LPSECTREE new_tree = SECTREE_MANAGER::instance().Get(GetMapIndex(), x, y); if (!new_tree) { if (!GetDesc()) { sys_err("No tree %s %ld %ld %ld", GetName(), x, y, GetMapIndex()); Dead(); return false; } x = GetX(); y = GetY(); new_tree = GetSectree(); return false; } SetRotationToXY(x, y); SetXYZ(x, y, 0); if (GetDungeon()) { int iLastEventAttr = m_iEventAttr; m_iEventAttr = new_tree->GetEventAttribute(x, y); if (m_iEventAttr != iLastEventAttr) { if (GetParty()) { quest::CQuestManager::instance().AttrOut(GetParty()->GetLeaderPID(), this, iLastEventAttr); quest::CQuestManager::instance().AttrIn(GetParty()->GetLeaderPID(), this, m_iEventAttr); } else { quest::CQuestManager::instance().AttrOut(GetPlayerID(), this, iLastEventAttr); quest::CQuestManager::instance().AttrIn(GetPlayerID(), this, m_iEventAttr); } } } if (GetSectree() != new_tree) { if (!IsNPC()) { SECTREEID id = new_tree->GetID(); SECTREEID old_id = GetSectree()->GetID(); const float fDist = DISTANCE_SQRT(id.coord.x - old_id.coord.x, id.coord.y - old_id.coord.y); sys_log(0, "SECTREE DIFFER: %s %dx%d was %dx%d dist %.1fm", GetName(), id.coord.x, id.coord.y, old_id.coord.x, old_id.coord.y, fDist); } new_tree->InsertEntity(this); } return true; } void CHARACTER::Stop() { if (!IsState(m_stateIdle)) MonsterLog("[IDLE] Á¤Áö"); GotoState(m_stateIdle); m_posDest.x = m_posStart.x = GetX(); m_posDest.y = m_posStart.y = GetY(); } bool CHARACTER::Goto(long x, long y) { if (GetX() == x && GetY() == y) return false; if (m_posDest.x == x && m_posDest.y == y) { if (!IsState(m_stateMove)) { m_dwStateDuration = 4; GotoState(m_stateMove); } return false; } m_posDest.x = x; m_posDest.y = y; CalculateMoveDuration(); m_dwStateDuration = 4; if (!IsState(m_stateMove)) { MonsterLog("[MOVE] %s", GetVictim() ? "´ë»óÃßÀû" : "±×³ÉÀ̵¿"); if (GetVictim()) { //MonsterChat(MONSTER_CHAT_CHASE); MonsterChat(MONSTER_CHAT_ATTACK); } } GotoState(m_stateMove); return true; } DWORD CHARACTER::GetMotionMode() const { DWORD dwMode = MOTION_MODE_GENERAL; if (IsPolymorphed()) return dwMode; LPITEM pkItem; if ((pkItem = GetWear(WEAR_WEAPON))) { switch (pkItem->GetProto()->bSubType) { case WEAPON_SWORD: dwMode = MOTION_MODE_ONEHAND_SWORD; break; case WEAPON_TWO_HANDED: dwMode = MOTION_MODE_TWOHAND_SWORD; break; case WEAPON_DAGGER: dwMode = MOTION_MODE_DUALHAND_SWORD; break; case WEAPON_BOW: dwMode = MOTION_MODE_BOW; break; case WEAPON_BELL: dwMode = MOTION_MODE_BELL; break; case WEAPON_FAN: dwMode = MOTION_MODE_FAN; break; #ifdef ENABLE_WOLFMAN_CHARACTER case WEAPON_CLAW: dwMode = MOTION_MODE_CLAW; break; #endif } } return dwMode; } float CHARACTER::GetMoveMotionSpeed() const { DWORD dwMode = GetMotionMode(); const CMotion* pkMotion = NULL; if (!GetMountVnum()) pkMotion = CMotionManager::instance().GetMotion(GetRaceNum(), MAKE_MOTION_KEY(dwMode, (IsWalking() && IsPC()) ? MOTION_WALK : MOTION_RUN)); else { pkMotion = CMotionManager::instance().GetMotion(GetMountVnum(), MAKE_MOTION_KEY(MOTION_MODE_GENERAL, (IsWalking() && IsPC()) ? MOTION_WALK : MOTION_RUN)); if (!pkMotion) pkMotion = CMotionManager::instance().GetMotion(GetRaceNum(), MAKE_MOTION_KEY(MOTION_MODE_HORSE, (IsWalking() && IsPC()) ? MOTION_WALK : MOTION_RUN)); } if (pkMotion) return -pkMotion->GetAccumVector().y / pkMotion->GetDuration(); else { //sys_err("cannot find motion (name %s race %d mode %d)", GetName(), GetRaceNum(), dwMode); return 300.0f; } } float CHARACTER::GetMoveSpeed() const { return GetMoveMotionSpeed() * 10000 / CalculateDuration(GetLimitPoint(POINT_MOV_SPEED), 10000); } void CHARACTER::CalculateMoveDuration() { m_posStart.x = GetX(); m_posStart.y = GetY(); float fDist = DISTANCE_SQRT(m_posStart.x - m_posDest.x, m_posStart.y - m_posDest.y); float motionSpeed = GetMoveMotionSpeed(); m_dwMoveDuration = CalculateDuration(GetLimitPoint(POINT_MOV_SPEED), (int)((fDist / motionSpeed) * 1000.0f)); if (IsNPC()) sys_log(1, "%s: GOTO: distance %f, spd %u, duration %u, motion speed %f pos %d %d -> %d %d", GetName(), fDist, GetLimitPoint(POINT_MOV_SPEED), m_dwMoveDuration, motionSpeed, m_posStart.x, m_posStart.y, m_posDest.x, m_posDest.y); m_dwMoveStartTime = get_dword_time(); } bool CHARACTER::Move(long x, long y) { if (IsPC() && IsDead())// @fixme226 return false; if (GetX() == x && GetY() == y) return true; if (test_server) if (m_bDetailLog) sys_log(0, "%s position %u %u", GetName(), x, y); OnMove(); return Sync(x, y); } void CHARACTER::SendMovePacket(BYTE bFunc, BYTE bArg, DWORD x, DWORD y, DWORD dwDuration, DWORD dwTime, int iRot) { TPacketGCMove pack; if (bFunc == FUNC_WAIT) { x = m_posDest.x; y = m_posDest.y; dwDuration = m_dwMoveDuration; } EncodeMovePacket(pack, GetVID(), bFunc, bArg, x, y, dwDuration, dwTime, iRot == -1 ? (int)GetRotation() / 5 : iRot); PacketView(&pack, sizeof(TPacketGCMove), this); } long long CHARACTER::GetRealPoint(BYTE type) const { return m_points.points[type]; } void CHARACTER::SetRealPoint(BYTE type, long long val) { m_points.points[type] = val; } int CHARACTER::GetPolymorphPoint(BYTE type) const { if (IsPolymorphed() && !IsPolyMaintainStat()) { DWORD dwMobVnum = GetPolymorphVnum(); const CMob* pMob = CMobManager::instance().Get(dwMobVnum); #ifdef ENABLE_DAMAGE_LIMIT_RENEWAL long long iPower = GetPolymorphPower(); #else int iPower = GetPolymorphPower(); #endif if (pMob) { switch (type) { case POINT_ST: if ((GetJob() == JOB_SHAMAN) || ((GetJob() == JOB_SURA) && (GetSkillGroup() == 2))) return pMob->m_table.bStr * iPower / 100 + GetPoint(POINT_IQ); return pMob->m_table.bStr * iPower / 100 + GetPoint(POINT_ST); case POINT_HT: return pMob->m_table.bCon * iPower / 100 + GetPoint(POINT_HT); case POINT_IQ: return pMob->m_table.bInt * iPower / 100 + GetPoint(POINT_IQ); case POINT_DX: return pMob->m_table.bDex * iPower / 100 + GetPoint(POINT_DX); } } } return GetPoint(type); } #ifdef ENABLE_YANG_LIMIT_SYSTEM long long CHARACTER::GetPoint(BYTE type) const #else int CHARACTER::GetPoint(BYTE type) const #endif { if (type >= POINT_MAX_NUM) { sys_err("Point type overflow (type %u)", type); return 0; } #ifdef ENABLE_YANG_LIMIT_SYSTEM long long val = m_pointsInstant.points[type]; long long max_val = LLONG_MAX; #else int val = m_pointsInstant.points[type]; int max_val = INT_MAX; #endif switch (type) { case POINT_STEAL_HP: case POINT_STEAL_SP: max_val = 50; break; } if (val > max_val) //sys_err("POINT_ERROR: %s type %d val %d (max: %d)", GetName(), val, max_val); sys_err("POINT_ERROR: %s type %d val %llu (max: %llu)", GetName(), type, val, max_val);//@DsProject15 return (val); } #ifdef ENABLE_HP_LIMIT_RENEWAL long long CHARACTER::GetLimitPoint(int type) const #else int CHARACTER::GetLimitPoint(int type) const #endif { if (type >= POINT_MAX_NUM) { sys_err("Point type overflow (type %u)", type); return 0; } long long val = m_pointsInstant.points[type]; long long max_val = LLONG_MAX; long long limit = LLONG_MAX; long long min_limit = -LLONG_MAX; switch (type) { case POINT_ATT_SPEED: min_limit = 0; if (IsPC()) #ifdef ENABLE_MOVEANDATTACK_SPEED limit = AttSpeed; #else limit = 250; #endif else limit = 275; break; case POINT_MOV_SPEED: min_limit = 0; if (IsPC()) #ifdef ENABLE_MOVEANDATTACK_SPEED limit = MveSpeed; #else limit = 350; #endif else limit = 375; break; case POINT_STEAL_HP: case POINT_STEAL_SP: limit = 50; max_val = 50; break; case POINT_MALL_ATTBONUS: case POINT_MALL_DEFBONUS: limit = 20; max_val = 50; break; } if (val > max_val) #ifdef ENABLE_HP_LIMIT_RENEWAL sys_err("POINT_ERROR: %s type %d val %llu (max: %llu)", GetName(), type, val, max_val);//@Light5#15 #else sys_err("POINT_ERROR: %s type %d val %d (max: %d)", GetName(), type, val, max_val);//@Light5#15 #endif if (val > limit) val = limit; if (val < min_limit) val = min_limit; return (val); } #ifdef ENABLE_YANG_LIMIT_SYSTEM void CHARACTER::SetPoint(BYTE type, long long val) #else void CHARACTER::SetPoint(BYTE type, int val) #endif { if (type >= POINT_MAX_NUM) { sys_err("Point type overflow (type %u)", type); return; } m_pointsInstant.points[type] = val; if (type == POINT_MOV_SPEED && get_dword_time() < m_dwMoveStartTime + m_dwMoveDuration) { CalculateMoveDuration(); } } #ifdef ENABLE_YANG_LIMIT_SYSTEM long long CHARACTER::GetAllowedGold() const #else INT CHARACTER::GetAllowedGold() const #endif { if (GetLevel() <= 10) return 100000; else if (GetLevel() <= 20) return 500000; else return 50000000; } void CHARACTER::CheckMaximumPoints() { if (GetMaxHP() < GetHP()) PointChange(POINT_HP, GetMaxHP() - GetHP()); if (GetMaxSP() < GetSP()) PointChange(POINT_SP, GetMaxSP() - GetSP()); } #ifdef ENABLE_YANG_LIMIT_SYSTEM void CHARACTER::PointChange(BYTE type, long long amount, bool bAmount, bool bBroadcast) { long long val = 0; #else void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast) { int val = 0; #endif //sys_log(0, "PointChange %d %d | %d -> %d cHP %d mHP %d", type, amount, GetPoint(type), GetPoint(type)+amount, GetHP(), GetMaxHP()); switch (type) { case POINT_NONE: return; case POINT_LEVEL: if ((GetLevel() + amount) > gPlayerMaxLevel) return; SetLevel(GetLevel() + amount); val = GetLevel(); sys_log(0, "LEVELUP: %s %d NEXT EXP %d", GetName(), GetLevel(), GetNextExp()); #ifdef ENABLE_WOLFMAN_CHARACTER if (GetJob() == JOB_WOLFMAN) { if ((5 <= val) && (GetSkillGroup() != 1)) { ClearSkill(); // set skill group SetSkillGroup(4); // set skill points SetRealPoint(POINT_SKILL, GetLevel() - 1); SetPoint(POINT_SKILL, GetRealPoint(POINT_SKILL)); PointChange(POINT_SKILL, 0); // update points (not required) // ComputePoints(); // PointsPacket(); } } #endif PointChange(POINT_NEXT_EXP, GetNextExp(), false); if (amount) { quest::CQuestManager::instance().LevelUp(GetPlayerID()); LogManager::instance().LevelLog(this, val, GetRealPoint(POINT_PLAYTIME) + (get_dword_time() - m_dwPlayStartTime) / 60000); if (GetGuild()) { GetGuild()->LevelChange(GetPlayerID(), GetLevel()); } if (GetParty()) { GetParty()->RequestSetMemberLevel(GetPlayerID(), GetLevel()); } } break; case POINT_NEXT_EXP: val = GetNextExp(); bAmount = false; break; case POINT_EXP: { DWORD exp = GetExp(); DWORD next_exp = GetNextExp(); if (g_bChinaIntoxicationCheck) { if (IsOverTime(OT_NONE)) { dev_log(LOG_DEB0, " %s = NONE", GetName()); } else if (IsOverTime(OT_3HOUR)) { amount = (amount / 2); dev_log(LOG_DEB0, " %s = 3HOUR", GetName()); } else if (IsOverTime(OT_5HOUR)) { amount = 0; dev_log(LOG_DEB0, " %s = 5HOUR", GetName()); } } #ifdef ENABLE_POINT_EXP_FIX if ((amount < 0) && (exp <= std::abs(amount))) #else if ((amount < 0) && (exp < (DWORD)(-amount))) #endif { sys_log(1, "%s AMOUNT < 0 %d, CUR EXP: %d", GetName(), -amount, exp); amount = -exp; SetExp(exp + amount); val = GetExp(); } else { //#ifdef ENABLE_REBIRT_SYSTEM // if (GetLevel() >= gPlayerMaxLevel) // { // //DWORD next_exp = GetNextRebirtExp(); // if (GetRebirt() < REBIRT_MAX) // { // if (GetRebirt() < 6) // amount /= 8; // else // amount /= 12; // // if (GetLevel() >= gPlayerMaxLevel && (exp + amount) >= next_exp) // { // SetRebirt(GetRebirt() + 1); // SetExp(0); // // if (IsPC()) // { // if (GetRebirt() == 1 || // GetRebirt() == 2 || // GetRebirt() == 3 || // GetRebirt() == 4 || // GetRebirt() == 5) // { // EffectPacket(SE_DUEL_SENDER); // } // // else if (GetRebirt() == 6 || // GetRebirt() == 7 || // GetRebirt() == 8 || // GetRebirt() == 9 || // GetRebirt() == 10) // { // EffectPacket(SE_DUEL_RECEIVER); // } // else if (GetRebirt() == 11 || // GetRebirt() == 12 || // GetRebirt() == 13 || // GetRebirt() == 14 || // GetRebirt() == 15) // { // EffectPacket(SE_DUEL_RECEIVER2); // } // else if (GetRebirt() == 16 || // GetRebirt() == 17 || // GetRebirt() == 18 || // GetRebirt() == 19 || // GetRebirt() == 20) // { // EffectPacket(SE_DUEL_RECEIVER3); // } // else if (GetRebirt() == 21 || // GetRebirt() == 22 || // GetRebirt() == 23 || // GetRebirt() == 24 || // GetRebirt() == 25) // { // EffectPacket(SE_DUEL_RECEIVER4); // } // else if (GetRebirt() == 26 || // GetRebirt() == 27 || // GetRebirt() == 28 || // GetRebirt() == 29 || // GetRebirt() == 30) // { // EffectPacket(SE_DUEL_RECEIVER5); // } // if (GetRebirt() >= 1 && GetRebirt() <= 30) // { // BYTE bRebirt = GetRebirt(); // DWORD PointCanavar = bRebirt * 10; // DWORD PointMetin = bRebirt * 10; // // AddAffect(AFFECT_REBIRT_BONUS, POINT_ATTBONUS_MONSTER, PointCanavar, 0, 60 * 60 * 24 * 365 * 60, 0, false); // AddAffect(AFFECT_REBIRT_BONUS, POINT_ATTBONUS_STONE, PointMetin, 0, 60 * 60 * 24 * 365 * 60, 0, false); // // ChatPacket(CHAT_TYPE_COMMAND, "rebirtodul2 %u %u", PointCanavar, PointMetin); // PointsPacket(); // } // } // // return; // } // } // else // { // sys_log(1, "%s rebirt son seviyede.", GetName()); // return; // } // } // else if (gPlayerMaxLevel <= GetLevel() && REBIRT_MAX <= GetRebirt()) // { // if (GetExp() > 0) // SetExp(0); // // return; // } //#else if (gPlayerMaxLevel <= GetLevel()) return; //#endif if (IsBlockMode(BLOCK_POINT_EXP)) return; if (test_server) ChatPacket(CHAT_TYPE_INFO, "You have gained %d exp.", amount); DWORD iExpBalance = 0; if (exp + amount >= next_exp) { iExpBalance = (exp + amount) - next_exp; amount = next_exp - exp; SetExp(0); exp = next_exp; } else { SetExp(exp + amount); exp = GetExp(); } DWORD q = DWORD(next_exp / 4.0f); int iLevStep = GetRealPoint(POINT_LEVEL_STEP); if (iLevStep >= 4) { sys_err("%s LEVEL_STEP bigger than 4! (%d)", GetName(), iLevStep); iLevStep = 4; } if (exp >= next_exp && iLevStep < 4) { for (int i = 0; i < 4 - iLevStep; ++i) PointChange(POINT_LEVEL_STEP, 1, false, true); } else if (exp >= q * 3 && iLevStep < 3) { for (int i = 0; i < 3 - iLevStep; ++i) PointChange(POINT_LEVEL_STEP, 1, false, true); } else if (exp >= q * 2 && iLevStep < 2) { for (int i = 0; i < 2 - iLevStep; ++i) PointChange(POINT_LEVEL_STEP, 1, false, true); } else if (exp >= q && iLevStep < 1) PointChange(POINT_LEVEL_STEP, 1); if (iExpBalance) { PointChange(POINT_EXP, iExpBalance); } val = GetExp(); } } break; case POINT_LEVEL_STEP: if (amount > 0) { val = GetPoint(POINT_LEVEL_STEP) + amount; switch (val) { case 1: case 2: case 3: if ((GetLevel() <= g_iStatusPointGetLevelLimit) && (GetLevel() <= gPlayerMaxLevel)) // @fixme104 PointChange(POINT_STAT, 1); break; case 4: { long long iHP = number(JobInitialPoints[GetJob()].hp_per_lv_begin, JobInitialPoints[GetJob()].hp_per_lv_end); int iSP = number(JobInitialPoints[GetJob()].sp_per_lv_begin, JobInitialPoints[GetJob()].sp_per_lv_end); m_points.iRandomHP += iHP; m_points.iRandomSP += iSP; if (GetSkillGroup()) { if (GetLevel() >= 5) PointChange(POINT_SKILL, 1); if (GetLevel() >= 9) PointChange(POINT_SUB_SKILL, 1); } PointChange(POINT_MAX_HP, iHP); PointChange(POINT_MAX_SP, iSP); PointChange(POINT_LEVEL, 1, false, true); val = 0; } break; } //@DsProject29 //if (GetLevel() <= 10) // AutoGiveItem(27001, 2); //else if (GetLevel() <= 30) // AutoGiveItem(27002, 2); //else //{ // AutoGiveItem(27002, 2); // AutoGiveItem(27003, 2); //} PointChange(POINT_HP, GetMaxHP() - GetHP()); PointChange(POINT_SP, GetMaxSP() - GetSP()); PointChange(POINT_STAMINA, GetMaxStamina() - GetStamina()); SetPoint(POINT_LEVEL_STEP, val); SetRealPoint(POINT_LEVEL_STEP, val); Save(); } else val = GetPoint(POINT_LEVEL_STEP); break; case POINT_HP: { if (IsDead() || IsStun()) return; long long prev_hp = GetHP(); amount = MIN(GetMaxHP() - GetHP(), amount); SetHP(GetHP() + amount); val = GetHP(); BroadcastTargetPacket(); if (GetParty() && IsPC() && val != prev_hp) GetParty()->SendPartyInfoOneToAll(this); } break; case POINT_SP: { if (IsDead() || IsStun()) return; amount = MIN(GetMaxSP() - GetSP(), amount); SetSP(GetSP() + amount); val = GetSP(); } break; case POINT_STAMINA: { if (IsDead() || IsStun()) return; int prev_val = GetStamina(); amount = MIN(GetMaxStamina() - GetStamina(), amount); SetStamina(GetStamina() + amount); val = GetStamina(); if (val == 0) { // Stamina SetNowWalking(true); } else if (prev_val == 0) { ResetWalking(); } if (amount < 0 && val != 0) return; } break; case POINT_MAX_HP: { SetPoint(type, GetPoint(type) + amount); //SetMaxHP(GetMaxHP() + amount); long long hp = GetRealPoint(POINT_MAX_HP); long long add_hp = MIN(3500, hp * GetPoint(POINT_MAX_HP_PCT) / 100); add_hp += GetPoint(POINT_MAX_HP); add_hp += GetPoint(POINT_PARTY_TANKER_BONUS); SetMaxHP(hp + add_hp); val = GetMaxHP(); } break; case POINT_MAX_SP: { SetPoint(type, GetPoint(type) + amount); //SetMaxSP(GetMaxSP() + amount); int sp = GetRealPoint(POINT_MAX_SP); int add_sp = MIN(800, sp * GetPoint(POINT_MAX_SP_PCT) / 100); add_sp += GetPoint(POINT_MAX_SP); add_sp += GetPoint(POINT_PARTY_SKILL_MASTER_BONUS); SetMaxSP(sp + add_sp); val = GetMaxSP(); } break; case POINT_MAX_HP_PCT: SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); PointChange(POINT_MAX_HP, 0); break; case POINT_MAX_SP_PCT: SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); PointChange(POINT_MAX_SP, 0); break; case POINT_MAX_STAMINA: SetMaxStamina(GetMaxStamina() + amount); val = GetMaxStamina(); break; case POINT_GOLD: { #ifdef ENABLE_YANG_LIMIT_SYSTEM const long long nTotalMoney = GetGold() + amount; if (GOLD_MAX <= nTotalMoney) { sys_err("[OVERFLOW_GOLD] OriGold %lld AddedGold %lld id %u Name %s ", GetGold(), amount, GetPlayerID(), GetName()); LogManager::instance().CharLog(this, GetGold() + amount, "OVERFLOW_GOLD", ""); return; } #else const int64_t nTotalMoney = static_cast(GetGold()) + static_cast(amount); if (GOLD_MAX <= nTotalMoney) { sys_err("[OVERFLOW_GOLD] OriGold %d AddedGold %d id %u Name %s ", GetGold(), amount, GetPlayerID(), GetName()); LogManager::instance().CharLog(this, GetGold() + amount, "OVERFLOW_GOLD", ""); return; } #endif if (g_bChinaIntoxicationCheck && amount > 0) { if (IsOverTime(OT_NONE)) { dev_log(LOG_DEB0, " %s = NONE", GetName()); } else if (IsOverTime(OT_3HOUR)) { amount = (amount / 2); dev_log(LOG_DEB0, " %s = 3HOUR", GetName()); } else if (IsOverTime(OT_5HOUR)) { amount = 0; dev_log(LOG_DEB0, " %s = 5HOUR", GetName()); } } if (nTotalMoney < 0)// @fixme227 return; SetGold(GetGold() + amount); val = GetGold(); } break; #ifdef ENABLE_REBIRT_SYSTEM case POINT_REBIRT: { const int16_t nTotalRebirt = static_cast(GetRebirt()) + static_cast(amount); if (nTotalRebirt < 0) { sys_err("[OVERFLOW_REBIRT] Rebirt eksi deger rebirti %u Name %s ", GetRebirt(), GetName()); return; } if (nTotalRebirt >= REBIRT_MAX) { sys_err("[OVERFLOW_REBIRT] Rebirt max seviyede rebirti %u Name %s ", GetRebirt(), GetName()); return; } if (LC_IsNewCIBN() && amount > 0) { if (IsOverTime(OT_NONE)) { dev_log(LOG_DEB0, " %s = NONE", GetName()); } else if (IsOverTime(OT_3HOUR)) { amount = (amount / 2); dev_log(LOG_DEB0, " %s = 3HOUR", GetName()); } else if (IsOverTime(OT_5HOUR)) { amount = 0; dev_log(LOG_DEB0, " %s = 5HOUR", GetName()); } } SetRebirt(GetRebirt() + amount); val = GetRebirt(); } break; #endif #ifdef ENABLE_REBORN_SYSTEM case POINT_REBORN: { const int16_t nTotalReborn = static_cast(GetReborn()) + static_cast(amount); if (nTotalReborn < 0) { sys_err("[OVERFLOW_REBORN] Reborn eksi deger rebornu %u Name %s ", GetReborn(), GetName()); return; } if (nTotalReborn >= REBORN_MAX) { sys_err("[OVERFLOW_REBORN] Reborn max seviyede Rebornu %u Name %s ", GetReborn(), GetName()); return; } if (LC_IsNewCIBN() && amount > 0) { if (IsOverTime(OT_NONE)) { dev_log(LOG_DEB0, " %s = NONE", GetName()); } else if (IsOverTime(OT_3HOUR)) { amount = (amount / 2); dev_log(LOG_DEB0, " %s = 3HOUR", GetName()); } else if (IsOverTime(OT_5HOUR)) { amount = 0; dev_log(LOG_DEB0, " %s = 5HOUR", GetName()); } } SetReborn(GetReborn() + amount); val = GetReborn(); } break; #endif case POINT_SKILL: case POINT_STAT: case POINT_SUB_SKILL: case POINT_STAT_RESET_COUNT: case POINT_HORSE_SKILL: SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); SetRealPoint(type, val); break; case POINT_DEF_GRADE: SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); PointChange(POINT_CLIENT_DEF_GRADE, amount); break; case POINT_CLIENT_DEF_GRADE: SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); break; case POINT_ST: case POINT_HT: case POINT_DX: case POINT_IQ: case POINT_HP_REGEN: case POINT_SP_REGEN: case POINT_ATT_SPEED: case POINT_ATT_GRADE: case POINT_MOV_SPEED: case POINT_CASTING_SPEED: case POINT_MAGIC_ATT_GRADE: case POINT_MAGIC_DEF_GRADE: case POINT_BOW_DISTANCE: case POINT_HP_RECOVERY: case POINT_SP_RECOVERY: case POINT_ATTBONUS_HUMAN: // 42 case POINT_ATTBONUS_ANIMAL: // 43 case POINT_ATTBONUS_ORC: // 44 case POINT_ATTBONUS_MILGYO: // 45 case POINT_ATTBONUS_UNDEAD: // 46 case POINT_ATTBONUS_DEVIL: // 47 case POINT_ATTBONUS_MONSTER: case POINT_ATTBONUS_SURA: case POINT_ATTBONUS_ASSASSIN: case POINT_ATTBONUS_WARRIOR: case POINT_ATTBONUS_SHAMAN: #ifdef ENABLE_WOLFMAN_CHARACTER case POINT_ATTBONUS_WOLFMAN: #endif case POINT_POISON_PCT: #ifdef ENABLE_WOLFMAN_CHARACTER case POINT_BLEEDING_PCT: #endif case POINT_STUN_PCT: case POINT_SLOW_PCT: case POINT_BLOCK: case POINT_DODGE: case POINT_CRITICAL_PCT: case POINT_RESIST_CRITICAL: case POINT_PENETRATE_PCT: case POINT_RESIST_PENETRATE: case POINT_CURSE_PCT: case POINT_STEAL_HP: // 48 case POINT_STEAL_SP: // 49 case POINT_MANA_BURN_PCT: // 50 case POINT_DAMAGE_SP_RECOVER: // 51 case POINT_RESIST_NORMAL_DAMAGE: case POINT_RESIST_SWORD: case POINT_RESIST_TWOHAND: case POINT_RESIST_DAGGER: case POINT_RESIST_BELL: case POINT_RESIST_FAN: case POINT_RESIST_BOW: #ifdef ENABLE_WOLFMAN_CHARACTER case POINT_RESIST_CLAW: #endif case POINT_RESIST_FIRE: case POINT_RESIST_ELEC: case POINT_RESIST_MAGIC: #ifdef ENABLE_ACCE_SYSTEM case POINT_ACCEDRAIN_RATE: #endif #ifdef ENABLE_MAGIC_REDUCTION_SYSTEM case POINT_RESIST_MAGIC_REDUCTION: #endif #ifdef ENABLE_PENDANT_SYSTEM case POINT_ENCHANT_FIRE: case POINT_ENCHANT_ICE: case POINT_ENCHANT_EARTH: case POINT_ENCHANT_DARK: case POINT_ENCHANT_WIND: case POINT_ENCHANT_ELECT: case POINT_RESIST_HUMAN: case POINT_ATTBONUS_SWORD: case POINT_ATTBONUS_TWOHAND: case POINT_ATTBONUS_DAGGER: case POINT_ATTBONUS_BELL: case POINT_ATTBONUS_FAN: case POINT_ATTBONUS_BOW: #ifdef ENABLE_WOLFMAN_CHARACTER case POINT_ATTBONUS_CLAW: #endif case POINT_ATTBONUS_CZ: case POINT_ATTBONUS_DESERT: case POINT_ATTBONUS_INSECT: #endif #ifdef ENABLE_EXTRA_APPLY_BONUS case POINT_ATTBONUS_STONE: case POINT_ATTBONUS_BOSS: case POINT_ATTBONUS_ELEMENTS: case POINT_ENCHANT_ELEMENTS: case POINT_ATTBONUS_CHARACTERS: case POINT_ENCHANT_CHARACTERS: case POINT_ATTBONUS_RAZADOR: case POINT_ATTBONUS_NEMERE: case POINT_ATTBONUS_LUCIFER: case POINT_ATTBONUS_BLUE_DRAGON: case POINT_ATTBONUS_RED_DRAGON: case POINT_ATTBONUS_AZRAEL: #endif case POINT_RESIST_WIND: case POINT_RESIST_ICE: case POINT_RESIST_EARTH: case POINT_RESIST_DARK: case POINT_REFLECT_MELEE: // 67 case POINT_REFLECT_CURSE: // 68 case POINT_POISON_REDUCE: // 69 #ifdef ENABLE_WOLFMAN_CHARACTER case POINT_BLEEDING_REDUCE: #endif case POINT_KILL_SP_RECOVER: // 70 case POINT_KILL_HP_RECOVERY: // 75 case POINT_HIT_HP_RECOVERY: case POINT_HIT_SP_RECOVERY: case POINT_MANASHIELD: case POINT_ATT_BONUS: case POINT_DEF_BONUS: case POINT_SKILL_DAMAGE_BONUS: case POINT_NORMAL_HIT_DAMAGE_BONUS: // DEPEND_BONUS_ATTRIBUTES case POINT_SKILL_DEFEND_BONUS: case POINT_NORMAL_HIT_DEFEND_BONUS: SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); break; // END_OF_DEPEND_BONUS_ATTRIBUTES case POINT_PARTY_ATTACKER_BONUS: case POINT_PARTY_TANKER_BONUS: case POINT_PARTY_BUFFER_BONUS: case POINT_PARTY_SKILL_MASTER_BONUS: case POINT_PARTY_HASTE_BONUS: case POINT_PARTY_DEFENDER_BONUS: case POINT_RESIST_WARRIOR: case POINT_RESIST_ASSASSIN: case POINT_RESIST_SURA: case POINT_RESIST_SHAMAN: #ifdef ENABLE_WOLFMAN_CHARACTER case POINT_RESIST_WOLFMAN: #endif SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); break; case POINT_MALL_ATTBONUS: case POINT_MALL_DEFBONUS: case POINT_MALL_EXPBONUS: case POINT_MALL_ITEMBONUS: case POINT_MALL_GOLDBONUS: case POINT_MELEE_MAGIC_ATT_BONUS_PER: //if (GetPoint(type) + amount > 100) //{ // sys_err("MALL_BONUS exceeded over 100!! point type: %d name: %s amount %d", type, GetName(), amount); // amount = 100 - GetPoint(type); //} SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); break; // PC_BANG_ITEM_ADD case POINT_PC_BANG_EXP_BONUS: case POINT_PC_BANG_DROP_BONUS: case POINT_RAMADAN_CANDY_BONUS_EXP: SetPoint(type, amount); val = GetPoint(type); break; // END_PC_BANG_ITEM_ADD case POINT_EXP_DOUBLE_BONUS: // 71 case POINT_GOLD_DOUBLE_BONUS: // 72 case POINT_ITEM_DROP_BONUS: // 73 case POINT_POTION_BONUS: // 74 //if (GetPoint(type) + amount > 100) //{ // sys_err("BONUS exceeded over 100!! point type: %d name: %s amount %d", type, GetName(), amount); // amount = 100 - GetPoint(type); //} SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); break; case POINT_IMMUNE_STUN: // 76 SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); if (val) { // ChatPacket(CHAT_TYPE_INFO, "IMMUNE_STUN SET_BIT type(%u) amount(%d)", type, amount); SET_BIT(m_pointsInstant.dwImmuneFlag, IMMUNE_STUN); } else { // ChatPacket(CHAT_TYPE_INFO, "IMMUNE_STUN REMOVE_BIT type(%u) amount(%d)", type, amount); REMOVE_BIT(m_pointsInstant.dwImmuneFlag, IMMUNE_STUN); } break; case POINT_IMMUNE_SLOW: // 77 SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); if (val) { SET_BIT(m_pointsInstant.dwImmuneFlag, IMMUNE_SLOW); } else { REMOVE_BIT(m_pointsInstant.dwImmuneFlag, IMMUNE_SLOW); } break; case POINT_IMMUNE_FALL: // 78 SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); if (val) { SET_BIT(m_pointsInstant.dwImmuneFlag, IMMUNE_FALL); } else { REMOVE_BIT(m_pointsInstant.dwImmuneFlag, IMMUNE_FALL); } break; case POINT_ATT_GRADE_BONUS: SetPoint(type, GetPoint(type) + amount); PointChange(POINT_ATT_GRADE, amount); val = GetPoint(type); break; case POINT_DEF_GRADE_BONUS: SetPoint(type, GetPoint(type) + amount); PointChange(POINT_DEF_GRADE, amount); val = GetPoint(type); break; case POINT_MAGIC_ATT_GRADE_BONUS: SetPoint(type, GetPoint(type) + amount); PointChange(POINT_MAGIC_ATT_GRADE, amount); val = GetPoint(type); break; case POINT_MAGIC_DEF_GRADE_BONUS: SetPoint(type, GetPoint(type) + amount); PointChange(POINT_MAGIC_DEF_GRADE, amount); val = GetPoint(type); break; case POINT_VOICE: case POINT_EMPIRE_POINT: //sys_err("CHARACTER::PointChange: %s: point cannot be changed. use SetPoint instead (type: %d)", GetName(), type); val = GetRealPoint(type); break; case POINT_POLYMORPH: SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); SetPolymorph(val); break; case POINT_MOUNT: SetPoint(type, GetPoint(type) + amount); val = GetPoint(type); MountVnum(val); break; case POINT_ENERGY: case POINT_COSTUME_ATTR_BONUS: { int old_val = GetPoint(type); SetPoint(type, old_val + amount); val = GetPoint(type); BuffOnAttr_ValueChange(type, old_val, val); } break; default: sys_err("CHARACTER::PointChange: %s: unknown point change type %d", GetName(), type); return; } switch (type) { case POINT_LEVEL: case POINT_ST: case POINT_DX: case POINT_IQ: case POINT_HT: ComputeBattlePoints(); break; case POINT_MAX_HP: case POINT_MAX_SP: case POINT_MAX_STAMINA: break; } if (type == POINT_HP && amount == 0) return; if (GetDesc()) { struct packet_point_change pack; pack.header = HEADER_GC_CHARACTER_POINT_CHANGE; pack.dwVID = m_vid; pack.type = type; pack.value = val; if (bAmount) pack.amount = amount; else pack.amount = 0; if (!bBroadcast) GetDesc()->Packet(&pack, sizeof(struct packet_point_change)); else PacketAround(&pack, sizeof(pack)); } } #ifdef ENABLE_NEW_PET_SYSTEM void CHARACTER::SendPetLevelUpEffect(int vid, int type, int value, int amount) { struct packet_point_change pack; pack.header = HEADER_GC_CHARACTER_POINT_CHANGE; pack.dwVID = vid; pack.type = type; pack.value = value; pack.amount = amount; PacketAround(&pack, sizeof(pack)); } #endif #ifdef ENABLE_HP_LIMIT_RENEWAL void CHARACTER::ApplyPoint(BYTE bApplyType, long long iVal) #else void CHARACTER::ApplyPoint(BYTE bApplyType, int iVal) #endif { switch (bApplyType) { case APPLY_NONE: // 0 break; case APPLY_CON: PointChange(POINT_HT, iVal); PointChange(POINT_MAX_HP, (iVal * JobInitialPoints[GetJob()].hp_per_ht)); PointChange(POINT_MAX_STAMINA, (iVal * JobInitialPoints[GetJob()].stamina_per_con)); break; case APPLY_INT: PointChange(POINT_IQ, iVal); PointChange(POINT_MAX_SP, (iVal * JobInitialPoints[GetJob()].sp_per_iq)); break; case APPLY_SKILL: // SKILL_DAMAGE_BONUS { // 00000000 00000000 00000000 00000000 // vnum ^ add change BYTE bSkillVnum = (BYTE)(((DWORD)iVal) >> 24); long long iAdd = iVal & 0x00800000; long long iChange = iVal & 0x007fffff; sys_log(1, "APPLY_SKILL skill %d add? %d change %d", bSkillVnum, iAdd ? 1 : 0, iChange); if (0 == iAdd) iChange = -iChange; boost::unordered_map::iterator iter = m_SkillDamageBonus.find(bSkillVnum); if (iter == m_SkillDamageBonus.end()) m_SkillDamageBonus.insert(std::make_pair(bSkillVnum, iChange)); else iter->second += iChange; } // END_OF_SKILL_DAMAGE_BONUS break; case APPLY_MAX_HP: case APPLY_MAX_HP_PCT: { long long i = GetMaxHP(); if (i == 0) break; PointChange(aApplyInfo[bApplyType].bPointType, iVal); float fRatio = (float)GetMaxHP() / (float)i; PointChange(POINT_HP, GetHP() * fRatio - GetHP()); } break; case APPLY_MAX_SP: case APPLY_MAX_SP_PCT: { int i = GetMaxSP(); if (i == 0) break; PointChange(aApplyInfo[bApplyType].bPointType, iVal); float fRatio = (float)GetMaxSP() / (float)i; PointChange(POINT_SP, GetSP() * fRatio - GetSP()); } break; case APPLY_STR: case APPLY_DEX: case APPLY_ATT_SPEED: case APPLY_MOV_SPEED: case APPLY_CAST_SPEED: case APPLY_HP_REGEN: case APPLY_SP_REGEN: case APPLY_POISON_PCT: #ifdef ENABLE_WOLFMAN_CHARACTER case APPLY_BLEEDING_PCT: #endif case APPLY_STUN_PCT: case APPLY_SLOW_PCT: case APPLY_CRITICAL_PCT: case APPLY_PENETRATE_PCT: case APPLY_ATTBONUS_HUMAN: case APPLY_ATTBONUS_ANIMAL: case APPLY_ATTBONUS_ORC: case APPLY_ATTBONUS_MILGYO: case APPLY_ATTBONUS_UNDEAD: case APPLY_ATTBONUS_DEVIL: case APPLY_ATTBONUS_WARRIOR: // 59 case APPLY_ATTBONUS_ASSASSIN: // 60 case APPLY_ATTBONUS_SURA: // 61 case APPLY_ATTBONUS_SHAMAN: // 62 #ifdef ENABLE_WOLFMAN_CHARACTER case APPLY_ATTBONUS_WOLFMAN: #endif case APPLY_ATTBONUS_MONSTER: // 63 case APPLY_STEAL_HP: case APPLY_STEAL_SP: case APPLY_MANA_BURN_PCT: case APPLY_DAMAGE_SP_RECOVER: case APPLY_BLOCK: case APPLY_DODGE: case APPLY_RESIST_SWORD: case APPLY_RESIST_TWOHAND: case APPLY_RESIST_DAGGER: case APPLY_RESIST_BELL: case APPLY_RESIST_FAN: case APPLY_RESIST_BOW: #ifdef ENABLE_WOLFMAN_CHARACTER case APPLY_RESIST_CLAW: #endif case APPLY_RESIST_FIRE: case APPLY_RESIST_ELEC: case APPLY_RESIST_MAGIC: case APPLY_RESIST_WIND: case APPLY_RESIST_ICE: case APPLY_RESIST_EARTH: case APPLY_RESIST_DARK: case APPLY_REFLECT_MELEE: case APPLY_REFLECT_CURSE: case APPLY_ANTI_CRITICAL_PCT: case APPLY_ANTI_PENETRATE_PCT: case APPLY_POISON_REDUCE: #ifdef ENABLE_WOLFMAN_CHARACTER case APPLY_BLEEDING_REDUCE: #endif case APPLY_KILL_SP_RECOVER: case APPLY_EXP_DOUBLE_BONUS: case APPLY_GOLD_DOUBLE_BONUS: case APPLY_ITEM_DROP_BONUS: case APPLY_POTION_BONUS: case APPLY_KILL_HP_RECOVER: case APPLY_IMMUNE_STUN: case APPLY_IMMUNE_SLOW: case APPLY_IMMUNE_FALL: case APPLY_BOW_DISTANCE: case APPLY_ATT_GRADE_BONUS: case APPLY_DEF_GRADE_BONUS: case APPLY_MAGIC_ATT_GRADE: case APPLY_MAGIC_DEF_GRADE: case APPLY_CURSE_PCT: case APPLY_MAX_STAMINA: case APPLY_MALL_ATTBONUS: case APPLY_MALL_DEFBONUS: case APPLY_MALL_EXPBONUS: case APPLY_MALL_ITEMBONUS: case APPLY_MALL_GOLDBONUS: case APPLY_SKILL_DAMAGE_BONUS: case APPLY_NORMAL_HIT_DAMAGE_BONUS: // DEPEND_BONUS_ATTRIBUTES case APPLY_SKILL_DEFEND_BONUS: case APPLY_NORMAL_HIT_DEFEND_BONUS: // END_OF_DEPEND_BONUS_ATTRIBUTES case APPLY_PC_BANG_EXP_BONUS: case APPLY_PC_BANG_DROP_BONUS: case APPLY_RESIST_WARRIOR: case APPLY_RESIST_ASSASSIN: case APPLY_RESIST_SURA: case APPLY_RESIST_SHAMAN: #ifdef ENABLE_WOLFMAN_CHARACTER case APPLY_RESIST_WOLFMAN: #endif case APPLY_ENERGY: // 82 case APPLY_DEF_GRADE: // 83 case APPLY_COSTUME_ATTR_BONUS: // 84 case APPLY_MAGIC_ATTBONUS_PER: // 85 case APPLY_MELEE_MAGIC_ATTBONUS_PER: // 86 #ifdef ENABLE_ACCE_SYSTEM case APPLY_ACCEDRAIN_RATE: //97 #endif #ifdef ENABLE_MAGIC_REDUCTION_SYSTEM case APPLY_RESIST_MAGIC_REDUCTION: //98 #endif #ifdef ENABLE_PENDANT_SYSTEM case APPLY_ENCHANT_FIRE: case APPLY_ENCHANT_ICE: case APPLY_ENCHANT_EARTH: case APPLY_ENCHANT_DARK: case APPLY_ENCHANT_WIND: case APPLY_ENCHANT_ELECT: case APPLY_MOUNT: case APPLY_RESIST_HUMAN: case APPLY_ATTBONUS_SWORD: case APPLY_ATTBONUS_TWOHAND: case APPLY_ATTBONUS_DAGGER: case APPLY_ATTBONUS_BELL: case APPLY_ATTBONUS_FAN: case APPLY_ATTBONUS_BOW: #ifdef ENABLE_WOLFMAN_CHARACTER case APPLY_ATTBONUS_CLAW: #endif case APPLY_ATTBONUS_CZ: case APPLY_ATTBONUS_DESERT: case APPLY_ATTBONUS_INSECT: #endif #ifdef ENABLE_EXTRA_APPLY_BONUS case APPLY_ATTBONUS_STONE: case APPLY_ATTBONUS_BOSS: case APPLY_ATTBONUS_ELEMENTS: case APPLY_ENCHANT_ELEMENTS: case APPLY_ATTBONUS_CHARACTERS: case APPLY_ENCHANT_CHARACTERS: case APPLY_ATTBONUS_RAZADOR: case APPLY_ATTBONUS_NEMERE: case APPLY_ATTBONUS_LUCIFER: case APPLY_ATTBONUS_BLUE_DRAGON: case APPLY_ATTBONUS_RED_DRAGON: case APPLY_ATTBONUS_AZRAEL: #endif { PointChange(aApplyInfo[bApplyType].bPointType, iVal); break; } default: sys_err("Unknown apply type %d name %s", bApplyType, GetName()); break; } } void CHARACTER::MotionPacketEncode(BYTE motion, LPCHARACTER victim, struct packet_motion* packet) { packet->header = HEADER_GC_MOTION; packet->vid = m_vid; packet->motion = motion; if (victim) packet->victim_vid = victim->GetVID(); else packet->victim_vid = 0; } void CHARACTER::Motion(BYTE motion, LPCHARACTER victim) { struct packet_motion pack_motion; MotionPacketEncode(motion, victim, &pack_motion); PacketAround(&pack_motion, sizeof(struct packet_motion)); } EVENTFUNC(save_event) { char_event_info* info = dynamic_cast(event->info); if (info == NULL) { sys_err("save_event> Null pointer"); return 0; } LPCHARACTER ch = info->ch; if (ch == NULL) { // return 0; } sys_log(1, "SAVE_EVENT: %s", ch->GetName()); ch->Save(); ch->FlushDelayedSaveItem(); return (save_event_second_cycle); } void CHARACTER::StartSaveEvent() { if (m_pkSaveEvent) return; char_event_info* info = AllocEventInfo(); info->ch = this; m_pkSaveEvent = event_create(save_event, info, save_event_second_cycle); } void CHARACTER::MonsterLog(const char* format, ...) { if (!test_server) return; if (IsPC()) return; char chatbuf[CHAT_MAX_LEN + 1]; #ifdef ENABLE_HP_LIMIT_RENEWAL long long len = snprintf(chatbuf, sizeof(chatbuf), "%u)", (DWORD)GetVID()); #else int len = snprintf(chatbuf, sizeof(chatbuf), "%u)", (DWORD)GetVID()); #endif #ifdef ENABLE_HP_LIMIT_RENEWAL if (len < 0 || len >= (long long)sizeof(chatbuf)) #else if (len < 0 || len >= (int)sizeof(chatbuf)) #endif len = sizeof(chatbuf) - 1; va_list args; va_start(args, format); #ifdef ENABLE_HP_LIMIT_RENEWAL long long len2 = vsnprintf(chatbuf + len, sizeof(chatbuf) - len, format, args); #else int len2 = vsnprintf(chatbuf + len, sizeof(chatbuf) - len, format, args); #endif #ifdef ENABLE_HP_LIMIT_RENEWAL if (len2 < 0 || len2 >= (long long)sizeof(chatbuf) - len) #else if (len2 < 0 || len2 >= (int)sizeof(chatbuf) - len) #endif len += (sizeof(chatbuf) - len) - 1; else len += len2; ++len; va_end(args); TPacketGCChat pack_chat; pack_chat.header = HEADER_GC_CHAT; pack_chat.size = sizeof(TPacketGCChat) + len; pack_chat.type = CHAT_TYPE_TALKING; pack_chat.id = (DWORD)GetVID(); pack_chat.bEmpire = 0; TEMP_BUFFER buf; buf.write(&pack_chat, sizeof(TPacketGCChat)); buf.write(chatbuf, len); CHARACTER_MANAGER::instance().PacketMonsterLog(this, buf.read_peek(), buf.size()); } void CHARACTER::ChatPacket(BYTE type, const char* format, ...) { LPDESC d = GetDesc(); if (!d || !format) return; char chatbuf[CHAT_MAX_LEN + 1]; va_list args; va_start(args, format); int len = vsnprintf(chatbuf, sizeof(chatbuf), format, args); va_end(args); struct packet_chat pack_chat; pack_chat.header = HEADER_GC_CHAT; pack_chat.size = sizeof(struct packet_chat) + len; pack_chat.type = type; pack_chat.id = 0; pack_chat.bEmpire = d->GetEmpire(); TEMP_BUFFER buf; buf.write(&pack_chat, sizeof(struct packet_chat)); buf.write(chatbuf, len); d->Packet(buf.read_peek(), buf.size()); if (type == CHAT_TYPE_COMMAND && test_server) sys_log(0, "SEND_COMMAND %s %s", GetName(), chatbuf); } // MINING void CHARACTER::mining_take() { m_pkMiningEvent = NULL; } void CHARACTER::mining_cancel() { if (m_pkMiningEvent) { sys_log(0, "XXX MINING CANCEL"); event_cancel(&m_pkMiningEvent); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("䱤À» Áß´ÜÇÏ¿´½À´Ï´Ù.")); } } void CHARACTER::mining(LPCHARACTER chLoad) { if (m_pkMiningEvent) { mining_cancel(); return; } if (!chLoad) return; // @fixme128 if (GetMapIndex() != chLoad->GetMapIndex() || DISTANCE_APPROX(GetX() - chLoad->GetX(), GetY() - chLoad->GetY()) > 1000) return; if (mining::GetRawOreFromLoad(chLoad->GetRaceNum()) == 0) return; LPITEM pick = GetWear(WEAR_WEAPON); if (!pick || pick->GetType() != ITEM_PICK) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("°î±ªÀ̸¦ ÀåÂøÇϼ¼¿ä.")); return; } #ifdef ENABLE_MINING_DISTANCE_FIX if (DISTANCE_APPROX(GetX() - chLoad->GetX(), GetY() - chLoad->GetY()) > 2500) //T#77 A special mining bot can mine from everywhere with a faked OnClick packet. { LogManager::instance().HackLog("MINING_LOCATION", this); return; } #endif int count = number(5, 15); TPacketGCDigMotion p; p.header = HEADER_GC_DIG_MOTION; p.vid = GetVID(); p.target_vid = chLoad->GetVID(); p.count = count; PacketAround(&p, sizeof(p)); m_pkMiningEvent = mining::CreateMiningEvent(this, chLoad, count); } // END_OF_MINING // @fixme219 BEGIN bool CHARACTER::IsNearWater() const { if (!GetSectree()) return false; for (int x = -1; x <= 1; ++x) { for (int y = -1; y <= 1; ++y) { if (IS_SET(GetSectree()->GetAttribute(GetX() + x * 100, GetY() + y * 100), ATTR_WATER)) return true; } } return false; } // @fixme219 END void CHARACTER::fishing() { if (m_pkFishingEvent) { fishing_take(); return; } if (!IsNearWater())// @fixme219 return; { LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(GetMapIndex()); int x = GetX(); int y = GetY(); LPSECTREE tree = pkSectreeMap->Find(x, y); DWORD dwAttr = tree->GetAttribute(x, y); if (IS_SET(dwAttr, ATTR_BLOCK)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("³¬½Ã¸¦ ÇÒ ¼ö ÀÖ´Â °÷ÀÌ ¾Æ´Õ´Ï´Ù")); return; } } LPITEM rod = GetWear(WEAR_WEAPON); if (!rod || rod->GetType() != ITEM_ROD) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("³¬½Ã´ë¸¦ ÀåÂø Çϼ¼¿ä.")); return; } if (0 == rod->GetSocket(2)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¹Ì³¢¸¦ ³¢°í ´øÁ® ÁÖ¼¼¿ä.")); return; } float fx, fy; GetDeltaByDegree(GetRotation(), 400.0f, &fx, &fy); m_pkFishingEvent = fishing::CreateFishingEvent(this); } void CHARACTER::fishing_take() { LPITEM rod = GetWear(WEAR_WEAPON); if (rod && rod->GetType() == ITEM_ROD) { using fishing::fishing_event_info; if (m_pkFishingEvent) { struct fishing_event_info* info = dynamic_cast(m_pkFishingEvent->info); if (info) fishing::Take(info, this); } } else { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("³¬½Ã´ë°¡ ¾Æ´Ñ ¹°°ÇÀ¸·Î ³¬½Ã¸¦ ÇÒ ¼ö ¾ø½À´Ï´Ù!")); } event_cancel(&m_pkFishingEvent); } bool CHARACTER::StartStateMachine(int iNextPulse) { if (CHARACTER_MANAGER::instance().AddToStateList(this)) { m_dwNextStatePulse = thecore_heart->pulse + iNextPulse; return true; } return false; } void CHARACTER::StopStateMachine() { CHARACTER_MANAGER::instance().RemoveFromStateList(this); } void CHARACTER::UpdateStateMachine(DWORD dwPulse) { if (dwPulse < m_dwNextStatePulse) return; if (IsDead()) return; Update(); m_dwNextStatePulse = dwPulse + m_dwStateDuration; } void CHARACTER::SetNextStatePulse(int iNextPulse) { CHARACTER_MANAGER::instance().AddToStateList(this); m_dwNextStatePulse = iNextPulse; if (iNextPulse < 10) MonsterLog("´ÙÀ½»óÅ·ξ°¡ÀÚ"); } void CHARACTER::UpdateCharacter(DWORD dwPulse) { CFSM::Update(); } void CHARACTER::SetShop(LPSHOP pkShop) { if ((m_pkShop = pkShop)) SET_BIT(m_pointsInstant.instant_flag, INSTANT_FLAG_SHOP); else { REMOVE_BIT(m_pointsInstant.instant_flag, INSTANT_FLAG_SHOP); SetShopOwner(NULL); } } void CHARACTER::SetExchange(CExchange * pkExchange) { m_pkExchange = pkExchange; } void CHARACTER::SetPart(BYTE bPartPos, WORD wVal) { assert(bPartPos < PART_MAX_NUM); m_pointsInstant.parts[bPartPos] = wVal; } WORD CHARACTER::GetPart(BYTE bPartPos) const { assert(bPartPos < PART_MAX_NUM); #ifdef ENABLE_HIDE_COSTUME_SYSTEM if (bPartPos == PART_MAIN && GetWear(WEAR_COSTUME_BODY) && IsBodyCostumeHidden() == true) { if (const LPITEM pArmor = GetWear(WEAR_BODY)) #ifdef __CHANGE_LOOK_SYSTEM__ return pArmor->GetTransmutation() != 0 ? pArmor->GetTransmutation() : pArmor->GetVnum(); #else return pArmor->GetVnum(); #endif else return 0; } else if (bPartPos == PART_HAIR && GetWear(WEAR_COSTUME_HAIR) && IsHairCostumeHidden() == true) return 0; else if (bPartPos == PART_ACCE && GetWear(WEAR_COSTUME_ACCE) && IsAcceCostumeHidden() == true) return 0; else if (bPartPos == PART_WEAPON && GetWear(WEAR_COSTUME_WEAPON) && IsWeaponCostumeHidden() == true) { if (const LPITEM pWeapon = GetWear(WEAR_WEAPON)) #ifdef __CHANGE_LOOK_SYSTEM__ return pWeapon->GetTransmutation() != 0 ? pWeapon->GetTransmutation() : pWeapon->GetVnum(); #else return pWeapon->GetVnum(); #endif else return 0; } #endif #ifdef ENABLE_WINGS_NEW if (bPartPos == PART_WING) { const LPITEM pWing = GetWear(WEAR_COSTUME_WING); if (pWing) return pWing->GetVnum(); } #endif return m_pointsInstant.parts[bPartPos]; } WORD CHARACTER::GetOriginalPart(BYTE bPartPos) const { switch (bPartPos) { case PART_MAIN: #ifdef ENABLE_HIDE_COSTUME_SYSTEM if (GetWear(WEAR_COSTUME_BODY) && IsBodyCostumeHidden() == true) if (const LPITEM pArmor = GetWear(WEAR_BODY)) return pArmor->GetVnum(); #endif if (!IsPC()) return GetPart(PART_MAIN); else return m_pointsInstant.bBasePart; case PART_HAIR: #ifdef ENABLE_HIDE_COSTUME_SYSTEM if (GetWear(WEAR_COSTUME_HAIR) && IsHairCostumeHidden() == true) return 0; #endif return GetPart(PART_HAIR); #ifdef ENABLE_ACCE_SYSTEM case PART_ACCE: #ifdef ENABLE_HIDE_COSTUME_SYSTEM if (GetWear(WEAR_COSTUME_ACCE) && IsAcceCostumeHidden() == true) return 0; #endif return GetPart(PART_ACCE); #endif #ifdef ENABLE_AURA_SYSTEM case PART_AURA: return GetPart(PART_AURA); #endif #ifdef ENABLE_WINGS_NEW case PART_WING: return GetPart(PART_WING); #endif #ifdef ENABLE_WEAPON_COSTUME_SYSTEM case PART_WEAPON: #ifdef ENABLE_HIDE_COSTUME_SYSTEM if (GetWear(WEAR_COSTUME_WEAPON) && IsWeaponCostumeHidden() == true) if (const LPITEM pWeapon = GetWear(WEAR_WEAPON)) return pWeapon->GetVnum(); #endif return GetPart(PART_WEAPON); #endif default: return 0; } } BYTE CHARACTER::GetCharType() const { return m_bCharType; } bool CHARACTER::SetSyncOwner(LPCHARACTER ch, bool bRemoveFromList) { // TRENT_MONSTER if (IS_SET(m_pointsInstant.dwAIFlag, AIFLAG_NOMOVE)) return false; // END_OF_TRENT_MONSTER if (ch) // @fixme131 { if (!battle_is_attackable(ch, this)) { SendDamagePacket(ch, 0, DAMAGE_BLOCK); return false; } } if (ch == this) { sys_err("SetSyncOwner owner == this (%p)", this); return false; } if (!ch) { if (bRemoveFromList && m_pkChrSyncOwner) { m_pkChrSyncOwner->m_kLst_pkChrSyncOwned.remove(this); } if (m_pkChrSyncOwner) sys_log(1, "SyncRelease %s %p from %s", GetName(), this, m_pkChrSyncOwner->GetName()); m_pkChrSyncOwner = NULL; } else { if (!IsSyncOwner(ch)) return false; if (DISTANCE_APPROX(GetX() - ch->GetX(), GetY() - ch->GetY()) > 250) { sys_log(1, "SetSyncOwner distance over than 250 %s %s", GetName(), ch->GetName()); if (m_pkChrSyncOwner == ch) return true; return false; } if (m_pkChrSyncOwner != ch) { if (m_pkChrSyncOwner) { sys_log(1, "SyncRelease %s %p from %s", GetName(), this, m_pkChrSyncOwner->GetName()); m_pkChrSyncOwner->m_kLst_pkChrSyncOwned.remove(this); } m_pkChrSyncOwner = ch; m_pkChrSyncOwner->m_kLst_pkChrSyncOwned.push_back(this); static const timeval zero_tv = { 0, 0 }; SetLastSyncTime(zero_tv); sys_log(1, "SetSyncOwner set %s %p to %s", GetName(), this, ch->GetName()); } m_fSyncTime = get_float_time(); } TPacketGCOwnership pack; pack.bHeader = HEADER_GC_OWNERSHIP; pack.dwOwnerVID = ch ? ch->GetVID() : 0; pack.dwVictimVID = GetVID(); PacketAround(&pack, sizeof(TPacketGCOwnership)); return true; } struct FuncClearSync { void operator () (LPCHARACTER ch) { assert(ch != NULL); ch->SetSyncOwner(NULL, false); } }; void CHARACTER::ClearSync() { SetSyncOwner(NULL); std::for_each(m_kLst_pkChrSyncOwned.begin(), m_kLst_pkChrSyncOwned.end(), FuncClearSync()); m_kLst_pkChrSyncOwned.clear(); } bool CHARACTER::IsSyncOwner(LPCHARACTER ch) const { if (m_pkChrSyncOwner == ch) return true; if (get_float_time() - m_fSyncTime >= 3.0f) return true; return false; } void CHARACTER::SetParty(LPPARTY pkParty) { if (pkParty == m_pkParty) return; if (pkParty && m_pkParty) sys_err("%s is trying to reassigning party (current %p, new party %p)", GetName(), get_pointer(m_pkParty), get_pointer(pkParty)); sys_log(1, "PARTY set to %p", get_pointer(pkParty)); //if (m_pkDungeon && IsPC()) //SetDungeon(NULL); m_pkParty = pkParty; if (IsPC()) { if (m_pkParty) SET_BIT(m_bAddChrState, ADD_CHARACTER_STATE_PARTY); else REMOVE_BIT(m_bAddChrState, ADD_CHARACTER_STATE_PARTY); UpdatePacket(); } } // PARTY_JOIN_BUG_FIX EVENTINFO(TPartyJoinEventInfo) { DWORD dwGuestPID; DWORD dwLeaderPID; TPartyJoinEventInfo() : dwGuestPID(0) , dwLeaderPID(0) { } }; EVENTFUNC(party_request_event) { TPartyJoinEventInfo* info = dynamic_cast(event->info); if (info == NULL) { sys_err("party_request_event> Null pointer"); return 0; } LPCHARACTER ch = CHARACTER_MANAGER::instance().FindByPID(info->dwGuestPID); if (ch) { sys_log(0, "PartyRequestEvent %s", ch->GetName()); ch->ChatPacket(CHAT_TYPE_COMMAND, "PartyRequestDenied"); ch->SetPartyRequestEvent(NULL); } return 0; } bool CHARACTER::RequestToParty(LPCHARACTER leader) { if (leader->GetParty()) leader = leader->GetParty()->GetLeaderCharacter(); if (!leader) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ÆÄƼÀåÀÌ Á¢¼Ó »óÅ°¡ ¾Æ´Ï¶ó¼­ ¿äûÀ» ÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; } if (m_pkPartyRequestEvent) return false; if (!IsPC() || !leader->IsPC()) return false; if (leader->IsBlockMode(BLOCK_PARTY_REQUEST)) return false; PartyJoinErrCode errcode = IsPartyJoinableCondition(leader, this); switch (errcode) { case PERR_NONE: break; case PERR_SERVER: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ¼­¹ö ¹®Á¦·Î ÆÄƼ °ü·Ã 󸮸¦ ÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; case PERR_DIFFEMPIRE: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ´Ù¸¥ Á¦±¹°ú ÆÄƼ¸¦ ÀÌ·ê ¼ö ¾ø½À´Ï´Ù.")); return false; case PERR_DUNGEON: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ´øÀü ¾È¿¡¼­´Â ÆÄƼ Ãʴ븦 ÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; case PERR_OBSERVER: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> °üÀü ¸ğµå¿¡¼± ÆÄƼ Ãʴ븦 ÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; case PERR_LVBOUNDARY: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> -30 ~ +30 ·¹º§ À̳»ÀÇ »ó´ë¹æ¸¸ ÃÊ´ëÇÒ ¼ö ÀÖ½À´Ï´Ù.")); return false; case PERR_LOWLEVEL: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼ³» ÃÖ°í ·¹º§ º¸´Ù 30·¹º§ÀÌ ³·¾Æ ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; case PERR_HILEVEL: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼ³» ÃÖÀú ·¹º§ º¸´Ù 30·¹º§ÀÌ ³ô¾Æ ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; case PERR_ALREADYJOIN: return false; case PERR_PARTYISFULL: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ´õ ÀÌ»ó ÆÄƼ¿øÀ» ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; default: sys_err("Do not process party join error(%d)", errcode); return false; } TPartyJoinEventInfo* info = AllocEventInfo(); info->dwGuestPID = GetPlayerID(); info->dwLeaderPID = leader->GetPlayerID(); SetPartyRequestEvent(event_create(party_request_event, info, PASSES_PER_SEC(10))); leader->ChatPacket(CHAT_TYPE_COMMAND, "PartyRequest %u", (DWORD)GetVID()); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s ´Ô¿¡°Ô ÆÄƼ°¡ÀÔ ½ÅûÀ» Çß½À´Ï´Ù."), leader->GetName()); return true; } void CHARACTER::DenyToParty(LPCHARACTER member) { sys_log(1, "DenyToParty %s member %s %p", GetName(), member->GetName(), get_pointer(member->m_pkPartyRequestEvent)); if (!member->m_pkPartyRequestEvent) return; TPartyJoinEventInfo* info = dynamic_cast(member->m_pkPartyRequestEvent->info); if (!info) { sys_err("CHARACTER::DenyToParty> Null pointer"); return; } if (info->dwGuestPID != member->GetPlayerID()) return; if (info->dwLeaderPID != GetPlayerID()) return; event_cancel(&member->m_pkPartyRequestEvent); member->ChatPacket(CHAT_TYPE_COMMAND, "PartyRequestDenied"); } void CHARACTER::AcceptToParty(LPCHARACTER member) { sys_log(1, "AcceptToParty %s member %s %p", GetName(), member->GetName(), get_pointer(member->m_pkPartyRequestEvent)); if (!member->m_pkPartyRequestEvent) return; TPartyJoinEventInfo* info = dynamic_cast(member->m_pkPartyRequestEvent->info); if (!info) { sys_err("CHARACTER::AcceptToParty> Null pointer"); return; } if (info->dwGuestPID != member->GetPlayerID()) return; if (info->dwLeaderPID != GetPlayerID()) return; event_cancel(&member->m_pkPartyRequestEvent); if (!GetParty()) member->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»ó´ë¹æÀÌ ÆÄƼ¿¡ ¼ÓÇØÀÖÁö ¾Ê½À´Ï´Ù.")); else { if (GetPlayerID() != GetParty()->GetLeaderPID()) return; PartyJoinErrCode errcode = IsPartyJoinableCondition(this, member); switch (errcode) { case PERR_NONE: member->PartyJoin(this); return; case PERR_SERVER: member->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ¼­¹ö ¹®Á¦·Î ÆÄƼ °ü·Ã 󸮸¦ ÇÒ ¼ö ¾ø½À´Ï´Ù.")); break; case PERR_DUNGEON: member->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ´øÀü ¾È¿¡¼­´Â ÆÄƼ Ãʴ븦 ÇÒ ¼ö ¾ø½À´Ï´Ù.")); break; case PERR_OBSERVER: member->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> °üÀü ¸ğµå¿¡¼± ÆÄƼ Ãʴ븦 ÇÒ ¼ö ¾ø½À´Ï´Ù.")); break; case PERR_LVBOUNDARY: member->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> -30 ~ +30 ·¹º§ À̳»ÀÇ »ó´ë¹æ¸¸ ÃÊ´ëÇÒ ¼ö ÀÖ½À´Ï´Ù.")); break; case PERR_LOWLEVEL: member->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼ³» ÃÖ°í ·¹º§ º¸´Ù 30·¹º§ÀÌ ³·¾Æ ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); break; case PERR_HILEVEL: member->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼ³» ÃÖÀú ·¹º§ º¸´Ù 30·¹º§ÀÌ ³ô¾Æ ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); break; case PERR_ALREADYJOIN: break; case PERR_PARTYISFULL: { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ´õ ÀÌ»ó ÆÄƼ¿øÀ» ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); member->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼÀÇ ÀοøÁ¦ÇÑÀÌ ÃÊ°úÇÏ¿© ÆÄƼ¿¡ Âü°¡ÇÒ ¼ö ¾ø½À´Ï´Ù.")); break; } default: sys_err("Do not process party join error(%d)", errcode); } } member->ChatPacket(CHAT_TYPE_COMMAND, "PartyRequestDenied"); } EVENTFUNC(party_invite_event) { TPartyJoinEventInfo* pInfo = dynamic_cast(event->info); if (pInfo == NULL) { sys_err("party_invite_event> Null pointer"); return 0; } LPCHARACTER pchInviter = CHARACTER_MANAGER::instance().FindByPID(pInfo->dwLeaderPID); if (pchInviter) { sys_log(1, "PartyInviteEvent %s", pchInviter->GetName()); pchInviter->PartyInviteDeny(pInfo->dwGuestPID); } return 0; } void CHARACTER::PartyInvite(LPCHARACTER pchInvitee) { if (GetParty() && GetParty()->GetLeaderPID() != GetPlayerID()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼ¿øÀ» ÃÊ´ëÇÒ ¼ö ÀÖ´Â ±ÇÇÑÀÌ ¾ø½À´Ï´Ù.")); return; } else if (pchInvitee->IsBlockMode(BLOCK_PARTY_INVITE)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> %s ´ÔÀÌ ÆÄƼ °ÅºÎ »óÅÂÀÔ´Ï´Ù."), pchInvitee->GetName()); return; } PartyJoinErrCode errcode = IsPartyJoinableCondition(this, pchInvitee); switch (errcode) { case PERR_NONE: break; case PERR_SERVER: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ¼­¹ö ¹®Á¦·Î ÆÄƼ °ü·Ã 󸮸¦ ÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; case PERR_DIFFEMPIRE: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ´Ù¸¥ Á¦±¹°ú ÆÄƼ¸¦ ÀÌ·ê ¼ö ¾ø½À´Ï´Ù.")); return; case PERR_DUNGEON: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ´øÀü ¾È¿¡¼­´Â ÆÄƼ Ãʴ븦 ÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; case PERR_OBSERVER: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> °üÀü ¸ğµå¿¡¼± ÆÄƼ Ãʴ븦 ÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; case PERR_LVBOUNDARY: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> -30 ~ +30 ·¹º§ À̳»ÀÇ »ó´ë¹æ¸¸ ÃÊ´ëÇÒ ¼ö ÀÖ½À´Ï´Ù.")); return; case PERR_LOWLEVEL: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼ³» ÃÖ°í ·¹º§ º¸´Ù 30·¹º§ÀÌ ³·¾Æ ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; case PERR_HILEVEL: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼ³» ÃÖÀú ·¹º§ º¸´Ù 30·¹º§ÀÌ ³ô¾Æ ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; case PERR_ALREADYJOIN: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÀÌ¹Ì %s´ÔÀº ÆÄƼ¿¡ ¼ÓÇØ ÀÖ½À´Ï´Ù."), pchInvitee->GetName()); return; case PERR_PARTYISFULL: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ´õ ÀÌ»ó ÆÄƼ¿øÀ» ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; default: sys_err("Do not process party join error(%d)", errcode); return; } if (m_PartyInviteEventMap.end() != m_PartyInviteEventMap.find(pchInvitee->GetPlayerID())) return; TPartyJoinEventInfo* info = AllocEventInfo(); info->dwGuestPID = pchInvitee->GetPlayerID(); info->dwLeaderPID = GetPlayerID(); m_PartyInviteEventMap.insert(EventMap::value_type(pchInvitee->GetPlayerID(), event_create(party_invite_event, info, PASSES_PER_SEC(10)))); TPacketGCPartyInvite p; p.header = HEADER_GC_PARTY_INVITE; p.leader_vid = GetVID(); pchInvitee->GetDesc()->Packet(&p, sizeof(p)); } void CHARACTER::PartyInviteAccept(LPCHARACTER pchInvitee) { EventMap::iterator itFind = m_PartyInviteEventMap.find(pchInvitee->GetPlayerID()); if (itFind == m_PartyInviteEventMap.end()) { sys_log(1, "PartyInviteAccept from not invited character(%s)", pchInvitee->GetName()); return; } event_cancel(&itFind->second); m_PartyInviteEventMap.erase(itFind); if (GetParty() && GetParty()->GetLeaderPID() != GetPlayerID()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼ¿øÀ» ÃÊ´ëÇÒ ¼ö ÀÖ´Â ±ÇÇÑÀÌ ¾ø½À´Ï´Ù.")); return; } PartyJoinErrCode errcode = IsPartyJoinableMutableCondition(this, pchInvitee); switch (errcode) { case PERR_NONE: break; case PERR_SERVER: pchInvitee->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ¼­¹ö ¹®Á¦·Î ÆÄƼ °ü·Ã 󸮸¦ ÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; case PERR_DUNGEON: pchInvitee->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ´øÀü ¾È¿¡¼­´Â ÆÄƼ ÃÊ´ë¿¡ ÀÀÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; case PERR_OBSERVER: pchInvitee->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> °üÀü ¸ğµå¿¡¼± ÆÄƼ Ãʴ븦 ÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; case PERR_LVBOUNDARY: pchInvitee->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> -30 ~ +30 ·¹º§ À̳»ÀÇ »ó´ë¹æ¸¸ ÃÊ´ëÇÒ ¼ö ÀÖ½À´Ï´Ù.")); return; case PERR_LOWLEVEL: pchInvitee->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼ³» ÃÖ°í ·¹º§ º¸´Ù 30·¹º§ÀÌ ³·¾Æ ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; case PERR_HILEVEL: pchInvitee->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼ³» ÃÖÀú ·¹º§ º¸´Ù 30·¹º§ÀÌ ³ô¾Æ ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; case PERR_ALREADYJOIN: pchInvitee->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼ ÃÊ´ë¿¡ ÀÀÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; case PERR_PARTYISFULL: ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ´õ ÀÌ»ó ÆÄƼ¿øÀ» ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.")); pchInvitee->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> ÆÄƼÀÇ ÀοøÁ¦ÇÑÀÌ ÃÊ°úÇÏ¿© ÆÄƼ¿¡ Âü°¡ÇÒ ¼ö ¾ø½À´Ï´Ù.")); return; default: sys_err("ignore party join error(%d)", errcode); return; } if (GetParty()) pchInvitee->PartyJoin(this); else { LPPARTY pParty = CPartyManager::instance().CreateParty(this); pParty->Join(pchInvitee->GetPlayerID()); pParty->Link(pchInvitee); pParty->SendPartyInfoAllToOne(this); } } void CHARACTER::PartyInviteDeny(DWORD dwPID) { EventMap::iterator itFind = m_PartyInviteEventMap.find(dwPID); if (itFind == m_PartyInviteEventMap.end()) { sys_log(1, "PartyInviteDeny to not exist event(inviter PID: %d, invitee PID: %d)", GetPlayerID(), dwPID); return; } event_cancel(&itFind->second); m_PartyInviteEventMap.erase(itFind); LPCHARACTER pchInvitee = CHARACTER_MANAGER::instance().FindByPID(dwPID); if (pchInvitee) ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> %s´ÔÀÌ ÆÄƼ Ãʴ븦 °ÅÀıÇϼ̽À´Ï´Ù."), pchInvitee->GetName()); } void CHARACTER::PartyJoin(LPCHARACTER pLeader) { pLeader->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> %s´ÔÀÌ ÆÄƼ¿¡ Âü°¡Çϼ̽À´Ï´Ù."), GetName()); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<ÆÄƼ> %s´ÔÀÇ ÆÄƼ¿¡ Âü°¡Çϼ̽À´Ï´Ù."), pLeader->GetName()); pLeader->GetParty()->Join(GetPlayerID()); pLeader->GetParty()->Link(this); } CHARACTER::PartyJoinErrCode CHARACTER::IsPartyJoinableCondition(const LPCHARACTER pchLeader, const LPCHARACTER pchGuest) { if (pchLeader->GetEmpire() != pchGuest->GetEmpire()) return PERR_DIFFEMPIRE; return IsPartyJoinableMutableCondition(pchLeader, pchGuest); } static bool __party_can_join_by_level(LPCHARACTER leader, LPCHARACTER quest) { int level_limit = 30; return (abs(leader->GetLevel() - quest->GetLevel()) <= level_limit); } CHARACTER::PartyJoinErrCode CHARACTER::IsPartyJoinableMutableCondition(const LPCHARACTER pchLeader, const LPCHARACTER pchGuest) { if (!CPartyManager::instance().IsEnablePCParty()) return PERR_SERVER; else if (pchLeader->GetDungeon()) return PERR_DUNGEON; else if (pchGuest->IsObserverMode()) return PERR_OBSERVER; else if (false == __party_can_join_by_level(pchLeader, pchGuest)) return PERR_LVBOUNDARY; else if (pchGuest->GetParty()) return PERR_ALREADYJOIN; else if (pchLeader->GetParty()) { if (pchLeader->GetParty()->GetMemberCount() == PARTY_MAX_MEMBER) return PERR_PARTYISFULL; } return PERR_NONE; } // END_OF_PARTY_JOIN_BUG_FIX void CHARACTER::SetDungeon(LPDUNGEON pkDungeon) { if (pkDungeon && m_pkDungeon) sys_err("%s is trying to reassigning dungeon (current %p, new party %p)", GetName(), get_pointer(m_pkDungeon), get_pointer(pkDungeon)); if (m_pkDungeon == pkDungeon) { return; } if (m_pkDungeon) { if (IsPC()) { if (GetParty()) m_pkDungeon->DecPartyMember(GetParty(), this); else m_pkDungeon->DecMember(this); } else if (IsMonster() || IsStone()) { m_pkDungeon->DecMonster(); } } m_pkDungeon = pkDungeon; if (pkDungeon) { sys_log(0, "%s DUNGEON set to %p, PARTY is %p", GetName(), get_pointer(pkDungeon), get_pointer(m_pkParty)); if (IsPC()) { if (GetParty()) m_pkDungeon->IncPartyMember(GetParty(), this); else m_pkDungeon->IncMember(this); } else if (IsMonster() || IsStone()) { m_pkDungeon->IncMonster(); } } } void CHARACTER::SetWarMap(CWarMap * pWarMap) { if (m_pWarMap) m_pWarMap->DecMember(this); m_pWarMap = pWarMap; if (m_pWarMap) m_pWarMap->IncMember(this); } void CHARACTER::SetWeddingMap(marriage::WeddingMap * pMap) { if (m_pWeddingMap) m_pWeddingMap->DecMember(this); m_pWeddingMap = pMap; if (m_pWeddingMap) m_pWeddingMap->IncMember(this); } void CHARACTER::SetRegen(LPREGEN pkRegen) { m_pkRegen = pkRegen; if (pkRegen != NULL) { regen_id_ = pkRegen->id; } m_fRegenAngle = GetRotation(); m_posRegen = GetXYZ(); } bool CHARACTER::OnIdle() { return false; } void CHARACTER::OnMove(bool bIsAttack) { m_dwLastMoveTime = get_dword_time(); if (bIsAttack) { m_dwLastAttackTime = m_dwLastMoveTime; if (IsAffectFlag(AFFECT_REVIVE_INVISIBLE) || IsAffectFlag(AFF_REVIVE_INVISIBLE))// @fixme195 RemoveAffect(AFFECT_REVIVE_INVISIBLE); if (IsAffectFlag(AFF_EUNHYUNG)) { RemoveAffect(SKILL_EUNHYUNG); SetAffectedEunhyung(); } else { ClearAffectedEunhyung(); } // @fixme229 START SECTREE* sectree = GetSectree(); if (sectree && sectree->IsAttr(GetX(), GetY(), ATTR_BANPK) && IsMonster()) Return(); // @fixme229 END /*if (IsAffectFlag(AFF_JEONSIN)) RemoveAffect(SKILL_JEONSINBANGEO);*/ } /*if (IsAffectFlag(AFF_GUNGON)) RemoveAffect(SKILL_GUNGON);*/ // MINING mining_cancel(); // END_OF_MINING } void CHARACTER::OnClick(LPCHARACTER pkChrCauser) { if (!pkChrCauser) { sys_err("OnClick %s by NULL", GetName()); return; } DWORD vid = GetVID(); sys_log(0, "OnClick %s[vnum %d ServerUniqueID %d, pid %d] by %s", GetName(), GetRaceNum(), vid, GetPlayerID(), pkChrCauser->GetName()); { if (pkChrCauser->GetMyShop() && pkChrCauser != this) { sys_err("OnClick Fail (%s->%s) - pc has shop", pkChrCauser->GetName(), GetName()); return; } } { if (pkChrCauser->GetExchange()) { sys_err("OnClick Fail (%s->%s) - pc is exchanging", pkChrCauser->GetName(), GetName()); return; } } if (IsPC()) { if (!CTargetManager::instance().GetTargetInfo(pkChrCauser->GetPlayerID(), TARGET_TYPE_VID, GetVID())) { if (GetMyShop()) { if (pkChrCauser->IsDead() == true) return; //PREVENT_TRADE_WINDOW if (pkChrCauser == this) { if (pkChrCauser->HaveAnotherPagesOpen()) { pkChrCauser->ChatPacket(CHAT_TYPE_INFO, "Diger pencereleri kapatmadan bunu yapamazsin."); return; } } else { if (pkChrCauser->HaveAnotherPagesOpen()) { pkChrCauser->ChatPacket(CHAT_TYPE_INFO, "Diger pencereleri kapatmadan bunu yapamazsin."); return; } } //END_PREVENT_TRADE_WINDOW if (pkChrCauser->GetShop()) { pkChrCauser->GetShop()->RemoveGuest(pkChrCauser); pkChrCauser->SetShop(NULL); } GetMyShop()->AddGuest(pkChrCauser, GetVID(), false); pkChrCauser->SetShopOwner(this); return; } if (test_server) sys_err("%s.OnClickFailure(%s) - target is PC", pkChrCauser->GetName(), GetName()); return; } } if (g_bChinaIntoxicationCheck) { if (pkChrCauser->IsOverTime(OT_3HOUR)) { sys_log(0, "Teen OverTime : name = %s, hour = %d)", pkChrCauser->GetName(), 3); return; } else if (pkChrCauser->IsOverTime(OT_5HOUR)) { sys_log(0, "Teen OverTime : name = %s, hour = %d)", pkChrCauser->GetName(), 5); return; } } pkChrCauser->SetQuestNPCID(GetVID()); if (quest::CQuestManager::instance().Click(pkChrCauser->GetPlayerID(), this #ifdef MODERATED_NPC , (IsModeratedNPC() ? GetQuestNPCVnum() : 0) #endif )) { return; } if (!IsPC()) { if (!m_triggerOnClick.pFunc) { //sys_err("%s.OnClickFailure(%s) : triggerOnClick.pFunc is EMPTY(pid=%d)", // pkChrCauser->GetName(), // GetName(), // pkChrCauser->GetPlayerID()); return; } m_triggerOnClick.pFunc(this, pkChrCauser); } } BYTE CHARACTER::GetGMLevel() const { if (test_server) return GM_IMPLEMENTOR; return m_pointsInstant.gm_level; } void CHARACTER::SetGMLevel() { if (GetDesc()) { m_pointsInstant.gm_level = gm_get_level(GetName(), GetDesc()->GetHostName(), GetDesc()->GetAccountTable().login); } else { m_pointsInstant.gm_level = GM_PLAYER; } } BOOL CHARACTER::IsGM() const { if (m_pointsInstant.gm_level != GM_PLAYER) return true; if (test_server) return true; return false; } void CHARACTER::SetStone(LPCHARACTER pkChrStone) { m_pkChrStone = pkChrStone; if (m_pkChrStone) { if (pkChrStone->m_set_pkChrSpawnedBy.find(this) == pkChrStone->m_set_pkChrSpawnedBy.end()) pkChrStone->m_set_pkChrSpawnedBy.insert(this); } } struct FuncDeadSpawnedByStone { void operator () (LPCHARACTER ch) { ch->Dead(NULL); ch->SetStone(NULL); } }; void CHARACTER::ClearStone() { if (!m_set_pkChrSpawnedBy.empty()) { FuncDeadSpawnedByStone f; std::for_each(m_set_pkChrSpawnedBy.begin(), m_set_pkChrSpawnedBy.end(), f); m_set_pkChrSpawnedBy.clear(); } if (!m_pkChrStone) return; m_pkChrStone->m_set_pkChrSpawnedBy.erase(this); m_pkChrStone = NULL; } void CHARACTER::ClearTarget() { if (m_pkChrTarget) { m_pkChrTarget->m_set_pkChrTargetedBy.erase(this); m_pkChrTarget = NULL; } TPacketGCTarget p; p.header = HEADER_GC_TARGET; p.dwVID = 0; p.bHPPercent = 0; #ifdef WJ_TARGET_HP_SYSTEM p.dwActualHP = 0; p.dwMaxHP = 0; #endif CHARACTER_SET::iterator it = m_set_pkChrTargetedBy.begin(); while (it != m_set_pkChrTargetedBy.end()) { LPCHARACTER pkChr = *(it++); if (!pkChr) return; //fixme600 pkChr->m_pkChrTarget = NULL; if (!pkChr->GetDesc()) { sys_err("%s %p does not have desc", pkChr->GetName(), get_pointer(pkChr)); abort(); } pkChr->GetDesc()->Packet(&p, sizeof(TPacketGCTarget)); } m_set_pkChrTargetedBy.clear(); } void CHARACTER::SetTarget(LPCHARACTER pkChrTarget) { #ifdef WJ_TARGET_HP_SYSTEM if (m_pkChrTarget == pkChrTarget) return; // CASTLE if (IS_CASTLE_MAP(GetMapIndex()) && !IsGM()) return; // CASTLE if (m_pkChrTarget) m_pkChrTarget->m_set_pkChrTargetedBy.erase(this); m_pkChrTarget = pkChrTarget; TPacketGCTarget p; p.header = HEADER_GC_TARGET; if (m_pkChrTarget) { m_pkChrTarget->m_set_pkChrTargetedBy.insert(this); p.dwVID = m_pkChrTarget->GetVID(); p.bHPPercent = 0; #ifdef WJ_TARGET_HP_SYSTEM p.dwActualHP = 0; p.dwMaxHP = 0; #endif if (m_pkChrTarget->GetMaxHP() <= 0) { p.bHPPercent = 0; #ifdef WJ_TARGET_HP_SYSTEM p.dwActualHP = 0; p.dwMaxHP = 0; #endif } else { if (m_pkChrTarget->GetRaceNum() == 20101 || m_pkChrTarget->GetRaceNum() == 20102 || m_pkChrTarget->GetRaceNum() == 20103 || m_pkChrTarget->GetRaceNum() == 20104 || m_pkChrTarget->GetRaceNum() == 20105 || m_pkChrTarget->GetRaceNum() == 20106 || m_pkChrTarget->GetRaceNum() == 20107 || m_pkChrTarget->GetRaceNum() == 20108 || m_pkChrTarget->GetRaceNum() == 20109) { LPCHARACTER owner = m_pkChrTarget->GetVictim(); if (owner) { int iHorseHealth = owner->GetHorseHealth(); int iHorseMaxHealth = owner->GetHorseMaxHealth(); if (iHorseMaxHealth) { p.bHPPercent = MINMAX(0, iHorseHealth * 100 / iHorseMaxHealth, 100); #ifdef WJ_TARGET_HP_SYSTEM p.dwActualHP = 100; p.dwMaxHP = 100; #endif } else { p.bHPPercent = 100; #ifdef WJ_TARGET_HP_SYSTEM p.dwActualHP = 100; p.dwMaxHP = 100; #endif } } else { p.bHPPercent = 100; #ifdef WJ_TARGET_HP_SYSTEM p.dwActualHP = 100; p.dwMaxHP = 100; #endif } } else { p.bHPPercent = m_pkChrTarget->GetMaxHP() <= 0 ? 0 : int64_t(float(m_pkChrTarget->GetHP()) / float(m_pkChrTarget->GetMaxHP()) * 100.0f); #ifdef WJ_TARGET_HP_SYSTEM p.dwActualHP = m_pkChrTarget->GetHP(); p.dwMaxHP = m_pkChrTarget->GetMaxHP(); #endif } } } else { p.dwVID = 0; p.bHPPercent = 0; #ifdef WJ_TARGET_HP_SYSTEM p.dwActualHP = 0; p.dwMaxHP = 0; #endif } #else if (m_pkChrTarget == pkChrTarget) return; // CASTLE if (IS_CASTLE_MAP(GetMapIndex()) && !IsGM()) return; // CASTLE if (m_pkChrTarget) m_pkChrTarget->m_set_pkChrTargetedBy.erase(this); m_pkChrTarget = pkChrTarget; TPacketGCTarget p; p.header = HEADER_GC_TARGET; if (m_pkChrTarget) { m_pkChrTarget->m_set_pkChrTargetedBy.insert(this); p.dwVID = m_pkChrTarget->GetVID(); if ((m_pkChrTarget->IsPC() && !m_pkChrTarget->IsPolymorphed()) || (m_pkChrTarget->GetMaxHP() <= 0)) p.bHPPercent = 0; else { if (m_pkChrTarget->GetRaceNum() == 20101 || m_pkChrTarget->GetRaceNum() == 20102 || m_pkChrTarget->GetRaceNum() == 20103 || m_pkChrTarget->GetRaceNum() == 20104 || m_pkChrTarget->GetRaceNum() == 20105 || m_pkChrTarget->GetRaceNum() == 20106 || m_pkChrTarget->GetRaceNum() == 20107 || m_pkChrTarget->GetRaceNum() == 20108 || m_pkChrTarget->GetRaceNum() == 20109) { LPCHARACTER owner = m_pkChrTarget->GetVictim(); if (owner) { int iHorseHealth = owner->GetHorseHealth(); int iHorseMaxHealth = owner->GetHorseMaxHealth(); if (iHorseMaxHealth) p.bHPPercent = MINMAX(0, iHorseHealth * 100 / iHorseMaxHealth, 100); else p.bHPPercent = 100; } else p.bHPPercent = 100; } else { if (m_pkChrTarget->GetMaxHP() <= 0) // @fixme136 p.bHPPercent = 0; else p.bHPPercent = MINMAX(0, (m_pkChrTarget->GetHP() * 100) / m_pkChrTarget->GetMaxHP(), 100); } } } else { p.dwVID = 0; p.bHPPercent = 0; } #endif #ifdef ENABLE_PENDANT_SYSTEM const int ELEMENT_BASE = 11; DWORD curElementBase = ELEMENT_BASE; DWORD raceFlag; if (m_pkChrTarget && m_pkChrTarget->IsMonster() && (raceFlag = m_pkChrTarget->GetMobTable().dwRaceFlag) >= RACE_FLAG_ATT_ELEC) { for (int i = RACE_FLAG_ATT_ELEC; i <= RACE_FLAG_ATT_DARK; i *= 2) { curElementBase++; int diff = raceFlag - i; if (abs(diff) <= 1024) break; } p.bElement = curElementBase - ELEMENT_BASE; } else { p.bElement = 0; } #endif GetDesc()->Packet(&p, sizeof(TPacketGCTarget)); } void CHARACTER::BroadcastTargetPacket() { if (m_set_pkChrTargetedBy.empty()) return; TPacketGCTarget p; p.header = HEADER_GC_TARGET; p.dwVID = GetVID(); #ifdef WJ_TARGET_HP_SYSTEM p.dwActualHP = 0; p.dwMaxHP = 0; if (GetMaxHP() <= 0) { p.bHPPercent = 0; p.dwActualHP = 0; p.dwMaxHP = 0; } else { p.bHPPercent = int64_t(float(GetHP()) / float(GetMaxHP()) * 100.0f); p.dwActualHP = GetHP(); p.dwMaxHP = GetMaxHP(); } #else if (IsPC()) p.bHPPercent = 0; else if (GetMaxHP() <= 0) // @fixme136 p.bHPPercent = 0; else p.bHPPercent = MINMAX(0, (GetHP() * 100) / GetMaxHP(), 100); #endif CHARACTER_SET::iterator it = m_set_pkChrTargetedBy.begin(); while (it != m_set_pkChrTargetedBy.end()) { LPCHARACTER pkChr = *it++; if (!pkChr->GetDesc()) { sys_err("%s %p does not have desc", pkChr->GetName(), get_pointer(pkChr)); abort(); } pkChr->GetDesc()->Packet(&p, sizeof(TPacketGCTarget)); } } void CHARACTER::CheckTarget() { if (!m_pkChrTarget) return; if (DISTANCE_APPROX(GetX() - m_pkChrTarget->GetX(), GetY() - m_pkChrTarget->GetY()) >= 4800) SetTarget(NULL); } void CHARACTER::SetWarpLocation(long lMapIndex, long x, long y) { m_posWarp.x = x * 100; m_posWarp.y = y * 100; m_lWarpMapIndex = lMapIndex; } void CHARACTER::SaveExitLocation() { m_posExit = GetXYZ(); m_lExitMapIndex = GetMapIndex(); } void CHARACTER::ExitToSavedLocation() { sys_log(0, "ExitToSavedLocation"); WarpSet(m_posWarp.x, m_posWarp.y, m_lWarpMapIndex); m_posExit.x = m_posExit.y = m_posExit.z = 0; m_lExitMapIndex = 0; } bool CHARACTER::WarpSet(long x, long y, long lPrivateMapIndex) { if (!IsPC()) return false; long lAddr; long lMapIndex; WORD wPort; if (!CMapLocation::instance().Get(x, y, lMapIndex, lAddr, wPort)) { sys_err("cannot find map location index %d x %d y %d name %s", lMapIndex, x, y, GetName()); GoHome(); return false; } /*if (!CMapLocation::instance().Get(x, y, lMapIndex, lAddr, wPort)) { SetWarpLocation(EMPIRE_START_MAP(GetEmpire()), EMPIRE_START_X(GetEmpire()) / 100, EMPIRE_START_Y(GetEmpire()) / 100); //@fixme230 return false; //sys_err("cannot find map location index %d x %d y %d name %s", lMapIndex, x, y, GetName()); //return false; }*/ //Send Supplementary Data Block if new map requires security packages in loading this map { long lCurAddr; long lCurMapIndex = 0; WORD wCurPort; CMapLocation::instance().Get(GetX(), GetY(), lCurMapIndex, lCurAddr, wCurPort); //do not send SDB files if char is in the same map if (lCurMapIndex != lMapIndex) { const TMapRegion* rMapRgn = SECTREE_MANAGER::instance().GetMapRegion(lMapIndex); { DESC_MANAGER::instance().SendClientPackageSDBToLoadMap(GetDesc(), rMapRgn->strMapName.c_str()); } } } if (lPrivateMapIndex >= 10000) { if (lPrivateMapIndex / 10000 != lMapIndex) { sys_err("Invalid map index %d, must be child of %d", lPrivateMapIndex, lMapIndex); return false; } lMapIndex = lPrivateMapIndex; } Stop(); Save(); if (GetSectree()) { GetSectree()->RemoveEntity(this); ViewCleanup(); EncodeRemovePacket(this); } m_lWarpMapIndex = lMapIndex; m_posWarp.x = x; m_posWarp.y = y; sys_log(0, "WarpSet %s %d %d current map %d target map %d", GetName(), x, y, GetMapIndex(), lMapIndex); TPacketGCWarp p; p.bHeader = HEADER_GC_WARP; p.lX = x; p.lY = y; p.lAddr = lAddr; #ifdef ENABLE_NEWSTUFF if (!g_stProxyIP.empty()) p.lAddr = inet_addr(g_stProxyIP.c_str()); #endif p.wPort = wPort; GetDesc()->Packet(&p, sizeof(TPacketGCWarp)); #ifdef ENABLE_SWITCHBOT CSwitchbotManager::Instance().SetIsWarping(GetPlayerID(), true); if (p.wPort != mother_port) { CSwitchbotManager::Instance().P2PSendSwitchbot(GetPlayerID(), p.wPort); } #endif char buf[256]; snprintf(buf, sizeof(buf), "%s MapIdx %ld DestMapIdx%ld DestX%ld DestY%ld Empire%d", GetName(), GetMapIndex(), lPrivateMapIndex, x, y, GetEmpire()); LogManager::instance().CharLog(this, 0, "WARP", buf); return true; } #define ENABLE_GOHOME_IF_MAP_NOT_ALLOWED void CHARACTER::WarpEnd() { if (test_server) sys_log(0, "WarpEnd %s", GetName()); if (m_posWarp.x == 0 && m_posWarp.y == 0) return; int index = m_lWarpMapIndex; if (index > 10000) index /= 10000; if (!map_allow_find(index)) { sys_err("location %d %d not allowed to login this server", m_posWarp.x, m_posWarp.y); #ifdef ENABLE_GOHOME_IF_MAP_NOT_ALLOWED GoHome(); #else GetDesc()->SetPhase(PHASE_CLOSE); #endif return; } sys_log(0, "WarpEnd %s %d %u %u", GetName(), m_lWarpMapIndex, m_posWarp.x, m_posWarp.y); Show(m_lWarpMapIndex, m_posWarp.x, m_posWarp.y, 0); Stop(); m_lWarpMapIndex = 0; m_posWarp.x = m_posWarp.y = m_posWarp.z = 0; { // P2P Login TPacketGGLogin p; p.bHeader = HEADER_GG_LOGIN; strlcpy(p.szName, GetName(), sizeof(p.szName)); p.dwPID = GetPlayerID(); p.bEmpire = GetEmpire(); p.lMapIndex = SECTREE_MANAGER::instance().GetMapIndex(GetX(), GetY()); p.bChannel = g_bChannel; P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGLogin)); } } bool CHARACTER::Return() { if (!IsNPC()) return false; int x, y; /* float fDist = DISTANCE_SQRT(m_pkMobData->m_posLastAttacked.x - GetX(), m_pkMobData->m_posLastAttacked.y - GetY()); float fx, fy; GetDeltaByDegree(GetRotation(), fDist, &fx, &fy); x = GetX() + (int) fx; y = GetY() + (int) fy; */ SetVictim(NULL); x = m_pkMobInst->m_posLastAttacked.x; y = m_pkMobInst->m_posLastAttacked.y; SetRotationToXY(x, y); if (!Goto(x, y)) return false; SendMovePacket(FUNC_WAIT, 0, 0, 0, 0); if (test_server) sys_log(0, "%s %p Æ÷±âÇÏ°í µ¹¾Æ°¡ÀÚ! %d %d", GetName(), this, x, y); if (GetParty()) GetParty()->SendMessage(this, PM_RETURN, x, y); return true; } bool CHARACTER::Follow(LPCHARACTER pkChr, float fMinDistance) { if (IsPC()) { sys_err("CHARACTER::Follow : PC cannot use this method", GetName()); return false; } // TRENT_MONSTER if (IS_SET(m_pointsInstant.dwAIFlag, AIFLAG_NOMOVE)) { if (pkChr->IsPC()) { // If i'm in a party. I must obey party leader's AI. if (!GetParty() || !GetParty()->GetLeader() || GetParty()->GetLeader() == this) { if (get_dword_time() - m_pkMobInst->m_dwLastAttackedTime >= 15000) { if (m_pkMobData->m_table.wAttackRange < DISTANCE_APPROX(pkChr->GetX() - GetX(), pkChr->GetY() - GetY())) if (Return()) return true; } } } return false; } // END_OF_TRENT_MONSTER long x = pkChr->GetX(); long y = pkChr->GetY(); if (pkChr->IsPC()) { // If i'm in a party. I must obey party leader's AI. if (!GetParty() || !GetParty()->GetLeader() || GetParty()->GetLeader() == this) { if (get_dword_time() - m_pkMobInst->m_dwLastAttackedTime >= 15000) { if (5000 < DISTANCE_APPROX(m_pkMobInst->m_posLastAttacked.x - GetX(), m_pkMobInst->m_posLastAttacked.y - GetY())) if (Return()) return true; } } } if (IsGuardNPC()) { if (5000 < DISTANCE_APPROX(m_pkMobInst->m_posLastAttacked.x - GetX(), m_pkMobInst->m_posLastAttacked.y - GetY())) if (Return()) return true; } if (pkChr->IsState(pkChr->m_stateMove) && GetMobBattleType() != BATTLE_TYPE_RANGE && GetMobBattleType() != BATTLE_TYPE_MAGIC && false == IsPet() #ifdef ENABLE_MOUNT_COSTUME_SYSTEM && false == IsMount() #endif #ifdef ENABLE_NEW_PET_SYSTEM && false == IsNewPet() #endif ) { float rot = pkChr->GetRotation(); float rot_delta = GetDegreeDelta(rot, GetDegreeFromPositionXY(GetX(), GetY(), pkChr->GetX(), pkChr->GetY())); float yourSpeed = pkChr->GetMoveSpeed(); float mySpeed = GetMoveSpeed(); float fDist = DISTANCE_SQRT(x - GetX(), y - GetY()); float fFollowSpeed = mySpeed - yourSpeed * cos(rot_delta * M_PI / 180); if (fFollowSpeed >= 0.1f) { float fMeetTime = fDist / fFollowSpeed; float fYourMoveEstimateX, fYourMoveEstimateY; if (fMeetTime * yourSpeed <= 100000.0f) { GetDeltaByDegree(pkChr->GetRotation(), fMeetTime * yourSpeed, &fYourMoveEstimateX, &fYourMoveEstimateY); x += (long)fYourMoveEstimateX; y += (long)fYourMoveEstimateY; float fDistNew = sqrt(((double)x - GetX()) * (x - GetX()) + ((double)y - GetY()) * (y - GetY())); if (fDist < fDistNew) { x = (long)(GetX() + (x - GetX()) * fDist / fDistNew); y = (long)(GetY() + (y - GetY()) * fDist / fDistNew); } } } } SetRotationToXY(x, y); float fDist = DISTANCE_SQRT(x - GetX(), y - GetY()); if (fDist <= fMinDistance) return false; float fx, fy; if (IsChangeAttackPosition(pkChr) && GetMobRank() < MOB_RANK_BOSS) { SetChangeAttackPositionTime(); int retry = 16; int dx, dy; int rot = (int)GetDegreeFromPositionXY(x, y, GetX(), GetY()); while (--retry) { if (fDist < 500.0f) GetDeltaByDegree((rot + number(-90, 90) + number(-90, 90)) % 360, fMinDistance, &fx, &fy); else GetDeltaByDegree(number(0, 359), fMinDistance, &fx, &fy); dx = x + (int)fx; dy = y + (int)fy; LPSECTREE tree = SECTREE_MANAGER::instance().Get(GetMapIndex(), dx, dy); if (NULL == tree) break; if (0 == (tree->GetAttribute(dx, dy) & (ATTR_BLOCK | ATTR_OBJECT))) break; } if (!Goto(dx, dy)) return false; } else { float fDistToGo = fDist - fMinDistance; GetDeltaByDegree(GetRotation(), fDistToGo, &fx, &fy); if (!Goto(GetX() + (int)fx, GetY() + (int)fy)) return false; } SendMovePacket(FUNC_WAIT, 0, 0, 0, 0); return true; } float CHARACTER::GetDistanceFromSafeboxOpen() const { return DISTANCE_APPROX(GetX() - m_posSafeboxOpen.x, GetY() - m_posSafeboxOpen.y); } void CHARACTER::SetSafeboxOpenPosition() { m_posSafeboxOpen = GetXYZ(); } CSafebox* CHARACTER::GetSafebox() const { return m_pkSafebox; } void CHARACTER::ReqSafeboxLoad(const char* pszPassword) { if (!*pszPassword || strlen(pszPassword) > SAFEBOX_PASSWORD_MAX_LEN) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<â°í> À߸øµÈ ¾ÏÈ£¸¦ ÀÔ·ÂÇϼ̽À´Ï´Ù.")); return; } else if (m_pkSafebox) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<â°í> â°í°¡ ÀÌ¹Ì ¿­·ÁÀÖ½À´Ï´Ù.")); return; } int iPulse = thecore_pulse(); if (iPulse - GetSafeboxLoadTime() < PASSES_PER_SEC(10)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<â°í> â°í¸¦ ´İÀºÁö 10ÃÊ ¾È¿¡´Â ¿­ ¼ö ¾ø½À´Ï´Ù.")); return; } /* @fixme196 else if (GetDistanceFromSafeboxOpen() > 1000) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT(" ¡ÆA¢¬¢ç¡Æ¢® ¢¬O¨úi¨ù¡© A¡Ë¡Æi¢¬| ¢¯¡© ¨ùo ¨ú©ª¨öA¢¥I¢¥U.")); return; } */ else if (m_bOpeningSafebox) { sys_log(0, "Overlapped safebox load request from %s", GetName()); return; } SetSafeboxLoadTime(); m_bOpeningSafebox = true; TSafeboxLoadPacket p; p.dwID = GetDesc()->GetAccountTable().id; strlcpy(p.szLogin, GetDesc()->GetAccountTable().login, sizeof(p.szLogin)); strlcpy(p.szPassword, pszPassword, sizeof(p.szPassword)); db_clientdesc->DBPacket(HEADER_GD_SAFEBOX_LOAD, GetDesc()->GetHandle(), &p, sizeof(p)); } #ifdef ENABLE_YANG_LIMIT_SYSTEM void CHARACTER::LoadSafebox(int iSize, long long llGold, int iItemCount, TPlayerItem * pItems) #else void CHARACTER::LoadSafebox(int iSize, DWORD dwGold, int iItemCount, TPlayerItem * pItems) #endif { bool bLoaded = false; //PREVENT_TRADE_WINDOW SetOpenSafebox(true); //END_PREVENT_TRADE_WINDOW if (m_pkSafebox) bLoaded = true; if (!m_pkSafebox) #ifdef ENABLE_YANG_LIMIT_SYSTEM m_pkSafebox = M2_NEW CSafebox(this, iSize, llGold); #else m_pkSafebox = M2_NEW CSafebox(this, iSize, dwGold); #endif else m_pkSafebox->ChangeSize(iSize); m_iSafeboxSize = iSize; TPacketCGSafeboxSize p; p.bHeader = HEADER_GC_SAFEBOX_SIZE; p.bSize = iSize; GetDesc()->Packet(&p, sizeof(TPacketCGSafeboxSize)); if (!bLoaded) { for (int i = 0; i < iItemCount; ++i, ++pItems) { if (!m_pkSafebox->IsValidPosition(pItems->pos)) continue; LPITEM item = ITEM_MANAGER::instance().CreateItem(pItems->vnum, pItems->count, pItems->id); if (!item) { sys_err("cannot create item vnum %d id %u (name: %s)", pItems->vnum, pItems->id, GetName()); continue; } item->SetSkipSave(true); item->SetSockets(pItems->alSockets); item->SetAttributes(pItems->aAttr); #ifdef ENABLE_CHANGELOOK_SYSTEM item->SetTransmutation(pItems->transmutation); #endif if (!m_pkSafebox->Add(pItems->pos, item)) { M2_DESTROY_ITEM(item); } else item->SetSkipSave(false); } } } void CHARACTER::ChangeSafeboxSize(BYTE bSize) { //if (!m_pkSafebox) //return; TPacketCGSafeboxSize p; p.bHeader = HEADER_GC_SAFEBOX_SIZE; p.bSize = bSize; GetDesc()->Packet(&p, sizeof(TPacketCGSafeboxSize)); if (m_pkSafebox) m_pkSafebox->ChangeSize(bSize); m_iSafeboxSize = bSize; } void CHARACTER::CloseSafebox() { if (!m_pkSafebox) return; //PREVENT_TRADE_WINDOW SetOpenSafebox(false); //END_PREVENT_TRADE_WINDOW m_pkSafebox->Save(); M2_DELETE(m_pkSafebox); m_pkSafebox = NULL; ChatPacket(CHAT_TYPE_COMMAND, "CloseSafebox"); SetSafeboxLoadTime(); m_bOpeningSafebox = false; Save(); } CSafebox* CHARACTER::GetMall() const { return m_pkMall; } void CHARACTER::LoadMall(int iItemCount, TPlayerItem * pItems) { bool bLoaded = false; if (m_pkMall) bLoaded = true; if (!m_pkMall) m_pkMall = M2_NEW CSafebox(this, 3 * SAFEBOX_PAGE_SIZE, 0); else m_pkMall->ChangeSize(3 * SAFEBOX_PAGE_SIZE); m_pkMall->SetWindowMode(MALL); TPacketCGSafeboxSize p; p.bHeader = HEADER_GC_MALL_OPEN; p.bSize = 3 * SAFEBOX_PAGE_SIZE; GetDesc()->Packet(&p, sizeof(TPacketCGSafeboxSize)); if (!bLoaded) { for (int i = 0; i < iItemCount; ++i, ++pItems) { if (!m_pkMall->IsValidPosition(pItems->pos)) continue; LPITEM item = ITEM_MANAGER::instance().CreateItem(pItems->vnum, pItems->count, pItems->id); if (!item) { sys_err("cannot create item vnum %d id %u (name: %s)", pItems->vnum, pItems->id, GetName()); continue; } item->SetSkipSave(true); item->SetSockets(pItems->alSockets); item->SetAttributes(pItems->aAttr); #ifdef ENABLE_CHANGELOOK_SYSTEM item->SetTransmutation(pItems->transmutation); #endif if (!m_pkMall->Add(pItems->pos, item)) M2_DESTROY_ITEM(item); else item->SetSkipSave(false); } } } void CHARACTER::CloseMall() { if (!m_pkMall) return; m_pkMall->Save(); M2_DELETE(m_pkMall); m_pkMall = NULL; ChatPacket(CHAT_TYPE_COMMAND, "CloseMall"); } bool CHARACTER::BuildUpdatePartyPacket(TPacketGCPartyUpdate & out) { if (!GetParty()) return false; memset(&out, 0, sizeof(out)); out.header = HEADER_GC_PARTY_UPDATE; out.pid = GetPlayerID(); if (GetMaxHP() <= 0) // @fixme136 out.percent_hp = 0; else out.percent_hp = MINMAX(0, GetHP() * 100 / GetMaxHP(), 100); out.role = GetParty()->GetRole(GetPlayerID()); sys_log(1, "PARTY %s role is %d", GetName(), out.role); LPCHARACTER l = GetParty()->GetLeaderCharacter(); if (l && DISTANCE_APPROX(GetX() - l->GetX(), GetY() - l->GetY()) < PARTY_DEFAULT_RANGE) { out.affects[0] = GetParty()->GetPartyBonusExpPercent(); out.affects[1] = GetPoint(POINT_PARTY_ATTACKER_BONUS); out.affects[2] = GetPoint(POINT_PARTY_TANKER_BONUS); out.affects[3] = GetPoint(POINT_PARTY_BUFFER_BONUS); out.affects[4] = GetPoint(POINT_PARTY_SKILL_MASTER_BONUS); out.affects[5] = GetPoint(POINT_PARTY_HASTE_BONUS); out.affects[6] = GetPoint(POINT_PARTY_DEFENDER_BONUS); } return true; } int CHARACTER::GetLeadershipSkillLevel() const { return GetSkillLevel(SKILL_LEADERSHIP); } void CHARACTER::QuerySafeboxSize() { if (m_iSafeboxSize == -1) { DBManager::instance().ReturnQuery(QID_SAFEBOX_SIZE, GetPlayerID(), NULL, "SELECT size FROM safebox%s WHERE account_id = %u", get_table_postfix(), GetDesc()->GetAccountTable().id); } } void CHARACTER::SetSafeboxSize(int iSize) { sys_log(1, "SetSafeboxSize: %s %d", GetName(), iSize); m_iSafeboxSize = iSize; DBManager::instance().Query("UPDATE safebox%s SET size = %d WHERE account_id = %u", get_table_postfix(), iSize / SAFEBOX_PAGE_SIZE, GetDesc()->GetAccountTable().id); } int CHARACTER::GetSafeboxSize() const { return m_iSafeboxSize; } void CHARACTER::SetNowWalking(bool bWalkFlag) { //if (m_bNowWalking != bWalkFlag || IsNPC()) if (m_bNowWalking != bWalkFlag) { if (bWalkFlag) { m_bNowWalking = true; m_dwWalkStartTime = get_dword_time(); } else { m_bNowWalking = false; } //if (m_bNowWalking) { TPacketGCWalkMode p; p.vid = GetVID(); p.header = HEADER_GC_WALK_MODE; p.mode = m_bNowWalking ? WALKMODE_WALK : WALKMODE_RUN; PacketView(&p, sizeof(p)); } if (IsNPC()) { if (m_bNowWalking) MonsterLog("°È´Â´Ù"); else MonsterLog("¶Ú´Ù"); } //sys_log(0, "%s is now %s", GetName(), m_bNowWalking?"walking.":"running."); } } void CHARACTER::StartStaminaConsume() { if (m_bStaminaConsume) return; PointChange(POINT_STAMINA, 0); m_bStaminaConsume = true; //ChatPacket(CHAT_TYPE_COMMAND, "StartStaminaConsume %d %d", STAMINA_PER_STEP * passes_per_sec, GetStamina()); if (IsStaminaHalfConsume()) ChatPacket(CHAT_TYPE_COMMAND, "StartStaminaConsume %d %d", STAMINA_PER_STEP * passes_per_sec / 2, GetStamina()); else ChatPacket(CHAT_TYPE_COMMAND, "StartStaminaConsume %d %d", STAMINA_PER_STEP * passes_per_sec, GetStamina()); } void CHARACTER::StopStaminaConsume() { if (!m_bStaminaConsume) return; PointChange(POINT_STAMINA, 0); m_bStaminaConsume = false; ChatPacket(CHAT_TYPE_COMMAND, "StopStaminaConsume %d", GetStamina()); } bool CHARACTER::IsStaminaConsume() const { return m_bStaminaConsume; } bool CHARACTER::IsStaminaHalfConsume() const { return IsEquipUniqueItem(UNIQUE_ITEM_HALF_STAMINA); } void CHARACTER::ResetStopTime() { m_dwStopTime = get_dword_time(); } DWORD CHARACTER::GetStopTime() const { return m_dwStopTime; } void CHARACTER::ResetPoint(int iLv) { BYTE bJob = GetJob(); PointChange(POINT_LEVEL, iLv - GetLevel()); SetRealPoint(POINT_ST, JobInitialPoints[bJob].st); SetPoint(POINT_ST, GetRealPoint(POINT_ST)); SetRealPoint(POINT_HT, JobInitialPoints[bJob].ht); SetPoint(POINT_HT, GetRealPoint(POINT_HT)); SetRealPoint(POINT_DX, JobInitialPoints[bJob].dx); SetPoint(POINT_DX, GetRealPoint(POINT_DX)); SetRealPoint(POINT_IQ, JobInitialPoints[bJob].iq); SetPoint(POINT_IQ, GetRealPoint(POINT_IQ)); SetRandomHP((iLv - 1) * number(JobInitialPoints[GetJob()].hp_per_lv_begin, JobInitialPoints[GetJob()].hp_per_lv_end)); SetRandomSP((iLv - 1) * number(JobInitialPoints[GetJob()].sp_per_lv_begin, JobInitialPoints[GetJob()].sp_per_lv_end)); // @fixme104 PointChange(POINT_STAT, (MINMAX(1, iLv, g_iStatusPointGetLevelLimit) * 3) + GetPoint(POINT_LEVEL_STEP) - GetPoint(POINT_STAT)); ComputePoints(); PointChange(POINT_HP, GetMaxHP() - GetHP()); PointChange(POINT_SP, GetMaxSP() - GetSP()); PointsPacket(); LogManager::instance().CharLog(this, 0, "RESET_POINT", ""); } bool CHARACTER::IsChangeAttackPosition(LPCHARACTER target) const { if (!IsNPC()) return true; DWORD dwChangeTime = AI_CHANGE_ATTACK_POISITION_TIME_NEAR; if (DISTANCE_APPROX(GetX() - target->GetX(), GetY() - target->GetY()) > AI_CHANGE_ATTACK_POISITION_DISTANCE + GetMobAttackRange()) dwChangeTime = AI_CHANGE_ATTACK_POISITION_TIME_FAR; return get_dword_time() - m_dwLastChangeAttackPositionTime > dwChangeTime; } void CHARACTER::GiveRandomSkillBook() { LPITEM item = AutoGiveItem(50300); if (NULL != item) { extern const DWORD GetRandomSkillVnum(BYTE bJob = JOB_MAX_NUM); DWORD dwSkillVnum = 0; // 50% of getting random books or getting one of the same player's race if (!number(0, 1)) dwSkillVnum = GetRandomSkillVnum(GetJob()); else dwSkillVnum = GetRandomSkillVnum(); item->SetSocket(0, dwSkillVnum); } } void CHARACTER::ReviveInvisible(int iDur) { AddAffect(AFFECT_REVIVE_INVISIBLE, POINT_NONE, 0, AFF_REVIVE_INVISIBLE, iDur, 0, true); } void CHARACTER::ToggleMonsterLog() { m_bMonsterLog = !m_bMonsterLog; if (m_bMonsterLog) { CHARACTER_MANAGER::instance().RegisterForMonsterLog(this); } else { CHARACTER_MANAGER::instance().UnregisterForMonsterLog(this); } } void CHARACTER::SetGuild(CGuild * pGuild) { if (m_pGuild != pGuild) { m_pGuild = pGuild; UpdatePacket(); } } void CHARACTER::SendGreetMessage() { typeof(DBManager::instance().GetGreetMessage()) v = DBManager::instance().GetGreetMessage(); for (itertype(v) it = v.begin(); it != v.end(); ++it) { ChatPacket(CHAT_TYPE_NOTICE, it->c_str()); } } void CHARACTER::BeginStateEmpty() { MonsterLog("!"); } void CHARACTER::EffectPacket(int enumEffectType) { TPacketGCSpecialEffect p; p.header = HEADER_GC_SEPCIAL_EFFECT; p.type = enumEffectType; p.vid = GetVID(); PacketAround(&p, sizeof(TPacketGCSpecialEffect)); } void CHARACTER::SpecificEffectPacket(const char filename[MAX_EFFECT_FILE_NAME]) { TPacketGCSpecificEffect p; p.header = HEADER_GC_SPECIFIC_EFFECT; p.vid = GetVID(); memcpy(p.effect_file, filename, MAX_EFFECT_FILE_NAME); PacketAround(&p, sizeof(TPacketGCSpecificEffect)); } void CHARACTER::MonsterChat(BYTE bMonsterChatType) { if (IsPC()) return; char sbuf[256 + 1]; if (IsMonster()) { if (number(0, 60)) return; snprintf(sbuf, sizeof(sbuf), "(locale.monster_chat[%i] and locale.monster_chat[%i][%d] or '')", GetRaceNum(), GetRaceNum(), bMonsterChatType * 3 + number(1, 3)); } else { if (bMonsterChatType != MONSTER_CHAT_WAIT) return; if (IsGuardNPC()) { if (number(0, 6)) return; } else { if (number(0, 30)) return; } snprintf(sbuf, sizeof(sbuf), "(locale.monster_chat[%i] and locale.monster_chat[%i][number(1, table.getn(locale.monster_chat[%i]))] or '')", GetRaceNum(), GetRaceNum(), GetRaceNum()); } std::string text = quest::ScriptToString(sbuf); if (text.empty()) return; struct packet_chat pack_chat; pack_chat.header = HEADER_GC_CHAT; pack_chat.size = sizeof(struct packet_chat) + text.size() + 1; pack_chat.type = CHAT_TYPE_TALKING; pack_chat.id = GetVID(); pack_chat.bEmpire = 0; TEMP_BUFFER buf; buf.write(&pack_chat, sizeof(struct packet_chat)); buf.write(text.c_str(), text.size() + 1); PacketAround(buf.read_peek(), buf.size()); } void CHARACTER::SetQuestNPCID(DWORD vid) { // @fixme197 BEGIN if (vid && m_dwQuestNPCVID) { quest::PC* pPC = quest::CQuestManager::instance().GetPCForce(GetPlayerID()); if (pPC && pPC->IsRunning()) { //sys_err("cannot reset quest npc id - already running quest [%u %s]", GetPlayerID(), GetName()); return; } } // @fixme197 END m_dwQuestNPCVID = vid; } LPCHARACTER CHARACTER::GetQuestNPC() const { return CHARACTER_MANAGER::instance().Find(m_dwQuestNPCVID); } void CHARACTER::SetQuestItemPtr(LPITEM item) { m_pQuestItem = item; } void CHARACTER::ClearQuestItemPtr() { m_pQuestItem = NULL; } LPITEM CHARACTER::GetQuestItemPtr() const { return m_pQuestItem; } LPDUNGEON CHARACTER::GetDungeonForce() const { if (m_lWarpMapIndex > 10000) return CDungeonManager::instance().FindByMapIndex(m_lWarpMapIndex); return m_pkDungeon; } void CHARACTER::SetBlockMode(BYTE bFlag) { m_pointsInstant.bBlockMode = bFlag; ChatPacket(CHAT_TYPE_COMMAND, "setblockmode %d", m_pointsInstant.bBlockMode); SetQuestFlag("game_option.block_exchange", bFlag & BLOCK_EXCHANGE ? 1 : 0); SetQuestFlag("game_option.block_party_invite", bFlag & BLOCK_PARTY_INVITE ? 1 : 0); SetQuestFlag("game_option.block_guild_invite", bFlag & BLOCK_GUILD_INVITE ? 1 : 0); SetQuestFlag("game_option.block_whisper", bFlag & BLOCK_WHISPER ? 1 : 0); SetQuestFlag("game_option.block_messenger_invite", bFlag & BLOCK_MESSENGER_INVITE ? 1 : 0); SetQuestFlag("game_option.block_party_request", bFlag & BLOCK_PARTY_REQUEST ? 1 : 0); SetQuestFlag("game_option.block_point_exp", bFlag & BLOCK_POINT_EXP ? 1 : 0); SetQuestFlag("game_option.block_point_attack", bFlag & BLOCK_POINT_ATTACK ? 1 : 0); } void CHARACTER::SetBlockModeForce(BYTE bFlag) { m_pointsInstant.bBlockMode = bFlag; ChatPacket(CHAT_TYPE_COMMAND, "setblockmode %d", m_pointsInstant.bBlockMode); } bool CHARACTER::IsGuardNPC() const { return IsNPC() && (GetRaceNum() == 11000 || GetRaceNum() == 11002 || GetRaceNum() == 11004); } int CHARACTER::GetPolymorphPower() const { if (test_server) { int value = quest::CQuestManager::instance().GetEventFlag("poly"); if (value) return value; } return aiPolymorphPowerByLevel[MINMAX(0, GetSkillLevel(SKILL_POLYMORPH), 40)]; } void CHARACTER::SetPolymorph(DWORD dwRaceNum, bool bMaintainStat) { #ifdef ENABLE_WOLFMAN_CHARACTER if (dwRaceNum < MAIN_RACE_MAX_NUM) #else if (dwRaceNum < JOB_MAX_NUM) #endif { dwRaceNum = 0; bMaintainStat = false; } if (m_dwPolymorphRace == dwRaceNum) return; m_bPolyMaintainStat = bMaintainStat; m_dwPolymorphRace = dwRaceNum; sys_log(0, "POLYMORPH: %s race %u ", GetName(), dwRaceNum); if (dwRaceNum != 0) StopRiding(); SET_BIT(m_bAddChrState, ADD_CHARACTER_STATE_SPAWN); m_afAffectFlag.Set(AFF_SPAWN); ViewReencode(); REMOVE_BIT(m_bAddChrState, ADD_CHARACTER_STATE_SPAWN); if (!bMaintainStat) { PointChange(POINT_ST, 0); PointChange(POINT_DX, 0); PointChange(POINT_IQ, 0); PointChange(POINT_HT, 0); } SetValidComboInterval(0); SetComboSequence(0); ComputeBattlePoints(); } int CHARACTER::GetQuestFlag(const std::string & flag) const { // @DsProject19 BEGIN if (!IsPC()) { sys_err("Trying to get qf %s from non player character", flag.c_str()); return 0; } // DWORD pid = GetPlayerID(); // @DsProject19 END quest::CQuestManager& q = quest::CQuestManager::instance(); quest::PC* pPC = q.GetPC(GetPlayerID()); // @DsProject19 BEGIN if (!pPC) { //sys_err("Nullpointer when trying to access questflag %s for player with pid %u", flag.c_str(), pid); return 0; } // @DsProject19 END return pPC->GetFlag(flag); } void CHARACTER::SetQuestFlag(const std::string & flag, int value) { quest::CQuestManager& q = quest::CQuestManager::instance(); quest::PC* pPC = q.GetPC(GetPlayerID()); // @DsProject19 BEGIN if (!pPC) { //sys_err("Nullpointer when trying to set questflag %s for player with pid %u", flag.c_str(), pid); return; } // @DsProject19 END pPC->SetFlag(flag, value); } void CHARACTER::DetermineDropMetinStone() { #ifdef ENABLE_NEWSTUFF if (g_NoDropMetinStone) { m_dwDropMetinStone = 0; return; } #endif static const DWORD c_adwMetin[] = { #if defined(ENABLE_WOLFMAN_CHARACTER) && defined(USE_WOLFMAN_STONES) 28012, #endif 28030, 28031, 28032, 28033, 28034, 28035, 28036, 28037, 28038, 28039, 28040, 28041, 28042, 28043, #if defined(ENABLE_MAGIC_REDUCTION_SYSTEM) && defined(USE_MAGIC_REDUCTION_STONES) 28044, 28045, #endif }; DWORD stone_num = GetRaceNum(); int idx = std::lower_bound(aStoneDrop, aStoneDrop + STONE_INFO_MAX_NUM, stone_num) - aStoneDrop; if (idx >= STONE_INFO_MAX_NUM || aStoneDrop[idx].dwMobVnum != stone_num) { m_dwDropMetinStone = 0; } else { const SStoneDropInfo& info = aStoneDrop[idx]; m_bDropMetinStonePct = info.iDropPct; { m_dwDropMetinStone = c_adwMetin[number(0, sizeof(c_adwMetin) / sizeof(DWORD) - 1)]; int iGradePct = number(1, 100); for (int iStoneLevel = 0; iStoneLevel < STONE_LEVEL_MAX_NUM; iStoneLevel++) { int iLevelGradePortion = info.iLevelPct[iStoneLevel]; if (iGradePct <= iLevelGradePortion) { break; } else { iGradePct -= iLevelGradePortion; m_dwDropMetinStone += 100; } } } } } void CHARACTER::SendEquipment(LPCHARACTER ch) { TPacketViewEquip p; p.header = HEADER_GC_VIEW_EQUIP; p.vid = GetVID(); for (int i = 0; i < WEAR_MAX_NUM; i++) { LPITEM item = GetWear(i); if (item) { p.equips[i].vnum = item->GetVnum(); p.equips[i].count = item->GetCount(); thecore_memcpy(p.equips[i].alSockets, item->GetSockets(), sizeof(p.equips[i].alSockets)); thecore_memcpy(p.equips[i].aAttr, item->GetAttributes(), sizeof(p.equips[i].aAttr)); } else { p.equips[i].vnum = 0; } } ch->GetDesc()->Packet(&p, sizeof(p)); } bool CHARACTER::CanSummon(int iLeaderShip) { return ((iLeaderShip >= 20) || ((iLeaderShip >= 12) && ((m_dwLastDeadTime + 180) > get_dword_time()))); } // #define ENABLE_MOUNT_ENTITY_REFRESH void CHARACTER::MountVnum(DWORD vnum) { if (m_dwMountVnum == vnum) return; if ((m_dwMountVnum != 0) && (vnum != 0)) //@fixme108 set recursively to 0 for eventuality MountVnum(0); m_dwMountVnum = vnum; m_dwMountTime = get_dword_time(); if (m_bIsObserver) return; m_posDest.x = m_posStart.x = GetX(); m_posDest.y = m_posStart.y = GetY(); #ifdef ENABLE_MOUNT_ENTITY_REFRESH // EncodeRemovePacket(this); // commented, otherwise it may warp you back #endif EncodeInsertPacket(this); ENTITY_MAP::iterator it = m_map_view.begin(); while (it != m_map_view.end()) { LPENTITY entity = (it++)->first; #ifdef ENABLE_MOUNT_ENTITY_REFRESH if (entity->IsType(ENTITY_CHARACTER)) { EncodeRemovePacket(entity); if (!m_bIsObserver) EncodeInsertPacket(entity); if (!entity->IsObserverMode()) entity->EncodeInsertPacket(this); } else EncodeInsertPacket(entity); #else EncodeInsertPacket(entity); #endif } SetValidComboInterval(0); SetComboSequence(0); ComputePoints(); } namespace { class FuncCheckWarp { public: FuncCheckWarp(LPCHARACTER pkWarp) { m_lTargetY = 0; m_lTargetX = 0; m_lX = pkWarp->GetX(); m_lY = pkWarp->GetY(); m_bInvalid = false; m_bEmpire = pkWarp->GetEmpire(); char szTmp[64]; if (3 != sscanf(pkWarp->GetName(), " %s %ld %ld ", szTmp, &m_lTargetX, &m_lTargetY)) { if (number(1, 100) < 5) sys_err("Warp NPC name wrong : vnum(%d) name(%s)", pkWarp->GetRaceNum(), pkWarp->GetName()); m_bInvalid = true; return; } m_lTargetX *= 100; m_lTargetY *= 100; m_bUseWarp = true; if (pkWarp->IsGoto()) { LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(pkWarp->GetMapIndex()); m_lTargetX += pkSectreeMap->m_setting.iBaseX; m_lTargetY += pkSectreeMap->m_setting.iBaseY; m_bUseWarp = false; } } bool Valid() { return !m_bInvalid; } void operator () (LPENTITY ent) { if (!Valid()) return; if (!ent->IsType(ENTITY_CHARACTER)) return; LPCHARACTER pkChr = (LPCHARACTER)ent; if (!pkChr->IsPC()) return; int iDist = DISTANCE_APPROX(pkChr->GetX() - m_lX, pkChr->GetY() - m_lY); if (iDist > 300) return; if (m_bEmpire && pkChr->GetEmpire() && m_bEmpire != pkChr->GetEmpire()) return; if (pkChr->IsHack()) return; if (!pkChr->CanHandleItem(false, true)) return; if (m_bUseWarp) pkChr->WarpSet(m_lTargetX, m_lTargetY); else { pkChr->Show(pkChr->GetMapIndex(), m_lTargetX, m_lTargetY); pkChr->Stop(); } } bool m_bInvalid; bool m_bUseWarp; long m_lX; long m_lY; long m_lTargetX; long m_lTargetY; BYTE m_bEmpire; }; } EVENTFUNC(warp_npc_event) { char_event_info* info = dynamic_cast(event->info); if (info == NULL) { sys_err("warp_npc_event> Null pointer"); return 0; } LPCHARACTER ch = info->ch; if (ch == NULL) { // return 0; } if (!ch->GetSectree()) { ch->m_pkWarpNPCEvent = NULL; return 0; } FuncCheckWarp f(ch); if (f.Valid()) ch->GetSectree()->ForEachAround(f); return passes_per_sec / 2; } void CHARACTER::StartWarpNPCEvent() { if (m_pkWarpNPCEvent) return; if (!IsWarp() && !IsGoto()) return; char_event_info* info = AllocEventInfo(); info->ch = this; m_pkWarpNPCEvent = event_create(warp_npc_event, info, passes_per_sec / 2); } void CHARACTER::SyncPacket() { TEMP_BUFFER buf; TPacketCGSyncPositionElement elem; elem.dwVID = GetVID(); elem.lX = GetX(); elem.lY = GetY(); TPacketGCSyncPosition pack; pack.bHeader = HEADER_GC_SYNC_POSITION; pack.wSize = sizeof(TPacketGCSyncPosition) + sizeof(elem); buf.write(&pack, sizeof(pack)); buf.write(&elem, sizeof(elem)); PacketAround(buf.read_peek(), buf.size()); } LPCHARACTER CHARACTER::GetMarryPartner() const { return m_pkChrMarried; } void CHARACTER::SetMarryPartner(LPCHARACTER ch) { m_pkChrMarried = ch; } int CHARACTER::GetMarriageBonus(DWORD dwItemVnum, bool bSum) { if (IsNPC()) return 0; marriage::TMarriage* pMarriage = marriage::CManager::instance().Get(GetPlayerID()); if (!pMarriage) return 0; return pMarriage->GetBonus(dwItemVnum, bSum, this); } void CHARACTER::ConfirmWithMsg(const char* szMsg, int iTimeout, DWORD dwRequestPID) { if (!IsPC()) return; TPacketGCQuestConfirm p; p.header = HEADER_GC_QUEST_CONFIRM; p.requestPID = dwRequestPID; p.timeout = iTimeout; strlcpy(p.msg, szMsg, sizeof(p.msg)); GetDesc()->Packet(&p, sizeof(p)); } int CHARACTER::GetPremiumRemainSeconds(BYTE bType) const { if (bType >= PREMIUM_MAX_NUM) return 0; return m_aiPremiumTimes[bType] - get_global_time(); } bool CHARACTER::WarpToPID(DWORD dwPID) { LPCHARACTER victim; if ((victim = (CHARACTER_MANAGER::instance().FindByPID(dwPID)))) { int mapIdx = victim->GetMapIndex(); if (IS_SUMMONABLE_ZONE(mapIdx)) { if (CAN_ENTER_ZONE(this, mapIdx)) { WarpSet(victim->GetX(), victim->GetY()); } else { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»ó´ë¹æÀÌ ÀÖ´Â °÷À¸·Î ¿öÇÁÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; } } else { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»ó´ë¹æÀÌ ÀÖ´Â °÷À¸·Î ¿öÇÁÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; } } else { CCI* pcci = P2P_MANAGER::instance().FindByPID(dwPID); if (!pcci) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»ó´ë¹æÀÌ ¿Â¶óÀÎ »óÅ°¡ ¾Æ´Õ´Ï´Ù.")); return false; } if (pcci->bChannel != g_bChannel) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»ó´ë¹æÀÌ %d ä³Î¿¡ ÀÖ½À´Ï´Ù. (ÇöÀç ä³Î %d)"), pcci->bChannel, g_bChannel); return false; } else if (false == IS_SUMMONABLE_ZONE(pcci->lMapIndex)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»ó´ë¹æÀÌ ÀÖ´Â °÷À¸·Î ¿öÇÁÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; } else { if (!CAN_ENTER_ZONE(this, pcci->lMapIndex)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»ó´ë¹æÀÌ ÀÖ´Â °÷À¸·Î ¿öÇÁÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; } TPacketGGFindPosition p; p.header = HEADER_GG_FIND_POSITION; p.dwFromPID = GetPlayerID(); p.dwTargetPID = dwPID; pcci->pkDesc->Packet(&p, sizeof(TPacketGGFindPosition)); if (test_server) ChatPacket(CHAT_TYPE_PARTY, "sent find position packet for teleport"); } } return true; } // ADD_REFINE_BUILDING CGuild* CHARACTER::GetRefineGuild() const { LPCHARACTER chRefineNPC = CHARACTER_MANAGER::instance().Find(m_dwRefineNPCVID); return (chRefineNPC ? chRefineNPC->GetGuild() : NULL); } bool CHARACTER::IsRefineThroughGuild() const { return GetRefineGuild() != NULL; } #ifdef ENABLE_YANG_LIMIT_SYSTEM long long CHARACTER::ComputeRefineFee(long long iCost, int iMultiply) const #else int CHARACTER::ComputeRefineFee(int iCost, int iMultiply) const #endif { CGuild* pGuild = GetRefineGuild(); if (pGuild) { if (pGuild == GetGuild()) return iCost * iMultiply * 9 / 10; LPCHARACTER chRefineNPC = CHARACTER_MANAGER::instance().Find(m_dwRefineNPCVID); if (chRefineNPC && chRefineNPC->GetEmpire() != GetEmpire()) return iCost * iMultiply * 3; return iCost * iMultiply; } else return iCost; } #ifdef ENABLE_YANG_LIMIT_SYSTEM void CHARACTER::PayRefineFee(long long llTotalMoney) #else void CHARACTER::PayRefineFee(int iTotalMoney) #endif { #ifdef ENABLE_YANG_LIMIT_SYSTEM long long iFee = llTotalMoney / 10; #else int iFee = iTotalMoney / 10; #endif CGuild* pGuild = GetRefineGuild(); #ifdef ENABLE_YANG_LIMIT_SYSTEM long long iRemain = llTotalMoney; #else int iRemain = iTotalMoney; #endif if (pGuild) { if (pGuild != GetGuild()) { pGuild->RequestDepositMoney(this, iFee); iRemain -= iFee; } } PointChange(POINT_GOLD, -iRemain); } // END_OF_ADD_REFINE_BUILDING bool CHARACTER::IsHack(bool bSendMsg, bool bCheckShopOwner, int limittime) { const int iPulse = thecore_pulse(); if (test_server) bSendMsg = true; if (iPulse - GetSafeboxLoadTime() < PASSES_PER_SEC(limittime)) { if (bSendMsg) ChatPacket(CHAT_TYPE_INFO, LC_TEXT("â°í¸¦ ¿¬ÈÄ %dÃÊ À̳»¿¡´Â ´Ù¸¥°÷À¸·Î À̵¿ÇÒ¼ö ¾ø½À´Ï´Ù."), limittime); if (test_server) ChatPacket(CHAT_TYPE_INFO, "[TestOnly]Pulse %d LoadTime %d PASS %d", iPulse, GetSafeboxLoadTime(), PASSES_PER_SEC(limittime)); return true; } if (bCheckShopOwner) { if (HaveAnotherPagesOpen()) { if (bSendMsg) ChatPacket(CHAT_TYPE_INFO, "Diger pencereleri kapatmadan bunu yapamazsin."); return true; } } else { if (HaveAnotherPagesOpen()) { if (bSendMsg) ChatPacket(CHAT_TYPE_INFO, "Diger pencereleri kapatmadan bunu yapamazsin."); return true; } } //PREVENT_PORTAL_AFTER_EXCHANGE if (iPulse - GetExchangeTime() < PASSES_PER_SEC(limittime)) { if (bSendMsg) ChatPacket(CHAT_TYPE_INFO, LC_TEXT("°Å·¡ ÈÄ %dÃÊ À̳»¿¡´Â ´Ù¸¥Áö¿ªÀ¸·Î À̵¿ ÇÒ ¼ö ¾ø½À´Ï´Ù."), limittime); return true; } //END_PREVENT_PORTAL_AFTER_EXCHANGE //PREVENT_ITEM_COPY if (iPulse - GetMyShopTime() < PASSES_PER_SEC(limittime)) { if (bSendMsg) ChatPacket(CHAT_TYPE_INFO, LC_TEXT("°Å·¡ ÈÄ %dÃÊ À̳»¿¡´Â ´Ù¸¥Áö¿ªÀ¸·Î À̵¿ ÇÒ ¼ö ¾ø½À´Ï´Ù."), limittime); return true; } if (iPulse - GetRefineTime() < PASSES_PER_SEC(limittime)) { if (bSendMsg) ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¾ÆÀÌÅÛ °³·®ÈÄ %dÃÊ À̳»¿¡´Â ±ÍȯºÎ,±Íȯ±â¾ïºÎ¸¦ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù."), limittime); return true; } //END_PREVENT_ITEM_COPY return false; } BOOL CHARACTER::IsMonarch() const { //MONARCH_LIMIT if (CMonarch::instance().IsMonarch(GetPlayerID(), GetEmpire())) return true; return false; //END_MONARCH_LIMIT } void CHARACTER::Say(const std::string & s) { struct ::packet_script packet_script; packet_script.header = HEADER_GC_SCRIPT; packet_script.skin = 1; packet_script.src_size = s.size(); packet_script.size = packet_script.src_size + sizeof(struct packet_script); TEMP_BUFFER buf; buf.write(&packet_script, sizeof(struct packet_script)); buf.write(&s[0], s.size()); if (IsPC()) { GetDesc()->Packet(buf.read_peek(), buf.size()); } } // // Monarch // void CHARACTER::InitMC() { for (int n = 0; n < MI_MAX; ++n) { m_dwMonarchCooltime[n] = thecore_pulse(); } m_dwMonarchCooltimelimit[MI_HEAL] = PASSES_PER_SEC(MC_HEAL); m_dwMonarchCooltimelimit[MI_WARP] = PASSES_PER_SEC(MC_WARP); m_dwMonarchCooltimelimit[MI_TRANSFER] = PASSES_PER_SEC(MC_TRANSFER); m_dwMonarchCooltimelimit[MI_TAX] = PASSES_PER_SEC(MC_TAX); m_dwMonarchCooltimelimit[MI_SUMMON] = PASSES_PER_SEC(MC_SUMMON); m_dwMonarchCooltime[MI_HEAL] -= PASSES_PER_SEC(GetMCL(MI_HEAL)); m_dwMonarchCooltime[MI_WARP] -= PASSES_PER_SEC(GetMCL(MI_WARP)); m_dwMonarchCooltime[MI_TRANSFER] -= PASSES_PER_SEC(GetMCL(MI_TRANSFER)); m_dwMonarchCooltime[MI_TAX] -= PASSES_PER_SEC(GetMCL(MI_TAX)); m_dwMonarchCooltime[MI_SUMMON] -= PASSES_PER_SEC(GetMCL(MI_SUMMON)); } DWORD CHARACTER::GetMC(enum MONARCH_INDEX e) const { return m_dwMonarchCooltime[e]; } void CHARACTER::SetMC(enum MONARCH_INDEX e) { m_dwMonarchCooltime[e] = thecore_pulse(); } bool CHARACTER::IsMCOK(enum MONARCH_INDEX e) const { int iPulse = thecore_pulse(); if ((iPulse - GetMC(e)) < GetMCL(e)) { if (test_server) sys_log(0, " Pulse %d cooltime %d, limit %d", iPulse, GetMC(e), GetMCL(e)); return false; } if (test_server) sys_log(0, " Pulse %d cooltime %d, limit %d", iPulse, GetMC(e), GetMCL(e)); return true; } DWORD CHARACTER::GetMCL(enum MONARCH_INDEX e) const { return m_dwMonarchCooltimelimit[e]; } DWORD CHARACTER::GetMCLTime(enum MONARCH_INDEX e) const { int iPulse = thecore_pulse(); if (test_server) sys_log(0, " Pulse %d cooltime %d, limit %d", iPulse, GetMC(e), GetMCL(e)); return (GetMCL(e)) / passes_per_sec - (iPulse - GetMC(e)) / passes_per_sec; } bool CHARACTER::IsSiegeNPC() const { return IsNPC() && (GetRaceNum() == 11000 || GetRaceNum() == 11002 || GetRaceNum() == 11004); } //------------------------------------------------ void CHARACTER::UpdateDepositPulse() { m_deposit_pulse = thecore_pulse() + PASSES_PER_SEC(60 * 5); } bool CHARACTER::CanDeposit() const { return (m_deposit_pulse == 0 || (m_deposit_pulse < thecore_pulse())); } //------------------------------------------------ ESex GET_SEX(LPCHARACTER ch) { switch (ch->GetRaceNum()) { case MAIN_RACE_WARRIOR_M: case MAIN_RACE_SURA_M: case MAIN_RACE_ASSASSIN_M: case MAIN_RACE_SHAMAN_M: #ifdef ENABLE_WOLFMAN_CHARACTER case MAIN_RACE_WOLFMAN_M: #endif return SEX_MALE; case MAIN_RACE_ASSASSIN_W: case MAIN_RACE_SHAMAN_W: case MAIN_RACE_WARRIOR_W: case MAIN_RACE_SURA_W: return SEX_FEMALE; } /* default sex = male */ return SEX_MALE; } long long CHARACTER::GetHPPct() const { if (GetMaxHP() <= 0) // @fixme136 return 0; return (GetHP() * 100) / GetMaxHP(); } bool CHARACTER::IsBerserk() const { if (m_pkMobInst != NULL) return m_pkMobInst->m_IsBerserk; else return false; } void CHARACTER::SetBerserk(bool mode) { if (m_pkMobInst != NULL) m_pkMobInst->m_IsBerserk = mode; } bool CHARACTER::IsGodSpeed() const { if (m_pkMobInst != NULL) { return m_pkMobInst->m_IsGodSpeed; } else { return false; } } void CHARACTER::SetGodSpeed(bool mode) { if (m_pkMobInst != NULL) { m_pkMobInst->m_IsGodSpeed = mode; if (mode == true) { SetPoint(POINT_ATT_SPEED, 250); } else { SetPoint(POINT_ATT_SPEED, m_pkMobData->m_table.sAttackSpeed); } } } bool CHARACTER::IsDeathBlow() const { if (number(1, 100) <= m_pkMobData->m_table.bDeathBlowPoint) { return true; } else { return false; } } struct FFindReviver { FFindReviver() { pChar = NULL; HasReviver = false; } void operator() (LPCHARACTER ch) { if (ch->IsMonster() != true) { return; } if (ch->IsReviver() == true && pChar != ch && ch->IsDead() != true) { if (number(1, 100) <= ch->GetMobTable().bRevivePoint) { HasReviver = true; pChar = ch; } } } LPCHARACTER pChar; bool HasReviver; }; bool CHARACTER::HasReviverInParty() const { LPPARTY party = GetParty(); if (party != NULL) { if (party->GetMemberCount() == 1) return false; FFindReviver f; party->ForEachMemberPtr(f); return f.HasReviver; } return false; } bool CHARACTER::IsRevive() const { if (m_pkMobInst != NULL) { return m_pkMobInst->m_IsRevive; } return false; } void CHARACTER::SetRevive(bool mode) { if (m_pkMobInst != NULL) { m_pkMobInst->m_IsRevive = mode; } } #define IS_SPEED_HACK_PLAYER(ch) (ch->m_speed_hack_count > SPEEDHACK_LIMIT_COUNT) EVENTFUNC(check_speedhack_event) { char_event_info* info = dynamic_cast(event->info); if (info == NULL) { sys_err("check_speedhack_event> Null pointer"); return 0; } LPCHARACTER ch = info->ch; if (NULL == ch || ch->IsNPC()) return 0; if (IS_SPEED_HACK_PLAYER(ch)) { // write hack log LogManager::instance().SpeedHackLog(ch->GetPlayerID(), ch->GetX(), ch->GetY(), ch->m_speed_hack_count); if (g_bEnableSpeedHackCrash) { // close connection LPDESC desc = ch->GetDesc(); if (desc) { DESC_MANAGER::instance().DestroyDesc(desc); return 0; } } } ch->m_speed_hack_count = 0; ch->ResetComboHackCount(); return PASSES_PER_SEC(60); } void CHARACTER::StartCheckSpeedHackEvent() { if (m_pkCheckSpeedHackEvent) return; char_event_info* info = AllocEventInfo(); info->ch = this; m_pkCheckSpeedHackEvent = event_create(check_speedhack_event, info, PASSES_PER_SEC(60)); } void CHARACTER::GoHome() { WarpSet(EMPIRE_START_X(GetEmpire()), EMPIRE_START_Y(GetEmpire())); } void CHARACTER::SendGuildName(CGuild * pGuild) { if (NULL == pGuild) return; DESC* desc = GetDesc(); if (NULL == desc) return; if (m_known_guild.find(pGuild->GetID()) != m_known_guild.end()) return; m_known_guild.insert(pGuild->GetID()); TPacketGCGuildName pack; memset(&pack, 0x00, sizeof(pack)); pack.header = HEADER_GC_GUILD; pack.subheader = GUILD_SUBHEADER_GC_GUILD_NAME; pack.size = sizeof(TPacketGCGuildName); pack.guildID = pGuild->GetID(); memcpy(pack.guildName, pGuild->GetName(), GUILD_NAME_MAX_LEN); desc->Packet(&pack, sizeof(pack)); } void CHARACTER::SendGuildName(DWORD dwGuildID) { SendGuildName(CGuildManager::instance().FindGuild(dwGuildID)); } EVENTFUNC(destroy_when_idle_event) { char_event_info* info = dynamic_cast(event->info); if (info == NULL) { sys_err("destroy_when_idle_event> Null pointer"); return 0; } LPCHARACTER ch = info->ch; if (ch == NULL) { // return 0; } if (ch->GetVictim()) { return PASSES_PER_SEC(300); } sys_log(1, "DESTROY_WHEN_IDLE: %s", ch->GetName()); ch->m_pkDestroyWhenIdleEvent = NULL; M2_DESTROY_CHARACTER(ch); return 0; } void CHARACTER::StartDestroyWhenIdleEvent() { if (m_pkDestroyWhenIdleEvent) return; char_event_info* info = AllocEventInfo(); info->ch = this; m_pkDestroyWhenIdleEvent = event_create(destroy_when_idle_event, info, PASSES_PER_SEC(300)); } void CHARACTER::SetComboSequence(BYTE seq) { m_bComboSequence = seq; } BYTE CHARACTER::GetComboSequence() const { return m_bComboSequence; } void CHARACTER::SetLastComboTime(DWORD time) { m_dwLastComboTime = time; } DWORD CHARACTER::GetLastComboTime() const { return m_dwLastComboTime; } void CHARACTER::SetValidComboInterval(int interval) { m_iValidComboInterval = interval; } int CHARACTER::GetValidComboInterval() const { return m_iValidComboInterval; } BYTE CHARACTER::GetComboIndex() const { return m_bComboIndex; } void CHARACTER::IncreaseComboHackCount(int k) { m_iComboHackCount += k; if (m_iComboHackCount >= 10) { if (GetDesc()) if (GetDesc()->DelayedDisconnect(number(2, 7))) { sys_log(0, "COMBO_HACK_DISCONNECT: %s count: %d", GetName(), m_iComboHackCount); LogManager::instance().HackLog("Combo", this); } } } void CHARACTER::ResetComboHackCount() { m_iComboHackCount = 0; } void CHARACTER::SkipComboAttackByTime(int interval) { m_dwSkipComboAttackByTime = get_dword_time() + interval; } DWORD CHARACTER::GetSkipComboAttackByTime() const { return m_dwSkipComboAttackByTime; } void CHARACTER::ResetChatCounter() { m_bChatCounter = 0; } BYTE CHARACTER::IncreaseChatCounter() { return ++m_bChatCounter; } BYTE CHARACTER::GetChatCounter() const { return m_bChatCounter; } bool CHARACTER::IsRiding() const { return IsHorseRiding() || GetMountVnum(); } bool CHARACTER::CanWarp() { const int iPulse = thecore_pulse(); const int limit_time = PASSES_PER_SEC(g_nPortalLimitTime); if ((iPulse - GetSafeboxLoadTime()) < limit_time) return false; if ((iPulse - GetExchangeTime()) < limit_time) return false; if ((iPulse - GetMyShopTime()) < limit_time) return false; if ((iPulse - GetRefineTime()) < limit_time) return false; if (HaveAnotherPagesOpen()) { ChatPacket(CHAT_TYPE_INFO, "Diger pencereleri kapatmadan bunu yapamazsin."); return false; } // patch with warp check #ifdef __ENABLE_NEW_OFFLINESHOP__ if (iPulse - GetOfflineShopUseTime() < limit_time) return false; if (GetOfflineShopGuest() || GetAuctionGuest()) return false; #endif return true; } DWORD CHARACTER::GetNextExp() const { if (PLAYER_MAX_LEVEL_CONST < GetLevel()) return 2500000000u; else return exp_table[GetLevel()]; } #ifdef ENABLE_NEW_PET_SYSTEM DWORD CHARACTER::PetGetNextExp() const { if (IsNewPet()) { if (PLAYER_MAX_LEVEL_CONST < GetLevel()) return 2500000000u; else return exp_pet_table[GetLevel()]; } return 0; } #endif int CHARACTER::GetSkillPowerByLevel(int level, bool bMob) const { return CTableBySkill::instance().GetSkillPowerByLevelFromType(GetJob(), GetSkillGroup(), MINMAX(0, level, SKILL_MAX_LEVEL), bMob); } #ifdef __ENABLE_NEW_OFFLINESHOP__ void CHARACTER::SetShopSafebox(offlineshop::CShopSafebox * pk) { if (m_pkShopSafebox && pk == NULL) m_pkShopSafebox->SetOwner(NULL); else if (m_pkShopSafebox == NULL && pk) pk->SetOwner(this); m_pkShopSafebox = pk; } void CHARACTER::SetOfflineShopUseTime() { m_iOfflineShopUseTime = get_global_time() + 2; ///for test } void CHARACTER::SetIkarusOfflineShopUseTime() { m_iOfflineShopGlobalTime = get_global_time() + 2; ///for test } #endif #ifdef ENABLE_ACCE_SYSTEM std::vector CHARACTER::GetAcceMaterials() { return std::vector{ITEM_MANAGER::instance().Find(m_pointsInstant.pAcceMaterials[0].id), ITEM_MANAGER::instance().Find(m_pointsInstant.pAcceMaterials[1].id)}; } const TItemPosEx* CHARACTER::GetAcceMaterialsInfo() { return m_pointsInstant.pAcceMaterials; } void CHARACTER::SetAcceMaterial(int pos, LPITEM ptr) { if (pos < 0 || pos >= ACCE_WINDOW_MAX_MATERIALS) return; if (!ptr) m_pointsInstant.pAcceMaterials[pos] = {}; else { m_pointsInstant.pAcceMaterials[pos].id = ptr->GetID(); m_pointsInstant.pAcceMaterials[pos].pos.cell = ptr->GetCell(); m_pointsInstant.pAcceMaterials[pos].pos.window_type = ptr->GetWindow(); } } bool CHARACTER::IsOpenAcce() { if (m_bAcceCombination || m_bAcceAbsorption) return true; return false; } void CHARACTER::OpenAcce(bool bCombination) { if (isAcceOpened(bCombination)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("The acce window it's already opened.")); return; } if (bCombination) { if (m_bAcceAbsorption) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Before you may close the acce absorption window.")); return; } m_bAcceCombination = true; } else { if (m_bAcceCombination) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Before you may close the acce combine window.")); return; } m_bAcceAbsorption = true; } TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketAcce sPacket; sPacket.header = HEADER_GC_ACCE; sPacket.subheader = ACCE_SUBHEADER_GC_OPEN; sPacket.bWindow = bCombination; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llPrice = 0; #else sPacket.dwPrice = 0; #endif sPacket.bPos = 0; sPacket.tPos = tPos; sPacket.dwItemVnum = 0; sPacket.dwMinAbs = 0; sPacket.dwMaxAbs = 0; GetDesc()->Packet(&sPacket, sizeof(TPacketAcce)); ClearAcceMaterials(); } void CHARACTER::CloseAcce() { if ((!m_bAcceCombination) && (!m_bAcceAbsorption)) return; bool bWindow = (m_bAcceCombination == true ? true : false); TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketAcce sPacket; sPacket.header = HEADER_GC_ACCE; sPacket.subheader = ACCE_SUBHEADER_GC_CLOSE; sPacket.bWindow = bWindow; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llPrice = 0; #else sPacket.dwPrice = 0; #endif sPacket.bPos = 0; sPacket.tPos = tPos; sPacket.dwItemVnum = 0; sPacket.dwMinAbs = 0; sPacket.dwMaxAbs = 0; GetDesc()->Packet(&sPacket, sizeof(TPacketAcce)); if (bWindow) m_bAcceCombination = false; else m_bAcceAbsorption = false; ClearAcceMaterials(); } void CHARACTER::ClearAcceMaterials() { auto pkItemMaterial = GetAcceMaterials(); for (int i = 0; i < ACCE_WINDOW_MAX_MATERIALS; ++i) { if (!pkItemMaterial[i]) continue; pkItemMaterial[i]->Lock(false); pkItemMaterial[i] = NULL; SetAcceMaterial(i, nullptr); } } bool CHARACTER::AcceIsSameGrade(long lGrade) { auto pkItemMaterial = GetAcceMaterials(); if (!pkItemMaterial[0]) return false; bool bReturn = (pkItemMaterial[0]->GetValue(ACCE_GRADE_VALUE_FIELD) == lGrade ? true : false); return bReturn; } #ifdef ENABLE_YANG_LIMIT_SYSTEM long long CHARACTER::GetAcceCombinePrice(long lGrade) { long long llPrice = 0; switch (lGrade) { case 2: { llPrice = ACCE_GRADE_2_PRICE; } break; case 3: { llPrice = ACCE_GRADE_3_PRICE; } break; case 4: { llPrice = ACCE_GRADE_4_PRICE; } break; default: { llPrice = ACCE_GRADE_1_PRICE; } break; } return llPrice; } #else DWORD CHARACTER::GetAcceCombinePrice(long lGrade) { DWORD dwPrice = 0; switch (lGrade) { case 2: { dwPrice = ACCE_GRADE_2_PRICE; } break; case 3: { dwPrice = ACCE_GRADE_3_PRICE; } break; case 4: { dwPrice = ACCE_GRADE_4_PRICE; } break; default: { dwPrice = ACCE_GRADE_1_PRICE; } break; } return dwPrice; } #endif bool Acce100Abs(DWORD vnum) { switch (vnum) { case 85018: case 85014: case 85008: case 85004: return true; } return false; } BYTE CHARACTER::CheckEmptyMaterialSlot() { auto pkItemMaterial = GetAcceMaterials(); for (int i = 0; i < ACCE_WINDOW_MAX_MATERIALS; ++i) { if (!pkItemMaterial[i]) return i; } return 255; } void CHARACTER::GetAcceCombineResult(DWORD & dwItemVnum, DWORD & dwMinAbs, DWORD & dwMaxAbs) { auto pkItemMaterial = GetAcceMaterials(); if (m_bAcceCombination) { if ((pkItemMaterial[0]) && (pkItemMaterial[1])) { long lVal = pkItemMaterial[0]->GetValue(ACCE_GRADE_VALUE_FIELD); if (lVal == 4) { dwItemVnum = pkItemMaterial[0]->GetOriginalVnum(); dwMinAbs = pkItemMaterial[0]->GetSocket(ACCE_ABSORPTION_SOCKET); DWORD dwMaxAbsCalc = ACCE_GRADE_4_ABS_MAX; if (pkItemMaterial[0]->GetSocket(2) > 0) { dwMaxAbsCalc = pkItemMaterial[0]->GetSocket(2); } /*if (Acce100Abs(dwItemVnum) == true) dwMaxAbsCalc = (dwMinAbs + ACCE_GRADE_4_ABS_RANGE > ACCE_GRADE_NEW_ABS_100 ? ACCE_GRADE_NEW_ABS_100 : (dwMinAbs + ACCE_GRADE_4_ABS_RANGE)); else dwMaxAbsCalc = (dwMinAbs + ACCE_GRADE_4_ABS_RANGE > ACCE_GRADE_4_ABS_MAX ? ACCE_GRADE_4_ABS_MAX : (dwMinAbs + ACCE_GRADE_4_ABS_RANGE));*/ dwMaxAbs = dwMaxAbsCalc; } else { DWORD dwMaskVnum = pkItemMaterial[0]->GetOriginalVnum(); TItemTable* pTable = ITEM_MANAGER::instance().GetTable(dwMaskVnum + 1); if (pTable) dwMaskVnum += 1; dwItemVnum = dwMaskVnum; switch (lVal) { case 2: { dwMinAbs = ACCE_GRADE_3_ABS; dwMaxAbs = ACCE_GRADE_3_ABS; } break; case 3: { dwMinAbs = ACCE_GRADE_4_ABS_MIN; dwMaxAbs = ACCE_GRADE_4_ABS_MAX_COMB; } break; default: { dwMinAbs = ACCE_GRADE_2_ABS; dwMaxAbs = ACCE_GRADE_2_ABS; } break; } } } else { dwItemVnum = 0; dwMinAbs = 0; dwMaxAbs = 0; } } else { if ((pkItemMaterial[0]) && (pkItemMaterial[1])) { dwItemVnum = pkItemMaterial[0]->GetOriginalVnum(); dwMinAbs = pkItemMaterial[0]->GetSocket(ACCE_ABSORPTION_SOCKET); dwMaxAbs = dwMinAbs; } else { dwItemVnum = 0; dwMinAbs = 0; dwMaxAbs = 0; } } } void CHARACTER::AddAcceMaterial(TItemPos tPos, BYTE bPos) { if (bPos >= ACCE_WINDOW_MAX_MATERIALS) { if (bPos == 255) { bPos = CheckEmptyMaterialSlot(); if (bPos >= ACCE_WINDOW_MAX_MATERIALS) return; } else return; } LPITEM pkItem = GetItem(tPos); if (!pkItem) return; else if ((pkItem->GetCell() >= INVENTORY_MAX_NUM) || (pkItem->IsEquipped()) || (tPos.IsBeltInventoryPosition()) || (pkItem->IsDragonSoul())) return; else if ((pkItem->GetType() != ITEM_COSTUME) && (m_bAcceCombination)) return; else if ((pkItem->GetType() != ITEM_COSTUME) && (bPos == 0) && (m_bAcceAbsorption)) return; else if (pkItem->isLocked()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't add locked items.")); return; } #ifdef __SOULBINDING_SYSTEM__ else if ((pkItem->IsBind()) || (pkItem->IsUntilBind())) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't add binded items.")); return; } #endif #ifdef ENABLE_BASIC_ITEM_SYSTEM else if ((pkItem->IsBasicItem())) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't add binded items.")); return; } #endif else if ((m_bAcceCombination) && (bPos == 1) && (!AcceIsSameGrade(pkItem->GetValue(ACCE_GRADE_VALUE_FIELD)))) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can combine just accees of same grade.")); return; } else if ((m_bAcceCombination) && (pkItem->GetSocket(ACCE_ABSORPTION_SOCKET) >= ACCE_GRADE_4_ABS_MAX)) { /*if (Acce100Abs(pkItem->GetVnum()) == true) { if ((m_bAcceCombination) && (pkItem->GetSocket(ACCE_ABSORPTION_SOCKET) >= ACCE_GRADE_NEW_ABS_100)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This acce got already maximum absorption chance.")); return; } }*/ if (pkItem->GetSocket(ACCE_ABSORPTION_SOCKET) < pkItem->GetSocket(2) && pkItem->GetSocket(2) != 0) { //do nothing } else { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This acce got already maximum absorption chance.")); return; } } else if ((bPos == 1) && (m_bAcceAbsorption)) { if ((pkItem->GetType() != ITEM_WEAPON) && (pkItem->GetType() != ITEM_ARMOR)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can absorb just the bonuses from armors and weapons.")); return; } else if ((pkItem->GetType() == ITEM_ARMOR) && (pkItem->GetSubType() != ARMOR_BODY)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can absorb just the bonuses from armors and weapons.")); return; } } else if ((pkItem->GetSubType() != COSTUME_ACCE) && (m_bAcceCombination)) return; else if ((pkItem->GetSubType() != COSTUME_ACCE) && (bPos == 0) && (m_bAcceAbsorption)) return; else if ((pkItem->GetSocket(ACCE_ABSORBED_SOCKET) > 0) && (bPos == 0) && (m_bAcceAbsorption)) return; auto pkItemMaterial = GetAcceMaterials(); if ((bPos == 1) && (!pkItemMaterial[0])) return; if (pkItemMaterial[bPos]) return; SetAcceMaterial(bPos, pkItem); pkItemMaterial[bPos] = pkItem; pkItemMaterial[bPos]->Lock(true); DWORD dwItemVnum, dwMinAbs, dwMaxAbs; GetAcceCombineResult(dwItemVnum, dwMinAbs, dwMaxAbs); TPacketAcce sPacket; sPacket.header = HEADER_GC_ACCE; sPacket.subheader = ACCE_SUBHEADER_GC_ADDED; sPacket.bWindow = m_bAcceCombination == true ? true : false; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llPrice = GetAcceCombinePrice(pkItem->GetValue(ACCE_GRADE_VALUE_FIELD)); #else sPacket.dwPrice = GetAcceCombinePrice(pkItem->GetValue(ACCE_GRADE_VALUE_FIELD)); #endif sPacket.bPos = bPos; sPacket.tPos = tPos; sPacket.dwItemVnum = dwItemVnum; sPacket.dwMinAbs = dwMinAbs; sPacket.dwMaxAbs = dwMaxAbs; GetDesc()->Packet(&sPacket, sizeof(TPacketAcce)); } void CHARACTER::RemoveAcceMaterial(BYTE bPos) { if (bPos >= ACCE_WINDOW_MAX_MATERIALS) return; auto pkItemMaterial = GetAcceMaterials(); #ifdef ENABLE_YANG_LIMIT_SYSTEM long long llPrice = 0; #else DWORD dwPrice = 0; #endif if (bPos == 1) { if (pkItemMaterial[bPos]) { pkItemMaterial[bPos]->Lock(false); pkItemMaterial[bPos] = NULL; SetAcceMaterial(bPos, nullptr); } if (pkItemMaterial[0]) #ifdef ENABLE_YANG_LIMIT_SYSTEM llPrice = GetAcceCombinePrice(pkItemMaterial[0]->GetValue(ACCE_GRADE_VALUE_FIELD)); #else dwPrice = GetAcceCombinePrice(pkItemMaterial[0]->GetValue(ACCE_GRADE_VALUE_FIELD)); #endif } else ClearAcceMaterials(); TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketAcce sPacket; sPacket.header = HEADER_GC_ACCE; sPacket.subheader = ACCE_SUBHEADER_GC_REMOVED; sPacket.bWindow = m_bAcceCombination == true ? true : false; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llPrice = llPrice; #else sPacket.dwPrice = dwPrice; #endif sPacket.bPos = bPos; sPacket.tPos = tPos; sPacket.dwItemVnum = 0; sPacket.dwMinAbs = 0; sPacket.dwMaxAbs = 0; GetDesc()->Packet(&sPacket, sizeof(TPacketAcce)); } BYTE CHARACTER::CanRefineAcceMaterials() { BYTE bReturn = 0; if (!GetDesc()) return bReturn; if (HaveAnotherPagesOpen()) { ChatPacket(CHAT_TYPE_INFO, "Diger pencereleri kapatmadan bunu yapamazsin."); return bReturn; } auto materialInfo = GetAcceMaterialsInfo(); auto pkItemMaterial = GetAcceMaterials(); if (!pkItemMaterial[0] || !pkItemMaterial[1]) { sys_err("CanRefineAcceMaterials: pkItemMaterial null"); return bReturn; } else if (pkItemMaterial[0]->GetOwner() != this || pkItemMaterial[1]->GetOwner() != this) { sys_err("CanRefineAcceMaterials: pkItemMaterial different ownership"); return bReturn; } else if (pkItemMaterial[0]->IsEquipped() || pkItemMaterial[1]->IsEquipped()) { sys_err("CanRefineAcceMaterials: pkItemMaterial equipped"); return bReturn; } else if (pkItemMaterial[0]->GetWindow() != INVENTORY || pkItemMaterial[1]->GetWindow() != INVENTORY) { sys_err("CanRefineAcceMaterials: pkItemMaterial not in INVENTORY"); return bReturn; } else if (!materialInfo[0].id || !materialInfo[1].id) { sys_err("CanRefineAcceMaterials: materialInfo id 0"); return bReturn; } else if (materialInfo[0].pos.cell != pkItemMaterial[0]->GetCell() || materialInfo[1].pos.cell != pkItemMaterial[1]->GetCell()) { sys_err("CanRefineAcceMaterials: pkItemMaterial wrong cell"); return bReturn; } else if (materialInfo[0].pos.window_type != pkItemMaterial[0]->GetWindow() || materialInfo[1].pos.window_type != pkItemMaterial[1]->GetWindow()) { sys_err("CanRefineAcceMaterials: pkItemMaterial wrong window_type"); return bReturn; } if (m_bAcceCombination) { for (int i = 0; i < ACCE_WINDOW_MAX_MATERIALS; ++i) { if (pkItemMaterial[i]) { if ((pkItemMaterial[i]->GetType() == ITEM_COSTUME) && (pkItemMaterial[i]->GetSubType() == COSTUME_ACCE)) bReturn = 1; else { bReturn = 0; break; } } else { bReturn = 0; break; } } } else if (m_bAcceAbsorption) { if ((pkItemMaterial[0]) && (pkItemMaterial[1])) { if ((pkItemMaterial[0]->GetType() == ITEM_COSTUME) && (pkItemMaterial[0]->GetSubType() == COSTUME_ACCE)) bReturn = 2; else bReturn = 0; if ((pkItemMaterial[1]->GetType() == ITEM_WEAPON) || ((pkItemMaterial[1]->GetType() == ITEM_ARMOR) && (pkItemMaterial[1]->GetSubType() == ARMOR_BODY))) bReturn = 2; else bReturn = 0; if (pkItemMaterial[0]->GetSocket(ACCE_ABSORBED_SOCKET) > 0) bReturn = 0; } else bReturn = 0; } return bReturn; } void CHARACTER::RefineAcceMaterials() { BYTE bCan = CanRefineAcceMaterials(); if (bCan == 0) return; auto pkItemMaterial = GetAcceMaterials(); DWORD dwItemVnum, dwMinAbs, dwMaxAbs; GetAcceCombineResult(dwItemVnum, dwMinAbs, dwMaxAbs); #ifdef ENABLE_YANG_LIMIT_SYSTEM long long llPrice = GetAcceCombinePrice(pkItemMaterial[0]->GetValue(ACCE_GRADE_VALUE_FIELD)); #else DWORD dwPrice = GetAcceCombinePrice(pkItemMaterial[0]->GetValue(ACCE_GRADE_VALUE_FIELD)); #endif if (bCan == 1) { int iSuccessChance = 0; long lVal = pkItemMaterial[0]->GetValue(ACCE_GRADE_VALUE_FIELD); switch (lVal) { case 2: { iSuccessChance = ACCE_COMBINE_GRADE_2; } break; case 3: { iSuccessChance = ACCE_COMBINE_GRADE_3; } break; case 4: { iSuccessChance = ACCE_COMBINE_GRADE_4; } break; default: { iSuccessChance = ACCE_COMBINE_GRADE_1; } break; } #ifdef ENABLE_YANG_LIMIT_SYSTEM if (GetGold() < llPrice) #else if (GetGold() < dwPrice) #endif { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You don't have enough Yang.")); return; } int iChance = number(1, 100); bool bSucces = (iChance <= iSuccessChance ? true : false); if (bSucces) { LPITEM pkItem = ITEM_MANAGER::instance().CreateItem(dwItemVnum, 1, 0, false); if (!pkItem) { sys_err("%d can't be created.", dwItemVnum); return; } ITEM_MANAGER::CopyAllAttrTo(pkItemMaterial[0], pkItem); LogManager::instance().ItemLog(this, pkItem, "COMBINE SUCCESS", pkItem->GetName()); DWORD dwAbs = (dwMinAbs == dwMaxAbs ? dwMinAbs : number(dwMinAbs + 1, dwMaxAbs)); pkItem->SetSocket(ACCE_ABSORPTION_SOCKET, dwAbs); pkItem->SetSocket(ACCE_ABSORBED_SOCKET, pkItemMaterial[0]->GetSocket(ACCE_ABSORBED_SOCKET)); pkItem->SetSocket(2, pkItemMaterial[0]->GetSocket(2)); #ifdef ENABLE_YANG_LIMIT_SYSTEM PointChange(POINT_GOLD, -llPrice); DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, pkItemMaterial[0]->GetVnum(), -llPrice); #else PointChange(POINT_GOLD, -dwPrice); DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, pkItemMaterial[0]->GetVnum(), -dwPrice); #endif WORD wCell = pkItemMaterial[0]->GetCell(); ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[0], "COMBINE (REFINE SUCCESS)"); ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[1], "COMBINE (REFINE SUCCESS)"); pkItem->AddToCharacter(this, TItemPos(INVENTORY, wCell)); ITEM_MANAGER::instance().FlushDelayedSave(pkItem); pkItem->AttrLog(); if (lVal == 4) ChatPacket(CHAT_TYPE_INFO, LC_TEXT("New absorption rate: %d%"), dwAbs); else ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Success.")); EffectPacket(SE_EFFECT_ACCE_SUCCEDED); LogManager::instance().AcceLog(GetPlayerID(), GetX(), GetY(), dwItemVnum, pkItem->GetID(), 1, dwAbs, 1); ClearAcceMaterials(); } else { #ifdef ENABLE_YANG_LIMIT_SYSTEM PointChange(POINT_GOLD, -llPrice); DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, pkItemMaterial[0]->GetVnum(), -llPrice); #else PointChange(POINT_GOLD, -dwPrice); DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, pkItemMaterial[0]->GetVnum(), -dwPrice); #endif ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[1], "COMBINE (REFINE FAIL)"); if (lVal == 4) ChatPacket(CHAT_TYPE_INFO, LC_TEXT("New absorption rate: %d%"), pkItemMaterial[0]->GetSocket(ACCE_ABSORPTION_SOCKET)); else ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Failed.")); LogManager::instance().AcceLog(GetPlayerID(), GetX(), GetY(), dwItemVnum, 0, 0, 0, 0); pkItemMaterial[1] = NULL; } TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketAcce sPacket; sPacket.header = HEADER_GC_ACCE; sPacket.subheader = ACCE_SUBHEADER_CG_REFINED; sPacket.bWindow = m_bAcceCombination == true ? true : false; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llPrice = llPrice; #else sPacket.dwPrice = dwPrice; #endif sPacket.bPos = 0; sPacket.tPos = tPos; sPacket.dwItemVnum = 0; sPacket.dwMinAbs = 0; if (bSucces) sPacket.dwMaxAbs = 100; else sPacket.dwMaxAbs = 0; GetDesc()->Packet(&sPacket, sizeof(TPacketAcce)); } else { pkItemMaterial[1]->CopyAttributeTo(pkItemMaterial[0]); LogManager::instance().ItemLog(this, pkItemMaterial[0], "ABSORB (REFINE SUCCESS)", pkItemMaterial[0]->GetName()); pkItemMaterial[0]->SetSocket(ACCE_ABSORBED_SOCKET, pkItemMaterial[1]->GetOriginalVnum()); for (int i = 0; i < ITEM_ATTRIBUTE_MAX_NUM; ++i) { if (pkItemMaterial[0]->GetAttributeValue(i) < 0) pkItemMaterial[0]->SetForceAttribute(i, pkItemMaterial[0]->GetAttributeType(i), 0); } ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[1], "ABSORBED (REFINE SUCCESS)"); ITEM_MANAGER::instance().FlushDelayedSave(pkItemMaterial[0]); pkItemMaterial[0]->AttrLog(); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Success.")); ClearAcceMaterials(); TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketAcce sPacket; sPacket.header = HEADER_GC_ACCE; sPacket.subheader = ACCE_SUBHEADER_CG_REFINED; sPacket.bWindow = m_bAcceCombination == true ? true : false; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llPrice = llPrice; #else sPacket.dwPrice = dwPrice; #endif sPacket.bPos = 255; sPacket.tPos = tPos; sPacket.dwItemVnum = 0; sPacket.dwMinAbs = 0; sPacket.dwMaxAbs = 1; GetDesc()->Packet(&sPacket, sizeof(TPacketAcce)); } } #ifdef ENABLE_FALL_FIX bool CHARACTER::CanFall() { if (IsAffectFlag(AFF_CHEONGEUN) && !IsAffectFlag(AFF_CHEONGEUN_WITH_FALL)) //Taichi skill return false; if (IsImmune(IMMUNE_FALL)) //Immune flag return false; if (!IsPC() && GetRaceNum() == 1097 && GetRaceNum() == 1098 && GetRaceNum() == 1099 && GetRaceNum() == 2496 && GetRaceNum() == 2497 && GetRaceNum() == 2498 ) return false; return true; } #endif bool CHARACTER::CleanAcceAttr(LPITEM pkItem, LPITEM pkTarget) { if (!CanHandleItem()) return false; else if ((!pkItem) || (!pkTarget)) return false; else if ((pkTarget->GetType() != ITEM_COSTUME) && (pkTarget->GetSubType() != COSTUME_ACCE)) return false; if (pkTarget->GetSocket(ACCE_ABSORBED_SOCKET) <= 0) return false; pkTarget->SetSocket(ACCE_ABSORBED_SOCKET, 0); for (int i = 0; i < ITEM_ATTRIBUTE_MAX_NUM; ++i) pkTarget->SetForceAttribute(i, 0, 0); pkItem->SetCount(pkItem->GetCount() - 1); LogManager::instance().ItemLog(this, pkTarget, "USE_DETACHMENT (CLEAN ATTR)", pkTarget->GetName()); return true; } #endif #ifdef ENABLE_MOUNT_COSTUME_SYSTEM void CHARACTER::MountSummon(LPITEM mountItem) { if (GetMapIndex() == 113) return; if (CWarMapManager::instance().IsWarMap(GetMapIndex())) return; if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true) return; CMountSystem* mountSystem = GetMountSystem(); DWORD mobVnum = 0; if (!mountSystem || !mountItem) return; #ifdef ENABLE_MOUNT_CHANGELOOK_SYSTEM TItemTable* pkItemTransmutation = ITEM_MANAGER::instance().GetTable(mountItem->GetTransmutation()); if (pkItemTransmutation) { /*for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i) { BYTE bType = pkItemTransmutation->aApplies[i].bType; long value = pkItemTransmutation->aApplies[i].lValue; }*/ mobVnum = pkItemTransmutation->alValues[4]; } else { if (mountItem->GetValue(4) != 0) mobVnum = mountItem->GetValue(4); } #else if (mountItem->GetValue(4) != 0) mobVnum = mountItem->GetValue(4); #endif if (IsHorseRiding()) StopRiding(); if (GetHorse()) HorseSummon(false); mountSystem->Summon(mobVnum, mountItem, false); } void CHARACTER::MountUnsummon(LPITEM mountItem) { CMountSystem* mountSystem = GetMountSystem(); DWORD mobVnum = 0; if (!mountSystem || !mountItem) return; #ifdef ENABLE_MOUNT_CHANGELOOK_SYSTEM TItemTable* pkItemTransmutation = ITEM_MANAGER::instance().GetTable(mountItem->GetTransmutation()); if (pkItemTransmutation) { /*for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i) { BYTE bType = pkItemTransmutation->aApplies[i].bType; long value = pkItemTransmutation->aApplies[i].lValue; }*/ mobVnum = pkItemTransmutation->alValues[4]; } else { if (mountItem->GetValue(4) != 0) mobVnum = mountItem->GetValue(4); } #else if (mountItem->GetValue(4) != 0) mobVnum = mountItem->GetValue(4); #endif if (GetMountVnum() == mobVnum) mountSystem->Unmount(mobVnum); mountSystem->Unsummon(mobVnum); } void CHARACTER::CheckMount() { if (GetMapIndex() == 113) return; if (CWarMapManager::instance().IsWarMap(GetMapIndex())) return; CMountSystem* mountSystem = GetMountSystem(); LPITEM mountItem = GetWear(WEAR_COSTUME_MOUNT); DWORD mobVnum = 0; if (!mountSystem || !mountItem) return; #ifdef ENABLE_MOUNT_CHANGELOOK_SYSTEM TItemTable* pkItemTransmutation = ITEM_MANAGER::instance().GetTable(mountItem->GetTransmutation()); if (pkItemTransmutation) { /*for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i) { BYTE bType = pkItemTransmutation->aApplies[i].bType; long value = pkItemTransmutation->aApplies[i].lValue; //mobVnum = pkItemTransmutation->alValues[4]; }*/ mobVnum = pkItemTransmutation->alValues[4]; } else // şuan yans?ma işler bonuslar da problem şçıkmaz ama bonuslar?vermiyorsa başka yerde problem var demektir { if (mountItem->GetValue(4) != 0) mobVnum = mountItem->GetValue(4); } #else if (mountItem->GetValue(4) != 0) mobVnum = mountItem->GetValue(4); #endif if (mountSystem->CountSummoned() == 0) { mountSystem->Summon(mobVnum, mountItem, false); } } bool CHARACTER::IsRidingMount() { return (GetWear(WEAR_COSTUME_MOUNT) || FindAffect(AFFECT_MOUNT)); } #endif #ifdef ENABLE_CHANNEL_SWITCH_SYSTEM bool CHARACTER::SwitchChannel(long newAddr, WORD newPort) { if (!IsPC() || !GetDesc() || !CanWarp()) return false; long x = GetX(); long y = GetY(); long lAddr = newAddr; long lMapIndex = GetMapIndex(); WORD wPort = newPort; // If we currently are in a dungeon. if (lMapIndex >= 10000) { sys_err("Invalid change channel request from dungeon %d!", lMapIndex); return false; } // If we are on CH99. if (g_bChannel == 99) { sys_err("%s attempted to change channel from CH99, ignoring req.", GetName()); return false; } Stop(); Save(); if (GetSectree()) { GetSectree()->RemoveEntity(this); ViewCleanup(); EncodeRemovePacket(this); } m_lWarpMapIndex = lMapIndex; m_posWarp.x = x; m_posWarp.y = y; // TODO: This log message should mention channel we are changing to instead of port. sys_log(0, "ChangeChannel %s, %ld %ld map %ld to port %d", GetName(), x, y, GetMapIndex(), wPort); TPacketGCWarp p; p.bHeader = HEADER_GC_WARP; p.lX = x; p.lY = y; p.lAddr = lAddr; p.wPort = wPort; GetDesc()->Packet(&p, sizeof(p)); char buf[256]; // TODO: This log message should mention channel we are changing to instead of port snprintf(buf, sizeof(buf), "%s Port%d Map%ld x%ld y%ld", GetName(), wPort, GetMapIndex(), x, y); LogManager::instance().CharLog(this, 0, "CHANGE_CH", buf); return true; } EVENTINFO(switch_channel_info) { DynamicCharacterPtr ch; int secs; long newAddr; WORD newPort; switch_channel_info() : ch(), secs(0), newAddr(0), newPort(0) { } }; EVENTFUNC(switch_channel) { switch_channel_info* info = dynamic_cast(event->info); if (!info) { sys_err("No switch channel event info!"); return 0; } LPCHARACTER ch = info->ch; if (!ch) { sys_err("No char to work on for the switch."); return 0; } if (!ch->GetDesc()) return 0; if (info->secs > 0) { ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Channel switch in %d seconds."), info->secs); --info->secs; return PASSES_PER_SEC(1); } ch->SwitchChannel(info->newAddr, info->newPort); ch->m_pkTimedEvent = nullptr; return 0; } bool CHARACTER::StartChannelSwitch(long newAddr, WORD newPort) { if (IsHack(false, true, 10)) return false; switch_channel_info* info = AllocEventInfo(); info->ch = this; info->secs = CanWarp() && !IsPosition(POS_FIGHTING) ? 3 : 10; info->newAddr = newAddr; info->newPort = newPort; m_pkTimedEvent = event_create(switch_channel, info, 1); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Channel switch starting.")); return true; } #endif bool CHARACTER::IsBoss() { switch (GetRaceNum()) { case 18040: case 18041: case 18042: case 18043: case 18044: case 18045: case 18046: case 18047: case 18048: case 18049: case 18050: case 18051: case 18052: case 18053: case 18054: case 18055: case 18056: case 18057: case 18058: case 18059: case 18060: case 18061: case 18062: case 18063: case 18064: case 18065: case 18066: case 18067: case 18068: case 18069: return true; } return false; } bool CHARACTER::CanTakeInventoryItem(LPITEM item, TItemPos * cell) { int iEmpty = -1; if (item->IsDragonSoul()) { cell->window_type = DRAGON_SOUL_INVENTORY; cell->cell = iEmpty = GetEmptyDragonSoulInventory(item); } #ifdef ENABLE_SPECIAL_STORAGE else if (item->IsUpgradeItem()) { cell->window_type = UPGRADE_INVENTORY; cell->cell = iEmpty = GetEmptyUpgradeInventory(item); } else if (item->IsBook()) { cell->window_type = BOOK_INVENTORY; cell->cell = iEmpty = GetEmptyBookInventory(item); } else if (item->IsStone()) { cell->window_type = STONE_INVENTORY; cell->cell = iEmpty = GetEmptyStoneInventory(item); } else if (item->IsChest()) { cell->window_type = CHEST_INVENTORY; cell->cell = iEmpty = GetEmptyChestInventory(item); } #endif else { cell->window_type = INVENTORY; cell->cell = iEmpty = GetEmptyInventory(item->GetSize()); } return iEmpty != -1; } #ifdef ENABLE_ALIGNMENT_SYSTEM void CHARACTER::OnAlignUpdate(long long lOldAlignment) { if (GetRealAlignment() >= 500000000) { if (lOldAlignment < 500000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 200, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 5000, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 5000, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 2500, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 490000000) { if (lOldAlignment < 490000000 && lOldAlignment >= 500000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 195, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 4900, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 4900, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 2450, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 480000000) { if (lOldAlignment < 480000000 && lOldAlignment >= 490000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 190, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 4800, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 4800, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 2400, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 470000000) { if (lOldAlignment < 470000000 && lOldAlignment >= 480000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 185, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 4700, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 4700, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 2350, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 460000000) { if (lOldAlignment < 460000000 && lOldAlignment >= 470000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 180, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 4600, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 4600, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 2300, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 450000000) { if (lOldAlignment < 450000000 && lOldAlignment >= 460000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 175, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 4500, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 4500, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 2250, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 440000000) { if (lOldAlignment < 440000000 && lOldAlignment >= 450000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 170, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 4400, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 4400, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 2200, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 430000000) { if (lOldAlignment < 430000000 && lOldAlignment >= 440000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 165, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 4300, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 4300, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 2150, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 420000000) { if (lOldAlignment < 420000000 && lOldAlignment >= 430000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 160, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 4200, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 4200, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 2100, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 410000000) { if (lOldAlignment < 410000000 && lOldAlignment >= 420000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 155, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 4100, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 4100, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 2050, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 400000000) { if (lOldAlignment < 400000000 && lOldAlignment >= 410000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 150, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 4000, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 4000, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 2000, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 390000000) { if (lOldAlignment < 390000000 && lOldAlignment >= 400000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 145, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 3900, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 3900, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1950, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 380000000) { if (lOldAlignment < 380000000 && lOldAlignment >= 390000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 140, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 3800, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 3800, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1900, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 370000000) { if (lOldAlignment < 370000000 && lOldAlignment >= 380000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 135, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 3700, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 3700, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1850, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 360000000) { if (lOldAlignment < 360000000 && lOldAlignment >= 370000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 130, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 3600, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 3600, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1800, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 350000000) { if (lOldAlignment < 350000000 && lOldAlignment >= 360000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 125, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 3500, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 3500, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1750, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 340000000) { if (lOldAlignment < 340000000 && lOldAlignment >= 350000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 120, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 3400, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 3400, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1700, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 330000000) { if (lOldAlignment < 330000000 && lOldAlignment >= 340000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 115, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 3300, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 3300, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1650, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 320000000) { if (lOldAlignment < 320000000 && lOldAlignment >= 330000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 110, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 3200, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 3200, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1600, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 310000000) { if (lOldAlignment < 310000000 && lOldAlignment >= 320000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 105, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 3100, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 3100, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1550, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 300000000) { if (lOldAlignment < 300000000 && lOldAlignment >= 310000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 100, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 3000, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 3000, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1500, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 290000000) { if (lOldAlignment < 290000000 && lOldAlignment >= 300000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 96, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 2900, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 2900, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1450, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 280000000) { if (lOldAlignment < 280000000 && lOldAlignment >= 290000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 92, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 2800, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 2800, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1400, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 270000000) { if (lOldAlignment < 270000000 && lOldAlignment >= 280000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 88, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 2700, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 2700, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1350, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 260000000) { if (lOldAlignment < 260000000 && lOldAlignment >= 270000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 84, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 2600, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 2600, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1300, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 250000000) { if (lOldAlignment < 250000000 && lOldAlignment >= 260000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 80, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 2500, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 2500, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1250, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 240000000) { if (lOldAlignment < 240000000 && lOldAlignment >= 250000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 76, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 2400, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 2400, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1200, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 230000000) { if (lOldAlignment < 230000000 && lOldAlignment >= 240000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 72, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 2300, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 2300, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1150, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 220000000) { if (lOldAlignment < 220000000 && lOldAlignment >= 230000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 68, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 2200, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 2200, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1100, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 210000000) { if (lOldAlignment < 210000000 && lOldAlignment >= 220000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 64, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 2100, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 2100, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1050, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 200000000) { if (lOldAlignment < 200000000 && lOldAlignment >= 210000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 60, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 2000, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 2000, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 1000, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 190000000) { if (lOldAlignment < 190000000 && lOldAlignment >= 200000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 57, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 1900, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 1900, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 950, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 180000000) { if (lOldAlignment < 180000000 && lOldAlignment >= 190000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 54, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 1800, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 1800, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 900, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 170000000) { if (lOldAlignment < 170000000 && lOldAlignment >= 180000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 51, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 1700, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 1700, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 850, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 160000000) { if (lOldAlignment < 160000000 && lOldAlignment >= 170000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 48, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 1600, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 1600, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 800, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 150000000) { if (lOldAlignment < 150000000 && lOldAlignment >= 160000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 45, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 1500, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 1500, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 750, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 140000000) { if (lOldAlignment < 140000000 && lOldAlignment >= 150000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 42, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 1400, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 1400, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 700, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 130000000) { if (lOldAlignment < 130000000 && lOldAlignment >= 140000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 39, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 1300, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 1300, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 650, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 120000000) { if (lOldAlignment < 120000000 && lOldAlignment >= 130000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 36, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 1200, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 1200, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 600, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 110000000) { if (lOldAlignment < 110000000 && lOldAlignment >= 120000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 33, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 1100, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 1100, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 550, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 100000000) { if (lOldAlignment < 100000000 && lOldAlignment >= 110000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 30, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 1000, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 1000, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 500, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 90000000) { if (lOldAlignment < 90000000 && lOldAlignment >= 100000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 27, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 900, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 900, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 450, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 80000000) { if (lOldAlignment < 80000000 && lOldAlignment >= 90000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 24, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 800, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 800, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 40, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 70000000) { if (lOldAlignment < 70000000 && lOldAlignment >= 80000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 21, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 700, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 700, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 350, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 60000000) { if (lOldAlignment < 60000000 && lOldAlignment >= 70000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 18, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 600, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 600, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 300, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 50000000) { if (lOldAlignment < 50000000 && lOldAlignment >= 60000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 15, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 500, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 500, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 250, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 40000000) { if (lOldAlignment < 40000000 && lOldAlignment >= 50000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 12, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 400, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 400, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 200, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 30000000) { if (lOldAlignment < 30000000 && lOldAlignment >= 40000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 9, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 300, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 300, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 150, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 20000000) { if (lOldAlignment < 20000000 && lOldAlignment >= 30000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 6, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 200, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 200, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 100, 0, 60 * 60 * 60 * 365, 0, true); } else if (GetRealAlignment() >= 10000000) { if (lOldAlignment < 10000000 && lOldAlignment >= 20000000) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } AddAffect(AFFECT_ALIGN_BONUS1, POINT_NORMAL_HIT_DAMAGE_BONUS, 3, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS2, POINT_ATTBONUS_MONSTER, 100, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS3, POINT_ATTBONUS_STONE, 100, 0, 60 * 60 * 60 * 365, 0, true); AddAffect(AFFECT_ALIGN_BONUS4, POINT_ATTBONUS_BOSS, 50, 0, 60 * 60 * 60 * 365, 0, true); } else { if (lOldAlignment >= 10000000 && GetRealAlignment() >= 0) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } else if (lOldAlignment >= 0 && GetRealAlignment() < 0) { RemoveAffect(AFFECT_ALIGN_BONUS1); RemoveAffect(AFFECT_ALIGN_BONUS2); RemoveAffect(AFFECT_ALIGN_BONUS3); RemoveAffect(AFFECT_ALIGN_BONUS4); } } //UpdatePacket(); } #endif #ifdef ENABLE_AURA_SYSTEM bool CHARACTER::IsOpenAura() { if (m_bAuraRefine || m_bAuraAbsorption) return true; return false; } void CHARACTER::OpenAura(bool bCombination) { if (isAuraOpened(bCombination)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("The aura window it's already opened.")); return; } if (bCombination) { if (m_bAuraAbsorption) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Before you may close the aura absorption window.")); return; } m_bAuraRefine = true; } else { if (m_bAuraRefine) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Before you may close the aura combine window.")); return; } m_bAuraAbsorption = true; } TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketAura sPacket; sPacket.header = HEADER_GC_AURA; sPacket.subheader = AURA_SUBHEADER_GC_OPEN; sPacket.bWindow = bCombination; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llPrice = 0; #else sPacket.dwPrice = 0; #endif sPacket.bPos = 0; sPacket.tPos = tPos; sPacket.dwItemVnum = 0; sPacket.dwMinAbs = 0; sPacket.dwMaxAbs = 0; GetDesc()->Packet(&sPacket, sizeof(TPacketAura)); ClearAuraMaterials(); } void CHARACTER::CloseAura() { if ((!m_bAuraRefine) && (!m_bAuraAbsorption)) return; bool bWindow = (m_bAuraRefine == true ? true : false); TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketAura sPacket; sPacket.header = HEADER_GC_AURA; sPacket.subheader = AURA_SUBHEADER_GC_CLOSE; sPacket.bWindow = bWindow; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llPrice = 0; #else sPacket.dwPrice = 0; #endif sPacket.bPos = 0; sPacket.tPos = tPos; sPacket.dwItemVnum = 0; sPacket.dwMinAbs = 0; sPacket.dwMaxAbs = 0; GetDesc()->Packet(&sPacket, sizeof(TPacketAura)); if (bWindow) m_bAuraRefine = false; else m_bAuraAbsorption = false; ClearAuraMaterials(); } void CHARACTER::ClearAuraMaterials() { LPITEM* pkItemMaterial; pkItemMaterial = GetAuraMaterials(); for (int i = 0; i < AURA_WINDOW_MAX_MATERIALS; ++i) { if (!pkItemMaterial[i]) continue; pkItemMaterial[i]->Lock(false); pkItemMaterial[i] = NULL; } } bool CHARACTER::AuraIsSameGrade(long lGrade) { LPITEM* pkItemMaterial; pkItemMaterial = GetAuraMaterials(); if (!pkItemMaterial[0]) return false; bool bReturn = (pkItemMaterial[0]->GetValue(AURA_GRADE_VALUE_FIELD) == lGrade ? true : false); return bReturn; } #ifdef ENABLE_YANG_LIMIT_SYSTEM long long CHARACTER::GetAuraCombinePrice(long lGrade) #else DWORD CHARACTER::GetAuraCombinePrice(long lGrade) #endif { #ifdef ENABLE_YANG_LIMIT_SYSTEM long long llPrice = AURA_REFINE_PRICE; return llPrice; #else DWORD dwPrice = AURA_REFINE_PRICE; return dwPrice; #endif } BYTE CHARACTER::CheckAuraEmptyMaterialSlot() { LPITEM* pkItemMaterial; pkItemMaterial = GetAuraMaterials(); for (int i = 0; i < AURA_WINDOW_MAX_MATERIALS; ++i) { if (!pkItemMaterial[i]) return i; } return 255; } void CHARACTER::GetAuraCombineResult(DWORD & dwItemVnum, DWORD & dwMinAbs, DWORD & dwMaxAbs) { LPITEM* pkItemMaterial; pkItemMaterial = GetAuraMaterials(); if (m_bAuraRefine) { if ((pkItemMaterial[0]) && (pkItemMaterial[1])) { long lVal = pkItemMaterial[0]->GetValue(AURA_TYPE_VALUE_FIELD); if (lVal == 6) { dwItemVnum = pkItemMaterial[0]->GetOriginalVnum(); } else { DWORD dwMaskVnum = pkItemMaterial[0]->GetOriginalVnum(); TItemTable* pTable = ITEM_MANAGER::instance().GetTable(dwMaskVnum + 1); if (pTable) dwMaskVnum += 1; dwItemVnum = dwMaskVnum; } } else { dwItemVnum = 0; dwMinAbs = 0; dwMaxAbs = 0; } } else { if ((pkItemMaterial[0]) && (pkItemMaterial[1])) { dwItemVnum = pkItemMaterial[0]->GetOriginalVnum(); dwMinAbs = pkItemMaterial[0]->GetSocket(AURA_ABSORPTION_SOCKET); dwMaxAbs = dwMinAbs; } else { dwItemVnum = 0; dwMinAbs = 0; dwMaxAbs = 0; } } } void CHARACTER::AddAuraMaterial(TItemPos tPos, BYTE bPos) { if (bPos >= AURA_WINDOW_MAX_MATERIALS) { if (bPos == 255) { bPos = CheckEmptyMaterialSlot(); if (bPos >= AURA_WINDOW_MAX_MATERIALS) return; } else return; } LPITEM pkItem = GetItem(tPos); if (!pkItem) return; else if ((pkItem->GetCell() >= INVENTORY_MAX_NUM) || (pkItem->IsEquipped()) || (tPos.IsBeltInventoryPosition()) || (pkItem->IsDragonSoul())) return; else if ((pkItem->GetType() != ITEM_COSTUME && pkItem->GetType() != COSTUME_AURA) && (bPos == 0) && (m_bAuraRefine)) return; else if ((pkItem->GetType() != ITEM_COSTUME && pkItem->GetType() != COSTUME_AURA) && (bPos == 0) && (m_bAuraAbsorption)) return; else if (pkItem->isLocked()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't add locked items.")); return; } #ifdef ENABLE_ITEM_SEALBIND_SYSTEM else if ((pkItem->IsSealed())) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't add binded items.")); return; } #endif #ifdef ENABLE_BASIC_ITEM_SYSTEM else if (pkItem->IsBasicItem()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ITEM_IS_BASIC_CANNOT_DO")); return; } #endif else if ((m_bAuraRefine) && (pkItem->GetSocket(AURA_ABSORPTION_SOCKET) >= AURA_MAX_ABS)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This aura got already maximum absorption chance.")); return; } else if ((bPos == 1) && (m_bAuraAbsorption)) { if ((pkItem->GetType() != ITEM_ARMOR)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aura You can absorb just the bonuses from armors and weapons.")); return; } else if ((pkItem->GetType() == ITEM_ARMOR) && (pkItem->GetSubType() != ARMOR_SHIELD) && (pkItem->GetSubType() != ARMOR_EAR) && (pkItem->GetSubType() != ARMOR_WRIST) && (pkItem->GetSubType() != ARMOR_NECK)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aura You can absorb just the bonuses from armors and weapons.")); return; } } else if ((bPos == 1) && (m_bAuraRefine)) { if ((pkItem->GetVnum() != AURA_ICE_RUNIC)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aura Only Refine Material Ice Runic")); return; } } else if ((pkItem->GetSubType() != COSTUME_AURA) && (m_bAuraAbsorption)) return; else if ((pkItem->GetSubType() != COSTUME_AURA) && (bPos == 0) && (m_bAuraAbsorption)) return; else if ((pkItem->GetSocket(AURA_ABSORBED_SOCKET) > 0) && (bPos == 0) && (m_bAuraAbsorption)) return; LPITEM* pkItemMaterial; pkItemMaterial = GetAuraMaterials(); if ((bPos == 1) && (!pkItemMaterial[0])) return; if (pkItemMaterial[bPos]) return; pkItemMaterial[bPos] = pkItem; pkItemMaterial[bPos]->Lock(true); DWORD dwItemVnum, dwMinAbs, dwMaxAbs; GetAuraCombineResult(dwItemVnum, dwMinAbs, dwMaxAbs); TPacketAura sPacket; sPacket.header = HEADER_GC_AURA; sPacket.subheader = AURA_SUBHEADER_GC_ADDED; sPacket.bWindow = m_bAuraRefine == true ? true : false; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llPrice = GetAuraCombinePrice(pkItem->GetValue(AURA_GRADE_VALUE_FIELD)); #else sPacket.dwPrice = GetAuraCombinePrice(pkItem->GetValue(AURA_GRADE_VALUE_FIELD)); #endif sPacket.bPos = bPos; sPacket.tPos = tPos; sPacket.dwItemVnum = dwItemVnum; sPacket.dwMinAbs = dwMinAbs; sPacket.dwMaxAbs = dwMaxAbs; GetDesc()->Packet(&sPacket, sizeof(TPacketAura)); } void CHARACTER::RemoveAuraMaterial(BYTE bPos) { if (bPos >= AURA_WINDOW_MAX_MATERIALS) return; LPITEM* pkItemMaterial; pkItemMaterial = GetAuraMaterials(); //sPacket.bWindow = m_bAuraRefine == true ? true : false; #ifdef ENABLE_YANG_LIMIT_SYSTEM long long llPrice = 0; #else DWORD dwPrice = 0; #endif if (bPos == 1) { if (pkItemMaterial[bPos]) { pkItemMaterial[bPos]->Lock(false); pkItemMaterial[bPos] = NULL; } if (pkItemMaterial[0]) #ifdef ENABLE_YANG_LIMIT_SYSTEM llPrice = GetAuraCombinePrice(pkItemMaterial[0]->GetValue(AURA_GRADE_VALUE_FIELD)); #else dwPrice = GetAuraCombinePrice(pkItemMaterial[0]->GetValue(AURA_GRADE_VALUE_FIELD)); #endif } else ClearAuraMaterials(); TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketAura sPacket; sPacket.header = HEADER_GC_AURA; sPacket.subheader = AURA_SUBHEADER_GC_REMOVED; sPacket.bWindow = m_bAuraRefine == true ? true : false; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llPrice = llPrice; #else sPacket.dwPrice = dwPrice; #endif sPacket.bPos = bPos; sPacket.tPos = tPos; sPacket.dwItemVnum = 0; sPacket.dwMinAbs = 0; sPacket.dwMaxAbs = 0; GetDesc()->Packet(&sPacket, sizeof(TPacketAura)); } BYTE CHARACTER::CanRefineAuraMaterials() { BYTE bReturn = 0; LPITEM* pkItemMaterial = GetAuraMaterials(); if (m_bAuraRefine) { for (int i = 0; i < AURA_WINDOW_MAX_MATERIALS; ++i) { if (pkItemMaterial[i] != NULL) { if ((pkItemMaterial[i]->GetType() == ITEM_COSTUME) && (pkItemMaterial[i]->GetSubType() == COSTUME_AURA)) bReturn = 1; else if ((pkItemMaterial[i]->GetVnum() == AURA_ICE_RUNIC)) bReturn = 1; else { bReturn = 0; break; } } else { bReturn = 0; break; } } } else if (m_bAuraAbsorption) { if ((pkItemMaterial[0]) && (pkItemMaterial[1])) { if ((pkItemMaterial[0]->GetType() == ITEM_COSTUME) && (pkItemMaterial[0]->GetSubType() == COSTUME_AURA)) bReturn = 2; else bReturn = 0; if ((pkItemMaterial[1]->GetType() == ITEM_ARMOR) && ((pkItemMaterial[1]->GetSubType() == ARMOR_EAR) || (pkItemMaterial[1]->GetSubType() == ARMOR_WRIST) || (pkItemMaterial[1]->GetSubType() == ARMOR_NECK) || (pkItemMaterial[1]->GetSubType() == ARMOR_SHIELD))) bReturn = 2; else bReturn = 0; if (pkItemMaterial[0]->GetSocket(AURA_ABSORBED_SOCKET) > 0) bReturn = 0; } else bReturn = 0; } return bReturn; } void CHARACTER::RefineAuraMaterials() { BYTE bCan = CanRefineAuraMaterials(); if (bCan == 0) return; LPITEM* pkItemMaterial; pkItemMaterial = GetAuraMaterials(); if (!pkItemMaterial[0] || !pkItemMaterial[1]) return; DWORD dwItemVnum, dwMinAbs, dwMaxAbs; GetAuraCombineResult(dwItemVnum, dwMinAbs, dwMaxAbs); #ifdef ENABLE_YANG_LIMIT_SYSTEM long long llPrice = AURA_REFINE_PRICE; #else DWORD dwPrice = AURA_REFINE_PRICE; #endif if (bCan == 1) { int iSuccessChance = 0; long lVal = pkItemMaterial[0]->GetValue(AURA_TYPE_VALUE_FIELD); switch (lVal) { case 2: { iSuccessChance = AURA_GRADE_2_REFINE; } break; case 3: { iSuccessChance = AURA_GRADE_3_REFINE; } break; case 4: { iSuccessChance = AURA_GRADE_4_REFINE; } break; case 5: { iSuccessChance = AURA_GRADE_5_REFINE; } break; case 6: { iSuccessChance = AURA_GRADE_6_REFINE; } break; default: { iSuccessChance = AURA_GRADE_1_REFINE; } break; } #ifdef ENABLE_YANG_LIMIT_SYSTEM if (GetGold() < llPrice) #else if (GetGold() < dwPrice) #endif { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aura You don't have enough Yang.")); return; } int iChance = number(1, 100); bool bSucces = (iChance <= iSuccessChance ? true : false); if (pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) != 49 && pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) != 99 && pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) != 149 && pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) != 199 && pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) != 249) bSucces = true; int oldGradeValue = pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD); bool bPacket = true; if (bSucces) { if (pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) != 49 && pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) != 99 && pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) != 149 && pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) != 199 && pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) != 249) { #ifdef ENABLE_YANG_LIMIT_SYSTEM PointChange(POINT_GOLD, -llPrice); #else PointChange(POINT_GOLD, -dwPrice); #endif pkItemMaterial[0]->SetSocket(AURA_ABSORPTION_SOCKET, pkItemMaterial[0]->GetSocket(AURA_ABSORPTION_SOCKET) + 1); pkItemMaterial[0]->SetSocket(AURA_GRADE_VALUE_FIELD, pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) + 1); bool bDelete = false; if (pkItemMaterial[1]->GetCount() - 1 < 1) bDelete = true; pkItemMaterial[1]->SetCount(pkItemMaterial[1]->GetCount() - 1); if (bDelete == true) pkItemMaterial[1] = NULL; ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aura Success.")); } else { LPITEM pkItem = ITEM_MANAGER::instance().CreateItem(dwItemVnum, 1, 0, false); if (!pkItem) { sys_err("%d can't be created.", dwItemVnum); return; } ITEM_MANAGER::CopyAllAttrTo(pkItemMaterial[0], pkItem); LogManager::instance().ItemLog(this, pkItem, "AURA REFINE SUCCESS", pkItem->GetName()); pkItem->SetSocket(AURA_ABSORPTION_SOCKET, pkItem->GetSocket(AURA_ABSORPTION_SOCKET) + 1); pkItem->SetSocket(AURA_ABSORBED_SOCKET, pkItemMaterial[0]->GetSocket(AURA_ABSORBED_SOCKET)); pkItem->SetSocket(AURA_GRADE_VALUE_FIELD, pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) + 1); #ifdef ENABLE_YANG_LIMIT_SYSTEM PointChange(POINT_GOLD, -llPrice); DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, pkItemMaterial[0]->GetVnum(), -llPrice); #else PointChange(POINT_GOLD, -dwPrice); DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, pkItemMaterial[0]->GetVnum(), -dwPrice); #endif WORD wCell = pkItemMaterial[0]->GetCell(); ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[0], "AURA (REFINE SUCCESS)"); pkItemMaterial[1]->SetCount(pkItemMaterial[1]->GetCount() - 1); pkItem->AddToCharacter(this, TItemPos(INVENTORY, wCell)); ITEM_MANAGER::instance().FlushDelayedSave(pkItem); #ifndef ENABLE_LOG_RENEWAL pkItem->AttrLog(); #endif if (lVal == 6) ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aura New absorption rate: %2f%"), float(pkItem->GetSocket(AURA_ABSORPTION_SOCKET) / 10.0f)); else ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aura Success.")); ClearAuraMaterials(); bPacket = false; } } else { #ifdef ENABLE_YANG_LIMIT_SYSTEM PointChange(POINT_GOLD, -llPrice); pkItemMaterial[1]->SetCount(pkItemMaterial[1]->GetCount() - 1); DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, pkItemMaterial[0]->GetVnum(), -llPrice); #else PointChange(POINT_GOLD, -dwPrice); pkItemMaterial[1]->SetCount(pkItemMaterial[1]->GetCount() - 1); DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, pkItemMaterial[0]->GetVnum(), -dwPrice); #endif //ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[1], "COMBINE (REFINE FAIL)"); if (lVal == 6) ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aura New absorption rate: %d%"), pkItemMaterial[0]->GetSocket(AURA_ABSORPTION_SOCKET)); else ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aura Failed.")); if (pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) == 50 || pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) == 100 || pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) == 150 || pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) == 200 || pkItemMaterial[0]->GetSocket(AURA_GRADE_VALUE_FIELD) == 250) ClearAuraMaterials(); bPacket = false; } TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketAura sPacket; sPacket.header = HEADER_GC_AURA; sPacket.subheader = AURA_SUBHEADER_GC_REFINED; sPacket.bWindow = m_bAuraRefine == true ? true : false; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llPrice = llPrice; #else sPacket.dwPrice = dwPrice; #endif if (pkItemMaterial[0]) { if (bPacket) if (oldGradeValue != 49 && oldGradeValue != 99 && oldGradeValue != 149 && oldGradeValue != 199 && oldGradeValue != 249) sPacket.bPos = 255; else sPacket.bPos = 0; else sPacket.bPos = 0; } else sPacket.bPos = 0; sPacket.tPos = tPos; sPacket.dwItemVnum = 0; sPacket.dwMinAbs = 0; if (bSucces) sPacket.dwMaxAbs = 100; else sPacket.dwMaxAbs = 0; GetDesc()->Packet(&sPacket, sizeof(TPacketAura)); } else { pkItemMaterial[1]->CopyAttributeTo(pkItemMaterial[0]); LogManager::instance().ItemLog(this, pkItemMaterial[0], "ABSORB (REFINE SUCCESS)", pkItemMaterial[0]->GetName()); pkItemMaterial[0]->SetSocket(AURA_ABSORBED_SOCKET, pkItemMaterial[1]->GetOriginalVnum()); for (int i = 0; i < ITEM_ATTRIBUTE_MAX_NUM; ++i) { if (pkItemMaterial[0]->GetAttributeValue(i) < 0) pkItemMaterial[0]->SetForceAttribute(i, pkItemMaterial[0]->GetAttributeType(i), 0); } ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[1], "ABSORBED (REFINE SUCCESS)"); ITEM_MANAGER::instance().FlushDelayedSave(pkItemMaterial[0]); #ifndef ENABLE_LOG_RENEWAL pkItemMaterial[0]->AttrLog(); #endif ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aura Success.")); ClearAuraMaterials(); TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketAura sPacket; sPacket.header = HEADER_GC_AURA; sPacket.subheader = AURA_SUBHEADER_GC_REFINED; sPacket.bWindow = m_bAuraRefine == true ? true : false; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llPrice = llPrice; #else sPacket.dwPrice = dwPrice; #endif sPacket.bPos = 255; sPacket.tPos = tPos; sPacket.dwItemVnum = 0; sPacket.dwMinAbs = 0; sPacket.dwMaxAbs = 1; GetDesc()->Packet(&sPacket, sizeof(TPacketAura)); } } bool CHARACTER::CleanAuraAttr(LPITEM pkItem, LPITEM pkTarget) { if (!CanHandleItem()) return false; else if ((!pkItem) || (!pkTarget)) return false; else if ((pkTarget->GetType() != ITEM_COSTUME) && (pkTarget->GetSubType() != COSTUME_AURA)) return false; if (pkTarget->GetSocket(AURA_ABSORBED_SOCKET) <= 0) return false; pkTarget->SetSocket(AURA_ABSORBED_SOCKET, 0); for (int i = 0; i < ITEM_ATTRIBUTE_MAX_NUM; ++i) pkTarget->SetForceAttribute(i, 0, 0); pkItem->SetCount(pkItem->GetCount() - 1); LogManager::instance().ItemLog(this, pkTarget, "USE_DETACHMENT (CLEAN ATTR)", pkTarget->GetName()); return true; } #endif #ifdef ENABLE_SKILL_COLOR_SYSTEM void CHARACTER::SetSkillColor(DWORD * dwSkillColor) { memcpy(m_dwSkillColor, dwSkillColor, sizeof(m_dwSkillColor)); UpdatePacket(); } #endif #ifdef ENABLE_CHANGELOOK_SYSTEM #ifdef ENABLE_MOUNT_CHANGELOOK_SYSTEM void CHARACTER::ChangeLookWindow(bool bOpen, bool bRequest, bool bMount) #else void CHARACTER::ChangeLookWindow(bool bOpen, bool bRequest) #endif { if ((bOpen) && (isChangeLookOpened())) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] The window is already opened.")); return; } if ((!bOpen) && (!isChangeLookOpened())) { if (!bRequest) ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] The window is not opened.")); return; } TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketChangeLook sPacket; sPacket.header = HEADER_GC_CL; sPacket.subheader = CL_SUBHEADER_OPEN; sPacket.subheader = bOpen == true ? CL_SUBHEADER_OPEN : CL_SUBHEADER_CLOSE; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llCost = bOpen == true ? CL_TRANSMUTATION_PRICE : 0; #else sPacket.dwCost = bOpen == true ? CL_TRANSMUTATION_PRICE : 0; #endif sPacket.bPos = 0; sPacket.tPos = tPos; #ifdef ENABLE_MOUNT_CHANGELOOK_SYSTEM sPacket.bMount = bMount; #endif GetDesc()->Packet(&sPacket, sizeof(TPacketChangeLook)); m_bChangeLook = bOpen; #ifdef ENABLE_MOUNT_CHANGELOOK_SYSTEM m_bMountChangeLook = bMount; #endif ClearClWindowMaterials(); } void CHARACTER::ClearClWindowMaterials() { LPITEM* pkItemMaterial; pkItemMaterial = GetClWindowMaterials(); for (int i = 0; i < CL_WINDOW_MAX_MATERIALS; ++i) { if (!pkItemMaterial[i]) continue; pkItemMaterial[i]->Lock(false); pkItemMaterial[i] = NULL; } } BYTE CHARACTER::CheckClEmptyMaterialSlot() { LPITEM* pkItemMaterial; pkItemMaterial = GetClWindowMaterials(); for (int i = 0; i < CL_WINDOW_MAX_MATERIALS; ++i) { if (!pkItemMaterial[i]) return i; } return 255; } void CHARACTER::AddClMaterial(TItemPos tPos, BYTE bPos) { if (!isChangeLookOpened()) return; else if (bPos >= CL_WINDOW_MAX_MATERIALS) { if (bPos != 255) return; LPITEM pkScroll = GetItem(tPos); if (!pkScroll) return; //@fixme if (pkScroll->GetVnum() == CL_SCROLL_VNUM) bPos = 2; else bPos = CheckClEmptyMaterialSlot(); //@fixme if (bPos >= CL_WINDOW_MAX_MATERIALS) return; } LPITEM pkItem = GetItem(tPos); if (!pkItem) return; if ((pkItem->GetCell() >= INVENTORY_MAX_NUM) || (tPos.IsBeltInventoryPosition())) return; if (pkItem->IsEquipped()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] You cannot transmute an item while it is equipped.")); return; } if ((bPos == 2 && pkItem->GetVnum() != CL_SCROLL_VNUM) || (bPos != 2 && pkItem->GetVnum() == CL_SCROLL_VNUM)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] This item cannot be transmuted.")); return; } if (pkItem->GetVnum() != CL_SCROLL_VNUM) { #ifdef ENABLE_MOUNT_CHANGELOOK_SYSTEM if (m_bMountChangeLook == true) { if (!pkItem->IsMountItem()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] This item cannot be transmuted.")); return; } #ifdef ENABLE_ITEM_SEALBIND_SYSTEM else if ((pkItem->IsSealed())) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] You can't add binded items.")); return; } #endif else if (pkItem->GetTransmutation() != 0) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] You can't add items which are transmuted yet.")); return; } } else #endif { if ((pkItem->GetType() != ITEM_WEAPON) && (pkItem->GetType() != ITEM_ARMOR) && (pkItem->GetType() != ITEM_COSTUME) && (pkItem->GetType() != ITEM_UNIQUE) && (!pkItem->IsPetItem())) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] This item cannot be transmuted.")); return; } #ifdef ENABLE_QUIVER_SYSTEM else if ((pkItem->GetType() == ITEM_WEAPON) && ((pkItem->GetSubType() == WEAPON_ARROW) || (pkItem->GetSubType() == WEAPON_MOUNT_SPEAR) || (pkItem->GetSubType() == WEAPON_QUIVER))) #else else if ((pkItem->GetType() == ITEM_WEAPON) && ((pkItem->GetSubType() == WEAPON_ARROW) || (pkItem->GetSubType() == WEAPON_MOUNT_SPEAR))) #endif { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] This item cannot be transmuted.")); return; } else if ((pkItem->GetType() == ITEM_ARMOR) && (pkItem->GetSubType() != ARMOR_BODY)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] This item cannot be transmuted.")); return; } else if ((pkItem->GetType() == ITEM_COSTUME) && (pkItem->GetSubType() != COSTUME_BODY) && (pkItem->GetSubType() != COSTUME_HAIR) && (pkItem->GetSubType() != COSTUME_WEAPON)) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] This item cannot be transmuted.")); return; } #ifdef ENABLE_ITEM_SEALBIND_SYSTEM else if ((pkItem->IsSealed())) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] You can't add binded items.")); return; } #endif else if (pkItem->GetTransmutation() != 0) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] You can't add items which are transmuted yet.")); return; } } } LPITEM* pkItemMaterial; pkItemMaterial = GetClWindowMaterials(); if ((bPos == 1) && (!pkItemMaterial[0])) return; if (pkItemMaterial[bPos]) return; #ifdef ENABLE_MOUNT_CHANGELOOK_SYSTEM if (m_bMountChangeLook) { if (bPos == 1) { bool bStop = true; if (pkItem->IsMountItem() && pkItemMaterial[0]->IsMountItem()) bStop = false; if (pkItemMaterial[0]->GetOriginalVnum() == pkItem->GetOriginalVnum()) bStop = true; if (bStop) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] You cannot submit this item.")); return; } } } else #endif { if (bPos == 1) { bool bStop = false; if ((pkItem->GetType() != pkItemMaterial[0]->GetType())) { if ((pkItem->GetType() == ITEM_COSTUME && pkItem->GetSubType() == COSTUME_BODY) && (pkItemMaterial[0]->GetType() == ITEM_ARMOR && pkItemMaterial[0]->GetSubType() == ARMOR_BODY)) bStop = false; else if ((pkItem->GetType() == ITEM_COSTUME && pkItem->GetSubType() == COSTUME_WEAPON) && (pkItemMaterial[0]->GetType() == ITEM_WEAPON)) bStop = false; else if ((pkItem->GetType() == ITEM_COSTUME && pkItem->GetSubType() == COSTUME_BODY) && (pkItemMaterial[0]->GetType() == ITEM_COSTUME && pkItemMaterial[0]->GetSubType() == COSTUME_BODY)) bStop = false; else if ((pkItem->GetType() == ITEM_COSTUME && pkItem->GetSubType() == COSTUME_HAIR) && (pkItemMaterial[0]->GetType() == ITEM_COSTUME && pkItemMaterial[0]->GetSubType() == COSTUME_HAIR)) bStop = false; else if ((pkItem->GetType() == ITEM_COSTUME && pkItem->GetSubType() == COSTUME_WEAPON) && (pkItemMaterial[0]->GetType() == ITEM_COSTUME && pkItemMaterial[0]->GetSubType() == COSTUME_WEAPON)) bStop = false; else if ((pkItem->GetType() == ITEM_ARMOR && pkItem->GetSubType() == ARMOR_BODY) && (pkItemMaterial[0]->GetType() == ITEM_COSTUME && pkItemMaterial[0]->GetSubType() == COSTUME_BODY)) bStop = false; else if ((pkItem->GetType() == ITEM_WEAPON) && (pkItemMaterial[0]->GetType() == ITEM_COSTUME && pkItemMaterial[0]->GetSubType() == COSTUME_WEAPON)) bStop = false; else if ((pkItem->IsPetItem()) && pkItemMaterial[0]->IsPetItem()) bStop = false; else bStop = true; } else { if (pkItemMaterial[0]->GetType() != pkItem->GetType()) bStop = true; else if (pkItemMaterial[0]->GetSubType() != pkItem->GetSubType()) bStop = true; } if (pkItemMaterial[0]->GetOriginalVnum() == pkItem->GetOriginalVnum()) bStop = true; else if (((IS_SET(pkItemMaterial[0]->GetAntiFlag(), ITEM_ANTIFLAG_FEMALE)) && (!IS_SET(pkItem->GetAntiFlag(), ITEM_ANTIFLAG_FEMALE))) || ((IS_SET(pkItemMaterial[0]->GetAntiFlag(), ITEM_ANTIFLAG_MALE)) && (!IS_SET(pkItem->GetAntiFlag(), ITEM_ANTIFLAG_MALE)))) bStop = true; else if ((pkItem->GetAntiFlag() & ITEM_ANTIFLAG_WARRIOR) && (!IS_SET(pkItemMaterial[0]->GetAntiFlag(), ITEM_ANTIFLAG_WARRIOR))) bStop = true; else if ((pkItem->GetAntiFlag() & ITEM_ANTIFLAG_ASSASSIN) && (!IS_SET(pkItemMaterial[0]->GetAntiFlag(), ITEM_ANTIFLAG_ASSASSIN))) bStop = true; else if ((pkItem->GetAntiFlag() & ITEM_ANTIFLAG_SHAMAN) && (!IS_SET(pkItemMaterial[0]->GetAntiFlag(), ITEM_ANTIFLAG_SHAMAN))) bStop = true; else if ((pkItem->GetAntiFlag() & ITEM_ANTIFLAG_SURA) && (!IS_SET(pkItemMaterial[0]->GetAntiFlag(), ITEM_ANTIFLAG_SURA))) bStop = true; else if ((pkItem->GetType() == ITEM_COSTUME && pkItemMaterial[0]->GetType() == ITEM_COSTUME) && ((pkItem->GetType() == ITEM_COSTUME && pkItem->GetSubType() == COSTUME_WEAPON) && (pkItemMaterial[0]->GetType() == ITEM_COSTUME && pkItemMaterial[0]->GetSubType() == COSTUME_WEAPON))) { if (pkItem->GetValue(3) != pkItemMaterial[0]->GetValue(3)) bStop = true; } // Yansitma Fix Suky else if ((pkItem->GetType() == ITEM_WEAPON && pkItemMaterial[0]->GetType() == ITEM_COSTUME) && ((pkItem->GetType() == ITEM_WEAPON && ((pkItemMaterial[0]->GetType() == ITEM_COSTUME && pkItemMaterial[0]->GetSubType() == COSTUME_WEAPON))))) { if (pkItem->GetType() != pkItemMaterial[0]->GetValue(3)) bStop = true; } else if ((pkItem->GetType() == ITEM_COSTUME && pkItemMaterial[0]->GetType() == ITEM_WEAPON) && ((pkItem->GetType() == ITEM_COSTUME && pkItem->GetSubType() == COSTUME_WEAPON) && ((pkItemMaterial[0]->GetType() == ITEM_WEAPON)))) { if (pkItem->GetValue(3) != pkItemMaterial[0]->GetType()) bStop = true; } if (bStop) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] You cannot submit this item.")); return; } } } pkItemMaterial[bPos] = pkItem; pkItemMaterial[bPos]->Lock(true); TPacketChangeLook sPacket; sPacket.header = HEADER_GC_CL; sPacket.subheader = CL_SUBHEADER_ADD; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llCost = 0; #else sPacket.dwCost = 0; #endif sPacket.bPos = bPos; sPacket.tPos = tPos; GetDesc()->Packet(&sPacket, sizeof(TPacketChangeLook)); } void CHARACTER::RemoveClMaterial(BYTE bPos) { if (bPos >= CL_WINDOW_MAX_MATERIALS) return; LPITEM* pkItemMaterial; pkItemMaterial = GetClWindowMaterials(); if (!pkItemMaterial[bPos]) return; if (bPos == 1 || bPos == 2) { pkItemMaterial[bPos]->Lock(false); pkItemMaterial[bPos] = NULL; } else ClearClWindowMaterials(); TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketChangeLook sPacket; sPacket.header = HEADER_GC_CL; sPacket.subheader = CL_SUBHEADER_REMOVE; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llCost = 0; #else sPacket.dwCost = 0; #endif sPacket.bPos = bPos; sPacket.tPos = tPos; GetDesc()->Packet(&sPacket, sizeof(TPacketChangeLook)); } void CHARACTER::RefineClMaterials() { LPITEM* pkItemMaterial; pkItemMaterial = GetClWindowMaterials(); if (!pkItemMaterial[0]) return; else if (!pkItemMaterial[1]) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] Please submit the item you want to transmute.")); return; } #ifdef ENABLE_YANG_LIMIT_SYSTEM long long llPrice = CL_TRANSMUTATION_PRICE; #else DWORD dwPrice = CL_TRANSMUTATION_PRICE; #endif bool isNeedGold = true; if (pkItemMaterial[2] && pkItemMaterial[2]->GetVnum() == CL_SCROLL_VNUM) isNeedGold = false; if (isNeedGold == true) { #ifdef ENABLE_CHEQUE_SYSTEM if (GetCheque() < llPrice) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] You don't have enough Cheque.")); return; } #else if (GetGold() < llPrice) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Transmutation] You don't have enough Yang.")); return; } #endif } DWORD dwVnum = pkItemMaterial[1]->GetVnum(); if (isNeedGold == false) ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[2], "SPECIFY ITEM TRANSMUTED"); else #ifdef ENABLE_CHEQUE_SYSTEM PointChange(POINT_CHEQUE, -llPrice); #else PointChange(POINT_GOLD, -llPrice); #endif DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, pkItemMaterial[0]->GetVnum(), -llPrice); ITEM_MANAGER::instance().RemoveItem(pkItemMaterial[1], "TRANSMUTED (SUCCESSFULLY)"); pkItemMaterial[0]->SetTransmutation(dwVnum, true); ClearClWindowMaterials(); TItemPos tPos; tPos.window_type = INVENTORY; tPos.cell = 0; TPacketChangeLook sPacket; sPacket.header = HEADER_GC_CL; sPacket.subheader = CL_SUBHEADER_REFINE; #ifdef ENABLE_YANG_LIMIT_SYSTEM sPacket.llCost = 0; #else sPacket.dwCost = 0; #endif sPacket.bPos = 0; sPacket.tPos = tPos; GetDesc()->Packet(&sPacket, sizeof(TPacketChangeLook)); } bool CHARACTER::CleanTransmutation(LPITEM pkItem, LPITEM pkTarget) { if (!CanHandleItem()) return false; else if ((!pkItem) || (!pkTarget)) return false; else if ((pkTarget->GetType() != ITEM_WEAPON) && (pkTarget->GetType() != ITEM_ARMOR) && (pkTarget->GetType() != ITEM_COSTUME)) return false; #ifdef ENABLE_ITEM_SEALBIND_SYSTEM else if ((pkTarget->IsSealed())) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't remove the transmute because item is binded.")); return false; } #endif else if (pkTarget->isLocked()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't remove the transmute because item is locked.")); return false; } if (pkTarget->GetTransmutation() == 0) return false; pkTarget->SetTransmutation(0); pkItem->SetCount(pkItem->GetCount() - 1); LogManager::instance().ItemLog(this, pkTarget, "USE_DETACHMENT (CLEAN TRANSMUTED)", pkTarget->GetName()); return true; } #endif #ifdef ITEM_SHOP bool CHARACTER::UpdateCoins(DWORD dwAID, long val) { if (val == 0) { sys_err("Value is empty"); return false; } if (!dwAID) { sys_err("dwAID = 0, returned"); return false; } char szQuery[256 + 1]; long lValue = abs(val); if (val > 0) { sprintf(szQuery, "UPDATE account.account SET cash = cash + '%ld' WHERE id = '%u'", lValue, dwAID); } else { sprintf(szQuery, "UPDATE account.account SET cash = cash - '%ld' WHERE id = '%u'", lValue, dwAID); } std::unique_ptr msg(DBManager::instance().DirectQuery(szQuery)); if (msg->uiSQLErrno != 0) { sys_err("UpdateCoins Query Failed, Error code: %ld", msg->uiSQLErrno); return false; } sys_log(0, "NAME: %s Coins Updated, Amount: %d", GetName(), val); return true; } DWORD CHARACTER::GetCoins() { if (!GetDesc()) { return 0; } std::unique_ptr msg(DBManager::instance().DirectQuery("SELECT cash FROM account.account WHERE id = '%u'", GetDesc()->GetAccountTable().id)); if (msg->uiSQLErrno != 0) { sys_err("GetCoins Query Failed, Error code: %ld", msg->uiSQLErrno); return 0; } if (!msg->Get()->uiNumRows) { sys_err("GetCoins Query Failed, Rows couldn't get"); return 0; } MYSQL_ROW row = mysql_fetch_row(msg->Get()->pSQLResult); const char* cMyCoins = row[0]; long lMyCoins = 0; str_to_number(lMyCoins, cMyCoins); return lMyCoins; } #endif #ifdef ENABLE_HIDE_COSTUME_SYSTEM void CHARACTER::SetBodyCostumeHidden(bool hidden) { m_bHideBodyCostume = hidden; ChatPacket(CHAT_TYPE_COMMAND, "SetBodyCostumeHidden %d", m_bHideBodyCostume ? 1 : 0); SetQuestFlag("costume_option.hide_body", m_bHideBodyCostume ? 1 : 0); } void CHARACTER::SetHairCostumeHidden(bool hidden) { m_bHideHairCostume = hidden; ChatPacket(CHAT_TYPE_COMMAND, "SetHairCostumeHidden %d", m_bHideHairCostume ? 1 : 0); SetQuestFlag("costume_option.hide_hair", m_bHideHairCostume ? 1 : 0); } #ifdef ENABLE_ACCE_SYSTEM void CHARACTER::SetAcceCostumeHidden(bool hidden) { m_bHideAcceCostume = hidden; ChatPacket(CHAT_TYPE_COMMAND, "SetAcceCostumeHidden %d", m_bHideAcceCostume ? 1 : 0); SetQuestFlag("costume_option.hide_acce", m_bHideAcceCostume ? 1 : 0); } #endif #ifdef ENABLE_WEAPON_COSTUME_SYSTEM void CHARACTER::SetWeaponCostumeHidden(bool hidden) { m_bHideWeaponCostume = hidden; ChatPacket(CHAT_TYPE_COMMAND, "SetWeaponCostumeHidden %d", m_bHideWeaponCostume ? 1 : 0); SetQuestFlag("costume_option.hide_weapon", m_bHideWeaponCostume ? 1 : 0); } #endif #endif #ifdef ENABLE_KILL_STATISTICS void CHARACTER::SendKillStatisticsPacket() { if (!GetDesc()) { return; } TPacketGCKillStatistics KillStatisticsGC; KillStatisticsGC.bHeader = HEADER_GC_KILL_STATISTICS; KillStatisticsGC.iJinnoKills = GetJinnoKills(); KillStatisticsGC.iShinsooKills = GetShinsooKills(); KillStatisticsGC.iChunjoKills = GetChunjoKills(); KillStatisticsGC.iTotalKills = GetTotalKills(); KillStatisticsGC.iTotalDeaths = GetTotalDeaths(); KillStatisticsGC.iDuelsWon = GetDuelsWon(); KillStatisticsGC.iDuelsLost = GetDuelsLost(); KillStatisticsGC.iBossesKills = GetBossesKills(); KillStatisticsGC.iStonesKills = GetStonesKills(); KillStatisticsGC.iMobsKills = GetMobsKills(); KillStatisticsGC.top_damage = GetTopDamage(); GetDesc()->Packet(&KillStatisticsGC, sizeof(TPacketGCKillStatistics)); } #endif bool CHARACTER::HaveAnotherPagesOpen() { if (GetExchange() || IsOpenSafebox() || GetMyShop() || GetShopOwner() || IsCubeOpen() || // GetShop() || //IsOpenAcce() || //IsOpenAura() || //isChangeLookOpened() || // IsStun() || // IsDead() || //m_pkTimedEvent || //m_bUnderRefine || //GetOfflineShopGuest() || //GetShopSafebox() || DragonSoul_RefineWindow_GetOpener()) return true; return false; } void CHARACTER::SetProtectTime(const std::string& flagname, int value) { itertype(m_protection_Time) it = m_protection_Time.find(flagname); if (it != m_protection_Time.end()) { it->second = value; } else { m_protection_Time.insert(make_pair(flagname, value)); } } int CHARACTER::GetProtectTime(const std::string& flagname) const { itertype(m_protection_Time) it = m_protection_Time.find(flagname); if (it != m_protection_Time.end()) { return it->second; } return 0; }