Active Member Klaus 158 Posted June 11, 2021 Active Member Share Posted June 11, 2021 One problem I face is the delay for the player to actually die, in the example below, I took the total damage from the player and there is a delay until he actually dies. In wars, where kills are counted, I often kill a player and another character steals the "kill", is there any way to solve this problem? Thank you for your attention! Link to comment Share on other sites More sharing options...
Solution DrTurk 133 Posted June 11, 2021 Solution Share Posted June 11, 2021 (edited) char.cpp --> remove that: m_dwKillerPID = 0; char.h --> remove that: DWORD m_dwKillerPID; char_battle.cpp --> remove/change that: if (!pkKiller && m_dwKillerPID) pkKiller = CHARACTER_MANAGER::instance().FindByPID(m_dwKillerPID); m_dwKillerPID = 0; change that: if (GetHP() <= 0) { Stun(); if (pAttacker && !pAttacker->IsNPC()) m_dwKillerPID = pAttacker->GetPlayerID(); else m_dwKillerPID = 0; } to this: if (GetHP() <= 0) { Dead(pAttacker); } Edited June 11, 2021 by DrTurk 1 Link to comment Share on other sites More sharing options...
Active Member Klaus 158 Posted June 11, 2021 Author Active Member Share Posted June 11, 2021 5 hours ago, DrTurk said: char.cpp --> remove that: m_dwKillerPID = 0; char.h --> remove that: DWORD m_dwKillerPID; char_battle.cpp --> remove/change that: if (!pkKiller && m_dwKillerPID) pkKiller = CHARACTER_MANAGER::instance().FindByPID(m_dwKillerPID); m_dwKillerPID = 0; change that: if (GetHP() <= 0) { Stun(); if (pAttacker && !pAttacker->IsNPC()) m_dwKillerPID = pAttacker->GetPlayerID(); else m_dwKillerPID = 0; } to this: if (GetHP() <= 0) { Dead(pAttacker); } Solved! (Is there any risk of causing an error/bug?) Link to comment Share on other sites More sharing options...
DrTurk 133 Posted June 12, 2021 Share Posted June 12, 2021 Had two servers with that change, didnt experienced any bugs 1 Link to comment Share on other sites More sharing options...
Active Member ReFresh 2338 Posted August 3, 2021 Active Member Share Posted August 3, 2021 (edited) On 6/12/2021 at 12:56 PM, DrTurk said: Had two servers with that change, didnt experienced any bugs I just tried your code edits and it has at least one bug with removing char affect like poison. Try to kill the player with ninja char skill Poisoned Arrow, player will die with poison affect on yourself. I tried to call Dead(); function instead of your changes, but there is still the same bug with affects. Dead(); is not removing the poison, bleed, etc. affects. I couldn't find differences between why Stun(); function removing the affects correctly and Dead(); function not. Spoiler if (GetHP() <= 0) { Stun(); or Dead(); can be called but only Stun(); removing the affects before death correctly if (pAttacker && !pAttacker->IsNPC()) m_dwKillerPID = pAttacker->GetPlayerID(); else m_dwKillerPID = 0; } return false; Would be really nice if someone can solve this problem. Edited August 3, 2021 by ReFresh I'll be always helpful! Link to comment Share on other sites More sharing options...
DrTurk 133 Posted August 3, 2021 Share Posted August 3, 2021 12 hours ago, ReFresh said: I just tried your code edits and it has at least one bug with removing char affect like poison. Try to kill the player with ninja char skill Poisoned Arrow, player will die with poison affect on yourself. I tried to call Dead(); function instead of your changes, but there is still the same bug with affects. Dead(); is not removing the poison, bleed, etc. affects. I couldn't find differences between why Stun(); function removing the affects correctly and Dead(); function not. Hide contents if (GetHP() <= 0) { Stun(); or Dead(); can be called but only Stun(); removing the affects before death correctly if (pAttacker && !pAttacker->IsNPC()) m_dwKillerPID = pAttacker->GetPlayerID(); else m_dwKillerPID = 0; } return false; Would be really nice if someone can solve this problem. Isnt that a normal m2 problem with bleed/poison/fire when you one shot someone with it? I fixxed this before i did this change. Just add if (ch->IsDead()) { ch->RemovePoison(); } like that: EVENTFUNC(poison_event) { TPoisonEventInfo * info = dynamic_cast<TPoisonEventInfo *>( event->info ); if ( info == NULL ) { sys_err( "poison_event> <Factor> Null pointer" ); return 0; } LPCHARACTER ch = info->ch; if (ch == NULL) { return 0; } LPCHARACTER pkAttacker = CHARACTER_MANAGER::instance().FindByPID(info->attacker_pid); if (ch->IsDead()) { ch->RemovePoison(); } int dam = ch->GetMaxHP() * GetPoisonDamageRate(ch) / 1000; if (test_server) ch->ChatPacket(CHAT_TYPE_NOTICE, "Poison Damage %d", dam); if (ch->Damage(pkAttacker, dam, DAMAGE_TYPE_POISON)) { ch->m_pkPoisonEvent = NULL; return 0; } --info->count; if (info->count) return PASSES_PER_SEC(3); else { ch->m_pkPoisonEvent = NULL; return 0; } } same thing with fire: EVENTFUNC(fire_event) { TFireEventInfo * info = dynamic_cast<TFireEventInfo *>( event->info ); if ( info == NULL ) { sys_err( "fire_event> <Factor> Null pointer" ); return 0; } LPCHARACTER ch = info->ch; if (ch == NULL) { return 0; } LPCHARACTER pkAttacker = CHARACTER_MANAGER::instance().FindByPID(info->attacker_pid); if (ch->IsDead()) { ch->RemoveFire(); } int dam = info->amount; if (test_server) ch->ChatPacket(CHAT_TYPE_NOTICE, "Fire Damage %d", dam); if (ch->Damage(pkAttacker, dam, DAMAGE_TYPE_FIRE)) { ch->m_pkFireEvent = NULL; return 0; } --info->count; if (info->count) return PASSES_PER_SEC(3); else { ch->m_pkFireEvent = NULL; return 0; } } Link to comment Share on other sites More sharing options...
Active Member ReFresh 2338 Posted August 3, 2021 Active Member Share Posted August 3, 2021 (edited) @DrTurk Thanks I'll try. But why did you remove that functions instead of calling Dead(); function? It should be the same thing as we call the Stun(); am I right? But mystery is why Stun(); function is able to remove these affects without editing something. Edited August 3, 2021 by ReFresh I'll be always helpful! Link to comment Share on other sites More sharing options...
DrTurk 133 Posted August 3, 2021 Share Posted August 3, 2021 25 minutes ago, ReFresh said: @DrTurk Thanks I'll try. But why did you remove that functions instead of calling Dead(); function? It should be the same thing as we call the Stun(); am I right? But mystery is why Stun(); function is able to remove these affects without editing something. as i said i had this problem even before i modifyed the dead function, but only when you one shot someone with a poison skill. i can redo my dead function modify and it will also bug when killed with one shot which has 100% poison rate Link to comment Share on other sites More sharing options...
Active Member ReFresh 2338 Posted August 5, 2021 Active Member Share Posted August 5, 2021 On 8/3/2021 at 3:49 PM, DrTurk said: as i said i had this problem even before i modifyed the dead function, but only when you one shot someone with a poison skill. i can redo my dead function modify and it will also bug when killed with one shot which has 100% poison rate Just call Dead(); instad of Stun(); and do the changes to affect events like you did, then change this: Spoiler m_pkDeadEvent = event_create(dead_event, pEventInfo, bImmediateDead ? 1 : PASSES_PER_SEC(3)); To this: Spoiler m_pkDeadEvent = event_create(dead_event, pEventInfo, bImmediateDead ? 1 : PASSES_PER_SEC(0)); And you are done, I think you don't need to remove something from source, just use the functions which are already done. I'll be always helpful! Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now