summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--example/abilities.xml11
-rw-r--r--example/attributes.xml6
-rw-r--r--example/monsters.xml5
-rw-r--r--example/scripts/abilities.lua7
-rw-r--r--example/scripts/attributes.lua66
-rw-r--r--example/scripts/damage.lua22
-rw-r--r--example/scripts/monster/basic_ai.lua22
-rw-r--r--example/scripts/monster/settings.lua10
-rw-r--r--src/account-server/accounthandler.cpp2
-rw-r--r--src/account-server/character.cpp2
-rw-r--r--src/account-server/character.h10
-rw-r--r--src/account-server/storage.cpp6
-rw-r--r--src/common/defines.h4
-rw-r--r--src/common/manaserv_protocol.h1
-rw-r--r--src/game-server/character.cpp23
-rw-r--r--src/game-server/character.h53
-rw-r--r--src/game-server/gamehandler.cpp4
-rw-r--r--src/scripting/lua.cpp66
-rw-r--r--src/serialize/characterdata.h4
19 files changed, 284 insertions, 40 deletions
diff --git a/example/abilities.xml b/example/abilities.xml
index 5b8a3806..27a4b65d 100644
--- a/example/abilities.xml
+++ b/example/abilities.xml
@@ -23,4 +23,15 @@
useaction="attack"
/>
</ability-category>
+ <ability-category name="debug">
+ <ability
+ id="3"
+ name="debug"
+ rechargeable="true"
+ needed="1"
+ rechargeattribute="20"
+ cooldownattribute="20"
+ target="point"
+ />
+ </ability-category>
</abilities>
diff --git a/example/attributes.xml b/example/attributes.xml
index fd91b066..09868892 100644
--- a/example/attributes.xml
+++ b/example/attributes.xml
@@ -190,4 +190,10 @@
modifiable="false"
scope="character"
minimum="0" />
+ <attribute id="23" name="Level"
+ desc="The level of this character."
+ modifiable="false"
+ scope="character"
+ minimum="0"
+ maximum="100" />
</attributes>
diff --git a/example/monsters.xml b/example/monsters.xml
index 53fd3382..46cd9b90 100644
--- a/example/monsters.xml
+++ b/example/monsters.xml
@@ -43,9 +43,10 @@ attributes <TAG>: Tells all the monsters attribute. These attribute, as for ite
size="4"
mutation="50"
/>
- <attribute id="HP" value="200" />
- <attribute id="Max HP" value="200" />
+ <attribute id="HP" value="20" />
+ <attribute id="Max HP" value="20" />
<attribute id="Movement speed" value="2" />
+ <ability id="2" />
<!-- average stroll- and track range-->
</monster>
diff --git a/example/scripts/abilities.lua b/example/scripts/abilities.lua
index 0dee2810..deed0c52 100644
--- a/example/scripts/abilities.lua
+++ b/example/scripts/abilities.lua
@@ -31,7 +31,14 @@ spell1:on_use(function(user, x, y, abilityId)
chance_to_hit = user:modified_attribute(ATTR_STR),
}
being:damage(user, damage)
+ being:say("OUCH")
end
end
end)
--spell1:on_recharged(function(ch) ch:say("Hoooooooo...") end)
+
+local debugspell = get_ability_info("debug_debug")
+debugspell:on_use(function(user)
+ WARN("USED")
+ user:give_experience(10)
+end)
diff --git a/example/scripts/attributes.lua b/example/scripts/attributes.lua
index 37d642d9..3e9b97e0 100644
--- a/example/scripts/attributes.lua
+++ b/example/scripts/attributes.lua
@@ -7,6 +7,9 @@
--]]
+local ATTR_EXP = 22
+local ATTR_LEVEL = 23
+
local function recalculate_base_attribute(being, attribute)
local old_base = being:base_attribute(attribute)
local new_base = old_base
@@ -49,6 +52,10 @@ local function recalculate_base_attribute(being, attribute)
elseif attribute == ATTR_ABILITY_COOLDOWN then
-- Provisional
new_base = 100 - being:modified_attribute(ATTR_WIL)
+ elseif attribute == ATTR_LEVEL then
+ -- Provisional
+ --new_base = 100 - 100 * math.pow(0.99999, being:base_attribute(ATTR_EXP))
+ new_base = being:base_attribute(ATTR_EXP) / 20
end
if new_base ~= old_base then
@@ -70,8 +77,67 @@ local function update_derived_attributes(being, attribute)
-- unimplemented
elseif attribute == ATTR_WIL then
recalculate_base_attribute(being, ATTR_ABILITY_COOLDOWN)
+ elseif attribute == ATTR_EXP then
+ recalculate_base_attribute(being, ATTR_LEVEL)
end
end
on_recalculate_base_attribute(recalculate_base_attribute)
on_update_derived_attribute(update_derived_attributes)
+
+function Entity:level()
+ return math.floor(self:base_attribute(ATTR_LEVEL))
+end
+
+function Entity:give_experience(experience)
+ local old_experience = self:base_attribute(ATTR_EXP)
+ local old_level = self:level()
+ self:set_base_attribute(ATTR_EXP, old_experience + experience)
+ if self:level() > old_level then
+ self:say("LEVELUP!!! " .. self:level())
+ self:set_attribute_points(self:attribute_points() + 1)
+ self:set_correction_points(self:correction_points() + 1)
+ end
+end
+
+local mobs_config = require "scripts/monster/settings"
+
+local exp_receiver = {}
+
+-- Give EXP for monster kills
+local function monster_damaged(mob, source, damage)
+
+ local receiver = exp_receiver[mob] or { chars = {}, total = 0 }
+ exp_receiver[mob] = receiver
+
+ if source and source:type() == TYPE_CHARACTER then
+ mob:change_anger(source, damage)
+
+ local current_damage = receiver.chars[source]
+ if not current_damage then
+ on_remove(source, function(removed_being)
+ receiver[removed_being] = nil
+ end)
+ on_death(source, function(removed_being)
+ receiver[removed_being] = nil
+ end)
+ end
+
+ current_damage = (current_damage or 0) + damage
+ receiver.chars[source] = current_damage
+ receiver.total = receiver.total + damage
+ end
+
+ if mob:base_attribute(ATTR_HP) == 0 then
+ local mob_config = mobs_config[mob:name()]
+ local experience = mob_config.experience or 0
+ for char, damage in pairs(receiver.chars) do
+ local gained_exp = damage / receiver.total * experience
+ char:give_experience(gained_exp)
+ end
+ end
+end
+
+for _, monsterclass in pairs(get_monster_classes()) do
+ monsterclass:on_damaged(monster_damaged)
+end
diff --git a/example/scripts/damage.lua b/example/scripts/damage.lua
index d031deee..8ad014f4 100644
--- a/example/scripts/damage.lua
+++ b/example/scripts/damage.lua
@@ -4,6 +4,11 @@
--]]
+local monster_class_damage_functions = {}
+
+function MonsterClass:on_damaged(func)
+ monster_class_damage_functions[self] = func
+end
-- damage is a table with these keys:
-- base, delta, chance_to_hit
@@ -11,20 +16,33 @@ function Entity:damage(source, damage)
local hp_loss = math.random(damage.base, damage.base + damage.delta)
local dodge = self:modified_attribute(ATTR_DODGE)
- if math.random(dodge) > math.random(damage.chance_to_hit) then
+ if dodge > 0 and math.random(dodge) > math.random(damage.chance_to_hit) or
+ damage.chance_to_hit == 0
+ then
hp_loss = 0 -- attack missed
+ self:say("HAHA MISSED")
else
local defense = self:modified_attribute(ATTR_DEFENSE)
local randomness = hp_loss > 16 and math.random(hp_loss / 16) or 0
hp_loss = hp_loss * (1 - (0.0159375 * defense) / (1 + 0.017 * defense))
+ randomness
+ self:say("UH NO")
end
if hp_loss > 0 then
- local hp = self:modified_attribute(ATTR_HP)
+ local hp = self:base_attribute(ATTR_HP)
hp_loss = math.min(hp, hp_loss)
self:add_hit_taken(hp_loss)
self:set_base_attribute(ATTR_HP, hp - hp_loss)
+ self:say("I GOT DAMAGED " .. hp - hp_loss)
+
+ if self:type() == TYPE_MONSTER then
+ local class = get_monster_class(self:monster_id())
+ local callback = monster_class_damage_functions[class]
+ if callback then
+ return callback(self, source, hp_loss)
+ end
+ end
else
hp_loss = 0
end
diff --git a/example/scripts/monster/basic_ai.lua b/example/scripts/monster/basic_ai.lua
index 17ffa74a..c75ca300 100644
--- a/example/scripts/monster/basic_ai.lua
+++ b/example/scripts/monster/basic_ai.lua
@@ -12,6 +12,24 @@ local TARGET_SEARCH_DELAY = 10
local mob_stati = {}
local angerlist = {}
+local function create_mob_status()
+ return {
+ angerlist = {},
+ }
+end
+
+function Entity:change_anger(target, amount)
+ local mob_status = mob_stati[self]
+ if not mob_status then
+ mob_status = create_mob_status()
+ mob_stati[self] = mob_status
+ end
+
+ local anger = mob_status.angerlist[target] or 0
+ mob_status.angerlist[target] = anger + amount
+ mob_stati[self].update_target_timer = 0 -- Enforce looking for new target
+end
+
local mob_config = require "scripts/monster/settings"
local function calculate_position_priority(x1, y1, x2, y2, anger, range)
@@ -43,7 +61,7 @@ local function update_attack_ai(mob, tick)
if being:type() == TYPE_CHARACTER
and being:action() ~= ACTION_DEAD
then
- local anger = angerlist[being] or 0
+ local anger = mob_status.angerlist[being] or 0
if anger == 0 and config.aggressive then
anger = 1
end
@@ -130,7 +148,7 @@ end
local function update(mob, tick)
local mob_status = mob_stati[mob]
if not mob_status then
- mob_status = {}
+ mob_status = create_mob_status()
mob_stati[mob] = mob_status
on_remove(mob, remove_mob)
end
diff --git a/example/scripts/monster/settings.lua b/example/scripts/monster/settings.lua
index f2b6741b..d89da569 100644
--- a/example/scripts/monster/settings.lua
+++ b/example/scripts/monster/settings.lua
@@ -4,12 +4,20 @@ return {
aggressive = false,
trackrange = 5 * TILESIZE,
attack_distance = TILESIZE,
+ experience = 10,
+ ability_id = 2,
+ damage = {
+ base = 0,
+ delta = 1,
+ chance_to_hit = 2,
+ },
},
["Scorpion"] = {
strollrange = 2 * TILESIZE,
aggressive = false,
trackrange = 5 * TILESIZE,
attack_distance = TILESIZE,
+ experience = 10,
},
["Red Scorpion"] = {
strollrange = TILESIZE,
@@ -17,6 +25,7 @@ return {
trackrange = 5 * TILESIZE,
attack_distance = TILESIZE,
ability_id = 2,
+ experience = 10,
damage = {
base = 2,
delta = 5,
@@ -28,5 +37,6 @@ return {
aggressive = true,
trackrange = 5 * TILESIZE,
attack_distance = TILESIZE,
+ experience = 10,
},
}
diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp
index 87cb2b46..9271c0ab 100644
--- a/src/account-server/accounthandler.cpp
+++ b/src/account-server/accounthandler.cpp
@@ -280,7 +280,7 @@ void AccountHandler::sendCharacterData(AccountClient &client,
charInfo.writeInt8(ch.getGender());
charInfo.writeInt8(ch.getHairStyle());
charInfo.writeInt8(ch.getHairColor());
- charInfo.writeInt16(ch.getCharacterPoints());
+ charInfo.writeInt16(ch.getAttributePoints());
charInfo.writeInt16(ch.getCorrectionPoints());
for (AttributeMap::const_iterator it = ch.mAttributes.begin(),
diff --git a/src/account-server/character.cpp b/src/account-server/character.cpp
index 3fc3ed19..9c371f54 100644
--- a/src/account-server/character.cpp
+++ b/src/account-server/character.cpp
@@ -32,7 +32,7 @@ CharacterData::CharacterData(const std::string &name, int id):
mGender(0),
mHairStyle(0),
mHairColor(0),
- mCharacterPoints(0),
+ mAttributePoints(0),
mCorrectionPoints(0),
mAccountLevel(0)
{
diff --git a/src/account-server/character.h b/src/account-server/character.h
index 58e32dad..1fa0e975 100644
--- a/src/account-server/character.h
+++ b/src/account-server/character.h
@@ -245,11 +245,11 @@ class CharacterData
Possessions &getPossessions()
{ return mPossessions; }
- void setCharacterPoints(int points)
- { mCharacterPoints = points; }
+ void setAttributePoints(int points)
+ { mAttributePoints = points; }
- int getCharacterPoints() const
- { return mCharacterPoints; }
+ int getAttributePoints() const
+ { return mAttributePoints; }
void setCorrectionPoints(int points)
{ mCorrectionPoints = points; }
@@ -283,7 +283,7 @@ class CharacterData
unsigned char mGender; //!< Gender of the being.
unsigned char mHairStyle; //!< Hair style of the being.
unsigned char mHairColor; //!< Hair color of the being.
- short mCharacterPoints; //!< Unused character points.
+ short mAttributePoints; //!< Unused character points.
short mCorrectionPoints; //!< Unused correction points.
unsigned char mAccountLevel; //!< Level of the associated account.
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp
index 2ddb2e08..c2af965b 100644
--- a/src/account-server/storage.cpp
+++ b/src/account-server/storage.cpp
@@ -362,7 +362,7 @@ CharacterData *Storage::getCharacterBySQL(Account *owner)
character->setGender(toUshort(charInfo(0, 3)));
character->setHairStyle(toUshort(charInfo(0, 4)));
character->setHairColor(toUshort(charInfo(0, 5)));
- character->setCharacterPoints(toUshort(charInfo(0, 6)));
+ character->setAttributePoints(toUshort(charInfo(0, 6)));
character->setCorrectionPoints(toUshort(charInfo(0, 7)));
Point pos(toInt(charInfo(0, 8)), toInt(charInfo(0, 9)));
character->setPosition(pos);
@@ -702,7 +702,7 @@ bool Storage::updateCharacter(CharacterData *character)
<< "gender = '" << character->getGender() << "', "
<< "hair_style = '" << character->getHairStyle() << "', "
<< "hair_color = '" << character->getHairColor() << "', "
- << "char_pts = '" << character->getCharacterPoints() << "', "
+ << "char_pts = '" << character->getAttributePoints() << "', "
<< "correct_pts = '"<< character->getCorrectionPoints() << "', "
<< "x = '" << character->getPosition().x << "', "
<< "y = '" << character->getPosition().y << "', "
@@ -990,7 +990,7 @@ void Storage::flush(Account *account)
<< character->getGender() << ", "
<< (int)character->getHairStyle() << ", "
<< (int)character->getHairColor() << ", "
- << (int)character->getCharacterPoints() << ", "
+ << (int)character->getAttributePoints() << ", "
<< (int)character->getCorrectionPoints() << ", "
<< character->getPosition().x << ", "
<< character->getPosition().y << ", "
diff --git a/src/common/defines.h b/src/common/defines.h
index 40be064e..86b97e25 100644
--- a/src/common/defines.h
+++ b/src/common/defines.h
@@ -219,7 +219,9 @@ enum
// Money and inventory size attributes.
ATTR_GP = 18,
- ATTR_INV_CAPACITY = 19
+ ATTR_INV_CAPACITY = 19,
+
+ ATTR_LEVEL = 23
};
#endif // DEFINES_H
diff --git a/src/common/manaserv_protocol.h b/src/common/manaserv_protocol.h
index 734ba1f2..d3f2c8b4 100644
--- a/src/common/manaserv_protocol.h
+++ b/src/common/manaserv_protocol.h
@@ -118,6 +118,7 @@ enum {
GPMSG_INVENTORY_FULL = 0x0121, // W inventory slot count { W slot, W itemId, W amount }, { W equip slot, W item Id, W item Instance}*
GPMSG_EQUIP = 0x0122, // W item Id, W equip slot type count //{ W equip slot, W capacity used}*//<- When equipping, //{ W item instance, W 0}*//<- When unequipping
GPMSG_PLAYER_ATTRIBUTE_CHANGE = 0x0130, // { W attribute, D base value (in 1/256ths), D modified value (in 1/256ths)}*
+ GPMSG_ATTRIBUTE_POINTS_STATUS = 0x0140, // W character points, W correction points
PGMSG_RAISE_ATTRIBUTE = 0x0160, // W attribute
GPMSG_RAISE_ATTRIBUTE_RESPONSE = 0x0161, // B error, W attribute
PGMSG_LOWER_ATTRIBUTE = 0x0170, // W attribute
diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp
index e4a30a2f..a593b58b 100644
--- a/src/game-server/character.cpp
+++ b/src/game-server/character.cpp
@@ -69,6 +69,9 @@ CharacterComponent::CharacterComponent(Entity &entity, MessageIn &msg):
mDatabaseID(-1),
mHairStyle(0),
mHairColor(0),
+ mSendAttributePointsStatus(false),
+ mAttributePoints(0),
+ mCorrectionPoints(0),
mSendAbilityCooldown(false),
mParty(0),
mTransaction(TRANS_NONE),
@@ -131,6 +134,9 @@ void CharacterComponent::update(Entity &entity)
if (mSendAbilityCooldown)
sendAbilityCooldownUpdate(entity);
+
+ if (mSendAttributePointsStatus)
+ sendAttributePointsStatus(entity);
}
void CharacterComponent::characterDied(Entity *being)
@@ -213,6 +219,15 @@ void CharacterComponent::sendAbilityCooldownUpdate(Entity &entity)
mSendAbilityCooldown = false;
}
+void CharacterComponent::sendAttributePointsStatus(Entity &entity)
+{
+ MessageOut msg(GPMSG_ATTRIBUTE_POINTS_STATUS);
+ msg.writeInt16(mAttributePoints);
+ msg.writeInt16(mCorrectionPoints);
+ gameHandler->sendTo(mClient, msg);
+ mSendAttributePointsStatus = false;
+}
+
void CharacterComponent::cancelTransaction()
{
TransactionType t = mTransaction;
@@ -341,10 +356,10 @@ AttribmodResponseCode CharacterComponent::useCharacterPoint(Entity &entity,
if (!attributeManager->isAttributeDirectlyModifiable(attribute))
return ATTRIBMOD_INVALID_ATTRIBUTE;
- if (!mCharacterPoints)
+ if (!mAttributePoints)
return ATTRIBMOD_NO_POINTS_LEFT;
- --mCharacterPoints;
+ setAttributePoints(mAttributePoints - 1);
const double base = beingComponent->getAttributeBase(attribute);
beingComponent->setAttribute(entity, attribute, base + 1);
@@ -364,8 +379,8 @@ AttribmodResponseCode CharacterComponent::useCorrectionPoint(Entity &entity,
if (beingComponent->getAttributeBase(attribute) <= 1)
return ATTRIBMOD_DENIED;
- --mCorrectionPoints;
- ++mCharacterPoints;
+ setCorrectionPoints(mCorrectionPoints - 1);
+ setAttributePoints(mAttributePoints + 1);
const double base = beingComponent->getAttributeBase(attribute);
beingComponent->setAttribute(entity, attribute, base - 1);
diff --git a/src/game-server/character.h b/src/game-server/character.h
index 162235ad..834f9fe3 100644
--- a/src/game-server/character.h
+++ b/src/game-server/character.h
@@ -64,8 +64,8 @@ public:
void setAttribute(int id, int base);
void setModAttribute(int id, int mod);
const AttributeMap &getAttributes() const;
- void setCharacterPoints(int characterPoints);
- int getCharacterPoints() const;
+ void setAttributePoints(int characterPoints);
+ int getAttributePoints() const;
void setCorrectionPoints(int correctionPoints);
int getCorrectionPoints() const;
@@ -285,11 +285,11 @@ class CharacterComponent : public Component
AttribmodResponseCode useCorrectionPoint(Entity &entity,
int attribute);
- void setCharacterPoints(int points) { mCharacterPoints = points; }
- int getCharacterPoints() const { return mCharacterPoints; }
+ void setAttributePoints(int points);
+ int getAttributePoints() const;
- void setCorrectionPoints(int points) { mCorrectionPoints = points; }
- int getCorrectionPoints() const { return mCorrectionPoints; }
+ void setCorrectionPoints(int points);
+ int getCorrectionPoints() const;
/**
@@ -350,12 +350,9 @@ class CharacterComponent : public Component
void abilityStatusChanged(int id);
void abilityCooldownActivated();
- /**
- * Informs the client about his characters abilities charge status
- */
void sendAbilityUpdate(Entity &entity);
-
void sendAbilityCooldownUpdate(Entity &entity);
+ void sendAttributePointsStatus(Entity &entity);
enum TransactionType
{ TRANS_NONE, TRANS_TRADE, TRANS_BUYSELL };
@@ -381,8 +378,11 @@ class CharacterComponent : public Component
int mDatabaseID; /**< Character's database ID. */
unsigned char mHairStyle; /**< Hair Style of the character. */
unsigned char mHairColor; /**< Hair Color of the character. */
- int mCharacterPoints; /**< Unused attribute points that can be distributed */
+
+ bool mSendAttributePointsStatus;
+ int mAttributePoints; /**< Unused attribute points that can be distributed */
int mCorrectionPoints; /**< Unused attribute correction points */
+
bool mSendAbilityCooldown;
unsigned char mAccountLevel; /**< Account level of the user. */
int mParty; /**< Party id of the character */
@@ -459,14 +459,14 @@ inline const AttributeMap &CharacterData::getAttributes() const
return mEntity->getComponent<BeingComponent>()->getAttributes();
}
-inline void CharacterData::setCharacterPoints(int characterPoints)
+inline void CharacterData::setAttributePoints(int characterPoints)
{
- mCharacterComponent->setCharacterPoints(characterPoints);
+ mCharacterComponent->setAttributePoints(characterPoints);
}
-inline int CharacterData::getCharacterPoints() const
+inline int CharacterData::getAttributePoints() const
{
- return mCharacterComponent->getCharacterPoints();
+ return mCharacterComponent->getAttributePoints();
}
inline void CharacterData::setCorrectionPoints(int correctionPoints)
@@ -579,4 +579,27 @@ inline Possessions &CharacterData::getPossessions() const
return mCharacterComponent->getPossessions();
}
+
+inline void CharacterComponent::setAttributePoints(int points)
+{
+ mSendAttributePointsStatus = true;
+ mAttributePoints = points;
+}
+
+inline int CharacterComponent::getAttributePoints() const
+{
+ return mAttributePoints;
+}
+
+inline void CharacterComponent::setCorrectionPoints(int points)
+{
+ mSendAttributePointsStatus = true;
+ mCorrectionPoints = points;
+}
+
+inline int CharacterComponent::getCorrectionPoints() const
+{
+ return mCorrectionPoints;
+}
+
#endif // CHARACTER_H
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index e9890c66..c7ff655a 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -890,7 +890,7 @@ void GameHandler::handleRaiseAttribute(GameClient &client, MessageIn &message)
{
accountHandler->updateCharacterPoints(
characterComponent->getDatabaseID(),
- characterComponent->getCharacterPoints(),
+ characterComponent->getAttributePoints(),
characterComponent->getCorrectionPoints());
// log transaction
@@ -920,7 +920,7 @@ void GameHandler::handleLowerAttribute(GameClient &client, MessageIn &message)
{
accountHandler->updateCharacterPoints(
characterComponent->getDatabaseID(),
- characterComponent->getCharacterPoints(),
+ characterComponent->getAttributePoints(),
characterComponent->getCorrectionPoints());
// log transaction
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 624fbda1..13373d81 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -1838,6 +1838,68 @@ static int entity_remove_attribute_modifier(lua_State *s)
return 0;
}
+/** LUA entity:attribute_points (being)
+ * entity:attribute_points()
+ **
+ * Valid only for character entities.
+ *
+ * *Returns:* Returns the amount of available attribute points.
+ */
+static int entity_attribute_points(lua_State *s)
+{
+ Entity *being = checkCharacter(s, 1);
+ auto *characterComponent = being->getComponent<CharacterComponent>();
+ lua_pushinteger(s, characterComponent->getAttributePoints());
+ return 1;
+}
+
+/** LUA entity:set_attribute_points (being)
+ * entity:set_attribute_points(int amount)
+ **
+ * Valid only for character entities.
+ *
+ * Sets the amount of attribute points for the entity
+ */
+static int entity_set_attribute_points(lua_State *s)
+{
+ Entity *being = checkCharacter(s, 1);
+ int points = luaL_checkint(s, 2);
+ auto *characterComponent = being->getComponent<CharacterComponent>();
+ characterComponent->setAttributePoints(points);
+ return 0;
+}
+
+/** LUA entity:correction_points (being)
+ * entity:correction_points()
+ **
+ * Valid only for character entities.
+ *
+ * *Returns:* Returns the amount of available correction points.
+ */
+static int entity_correction_points(lua_State *s)
+{
+ Entity *being = checkCharacter(s, 1);
+ auto *characterComponent = being->getComponent<CharacterComponent>();
+ lua_pushinteger(s, characterComponent->getCorrectionPoints());
+ return 1;
+}
+
+/** LUA entity:set_correction_points (being)
+ * entity:set_correction_points(int amount)
+ **
+ * Valid only for character entities.
+ *
+ * Sets the amount of correction points for the entity
+ */
+static int entity_set_correction_points(lua_State *s)
+{
+ Entity *being = checkCharacter(s, 1);
+ int points = luaL_checkint(s, 2);
+ auto *characterComponent = being->getComponent<CharacterComponent>();
+ characterComponent->setCorrectionPoints(points);
+ return 0;
+}
+
/** LUA entity:gender (being)
* entity:gender()
**
@@ -3350,6 +3412,10 @@ LuaScript::LuaScript():
{ "modified_attribute", entity_get_modified_attribute },
{ "apply_attribute_modifier", entity_apply_attribute_modifier },
{ "remove_attribute_modifier", entity_remove_attribute_modifier },
+ { "attribute_points", entity_attribute_points },
+ { "set_attribute_points", entity_set_attribute_points },
+ { "correction_points", entity_correction_points },
+ { "set_correction_points", entity_set_correction_points },
{ "gender", entity_get_gender },
{ "set_gender", entity_set_gender },
{ "hair_color", entity_get_hair_color },
diff --git a/src/serialize/characterdata.h b/src/serialize/characterdata.h
index a8554684..2e4620dc 100644
--- a/src/serialize/characterdata.h
+++ b/src/serialize/characterdata.h
@@ -38,7 +38,7 @@ void serializeCharacterData(const T &data, MessageOut &msg)
msg.writeInt8(data.getGender());
msg.writeInt8(data.getHairStyle());
msg.writeInt8(data.getHairColor());
- msg.writeInt16(data.getCharacterPoints());
+ msg.writeInt16(data.getAttributePoints());
msg.writeInt16(data.getCorrectionPoints());
@@ -115,7 +115,7 @@ void deserializeCharacterData(T &data, MessageIn &msg)
data.setGender(ManaServ::getGender(msg.readInt8()));
data.setHairStyle(msg.readInt8());
data.setHairColor(msg.readInt8());
- data.setCharacterPoints(msg.readInt16());
+ data.setAttributePoints(msg.readInt16());
data.setCorrectionPoints(msg.readInt16());
// character attributes