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.
I appreciate any kind of help!
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!