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

[core] [lua] Add lua binding to the timer packet #4565

Merged
merged 1 commit into from
Sep 30, 2023
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
35 changes: 35 additions & 0 deletions src/map/lua/lua_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10839,6 +10839,39 @@ bool CLuaBaseEntity::hasEnteredBattlefield()
return CBattlefield::hasPlayerEntered(PChar);
}

/************************************************************************
* Function: sendTimerPacket()
* Purpose : sends the packet to enable a timer with durations in seconds
* Example : player:sendTimerPacket(60 * 15)
* Notes :
************************************************************************/

void CLuaBaseEntity::sendTimerPacket(uint32 seconds)
{
if (m_PBaseEntity->objtype != TYPE_PC)
{
ShowWarning("CLuaBaseEntity::sendTimerPacket() was called on non CCharEntity!");
return;
}
charutils::SendTimerPacket(static_cast<CCharEntity*>(m_PBaseEntity), seconds);
}

/************************************************************************
* Function: sendClearTimerPacket()
* Purpose : sends the packet to clear an existing timer
* Example : player:sendClearTimerPacket()
* Notes :
************************************************************************/
void CLuaBaseEntity::sendClearTimerPacket()
{
if (m_PBaseEntity->objtype != TYPE_PC)
{
ShowWarning("CLuaBaseEntity::sendClearTimerPacket() was called on non CCharEntity!");
return;
}
charutils::SendClearTimerPacket(static_cast<CCharEntity*>(m_PBaseEntity));
}

/************************************************************************
* Function: isAlive()
* Purpose : Returns true if an Entity is alive
Expand Down Expand Up @@ -17334,6 +17367,8 @@ void CLuaBaseEntity::Register()
SOL_REGISTER("isInDynamis", CLuaBaseEntity::isInDynamis);
SOL_REGISTER("setEnteredBattlefield", CLuaBaseEntity::setEnteredBattlefield);
SOL_REGISTER("hasEnteredBattlefield", CLuaBaseEntity::hasEnteredBattlefield);
SOL_REGISTER("sendTimerPacket", CLuaBaseEntity::sendTimerPacket);
SOL_REGISTER("sendClearTimerPacket", CLuaBaseEntity::sendClearTimerPacket);

// Battle Utilities
SOL_REGISTER("isAlive", CLuaBaseEntity::isAlive);
Expand Down
2 changes: 2 additions & 0 deletions src/map/lua/lua_baseentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@ class CLuaBaseEntity
bool isInDynamis();
void setEnteredBattlefield(bool entered);
bool hasEnteredBattlefield();
void sendTimerPacket(uint32 seconds);
void sendClearTimerPacket();

// Battle Utilities
bool isAlive();
Expand Down