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

Lua OnEquip Exiva Tfs 0.3.6

calidacs

Member
Joined
Feb 19, 2013
Messages
49
Reaction score
8
Hello, could someone help me and make for me spell Exiva which will work only if ill have equipped XXXX item? Thanks

Tfs 0.3.6
 
Do you know how to edit the source? Since the find person function is not made in LUA, rather in the source code, it's inevitable to modify it from there.

Here are some pointers if you have any experience:
spells.cpp -> :1292 [SearchPlayer]
Further down you can see validation processes at :1325-:1334
You can add your own if-statement here

Further more, you can do this iteration-process to check all the items equipped by the player:
Code:
bool foundItem = false;
for (int32_t slotId = 1; slotId <= 10; ++slotId) {
    Item* item = player->inventory[slotId];
    if (item) {
        if (item->getId() == 2014) {
            foundItem = true;
        }
    }
}

if (!foundItem) {
    return false;
}

This little piece of code should hopefully iterate through the player's item slots, checking if any of the items has the id of 2014, if the item was not found, it simply cancels the process. Then you can add error messages, etc. Let me know how it works out.

There might be variation in the sources, depending on version, but the function names should be the same.

Ignazio
 
i dont really want to edit SearchPerson, main code because i want to have 2 kinds of this spell, first one is the normal exiva, and another is the one that need an equpped item to work
 
Last edited:
ok i found a way how to do it, but still need some help with it i added a new bool to spells called needitem something like needweapon almost the same, but now i need some help with change needweapon code to getplayeritemid if its even possible heres the code, maybe someone will be able to help me with it
Code:
    if(needitem)
    {
        switch(player->getWeaponType())
        {
            case WEAPON_SWORD:
            case WEAPON_CLUB:
            case WEAPON_AXE:
            case WEAPON_FIST:
                break;

            default:
            {
                player->sendCancelMessage(RET_YOUNEEDTOEQUIPitem);
                g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
                return false;
            }
        }
    }
 
Back
Top