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

Solved DoCreatureCastSpell

mrianura

Well-Known Member
Joined
Jan 31, 2015
Messages
81
Reaction score
71
hi i have problem with this code : (tfs 0.3.6)

int32_t LuaScriptInterface::luaDoCreatureCastSpell(lua_State* L)
{
//doCreatureCastSpell (uid, spell)
std::string spellname = popString(L);
ScriptEnviroment *env = getEnv();
Creature *creature = env->getCreatureByUID(popNumber(L));
if(!creature)
{
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean (L, false);
return 1;
}
Spell *spell = g_spells->getInstantSpellByName(spellname);
if(spell)
{
if(spell->castSpell(creature))
{
lua_pushboolean(L, true);
return 1;
}
}
errorEx(getError(LUA_ERROR_SPELL_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}

i had no problems with compile.
but when monster use a spell its sending magic effect but nothig else. Target dont recieve damage.
i would be grateful if someone can help me ;)
 
It has nothing to do with that function (unless you are actually calling doCreatureCastSpell in a lua script).
Does any other of your monsters spells work?
If they do, then post the xml file for the monster that doesn't work.

If you are calling doCreatureCastSpell, then post the spell script you're using.
 
Last edited:
function onSay(cid, words, param, channel)
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
local pk = getCreatureSummons(cid)[1]
local name = getCreatureName(pk)
local target = GetCreatureTarget(pk)
doCreatureCastSpell(target ,pk,"aurafogo")


return true
end ......

yeah i tired almost all spells and no one can deal dmg
 
I suppose first things first...

Does casting a spell normally work?
Aka:
Saying: "exori vis"
Rather than using: doCreatureCastSpell(cid , target, "exori vis")
 
You can make monsters cast spells by putting them in their XML attack configuration, for example this spell Spike:

<attacks>
<attack name="melee" interval="2000" min="-34" max="-105"/>
<attack name="Spike" interval="2200" range="4" chance="25" min="-45" max="-80"/>
</attacks>
 
@Shadowsong yeah i know but i want to make script where player have summon and when player say for example do exori then this summon will do exori
@Xagul yeah when player cast for example exori then monster deal good damage , but i have problem when sommon cast spell.
he is casting spell normally but he cant deal dmg.
 
@Shadowsong yeah i know but i want to make script where player have summon and when player say for example do exori then this summon will do exori
@Xagul yeah when player cast for example exori then monster deal good damage , but i have problem when sommon cast spell.
he is casting spell normally but he cant deal dmg.

Have you tried that with multiple spells, not just that one?
Can you post the spell's configuration and script here?
 
The monster will not deal damage with a players spell (in the way you are trying to make the monster cast the spell) because the formula inside of the spell is for players only. You will need to add shit into your spell to make it do dmg when used by a monster.
 
You could do a check within the onCastSpell function in the spell's script such as

if not isPlayer(cid) then
local min, max, effect = 10, 20, 6
doTargetCombatHealth(cid, variantToNumber(var), COMBAT_PHYSICALDAMAGE, -min, -max, effect)
else
-- what was in the original script
end
 
Back
Top