parent
05436e135a
commit
52f81c53f9
|
@ -47,7 +47,7 @@ end
|
||||||
function UIMiniWindowContainer:scheduleInsert(widget, index)
|
function UIMiniWindowContainer:scheduleInsert(widget, index)
|
||||||
if index - 1 > self:getChildCount() then
|
if index - 1 > self:getChildCount() then
|
||||||
if self.scheduledWidgets[index] then
|
if self.scheduledWidgets[index] then
|
||||||
warning('replacing scheduled widget id ' .. widget:getId())
|
pwarning('replacing scheduled widget id ' .. widget:getId())
|
||||||
end
|
end
|
||||||
self.scheduledWidgets[index] = widget
|
self.scheduledWidgets[index] = widget
|
||||||
else
|
else
|
||||||
|
|
|
@ -32,7 +32,6 @@ function UIItem:onDrop(widget, mousePos)
|
||||||
if itemPos.x == toPos.x and itemPos.y == toPos.y and itemPos.z == toPos.z then return false end
|
if itemPos.x == toPos.x and itemPos.y == toPos.y and itemPos.z == toPos.z then return false end
|
||||||
|
|
||||||
if item:getCount() > 1 then
|
if item:getCount() > 1 then
|
||||||
g_game.look(item)
|
|
||||||
modules.game_interface.moveStackableItem(item, toPos)
|
modules.game_interface.moveStackableItem(item, toPos)
|
||||||
else
|
else
|
||||||
g_game.move(item, toPos, 1)
|
g_game.move(item, toPos, 1)
|
||||||
|
|
|
@ -380,6 +380,11 @@ function onOpenNpcTrade(items)
|
||||||
addEvent(show) -- player goods has not been parsed yet
|
addEvent(show) -- player goods has not been parsed yet
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function closeNpcTrade()
|
||||||
|
g_game.closeNpcTrade()
|
||||||
|
hide()
|
||||||
|
end
|
||||||
|
|
||||||
function onCloseNpcTrade()
|
function onCloseNpcTrade()
|
||||||
hide()
|
hide()
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,7 +33,7 @@ MainWindow
|
||||||
id: npcWindow
|
id: npcWindow
|
||||||
!text: tr('NPC Trade')
|
!text: tr('NPC Trade')
|
||||||
size: 550 515
|
size: 550 515
|
||||||
@onEscape: g_game.closeNpcTrade()
|
@onEscape: modules.game_npctrade.closeNpcTrade()
|
||||||
|
|
||||||
TabButton
|
TabButton
|
||||||
id: buyTab
|
id: buyTab
|
||||||
|
@ -264,4 +264,4 @@ MainWindow
|
||||||
width: 64
|
width: 64
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
@onClick: g_game.closeNpcTrade()
|
@onClick: modules.game_npctrade.closeNpcTrade()
|
||||||
|
|
|
@ -150,6 +150,7 @@ function destroy()
|
||||||
currentColorBox = nil
|
currentColorBox = nil
|
||||||
currentClotheButtonBox = nil
|
currentClotheButtonBox = nil
|
||||||
colorBoxes = {}
|
colorBoxes = {}
|
||||||
|
addons = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,4 @@ MiniWindow
|
||||||
MiniWindowContents
|
MiniWindowContents
|
||||||
layout: verticalBox
|
layout: verticalBox
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@onMousePress: onVipListMousePress()
|
&onMousePress: modules.game_viplist.onVipListMousePress
|
||||||
|
|
|
@ -158,6 +158,11 @@ void Game::processPing()
|
||||||
g_lua.callGlobalField("g_game", "onPing");
|
g_lua.callGlobalField("g_game", "onPing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Game::processPingBack(int elapsed)
|
||||||
|
{
|
||||||
|
g_lua.callGlobalField("g_game", "onPingBack", elapsed);
|
||||||
|
}
|
||||||
|
|
||||||
void Game::processTextMessage(Otc::MessageMode mode, const std::string& text)
|
void Game::processTextMessage(Otc::MessageMode mode, const std::string& text)
|
||||||
{
|
{
|
||||||
g_lua.callGlobalField("g_game", "onTextMessage", mode, text);
|
g_lua.callGlobalField("g_game", "onTextMessage", mode, text);
|
||||||
|
@ -1073,6 +1078,16 @@ void Game::mount(bool mount)
|
||||||
m_mounted = mount;
|
m_mounted = mount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Game::ping()
|
||||||
|
{
|
||||||
|
if(!m_protocolGame || !m_protocolGame->isConnected())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_denyBotCall = false;
|
||||||
|
m_protocolGame->sendPing();
|
||||||
|
m_denyBotCall = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Game::checkBotProtection()
|
bool Game::checkBotProtection()
|
||||||
{
|
{
|
||||||
#ifdef BOT_PROTECTION
|
#ifdef BOT_PROTECTION
|
||||||
|
|
|
@ -51,6 +51,7 @@ protected:
|
||||||
void processConnectionError(const boost::system::error_code& error);
|
void processConnectionError(const boost::system::error_code& error);
|
||||||
void processDisconnect();
|
void processDisconnect();
|
||||||
void processPing();
|
void processPing();
|
||||||
|
void processPingBack(int elapsed);
|
||||||
|
|
||||||
void processLoginError(const std::string& error);
|
void processLoginError(const std::string& error);
|
||||||
void processLoginAdvice(const std::string& message);
|
void processLoginAdvice(const std::string& message);
|
||||||
|
@ -232,7 +233,7 @@ public:
|
||||||
// 910 only
|
// 910 only
|
||||||
//void requestItemInfo();
|
//void requestItemInfo();
|
||||||
//void reportRuleViolation2();
|
//void reportRuleViolation2();
|
||||||
// TODO: market related
|
void ping();
|
||||||
|
|
||||||
// dynamic support for game features
|
// dynamic support for game features
|
||||||
void enableFeature(Otc::GameFeature feature) { m_features.set(feature, true); }
|
void enableFeature(Otc::GameFeature feature) { m_features.set(feature, true); }
|
||||||
|
|
|
@ -37,6 +37,7 @@ LocalPlayer::LocalPlayer()
|
||||||
|
|
||||||
m_states = 0;
|
m_states = 0;
|
||||||
m_vocation = 0;
|
m_vocation = 0;
|
||||||
|
m_walkLockInterval = 0;
|
||||||
|
|
||||||
m_skillsLevel.fill(-1);
|
m_skillsLevel.fill(-1);
|
||||||
m_skillsLevelPercent.fill(-1);
|
m_skillsLevelPercent.fill(-1);
|
||||||
|
@ -55,7 +56,7 @@ LocalPlayer::LocalPlayer()
|
||||||
m_stamina = -1;
|
m_stamina = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlayer::lockWalk()
|
void LocalPlayer::lockWalk(int millis)
|
||||||
{
|
{
|
||||||
// prevents double locks
|
// prevents double locks
|
||||||
if(m_walkLocked)
|
if(m_walkLocked)
|
||||||
|
@ -63,6 +64,7 @@ void LocalPlayer::lockWalk()
|
||||||
|
|
||||||
m_walkLocked = true;
|
m_walkLocked = true;
|
||||||
m_walkLockTimer.restart();
|
m_walkLockTimer.restart();
|
||||||
|
m_walkLockInterval = millis;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalPlayer::canWalk(Otc::Direction direction)
|
bool LocalPlayer::canWalk(Otc::Direction direction)
|
||||||
|
@ -79,7 +81,7 @@ bool LocalPlayer::canWalk(Otc::Direction direction)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// cannot walk while locked
|
// cannot walk while locked
|
||||||
if(m_walkLocked && m_walkLockTimer.ticksElapsed() <= WALK_LOCK_INTERVAL)
|
if(m_walkLocked && m_walkLockTimer.ticksElapsed() <= m_walkLockInterval)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
m_walkLocked = false;
|
m_walkLocked = false;
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
class LocalPlayer : public Player
|
class LocalPlayer : public Player
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
WALK_LOCK_INTERVAL = 250,
|
|
||||||
PREWALK_TIMEOUT = 1000
|
PREWALK_TIMEOUT = 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,7 +36,7 @@ public:
|
||||||
LocalPlayer();
|
LocalPlayer();
|
||||||
|
|
||||||
void unlockWalk() { m_walkLocked = false; }
|
void unlockWalk() { m_walkLocked = false; }
|
||||||
void lockWalk();
|
void lockWalk(int millis = 250);
|
||||||
bool canWalk(Otc::Direction direction);
|
bool canWalk(Otc::Direction direction);
|
||||||
|
|
||||||
void setStates(int states);
|
void setStates(int states);
|
||||||
|
@ -112,6 +111,7 @@ private:
|
||||||
bool m_known;
|
bool m_known;
|
||||||
int m_states;
|
int m_states;
|
||||||
int m_vocation;
|
int m_vocation;
|
||||||
|
int m_walkLockInterval;
|
||||||
|
|
||||||
double m_health;
|
double m_health;
|
||||||
double m_maxHealth;
|
double m_maxHealth;
|
||||||
|
|
|
@ -164,6 +164,7 @@ void OTClient::registerLuaFunctions()
|
||||||
g_lua.bindSingletonFunction("g_game", "inspectNpcTrade", &Game::inspectNpcTrade, &g_game);
|
g_lua.bindSingletonFunction("g_game", "inspectNpcTrade", &Game::inspectNpcTrade, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "buyItem", &Game::buyItem, &g_game);
|
g_lua.bindSingletonFunction("g_game", "buyItem", &Game::buyItem, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "sellItem", &Game::sellItem, &g_game);
|
g_lua.bindSingletonFunction("g_game", "sellItem", &Game::sellItem, &g_game);
|
||||||
|
g_lua.bindSingletonFunction("g_game", "ping", &Game::ping, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "closeNpcTrade", &Game::closeNpcTrade, &g_game);
|
g_lua.bindSingletonFunction("g_game", "closeNpcTrade", &Game::closeNpcTrade, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "requestTrade", &Game::requestTrade, &g_game);
|
g_lua.bindSingletonFunction("g_game", "requestTrade", &Game::requestTrade, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "inspectTrade", &Game::inspectTrade, &g_game);
|
g_lua.bindSingletonFunction("g_game", "inspectTrade", &Game::inspectTrade, &g_game);
|
||||||
|
@ -249,6 +250,8 @@ void OTClient::registerLuaFunctions()
|
||||||
g_lua.bindClassMemberFunction<Thing>("getStackPriority", &Thing::getStackPriority);
|
g_lua.bindClassMemberFunction<Thing>("getStackPriority", &Thing::getStackPriority);
|
||||||
g_lua.bindClassMemberFunction<Thing>("getAnimationPhases", &Thing::getAnimationPhases);
|
g_lua.bindClassMemberFunction<Thing>("getAnimationPhases", &Thing::getAnimationPhases);
|
||||||
g_lua.bindClassMemberFunction<Thing>("isItem", &Thing::isItem);
|
g_lua.bindClassMemberFunction<Thing>("isItem", &Thing::isItem);
|
||||||
|
g_lua.bindClassMemberFunction<Thing>("isMonster", &Thing::isMonster);
|
||||||
|
g_lua.bindClassMemberFunction<Thing>("isNpc", &Thing::isNpc);
|
||||||
g_lua.bindClassMemberFunction<Thing>("isCreature", &Thing::isCreature);
|
g_lua.bindClassMemberFunction<Thing>("isCreature", &Thing::isCreature);
|
||||||
g_lua.bindClassMemberFunction<Thing>("isEffect", &Thing::isEffect);
|
g_lua.bindClassMemberFunction<Thing>("isEffect", &Thing::isEffect);
|
||||||
g_lua.bindClassMemberFunction<Thing>("isMissile", &Thing::isMissile);
|
g_lua.bindClassMemberFunction<Thing>("isMissile", &Thing::isMissile);
|
||||||
|
|
|
@ -219,6 +219,7 @@ private:
|
||||||
std::string m_accountName;
|
std::string m_accountName;
|
||||||
std::string m_accountPassword;
|
std::string m_accountPassword;
|
||||||
std::string m_characterName;
|
std::string m_characterName;
|
||||||
|
Timer m_pingTimer;
|
||||||
LocalPlayerPtr m_localPlayer;
|
LocalPlayerPtr m_localPlayer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -378,7 +378,7 @@ void ProtocolGame::parsePing(const InputMessagePtr& msg)
|
||||||
|
|
||||||
void ProtocolGame::parsePingBack(const InputMessagePtr& msg)
|
void ProtocolGame::parsePingBack(const InputMessagePtr& msg)
|
||||||
{
|
{
|
||||||
// nothing to do
|
g_game.processPingBack(m_pingTimer.ticksElapsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseChallange(const InputMessagePtr& msg)
|
void ProtocolGame::parseChallange(const InputMessagePtr& msg)
|
||||||
|
@ -928,7 +928,7 @@ void ProtocolGame::parsePlayerCancelAttack(const InputMessagePtr& msg)
|
||||||
|
|
||||||
void ProtocolGame::parseSpellCooldown(const InputMessagePtr& msg)
|
void ProtocolGame::parseSpellCooldown(const InputMessagePtr& msg)
|
||||||
{
|
{
|
||||||
msg->getU16(); // spell id
|
msg->getU8(); // spell id
|
||||||
msg->getU32(); // cooldown
|
msg->getU32(); // cooldown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1083,16 +1083,26 @@ void ProtocolGame::parseTextMessage(const InputMessagePtr& msg)
|
||||||
case Otc::MessageDamageReceived:
|
case Otc::MessageDamageReceived:
|
||||||
case Otc::MessageDamageOthers: {
|
case Otc::MessageDamageOthers: {
|
||||||
Position pos = getPosition(msg);
|
Position pos = getPosition(msg);
|
||||||
uint value = msg->getU32();
|
uint value[2];
|
||||||
int color = msg->getU8();
|
int color[2];
|
||||||
msg->getU32(); // ??
|
|
||||||
msg->getU8(); // ??
|
// physical damage
|
||||||
|
value[0] = msg->getU32();
|
||||||
|
color[0] = msg->getU8();
|
||||||
|
|
||||||
|
// magic damage
|
||||||
|
value[1] = msg->getU32();
|
||||||
|
color[1] = msg->getU8();
|
||||||
text = msg->getString();
|
text = msg->getString();
|
||||||
|
|
||||||
|
for(int i=0;i<2;++i) {
|
||||||
|
if(value[i] == 0)
|
||||||
|
continue;
|
||||||
AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
|
AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
|
||||||
animatedText->setColor(color);
|
animatedText->setColor(color[i]);
|
||||||
animatedText->setText(stdext::to_string(value));
|
animatedText->setText(stdext::to_string(value[i]));
|
||||||
g_map.addThing(animatedText, pos);
|
g_map.addThing(animatedText, pos);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Otc::MessageHeal:
|
case Otc::MessageHeal:
|
||||||
|
@ -1130,8 +1140,8 @@ void ProtocolGame::parseCancelWalk(const InputMessagePtr& msg)
|
||||||
|
|
||||||
void ProtocolGame::parseWalkWait(const InputMessagePtr& msg)
|
void ProtocolGame::parseWalkWait(const InputMessagePtr& msg)
|
||||||
{
|
{
|
||||||
//TODO: implement walk wait time
|
int millis = msg->getU16();
|
||||||
msg->getU16(); // time
|
m_localPlayer->lockWalk(millis);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parseFloorChangeUp(const InputMessagePtr& msg)
|
void ProtocolGame::parseFloorChangeUp(const InputMessagePtr& msg)
|
||||||
|
|
|
@ -109,6 +109,7 @@ void ProtocolGame::sendPing()
|
||||||
{
|
{
|
||||||
OutputMessagePtr msg(new OutputMessage);
|
OutputMessagePtr msg(new OutputMessage);
|
||||||
msg->addU8(Proto::ClientPing);
|
msg->addU8(Proto::ClientPing);
|
||||||
|
m_pingTimer.restart();
|
||||||
Protocol::send(msg);
|
Protocol::send(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue