summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-04-13 12:32:22 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-05-08 14:02:50 +0200
commit708896008ad8ea391d542ce37b9871318a84fb97 (patch)
tree30c862cb18d354f879ffb0b426d5ff133d2bde3b /src
parente2b6a4efe72333ab0e0761f4e9e8ce9eb29a5335 (diff)
downloadmanaserv-708896008ad8ea391d542ce37b9871318a84fb97.tar.gz
manaserv-708896008ad8ea391d542ce37b9871318a84fb97.tar.xz
manaserv-708896008ad8ea391d542ce37b9871318a84fb97.zip
[Abilities] Renamed specials to abilities
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/account-server/character.cpp6
-rw-r--r--src/account-server/character.h38
-rw-r--r--src/account-server/storage.cpp38
-rw-r--r--src/common/manaserv_protocol.h8
-rw-r--r--src/game-server/abilitymanager.cpp182
-rw-r--r--src/game-server/abilitymanager.h (renamed from src/game-server/specialmanager.h)52
-rw-r--r--src/game-server/character.cpp149
-rw-r--r--src/game-server/character.h112
-rw-r--r--src/game-server/commandhandler.cpp128
-rw-r--r--src/game-server/gamehandler.cpp24
-rw-r--r--src/game-server/gamehandler.h4
-rw-r--r--src/game-server/main-game.cpp6
-rw-r--r--src/game-server/settingsmanager.cpp16
-rw-r--r--src/game-server/specialmanager.cpp179
-rw-r--r--src/scripting/lua.cpp273
-rw-r--r--src/scripting/luautil.cpp6
-rw-r--r--src/scripting/luautil.h6
-rw-r--r--src/scripting/scriptmanager.h4
-rw-r--r--src/serialize/characterdata.h23
-rw-r--r--src/sql/mysql/createTables.sql14
-rw-r--r--src/sql/mysql/updates/update_21_to_22.sql26
-rw-r--r--src/sql/sqlite/createTables.sql14
-rw-r--r--src/sql/sqlite/updates/update_21_to_22.sql26
24 files changed, 698 insertions, 640 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5a92e29..0f18ebd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -197,6 +197,8 @@ SET(SRCS_MANASERVGAME
game-server/main-game.cpp
common/permissionmanager.h
common/permissionmanager.cpp
+ game-server/abilitymanager.cpp
+ game-server/abilitymanager.h
game-server/accountconnection.h
game-server/accountconnection.cpp
game-server/actor.h
@@ -259,8 +261,6 @@ SET(SRCS_MANASERVGAME
game-server/skillmanager.cpp
game-server/spawnareacomponent.h
game-server/spawnareacomponent.cpp
- game-server/specialmanager.cpp
- game-server/specialmanager.h
game-server/state.h
game-server/state.cpp
game-server/statuseffect.h
diff --git a/src/account-server/character.cpp b/src/account-server/character.cpp
index 61e59b4..19d679d 100644
--- a/src/account-server/character.cpp
+++ b/src/account-server/character.cpp
@@ -46,10 +46,10 @@ void CharacterData::setAccount(Account *acc)
mAccountLevel = acc->getLevel();
}
-void CharacterData::giveSpecial(int id, int currentMana)
+void CharacterData::giveAbility(int id, int currentMana)
{
- if (mSpecials.find(id) == mSpecials.end())
+ if (mAbilities.find(id) == mAbilities.end())
{
- mSpecials[id] = SpecialValue(currentMana);
+ mAbilities[id] = AbilityValue(currentMana);
}
}
diff --git a/src/account-server/character.h b/src/account-server/character.h
index a9aa810..f59fe23 100644
--- a/src/account-server/character.h
+++ b/src/account-server/character.h
@@ -55,17 +55,17 @@ struct AttributeValue
{ return modified; }
};
-struct SpecialValue
+struct AbilityValue
{
- SpecialValue()
- : currentMana(0)
+ AbilityValue()
+ : currentPoints(0)
{}
- SpecialValue(unsigned currentMana)
- : currentMana(currentMana)
+ AbilityValue(unsigned currentPoints)
+ : currentPoints(currentPoints)
{}
- unsigned currentMana;
+ unsigned currentPoints;
};
struct Status
@@ -83,9 +83,9 @@ struct Status
typedef std::map<unsigned, AttributeValue> AttributeMap;
/**
- * Stores specials by their id.
+ * Stores abilitys by their id.
*/
-typedef std::map<unsigned, SpecialValue> SpecialMap;
+typedef std::map<unsigned, AbilityValue> AbilityMap;
class CharacterData
{
@@ -221,22 +221,22 @@ class CharacterData
{ mKillCount[monsterId] = kills; }
/**
- * Get / Set specials
+ * Get / Set abilitys
*/
- int getSpecialSize() const
- { return mSpecials.size(); }
+ int getAbilitySize() const
+ { return mAbilities.size(); }
- SpecialMap::const_iterator getSpecialBegin() const
- { return mSpecials.begin(); }
+ AbilityMap::const_iterator getAbilityBegin() const
+ { return mAbilities.begin(); }
- SpecialMap::const_iterator getSpecialEnd() const
- { return mSpecials.end(); }
+ AbilityMap::const_iterator getAbilityEnd() const
+ { return mAbilities.end(); }
- void clearSpecials()
- { mSpecials.clear(); }
+ void clearAbilities()
+ { mAbilities.clear(); }
- void giveSpecial(int id, int currentMana);
+ void giveAbility(int id, int currentMana);
/**
* Gets the Id of the map that the character is on.
@@ -303,7 +303,7 @@ class CharacterData
std::map<int, int> mExperience; //!< Skill Experience.
std::map<int, Status> mStatusEffects; //!< Status Effects
std::map<int, int> mKillCount; //!< Kill Count
- SpecialMap mSpecials;
+ AbilityMap mAbilities;
unsigned short mMapId; //!< Map the being is on.
unsigned char mGender; //!< Gender of the being.
unsigned char mHairStyle; //!< Hair style of the being.
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp
index 72f4fc0..965024a 100644
--- a/src/account-server/storage.cpp
+++ b/src/account-server/storage.cpp
@@ -78,7 +78,7 @@ static const char *CHAR_ATTR_TBL_NAME = "mana_char_attr";
static const char *CHAR_SKILLS_TBL_NAME = "mana_char_skills";
static const char *CHAR_STATUS_EFFECTS_TBL_NAME = "mana_char_status_effects";
static const char *CHAR_KILL_COUNT_TBL_NAME = "mana_char_kill_stats";
-static const char *CHAR_SPECIALS_TBL_NAME = "mana_char_specials";
+static const char *CHAR_ABILITIES_TBL_NAME = "mana_char_abilities";
static const char *CHAR_EQUIPS_TBL_NAME = "mana_char_equips";
static const char *INVENTORIES_TBL_NAME = "mana_inventories";
static const char *ITEMS_TBL_NAME = "mana_items";
@@ -474,20 +474,20 @@ CharacterData *Storage::getCharacterBySQL(Account *owner)
}
}
- // Load the special status
+ // Load the ability status
s.clear();
s.str("");
- s << "SELECT special_id, special_current_mana FROM "
- << CHAR_SPECIALS_TBL_NAME
+ s << "SELECT ability_id, ability_current_points FROM "
+ << CHAR_ABILITIES_TBL_NAME
<< " WHERE char_id = " << character->getDatabaseID();
- const dal::RecordSet &specialsInfo = mDb->execSql(s.str());
- if (!specialsInfo.isEmpty())
+ const dal::RecordSet &abilitiesInfo = mDb->execSql(s.str());
+ if (!abilitiesInfo.isEmpty())
{
- const unsigned nRows = specialsInfo.rows();
+ const unsigned nRows = abilitiesInfo.rows();
for (unsigned row = 0; row < nRows; row++)
{
- character->giveSpecial(toUint(specialsInfo(row, 0)),
- toUint(specialsInfo(row, 1)));
+ character->giveAbility(toUint(abilitiesInfo(row, 0)),
+ toUint(abilitiesInfo(row, 1)));
}
}
}
@@ -788,29 +788,29 @@ bool Storage::updateCharacter(CharacterData *character)
"SQL query failure: ", e);
}
- // Character's special actions
+ // Character's abillities
try
{
// Out with the old
std::ostringstream deleteSql("");
std::ostringstream insertSql;
- deleteSql << "DELETE FROM " << CHAR_SPECIALS_TBL_NAME
+ deleteSql << "DELETE FROM " << CHAR_ABILITIES_TBL_NAME
<< " WHERE char_id='"
<< character->getDatabaseID() << "';";
mDb->execSql(deleteSql.str());
// In with the new
- SpecialMap::const_iterator special_it, special_it_end;
- for (special_it = character->getSpecialBegin(),
- special_it_end = character->getSpecialEnd();
- special_it != special_it_end; ++special_it)
+ AbilityMap::const_iterator ability_it, ability_it_end;
+ for (ability_it = character->getAbilityBegin(),
+ ability_it_end = character->getAbilityEnd();
+ ability_it != ability_it_end; ++ability_it)
{
insertSql.str("");
- insertSql << "INSERT INTO " << CHAR_SPECIALS_TBL_NAME
- << " (char_id, special_id, special_current_mana)"
+ insertSql << "INSERT INTO " << CHAR_ABILITIES_TBL_NAME
+ << " (char_id, ability_id, ability_current_points)"
<< " VALUES ("
<< " '" << character->getDatabaseID() << "',"
- << " '" << special_it->first << "',"
- << " '" << special_it->second.currentMana
+ << " '" << ability_it->first << "',"
+ << " '" << ability_it->second.currentPoints
<< "');";
mDb->execSql(insertSql.str());
}
diff --git a/src/common/manaserv_protocol.h b/src/common/manaserv_protocol.h
index 2a1c9c1..5649999 100644
--- a/src/common/manaserv_protocol.h
+++ b/src/common/manaserv_protocol.h
@@ -30,7 +30,7 @@ namespace ManaServ {
enum {
PROTOCOL_VERSION = 3,
- SUPPORTED_DB_VERSION = 21
+ SUPPORTED_DB_VERSION = 22
};
/**
@@ -145,9 +145,9 @@ enum {
GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }*
PGMSG_ATTACK = 0x0290, // W being id
GPMSG_BEING_ATTACK = 0x0291, // W being id, B direction, B attack Id
- PGMSG_USE_SPECIAL_ON_BEING = 0x0292, // B specialID, W being id
- GPMSG_SPECIAL_STATUS = 0x0293, // { B specialID, D current, D max, D recharge }
- PGMSG_USE_SPECIAL_ON_POINT = 0x0294, // B specialID, W*2 position
+ PGMSG_USE_ABILITY_ON_BEING = 0x0292, // B abilityID, W being id
+ GPMSG_ABILITY_STATUS = 0x0293, // { B abilityID, D current, D max, D recharge }
+ PGMSG_USE_ABILITY_ON_POINT = 0x0294, // B abilityID, W*2 position
PGMSG_SAY = 0x02A0, // S text
GPMSG_SAY = 0x02A1, // W being id, S text
GPMSG_NPC_CHOICE = 0x02B0, // W being id, { S text }*
diff --git a/src/game-server/abilitymanager.cpp b/src/game-server/abilitymanager.cpp
new file mode 100644
index 0000000..91669f1
--- /dev/null
+++ b/src/game-server/abilitymanager.cpp
@@ -0,0 +1,182 @@
+/*
+ * The Mana Server
+ * Copyright (C) 2004-2010 The Mana World Development Team
+ * Copyright (C) 2010-2012 The Mana Developers
+ *
+ * This file is part of The Mana Server.
+ *
+ * The Mana Server is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana Server is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana Server. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "abilitymanager.h"
+
+#include "utils/xml.h"
+#include "utils/logger.h"
+
+static AbilityManager::TargetMode getTargetByString(const std::string &str)
+{
+ std::string strLower = utils::toLower(str);
+ if (strLower == "being")
+ return AbilityManager::TARGET_BEING;
+ else if (strLower == "point")
+ return AbilityManager::TARGET_POINT;
+
+ LOG_WARN("Unknown targetmode " << str << " assuming being.");
+ return AbilityManager::TARGET_BEING;
+}
+
+
+/**
+ * Read a <special> element from settings.
+ * Used by SettingsManager.
+ */
+void AbilityManager::readAbilitySetNode(xmlNodePtr node,
+ const std::string &filename)
+{
+ std::string setName = XML::getProperty(node, "name", std::string());
+ if (setName.empty())
+ {
+ LOG_WARN("The " << filename << " file contains unamed "
+ << "<ability-set> tags and will be ignored.");
+ return;
+ }
+
+ setName = utils::toLower(setName);
+
+ for_each_xml_child_node(specialNode, node)
+ {
+ if (xmlStrEqual(specialNode->name, BAD_CAST "ability")) {
+ readAbilityNode(specialNode, setName);
+ }
+ }
+
+}
+
+/**
+ * Check the status of recently loaded configuration.
+ */
+void AbilityManager::checkStatus()
+{
+ LOG_INFO("Loaded " << mAbilitiesInfo.size() << " abilities");
+}
+
+
+void AbilityManager::readAbilityNode(xmlNodePtr abilityNode,
+ const std::string &setName)
+{
+ std::string name = utils::toLower(
+ XML::getProperty(abilityNode, "name", std::string()));
+ int id = XML::getProperty(abilityNode, "id", 0);
+
+ if (id <= 0 || name.empty())
+ {
+ LOG_WARN("Invalid ability (empty name or id <= 0) in set: " << setName);
+ return;
+ }
+
+ AbilitiesInfo::iterator it = mAbilitiesInfo.find(id);
+ if (it != mAbilitiesInfo.end())
+ {
+ LOG_WARN("AbilityManager: The same id: " << id
+ << " is given for ability names: " << it->first
+ << " and " << name);
+ LOG_WARN("The ability reference: " << id
+ << ": '" << name << "' will be ignored.");
+ return;
+ }
+
+ bool rechargeable = XML::getBoolProperty(abilityNode, "rechargeable", true);
+ int neededMana = XML::getProperty(abilityNode, "needed", 0);
+ int defaultRechargeSpeed = XML::getProperty(abilityNode,
+ "rechargespeed", 0);
+
+ if (rechargeable && neededMana <= 0)
+ {
+ LOG_WARN("Invalid ability '" << name
+ << "' (rechargable but no needed attribute) in set: "
+ << setName);
+ return;
+ }
+
+
+ AbilityInfo *newInfo = new AbilityManager::AbilityInfo;
+ newInfo->setName = setName;
+ newInfo->name = name;
+ newInfo->id = id;
+ newInfo->rechargeable = rechargeable;
+ newInfo->neededPoints = neededMana;
+ newInfo->defaultRechargeSpeed = defaultRechargeSpeed;
+
+ newInfo->target = getTargetByString(XML::getProperty(abilityNode, "target",
+ std::string()));
+
+ mAbilitiesInfo[newInfo->id] = newInfo;
+
+ std::string keyName = setName + "_" + newInfo->name;
+ mNamedAbilitiesInfo[keyName] = newInfo;
+}
+
+void AbilityManager::initialize()
+{
+ clear();
+}
+
+void AbilityManager::reload()
+{
+ clear();
+}
+
+void AbilityManager::clear()
+{
+ for (AbilitiesInfo::iterator it = mAbilitiesInfo.begin(),
+ it_end = mAbilitiesInfo.end(); it != it_end; ++it)
+ {
+ delete it->second;
+ }
+ mAbilitiesInfo.clear();
+ mNamedAbilitiesInfo.clear();
+}
+
+unsigned AbilityManager::getId(const std::string &set,
+ const std::string &name) const
+{
+ std::string key = utils::toLower(set) + "_" + utils::toLower(name);
+ return getId(key);
+}
+
+unsigned AbilityManager::getId(const std::string &abilityName) const
+{
+ if (mNamedAbilitiesInfo.contains(abilityName))
+ return mNamedAbilitiesInfo.value(abilityName)->id;
+ else
+ return 0;
+}
+
+const std::string AbilityManager::getAbilityName(int id) const
+{
+ AbilitiesInfo::const_iterator it = mAbilitiesInfo.find(id);
+ return it != mAbilitiesInfo.end() ? it->second->name : "";
+}
+
+const std::string AbilityManager::getSetName(int id) const
+{
+ AbilitiesInfo::const_iterator it = mAbilitiesInfo.find(id);
+ return it != mAbilitiesInfo.end() ? it->second->setName : "";
+}
+
+AbilityManager::AbilityInfo *AbilityManager::getAbilityInfo(int id)
+{
+ AbilitiesInfo::const_iterator it = mAbilitiesInfo.find(id);
+ return it != mAbilitiesInfo.end() ? it->second : 0;
+}
diff --git a/src/game-server/specialmanager.h b/src/game-server/abilitymanager.h
index b5ac874..969cd70 100644
--- a/src/game-server/specialmanager.h
+++ b/src/game-server/abilitymanager.h
@@ -19,8 +19,8 @@
*/
-#ifndef SPECIALMANAGER_H
-#define SPECIALMANAGER_H
+#ifndef ABILITYMANAGER_H
+#define ABILITYMANAGER_H
#include "utils/string.h"
#include "utils/xml.h"
@@ -29,7 +29,7 @@
-class SpecialManager
+class AbilityManager
{
public:
enum TargetMode
@@ -38,13 +38,13 @@ public:
TARGET_POINT
};
- struct SpecialInfo
+ struct AbilityInfo
{
- SpecialInfo() :
+ AbilityInfo() :
id(0),
rechargeable(false),
defaultRechargeSpeed(0),
- neededMana(0),
+ neededPoints(0),
target(TARGET_BEING)
{}
@@ -53,65 +53,65 @@ public:
std::string setName;
bool rechargeable;
int defaultRechargeSpeed;
- unsigned neededMana;
+ unsigned neededPoints;
TargetMode target;
Script::Ref rechargedCallback;
Script::Ref useCallback;
};
- SpecialManager()
+ AbilityManager()
{ }
- ~SpecialManager()
+ ~AbilityManager()
{ clear(); }
/**
- * Loads special reference file.
+ * Loads ability reference file.
*/
void initialize();
/**
- * Reloads special reference file.
+ * Reloads ability reference file.
*/
void reload();
/**
- * Gets the specials Id from a set and a special string.
+ * Gets the abilities Id from a set and a ability string.
*/
unsigned getId(const std::string &set, const std::string &name) const;
/**
- * Gets the specials Id from a string formatted in this way:
- * "setname_skillname"
+ * Gets the abilities Id from a string formatted in this way:
+ * "setname_abilityname"
*/
- unsigned getId(const std::string &specialName) const;
+ unsigned getId(const std::string &abilityName) const;
- const std::string getSpecialName(int id) const;
+ const std::string getAbilityName(int id) const;
const std::string getSetName(int id) const;
- SpecialInfo *getSpecialInfo(int id);
+ AbilityInfo *getAbilityInfo(int id);
- void readSpecialSetNode(xmlNodePtr node, const std::string &filename);
+ void readAbilitySetNode(xmlNodePtr node, const std::string &filename);
void checkStatus();
private:
/**
- * Clears up the special maps.
+ * Clears up the ability maps.
*/
void clear();
- void readSpecialNode(xmlNodePtr skillNode,
+ void readAbilityNode(xmlNodePtr skillNode,
const std::string &setName);
- typedef std::map<unsigned, SpecialInfo*> SpecialsInfo;
- SpecialsInfo mSpecialsInfo;
- typedef utils::NameMap<SpecialInfo*> NamedSpecialsInfo;
- NamedSpecialsInfo mNamedSpecialsInfo;
+ typedef std::map<unsigned, AbilityInfo*> AbilitiesInfo;
+ AbilitiesInfo mAbilitiesInfo;
+ typedef utils::NameMap<AbilityInfo*> NamedAbilitiesInfo;
+ NamedAbilitiesInfo mNamedAbilitiesInfo;
};
-extern SpecialManager *specialManager;
+extern AbilityManager *abilityManager;
-#endif // SPECIALMANAGER_H
+#endif // ABILITYMANAGER_H
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index 52cc73f..ce8c6ca 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -75,7 +75,7 @@ CharacterComponent::CharacterComponent(Entity &entity, MessageIn &msg):
mClient(nullptr),
mConnected(true),
mTransactionHandler(nullptr),
- mSpecialUpdateNeeded(false),
+ mAbilitiesUpdateNeeded(false),
mDatabaseID(-1),
mHairStyle(0),
mHairColor(0),
@@ -161,30 +161,30 @@ void CharacterComponent::update(Entity &entity)
if (entity.getComponent<BeingComponent>()->getAction() == DEAD)
return;
- // Update special recharge
- for (SpecialMap::iterator it = mSpecials.begin(), it_end = mSpecials.end();
- it != it_end; it++)
+ // Update ability recharge
+ for (auto &it : mAbilities)
{
- SpecialValue &s = it->second;
- if (s.specialInfo->rechargeable && s.currentMana < s.specialInfo->neededMana)
+ AbilityValue &s = it.second;
+ if (s.abilityInfo->rechargeable &&
+ s.currentPoints < s.abilityInfo->neededPoints)
{
- s.currentMana += s.rechargeSpeed;
- if (s.currentMana >= s.specialInfo->neededMana &&
- s.specialInfo->rechargedCallback.isValid())
+ s.currentPoints += s.rechargeSpeed;
+ if (s.currentPoints >= s.abilityInfo->neededPoints &&
+ s.abilityInfo->rechargedCallback.isValid())
{
Script *script = ScriptManager::currentState();
- script->prepare(s.specialInfo->rechargedCallback);
+ script->prepare(s.abilityInfo->rechargedCallback);
script->push(&entity);
- script->push(s.specialInfo->id);
+ script->push(s.abilityInfo->id);
script->execute(entity.getMap());
}
}
}
- if (mSpecialUpdateNeeded)
+ if (mAbilitiesUpdateNeeded)
{
- sendSpecialUpdate();
- mSpecialUpdateNeeded = false;
+ sendAbilityUpdate();
+ mAbilitiesUpdateNeeded = false;
}
}
@@ -225,130 +225,131 @@ void CharacterComponent::respawn(Entity &entity)
Point(spawnX, spawnY));
}
-bool CharacterComponent::specialUseCheck(SpecialMap::iterator it)
+bool CharacterComponent::abilityUseCheck(AbilityMap::iterator it)
{
- if (it == mSpecials.end())
+ if (it == mAbilities.end())
{
- LOG_INFO("Character uses special " << it->first
+ LOG_INFO("Character uses ability " << it->first
<< " without authorization.");
return false;
}
- //check if the special is currently recharged
- SpecialValue &special = it->second;
- if (special.specialInfo->rechargeable &&
- special.currentMana < special.specialInfo->neededMana)
+ //check if the ability is currently recharged
+ AbilityValue &ability = it->second;
+ if (ability.abilityInfo->rechargeable &&
+ ability.currentPoints < ability.abilityInfo->neededPoints)
{
- LOG_INFO("Character uses special " << it->first << " which is not recharged. ("
- << special.currentMana << "/"
- << special.specialInfo->neededMana << ")");
+ LOG_INFO("Character uses ability " << it->first
+ << " which is not recharged. ("
+ << ability.currentPoints << "/"
+ << ability.abilityInfo->neededPoints << ")");
return false;
}
- if (!special.specialInfo->useCallback.isValid())
+ if (!ability.abilityInfo->useCallback.isValid())
{
- LOG_WARN("No callback for use of special "
- << special.specialInfo->setName << "/"
- << special.specialInfo->name << ". Ignoring special.");
+ LOG_WARN("No callback for use of ability "
+ << ability.abilityInfo->setName << "/"
+ << ability.abilityInfo->name << ". Ignoring ability.");
return false;
}
return true;
}
-void CharacterComponent::useSpecialOnBeing(Entity &user, int id, Entity *b)
+void CharacterComponent::useAbilityOnBeing(Entity &user, int id, Entity *b)
{
- SpecialMap::iterator it = mSpecials.find(id);
- if (!specialUseCheck(it))
+ AbilityMap::iterator it = mAbilities.find(id);
+ if (!abilityUseCheck(it))
return;
- SpecialValue &special = it->second;
+ AbilityValue &ability = it->second;
- if (special.specialInfo->target != SpecialManager::TARGET_BEING)
+ if (ability.abilityInfo->target != AbilityManager::TARGET_BEING)
return;
//tell script engine to cast the spell
Script *script = ScriptManager::currentState();
- script->prepare(special.specialInfo->useCallback);
+ script->prepare(ability.abilityInfo->useCallback);
script->push(&user);
script->push(b);
- script->push(special.specialInfo->id);
+ script->push(ability.abilityInfo->id);
script->execute(user.getMap());
}
-void CharacterComponent::useSpecialOnPoint(Entity &user, int id, int x, int y)
+void CharacterComponent::useAbilityOnPoint(Entity &user, int id, int x, int y)
{
- SpecialMap::iterator it = mSpecials.find(id);
- if (!specialUseCheck(it))
+ AbilityMap::iterator it = mAbilities.find(id);
+ if (!abilityUseCheck(it))
return;
- SpecialValue &special = it->second;
+ AbilityValue &ability = it->second;
- if (special.specialInfo->target != SpecialManager::TARGET_POINT)
+ if (ability.abilityInfo->target != AbilityManager::TARGET_POINT)
return;
//tell script engine to cast the spell
Script *script = ScriptManager::currentState();
- script->prepare(special.specialInfo->useCallback);
+ script->prepare(ability.abilityInfo->useCallback);
script->push(&user);
script->push(x);
script->push(y);
- script->push(special.specialInfo->id);
+ script->push(ability.abilityInfo->id);
script->execute(user.getMap());
}
-bool CharacterComponent::giveSpecial(int id, int currentMana)
+bool CharacterComponent::giveAbility(int id, int currentPoints)
{
- if (mSpecials.find(id) == mSpecials.end())
+ if (mAbilities.find(id) == mAbilities.end())
{
- const SpecialManager::SpecialInfo *specialInfo =
- specialManager->getSpecialInfo(id);
- if (!specialInfo)
+ const AbilityManager::AbilityInfo *abilityInfo =
+ abilityManager->getAbilityInfo(id);
+ if (!abilityInfo)
{
- LOG_ERROR("Tried to give not existing special id " << id << ".");
+ LOG_ERROR("Tried to give not existing ability id " << id << ".");
return false;
}
- mSpecials.insert(std::pair<int, SpecialValue>(
- id, SpecialValue(currentMana, specialInfo)));
- mSpecialUpdateNeeded = true;
+ mAbilities.insert(std::pair<int, AbilityValue>(
+ id, AbilityValue(currentPoints, abilityInfo)));
+ mAbilitiesUpdateNeeded = true;
return true;
}
return false;
}
-bool CharacterComponent::setSpecialMana(int id, int mana)
+bool CharacterComponent::setAbilityMana(int id, int mana)
{
- SpecialMap::iterator it = mSpecials.find(id);
- if (it != mSpecials.end())
+ AbilityMap::iterator it = mAbilities.find(id);
+ if (it != mAbilities.end())
{
- it->second.currentMana = mana;
- mSpecialUpdateNeeded = true;
+ it->second.currentPoints = mana;
+ mAbilitiesUpdateNeeded = true;
return true;
}
return false;
}
-bool CharacterComponent::setSpecialRechargeSpeed(int id, int speed)
+bool CharacterComponent::setAbilityRechargeSpeed(int id, int speed)
{
- SpecialMap::iterator it = mSpecials.find(id);
- if (it != mSpecials.end())
+ AbilityMap::iterator it = mAbilities.find(id);
+ if (it != mAbilities.end())
{
it->second.rechargeSpeed = speed;
- mSpecialUpdateNeeded = true;
+ mAbilitiesUpdateNeeded = true;
return true;
}
return false;
}
-void CharacterComponent::sendSpecialUpdate()
+void CharacterComponent::sendAbilityUpdate()
{
- //GPMSG_SPECIAL_STATUS = 0x0293,
- // { B specialID, L current, L max, L recharge }
+ //GPMSG_ABILITY_STATUS = 0x0293,
+ // { B abilityID, L current, L max, L recharge }
- MessageOut msg(GPMSG_SPECIAL_STATUS);
- for (SpecialMap::iterator it = mSpecials.begin(), it_end = mSpecials.end();
+ MessageOut msg(GPMSG_ABILITY_STATUS);
+ for (AbilityMap::iterator it = mAbilities.begin(), it_end = mAbilities.end();
it != it_end; ++it)
{
msg.writeInt8(it->first);
- msg.writeInt32(it->second.currentMana);
- msg.writeInt32(it->second.specialInfo->neededMana);
+ msg.writeInt32(it->second.currentPoints);
+ msg.writeInt32(it->second.abilityInfo->neededPoints);
msg.writeInt32(it->second.rechargeSpeed);
}
gameHandler->sendTo(mClient, msg);
@@ -724,21 +725,21 @@ void CharacterComponent::disconnected(Entity &entity)
signal_disconnected.emit(entity);
}
-bool CharacterComponent::takeSpecial(int id)
+bool CharacterComponent::takeAbility(int id)
{
- SpecialMap::iterator i = mSpecials.find(id);
- if (i != mSpecials.end())
+ AbilityMap::iterator i = mAbilities.find(id);
+ if (i != mAbilities.end())
{
- mSpecials.erase(i);
- mSpecialUpdateNeeded = true;
+ mAbilities.erase(i);
+ mAbilitiesUpdateNeeded = true;
return true;
}
return false;
}
-void CharacterComponent::clearSpecials()
+void CharacterComponent::clearAbilities()
{
- mSpecials.clear();
+ mAbilities.clear();
}
void CharacterComponent::triggerLoginCallback(Entity &entity)
diff --git a/src/game-server/character.h b/src/game-server/character.h
index 704122d..d4dd0fd 100644
--- a/src/game-server/character.h
+++ b/src/game-server/character.h
@@ -28,7 +28,7 @@
#include "game-server/being.h"
#include "game-server/mapcomposite.h"
#include "game-server/mapmanager.h"
-#include "game-server/specialmanager.h"
+#include "game-server/abilitymanager.h"
#include "scripting/script.h"
@@ -46,24 +46,24 @@ class MessageOut;
class Point;
class Trade;
-struct SpecialValue
+struct AbilityValue
{
- SpecialValue(unsigned currentMana,
- const SpecialManager::SpecialInfo *specialInfo)
- : currentMana(currentMana)
- , rechargeSpeed(specialInfo->defaultRechargeSpeed)
- , specialInfo(specialInfo)
+ AbilityValue(unsigned currentMana,
+ const AbilityManager::AbilityInfo *abilityInfo)
+ : currentPoints(currentMana)
+ , rechargeSpeed(abilityInfo->defaultRechargeSpeed)
+ , abilityInfo(abilityInfo)
{}
- unsigned currentMana;
+ unsigned currentPoints;
unsigned rechargeSpeed;
- const SpecialManager::SpecialInfo *specialInfo;
+ const AbilityManager::AbilityInfo *abilityInfo;
};
/**
- * Stores specials by their id.
+ * Stores abilities by their id.
*/
-typedef std::map<unsigned, SpecialValue> SpecialMap;
+typedef std::map<unsigned, AbilityValue> AbilityMap;
class CharacterData
@@ -114,11 +114,11 @@ public:
const std::map<int, int>::const_iterator getKillCountEnd() const;
void setKillCount(int monsterId, int kills);
- void clearSpecials();
- void giveSpecial(int id, int mana);
- int getSpecialSize() const;
- SpecialMap::const_iterator getSpecialBegin() const;
- SpecialMap::const_iterator getSpecialEnd() const;
+ void clearAbilities();
+ void giveAbility(int id, int mana);
+ int getAbilitySize() const;
+ AbilityMap::const_iterator getAbilityBegin() const;
+ AbilityMap::const_iterator getAbilityEnd() const;
Possessions &getPossessions() const;
@@ -162,52 +162,52 @@ class CharacterComponent : public Component
void respawn(Entity &entity);
/**
- * makes the character perform a special action on a being
+ * makes the character perform a ability on a being
* when it is allowed to do so
*/
- void useSpecialOnBeing(Entity &user, int id, Entity *b);
+ void useAbilityOnBeing(Entity &user, int id, Entity *b);
/**
- * makes the character perform a special action on a map point
+ * makes the character perform a ability on a map point
* when it is allowed to do so
*/
- void useSpecialOnPoint(Entity &user, int id, int x, int y);
+ void useAbilityOnPoint(Entity &user, int id, int x, int y);
/**
- * Allows a character to perform a special action
+ * Allows a character to perform a ability
*/
- bool giveSpecial(int id, int currentMana = 0);
+ bool giveAbility(int id, int currentMana = 0);
/**
* Sets new current mana + makes sure that the client will get informed.
*/
- bool setSpecialMana(int id, int mana);
+ bool setAbilityMana(int id, int mana);
/**
- * Gets the special value by id
+ * Gets the ability value by id
*/
- SpecialMap::iterator findSpecial(int id)
- { return mSpecials.find(id); }
+ AbilityMap::iterator findAbility(int id)
+ { return mAbilities.find(id); }
/**
- * Sets recharge speed of a special
+ * Sets recharge speed of a ability
*/
- bool setSpecialRechargeSpeed(int id, int speed);
+ bool setAbilityRechargeSpeed(int id, int speed);
/**
- * Removes all specials from character
+ * Removes all abilities from character
*/
- void clearSpecials();
+ void clearAbilities();
/**
- * Checks if a character knows a special action
+ * Checks if a character knows a ability action
*/
- bool hasSpecial(int id) { return mSpecials.find(id) != mSpecials.end(); }
+ bool hasAbility(int id) { return mAbilities.find(id) != mAbilities.end(); }
/**
- * Removes an available special action
+ * Removes an available ability action
*/
- bool takeSpecial(int id);
+ bool takeAbility(int id);
/**
* Gets client computer.
@@ -356,16 +356,16 @@ class CharacterComponent : public Component
{ mKillCount[monsterId] = kills; }
/**
- * Used to serialize specials.
+ * Used to serialize abilities.
*/
- int getSpecialSize() const
- { return mSpecials.size(); }
+ int getAbilitiesSize() const
+ { return mAbilities.size(); }
- const SpecialMap::const_iterator getSpecialBegin() const
- { return mSpecials.begin(); }
+ const AbilityMap::const_iterator getAbilitiesBegin() const
+ { return mAbilities.begin(); }
- const SpecialMap::const_iterator getSpecialEnd() const
- { return mSpecials.end(); }
+ const AbilityMap::const_iterator getAbilitiesEnd() const
+ { return mAbilities.end(); }
/**
* Gets total accumulated exp for skill.
@@ -470,7 +470,7 @@ class CharacterComponent : public Component
sigc::signal<void, Entity &> signal_disconnected;
private:
- bool specialUseCheck(SpecialMap::iterator it);
+ bool abilityUseCheck(AbilityMap::iterator it);
double getAttrBase(AttributeMap::const_iterator it) const
{ return it->second.getBase(); }
@@ -509,9 +509,9 @@ class CharacterComponent : public Component
void recalculateLevel(Entity &entity);
/**
- * Informs the client about his characters special charge status
+ * Informs the client about his characters abilities charge status
*/
- void sendSpecialUpdate();
+ void sendAbilityUpdate();
enum TransactionType
{ TRANS_NONE, TRANS_TRADE, TRANS_BUYSELL };
@@ -535,8 +535,8 @@ class CharacterComponent : public Component
std::map<int, int> mExperience; /**< experience collected for each skill.*/
- SpecialMap mSpecials;
- bool mSpecialUpdateNeeded;
+ AbilityMap mAbilities;
+ bool mAbilitiesUpdateNeeded;
int mDatabaseID; /**< Character's database ID. */
unsigned char mHairStyle; /**< Hair Style of the character. */
@@ -744,29 +744,29 @@ inline void CharacterData::setKillCount(int monsterId, int kills)
mCharacterComponent->setKillCount(monsterId, kills);
}
-inline void CharacterData::clearSpecials()
+inline void CharacterData::clearAbilities()
{
- mCharacterComponent->clearSpecials();
+ mCharacterComponent->clearAbilities();
}
-inline void CharacterData::giveSpecial(int id, int mana)
+inline void CharacterData::giveAbility(int id, int mana)
{
- mCharacterComponent->giveSpecial(id, mana);
+ mCharacterComponent->giveAbility(id, mana);
}
-inline int CharacterData::getSpecialSize() const
+inline int CharacterData::getAbilitySize() const
{
- return mCharacterComponent->getSpecialSize();
+ return mCharacterComponent->getAbilitiesSize();
}
-inline SpecialMap::const_iterator CharacterData::getSpecialBegin() const
+inline AbilityMap::const_iterator CharacterData::getAbilityBegin() const
{
- return mCharacterComponent->getSpecialBegin();
+ return mCharacterComponent->getAbilitiesBegin();
}
-inline SpecialMap::const_iterator CharacterData::getSpecialEnd() const
+inline AbilityMap::const_iterator CharacterData::getAbilityEnd() const
{
- return mCharacterComponent->getSpecialEnd();
+ return mCharacterComponent->getAbilitiesEnd();
}
inline Possessions &CharacterData::getPossessions() const
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp
index 4c210bf..c93aeee 100644
--- a/src/game-server/commandhandler.cpp
+++ b/src/game-server/commandhandler.cpp
@@ -32,7 +32,7 @@
#include "game-server/mapmanager.h"
#include "game-server/monster.h"
#include "game-server/monstermanager.h"
-#include "game-server/specialmanager.h"
+#include "game-server/abilitymanager.h"
#include "game-server/state.h"
#include "scripting/scriptmanager.h"
@@ -82,10 +82,10 @@ static void handleCraft(Entity*, std::string&);
static void handleGetPos(Entity*, std::string&);
static void handleSkills(Entity*, std::string&);
static void handleEffect(Entity*, std::string&);
-static void handleGiveSpecial(Entity*, std::string&);
-static void handleTakeSpecial(Entity*, std::string&);
-static void handleRechargeSpecial(Entity*, std::string&);
-static void handleListSpecials(Entity*, std::string&);
+static void handleGiveAbility(Entity*, std::string&);
+static void handleTakeAbility(Entity*, std::string&);
+static void handleRechargeAbility(Entity*, std::string&);
+static void handleListAbility(Entity*, std::string&);
static CmdRef const cmdRef[] =
{
@@ -153,20 +153,20 @@ static CmdRef const cmdRef[] =
"Shows an effect at the given position or on the given being. "
"The player's character is targeted if neither of them is provided.",
&handleEffect},
- {"givespecial", "<character> <special>",
- "Gives the character the special. "
- "The special can get passed as specialid or in the format "
- "<setname>_<specialname>", &handleGiveSpecial},
- {"takespecial", "<character> <special>",
- "Takes the special aways from the character. "
- "The special can get passed as specialid or in the format "
- "<setname>_<specialname>", &handleTakeSpecial},
- {"rechargespecial", "<character> <special>",
- "Recharges the special of the character. "
- "The special can get passed as specialid or in the format "
- "<setname>_<specialname>", &handleRechargeSpecial},
- {"listspecials", "<character>",
- "Lists the specials of the character.", &handleListSpecials},
+ {"giveability", "<character> <ability>",
+ "Gives the character the ability. "
+ "The ability can get passed as abilityid or in the format "
+ "<setname>_<abilityname>", &handleGiveAbility},
+ {"takeability", "<character> <ability>",
+ "Takes the ability aways from the character. "
+ "The ability can get passed as abilityid or in the format "
+ "<setname>_<abilityname>", &handleTakeAbility},
+ {"rechargeability", "<character> <ability>",
+ "Recharges the ability of the character. "
+ "The ability can get passed as abilityid or in the format "
+ "<setname>_<abilityname>", &handleRechargeAbility},
+ {"listabilities", "<character>",
+ "Lists the abilitys of the character.", &handleListAbility},
{nullptr, nullptr, nullptr, nullptr}
};
@@ -1602,14 +1602,14 @@ static void handleEffect(Entity *player, std::string &args)
}
}
-static void handleGiveSpecial(Entity *player, std::string &args)
+static void handleGiveAbility(Entity *player, std::string &args)
{
std::string character = getArgument(args);
- std::string special = getArgument(args);
- if (character.empty() || special.empty())
+ std::string ability = getArgument(args);
+ if (character.empty() || ability.empty())
{
say("Invalid amount of arguments given.", player);
- say("Usage: @givespecial <character> <special>", player);
+ say("Usage: @giveability <character> <ability>", player);
return;
}
@@ -1625,28 +1625,28 @@ static void handleGiveSpecial(Entity *player, std::string &args)
return;
}
- int specialId;
- if (utils::isNumeric(special))
- specialId = utils::stringToInt(special);
+ int abilityId;
+ if (utils::isNumeric(ability))
+ abilityId = utils::stringToInt(ability);
else
- specialId = specialManager->getId(special);
+ abilityId = abilityManager->getId(ability);
- if (specialId <= 0 ||
- !other->getComponent<CharacterComponent>()->giveSpecial(specialId))
+ if (abilityId <= 0 ||
+ !other->getComponent<CharacterComponent>()->giveAbility(abilityId))
{
- say("Invalid special.", player);
+ say("Invalid ability.", player);
return;
}
}
-static void handleTakeSpecial(Entity *player, std::string &args)
+static void handleTakeAbility(Entity *player, std::string &args)
{
std::string character = getArgument(args);
- std::string special = getArgument(args);
- if (character.empty() || special.empty())
+ std::string ability = getArgument(args);
+ if (character.empty() || ability.empty())
{
say("Invalid amount of arguments given.", player);
- say("Usage: @takespecial <character> <special>", player);
+ say("Usage: @takeability <character> <ability>", player);
return;
}
@@ -1662,33 +1662,33 @@ static void handleTakeSpecial(Entity *player, std::string &args)
return;
}
- int specialId;
- if (utils::isNumeric(special))
- specialId = utils::stringToInt(special);
+ int abilityId;
+ if (utils::isNumeric(ability))
+ abilityId = utils::stringToInt(ability);
else
- specialId = specialManager->getId(special);
+ abilityId = abilityManager->getId(ability);
- if (specialId <= 0)
+ if (abilityId <= 0)
{
- say("Invalid special.", player);
+ say("Invalid ability.", player);
return;
}
- if (!other->getComponent<CharacterComponent>()->takeSpecial(specialId))
+ if (!other->getComponent<CharacterComponent>()->takeAbility(abilityId))
{
- say("Character does not have special.", player);
+ say("Character does not have ability.", player);
return;
}
}
-static void handleRechargeSpecial(Entity *player, std::string &args)
+static void handleRechargeAbility(Entity *player, std::string &args)
{
std::string character = getArgument(args);
- std::string special = getArgument(args);
+ std::string ability = getArgument(args);
std::string newMana = getArgument(args);
- if (character.empty() || special.empty())
+ if (character.empty() || ability.empty())
{
say("Invalid amount of arguments given.", player);
- say("Usage: @rechargespecial <character> <special> [<mana>]", player);
+ say("Usage: @rechargeability <character> <ability> [<mana>]", player);
return;
}
@@ -1704,24 +1704,24 @@ static void handleRechargeSpecial(Entity *player, std::string &args)
return;
}
- int specialId;
- if (utils::isNumeric(special))
- specialId = utils::stringToInt(special);
+ int abilityId;
+ if (utils::isNumeric(ability))
+ abilityId = utils::stringToInt(ability);
else
- specialId = specialManager->getId(special);
+ abilityId = abilityManager->getId(ability);
- SpecialManager::SpecialInfo *info =
- specialManager->getSpecialInfo(specialId);
+ AbilityManager::AbilityInfo *info =
+ abilityManager->getAbilityInfo(abilityId);
if (!info)
{
- say("Invalid special.", player);
+ say("Invalid ability.", player);
return;
}
int mana;
if (newMana.empty())
{
- mana = info->neededMana;
+ mana = info->neededPoints;
}
else
{
@@ -1733,20 +1733,20 @@ static void handleRechargeSpecial(Entity *player, std::string &args)
mana = utils::stringToInt(newMana);
}
if (!other->getComponent<CharacterComponent>()
- ->setSpecialMana(specialId, mana))
+ ->setAbilityMana(abilityId, mana))
{
- say("Character does not have special.", player);
+ say("Character does not have ability.", player);
return;
}
}
-static void handleListSpecials(Entity *player, std::string &args)
+static void handleListAbility(Entity *player, std::string &args)
{
std::string character = getArgument(args);
if (character.empty())
{
say("Invalid amount of arguments given.", player);
- say("Usage: @listspecials <character>", player);
+ say("Usage: @listabilitys <character>", player);
return;
}
@@ -1765,15 +1765,15 @@ static void handleListSpecials(Entity *player, std::string &args)
auto *characterComponent =
other->getComponent<CharacterComponent>();
- say("Specials of character " +
+ say("Abilityies of character " +
other->getComponent<BeingComponent>()->getName() + ":", player);
- for (SpecialMap::const_iterator it = characterComponent->getSpecialBegin(),
- it_end = characterComponent->getSpecialEnd(); it != it_end; ++it)
+ for (AbilityMap::const_iterator it = characterComponent->getAbilitiesBegin(),
+ it_end = characterComponent->getAbilitiesEnd(); it != it_end; ++it)
{
- const SpecialValue &info = it->second;
+ const AbilityValue &info = it->second;
std::stringstream str;
- str << info.specialInfo->id << ": " << info.specialInfo->setName << "/"
- << info.specialInfo->name << " charge: " << info.currentMana;
+ str << info.abilityInfo->id << ": " << info.abilityInfo->setName << "/"
+ << info.abilityInfo->name << " charge: " << info.currentPoints;
say(str.str(), player);
}
}
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index 79a14c6..2740284 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -258,12 +258,12 @@ void GameHandler::processMessage(NetComputer *computer, MessageIn &message)
handleAttack(client, message);
break;
- case PGMSG_USE_SPECIAL_ON_BEING:
- handleUseSpecialOnBeing(client, message);
+ case PGMSG_USE_ABILITY_ON_BEING:
+ handleUseAbilityOnBeing(client, message);
break;
- case PGMSG_USE_SPECIAL_ON_POINT:
- handleUseSpecialOnPoint(client, message);
+ case PGMSG_USE_ABILITY_ON_POINT:
+ handleUseAbilityOnPoint(client, message);
break;
case PGMSG_ACTION_CHANGE:
@@ -687,12 +687,12 @@ void GameHandler::handleAttack(GameClient &client, MessageIn &message)
}
}
-void GameHandler::handleUseSpecialOnBeing(GameClient &client, MessageIn &message)
+void GameHandler::handleUseAbilityOnBeing(GameClient &client, MessageIn &message)
{
if (client.character->getComponent<BeingComponent>()->getAction() == DEAD)
return;
- const int specialID = message.readInt8();
+ const int abilityID = message.readInt8();
const int targetID = message.readInt16(); // 0 when no target is selected
Entity *being = 0;
if (targetID != 0)
@@ -701,28 +701,28 @@ void GameHandler::handleUseSpecialOnBeing(GameClient &client, MessageIn &message
const int publicId =
client.character->getComponent<ActorComponent>()->getPublicID();
LOG_DEBUG("Character " << publicId
- << " tries to use his special attack " << specialID);
+ << " tries to use his ability " << abilityID);
auto *characterComponent = client.character
->getComponent<CharacterComponent>();
- characterComponent->useSpecialOnBeing(*client.character, specialID, being);
+ characterComponent->useAbilityOnBeing(*client.character, abilityID, being);
}
-void GameHandler::handleUseSpecialOnPoint(GameClient &client, MessageIn &message)
+void GameHandler::handleUseAbilityOnPoint(GameClient &client, MessageIn &message)
{
if (client.character->getComponent<BeingComponent>()->getAction() == DEAD)
return;
- const int specialID = message.readInt8();
+ const int abilityID = message.readInt8();
const int x = message.readInt16();
const int y = message.readInt16();
const int publicId =
client.character->getComponent<ActorComponent>()->getPublicID();
LOG_DEBUG("Character " << publicId
- << " tries to use his special attack " << specialID);
+ << " tries to use his ability attack " << abilityID);
auto *characterComponent = client.character
->getComponent<CharacterComponent>();
- characterComponent->useSpecialOnPoint(*client.character, specialID, x, y);
+ characterComponent->useAbilityOnPoint(*client.character, abilityID, x, y);
}
void GameHandler::handleActionChange(GameClient &client, MessageIn &message)
diff --git a/src/game-server/gamehandler.h b/src/game-server/gamehandler.h
index d66caf5..0abc287 100644
--- a/src/game-server/gamehandler.h
+++ b/src/game-server/gamehandler.h
@@ -135,8 +135,8 @@ class GameHandler: public ConnectionHandler
void handleMoveItem(GameClient &client, MessageIn &message);
void handleAttack(GameClient &client, MessageIn &message);
- void handleUseSpecialOnBeing(GameClient &client, MessageIn &message);
- void handleUseSpecialOnPoint(GameClient &client, MessageIn &message);
+ void handleUseAbilityOnBeing(GameClient &client, MessageIn &message);
+ void handleUseAbilityOnPoint(GameClient &client, MessageIn &message);
void handleActionChange(GameClient &client, MessageIn &message);
void handleDirectionChange(GameClient &client, MessageIn &message);
diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp
index 894af5f..1a9f0af 100644
--- a/src/game-server/main-game.cpp
+++ b/src/game-server/main-game.cpp
@@ -31,7 +31,7 @@
#include "game-server/mapmanager.h"
#include "game-server/monstermanager.h"
#include "game-server/skillmanager.h"
-#include "game-server/specialmanager.h"
+#include "game-server/abilitymanager.h"
#include "game-server/statusmanager.h"
#include "game-server/postman.h"
#include "game-server/state.h"
@@ -78,11 +78,11 @@ static bool running = true; /**< Whether the server keeps running */
utils::StringFilter *stringFilter; /**< Slang's Filter */
+AbilityManager *abilityManager = new AbilityManager();
AttributeManager *attributeManager = new AttributeManager();
ItemManager *itemManager = new ItemManager();
MonsterManager *monsterManager = new MonsterManager();
SkillManager *skillManager = new SkillManager();
-SpecialManager *specialManager = new SpecialManager();
EmoteManager *emoteManager = new EmoteManager();
SettingsManager *settingsManager = new SettingsManager(DEFAULT_SETTINGS_FILE);
@@ -185,7 +185,7 @@ static void deinitializeServer()
// Destroy Managers
delete stringFilter; stringFilter = 0;
delete monsterManager; monsterManager = 0;
- delete skillManager; skillManager = 0;
+ delete abilityManager; abilityManager = 0;
delete itemManager; itemManager = 0;
delete emoteManager; emoteManager = 0;
delete settingsManager; settingsManager = 0;
diff --git a/src/game-server/settingsmanager.cpp b/src/game-server/settingsmanager.cpp
index b45ef93..b909fb6 100644
--- a/src/game-server/settingsmanager.cpp
+++ b/src/game-server/settingsmanager.cpp
@@ -25,11 +25,11 @@
#include "common/resourcemanager.h"
-#include "game-server/mapmanager.h"
+#include "game-server/abilitymanager.h"
#include "game-server/attributemanager.h"
#include "game-server/skillmanager.h"
-#include "game-server/specialmanager.h"
#include "game-server/itemmanager.h"
+#include "game-server/mapmanager.h"
#include "game-server/monstermanager.h"
#include "game-server/emotemanager.h"
#include "game-server/statusmanager.h"
@@ -45,7 +45,7 @@ void SettingsManager::initialize()
MapManager::initialize();
attributeManager->initialize();
skillManager->initialize();
- specialManager->initialize();
+ abilityManager->initialize();
itemManager->initialize();
monsterManager->initialize();
emoteManager->initialize();
@@ -66,7 +66,7 @@ void SettingsManager::reload()
MapManager::reload();
attributeManager->reload();
skillManager->reload();
- specialManager->reload();
+ abilityManager->reload();
itemManager->reload();
monsterManager->reload();
emoteManager->reload();
@@ -143,10 +143,10 @@ void SettingsManager::loadFile(const std::string &filename)
// skills config
skillManager->readSkillSetNode(childNode, filename);
}
- else if (xmlStrEqual(childNode->name, BAD_CAST "special-set"))
+ else if (xmlStrEqual(childNode->name, BAD_CAST "ability-set"))
{
- // special config
- specialManager->readSpecialSetNode(childNode, filename);
+ // ability config
+ abilityManager->readAbilitySetNode(childNode, filename);
}
else if (xmlStrEqual(childNode->name, BAD_CAST "slot"))
{
@@ -192,7 +192,7 @@ void SettingsManager::checkStatus()
MapManager::checkStatus();
attributeManager->checkStatus();
skillManager->checkStatus();
- specialManager->checkStatus();
+ abilityManager->checkStatus();
itemManager->checkStatus();
monsterManager->checkStatus();
emoteManager->checkStatus();
diff --git a/src/game-server/specialmanager.cpp b/src/game-server/specialmanager.cpp
deleted file mode 100644
index 0840d25..0000000
--- a/src/game-server/specialmanager.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * The Mana Server
- * Copyright (C) 2004-2010 The Mana World Development Team
- * Copyright (C) 2010-2012 The Mana Developers
- *
- * This file is part of The Mana Server.
- *
- * The Mana Server is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * The Mana Server is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Mana Server. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "specialmanager.h"
-
-#include "utils/xml.h"
-#include "utils/logger.h"
-
-static SpecialManager::TargetMode getTargetByString(const std::string &str)
-{
- std::string strLower = utils::toLower(str);
- if (strLower == "being")
- return SpecialManager::TARGET_BEING;
- else if (strLower == "point")
- return SpecialManager::TARGET_POINT;
-
- LOG_WARN("Unknown targetmode " << str << " assuming being.");
- return SpecialManager::TARGET_BEING;
-}
-
-
-/**
- * Read a <special> element from settings.
- * Used by SettingsManager.
- */
-void SpecialManager::readSpecialSetNode(xmlNodePtr node, const std::string &filename)
-{
- std::string setName = XML::getProperty(node, "name", std::string());
- if (setName.empty())
- {
- LOG_WARN("The " << filename << " file contains unamed <set> tags and will be ignored.");
- return;
- }
-
- setName = utils::toLower(setName);
-
- for_each_xml_child_node(specialNode, node)
- {
- if (xmlStrEqual(specialNode->name, BAD_CAST "special")) {
- readSpecialNode(specialNode, setName);
- }
- }
-
-}
-
-/**
- * Check the status of recently loaded configuration.
- */
-void SpecialManager::checkStatus()
-{
- LOG_INFO("Loaded " << mSpecialsInfo.size() << " specials");
-}
-
-void SpecialManager::readSpecialNode(xmlNodePtr specialNode,
- const std::string &setName)
-{
- std::string name = utils::toLower(
- XML::getProperty(specialNode, "name", std::string()));
- int id = XML::getProperty(specialNode, "id", 0);
-
- if (id <= 0 || name.empty())
- {
- LOG_WARN("Invalid special (empty name or id <= 0) in set: " << setName);
- return;
- }
-
- SpecialsInfo::iterator it = mSpecialsInfo.find(id);
- if (it != mSpecialsInfo.end())
- {
- LOG_WARN("SpecialManager: The same id: " << id
- << " is given for special names: " << it->first
- << " and " << name);
- LOG_WARN("The special reference: " << id
- << ": '" << name << "' will be ignored.");
- return;
- }
-
- bool rechargeable = XML::getBoolProperty(specialNode, "rechargeable", true);
- int neededMana = XML::getProperty(specialNode, "needed", 0);
- int defaultRechargeSpeed = XML::getProperty(specialNode,
- "rechargespeed", 0);
-
- if (rechargeable && neededMana <= 0)
- {
- LOG_WARN("Invalid special '" << name
- << "' (rechargable but no needed attribute) in set: "
- << setName);
- return;
- }
-
-
- SpecialInfo *newInfo = new SpecialManager::SpecialInfo;
- newInfo->setName = setName;
- newInfo->name = name;
- newInfo->id = id;
- newInfo->rechargeable = rechargeable;
- newInfo->neededMana = neededMana;
- newInfo->defaultRechargeSpeed = defaultRechargeSpeed;
-
- newInfo->target = getTargetByString(XML::getProperty(specialNode, "target",
- std::string()));
-
- mSpecialsInfo[newInfo->id] = newInfo;
-
- std::string keyName = setName + "_" + newInfo->name;
- mNamedSpecialsInfo[keyName] = newInfo;
-}
-
-void SpecialManager::initialize()
-{
- clear();
-}
-
-void SpecialManager::reload()
-{
- clear();
-}
-
-void SpecialManager::clear()
-{
- for (SpecialsInfo::iterator it = mSpecialsInfo.begin(),
- it_end = mSpecialsInfo.end(); it != it_end; ++it)
- {
- delete it->second;
- }
- mSpecialsInfo.clear();
- mNamedSpecialsInfo.clear();
-}
-
-unsigned SpecialManager::getId(const std::string &set,
- const std::string &name) const
-{
- std::string key = utils::toLower(set) + "_" + utils::toLower(name);
- return getId(key);
-}
-
-unsigned SpecialManager::getId(const std::string &specialName) const
-{
- if (mNamedSpecialsInfo.contains(specialName))
- return mNamedSpecialsInfo.value(specialName)->id;
- else
- return 0;
-}
-
-const std::string SpecialManager::getSpecialName(int id) const
-{
- SpecialsInfo::const_iterator it = mSpecialsInfo.find(id);
- return it != mSpecialsInfo.end() ? it->second->name : "";
-}
-
-const std::string SpecialManager::getSetName(int id) const
-{
- SpecialsInfo::const_iterator it = mSpecialsInfo.find(id);
- return it != mSpecialsInfo.end() ? it->second->setName : "";
-}
-
-SpecialManager::SpecialInfo *SpecialManager::getSpecialInfo(int id)
-{
- SpecialsInfo::const_iterator it = mSpecialsInfo.find(id);
- return it != mSpecialsInfo.end() ? it->second : 0;
-}
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 422649f..b9ccaf5 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -1278,106 +1278,106 @@ static int chr_set_quest(lua_State *s)
return 0;
}
-/** LUA entity:set_special_recharge_speed (being)
- * entity:set_special_recharge_speed(int specialid, int new_speed)
- * entity:set_special_recharge_speed(string specialname, int new_speed)
+/** LUA entity:set_ability_recharge_speed (being)
+ * entity:set_ability_recharge_speed(int abilityid, int new_speed)
+ * entity:set_ability_recharge_speed(string abilityname, int new_speed)
**
* Valid only for character entities.
*
- * Sets the recharge speed of the special to a new value for the character.
+ * Sets the recharge speed of the ability to a new value for the character.
*
- * **Note:** When passing the ''specialname'' as parameter make sure that it is
- * formatted in this way: <setname>_<specialname> (for eg. "Magic_Healingspell").
+ * **Note:** When passing the ''abilityname'' as parameter make sure that it is
+ * formatted in this way: <setname>_<abilityname> (for eg. "Magic_Healingspell").
*/
-static int entity_set_special_recharge_speed(lua_State *s)
+static int entity_set_ability_recharge_speed(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
- const int special = checkSpecial(s, 2);
+ const int ability = checkAbility(s, 2);
const int speed = luaL_checkint(s, 3);
if (!c->getComponent<CharacterComponent>()
- ->setSpecialRechargeSpeed(special, speed))
+ ->setAbilityRechargeSpeed(ability, speed))
{
luaL_error(s,
- "set_special_recharge_speed called with special "
+ "set_ability_recharge_speed called with ability "
"that is not owned by character.");
}
return 0;
}
-/** LUA entity:special_recharge_speed (being)
- * entity:special_recharge_speed(int specialid)
- * entity:special_recharge_speed(string specialname)
+/** LUA entity:ability_recharge_speed (being)
+ * entity:ability_recharge_speed(int abilityid)
+ * entity:ability_recharge_speed(string abilityname)
**
* Valid only for character entities.
*
- * **Return value:** The current recharge speed of the special that is owned by
+ * **Return value:** The current recharge speed of the ability that is owned by
* the character.
*
- * **Note:** When passing the ''specialname'' as parameter make sure that it is
- * formatted in this way: <setname>_<specialname> (for eg. "Magic_Healingspell").
+ * **Note:** When passing the ''abilityname'' as parameter make sure that it is
+ * formatted in this way: <setname>_<abilityname> (for eg. "Magic_Healingspell").
*/
-static int entity_get_special_recharge_speed(lua_State *s)
+static int entity_get_ability_recharge_speed(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
- const int special = checkSpecial(s, 2);
+ const int ability = checkAbility(s, 2);
auto *characterComponent = c->getComponent<CharacterComponent>();
- SpecialMap::iterator it = characterComponent->findSpecial(special);
+ AbilityMap::iterator it = characterComponent->findAbility(ability);
- luaL_argcheck(s, it != characterComponent->getSpecialEnd(), 2,
- "character does not have special");
+ luaL_argcheck(s, it != characterComponent->getAbilitiesEnd(), 2,
+ "character does not have ability");
lua_pushinteger(s, it->second.rechargeSpeed);
return 1;
}
-/** LUA entity:set_special_mana (being)
- * entity:set_special_mana(int specialid, int new_mana)
- * entity:set_special_mana(string specialname, int new_mana)
+/** LUA entity:set_ability_mana (being)
+ * entity:set_ability_mana(int abilityid, int new_mana)
+ * entity:set_ability_mana(string abilityname, int new_mana)
**
* Valid only for character entities.
*
- * Sets the mana (recharge status) of the special to a new value for the
+ * Sets the mana (recharge status) of the ability to a new value for the
* character.
*
- * **Note:** When passing the ''specialname'' as parameter make sure that it is
- * formatted in this way: <setname>_<specialname> (for eg. "Magic_Healingspell").
+ * **Note:** When passing the ''abilityname'' as parameter make sure that it is
+ * formatted in this way: <setname>_<abilityname> (for eg. "Magic_Healingspell").
*/
-static int entity_set_special_mana(lua_State *s)
+static int entity_set_ability_mana(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
- const int special = checkSpecial(s, 2);
+ const int ability = checkAbility(s, 2);
const int mana = luaL_checkint(s, 3);
- if (!c->getComponent<CharacterComponent>()->setSpecialMana(special, mana))
+ if (!c->getComponent<CharacterComponent>()->setAbilityMana(ability, mana))
{
luaL_error(s,
- "set_special_mana called with special "
+ "set_ability_mana called with ability "
"that is not owned by character.");
}
return 0;
}
-/** LUA entity:special_mana (being)
- * entity:special_mana(int specialid)
- * entity:special_mana(string specialname)
+/** LUA entity:ability_mana (being)
+ * entity:ability_mana(int abilityid)
+ * entity:ability_mana(string abilityname)
**
- * **Return value:** The mana (recharge status) of the special that is owned by
+ * **Return value:** The mana (recharge status) of the ability that is owned by
* the character.
*
- * **Note:** When passing the ''specialname'' as parameter make sure that it is
- * formatted in this way: <setname>_<specialname> (for eg. "Magic_Healingspell").
+ * **Note:** When passing the ''abilityname'' as parameter make sure that it is
+ * formatted in this way: <setname>_<abilityname> (for eg. "Magic_Healingspell").
*/
-static int entity_get_special_mana(lua_State *s)
+static int entity_get_ability_mana(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
auto *characterComponent = c->getComponent<CharacterComponent>();
- const int special = checkSpecial(s, 2);
- SpecialMap::iterator it = characterComponent->findSpecial(special);
- luaL_argcheck(s, it != characterComponent->getSpecialEnd(), 2,
- "character does not have special");
- lua_pushinteger(s, it->second.currentMana);
+ const int ability = checkAbility(s, 2);
+ AbilityMap::iterator it = characterComponent->findAbility(ability);
+ luaL_argcheck(s, it != characterComponent->getAbilitiesEnd(), 2,
+ "character does not have ability");
+ lua_pushinteger(s, it->second.currentPoints);
return 1;
}
@@ -2342,58 +2342,58 @@ static int entity_show_text_particle(lua_State *s)
return 0;
}
-/** LUA entity:give_special (being)
- * entity:give_special(int special)
+/** LUA entity:give_ability (being)
+ * entity:give_ability(int ability)
**
* Valid only for character entities.
*
- * Enables a special for a character.
+ * Enables a ability for a character.
*/
-static int entity_give_special(lua_State *s)
+static int entity_give_ability(lua_State *s)
{
// cost_type is ignored until we have more than one cost type
Entity *c = checkCharacter(s, 1);
- const int special = checkSpecial(s, 2);
+ const int ability = checkAbility(s, 2);
const int currentMana = luaL_optint(s, 3, 0);
- c->getComponent<CharacterComponent>()->giveSpecial(special, currentMana);
+ c->getComponent<CharacterComponent>()->giveAbility(ability, currentMana);
return 0;
}
-/** LUA entity:has_special (being)
- * entity:has_special(int special)
+/** LUA entity:has_ability (being)
+ * entity:has_ability(int ability)
**
* Valid only for character entities.
*
- * **Return value:** True if the character has the special, false otherwise.
+ * **Return value:** True if the character has the ability, false otherwise.
*/
-static int entity_has_special(lua_State *s)
+static int entity_has_ability(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
- const int special = luaL_checkint(s, 2);
+ const int ability = luaL_checkint(s, 2);
- lua_pushboolean(s, c->getComponent<CharacterComponent>()->hasSpecial(special));
+ lua_pushboolean(s, c->getComponent<CharacterComponent>()->hasAbility(ability));
return 1;
}
-/** LUA entity:take_special (being)
- * entity:take_special(int special)
+/** LUA entity:take_ability (being)
+ * entity:take_ability(int ability)
**
* Valid only for character entities.
*
- * Removes a special from a character.
+ * Removes a ability from a character.
*
* **Return value:** True if removal was successful, false otherwise (in case
- * the character did not have the special).
+ * the character did not have the ability).
*/
-static int entity_take_special(lua_State *s)
+static int entity_take_ability(lua_State *s)
{
Entity *c = checkCharacter(s, 1);
- const int special = luaL_checkint(s, 2);
+ const int ability = luaL_checkint(s, 2);
CharacterComponent *cc = c->getComponent<CharacterComponent>();
- lua_pushboolean(s, cc->hasSpecial(special));
- cc->takeSpecial(special);
+ lua_pushboolean(s, cc->hasAbility(ability));
+ cc->takeAbility(ability);
return 1;
}
@@ -2902,124 +2902,125 @@ static int get_distance(lua_State *s)
}
-/** LUA_CATEGORY Special info class (specialinfo)
- * See the [[specials.xml#A script example|specials Documentation]] for a
+/** LUA_CATEGORY Ability info class (abilityinfo)
+ * See the [[abilitys.xml#A script example|abilitys Documentation]] for a
* script example
*/
-/** LUA get_special_info (specialinfo)
- * get_special_info(int specialId)
- * get_special_info(string specialName)
+/** LUA get_ability_info (abilityinfo)
+ * get_ability_info(int abilityId)
+ * get_ability_info(string abilityName)
**
- * **Return value:** This function returns a object of the specialinfo class.
+ * **Return value:** This function returns a object of the abilityinfo class.
* See below for usage of that object.
*
- * **Note:** When passing the ''specialName'' as parameter make sure that it is
- * formatted in this way: <setname>_<specialname> (for eg. "Magic_Healingspell").
+ * **Note:** When passing the ''abilityName'' as parameter make sure that it is
+ * formatted in this way: <setname>_<abilityname> (for eg. "Magic_Healingspell").
*/
-static int get_special_info(lua_State *s)
+static int get_ability_info(lua_State *s)
{
- const int special = checkSpecial(s, 1);
- SpecialManager::SpecialInfo *info = specialManager->getSpecialInfo(special);
- luaL_argcheck(s, info, 1, "invalid special");
- LuaSpecialInfo::push(s, info);
+ const int ability = checkAbility(s, 1);
+ AbilityManager::AbilityInfo *info =
+ abilityManager->getAbilityInfo(ability);
+ luaL_argcheck(s, info, 1, "invalid ability");
+ LuaAbilityInfo::push(s, info);
return 1;
}
-/** LUA specialinfo:name (specialinfo)
- * specialinfo:name()
+/** LUA abilityinfo:name (abilityinfo)
+ * abilityinfo:name()
**
- * ** Return value:** The name of the specialinfo object.
+ * ** Return value:** The name of the abilityinfo object.
*
- * **Note:** See [[scripting#get_special_info|get_special_info]] for getting a
- * specialinfo object.
+ * **Note:** See [[scripting#get_ability_info|get_ability_info]] for getting a
+ * abilityinfo object.
*/
-static int specialinfo_get_name(lua_State *s)
+static int abilityinfo_get_name(lua_State *s)
{
- SpecialManager::SpecialInfo *info = LuaSpecialInfo::check(s, 1);
+ AbilityManager::AbilityInfo *info = LuaAbilityInfo::check(s, 1);
push(s, info->name);
return 1;
}
-/** LUA specialinfo:needed_mana (specialinfo)
- * specialinfo:needed_mana()
+/** LUA abilityinfo:needed_mana (abilityinfo)
+ * abilityinfo:needed_mana()
**
- * ** Return value:** The mana that is needed to use the special
+ * ** Return value:** The mana that is needed to use the ability
*
- * **Note:** See [[scripting#get_special_info|get_special_info]] for getting a
- * specialinfo object.
+ * **Note:** See [[scripting#get_ability_info|get_ability_info]] for getting a
+ * abilityinfo object.
*/
-static int specialinfo_get_needed_mana(lua_State *s)
+static int abilityinfo_get_needed_mana(lua_State *s)
{
- SpecialManager::SpecialInfo *info = LuaSpecialInfo::check(s, 1);
- lua_pushinteger(s, info->neededMana);
+ AbilityManager::AbilityInfo *info = LuaAbilityInfo::check(s, 1);
+ lua_pushinteger(s, info->neededPoints);
return 1;
}
-/** LUA specialinfo:rechargeable (specialinfo)
- * specialinfo:rechargeable()
+/** LUA abilityinfo:rechargeable (abilityinfo)
+ * abilityinfo:rechargeable()
**
- * ** Return value:** A boolean value that indicates whether the special is
+ * ** Return value:** A boolean value that indicates whether the ability is
* rechargeable or usuable without recharge.
*
- * **Note:** See [[scripting#get_special_info|get_special_info]] for getting
- * a specialinfo object.
+ * **Note:** See [[scripting#get_ability_info|get_ability_info]] for getting
+ * a abilityinfo object.
*/
-static int specialinfo_is_rechargeable(lua_State *s)
+static int abilityinfo_is_rechargeable(lua_State *s)
{
- SpecialManager::SpecialInfo *info = LuaSpecialInfo::check(s, 1);
+ AbilityManager::AbilityInfo *info = LuaAbilityInfo::check(s, 1);
lua_pushboolean(s, info->rechargeable);
return 1;
}
-/** LUA specialinfo:on_use (specialinfo)
- * specialinfo:on_use(function callback)
+/** LUA abilityinfo:on_use (abilityinfo)
+ * abilityinfo:on_use(function callback)
**
* Assigns the ''callback'' as callback for the use event. This function will
- * be called everytime a character uses a special.
+ * be called everytime a character uses a ability.
*
- * **Note:** See [[scripting#get_special_info|get_special_info]] for getting
- * a specialinfo object.
+ * **Note:** See [[scripting#get_ability_info|get_ability_info]] for getting
+ * a abilityinfo object.
*/
-static int specialinfo_on_use(lua_State *s)
+static int abilityinfo_on_use(lua_State *s)
{
- SpecialManager::SpecialInfo *info = LuaSpecialInfo::check(s, 1);
+ AbilityManager::AbilityInfo *info = LuaAbilityInfo::check(s, 1);
Script *script = getScript(s);
luaL_checktype(s, 2, LUA_TFUNCTION);
script->assignCallback(info->useCallback);
return 0;
}
-/** LUA specialinfo:on_recharged (specialinfo)
- * specialinfo:on_recharged(function callback)
+/** LUA abilityinfo:on_recharged (abilityinfo)
+ * abilityinfo:on_recharged(function callback)
**
* Assigns the ''callback'' as callback for the recharged event. This function
- * will be called everytime when the special is fully recharged.
+ * will be called everytime when the ability is fully recharged.
*
- * **Note:** See [[scripting#get_special_info|get_special_info]] for getting
- * a specialinfo object.
+ * **Note:** See [[scripting#get_ability_info|get_ability_info]] for getting
+ * a abilityinfo object.
*/
-static int specialinfo_on_recharged(lua_State *s)
+static int abilityinfo_on_recharged(lua_State *s)
{
- SpecialManager::SpecialInfo *info = LuaSpecialInfo::check(s, 1);
+ AbilityManager::AbilityInfo *info = LuaAbilityInfo::check(s, 1);
Script *script = getScript(s);
luaL_checktype(s, 2, LUA_TFUNCTION);
script->assignCallback(info->rechargedCallback);
return 0;
}
-/** LUA specialinfo:category (specialinfo)
- * specialinfo:category(function callback)
+/** LUA abilityinfo:category (abilityinfo)
+ * abilityinfo:category(function callback)
**
- * **Return value:** The set-name of the special as defined in the
- * [[specials.xml]]
+ * **Return value:** The set-name of the ability as defined in the
+ * [[abilities.xml]]
*
- * **Note:** See [[scripting#get_special_info|get_special_info]] for getting
- * a specialinfo object.
+ * **Note:** See [[scripting#get_ability_info|get_ability_info]] for getting
+ * a abilityinfo object.
*/
-static int specialinfo_get_category(lua_State *s)
+static int abilitiyinfo_get_category(lua_State *s)
{
- SpecialManager::SpecialInfo *info = LuaSpecialInfo::check(s, 1);
+ AbilityManager::AbilityInfo *info = LuaAbilityInfo::check(s, 1);
push(s, info->setName);
return 1;
}
@@ -3690,7 +3691,7 @@ LuaScript::LuaScript():
{ "get_distance", get_distance },
{ "map_get_objects", map_get_objects },
{ "announce", announce },
- { "get_special_info", get_special_info },
+ { "get_ability_info", get_ability_info },
{ nullptr, nullptr }
};
#if LUA_VERSION_NUM < 502
@@ -3737,10 +3738,10 @@ LuaScript::LuaScript():
{ "equip_item", entity_equip_item },
{ "unequip_slot", entity_unequip_slot },
{ "unequip_item", entity_unequip_item },
- { "set_special_recharge_speed", entity_set_special_recharge_speed },
- { "special_recharge_speed", entity_get_special_recharge_speed },
- { "set_special_mana", entity_set_special_mana },
- { "special_mana", entity_get_special_mana },
+ { "set_ability_recharge_speed", entity_set_ability_recharge_speed },
+ { "ability_recharge_speed", entity_get_ability_recharge_speed },
+ { "set_ability_mana", entity_set_ability_mana },
+ { "ability_mana", entity_get_ability_mana },
{ "walk", entity_walk },
{ "damage", entity_damage },
{ "heal", entity_heal },
@@ -3777,9 +3778,9 @@ LuaScript::LuaScript():
{ "register", entity_register },
{ "shake_screen", entity_shake_screen },
{ "show_text_particle", entity_show_text_particle },
- { "give_special", entity_give_special },
- { "has_special", entity_has_special },
- { "take_special", entity_take_special },
+ { "give_ability", entity_give_ability },
+ { "has_ability", entity_has_ability },
+ { "take_ability", entity_take_ability },
{ "monster_id", entity_get_monster_id },
{ "change_anger", entity_change_anger },
{ "drop_anger", entity_drop_anger },
@@ -3820,13 +3821,13 @@ LuaScript::LuaScript():
{ nullptr, nullptr }
};
- static luaL_Reg const members_SpecialInfo[] = {
- { "name", specialinfo_get_name },
- { "needed_mana", specialinfo_get_needed_mana },
- { "rechargeable", specialinfo_is_rechargeable },
- { "on_use", specialinfo_on_use },
- { "on_recharged", specialinfo_on_recharged },
- { "category", specialinfo_get_category },
+ static luaL_Reg const members_AbilityInfo[] = {
+ { "name", abilityinfo_get_name },
+ { "needed_mana", abilityinfo_get_needed_mana },
+ { "rechargeable", abilityinfo_is_rechargeable },
+ { "on_use", abilityinfo_on_use },
+ { "on_recharged", abilityinfo_on_recharged },
+ { "category", abilitiyinfo_get_category },
{ nullptr, nullptr}
};
@@ -3837,7 +3838,7 @@ LuaScript::LuaScript():
LuaMapObject::registerType(mRootState, "MapObject", members_MapObject);
LuaMonsterClass::registerType(mRootState, "MonsterClass", members_MonsterClass);
LuaStatusEffect::registerType(mRootState, "StatusEffect", members_StatusEffect);
- LuaSpecialInfo::registerType(mRootState, "SpecialInfo", members_SpecialInfo);
+ LuaAbilityInfo::registerType(mRootState, "AbilityInfo", members_AbilityInfo);
// Make script object available to callback functions.
lua_pushlightuserdata(mRootState, const_cast<char *>(&registryKey));
diff --git a/src/scripting/luautil.cpp b/src/scripting/luautil.cpp
index ea0e3dd..f21e489 100644
--- a/src/scripting/luautil.cpp
+++ b/src/scripting/luautil.cpp
@@ -223,13 +223,13 @@ int checkSkill(lua_State *s, int p)
return id;
}
-int checkSpecial(lua_State *s, int p)
+int checkAbility(lua_State *s, int p)
{
if (lua_isnumber(s, p))
return luaL_checkint(s, p);
- int id = specialManager->getId(luaL_checkstring(s, p));
- luaL_argcheck(s, id != 0, p, "invalid special name");
+ int id = abilityManager->getId(luaL_checkstring(s, p));
+ luaL_argcheck(s, id != 0, p, "invalid ability name");
return id;
}
diff --git a/src/scripting/luautil.h b/src/scripting/luautil.h
index f2b7689..2f3c15c 100644
--- a/src/scripting/luautil.h
+++ b/src/scripting/luautil.h
@@ -35,7 +35,7 @@ extern "C" {
#include <vector>
#include "game-server/attack.h"
-#include "game-server/specialmanager.h"
+#include "game-server/abilitymanager.h"
class CharacterComponent;
class Entity;
@@ -166,7 +166,7 @@ typedef LuaUserData<ItemClass> LuaItemClass;
typedef LuaUserData<MapObject> LuaMapObject;
typedef LuaUserData<MonsterClass> LuaMonsterClass;
typedef LuaUserData<StatusEffect> LuaStatusEffect;
-typedef LuaUserData<SpecialManager::SpecialInfo> LuaSpecialInfo;
+typedef LuaUserData<AbilityManager::AbilityInfo> LuaAbilityInfo;
Script * getScript(lua_State *s);
@@ -181,7 +181,7 @@ Entity * checkMonster(lua_State *s, int p);
MonsterClass * checkMonsterClass(lua_State *s, int p);
Entity * checkNpc(lua_State *s, int p);
int checkSkill(lua_State *s, int p);
-int checkSpecial(lua_State *s, int p);
+int checkAbility(lua_State *s, int p);
MapComposite * checkCurrentMap(lua_State *s, Script *script = 0);
Script::Thread* checkCurrentThread(lua_State *s, Script *script = 0);
diff --git a/src/scripting/scriptmanager.h b/src/scripting/scriptmanager.h
index 14b01b6..691acec 100644
--- a/src/scripting/scriptmanager.h
+++ b/src/scripting/scriptmanager.h
@@ -58,8 +58,8 @@ Script *currentState();
bool performCraft(Entity *crafter, const std::list<InventoryItem> &recipe);
void setCraftCallback(Script *script);
-void setSpecialCallback(Script *script);
-void setGetSpecialRechargeCostCallback(Script *script);
+void setAbilityCallback(Script *script);
+void setGetAbilityRechargeCostCallback(Script *script);
} // namespace ScriptManager
diff --git a/src/serialize/characterdata.h b/src/serialize/characterdata.h
index c25fb09..ada7e25 100644
--- a/src/serialize/characterdata.h
+++ b/src/serialize/characterdata.h
@@ -86,13 +86,14 @@ void serializeCharacterData(const T &data, MessageOut &msg)
msg.writeInt32(kills_it->second);
}
- // character specials
- SpecialMap::const_iterator special_it;
- msg.writeInt16(data.getSpecialSize());
- for (special_it = data.getSpecialBegin(); special_it != data.getSpecialEnd() ; special_it++)
+ // character abilities
+ AbilityMap::const_iterator abilitiy_it;
+ msg.writeInt16(data.getAbilitySize());
+ for (abilitiy_it = data.getAbilityBegin();
+ abilitiy_it != data.getAbilityEnd(); abilitiy_it++)
{
- msg.writeInt32(special_it->first);
- msg.writeInt32(special_it->second.currentMana);
+ msg.writeInt32(abilitiy_it->first);
+ msg.writeInt32(abilitiy_it->second.currentPoints);
}
// inventory - must be last because size isn't transmitted
@@ -177,14 +178,14 @@ void deserializeCharacterData(T &data, MessageIn &msg)
data.setKillCount(monsterId, kills);
}
- // character specials
- int specialSize = msg.readInt16();
- data.clearSpecials();
- for (int i = 0; i < specialSize; i++)
+ // character abilities
+ int abilitiesSize = msg.readInt16();
+ data.clearAbilities();
+ for (int i = 0; i < abilitiesSize; i++)
{
const int id = msg.readInt32();
const int mana = msg.readInt32();
- data.giveSpecial(id, mana);
+ data.giveAbility(id, mana);
}
diff --git a/src/sql/mysql/createTables.sql b/src/sql/mysql/createTables.sql
index c47cbd1..212d481 100644
--- a/src/sql/mysql/createTables.sql
+++ b/src/sql/mysql/createTables.sql
@@ -113,14 +113,14 @@ CREATE TABLE IF NOT EXISTS `mana_char_kill_stats`
) ENGINE=InnoDB
DEFAULT CHARSET=utf8;
--- Create table 'mana_char_specials'
+-- Create table 'mana_char_abilities'
-CREATE TABLE mana_char_specials
+CREATE TABLE mana_char_abilities
(
- `char_id` int(10) unsigned NOT NULL,
- `special_id` int(10) unsigned NOT NULL,
- `special_current_mana` int(10) unsigned NOT NULL,
- PRIMARY KEY (`char_id`, `special_id`),
+ `char_id` int(10) unsigned NOT NULL,
+ `ability_id` int(10) unsigned NOT NULL,
+ `ability_current_points` int(10) unsigned NOT NULL,
+ PRIMARY KEY (`char_id`, `ability_id`),
FOREIGN KEY (`char_id`)
REFERENCES `mana_characters` (`id`)
ON DELETE CASCADE
@@ -438,7 +438,7 @@ AUTO_INCREMENT=0 ;
INSERT INTO mana_world_states VALUES('accountserver_startup',-1,'0', NOW());
INSERT INTO mana_world_states VALUES('accountserver_version',-1,'0', NOW());
-INSERT INTO mana_world_states VALUES('database_version', -1,'21', NOW());
+INSERT INTO mana_world_states VALUES('database_version', -1,'22', NOW());
-- all known transaction codes
diff --git a/src/sql/mysql/updates/update_21_to_22.sql b/src/sql/mysql/updates/update_21_to_22.sql
new file mode 100644
index 0000000..88c6f8c
--- /dev/null
+++ b/src/sql/mysql/updates/update_21_to_22.sql
@@ -0,0 +1,26 @@
+START TRANSACTION;
+
+CREATE TABLE mana_char_abilities
+(
+ `char_id` int(10) unsigned NOT NULL,
+ `ability_id` int(10) unsigned NOT NULL,
+ `ability_current_points` int(10) unsigned NOT NULL,
+ PRIMARY KEY (`char_id`, `ability_id`),
+ FOREIGN KEY (`char_id`)
+ REFERENCES `mana_characters` (`id`)
+ ON DELETE CASCADE
+) ENGINE=InnoDB
+DEFAULT CHARSET=utf8;
+
+INSERT INTO mana_char_abilities (char_id, ability_id, ability_current_points)
+ SELECT char_id, special_id, special_current_mana FROM mana_char_specials;
+
+DROP TABLE mana_char_specials;
+
+-- Update database version.
+UPDATE mana_world_states
+ SET value = '22',
+ moddate = UNIX_TIMESTAMP()
+ WHERE state_name = 'database_version';
+
+COMMIT;
diff --git a/src/sql/sqlite/createTables.sql b/src/sql/sqlite/createTables.sql
index d845e84..aaf18ef 100644
--- a/src/sql/sqlite/createTables.sql
+++ b/src/sql/sqlite/createTables.sql
@@ -120,16 +120,16 @@ CREATE INDEX mana_char_kill_stats_char on mana_char_kill_stats ( char_id );
-----------------------------------------------------------------------------
-CREATE TABLE mana_char_specials
+CREATE TABLE mana_char_abilities
(
- char_id INTEGER NOT NULL,
- special_id INTEGER NOT NULL,
- special_current_mana INTEGER NOT NULL,
- PRIMARY KEY (char_id, special_id),
+ char_id INTEGER NOT NULL,
+ ability_id INTEGER NOT NULL,
+ ability_current_points INTEGER NOT NULL,
+ PRIMARY KEY (char_id, ability_id),
FOREIGN KEY (char_id) REFERENCES mana_characters(id)
);
-CREATE INDEX mana_char_specials_char on mana_char_specials ( char_id );
+CREATE INDEX mana_char_abilities_char on mana_char_abilities ( char_id );
-----------------------------------------------------------------------------
@@ -424,7 +424,7 @@ AS
INSERT INTO mana_world_states VALUES('accountserver_startup',-1,'0', strftime('%s','now'));
INSERT INTO mana_world_states VALUES('accountserver_version',-1,'0', strftime('%s','now'));
-INSERT INTO mana_world_states VALUES('database_version', -1,'21', strftime('%s','now'));
+INSERT INTO mana_world_states VALUES('database_version', -1,'22', strftime('%s','now'));
-- all known transaction codes
diff --git a/src/sql/sqlite/updates/update_21_to_22.sql b/src/sql/sqlite/updates/update_21_to_22.sql
new file mode 100644
index 0000000..dbe6cb0
--- /dev/null
+++ b/src/sql/sqlite/updates/update_21_to_22.sql
@@ -0,0 +1,26 @@
+BEGIN;
+
+CREATE TABLE mana_char_abilities
+(
+ char_id INTEGER NOT NULL,
+ ability_id INTEGER NOT NULL,
+ ability_current_points INTEGER NOT NULL,
+ PRIMARY KEY (char_id, ability_id),
+ FOREIGN KEY (char_id) REFERENCES mana_characters(id)
+);
+
+CREATE INDEX mana_char_abilities_char on mana_char_abilities ( char_id );
+
+INSERT INTO mana_char_abilities (char_id, ability_id, ability_current_points)
+ SELECT char_id, special_id, special_current_mana FROM mana_char_specials;
+
+DROP TABLE mana_char_specials;
+
+
+-- Update the database version, and set date of update
+UPDATE mana_world_states
+ SET value = '22',
+ moddate = strftime('%s','now')
+ WHERE state_name = 'database_version';
+
+END;