Olá, hoje eu vim postar a função
creature:soltaMagia("nomedamagia")
Para o TFS 1.X.
Bom, eu estou fazendo um Poketibia com base no TFS 1.3 e vou postar essa função para quem quiser seguir o mesmo.
Segue um exemplo de uso:
function onSay(player, words, param)
poke = player:getSummons()[1]
poke:soltaMagia(pokes[poke:getName()][1].name)
player:say(poke:getName().."use "..pokes[poke:getName()][1].name, TALKTYPE_ORANGE_1)
end
Em LUASCRIPT.CPP
Abaixo de
registerMethod("Player", "addExperience", LuaScriptInterface::luaPlayerAddExperience);
Adicione:
registerMethod("Creature", "soltaMagia", LuaScriptInterface::luaSoltaMagia);
Logo abaixo da função:
int LuaScriptInterface::luaCreatureGetEvents(lua_State* L)
Adicione:
int LuaScriptInterface::luaSoltaMagia(lua_State* L) { //creature:soltaMagia("name") const std::string& spellName = getString(L, 2); if(Creature* creature = getUserdata<Creature>(L, 1)) { 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 { lua_pushboolean(L, false); } return 1; }
Em luascript.h registre:
static int luaSoltaMagia(lua_State* L);
static int luaSoltaMagia(lua_State* L);
Agora é só compilar a proveitar