Developer Ikarus_ 2450 Posted November 1, 2019 Developer Share Posted November 1, 2019 small code to apply to fix the problem of not starting the kill event (lua) after killing a monster that has set 0 as exp in his mob_proto. Spoiler service.h or CommonDefines.h #define __ENABLE_KILL_EVENT_FIX__ //if you want to fix the 0 exp problem about the when kill lua event (recommended) char.h // search void DistributeHP(LPCHARACTER pkKiller); void DistributeSP(LPCHARACTER pkKiller, int iMethod=0); // add under #ifdef __ENABLE_KILL_EVENT_FIX__ LPCHARACTER GetMostAttacked(); #endif char_battle.cpp // search: void CHARACTER::Reward(bool bItemDrop) { if (GetRaceNum() == 5001) { PIXEL_POSITION pos; if (!SECTREE_MANAGER::instance().GetMovablePosition(GetMapIndex(), GetX(), GetY(), pos)) return; LPITEM item; int iGold = number(GetMobTable().dwGoldMin, GetMobTable().dwGoldMax); iGold = iGold * CHARACTER_MANAGER::instance().GetMobGoldAmountRate(NULL) / 100; iGold *= GetGoldMultipler(); int iSplitCount = number(25, 35); sys_log(0, "WAEGU Dead gold %d split %d", iGold, iSplitCount); for (int i = 1; i <= iSplitCount; ++i) { if ((item = ITEM_MANAGER::instance().CreateItem(1, iGold / iSplitCount))) { if (i != 0) { pos.x = number(-7, 7) * 20; pos.y = number(-7, 7) * 20; pos.x += GetX(); pos.y += GetY(); } item->AddToGround(GetMapIndex(), pos); item->StartDestroyEvent(); } } return; } //PROF_UNIT puReward("Reward"); LPCHARACTER pkAttacker = DistributeExp(); // replace if (!pkAttacker) return; // with this #ifdef __ENABLE_KILL_EVENT_FIX__ if (!pkAttacker && !(pkAttacker = GetMostAttacked())) return; #else if (!pkAttacker) return; #endif // search : LPCHARACTER CHARACTER::DistributeExp() //* put BEFORE THIS -> WARNING BEFORE AND NOT UNDER //* put BEFORE THIS -> WARNING BEFORE AND NOT UNDER //* put BEFORE THIS -> WARNING BEFORE AND NOT UNDER //* put BEFORE THIS -> WARNING BEFORE AND NOT UNDER //* put BEFORE THIS -> WARNING BEFORE AND NOT UNDER //* put BEFORE THIS -> WARNING BEFORE AND NOT UNDER //* put BEFORE THIS -> WARNING BEFORE AND NOT UNDER #ifdef __ENABLE_KILL_EVENT_FIX__ LPCHARACTER CHARACTER::GetMostAttacked() { int iMostDam=-1; LPCHARACTER pkChrMostAttacked = NULL; auto it = m_map_kDamage.begin(); while (it != m_map_kDamage.end()){ //* getting information from the iterator const VID & c_VID = it->first; const int iDam = it->second.iTotalDamage; //* increasing the iterator ++it; //* finding the character from his vid LPCHARACTER pAttacker = CHARACTER_MANAGER::instance().Find(c_VID); //* if the attacked is now offline if (!pAttacker) continue; //* if the attacker is not a player if( pAttacker->IsNPC()) continue; //* if the player is too far if(DISTANCE_APPROX(GetX()-pAttacker->GetX(), GetY()-pAttacker->GetY())>5000) continue; if (iDam > iMostDam){ pkChrMostAttacked = pAttacker; iMostDam = iDam; } } return pkChrMostAttacked; } #endif This is the hidden content, please Sign In or Sign Up bye bye source : me 18 1 5 5 My youtube channel on which you can see my works here Link to comment Share on other sites More sharing options...
sheinfeld 1 Posted November 1, 2019 Share Posted November 1, 2019 It doesnt work, "undefined reference to `CHARACTER::GetMostAttacked()'" Link to comment Share on other sites More sharing options...
Premium WeedHex 636 Posted November 1, 2019 Premium Share Posted November 1, 2019 So ugly with define. If you rly want macro, define in main file cuz you use just one time. void CHARACTER::Reward(bool bItemDrop) Function is default shitty. Link to comment Share on other sites More sharing options...
Developer Ikarus_ 2450 Posted November 1, 2019 Author Developer Share Posted November 1, 2019 3 hours ago, sheinfeld said: It doesnt work, "undefined reference to `CHARACTER::GetMostAttacked()'" you didn't installed correctly 2 hours ago, WeedHex said: So ugly with define. If you rly want macro, define in main file cuz you use just one time. void CHARACTER::Reward(bool bItemDrop) Function is default shitty. The macro defines are usefull to find the code interesting a fix/implementation and to take trace of the changes made 1 My youtube channel on which you can see my works here Link to comment Share on other sites More sharing options...
Developer PACI 930 Posted November 2, 2019 Developer Share Posted November 2, 2019 :monkaHmm: @Raylee, mind erasing this post? when you return 0 and server doesn't boot: Link to comment Share on other sites More sharing options...
Developer Ikarus_ 2450 Posted November 2, 2019 Author Developer Share Posted November 2, 2019 I ask to be careful, char_battle.cpp contains the body of the function of which you speak My youtube channel on which you can see my works here Link to comment Share on other sites More sharing options...
Developer Ikarus_ 2450 Posted February 2, 2020 Author Developer Share Posted February 2, 2020 push My youtube channel on which you can see my works here Link to comment Share on other sites More sharing options...
Recommended Posts