• 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+ [TFS 1.3] How can i get spellGroup?

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,210
Solutions
35
Reaction score
206
Hello, I am using tfs 1.3.
I am wondering how I can get spellGroup.
Code:
    <instant group="attack" spellid="62" name="Annihilation" words="exori gran ico" level="110" mana="300" premium="1" range="1" needtarget="1" needweapon="1" cooldown="30000" groupcooldown="4000" needlearn="0" script="attack/annihilation.lua">
        <vocation name="Knight" />
        <vocation name="Elite Knight" />
    </instant>

If i use spell.level returns "110".
If i use spell.words it return "exori gran ico"
But if i use spell.group it returns "false", how can i make to return "attack/suport/etc"?
 
Solution
spells.h find
Code:
void setManaPercent(uint32_t m) {
            manaPercent = m;
        }

add this below
Code:
std::string getGroupName() const {
            switch(group) {
                case SPELLGROUP_ATTACK: return "attack";
                case SPELLGROUP_HEALING: return "healing";
                case SPELLGROUP_SUPPORT: return "support";
                case SPELLGROUP_SPECIAL: return "special";
                default: return "none";
            }
        }

luascript.cpp find
Code:
lua_createtable(L, 0, 6);
    setField(L, "name", spell->getName());
    setField(L, "words", spell->getWords());
you have to change the number 6 to the 7

a little bit below you'll find this:
Code:
setField(L, "manapercent"...
spells.h find
Code:
void setManaPercent(uint32_t m) {
            manaPercent = m;
        }

add this below
Code:
std::string getGroupName() const {
            switch(group) {
                case SPELLGROUP_ATTACK: return "attack";
                case SPELLGROUP_HEALING: return "healing";
                case SPELLGROUP_SUPPORT: return "support";
                case SPELLGROUP_SPECIAL: return "special";
                default: return "none";
            }
        }

luascript.cpp find
Code:
lua_createtable(L, 0, 6);
    setField(L, "name", spell->getName());
    setField(L, "words", spell->getWords());
you have to change the number 6 to the 7

a little bit below you'll find this:
Code:
setField(L, "manapercent", spell->getManaPercent());
add this below:
Code:
setField(L, "group", spell->getGroupName());
 
Solution
~Sarah Wesker did it correctly, however, I don't see any benefit of returning this as a string unless you want to show it to the player (which i'd assume having a function for that instead of having the result as string in general.)

setField(L, "group", spell->getGroup()); would do the job.
 
You're absolutely right and I think just like you, but it was what he asked for in this thread, my English is rubbish and sometimes I find it hard to give them a detailed explanation and that's why I decided to do it the way he wanted
 
Back
Top