epaminombas
New Member
- Joined
- Apr 23, 2009
- Messages
- 17
- Reaction score
- 0
TFS 1.3
This code works but ignore parameters of spells.xml spent mana, cooldown, range and all another parameters.
I need this code follow spells.xml parameters.
I try make items with shorcut for cast spells
Lua Script
C++ Code
This code works but ignore parameters of spells.xml spent mana, cooldown, range and all another parameters.
I need this code follow spells.xml parameters.
I try make items with shorcut for cast spells
Lua Script
Lua:
function onUse(player, words, param)
player:doCastSpell("Light Healing")
end
C++ Code
C++:
int LuaScriptInterface::luaDoCastSpell(lua_State* L)
{
//creature: doCastSpell("spellName")
Creature* creature = getUserdata<Creature>(L, 1);
if(!creature) {
lua_pushboolean(L, false);
return 1;
}
const std::string& spellName = getString(L, 2);
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);
return 1;
}