Permalink
Browse files

Made the elemental and status effects loaded in equipment, and displa…

…yed in the shop mode.

I also renamed the sockets -> shard slots, removed the lore aka long description
which is not used and won't likely be.

I also turned the elemental and status effect std::map into vector
to speed up the display time a bit.

I then added the Paladin Sword in the debug shop to show
the elements and status effects there.
  • Loading branch information...
1 parent d62a02c commit 8756b802329aa7d69ad9942b9988ae2b6174e255 Yohann Ferreira committed Oct 5, 2012
View
@@ -22,6 +22,7 @@ function BootShopTest()
shop:AddObject(10001, 2);
shop:AddObject(10002, 4);
shop:AddObject(10003, 12);
+ shop:AddObject(10004, 1);
shop:AddObject(11001, 5);
shop:AddObject(20002, 1);
shop:AddObject(20003, 2);
View
@@ -80,6 +80,26 @@ weapons[10003] = {
slots = 1
}
+weapons[10004] = {
+ name = hoa_system.Translate("Paladin's Sword"),
+ description = hoa_system.Translate("A mythical weapon blessed with a magical fire."),
+ icon = "img/icons/weapons/paladin-sword.png",
+ physical_attack = 90,
+ metaphysical_attack = 30,
+ standard_price = 30800,
+ usable_by = BRONANN + THANIS,
+ slots = 3,
+
+ elemental_effects = {
+ [hoa_global.GameGlobal.GLOBAL_ELEMENTAL_FIRE] = hoa_global.GameGlobal.GLOBAL_INTENSITY_POS_LESSER
+ },
+
+ status_effects = {
+ [hoa_global.GameGlobal.GLOBAL_STATUS_PROTECTION_RAISE] = hoa_global.GameGlobal.GLOBAL_INTENSITY_POS_LESSER,
+ [hoa_global.GameGlobal.GLOBAL_STATUS_VIGOR_RAISE] = hoa_global.GameGlobal.GLOBAL_INTENSITY_POS_LESSER
+ }
+}
+
-- -----------------------------------------------------------------------------
-- IDs 11,001 - 11,500 are reserved for arbalests
-- -----------------------------------------------------------------------------
@@ -69,18 +69,18 @@ class GlobalElementalEffect {
_type(type), _intensity(intensity) {}
~GlobalElementalEffect()
- {}
+ {}
//! \brief Class Member Access Functions
//@{
GLOBAL_ELEMENTAL GetType() const
- { return _type; }
+ { return _type; }
GLOBAL_INTENSITY GetIntensity() const
- { return _intensity; }
+ { return _intensity; }
void SetIntensity(GLOBAL_INTENSITY intensity)
- { _intensity = intensity; }
+ { _intensity = intensity; }
//@}
/** \brief Increments the elemental effect's intensity
@@ -122,18 +122,18 @@ class GlobalStatusEffect {
_type(type), _intensity(intensity) {}
virtual ~GlobalStatusEffect()
- {}
+ {}
//! \brief Class Member Access Functions
//@{
GLOBAL_STATUS GetType() const
- { return _type; }
+ { return _type; }
GLOBAL_INTENSITY GetIntensity() const
- { return _intensity; }
+ { return _intensity; }
virtual void SetIntensity(GLOBAL_INTENSITY intensity)
- { _intensity = intensity; }
+ { _intensity = intensity; }
//@}
/** \brief Increments the status effect intensity by a positive amount
@@ -41,6 +41,63 @@ void GlobalObject::_LoadObjectData(hoa_script::ReadScriptDescriptor& script) {
}
}
+void GlobalObject::_LoadElementalEffects(hoa_script::ReadScriptDescriptor& script) {
+ if (!script.DoesTableExist("elemental_effects"))
+ return;
+
+ std::vector<int32> elemental_effects;
+ script.ReadTableKeys("elemental_effects", elemental_effects);
+
+ if (elemental_effects.empty())
+ return;
+
+ script.OpenTable("elemental_effects");
+
+ for (uint32 i = 0; i < elemental_effects.size(); ++i) {
+
+ int32 key = elemental_effects[i];
+ if (key <= GLOBAL_ELEMENTAL_INVALID || key >= GLOBAL_ELEMENTAL_TOTAL)
+ continue;
+
+ int32 intensity = script.ReadInt(key);
+ if (intensity <= GLOBAL_INTENSITY_INVALID || intensity >= GLOBAL_INTENSITY_TOTAL)
+ continue;
+
+ _elemental_effects.push_back(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>((GLOBAL_ELEMENTAL)key, (GLOBAL_INTENSITY)intensity));
+ }
+
+ script.CloseTable(); // elemental_effects
+}
+
+void GlobalObject::_LoadStatusEffects(hoa_script::ReadScriptDescriptor& script) {
+ if (!script.DoesTableExist("status_effects"))
+ return;
+
+ std::vector<int32> status_effects;
+ script.ReadTableKeys("status_effects", status_effects);
+
+ if (status_effects.empty())
+ return;
+
+ script.OpenTable("status_effects");
+
+ for (uint32 i = 0; i < status_effects.size(); ++i) {
+
+ int32 key = status_effects[i];
+ if (key <= GLOBAL_STATUS_INVALID || key >= GLOBAL_STATUS_TOTAL)
+ continue;
+
+ int32 intensity = script.ReadInt(key);
+ // Note: The intensity of a status effect can only be positive
+ if (intensity < GLOBAL_INTENSITY_NEUTRAL || intensity >= GLOBAL_INTENSITY_TOTAL)
+ continue;
+
+ _status_effects.push_back(std::pair<GLOBAL_STATUS, GLOBAL_INTENSITY>((GLOBAL_STATUS)key, (GLOBAL_INTENSITY)intensity));
+ }
+
+ script.CloseTable(); // status_effects
+}
+
////////////////////////////////////////////////////////////////////////////////
// GlobalItem class
////////////////////////////////////////////////////////////////////////////////
@@ -122,16 +179,6 @@ GlobalItem& GlobalItem::operator=(const GlobalItem& copy) {
GlobalWeapon::GlobalWeapon(uint32 id, uint32 count) :
GlobalObject(id, count)
{
- // Initialize all elemental effects as neutral
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_FIRE, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_WATER, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_VOLT, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_EARTH, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_SLICING, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_SMASHING, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_MAULING, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_PIERCING, GLOBAL_INTENSITY_NEUTRAL));
-
if ((_id <= MAX_ITEM_ID) || (_id > MAX_WEAPON_ID)) {
IF_PRINT_WARNING(GLOBAL_DEBUG) << "invalid id in constructor: " << _id << std::endl;
_InvalidateObject();
@@ -149,10 +196,17 @@ GlobalWeapon::GlobalWeapon(uint32 id, uint32 count) :
script_file.OpenTable(_id);
_LoadObjectData(script_file);
+ _LoadElementalEffects(script_file);
+ _LoadStatusEffects(script_file);
+
_physical_attack = script_file.ReadUInt("physical_attack");
_metaphysical_attack = script_file.ReadUInt("metaphysical_attack");
_usable_by = script_file.ReadUInt("usable_by");
+ uint32 shards_number = script_file.ReadUInt("slots");
+ _shard_slots.resize(shards_number, NULL);
+ // TODO: Load equipped shards data
+
// Load the possible battle ammo animated image filename.
_ammo_image_file = script_file.ReadString("battle_ammo_animation_file");
@@ -173,16 +227,6 @@ GlobalWeapon::GlobalWeapon(uint32 id, uint32 count) :
GlobalArmor::GlobalArmor(uint32 id, uint32 count) :
GlobalObject(id, count)
{
- // Initialize all elemental effects as neutral
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_FIRE, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_WATER, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_VOLT, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_EARTH, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_SLICING, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_SMASHING, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_MAULING, GLOBAL_INTENSITY_NEUTRAL));
- _elemental_effects.insert(std::pair<GLOBAL_ELEMENTAL, GLOBAL_INTENSITY>(GLOBAL_ELEMENTAL_PIERCING, GLOBAL_INTENSITY_NEUTRAL));
-
if ((_id <= MAX_WEAPON_ID) || (_id > MAX_LEG_ARMOR_ID)) {
IF_PRINT_WARNING(GLOBAL_DEBUG) << "invalid id in constructor: " << _id << std::endl;
_InvalidateObject();
@@ -220,10 +264,17 @@ GlobalArmor::GlobalArmor(uint32 id, uint32 count) :
script_file->OpenTable(_id);
_LoadObjectData(*script_file);
+ _LoadElementalEffects(*script_file);
+ _LoadStatusEffects(*script_file);
+
_physical_defense = script_file->ReadUInt("physical_defense");
_metaphysical_defense = script_file->ReadUInt("metaphysical_defense");
_usable_by = script_file->ReadUInt("usable_by");
+ uint32 shards_number = script_file->ReadUInt("slots");
+ _shard_slots.resize(shards_number, NULL);
+ // TODO: Load equipped shards data
+
script_file->CloseTable();
if (script_file->IsErrorDetected()) {
if (GLOBAL_DEBUG) {
Oops, something went wrong.

0 comments on commit 8756b80

Please sign in to comment.