mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-29 12:32:29 +00:00
[Quest API] Add EVENT_LEVEL_UP and EVENT_LEVEL_DOWN to Bots (#3750)
* [Quest API] Add EVENT_LEVEL_UP and EVENT_LEVEL_DOWN to bots # Notes - Bots did not have these events, this will allow operators to perform events on bot level up/down. * Update bot.cpp
This commit is contained in:
parent
33adb9bcc1
commit
9c238cd08d
52
zone/bot.cpp
52
zone/bot.cpp
@ -3638,41 +3638,45 @@ uint32 Bot::SpawnedBotCount(const uint32 owner_id, uint8 class_id) {
|
|||||||
return spawned_bot_count;
|
return spawned_bot_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::LevelBotWithClient(Client* client, uint8 level, bool sendlvlapp) {
|
void Bot::LevelBotWithClient(Client* c, uint8 new_level, bool send_appearance) {
|
||||||
// This essentially performs a '#bot update,' with appearance packets, based on the current methods.
|
// This essentially performs a '#bot update,' with appearance packets, based on the current methods.
|
||||||
// This should not be called outside of Client::SetEXP() due to it's lack of rule checks.
|
// This should not be called outside of Client::SetEXP() due to its lack of rule checks.
|
||||||
if (client) {
|
|
||||||
std::list<Bot*> blist = entity_list.GetBotsByBotOwnerCharacterID(client->CharacterID());
|
|
||||||
|
|
||||||
for (auto biter = blist.begin(); biter != blist.end(); ++biter) {
|
if (c) {
|
||||||
Bot* bot = *biter;
|
const auto &l = entity_list.GetBotsByBotOwnerCharacterID(c->CharacterID());
|
||||||
|
|
||||||
if (bot && (bot->GetLevel() != client->GetLevel())) {
|
for (const auto &e : l) {
|
||||||
bot->SetPetChooser(false); // not sure what this does, but was in bot 'update' code
|
if (e && (e->GetLevel() != c->GetLevel())) {
|
||||||
bot->CalcBotStats(client->GetBotOption(Client::booStatsUpdate));
|
int levels_change = (new_level - e->GetLevel());
|
||||||
|
|
||||||
if (sendlvlapp) {
|
if (levels_change < 0) {
|
||||||
bot->SendLevelAppearance();
|
parse->EventBot(EVENT_LEVEL_DOWN, e, nullptr, std::to_string(std::abs(levels_change)), 0);
|
||||||
|
} else {
|
||||||
|
parse->EventBot(EVENT_LEVEL_UP, e, nullptr, std::to_string(levels_change), 0);
|
||||||
}
|
}
|
||||||
// modified from Client::SetLevel()
|
|
||||||
|
e->SetPetChooser(false); // not sure what this does, but was in bot 'update' code
|
||||||
|
e->CalcBotStats(c->GetBotOption(Client::booStatsUpdate));
|
||||||
|
|
||||||
|
if (send_appearance) {
|
||||||
|
e->SendLevelAppearance();
|
||||||
|
}
|
||||||
|
|
||||||
if (!RuleB(Bots, BotHealOnLevel)) {
|
if (!RuleB(Bots, BotHealOnLevel)) {
|
||||||
int mhp = bot->CalcMaxHP();
|
const int64 max_hp = e->CalcMaxHP();
|
||||||
if (bot->GetHP() > mhp) {
|
if (e->GetHP() > max_hp) {
|
||||||
bot->SetHP(mhp);
|
e->SetHP(max_hp);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
e->SetHP(e->CalcMaxHP());
|
||||||
bot->SetHP(bot->CalcMaxHP());
|
e->SetMana(e->CalcMaxMana());
|
||||||
bot->SetMana(bot->CalcMaxMana());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bot->SendHPUpdate();
|
e->SendHPUpdate();
|
||||||
bot->SendAppearancePacket(AT_WhoLevel, level, true, true); // who level change
|
e->SendAppearancePacket(AT_WhoLevel, new_level, true, true); // who level change
|
||||||
bot->AI_AddBotSpells(bot->GetBotSpellID());
|
e->AI_AddBotSpells(e->GetBotSpellID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blist.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -341,6 +341,8 @@ LuaParser::LuaParser() {
|
|||||||
BotArgumentDispatch[EVENT_UNEQUIP_ITEM_BOT] = handle_bot_equip_item;
|
BotArgumentDispatch[EVENT_UNEQUIP_ITEM_BOT] = handle_bot_equip_item;
|
||||||
BotArgumentDispatch[EVENT_DAMAGE_GIVEN] = handle_bot_damage;
|
BotArgumentDispatch[EVENT_DAMAGE_GIVEN] = handle_bot_damage;
|
||||||
BotArgumentDispatch[EVENT_DAMAGE_TAKEN] = handle_bot_damage;
|
BotArgumentDispatch[EVENT_DAMAGE_TAKEN] = handle_bot_damage;
|
||||||
|
BotArgumentDispatch[EVENT_LEVEL_UP] = handle_bot_level_up;
|
||||||
|
BotArgumentDispatch[EVENT_LEVEL_DOWN] = handle_bot_level_down;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
L = nullptr;
|
L = nullptr;
|
||||||
|
|||||||
@ -2300,4 +2300,30 @@ void handle_bot_damage(
|
|||||||
lua_setfield(L, -2, "other");
|
lua_setfield(L, -2, "other");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handle_bot_level_up(
|
||||||
|
QuestInterface *parse,
|
||||||
|
lua_State* L,
|
||||||
|
Bot* bot,
|
||||||
|
Mob *init,
|
||||||
|
std::string data,
|
||||||
|
uint32 extra_data,
|
||||||
|
std::vector<std::any> *extra_pointers
|
||||||
|
) {
|
||||||
|
lua_pushinteger(L, Strings::ToInt(data));
|
||||||
|
lua_setfield(L, -2, "levels_gained");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handle_bot_level_down(
|
||||||
|
QuestInterface *parse,
|
||||||
|
lua_State* L,
|
||||||
|
Bot* bot,
|
||||||
|
Mob *init,
|
||||||
|
std::string data,
|
||||||
|
uint32 extra_data,
|
||||||
|
std::vector<std::any> *extra_pointers
|
||||||
|
) {
|
||||||
|
lua_pushinteger(L, Strings::ToInt(data));
|
||||||
|
lua_setfield(L, -2, "levels_lost");
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -1055,5 +1055,25 @@ void handle_bot_damage(
|
|||||||
std::vector<std::any> *extra_pointers
|
std::vector<std::any> *extra_pointers
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void handle_bot_level_up(
|
||||||
|
QuestInterface *parse,
|
||||||
|
lua_State* L,
|
||||||
|
Bot* bot,
|
||||||
|
Mob* init,
|
||||||
|
std::string data,
|
||||||
|
uint32 extra_data,
|
||||||
|
std::vector<std::any> *extra_pointers
|
||||||
|
);
|
||||||
|
|
||||||
|
void handle_bot_level_down(
|
||||||
|
QuestInterface *parse,
|
||||||
|
lua_State* L,
|
||||||
|
Bot* bot,
|
||||||
|
Mob* init,
|
||||||
|
std::string data,
|
||||||
|
uint32 extra_data,
|
||||||
|
std::vector<std::any> *extra_pointers
|
||||||
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user