• 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!

C++ Chance to automatically cast a spell on every base attack based on vocation

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,521
Solutions
27
Reaction score
870
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi guys! I have a little idea and I need to know if it is possible to automatically cast a random spell on every base attack, with a % of happening. And if it is possible too, that this is strictly related to player's vocation. I use TFS 1.5 downgrades 8.6.

The idea is the following:
If my vocation is dragon lord, all my basic attacks will be have a chance to throw a fire bomb or a great fire ball spell, or with a lower chance the big wave they do (fire wave Dragon Lord (https://tibia.fandom.com/wiki/Dragon_Lord)). If my vocation is giant spider for example, my basic attacks could have a % of chance to cast haste, or utito tempo, and so on.

The idea of all this is to avoid the usage of spells in game, specifically, avoid the usage of any hotkey or use of runes / tools for a personal purpose I wan't to work with OTU and it has too many bugs with this interactions to solve them. The script parameters should be written in order to easily customize the script by using tables, such as vocation as main parameter, and spells with % of chance inside the tables.

Hope someone can help me with this,
Thanks in advance!
 
Last edited:
C++:
int LuaScriptInterface::luaPlayerCastSpell(lua_State* L)
{
    // player:castSpell(spell, param)
    Player* player = getUserdata<Player>(L, 1);
    InstantSpell* spell = getInstantSpell(L, 2);
    std::string param = getString(L, 3);
    if (player && spell) {
        pushBoolean(L, spell->playerCastInstant(player, param));
    } else {
        lua_pushnil(L);
    }
    return 1;
}
I would just hook a function that reading "onAttack" func from c++ and write whole system in lua (for better and flexible config)

(this is a good base for a begin this system i think :D)
 
Back
Top