• 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++ Help with my c++ function creature:doCreatureCastSpell() TFS 1.2

bizao030188

Member
Joined
Jun 4, 2012
Messages
50
Solutions
2
Reaction score
7
Hi friends!
I am working in a function that makes monsters cast spells in lua environment.

The current version (below) is working but I cannot control the damage that it deals. I am trying to do as normal monsters does (use min and max values to calculate the damage) but I was not able.

C++:
int LuaScriptInterface::luaDoCreatureCastSpell(lua_State* L) 
{
    //doCreatureCastSpell(cid, spellname)
    Creature* creature = getCreature(L, 1);
    std::string spellName = getString(L, 2);
    if(creature){
        InstantSpell* spell = g_spells->getInstantSpellByName(spellName);
        if(!spell){
            lua_pushboolean(L, false);
            return 1;
        }
        Creature* target = creature->getAttackedCreature();
        if(target){
            spell->castSpell(creature, target);
        } else {
            spell->castSpell(creature, creature);
        }
        lua_pushboolean(L, true);
    } else {
        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        lua_pushboolean(L, false);
    }
    return 1;
}

I appreciate any kind of help!
 
Back
Top