summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-11-02 04:40:58 +0300
committerAndrei Karas <akaras@inbox.ru>2011-11-02 04:41:47 +0300
commitb90214b9878246ec45e68c0c6c309337d8e15ef2 (patch)
treeea977f4aaf1bc2ab8cd86f77103d1bc9cee9e1d9
parent17631dacf2cb8ebc3acc1dae9df0729a80a150d9 (diff)
downloadmv-b90214b9878246ec45e68c0c6c309337d8e15ef2.tar.gz
mv-b90214b9878246ec45e68c0c6c309337d8e15ef2.tar.bz2
mv-b90214b9878246ec45e68c0c6c309337d8e15ef2.tar.xz
mv-b90214b9878246ec45e68c0c6c309337d8e15ef2.zip
Add option to yellow bar to change player attack in pvp mode.
Modes: attack all, attack not friends, attack bad relations, dont attack players.
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/game.cpp8
-rw-r--r--src/gui/ministatuswindow.cpp2
-rw-r--r--src/gui/statuspopup.cpp46
-rw-r--r--src/gui/statuspopup.h1
-rw-r--r--src/gui/statuswindow.cpp19
-rw-r--r--src/keyboardconfig.cpp2
-rw-r--r--src/keyboardconfig.h1
-rw-r--r--src/localplayer.cpp70
-rw-r--r--src/localplayer.h9
-rw-r--r--src/playerrelations.cpp17
-rw-r--r--src/playerrelations.h1
12 files changed, 153 insertions, 24 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index c5397a7d5..d7386fc07 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -220,6 +220,7 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "enableLazyScrolling", true);
AddDEF(configData, "extMouseTargeting", true);
AddDEF(configData, "showMVP", false);
+ AddDEF(configData, "pvpAttackType", 0);
return configData;
}
diff --git a/src/game.cpp b/src/game.cpp
index 021943822..14e6806ce 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1105,6 +1105,14 @@ void Game::handleInput()
}
break;
+ case KeyboardConfig::KEY_SWITCH_PVP_ATTACK:
+ if (player_node)
+ {
+ if (!player_node->getDisableGameModifiers())
+ player_node->switchPvpAttack();
+ }
+ break;
+
case KeyboardConfig::KEY_CHANGE_MOVE_TO_TARGET:
if (player_node)
{
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp
index 3e66f42cb..d307dfed0 100644
--- a/src/gui/ministatuswindow.cpp
+++ b/src/gui/ministatuswindow.cpp
@@ -100,7 +100,7 @@ MiniStatusWindow::MiniStatusWindow():
mArrowsBar = createBar(0, 50, 20, Theme::PROG_INVY_SLOTS,
"arrows bar", _("arrows bar"));
- mStatusBar = createBar(100, 150, 20, Theme::PROG_EXP,
+ mStatusBar = createBar(100, 165, 20, Theme::PROG_EXP,
"status bar", _("status bar"));
loadBars();
diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp
index 9807fac47..5f2ec71e3 100644
--- a/src/gui/statuspopup.cpp
+++ b/src/gui/statuspopup.cpp
@@ -75,29 +75,33 @@ StatusPopup::StatusPopup():
mMagicAttackType->setPosition(getPadding(),
4 + 6 * fontHeight + getPadding());
+ mPvpAttackType = new Label;
+ mPvpAttackType->setPosition(getPadding(),
+ 4 + 7 * fontHeight + getPadding());
+
mDropCounter = new Label;
- mDropCounter->setPosition(getPadding(), 8 + 7 * fontHeight + getPadding());
+ mDropCounter->setPosition(getPadding(), 8 + 8 * fontHeight + getPadding());
mPickUpType = new Label;
- mPickUpType->setPosition(getPadding(), 8 + 8 * fontHeight + getPadding());
+ mPickUpType->setPosition(getPadding(), 8 + 9 * fontHeight + getPadding());
mMapType = new Label;
- mMapType->setPosition(getPadding(), 12 + 9 * fontHeight + getPadding());
+ mMapType->setPosition(getPadding(), 12 + 10 * fontHeight + getPadding());
mImitationMode = new Label;
mImitationMode->setPosition(getPadding(),
- 16 + 10 * fontHeight + getPadding());
+ 16 + 11 * fontHeight + getPadding());
mAwayMode = new Label;
- mAwayMode->setPosition(getPadding(), 16 + 11 * fontHeight + getPadding());
+ mAwayMode->setPosition(getPadding(), 16 + 12 * fontHeight + getPadding());
mCameraMode = new Label;
mCameraMode->setPosition(getPadding(),
- 16 + 12 * fontHeight + getPadding());
+ 16 + 13 * fontHeight + getPadding());
mDisableGameModifiers = new Label;
mDisableGameModifiers->setPosition(getPadding(),
- 20 + 13 * fontHeight + getPadding());
+ 20 + 14 * fontHeight + getPadding());
add(mMoveType);
add(mCrazyMoveType);
@@ -109,6 +113,7 @@ StatusPopup::StatusPopup():
add(mPickUpType);
add(mMapType);
add(mMagicAttackType);
+ add(mPvpAttackType);
add(mDisableGameModifiers);
add(mImitationMode);
add(mAwayMode);
@@ -145,6 +150,8 @@ void StatusPopup::update()
minWidth = mMapType->getWidth();
if (mMagicAttackType->getWidth() > minWidth)
minWidth = mMagicAttackType->getWidth();
+ if (mPvpAttackType->getWidth() > minWidth)
+ minWidth = mPvpAttackType->getWidth();
if (mDisableGameModifiers->getWidth() > minWidth)
minWidth = mDisableGameModifiers->getWidth();
if (mAwayMode->getWidth() > minWidth)
@@ -476,6 +483,31 @@ void StatusPopup::updateLabels()
}
mMagicAttackType->adjustSize();
+ switch (player_node->getPvpAttackType())
+ {
+ case 0:
+ setLabelText(mPvpAttackType, _("(a) attack all players"),
+ keyboard.KEY_SWITCH_PVP_ATTACK);
+ break;
+ case 1:
+ setLabelText(mPvpAttackType, _("(f) attack not friends"),
+ keyboard.KEY_SWITCH_PVP_ATTACK);
+ break;
+ case 2:
+ setLabelText(mPvpAttackType, _("(b) attack bad relations"),
+ keyboard.KEY_SWITCH_PVP_ATTACK);
+ break;
+ case 3:
+ setLabelText(mPvpAttackType, _("(d) dont attack players"),
+ keyboard.KEY_SWITCH_PVP_ATTACK);
+ break;
+ default:
+ setLabelText(mMagicAttackType, _("(?) pvp attack"),
+ keyboard.KEY_SWITCH_MAGIC_ATTACK);
+ break;
+ }
+ mPvpAttackType->adjustSize();
+
switch (player_node->getImitationMode())
{
case 0:
diff --git a/src/gui/statuspopup.h b/src/gui/statuspopup.h
index 802b077a6..2af8064c5 100644
--- a/src/gui/statuspopup.h
+++ b/src/gui/statuspopup.h
@@ -72,6 +72,7 @@ class StatusPopup : public Popup
gcn::Label *mPickUpType;
gcn::Label *mMapType;
gcn::Label *mMagicAttackType;
+ gcn::Label *mPvpAttackType;
gcn::Label *mDisableGameModifiers;
gcn::Label *mImitationMode;
gcn::Label *mAwayMode;
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 92e69b394..bd88fad7e 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -787,6 +787,25 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED)
break;
}
+ switch (player_node->getPvpAttackType())
+ {
+ case 0:
+ str += translateLetter(N_("(a)"));
+ break;
+ case 1:
+ str += translateLetter(N_("(f)"));
+ break;
+ case 2:
+ str += translateLetter(N_("(b)"));
+ break;
+ case 3:
+ str += translateLetter(N_("(d)"));
+ break;
+ default:
+ str += translateLetter(N_("(?)"));
+ break;
+ }
+
str += " " + toString(player_node->getQuickDropCounter());
switch (player_node->getPickUpType())
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index fdc8201ca..3e387ba64 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -325,6 +325,8 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
KeyboardConfig::GRP_DEFAULT},
{"keySwitchMagicAttack", SDLK_COMMA, N_("Switch magic attack"),
KeyboardConfig::GRP_DEFAULT},
+ {"keySwitchPvpAttack", KeyboardConfig::KEY_NO_VALUE,
+ N_("Switch pvp attack"), KeyboardConfig::GRP_DEFAULT},
{"keyInvertDirection", SDLK_KP0, N_("Change move type"),
KeyboardConfig::GRP_DEFAULT},
{"keyChangeAttackWeaponType", SDLK_g, N_("Change Attack Weapon Type"),
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index b322eb6d1..45c5ba65f 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -309,6 +309,7 @@ class KeyboardConfig
KEY_MAGIC_ITENPLZ,
KEY_MAGIC_ATTACK,
KEY_SWITCH_MAGIC_ATTACK,
+ KEY_SWITCH_PVP_ATTACK,
KEY_INVERT_DIRECTION,
KEY_CHANGE_ATTACK_WEAPON_TYPE,
KEY_CHANGE_ATTACK_TYPE,
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index ea3209229..2c7227a2d 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -36,6 +36,7 @@
#include "party.h"
#include "particle.h"
#include "playerinfo.h"
+#include "playerrelations.h"
#include "simpleanimation.h"
#include "sound.h"
#include "statuseffect.h"
@@ -159,6 +160,7 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mDisableCrazyMove = false;
mPickUpType = config.getIntValue("pickUpType");
mMagicAttackType = config.getIntValue("magicAttackType");
+ mPvpAttackType = config.getIntValue("pvpAttackType");
mMoveToTargetType = config.getIntValue("moveToTargetType");
mDisableGameModifiers = config.getBoolValue("disableGameModifiers");
mTargetDeadPlayers = config.getBoolValue("targetDeadPlayers");
@@ -1356,26 +1358,30 @@ void LocalPlayer::attack(Being *target, bool keep, bool dontChangeEquipment)
mTargetTime = tick_time;
}
- setAction(ATTACK);
-
- if (mEquippedWeapon)
+ if (target->getType() != Being::PLAYER || checAttackPermissions(target))
{
- std::string soundFile = mEquippedWeapon->getSound(EQUIP_EVENT_STRIKE);
- if (!soundFile.empty())
- sound.playSfx(soundFile);
- }
- else
- {
- sound.playSfx(paths.getValue("attackSfxFile", "fist-swish.ogg"));
- }
+ setAction(ATTACK);
- if (!Client::limitPackets(PACKET_ATTACK))
- return;
+ if (mEquippedWeapon)
+ {
+ std::string soundFile = mEquippedWeapon->getSound(EQUIP_EVENT_STRIKE);
+ if (!soundFile.empty())
+ sound.playSfx(soundFile);
+ }
+ else
+ {
+ sound.playSfx(paths.getValue("attackSfxFile", "fist-swish.ogg"));
+ }
- if (!dontChangeEquipment && target)
- changeEquipmentBeforeAttack(target);
+ if (!Client::limitPackets(PACKET_ATTACK))
+ return;
+
+ if (!dontChangeEquipment && target)
+ changeEquipmentBeforeAttack(target);
+
+ Net::getPlayerHandler()->attack(target->getId(), mServerAttack);
+ }
- Net::getPlayerHandler()->attack(target->getId(), mServerAttack);
#ifdef MANASERV_SUPPORT
if ((Net::getNetworkType() != ServerInfo::MANASERV) && !keep)
#else
@@ -2890,6 +2896,17 @@ void LocalPlayer::switchMagicAttack()
miniStatusWindow->updateStatus();
}
+void LocalPlayer::switchPvpAttack()
+{
+ mPvpAttackType++;
+ if (mPvpAttackType > 3)
+ mPvpAttackType = 0;
+
+ config.setValue("pvpAttackType", mPvpAttackType);
+ if (miniStatusWindow)
+ miniStatusWindow->updateStatus();
+}
+
void LocalPlayer::magicAttack()
{
if (!chatWindow || !isAlive()
@@ -3897,6 +3914,7 @@ void LocalPlayer::resetYellowBar()
mAttackWeaponType = config.resetIntValue("attackWeaponType");
mAttackType = config.resetIntValue("attackType");
mMagicAttackType = config.resetIntValue("magicAttackType");
+ mPvpAttackType = config.resetIntValue("pvpAttackType");
mQuickDropCounter = config.resetIntValue("quickDropCounter");
mPickUpType = config.resetIntValue("pickUpType");
if (viewport)
@@ -3937,6 +3955,26 @@ void LocalPlayer::stopAdvert()
mBlockAdvert = true;
}
+bool LocalPlayer::checAttackPermissions(Being *target)
+{
+ if (!target)
+ return false;
+
+ switch (mPvpAttackType)
+ {
+ case 0:
+ return true;
+ case 1:
+ return !(player_relations.getRelation(target->getName())
+ == PlayerRelation::FRIEND);
+ case 2:
+ return player_relations.checkBadRelation(target->getName());
+ default:
+ case 3:
+ return false;
+ }
+}
+
void AwayListener::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok" && player_node && player_node->getAway())
diff --git a/src/localplayer.h b/src/localplayer.h
index fc8c3339b..4183f2d1b 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -271,9 +271,14 @@ class LocalPlayer : public Being, public ActorSpriteListener,
void switchMagicAttack();
+ void switchPvpAttack();
+
int getMagicAttackType()
{ return mMagicAttackType ; }
+ int getPvpAttackType()
+ { return mPvpAttackType ; }
+
int getMoveToTargetType()
{ return mMoveToTargetType ; }
@@ -475,6 +480,8 @@ class LocalPlayer : public Being, public ActorSpriteListener,
void stopAdvert();
+ bool checAttackPermissions(Being *target);
+
protected:
/** Whether or not the name settings have changed */
bool mUpdateName;
@@ -526,6 +533,8 @@ class LocalPlayer : public Being, public ActorSpriteListener,
unsigned int mPickUpType;
//magic attack type
unsigned int mMagicAttackType;
+ //pvp attack type
+ unsigned int mPvpAttackType;
//type how move to target
unsigned int mMoveToTargetType;
unsigned int mAttackType;
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index 18587a91e..1778da0c3 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -409,6 +409,23 @@ void PlayerRelationsManager::ignoreTrade(std::string name)
}
}
+bool PlayerRelationsManager::checkBadRelation(std::string name)
+{
+ if (name.empty())
+ return true;
+
+ PlayerRelation::Relation relation = getRelation(name);
+
+ if (relation == PlayerRelation::IGNORED
+ || relation == PlayerRelation::DISREGARDED
+ || relation == PlayerRelation::BLACKLISTED
+ || relation == PlayerRelation::ERASED
+ || relation == PlayerRelation::ENEMY2)
+ {
+ return true;
+ }
+ return false;
+}
////////////////////////////////////////
// ignore strategies
diff --git a/src/playerrelations.h b/src/playerrelations.h
index fbff5a01d..6cb175ec2 100644
--- a/src/playerrelations.h
+++ b/src/playerrelations.h
@@ -239,6 +239,7 @@ class PlayerRelationsManager
void removeListener(PlayerRelationsListener *listener)
{ mListeners.remove(listener); }
+ bool checkBadRelation(std::string name);
private:
void signalUpdate(const std::string &name);