I want to create a spell that make a player atk other player, like exeta res to pvp
It looks like work, it is opeing PK, but it is not creating the red square...
Why?
What do i doing wrong?
spell:
source code:
It looks like work, it is opeing PK, but it is not creating the red square...
Why?
What do i doing wrong?
spell:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
local arr = {
{0, 0, 0, 0, 0},
{0, 1, 1, 1, 0},
{0, 1, 2, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0},
}
local area = createCombatArea(arr)
setCombatArea(combat, area)
function onCastSpell(cid, var)
for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1, false)) do
if(isPlayer(tid) and tid ~= cid) then
doCreatureSetTarget(tid, cid)
end
end
return doCombat(cid, combat, var)
end
source code:
Code:
int32_t LuaInterface::luaDoCreatureSetTarget(lua_State* L)
{
//doCreatureSetTarget(cid, target)
uint32_t targetId = popNumber(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;
}
Creature* target = env->getCreatureByUID(targetId);
if(!target && targetId != 0)
{
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}
bool attackedCreatureChanged = creature->setAttackedCreature(target);
// Remove red square in client if setting target to NULL
Player *player = creature->getPlayer();
if(player != NULL && targetId == 0 && attackedCreatureChanged) {
player->sendCancelTarget();
} else {
player->sendCreatureSquare(target, 112);
}
lua_pushboolean(L, attackedCreatureChanged);
return 1;
}