• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ Spells and Movements vocation id instead of name

Paulix

Active Member
Joined
Sep 13, 2012
Messages
129
Solutions
7
Reaction score
26
I'm actually using tfs 1.5 downgraded to 8.6, but in movements, spells and weapons, it is using
Lua:
<vocation name="vocation"/>
instead of
Code:
<vocation id="2"/>
like it was used on tfs 0.4.
Is it possible to change it in sources to use ID instead of name? couldn't find anything, can someone help?
 
I'm actually using tfs 1.5 downgraded to 8.6, but in movements, spells and weapons, it is using
Lua:
<vocation name="vocation"/>
instead of
Code:
<vocation id="2"/>
like it was used on tfs 0.4.
Is it possible to change it in sources to use ID instead of name? couldn't find anything, can someone help?

It appears to accept both already, at least for movements from what I gather from this line


Have you actually tried to change it just to see?
 
I've tried only on spells tbh, and it didn't work i've made some adjustments, but now it is now showing properly weapon descriptions
spells.cpp
C++:
int32_t vocationId = g_vocations.getVocationId(attr.as_string());
to
C++:
int32_t vocationId = attr.as_int();

weapons.cpp
C++:
int32_t vocationId = g_vocations.getVocationId(attr.as_string());
to
C++:
int32_t vocationId = attr.as_int();

and
movement.cpp
C++:
int32_t vocationId = g_vocations.getVocationId(vocationNameAttribute.as_string());
to
C++:
int32_t vocationId = vocationNameAttribute.as_int();

It is working properly, but something is breaking on item.cpp on function Item::getDescription, and this is how the item description is showing in game:
1648212662343.png

Can someone help to convert vocations ids to name on item description?
 
So for vacation requirements on items like the wand of inferno, it should actually be the movements.xml file or the revscript movement that would determine this, its an extra parameter in the movements.xml like this showInDescription="1", in the same node as the vocation, so for me it looks like this

<vocation name="Elder Druid" showInDescription="1" />

but since you made the source edits should be something like this for you

<vocation id="8" showInDescription="1" />

So just to reiterate, its not the items.xml where this description on the items for vocations requirements occur.

Alternatively, if for some reason you were able to get everything else working the way you want but the description still isn't working, you can write an onLook event to handle the item, or make items table and store the items and descriptions in the table and still utilizing onLook, enforce it in the description that way.
 
If anyone wants, here is how I solved the problem...

spells.cpp
C++:
for (auto vocationNode : node.children()) {
        if (!(attr = vocationNode.attribute("name"))) {
            continue;
        }

        int32_t vocationId = g_vocations.getVocationId(attr.as_string());
        if (vocationId != -1) {
            attr = vocationNode.attribute("showInDescription");
            vocSpellMap[vocationId] = !attr || attr.as_bool();
        } else {
            std::cout << "[Warning - Spell::configureSpell] Wrong vocation name: " << attr.as_string() << std::endl;
        }
    }
change for
C++:
for (auto vocationNode : node.children()) {
        if (!(attr = vocationNode.attribute("id"))) {
            continue;
        }

        int32_t vocationId = attr.as_int();
        if (vocationId != -1) {
            attr = vocationNode.attribute("showInDescription");
            vocSpellMap[vocationId] = !attr || attr.as_bool();
        } else {
            std::cout << "[Warning - Spell::configureSpell] Wrong vocation name: " << attr.as_string() << std::endl;
        }
    }

weapons.cpp
C++:
for (auto vocationNode : node.children()) {
        if (!(attr = vocationNode.attribute("name"))) {
            continue;
        }

        int32_t vocationId = g_vocations.getVocationId(attr.as_string());
        if (vocationId != -1) {
            vocWeaponMap[vocationId] = true;
            int32_t promotedVocation = g_vocations.getPromotedVocation(vocationId);
            if (promotedVocation != VOCATION_NONE) {
                vocWeaponMap[promotedVocation] = true;
            }

            if (vocationNode.attribute("showInDescription").as_bool(true)) {
                vocStringList.push_back(asLowerCaseString(attr.as_string()));
            }
        }
    }
change for
C++:
for (auto vocationNode : node.children()) {
        if (!(attr = vocationNode.attribute("id"))) {
            continue;
        }

        int32_t vocationId = attr.as_int();
        if (vocationId != -1) {
            vocWeaponMap[vocationId] = true;
            int32_t promotedVocation = g_vocations.getPromotedVocation(vocationId);
            if (promotedVocation != VOCATION_NONE) {
                vocWeaponMap[promotedVocation] = true;
            }

            if (vocationNode.attribute("showInDescription").as_bool(true)) {
        Vocation* voc = g_vocations.getVocation(vocationId);
        vocStringList.push_back(asLowerCaseString(voc->getVocName()));
            }
        }
    }

movement.cpp
C++:
std::list<std::string> vocStringList;
        for (auto vocationNode : node.children()) {
            pugi::xml_attribute vocationNameAttribute = vocationNode.attribute("name");
            if (!vocationNameAttribute) {
                continue;
            }

            int32_t vocationId = g_vocations.getVocationId(vocationNameAttribute.as_string());
            if (vocationId != -1) {
                vocEquipMap[vocationId] = true;
                if (vocationNode.attribute("showInDescription").as_bool(true)) {
                    vocStringList.push_back(asLowerCaseString(vocationNameAttribute.as_string()));
                }
            }
        }
change for
C++:
for (auto vocationNode : node.children()) {
            pugi::xml_attribute vocationNameAttribute = vocationNode.attribute("id");
            if (!vocationNameAttribute) {
                continue;
            }

      int32_t vocationId = vocationNameAttribute.as_int();
            if (vocationId != -1) {
                vocEquipMap[vocationId] = true;
                if (vocationNode.attribute("showInDescription").as_bool(true)) {
          Vocation* voc = g_vocations.getVocation(vocationId);
          vocStringList.push_back(asLowerCaseString(voc->getVocName()));
                }
            }
        }

now you need to replace on weapons.xml, movements.xml and spells.xml
XML:
<vocation name="Sorcerer"/>
for
XML:
<vocation id="1"/>

it works perfectly in game with my custom vocation names...

1648272916600.png

1648272795990.png
 
Back
Top