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

send cooldown to action bars when using items #3823

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,9 @@ static void showUseHotkeyMessage(Player* player, const Item* item, uint32_t coun

bool Actions::useItem(Player* player, const Position& pos, uint8_t index, Item* item, bool isHotkey)
{
player->setNextAction(OTSYS_TIME() + g_config.getNumber(ConfigManager::ACTIONS_DELAY_INTERVAL));
int32_t cooldown = g_config.getNumber(ConfigManager::ACTIONS_DELAY_INTERVAL);
player->setNextAction(OTSYS_TIME() + cooldown);
player->sendUseItemCooldown(cooldown);

if (isHotkey) {
uint16_t subType = item->getSubType();
Expand Down Expand Up @@ -454,7 +456,9 @@ bool Actions::useItem(Player* player, const Position& pos, uint8_t index, Item*
bool Actions::useItemEx(Player* player, const Position& fromPos, const Position& toPos,
uint8_t toStackPos, Item* item, bool isHotkey, Creature* creature/* = nullptr*/)
{
player->setNextAction(OTSYS_TIME() + g_config.getNumber(ConfigManager::EX_ACTIONS_DELAY_INTERVAL));
int32_t cooldown = g_config.getNumber(ConfigManager::EX_ACTIONS_DELAY_INTERVAL);
player->setNextAction(OTSYS_TIME() + cooldown);
player->sendUseItemCooldown(cooldown);

Action* action = getAction(item);
if (!action) {
Expand Down
5 changes: 5 additions & 0 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,11 @@ class Player final : public Creature, public Cylinder
client->sendSpellGroupCooldown(groupId, time);
}
}
void sendUseItemCooldown(uint32_t time) {
if (client) {
client->sendUseItemCooldown(time);
}
}
void sendModalWindow(const ModalWindow& modalWindow);

//container
Expand Down
8 changes: 8 additions & 0 deletions src/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3142,6 +3142,14 @@ void ProtocolGame::sendSpellGroupCooldown(SpellGroup_t groupId, uint32_t time)
writeToOutputBuffer(msg);
}

void ProtocolGame::sendUseItemCooldown(uint32_t time)
{
NetworkMessage msg;
msg.addByte(0xA6);
msg.add<uint32_t>(time);
writeToOutputBuffer(msg);
}

void ProtocolGame::sendModalWindow(const ModalWindow& modalWindow)
{
NetworkMessage msg;
Expand Down
1 change: 1 addition & 0 deletions src/protocolgame.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class ProtocolGame final : public Protocol

void sendSpellCooldown(uint8_t spellId, uint32_t time);
void sendSpellGroupCooldown(SpellGroup_t groupId, uint32_t time);
void sendUseItemCooldown(uint32_t time);

//tiles
void sendMapDescription(const Position& pos);
Expand Down