Bind spell functions

This commit is contained in:
Eduardo Bart 2012-08-19 06:46:24 -03:00
parent fb1c495a4c
commit ad0ed2b1a9
6 changed files with 32 additions and 8 deletions

View File

@ -63,6 +63,7 @@ GameChargeableItems = 19
GameOfflineTrainingTime = 20
GamePurseSlot = 21
GameFormatCreatureName = 22
GameSpellList = 23
TextColors = {
red = '#f55e5e', --'#c83200'

View File

@ -334,6 +334,7 @@ namespace Otc
GameOfflineTrainingTime = 20,
GamePurseSlot = 21,
GameFormatCreatureName = 22,
GameSpellList = 23,
// 23-50 unused yet
// 51-100 reserved to be defined in lua
LastGameFeature = 101

View File

@ -1157,6 +1157,7 @@ void Game::setClientVersion(int version)
if(version >= 870) {
enableFeature(Otc::GameDoubleExperience);
enableFeature(Otc::GamePlayerMounts);
enableFeature(Otc::GameSpellList);
}
if(version >= 910) {

View File

@ -448,6 +448,16 @@ void LocalPlayer::setOfflineTrainingTime(double offlineTrainingTime)
}
}
void LocalPlayer::setSpells(const std::vector<int>& spells)
{
if(m_spells != spells) {
std::vector<int> oldSpells = m_spells;
m_spells = spells;
callLuaField("onSpellsChange", spells, oldSpells);
}
}
double LocalPlayer::getWalkPing()
{
if(m_lastWalkPings.empty())

View File

@ -59,6 +59,7 @@ public:
void setBaseSpeed(double baseSpeed);
void setRegenerationTime(double regenerationTime);
void setOfflineTrainingTime(double offlineTrainingTime);
void setSpells(const std::vector<int>& spells);
int getStates() { return m_states; }
int getSkillLevel(Otc::Skill skill) { return m_skillsLevel[skill]; }
@ -83,6 +84,7 @@ public:
double getBaseSpeed() { return m_baseSpeed; }
double getRegenerationTime() { return m_regenerationTime; }
double getOfflineTrainingTime() { return m_offlineTrainingTime; }
std::vector<int> getSpells() { return m_spells; }
ItemPtr getInventoryItem(Otc::InventorySlot inventory) { return m_inventoryItems[inventory]; }
bool hasSight(const Position& pos);
@ -125,6 +127,7 @@ private:
std::array<int, Otc::LastSkill> m_skillsLevel;
std::array<int, Otc::LastSkill> m_skillsBaseLevel;
std::array<int, Otc::LastSkill> m_skillsLevelPercent;
std::vector<int> m_spells;
bool m_known;
int m_states;

View File

@ -856,13 +856,15 @@ void ProtocolGame::parsePlayerInfo(const InputMessagePtr& msg)
{
bool premium = msg->getU8(); // premium
int vocation = msg->getU8(); // vocation
int spellCount = msg->getU16();
for(int i=0;i<spellCount;++i) {
int spellId = msg->getU8(); // spell id - TODO: add to local player
}
std::vector<int> spells;
for(int i=0;i<spellCount;++i)
spells.push_back(msg->getU8()); // spell id
m_localPlayer->setPremium(premium);
m_localPlayer->setVocation(vocation);
m_localPlayer->setSpells(spells);
}
void ProtocolGame::parsePlayerStats(const InputMessagePtr& msg)
@ -963,19 +965,25 @@ void ProtocolGame::parsePlayerCancelAttack(const InputMessagePtr& msg)
void ProtocolGame::parseSpellCooldown(const InputMessagePtr& msg)
{
msg->getU8(); // spell id
msg->getU32(); // cooldown
int spellId = msg->getU8();
int delay = msg->getU32();
g_lua.callGlobalField("g_game", "onSpellCooldown", delay);
}
void ProtocolGame::parseSpellGroupCooldown(const InputMessagePtr& msg)
{
msg->getU8(); // group id
msg->getU32(); // cooldown
int groupId = msg->getU8();
int delay = msg->getU32();
g_lua.callGlobalField("g_game", "onSpellGroupCooldown", groupId, delay);
}
void ProtocolGame::parseMultiUseCooldown(const InputMessagePtr& msg)
{
msg->getU32(); // cooldown
int delay = msg->getU32();
g_lua.callGlobalField("g_game", "onMultiUseCooldown", delay);
}
void ProtocolGame::parseTalk(const InputMessagePtr& msg)