bool Game::internalCreatureSayWithRadius(Creature* creature, SpeakClasses type, const std::string& text, int radiusx, int radiusy)
{
Position destPos = creature->getPosition();
SpectatorVec list;
getSpectators(list, destPos, false, true, radiusx, radiusx, radiusy, radiusy);
return internalCreatureSay(creature, type, text, false, &list);
}
bool internalCreatureSayWithRadius(Creature* creature, SpeakClasses type, const std::string& text, int radiusx, int radiusy);
int32_t LuaInterface::luaDoCreatureSayWithRadius(lua_State* L)
{
//doCreatureSayWithRadius(uid, text, type, radiusx, radiusy)
uint32_t params = lua_gettop(L), uid = 0, radiusx, radiusy;
SpeakClasses type;
radiusy = popNumber(L);
radiusx = popNumber(L);
type = (SpeakClasses)popNumber(L);
std::string text = popString(L);
uid = popNumber(L);
ScriptEnviroment* env = getEnv();
Creature* creature = env->getCreatureByUID(uid);
if(!creature)
{
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}
lua_pushboolean(L, g_game.internalCreatureSayWithRadius(creature, type, text, radiusx, radiusy));
return 1;
}
//doCreatureSayWithRadius(uid, text, type, radiusx, radiusy)
lua_register(m_luaState, "doCreatureSayWithRadius", LuaInterface::luaDoCreatureSayWithRadius);
static int32_t luaDoCreatureSayWithRadius(lua_State* L);
function doCreatureSayWithRadius(cid, text, type, radiusx, radiusy, position)
position = position or getThingPos(cid)
local v = getSpectators(position, radiusx, radiusy, false) or {}
for i = 1, #v do
if isPlayer(v[i]) then
doCreatureSay(cid, text, type, false, v[i], position)
end
end
end