summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/char_select.cpp4
-rw-r--r--src/gui/inventorywindow.cpp4
-rw-r--r--src/gui/ministatus.cpp54
-rw-r--r--src/gui/ministatus.h4
-rw-r--r--src/gui/skill.cpp33
-rw-r--r--src/gui/skill.h3
-rw-r--r--src/gui/status.cpp95
-rw-r--r--src/gui/status.h8
-rw-r--r--src/localplayer.cpp61
-rw-r--r--src/localplayer.h128
-rw-r--r--src/net/buysellhandler.cpp4
-rw-r--r--src/net/charserverhandler.cpp8
-rw-r--r--src/net/playerhandler.cpp192
-rw-r--r--src/net/protocol.h1
14 files changed, 193 insertions, 406 deletions
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index bd348c88..09ce5b87 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -194,8 +194,8 @@ void CharSelectDialog::updatePlayerInfo()
if (pi)
{
mNameLabel->setCaption(pi->getName());
- mLevelLabel->setCaption("Lvl: " + toString(pi->mLevel));
- mMoneyLabel->setCaption("Money: " + toString(pi->mMoney));
+ mLevelLabel->setCaption("Lvl: " + toString(pi->getLevel()));
+ mMoneyLabel->setCaption("Money: " + toString(pi->getMoney()));
if (!mCharSelected)
{
mNewCharButton->setEnabled(false);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index e533c16c..44d042a6 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -94,8 +94,8 @@ void InventoryWindow::logic()
// Update weight information
mWeightLabel->setCaption(
- "Total Weight: " + toString(player_node->mTotalWeight) + " - "
- "Maximum Weight: " + toString(player_node->mMaxWeight));
+ "Total Weight: " + toString(player_node->getTotalWeight()) + " - "
+ "Maximum Weight: " + toString(player_node->getMaxWeight()));
mWeightLabel->adjustSize();
}
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 932b1f22..9a4c2273 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -43,51 +43,32 @@ MiniStatusWindow::MiniStatusWindow():
setTitleBarHeight(0);
mHpBar = new ProgressBar(1.0f, 100, 20, 0, 171, 34);
- mMpBar = new ProgressBar(1.0f, 100, 20, 26, 102, 230);
- mXpBar = new ProgressBar(1.0f, 100, 20, 143, 192, 211);
mHpLabel = new gcn::Label("");
- mMpLabel = new gcn::Label("");
- mXpLabel = new gcn::Label("");
mHpBar->setPosition(0, 3);
- mMpBar->setPosition(mHpBar->getWidth() + 3, 3);
- mXpBar->setPosition(mMpBar->getX() + mMpBar->getWidth() + 3, 3);
mHpLabel->setDimension(mHpBar->getDimension());
- mMpLabel->setDimension(mMpBar->getDimension());
- mXpLabel->setDimension(mXpBar->getDimension());
mHpLabel->setForegroundColor(gcn::Color(255, 255, 255));
- mMpLabel->setForegroundColor(gcn::Color(255, 255, 255));
- mXpLabel->setForegroundColor(gcn::Color(255, 255, 255));
mHpLabel->setFont(speechFont);
- mMpLabel->setFont(speechFont);
- mXpLabel->setFont(speechFont);
mHpLabel->setAlignment(gcn::Graphics::CENTER);
- mMpLabel->setAlignment(gcn::Graphics::CENTER);
- mXpLabel->setAlignment(gcn::Graphics::CENTER);
add(mHpBar);
- add(mMpBar);
- add(mXpBar);
add(mHpLabel);
- add(mMpLabel);
- add(mXpLabel);
-
- setDefaultSize(0, 0, mXpBar->getX() + mXpBar->getWidth(),
- mXpBar->getY() + mXpBar->getHeight());
}
void MiniStatusWindow::update()
{
// HP Bar coloration
- if (player_node->mHp < int(player_node->mMaxHp / 3))
+ int maxHp = player_node->getMaxHP();
+ int hp = player_node->getHP();
+ if (hp < int(maxHp / 3))
{
mHpBar->setColor(223, 32, 32); // Red
}
- else if (player_node->mHp < int((player_node->mMaxHp / 3) * 2))
+ else if (hp < int((maxHp / 3) * 2))
{
mHpBar->setColor(230, 171, 34); // Orange
}
@@ -96,33 +77,10 @@ void MiniStatusWindow::update()
mHpBar->setColor(0, 171, 34); // Green
}
- mHpBar->setProgress((float) player_node->mHp / player_node->mMaxHp);
- // mMpBar->setProgress((float) player_node->mMp / player_node->mMaxMp);
- mXpBar->setProgress((float) player_node->mXp / player_node->mXpForNextLevel);
+ mHpBar->setProgress((float) hp / maxHp);
// Update labels
- mHpLabel->setCaption(toString(player_node->mHp));
- mMpLabel->setCaption(toString(player_node->mMp));
-
- std::stringstream updatedText;
- updatedText << (int) (
- (float) player_node->mXp /
- player_node->mXpForNextLevel * 100) << "%";
-
- // Displays the number of monsters to next lvl
- // (disabled for now but interesting idea)
- /*
- if(config.getValue("xpBarMonsterCounterExp", 0)!=0)
- {
- updatedText << " | "
- << (int)(((float)player_node->mXpForNextLevel - (float)player_node->mXp)
- / (float)config.getValue("xpBarMonsterCounterExp", 0))
- << " "
- << config.getValue("xpBarMonsterCounterName", "Monsters") <<" left...";
- }
- */
-
- mXpLabel->setCaption(updatedText.str());
+ mHpLabel->setCaption(toString(hp));
}
void MiniStatusWindow::draw(gcn::Graphics *graphics)
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index 718fe140..1192bc1e 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -60,11 +60,7 @@ class MiniStatusWindow : public Window
* Mini Status Bars
*/
ProgressBar *mHpBar;
- ProgressBar *mMpBar;
- ProgressBar *mXpBar;
gcn::Label *mHpLabel;
- gcn::Label *mMpLabel;
- gcn::Label *mXpLabel;
};
#endif
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index 1b00a732..c9babda2 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -68,28 +68,17 @@ SkillDialog::SkillDialog():
mSkillListBox = new ListBox(this);
ScrollArea *skillScrollArea = new ScrollArea(mSkillListBox);
- mPointsLabel = new gcn::Label("Skill Points:");
- mIncButton = new Button("Up", "inc", this);
- mUseButton = new Button("Use", "use", this);
- mUseButton->setEnabled(false);
mCloseButton = new Button("Close", "close", this);
mSkillListBox->setActionEventId("skill");
skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
skillScrollArea->setDimension(gcn::Rectangle(5, 5, 230, 180));
- mPointsLabel->setDimension(gcn::Rectangle(8, 190, 200, 16));
- mIncButton->setPosition(skillScrollArea->getX(), 210);
- mUseButton->setPosition(mIncButton->getX() + mIncButton->getWidth() + 5,
- 210);
mCloseButton->setPosition(
skillScrollArea->getX() + skillScrollArea->getWidth() - mCloseButton->getWidth(),
210);
add(skillScrollArea);
- add(mPointsLabel);
- add(mIncButton);
- add(mUseButton);
add(mCloseButton);
mSkillListBox->addActionListener(this);
@@ -105,20 +94,8 @@ SkillDialog::~SkillDialog()
void SkillDialog::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "inc")
- {
- // Increment skill
- int selectedSkill = mSkillListBox->getSelected();
- if (selectedSkill >= 0)
- {
- player_node->raiseSkill(mSkillList[selectedSkill]->id);
- }
- }
- else if (event.getId() == "skill")
+ if (event.getId() == "skill")
{
- mIncButton->setEnabled(
- mSkillListBox->getSelected() > -1 &&
- player_node->mSkillPoint > 0);
}
else if (event.getId() == "close")
{
@@ -128,14 +105,6 @@ void SkillDialog::action(const gcn::ActionEvent &event)
void SkillDialog::update()
{
- if (mPointsLabel != NULL) {
- char tmp[128];
- sprintf(tmp, "Skill points: %i", player_node->mSkillPoint);
- mPointsLabel->setCaption(tmp);
- }
-
- mIncButton->setEnabled(mSkillListBox->getSelected() > -1 &&
- player_node->mSkillPoint > 0);
}
int SkillDialog::getNumberOfElements()
diff --git a/src/gui/skill.h b/src/gui/skill.h
index ed1257b0..b8794e35 100644
--- a/src/gui/skill.h
+++ b/src/gui/skill.h
@@ -71,9 +71,6 @@ class SkillDialog : public Window, public gcn::ActionListener,
private:
gcn::ListBox *mSkillListBox;
- gcn::Label *mPointsLabel;
- gcn::Button *mIncButton;
- gcn::Button *mUseButton;
gcn::Button *mCloseButton;
std::vector<SKILL*> mSkillList;
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 9c60752d..c7cb80c3 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -54,14 +54,6 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mHpBar = new ProgressBar(1.0f, 80, 15, 0, 171, 34);
mHpValueLabel = new gcn::Label("");
- mXpLabel = new gcn::Label("Exp:");
- mXpBar = new ProgressBar(1.0f, 80, 15, 143, 192, 211);
- mXpValueLabel = new gcn::Label("");
-
- mMpLabel = new gcn::Label("MP:");
- mMpBar = new ProgressBar(1.0f, 80, 15, 26, 102, 230);
- mMpValueLabel = new gcn::Label("");
-
int y = 3;
int x = 5;
@@ -78,30 +70,14 @@ StatusWindow::StatusWindow(LocalPlayer *player):
x += mHpBar->getWidth() + 5;
mHpValueLabel->setPosition(x, y);
- mXpLabel->setPosition(175, y);
- mXpBar->setPosition(205, y);
- mXpValueLabel->setPosition(290, y);
-
y += mHpLabel->getHeight() + 5; // Next Row
x = 5;
- mMpLabel->setPosition(x, y);
- x += mMpLabel->getWidth() + 5;
- mMpBar->setPosition(x, y);
- x += mMpBar->getWidth() + 5;
- mMpValueLabel->setPosition(x, y);
-
add(mLvlLabel);
add(mMoneyLabel);
add(mHpLabel);
add(mHpValueLabel);
- add(mMpLabel);
- add(mMpValueLabel);
- add(mXpLabel);
- add(mXpValueLabel);
add(mHpBar);
- add(mMpBar);
- add(mXpBar);
// ----------------------
// Stats Part
@@ -113,6 +89,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
gcn::Label *mStatsCostLabel = new gcn::Label("Cost");
// Derived Stats
+/*
mStatsAttackLabel = new gcn::Label("Attack:");
mStatsDefenseLabel= new gcn::Label("Defense:");
mStatsMagicAttackLabel = new gcn::Label("M.Attack:");
@@ -128,7 +105,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mStatsAccuracyPoints = new gcn::Label("% Accuracy:");
mStatsEvadePoints = new gcn::Label("% Evade:");
mStatsReflexPoints = new gcn::Label("% Reflex:");
-
+*/
// New labels
for (int i = 0; i < 7; i++) {
mStatsLabel[i] = new gcn::Label();
@@ -148,7 +125,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
// Set position
- mStatsTitleLabel->setPosition(mMpLabel->getX(), mMpLabel->getY() + 23 );
+ mStatsTitleLabel->setPosition(mHpLabel->getX(), mHpLabel->getY() + 23 );
mStatsTotalLabel->setPosition(110, mStatsTitleLabel->getY() + 15);
int totalLabelY = mStatsTotalLabel->getY();
mStatsCostLabel->setPosition(170, totalLabelY);
@@ -157,14 +134,14 @@ StatusWindow::StatusWindow(LocalPlayer *player):
{
mStatsLabel[i]->setPosition(5,
mStatsTotalLabel->getY() + (i * 23) + 15);
- mStatsDisplayLabel[i]->setPosition(115,
+ mStatsDisplayLabel[i]->setPosition(85,
totalLabelY + (i * 23) + 15);
mStatsButton[i]->setPosition(145, totalLabelY + (i * 23) + 10);
- mPointsLabel[i]->setPosition(175, totalLabelY + (i * 23) + 15);
+ mPointsLabel[i]->setPosition(165, totalLabelY + (i * 23) + 15);
}
mRemainingStatsPointsLabel->setPosition(5, mPointsLabel[6]->getY() + 25);
-
+/*
mStatsAttackLabel->setPosition(220, mStatsLabel[0]->getY());
mStatsDefenseLabel->setPosition(220, mStatsLabel[1]->getY());
mStatsMagicAttackLabel->setPosition(220, mStatsLabel[2]->getY());
@@ -180,7 +157,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mStatsAccuracyPoints->setPosition(310, mStatsLabel[4]->getY());
mStatsEvadePoints->setPosition(310, mStatsLabel[5]->getY());
mStatsReflexPoints->setPosition(310, mStatsLabel[6]->getY());
-
+*/
// Assemble
add(mStatsTitleLabel);
add(mStatsTotalLabel);
@@ -191,7 +168,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
add(mStatsDisplayLabel[i]);
add(mStatsButton[i]);
add(mPointsLabel[i]);
- }
+ }/*
add(mStatsAttackLabel);
add(mStatsDefenseLabel);
add(mStatsMagicAttackLabel);
@@ -206,7 +183,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
add(mStatsMagicDefensePoints);
add(mStatsAccuracyPoints);
add(mStatsEvadePoints);
- add(mStatsReflexPoints);
+ add(mStatsReflexPoints);*/
add(mRemainingStatsPointsLabel);
}
@@ -215,30 +192,25 @@ void StatusWindow::update()
{
// Status Part
// -----------
- mLvlLabel->setCaption("Level: " + toString(mPlayer->mLevel));
+ mLvlLabel->setCaption("Level: " + toString(mPlayer->getLevel()));
mLvlLabel->adjustSize();
- mMoneyLabel->setCaption("Money: " + toString(mPlayer->mMoney) + " GP");
+ mMoneyLabel->setCaption("Money: " + toString(mPlayer->getMoney()) + " GP");
mMoneyLabel->adjustSize();
- mHpValueLabel->setCaption(toString(mPlayer->mHp) +
- "/" + toString(mPlayer->mMaxHp));
- mHpValueLabel->adjustSize();
-
- mMpValueLabel->setCaption(toString(mPlayer->mMp) +
- "/" + toString(mPlayer->mMaxMp));
- mMpValueLabel->adjustSize();
+ int hp = mPlayer->getHP();
+ int maxHp = mPlayer->getMaxHP();
- mXpValueLabel->setCaption(toString(mPlayer->mXp) +
- "/" + toString(mPlayer->mXpForNextLevel));
- mXpValueLabel->adjustSize();
+ mHpValueLabel->setCaption(toString(hp) +
+ " / " + toString(maxHp));
+ mHpValueLabel->adjustSize();
// HP Bar coloration
- if (mPlayer->mHp < int(mPlayer->mMaxHp / 3))
+ if (hp < int(maxHp / 3))
{
mHpBar->setColor(223, 32, 32); // Red
}
- else if (mPlayer->mHp < int((mPlayer->mMaxHp / 3) * 2))
+ else if (hp < int((maxHp / 3) * 2))
{
mHpBar->setColor(230, 171, 34); // Orange
}
@@ -247,11 +219,7 @@ void StatusWindow::update()
mHpBar->setColor(0, 171, 34); // Green
}
- mHpBar->setProgress((float)mPlayer->mHp / (float)mPlayer->mMaxHp);
- // mMpBar->setProgress((float)mPlayer->mp / (float)mPlayer->maxMp);
-
- mXpBar->setProgress(
- (float) mPlayer->mXp / (float) mPlayer->mXpForNextLevel);
+ mHpBar->setProgress((float)hp / maxHp);
// Stats Part
// ----------
@@ -264,24 +232,26 @@ void StatusWindow::update()
"Willpower",
"Charisma"
};
- int statusPoints = mPlayer->mStatsPointsToAttribute;
+ int statusPoints = mPlayer->getAttributeIncreasePoints();
// Update labels
for (int i = 0; i < 7; i++) {
mStatsLabel[i]->setCaption(attrNames[i]);
- mStatsDisplayLabel[i]->setCaption(toString((int) mPlayer->mAttr[i]));
- mPointsLabel[i]->setCaption(toString((int) mPlayer->mAttrUp[i]));
+ mStatsDisplayLabel[i]->setCaption(
+ toString(mPlayer->getAttributeEffective(i)) +
+ " / " +
+ toString(mPlayer->getAttributeBase(i))
+ );
mStatsLabel[i]->adjustSize();
mStatsDisplayLabel[i]->adjustSize();
- mPointsLabel[i]->adjustSize();
- mStatsButton[i]->setEnabled(mPlayer->mAttrUp[i] <= statusPoints);
+ mStatsButton[i]->setEnabled(statusPoints);
}
mRemainingStatsPointsLabel->setCaption("Remaining Status Points: " +
toString(statusPoints));
mRemainingStatsPointsLabel->adjustSize();
-
+/*
// Derived Stats Points
// Attack TODO: Count equipped Weapons and items attack bonuses
@@ -315,20 +285,11 @@ void StatusWindow::update()
// Reflex %
mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter
mStatsReflexPoints->adjustSize();
-
+*/
// Update Second column widgets position
mMoneyLabel->setPosition(mLvlLabel->getX() + mLvlLabel->getWidth() + 20,
mLvlLabel->getY());
- mXpLabel->setPosition(
- mHpValueLabel->getX() + mHpValueLabel->getWidth() + 10,
- mHpLabel->getY());
- mXpBar->setPosition(
- mXpLabel->getX() + mXpLabel->getWidth() + 5,
- mXpLabel->getY());
- mXpValueLabel->setPosition(
- mXpBar->getX() + mXpBar->getWidth() + 5,
- mXpLabel->getY());
}
void StatusWindow::draw(gcn::Graphics *g)
diff --git a/src/gui/status.h b/src/gui/status.h
index 37f8a648..40d25a2a 100644
--- a/src/gui/status.h
+++ b/src/gui/status.h
@@ -70,14 +70,12 @@ class StatusWindow : public Window, public gcn::ActionListener {
* Status Part
*/
gcn::Label *mLvlLabel, *mMoneyLabel, *mHpLabel, *mHpValueLabel;
- gcn::Label *mMpLabel, *mMpValueLabel;
- gcn::Label *mXpLabel, *mXpValueLabel;
- ProgressBar *mHpBar, *mMpBar;
- ProgressBar *mXpBar;
+ ProgressBar *mHpBar;
/**
* Derived Statistics captions
*/
+/*
gcn::Label *mStatsAttackLabel, *mStatsDefenseLabel;
gcn::Label *mStatsMagicAttackLabel, *mStatsMagicDefenseLabel;
gcn::Label *mStatsAccuracyLabel, *mStatsEvadeLabel;
@@ -87,7 +85,7 @@ class StatusWindow : public Window, public gcn::ActionListener {
gcn::Label *mStatsMagicAttackPoints, *mStatsMagicDefensePoints;
gcn::Label *mStatsAccuracyPoints, *mStatsEvadePoints;
gcn::Label *mStatsReflexPoints;
-
+*/
/**
* Stats captions.
*/
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 16d5b191..7f595ef1 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -38,10 +38,13 @@ LocalPlayer *player_node = NULL;
LocalPlayer::LocalPlayer():
Player(65535, 0, NULL),
- mLevel(1),
mInventory(new Inventory()),
+ mAttributeBase(NB_BASE_ATTRIBUTES, 0),
+ mAttributeEffective(NB_BASE_ATTRIBUTES, 0),
+ mLevel(1),
mTarget(NULL), mPickUpTarget(NULL),
- mTrading(false), mLastAction(-1)
+ mTrading(false),
+ mLastAction(-1)
{
}
@@ -235,54 +238,6 @@ void LocalPlayer::setWalkingDir(int dir)
}
}
-void LocalPlayer::raiseAttribute(Attribute attr)
-{
- // XXX Convert for new server
- /*
- MessageOut outMsg(CMSG_STAT_UPDATE_REQUEST);
-
- switch (attr)
- {
- case STR:
- outMsg.writeShort(0x000d);
- break;
-
- case AGI:
- outMsg.writeShort(0x000e);
- break;
-
- case VIT:
- outMsg.writeShort(0x000f);
- break;
-
- case INT:
- outMsg.writeShort(0x0010);
- break;
-
- case DEX:
- outMsg.writeShort(0x0011);
- break;
-
- case LUK:
- outMsg.writeShort(0x0012);
- break;
- }
- outMsg.writeByte(1);
- */
-}
-
-void LocalPlayer::raiseSkill(Uint16 skillId)
-{
- if (mSkillPoint <= 0)
- return;
-
- // XXX Convert for new server
- /*
- MessageOut outMsg(CMSG_SKILL_LEVELUP_REQUEST);
- outMsg.writeShort(skillId);
- */
-}
-
void LocalPlayer::toggleSit()
{
if (mLastAction != -1)
@@ -375,3 +330,9 @@ void LocalPlayer::revive()
outMsg.writeByte(0);
*/
}
+
+void LocalPlayer::raiseAttribute(size_t attr)
+{
+ mAttributeBase.at(attr)++;
+ // TODO: Inform the server about our desire to raise the attribute
+}
diff --git a/src/localplayer.h b/src/localplayer.h
index 9ce67d13..299cf85a 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -36,6 +36,68 @@ class Inventory;
class Item;
/**
+ * Stats every being needs
+ */
+enum BeingStats
+{
+ BASE_ATTR_STRENGTH = 0, // Basic attributes
+ BASE_ATTR_AGILITY,
+ BASE_ATTR_DEXTERITY,
+ BASE_ATTR_VITALITY,
+ BASE_ATTR_INTELLIGENCE,
+ BASE_ATTR_WILLPOWER,
+ BASE_ATTR_CHARISMA,
+ NB_BASE_ATTRIBUTES,
+
+ ATTR_EFF_STRENGTH = NB_BASE_ATTRIBUTES, // modified basic attributes
+ ATTR_EFF_AGILITY,
+ ATTR_EFF_DEXTERITY,
+ ATTR_EFF_VITALITY,
+ ATTR_EFF_INTELLIGENCE,
+ ATTR_EFF_WILLPOWER,
+ ATTR_EFF_CHARISMA,
+ NB_EFFECTIVE_ATTRIBUTES,
+
+ DERIVED_ATTR_HP_MAXIMUM = NB_EFFECTIVE_ATTRIBUTES, // Computed stats
+ DERIVED_ATTR_PHYSICAL_ATTACK_MINIMUM,
+ DERIVED_ATTR_PHYSICAL_ATTACK_FLUCTUATION,
+ DERIVED_ATTR_PHYSICAL_DEFENCE,
+ // add new computed statistics when they are needed
+ NB_ATTRIBUTES_BEING
+};
+
+/**
+ * Player character specific stats
+ */
+enum CharacterStats
+{
+ CHAR_SKILL_WEAPON_UNARMED = NB_ATTRIBUTES_BEING,
+ CHAR_SKILL_WEAPON_SWORD,
+ CHAR_SKILL_WEAPON_AXE,
+ CHAR_SKILL_WEAPON_POLEARM,
+ CHAR_SKILL_WEAPON_JAVELIN,
+ CHAR_SKILL_WEAPON_WHIP,
+ CHAR_SKILL_WEAPON_DAGGER,
+ CHAR_SKILL_WEAPON_STAFF,
+ CHAR_SKILL_WEAPON_BOW,
+ CHAR_SKILL_WEAPON_CROSSBOW,
+ CHAR_SKILL_WEAPON_THROWN,
+ NB_CHAR_WEAPONSKILLS,
+
+ CHAR_SKILL_MAGIC_IAMJUSTAPLACEHOLDER = NB_CHAR_WEAPONSKILLS,
+ NB_CHAR_MAGICSKILLS,
+
+ CHAR_SKILL_CRAFT_IAMJUSTAPLACEHOLDER = NB_CHAR_MAGICSKILLS,
+ NB_CHAR_CRAFTSKILLS,
+
+ CHAR_SKILL_IAMJUSTAPLACEHOLDER = NB_CHAR_CRAFTSKILLS,
+ NB_CHAR_OTHERSKILLS,
+
+ NB_ATTRIBUTES_CHAR = NB_CHAR_OTHERSKILLS
+};
+
+
+/**
* The local player character.
*/
class LocalPlayer : public Player
@@ -138,32 +200,57 @@ class LocalPlayer : public Player
*/
void setWalkingDir(int dir);
- void raiseAttribute(Attribute attr);
- void raiseSkill(Uint16 skillId);
+ void raiseAttribute(size_t attr);
void toggleSit();
void emote(Uint8 emotion);
void revive();
- Uint32 mCharId;
+ int getHP() const
+ { return mHP; }
- Uint32 mXp;
- Uint16 mLevel;
- Uint32 mXpForNextLevel;
- Uint16 mHp, mMaxHp, mMp, mMaxMp;
- Uint32 mMoney;
+ int getMaxHP() const
+ { return mMaxHP; }
- Uint32 mTotalWeight, mMaxWeight;
+ void setHP(int value)
+ { mHP = value; }
- Uint8 mAttr[7];
- Uint8 mAttrUp[7];
+ void setMaxHP(int value)
+ { mMaxHP = value; }
- Sint16 ATK, MATK, DEF, MDEF, HIT, FLEE;
- Sint16 ATK_BONUS, MATK_BONUS, DEF_BONUS, MDEF_BONUS, FLEE_BONUS;
+ int getLevel() const
+ { return mLevel; }
- Uint16 mStatPoint, mSkillPoint;
- Uint16 mStatsPointsToAttribute;
+ void setLevel(int value)
+ { mLevel = value; }
+
+ int getMoney() const
+ { return mMoney; }
+
+ void setMoney(int value)
+ { mMoney = value; }
+
+ int getTotalWeight() const
+ { return mTotalWeight; }
+
+ int getMaxWeight() const
+ { return mMaxWeight; }
+
+ int getAttributeBase(size_t num) const
+ { return mAttributeBase.at(num); }
+
+ void setAttributeBase(size_t num, int value)
+ { mAttributeBase.at(num) = value; }
+
+ int getAttributeEffective(size_t num) const
+ { return mAttributeEffective.at(num); }
+
+ void setAttributeEffective(size_t num, int value)
+ { mAttributeEffective.at(num) = value; }
+
+ int getAttributeIncreasePoints() const
+ { return mAttributeIncreasePoints; }
float mLastAttackTime; /**< Used to synchronize the charge dialog */
@@ -172,6 +259,17 @@ class LocalPlayer : public Player
protected:
void walk(unsigned char dir);
+ // Character status:
+ std::vector<int> mAttributeBase;
+ std::vector<int> mAttributeEffective;
+ int mAttributeIncreasePoints;
+ int mLevel;
+ int mMoney;
+ int mTotalWeight;
+ int mMaxWeight;
+ int mHP;
+ int mMaxHP;
+
Being *mTarget;
FloorItem *mPickUpTarget;
diff --git a/src/net/buysellhandler.cpp b/src/net/buysellhandler.cpp
index 473a706c..45dfb9ad 100644
--- a/src/net/buysellhandler.cpp
+++ b/src/net/buysellhandler.cpp
@@ -72,7 +72,7 @@ void BuySellHandler::handleMessage(MessageIn &msg)
msg.readShort(); // length
n_items = (msg.getLength() - 4) / 11;
buyDialog->reset();
- buyDialog->setMoney(player_node->mMoney);
+ buyDialog->setMoney(player_node->getMoney());
buyDialog->setVisible(true);
for (int k = 0; k < n_items; k++)
@@ -89,7 +89,7 @@ void BuySellHandler::handleMessage(MessageIn &msg)
msg.readShort(); // length
n_items = (msg.getLength() - 4) / 10;
if (n_items > 0) {
- sellDialog->setMoney(player_node->mMoney);
+ sellDialog->setMoney(player_node->getMoney());
sellDialog->reset();
sellDialog->setVisible(true);
diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp
index ebc11bb3..34fc188d 100644
--- a/src/net/charserverhandler.cpp
+++ b/src/net/charserverhandler.cpp
@@ -202,10 +202,10 @@ CharServerHandler::readPlayerData(MessageIn &msg, int &slot)
tempPlayer->setSex(msg.readByte());
tempPlayer->setHairStyle(msg.readByte());
tempPlayer->setHairColor(msg.readByte());
- tempPlayer->mLevel = msg.readByte();
- tempPlayer->mMoney = msg.readShort();
- for (int i = 0; i < 6; i++) {
- tempPlayer->mAttr[i] = msg.readByte();
+ tempPlayer->setLevel(msg.readByte());
+ tempPlayer->setMoney(msg.readLong());
+ for (int i = 0; i < 7; i++) {
+ tempPlayer->setAttributeBase(i, msg.readByte());
}
return tempPlayer;
}
diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp
index 327edea3..335c2eb1 100644
--- a/src/net/playerhandler.cpp
+++ b/src/net/playerhandler.cpp
@@ -96,6 +96,7 @@ PlayerHandler::PlayerHandler()
//SMSG_PLAYER_ARROW_MESSAGE,
GPMSG_PLAYER_MAP_CHANGE,
GPMSG_PLAYER_SERVER_CHANGE,
+ GPMSG_PLAYER_ATTRIBUTE_UPDATE,
0
};
handledMessages = _messages;
@@ -117,187 +118,34 @@ void PlayerHandler::handleMessage(MessageIn &msg)
logger->log("Changing server to %s:%d", address.c_str(), port);
} break;
- /*
- case SMSG_PLAYER_STAT_UPDATE_1:
+ case GPMSG_PLAYER_ATTRIBUTE_UPDATE:
+ {
+ logger->log("ATTRIBUTE UPDATE:");
+ while (msg.getUnreadLength())
{
- Sint16 type = msg.readShort();
- Uint32 value = msg.readLong();
+ int stat = msg.readShort();
+ int value = msg.readShort();
+ logger->log("%d set to %d", stat, value);
- switch (type)
+ if (stat < NB_BASE_ATTRIBUTES)
{
- //case 0x0000:
- // player_node->setWalkSpeed(msg.readLong());
- // break;
- case 0x0005: player_node->mHp = value; break;
- case 0x0006: player_node->mMaxHp = value; break;
- case 0x0007: player_node->mMp = value; break;
- case 0x0008: player_node->mMaxMp = value; break;
- case 0x000b: player_node->mLevel = value; break;
- case 0x000c:
- player_node->mSkillPoint = value;
- skillDialog->update();
- break;
- case 0x0018:
- if (value >= player_node->mMaxWeight / 2 &&
- player_node->mTotalWeight <
- player_node->mMaxWeight / 2)
- {
- weightNotice = new OkDialog("Message",
- "You are carrying more then half "
- "your weight. You are unable to "
- "regain health.");
- weightNotice->addActionListener(
- &weightListener);
- }
- player_node->mTotalWeight = value;
- break;
- case 0x0019: player_node->mMaxWeight = value; break;
- case 0x0037: player_node->mJobLevel = value; break;
- case 0x0009:
- player_node->mStatsPointsToAttribute = value;
- break;
- case 0x0029: player_node->ATK = value; break;
- case 0x002b: player_node->MATK = value; break;
- case 0x002d: player_node->DEF = value; break;
- case 0x002f: player_node->MDEF = value; break;
- case 0x0031: player_node->HIT = value; break;
- case 0x0032: player_node->FLEE = value; break;
- case 0x0035: player_node->mAttackSpeed = value; break;
+ player_node->setAttributeBase(stat, value);
}
-
- if (player_node->mHp == 0 && deathNotice == NULL)
+ else if (stat < NB_EFFECTIVE_ATTRIBUTES)
{
- deathNotice = new OkDialog("Message",
- "You're now dead, press ok to restart");
- deathNotice->addActionListener(&deathListener);
- player_node->setAction(Being::DEAD);
+ player_node->setAttributeEffective(stat - NB_BASE_ATTRIBUTES, value);
}
- }
- break;
-
- case SMSG_PLAYER_STAT_UPDATE_2:
- switch (msg.readShort()) {
- case 0x0001:
- player_node->mXp = msg.readLong();
- break;
- case 0x0002:
- player_node->mJobXp = msg.readLong();
- break;
- case 0x0014:
- player_node->mMoney = msg.readLong();
- break;
- case 0x0016:
- player_node->mXpForNextLevel = msg.readLong();
- break;
- case 0x0017:
- player_node->mJobXpForNextLevel = msg.readLong();
- break;
- }
- break;
-
- case SMSG_PLAYER_STAT_UPDATE_3:
- {
- Sint32 type = msg.readLong();
- Sint32 base = msg.readLong();
- Sint32 bonus = msg.readLong();
- Sint32 total = base + bonus;
-
- switch (type) {
- case 0x000d: player_node->mAttr[LocalPlayer::STR] = total;
- break;
- case 0x000e: player_node->mAttr[LocalPlayer::AGI] = total;
- break;
- case 0x000f: player_node->mAttr[LocalPlayer::VIT] = total;
- break;
- case 0x0010: player_node->mAttr[LocalPlayer::INT] = total;
- break;
- case 0x0011: player_node->mAttr[LocalPlayer::DEX] = total;
- break;
- case 0x0012: player_node->mAttr[LocalPlayer::LUK] = total;
- break;
+ else if (stat == DERIVED_ATTR_HP_MAXIMUM)
+ {
+ player_node->setMaxHP(value);
}
- }
- break;
-
- case SMSG_PLAYER_STAT_UPDATE_4:
- {
- Sint16 type = msg.readShort();
- Sint8 fail = msg.readByte();
- Sint8 value = msg.readByte();
-
- if (fail != 1)
- break;
-
- switch (type) {
- case 0x000d: player_node->mAttr[LocalPlayer::STR] = value;
- break;
- case 0x000e: player_node->mAttr[LocalPlayer::AGI] = value;
- break;
- case 0x000f: player_node->mAttr[LocalPlayer::VIT] = value;
- break;
- case 0x0010: player_node->mAttr[LocalPlayer::INT] = value;
- break;
- case 0x0011: player_node->mAttr[LocalPlayer::DEX] = value;
- break;
- case 0x0012: player_node->mAttr[LocalPlayer::LUK] = value;
- break;
+ else
+ {
+ logger->log("Warning: server wants to update unknown attribute %d to %d", stat, value);
}
}
- break;
-
- // Updates stats and status points
- case SMSG_PLAYER_STAT_UPDATE_5:
- player_node->mStatsPointsToAttribute = msg.readShort();
- player_node->mAttr[LocalPlayer::STR] = msg.readByte();
- player_node->mAttrUp[LocalPlayer::STR] = msg.readByte();
- player_node->mAttr[LocalPlayer::AGI] = msg.readByte();
- player_node->mAttrUp[LocalPlayer::AGI] = msg.readByte();
- player_node->mAttr[LocalPlayer::VIT] = msg.readByte();
- player_node->mAttrUp[LocalPlayer::VIT] = msg.readByte();
- player_node->mAttr[LocalPlayer::INT] = msg.readByte();
- player_node->mAttrUp[LocalPlayer::INT] = msg.readByte();
- player_node->mAttr[LocalPlayer::DEX] = msg.readByte();
- player_node->mAttrUp[LocalPlayer::DEX] = msg.readByte();
- player_node->mAttr[LocalPlayer::LUK] = msg.readByte();
- player_node->mAttrUp[LocalPlayer::LUK] = msg.readByte();
- player_node->ATK = msg.readShort(); // ATK
- player_node->ATK_BONUS = msg.readShort(); // ATK bonus
- player_node->MATK = msg.readShort(); // MATK max
- player_node->MATK_BONUS = msg.readShort(); // MATK min
- player_node->DEF = msg.readShort(); // DEF
- player_node->DEF_BONUS = msg.readShort(); // DEF bonus
- player_node->MDEF = msg.readShort(); // MDEF
- player_node->MDEF_BONUS = msg.readShort(); // MDEF bonus
- player_node->HIT = msg.readShort(); // HIT
- player_node->FLEE = msg.readShort(); // FLEE
- player_node->FLEE_BONUS = msg.readShort(); // FLEE bonus
- msg.readShort(); // critical
- msg.readShort(); // unknown
- break;
-
- case SMSG_PLAYER_STAT_UPDATE_6:
- switch (msg.readShort()) {
- case 0x0020:
- player_node->mAttrUp[LocalPlayer::STR] = msg.readByte();
- break;
- case 0x0021:
- player_node->mAttrUp[LocalPlayer::AGI] = msg.readByte();
- break;
- case 0x0022:
- player_node->mAttrUp[LocalPlayer::VIT] = msg.readByte();
- break;
- case 0x0023:
- player_node->mAttrUp[LocalPlayer::INT] = msg.readByte();
- break;
- case 0x0024:
- player_node->mAttrUp[LocalPlayer::DEX] = msg.readByte();
- break;
- case 0x0025:
- player_node->mAttrUp[LocalPlayer::LUK] = msg.readByte();
- break;
- }
- break;
-
+ } break;
+ /*
case SMSG_PLAYER_ARROW_MESSAGE:
{
Sint16 type = msg.readShort();
diff --git a/src/net/protocol.h b/src/net/protocol.h
index 980e841a..a9ee0e5b 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -160,6 +160,7 @@ enum {
PGMSG_EQUIP = 0x0112, // B slot
GPMSG_INVENTORY = 0x0120, // { B slot, W item id [, B amount] }*
GPMSG_INVENTORY_FULL = 0x0121, // { B slot, W item id [, B amount] }*
+ GPMSG_PLAYER_ATTRIBUTE_UPDATE = 0x0130, // { W attribute, W value }*
GPMSG_BEING_ENTER = 0x0200, // B type, W being id, B action, W*2 position
// player: S name, B hair style, B hair color, B gender
// monster: W type id