New pvp modes to combat controls
This commit is contained in:
parent
c98439ae65
commit
4d656f8bd1
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
|
@ -5,7 +5,14 @@ fightBalancedBox = nil
|
||||||
fightDefensiveBox = nil
|
fightDefensiveBox = nil
|
||||||
chaseModeButton = nil
|
chaseModeButton = nil
|
||||||
safeFightButton = nil
|
safeFightButton = nil
|
||||||
|
whiteDoveBox = nil
|
||||||
|
whiteHandBox = nil
|
||||||
|
yellowHandBox = nil
|
||||||
|
redFistBox = nil
|
||||||
|
mountButton = nil
|
||||||
|
pvpModesPanel = nil
|
||||||
fightModeRadioGroup = nil
|
fightModeRadioGroup = nil
|
||||||
|
pvpModeRadioGroup = nil
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
combatControlsButton = modules.client_topmenu.addRightGameToggleButton('combatControlsButton', tr('Combat Controls'), '/images/topbuttons/combatcontrols', toggle)
|
combatControlsButton = modules.client_topmenu.addRightGameToggleButton('combatControlsButton', tr('Combat Controls'), '/images/topbuttons/combatcontrols', toggle)
|
||||||
|
@ -16,15 +23,33 @@ function init()
|
||||||
fightOffensiveBox = combatControlsWindow:recursiveGetChildById('fightOffensiveBox')
|
fightOffensiveBox = combatControlsWindow:recursiveGetChildById('fightOffensiveBox')
|
||||||
fightBalancedBox = combatControlsWindow:recursiveGetChildById('fightBalancedBox')
|
fightBalancedBox = combatControlsWindow:recursiveGetChildById('fightBalancedBox')
|
||||||
fightDefensiveBox = combatControlsWindow:recursiveGetChildById('fightDefensiveBox')
|
fightDefensiveBox = combatControlsWindow:recursiveGetChildById('fightDefensiveBox')
|
||||||
|
|
||||||
chaseModeButton = combatControlsWindow:recursiveGetChildById('chaseModeBox')
|
chaseModeButton = combatControlsWindow:recursiveGetChildById('chaseModeBox')
|
||||||
safeFightButton = combatControlsWindow:recursiveGetChildById('safeFightBox')
|
safeFightButton = combatControlsWindow:recursiveGetChildById('safeFightBox')
|
||||||
|
|
||||||
|
mountButton = combatControlsWindow:recursiveGetChildById('mountButton')
|
||||||
|
mountButton.onClick = onMountButtonClick
|
||||||
|
|
||||||
|
pvpModesPanel = combatControlsWindow:recursiveGetChildById('pvpModesPanel')
|
||||||
|
|
||||||
|
whiteDoveBox = combatControlsWindow:recursiveGetChildById('whiteDoveBox')
|
||||||
|
whiteHandBox = combatControlsWindow:recursiveGetChildById('whiteHandBox')
|
||||||
|
yellowHandBox = combatControlsWindow:recursiveGetChildById('yellowHandBox')
|
||||||
|
redFistBox = combatControlsWindow:recursiveGetChildById('redFistBox')
|
||||||
|
|
||||||
fightModeRadioGroup = UIRadioGroup.create()
|
fightModeRadioGroup = UIRadioGroup.create()
|
||||||
fightModeRadioGroup:addWidget(fightOffensiveBox)
|
fightModeRadioGroup:addWidget(fightOffensiveBox)
|
||||||
fightModeRadioGroup:addWidget(fightBalancedBox)
|
fightModeRadioGroup:addWidget(fightBalancedBox)
|
||||||
fightModeRadioGroup:addWidget(fightDefensiveBox)
|
fightModeRadioGroup:addWidget(fightDefensiveBox)
|
||||||
|
|
||||||
|
pvpModeRadioGroup = UIRadioGroup.create()
|
||||||
|
pvpModeRadioGroup:addWidget(whiteDoveBox)
|
||||||
|
pvpModeRadioGroup:addWidget(whiteHandBox)
|
||||||
|
pvpModeRadioGroup:addWidget(yellowHandBox)
|
||||||
|
pvpModeRadioGroup:addWidget(redFistBox)
|
||||||
|
|
||||||
connect(fightModeRadioGroup, { onSelectionChange = onSetFightMode })
|
connect(fightModeRadioGroup, { onSelectionChange = onSetFightMode })
|
||||||
|
connect(pvpModeRadioGroup, { onSelectionChange = onSetPVPMode })
|
||||||
connect(chaseModeButton, { onCheckChange = onSetChaseMode })
|
connect(chaseModeButton, { onCheckChange = onSetChaseMode })
|
||||||
connect(safeFightButton, { onCheckChange = onSetSafeFight })
|
connect(safeFightButton, { onCheckChange = onSetSafeFight })
|
||||||
connect(g_game, {
|
connect(g_game, {
|
||||||
|
@ -33,10 +58,13 @@ function init()
|
||||||
onFightModeChange = update,
|
onFightModeChange = update,
|
||||||
onChaseModeChange = update,
|
onChaseModeChange = update,
|
||||||
onSafeFightChange = update,
|
onSafeFightChange = update,
|
||||||
|
onPVPModeChange = update,
|
||||||
onWalk = check,
|
onWalk = check,
|
||||||
onAutoWalk = check
|
onAutoWalk = check
|
||||||
})
|
})
|
||||||
|
|
||||||
|
connect(LocalPlayer, { onOutfitChange = onOutfitChange })
|
||||||
|
|
||||||
if g_game.isOnline() then
|
if g_game.isOnline() then
|
||||||
online()
|
online()
|
||||||
end
|
end
|
||||||
|
@ -50,6 +78,7 @@ function terminate()
|
||||||
end
|
end
|
||||||
|
|
||||||
fightModeRadioGroup:destroy()
|
fightModeRadioGroup:destroy()
|
||||||
|
pvpModeRadioGroup:destroy()
|
||||||
combatControlsWindow:destroy()
|
combatControlsWindow:destroy()
|
||||||
combatControlsButton:destroy()
|
combatControlsButton:destroy()
|
||||||
|
|
||||||
|
@ -59,9 +88,12 @@ function terminate()
|
||||||
onFightModeChange = update,
|
onFightModeChange = update,
|
||||||
onChaseModeChange = update,
|
onChaseModeChange = update,
|
||||||
onSafeFightChange = update,
|
onSafeFightChange = update,
|
||||||
|
onPVPModeChange = update,
|
||||||
onWalk = check,
|
onWalk = check,
|
||||||
onAutoWalk = check
|
onAutoWalk = check
|
||||||
})
|
})
|
||||||
|
|
||||||
|
disconnect(LocalPlayer, { onOutfitChange = onOutfitChange })
|
||||||
end
|
end
|
||||||
|
|
||||||
function update()
|
function update()
|
||||||
|
@ -79,6 +111,14 @@ function update()
|
||||||
|
|
||||||
local safeFight = g_game.isSafeFight()
|
local safeFight = g_game.isSafeFight()
|
||||||
safeFightButton:setChecked(not safeFight)
|
safeFightButton:setChecked(not safeFight)
|
||||||
|
|
||||||
|
if g_game.getFeature(GamePVPMode) then
|
||||||
|
local pvpMode = g_game.getPVPMode()
|
||||||
|
local pvpWidget = getPVPBoxByMode(pvpMode)
|
||||||
|
if pvpWidget then
|
||||||
|
pvpModeRadioGroup:selectWidget(pvpWidget)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function check()
|
function check()
|
||||||
|
@ -101,8 +141,26 @@ function online()
|
||||||
g_game.setFightMode(lastCombatControls[char].fightMode)
|
g_game.setFightMode(lastCombatControls[char].fightMode)
|
||||||
g_game.setChaseMode(lastCombatControls[char].chaseMode)
|
g_game.setChaseMode(lastCombatControls[char].chaseMode)
|
||||||
g_game.setSafeFight(lastCombatControls[char].safeFight)
|
g_game.setSafeFight(lastCombatControls[char].safeFight)
|
||||||
|
if g_game.getFeature(GamePVPMode) and lastCombatControls[char].pvpMode then
|
||||||
|
g_game.setPVPMode(lastCombatControls[char].pvpMode)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if g_game.getFeature(GamePlayerMounts) then
|
||||||
|
mountButton:setVisible(true)
|
||||||
|
mountButton:setChecked(player:isMounted())
|
||||||
|
else
|
||||||
|
mountButton:setVisible(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
if g_game.getFeature(GamePVPMode) then
|
||||||
|
pvpModesPanel:setVisible(true)
|
||||||
|
combatControlsWindow:setHeight(combatControlsWindow.extendedControlsHeight)
|
||||||
|
else
|
||||||
|
pvpModesPanel:setVisible(false)
|
||||||
|
combatControlsWindow:setHeight(combatControlsWindow.simpleControlsHeight)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
update()
|
update()
|
||||||
|
@ -123,6 +181,10 @@ function offline()
|
||||||
safeFight = g_game.isSafeFight()
|
safeFight = g_game.isSafeFight()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if g_game.getFeature(GamePVPMode) then
|
||||||
|
lastCombatControls[char].pvpMode = g_game.getPVPMode()
|
||||||
|
end
|
||||||
|
|
||||||
-- save last combat control settings
|
-- save last combat control settings
|
||||||
g_settings.setNode('LastCombatControls', lastCombatControls)
|
g_settings.setNode('LastCombatControls', lastCombatControls)
|
||||||
end
|
end
|
||||||
|
@ -166,6 +228,57 @@ function onSetSafeFight(self, checked)
|
||||||
g_game.setSafeFight(not checked)
|
g_game.setSafeFight(not checked)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function onSetPVPMode(self, selectedPVPButton)
|
||||||
|
if selectedPVPButton == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local buttonId = selectedPVPButton:getId()
|
||||||
|
local pvpMode = PVPWhiteDove
|
||||||
|
if buttonId == 'whiteDoveBox' then
|
||||||
|
pvpMode = PVPWhiteDove
|
||||||
|
elseif buttonId == 'whiteHandBox' then
|
||||||
|
pvpMode = PVPWhiteHand
|
||||||
|
elseif buttonId == 'yellowHandBox' then
|
||||||
|
pvpMode = PVPYellowHand
|
||||||
|
elseif buttonId == 'redFistBox' then
|
||||||
|
pvpMode = PVPRedFist
|
||||||
|
end
|
||||||
|
|
||||||
|
if g_game.getFeature(GamePVPMode) then
|
||||||
|
g_game.setPVPMode(pvpMode)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function onMiniWindowClose()
|
function onMiniWindowClose()
|
||||||
combatControlsButton:setOn(false)
|
combatControlsButton:setOn(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function onMountButtonClick(self, mousePos)
|
||||||
|
local player = g_game.getLocalPlayer()
|
||||||
|
if player then
|
||||||
|
player:toggleMount()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function onOutfitChange(localPlayer, outfit, oldOutfit)
|
||||||
|
if outfit.mount == oldOutfit.mount then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
mountButton:setChecked(outfit.mount ~= nil and outfit.mount > 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function getPVPBoxByMode(mode)
|
||||||
|
local widget = nil
|
||||||
|
if mode == PVPWhiteDove then
|
||||||
|
widget = whiteDoveBox
|
||||||
|
elseif mode == PVPWhiteHand then
|
||||||
|
widget = whiteHandBox
|
||||||
|
elseif mode == PVPYellowHand then
|
||||||
|
widget = yellowHandBox
|
||||||
|
elseif mode == PVPRedFist then
|
||||||
|
widget = redFistBox
|
||||||
|
end
|
||||||
|
return widget
|
||||||
|
end
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
CombatBox < UICheckBox
|
CombatBox < UICheckBox
|
||||||
size: 20 20
|
size: 20 20
|
||||||
image-clip: 0 0 20 20
|
image-clip: 0 0 20 20
|
||||||
anchors.top: parent.top
|
margin: 2 4
|
||||||
margin: 0 4
|
|
||||||
$first:
|
|
||||||
margin: 0 1
|
|
||||||
$last:
|
|
||||||
margin: 0 1
|
|
||||||
|
|
||||||
$checked:
|
$checked:
|
||||||
image-clip: 0 20 20 20
|
image-clip: 0 20 20 20
|
||||||
|
@ -22,32 +17,77 @@ ChaseModeBox < CombatBox
|
||||||
SafeFightBox < CombatBox
|
SafeFightBox < CombatBox
|
||||||
image-source: /images/game/combatmodes/safefight
|
image-source: /images/game/combatmodes/safefight
|
||||||
|
|
||||||
|
MountButton < CombatBox
|
||||||
|
image-source: /images/game/combatmodes/mount
|
||||||
|
|
||||||
|
WhiteDoveBox < CombatBox
|
||||||
|
image-source: /images/game/combatmodes/whitedovemode
|
||||||
|
WhiteHandBox < CombatBox
|
||||||
|
image-source: /images/game/combatmodes/whitehandmode
|
||||||
|
YellowHandBox < CombatBox
|
||||||
|
image-source: /images/game/combatmodes/yellowhandmode
|
||||||
|
RedFistBox < CombatBox
|
||||||
|
image-source: /images/game/combatmodes/redfistmode
|
||||||
|
|
||||||
MiniWindow
|
MiniWindow
|
||||||
id: combatControlsWindow
|
id: combatControlsWindow
|
||||||
!text: tr('Combat Controls')
|
!text: tr('Combat Controls')
|
||||||
icon: /images/topbuttons/combatcontrols
|
icon: /images/topbuttons/combatcontrols
|
||||||
height: 48
|
height: 49
|
||||||
&save: true
|
&save: true
|
||||||
|
&simpleControlsHeight: 49
|
||||||
|
&extendedControlsHeight: 72
|
||||||
@onClose: modules.game_combatcontrols.onMiniWindowClose()
|
@onClose: modules.game_combatcontrols.onMiniWindowClose()
|
||||||
|
|
||||||
MiniWindowContents
|
MiniWindowContents
|
||||||
FightOffensiveBox
|
FightOffensiveBox
|
||||||
id: fightOffensiveBox
|
id: fightOffensiveBox
|
||||||
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
margin: 2 1
|
||||||
FightBalancedBox
|
FightBalancedBox
|
||||||
id: fightBalancedBox
|
id: fightBalancedBox
|
||||||
|
anchors.top: parent.top
|
||||||
anchors.left: prev.right
|
anchors.left: prev.right
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
FightDefensiveBox
|
FightDefensiveBox
|
||||||
id: fightDefensiveBox
|
id: fightDefensiveBox
|
||||||
|
anchors.top: parent.top
|
||||||
anchors.left: prev.right
|
anchors.left: prev.right
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
MountButton
|
||||||
|
id: mountButton
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.right: next.left
|
||||||
ChaseModeBox
|
ChaseModeBox
|
||||||
id: chaseModeBox
|
id: chaseModeBox
|
||||||
|
anchors.top: parent.top
|
||||||
anchors.right: next.left
|
anchors.right: next.left
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
SafeFightBox
|
SafeFightBox
|
||||||
id: safeFightBox
|
id: safeFightBox
|
||||||
|
anchors.top: parent.top
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
margin: 2 1
|
||||||
|
|
||||||
|
Panel
|
||||||
|
id: pvpModesPanel
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
height: 20
|
||||||
|
|
||||||
|
WhiteDoveBox
|
||||||
|
id: whiteDoveBox
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
margin: 2 1
|
||||||
|
WhiteHandBox
|
||||||
|
id: whiteHandBox
|
||||||
|
anchors.left: prev.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
YellowHandBox
|
||||||
|
id: yellowHandBox
|
||||||
|
anchors.left: prev.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
RedFistBox
|
||||||
|
id: redFistBox
|
||||||
|
anchors.left: prev.right
|
||||||
|
anchors.bottom: parent.bottom
|
|
@ -47,6 +47,11 @@ FightDefensive = 3
|
||||||
DontChase = 0
|
DontChase = 0
|
||||||
ChaseOpponent = 1
|
ChaseOpponent = 1
|
||||||
|
|
||||||
|
PVPWhiteDove = 0
|
||||||
|
PVPWhiteHand = 1
|
||||||
|
PVPYellowHand = 2
|
||||||
|
PVPRedFist = 3
|
||||||
|
|
||||||
GameProtocolChecksum = 1
|
GameProtocolChecksum = 1
|
||||||
GameAccountNames = 2
|
GameAccountNames = 2
|
||||||
GameChallengeOnLogin = 3
|
GameChallengeOnLogin = 3
|
||||||
|
@ -94,6 +99,7 @@ GameMesssageLevel = 46
|
||||||
GameNewFluids = 47
|
GameNewFluids = 47
|
||||||
GamePlayerStateU16 = 48
|
GamePlayerStateU16 = 48
|
||||||
GameNewOutfitProtocol = 49
|
GameNewOutfitProtocol = 49
|
||||||
|
GamePVPMode = 50
|
||||||
|
|
||||||
TextColors = {
|
TextColors = {
|
||||||
red = '#f55e5e', --'#c83200'
|
red = '#f55e5e', --'#c83200'
|
||||||
|
|
|
@ -206,6 +206,13 @@ namespace Otc
|
||||||
ChaseOpponent = 1
|
ChaseOpponent = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum PVPModes {
|
||||||
|
WhiteDove = 0,
|
||||||
|
WhiteHand = 1,
|
||||||
|
YellowHand = 2,
|
||||||
|
RedFist = 3
|
||||||
|
};
|
||||||
|
|
||||||
enum PlayerSkulls {
|
enum PlayerSkulls {
|
||||||
SkullNone = 0,
|
SkullNone = 0,
|
||||||
SkullYellow,
|
SkullYellow,
|
||||||
|
|
|
@ -51,6 +51,7 @@ Game::Game()
|
||||||
m_canReportBugs = false;
|
m_canReportBugs = false;
|
||||||
m_fightMode = Otc::FightBalanced;
|
m_fightMode = Otc::FightBalanced;
|
||||||
m_chaseMode = Otc::DontChase;
|
m_chaseMode = Otc::DontChase;
|
||||||
|
m_pvpMode = Otc::WhiteDove;
|
||||||
m_safeFight = true;
|
m_safeFight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +77,7 @@ void Game::resetGameStates()
|
||||||
m_canReportBugs = false;
|
m_canReportBugs = false;
|
||||||
m_fightMode = Otc::FightBalanced;
|
m_fightMode = Otc::FightBalanced;
|
||||||
m_chaseMode = Otc::DontChase;
|
m_chaseMode = Otc::DontChase;
|
||||||
|
m_pvpMode = Otc::WhiteDove;
|
||||||
m_safeFight = true;
|
m_safeFight = true;
|
||||||
m_followingCreature = nullptr;
|
m_followingCreature = nullptr;
|
||||||
m_attackingCreature = nullptr;
|
m_attackingCreature = nullptr;
|
||||||
|
@ -176,7 +178,7 @@ void Game::processGameStart()
|
||||||
m_online = true;
|
m_online = true;
|
||||||
|
|
||||||
// synchronize fight modes with the server
|
// 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)
|
// NOTE: the entire map description and local player information is not known yet (bot call is allowed here)
|
||||||
enableBotCall();
|
enableBotCall();
|
||||||
|
@ -239,15 +241,17 @@ void Game::processPlayerHelpers(int helpers)
|
||||||
g_lua.callGlobalField("g_game", "onPlayerHelpersUpdate", 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_fightMode = fightMode;
|
||||||
m_chaseMode = chaseMode;
|
m_chaseMode = chaseMode;
|
||||||
m_safeFight = safeMode;
|
m_safeFight = safeMode;
|
||||||
|
m_pvpMode = pvpMode;
|
||||||
|
|
||||||
g_lua.callGlobalField("g_game", "onFightModeChange", fightMode);
|
g_lua.callGlobalField("g_game", "onFightModeChange", fightMode);
|
||||||
g_lua.callGlobalField("g_game", "onChaseModeChange", chaseMode);
|
g_lua.callGlobalField("g_game", "onChaseModeChange", chaseMode);
|
||||||
g_lua.callGlobalField("g_game", "onSafeFightChange", safeMode);
|
g_lua.callGlobalField("g_game", "onSafeFightChange", safeMode);
|
||||||
|
g_lua.callGlobalField("g_game", "onPVPModeChange", pvpMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::processPing()
|
void Game::processPing()
|
||||||
|
@ -1195,7 +1199,7 @@ void Game::setChaseMode(Otc::ChaseModes chaseMode)
|
||||||
if(m_chaseMode == chaseMode)
|
if(m_chaseMode == chaseMode)
|
||||||
return;
|
return;
|
||||||
m_chaseMode = chaseMode;
|
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);
|
g_lua.callGlobalField("g_game", "onChaseModeChange", chaseMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1206,7 +1210,7 @@ void Game::setFightMode(Otc::FightModes fightMode)
|
||||||
if(m_fightMode == fightMode)
|
if(m_fightMode == fightMode)
|
||||||
return;
|
return;
|
||||||
m_fightMode = fightMode;
|
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);
|
g_lua.callGlobalField("g_game", "onFightModeChange", fightMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1217,10 +1221,21 @@ void Game::setSafeFight(bool on)
|
||||||
if(m_safeFight == on)
|
if(m_safeFight == on)
|
||||||
return;
|
return;
|
||||||
m_safeFight = on;
|
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);
|
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)
|
void Game::inspectNpcTrade(const ItemPtr& item)
|
||||||
{
|
{
|
||||||
if(!canPerformGameAction() || !item)
|
if(!canPerformGameAction() || !item)
|
||||||
|
|
|
@ -74,7 +74,7 @@ protected:
|
||||||
void processWalkCancel(Otc::Direction direction);
|
void processWalkCancel(Otc::Direction direction);
|
||||||
|
|
||||||
void processPlayerHelpers(int helpers);
|
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
|
// message related
|
||||||
void processTextMessage(Otc::MessageMode mode, const std::string& text);
|
void processTextMessage(Otc::MessageMode mode, const std::string& text);
|
||||||
|
@ -211,9 +211,11 @@ public:
|
||||||
void setChaseMode(Otc::ChaseModes chaseMode);
|
void setChaseMode(Otc::ChaseModes chaseMode);
|
||||||
void setFightMode(Otc::FightModes fightMode);
|
void setFightMode(Otc::FightModes fightMode);
|
||||||
void setSafeFight(bool on);
|
void setSafeFight(bool on);
|
||||||
|
void setPVPMode(Otc::PVPModes pvpMode);
|
||||||
Otc::ChaseModes getChaseMode() { return m_chaseMode; }
|
Otc::ChaseModes getChaseMode() { return m_chaseMode; }
|
||||||
Otc::FightModes getFightMode() { return m_fightMode; }
|
Otc::FightModes getFightMode() { return m_fightMode; }
|
||||||
bool isSafeFight() { return m_safeFight; }
|
bool isSafeFight() { return m_safeFight; }
|
||||||
|
Otc::PVPModes getPVPMode() { return m_pvpMode; }
|
||||||
|
|
||||||
// npc trade related
|
// npc trade related
|
||||||
void inspectNpcTrade(const ItemPtr& item);
|
void inspectNpcTrade(const ItemPtr& item);
|
||||||
|
@ -336,6 +338,7 @@ private:
|
||||||
int m_pingDelay;
|
int m_pingDelay;
|
||||||
Otc::FightModes m_fightMode;
|
Otc::FightModes m_fightMode;
|
||||||
Otc::ChaseModes m_chaseMode;
|
Otc::ChaseModes m_chaseMode;
|
||||||
|
Otc::PVPModes m_pvpMode;
|
||||||
Otc::Direction m_lastWalkDir;
|
Otc::Direction m_lastWalkDir;
|
||||||
bool m_safeFight;
|
bool m_safeFight;
|
||||||
bool m_canReportBugs;
|
bool m_canReportBugs;
|
||||||
|
|
|
@ -218,9 +218,11 @@ void Client::registerLuaFunctions()
|
||||||
g_lua.bindSingletonFunction("g_game", "removeVip", &Game::removeVip, &g_game);
|
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", "setChaseMode", &Game::setChaseMode, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "setFightMode", &Game::setFightMode, &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", "setSafeFight", &Game::setSafeFight, &g_game);
|
||||||
g_lua.bindSingletonFunction("g_game", "getChaseMode", &Game::getChaseMode, &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", "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", "isSafeFight", &Game::isSafeFight, &g_game);
|
||||||
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);
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
void sendCloseRuleViolation(const std::string& reporter);
|
void sendCloseRuleViolation(const std::string& reporter);
|
||||||
void sendCancelRuleViolation();
|
void sendCancelRuleViolation();
|
||||||
void sendCloseNpcChannel();
|
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 sendAttack(uint creatureId, uint seq);
|
||||||
void sendFollow(uint creatureId, uint seq);
|
void sendFollow(uint creatureId, uint seq);
|
||||||
void sendInviteToParty(uint creatureId);
|
void sendInviteToParty(uint creatureId);
|
||||||
|
|
|
@ -1158,11 +1158,11 @@ void ProtocolGame::parsePlayerModes(const InputMessagePtr& msg)
|
||||||
int chaseMode = msg->getU8();
|
int chaseMode = msg->getU8();
|
||||||
bool safeMode = msg->getU8();
|
bool safeMode = msg->getU8();
|
||||||
|
|
||||||
//TODO: implement pvp modes
|
int pvpMode = 0;
|
||||||
if(g_game.getFeature(Otc::GamePVPMode))
|
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)
|
void ProtocolGame::parseSpellCooldown(const InputMessagePtr& msg)
|
||||||
|
|
|
@ -573,7 +573,7 @@ void ProtocolGame::sendCloseNpcChannel()
|
||||||
send(msg);
|
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);
|
OutputMessagePtr msg(new OutputMessage);
|
||||||
msg->addU8(Proto::ClientChangeFightModes);
|
msg->addU8(Proto::ClientChangeFightModes);
|
||||||
|
@ -581,9 +581,8 @@ void ProtocolGame::sendChangeFightModes(Otc::FightModes fightMode, Otc::ChaseMod
|
||||||
msg->addU8(chaseMode);
|
msg->addU8(chaseMode);
|
||||||
msg->addU8(safeFight ? 0x01: 0x00);
|
msg->addU8(safeFight ? 0x01: 0x00);
|
||||||
|
|
||||||
//TODO: implement pvp modes
|
|
||||||
if(g_game.getFeature(Otc::GamePVPMode))
|
if(g_game.getFeature(Otc::GamePVPMode))
|
||||||
msg->addU8(0); // pvp mode
|
msg->addU8(pvpMode);
|
||||||
|
|
||||||
send(msg);
|
send(msg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue