Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player / Bot player with the last hit #199

Closed
Krutok opened this issue Jul 19, 2022 · 8 comments
Closed

Player / Bot player with the last hit #199

Krutok opened this issue Jul 19, 2022 · 8 comments
Labels
invalid-not-bots this is not a npcbots issue

Comments

@Krutok
Copy link

Krutok commented Jul 19, 2022

I had a special boss script written for my server. It includes that if you do a certain #daily quest, you can summon a certain boss. So far so good and it works, but when the bot gets the last hit, the quest doesn't complete automatically and no tribute chest appears either.

This only works if I do the kill as a real player, so I have to set the bots to passive so I can do the kill and the quest will complete automatically and the chest with the loot will appear.

In a raid or instance it doesn't matter, I always get loot no matter if the bot does the killing blow or I as a player. The coder just says:

Your core was probably heavily modified in order to allow that to happen. There is no OnCreatureKillCreature hook in the TC ScriptMgr, the only function that we can call once the boss this is OnCreatureKill which takes Player (killer) and creature (killed) as arguments.
There is no OnNPCBotKillCreature hook, and I don't think whoever made the NPCPlayerbots fork added that hook.
The way they handled players being able to loot an NPC killed by the bot was probably done through multiple core modifications.

here when i set the bots passively the chest appears: https://www.youtube.com/watch?v=TkxHrPfcb4s but when i make the bots the killing blow the quest is not completed as expected and no chest appears.

That's why the patch is about bots and you as a player should also have the opportunity to use them when you set self-created bosses into the world, then you should maybe see if you can do something there, regardless of whether the player or bot kills the mob, because you can die as a player in a fight and your bots will then finish the fight and then there should also be loot for custom bosses in the world.

@Krutok Krutok changed the title player with the last hit Player / Bot player with the last hit Jul 19, 2022
@trickerer
Copy link
Owner

I would say OnCreatureKill() is not the best way to hook creature death, judging from the code in Unit.cpp:Unit::Kill() you can run into the same problem if player's pet or any other summoned creature deals the killing blow.

TrinityCore uses loot recipient and loot damage requirement to determine player / group to receive the reward for killing, there is only a small addition to that from bots which is to set loot recepient to master so, unlike with pet, player can loot the creature even if bots do all the damage.

For scripted creatures normally after kill actions are handled by using JustDied() hook is creature script, sometimes DamageTaken() if creature doesn't really die, or, in case it's a smart script, probably with SMART_EVENT_DEATH -> SMART_ACTION_SUMMON_GO (I rarely do anything with smart scripts).

Alternatively, if you are desperate for a quick fix, you can just force OnCreatureKill() hook using master as killer

@@ -11586,6 +11586,11 @@ bool Unit::Kill(Unit*, Unit*, bool)
        {
            if (Player* killed = victim->ToPlayer())
                sScriptMgr->OnPlayerKilledByCreature(killerCre, killed);
+            else if (Creature* killedCre = victim->ToCreature())
+            {
+                if (killerCre->IsNPCBotOrPet() && !killerCre->IsFreeBot())
+                    sScriptMgr->OnCreatureKill(killerCre->GetBotOwner(), killedCre);
+            }
        }
    }
}

@Krutok
Copy link
Author

Krutok commented Jul 19, 2022

I will also post that in the trinitycore github, maybe adjust it then so that you don't have to adjust it again and again after each patch

@qyh214
Copy link

qyh214 commented Jul 19, 2022

is this issue belong to "in retail,when players do not cause enough damage, they will not be able to get loot."?

@Krutok
Copy link
Author

Krutok commented Jul 19, 2022

is this issue belong to "in retail,when players do not cause enough damage, they will not be able to get loot."?

I played wow retail for almost 9 years.
In certain situations, if you didn't do enough damage, you weren't entitled to the loot.
But I think that was changed when the LFG Raidbrowser was added, but I'm not quite sure anymore.

This is not about damage but who makes the last hit. Tried the code snippet and it works very well. The script that I have for my bosses also works perfectly with bots

@trickerer
Copy link
Owner

I played wow retail for almost 9 years.
In certain situations, if you didn't do enough damage, you weren't entitled to the loot.
But I think that was changed when the LFG Raidbrowser was added, but I'm not quite sure anymore.

At least on 3.3.5 TrinityCore, player / group still needs to deal 50% of creature's max hp damage to get loot; player's and player-controlled units' damage counts but at least 1 damage must be dealt as player (or bot) damage otherwise corpse won't be lootable

@Krutok
Copy link
Author

Krutok commented Jul 24, 2022

Is it possible to save the equipment in the database or rather not? would be really nice if that were possible, then you no longer have all the equipment in the bank and in the inventory

@trickerer
Copy link
Owner

Is it possible to save the equipment in the database or rather not? would be really nice if that were possible, then you no longer have all the equipment in the bank and in the inventory

Don't mix issues. Thanks.

@Krutok
Copy link
Author

Krutok commented Jul 25, 2022

sry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid-not-bots this is not a npcbots issue
Projects
None yet
Development

No branches or pull requests

3 participants