New pvp modes to combat controls

This commit is contained in:
Sam
2013-11-19 00:50:00 +01:00
parent c98439ae65
commit 4d656f8bd1
15 changed files with 210 additions and 25 deletions

View File

@@ -206,6 +206,13 @@ namespace Otc
ChaseOpponent = 1
};
enum PVPModes {
WhiteDove = 0,
WhiteHand = 1,
YellowHand = 2,
RedFist = 3
};
enum PlayerSkulls {
SkullNone = 0,
SkullYellow,

View File

@@ -51,6 +51,7 @@ Game::Game()
m_canReportBugs = false;
m_fightMode = Otc::FightBalanced;
m_chaseMode = Otc::DontChase;
m_pvpMode = Otc::WhiteDove;
m_safeFight = true;
}
@@ -76,6 +77,7 @@ void Game::resetGameStates()
m_canReportBugs = false;
m_fightMode = Otc::FightBalanced;
m_chaseMode = Otc::DontChase;
m_pvpMode = Otc::WhiteDove;
m_safeFight = true;
m_followingCreature = nullptr;
m_attackingCreature = nullptr;
@@ -176,7 +178,7 @@ void Game::processGameStart()
m_online = true;
// synchronize fight modes with the server
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight, m_pvpMode);
// NOTE: the entire map description and local player information is not known yet (bot call is allowed here)
enableBotCall();
@@ -239,15 +241,17 @@ void Game::processPlayerHelpers(int helpers)
g_lua.callGlobalField("g_game", "onPlayerHelpersUpdate", helpers);
}
void Game::processPlayerModes(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeMode)
void Game::processPlayerModes(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeMode, Otc::PVPModes pvpMode)
{
m_fightMode = fightMode;
m_chaseMode = chaseMode;
m_safeFight = safeMode;
m_pvpMode = pvpMode;
g_lua.callGlobalField("g_game", "onFightModeChange", fightMode);
g_lua.callGlobalField("g_game", "onChaseModeChange", chaseMode);
g_lua.callGlobalField("g_game", "onSafeFightChange", safeMode);
g_lua.callGlobalField("g_game", "onPVPModeChange", pvpMode);
}
void Game::processPing()
@@ -1195,7 +1199,7 @@ void Game::setChaseMode(Otc::ChaseModes chaseMode)
if(m_chaseMode == chaseMode)
return;
m_chaseMode = chaseMode;
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight, m_pvpMode);
g_lua.callGlobalField("g_game", "onChaseModeChange", chaseMode);
}
@@ -1206,7 +1210,7 @@ void Game::setFightMode(Otc::FightModes fightMode)
if(m_fightMode == fightMode)
return;
m_fightMode = fightMode;
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight, m_pvpMode);
g_lua.callGlobalField("g_game", "onFightModeChange", fightMode);
}
@@ -1217,10 +1221,21 @@ void Game::setSafeFight(bool on)
if(m_safeFight == on)
return;
m_safeFight = on;
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight, m_pvpMode);
g_lua.callGlobalField("g_game", "onSafeFightChange", on);
}
void Game::setPVPMode(Otc::PVPModes pvpMode)
{
if(!canPerformGameAction())
return;
if(m_pvpMode == pvpMode)
return;
m_pvpMode = pvpMode;
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight, m_pvpMode);
g_lua.callGlobalField("g_game", "onPVPModeChange", pvpMode);
}
void Game::inspectNpcTrade(const ItemPtr& item)
{
if(!canPerformGameAction() || !item)

View File

@@ -74,7 +74,7 @@ protected:
void processWalkCancel(Otc::Direction direction);
void processPlayerHelpers(int helpers);
void processPlayerModes(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeMode);
void processPlayerModes(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeMode, Otc::PVPModes pvpMode);
// message related
void processTextMessage(Otc::MessageMode mode, const std::string& text);
@@ -211,9 +211,11 @@ public:
void setChaseMode(Otc::ChaseModes chaseMode);
void setFightMode(Otc::FightModes fightMode);
void setSafeFight(bool on);
void setPVPMode(Otc::PVPModes pvpMode);
Otc::ChaseModes getChaseMode() { return m_chaseMode; }
Otc::FightModes getFightMode() { return m_fightMode; }
bool isSafeFight() { return m_safeFight; }
Otc::PVPModes getPVPMode() { return m_pvpMode; }
// npc trade related
void inspectNpcTrade(const ItemPtr& item);
@@ -336,6 +338,7 @@ private:
int m_pingDelay;
Otc::FightModes m_fightMode;
Otc::ChaseModes m_chaseMode;
Otc::PVPModes m_pvpMode;
Otc::Direction m_lastWalkDir;
bool m_safeFight;
bool m_canReportBugs;

View File

@@ -218,9 +218,11 @@ void Client::registerLuaFunctions()
g_lua.bindSingletonFunction("g_game", "removeVip", &Game::removeVip, &g_game);
g_lua.bindSingletonFunction("g_game", "setChaseMode", &Game::setChaseMode, &g_game);
g_lua.bindSingletonFunction("g_game", "setFightMode", &Game::setFightMode, &g_game);
g_lua.bindSingletonFunction("g_game", "setPVPMode", &Game::setPVPMode, &g_game);
g_lua.bindSingletonFunction("g_game", "setSafeFight", &Game::setSafeFight, &g_game);
g_lua.bindSingletonFunction("g_game", "getChaseMode", &Game::getChaseMode, &g_game);
g_lua.bindSingletonFunction("g_game", "getFightMode", &Game::getFightMode, &g_game);
g_lua.bindSingletonFunction("g_game", "getPVPMode", &Game::getPVPMode, &g_game);
g_lua.bindSingletonFunction("g_game", "isSafeFight", &Game::isSafeFight, &g_game);
g_lua.bindSingletonFunction("g_game", "inspectNpcTrade", &Game::inspectNpcTrade, &g_game);
g_lua.bindSingletonFunction("g_game", "buyItem", &Game::buyItem, &g_game);

View File

@@ -83,7 +83,7 @@ public:
void sendCloseRuleViolation(const std::string& reporter);
void sendCancelRuleViolation();
void sendCloseNpcChannel();
void sendChangeFightModes(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeFight);
void sendChangeFightModes(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeFight, Otc::PVPModes pvpMode);
void sendAttack(uint creatureId, uint seq);
void sendFollow(uint creatureId, uint seq);
void sendInviteToParty(uint creatureId);

View File

@@ -1158,11 +1158,11 @@ void ProtocolGame::parsePlayerModes(const InputMessagePtr& msg)
int chaseMode = msg->getU8();
bool safeMode = msg->getU8();
//TODO: implement pvp modes
int pvpMode = 0;
if(g_game.getFeature(Otc::GamePVPMode))
msg->getU8(); // pvp mode
pvpMode = msg->getU8();
g_game.processPlayerModes((Otc::FightModes)fightMode, (Otc::ChaseModes)chaseMode, safeMode);
g_game.processPlayerModes((Otc::FightModes)fightMode, (Otc::ChaseModes)chaseMode, safeMode, (Otc::PVPModes)pvpMode);
}
void ProtocolGame::parseSpellCooldown(const InputMessagePtr& msg)

View File

@@ -573,7 +573,7 @@ void ProtocolGame::sendCloseNpcChannel()
send(msg);
}
void ProtocolGame::sendChangeFightModes(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeFight)
void ProtocolGame::sendChangeFightModes(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeFight, Otc::PVPModes pvpMode)
{
OutputMessagePtr msg(new OutputMessage);
msg->addU8(Proto::ClientChangeFightModes);
@@ -581,9 +581,8 @@ void ProtocolGame::sendChangeFightModes(Otc::FightModes fightMode, Otc::ChaseMod
msg->addU8(chaseMode);
msg->addU8(safeFight ? 0x01: 0x00);
//TODO: implement pvp modes
if(g_game.getFeature(Otc::GamePVPMode))
msg->addU8(0); // pvp mode
msg->addU8(pvpMode);
send(msg);
}