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

Lua Creature Illusion Function

Status
Not open for further replies.

_Arthur

Joined
Oct 22, 2009
Messages
2,190
Reaction score
143
Just wondering what the creature illusion function is?


Rep+
 
Creature Illusion is written in C++, so it doesn't call any Lua functions :D
Code:
ReturnValue [B][COLOR="red"]Spell::CreateIllusion[/COLOR][/B](Creature* creature, const Outfit_t outfit, int32_t time)
{
	ConditionOutfit* outfitCondition = new ConditionOutfit(CONDITIONID_COMBAT, CONDITION_OUTFIT, time, false, 0);
	if(!outfitCondition)
		return RET_NOTPOSSIBLE;

	outfitCondition->addOutfit(outfit);
	creature->addCondition(outfitCondition);
	return RET_NOERROR;
}
Instead, this Lua function calls the same C++ function that this spell uses.
Code:
int32_t LuaScriptInterface::luaSetMonsterOutfit(lua_State* L)
{
	[COLOR="green"]//doSetMonsterOutfit(cid, name, time)[/COLOR]
	int32_t time = (int32_t)popNumber[COLOR="navy"]([/COLOR]L[COLOR="navy"]);[/COLOR]
	std::string name [COLOR="navy"]=[/COLOR] popString(L);

	ScriptEnviroment[COLOR="navy"]*[/COLOR] env = getEnv[COLOR="navy"]();[/COLOR]
	[COLOR="blue"]if[/COLOR][COLOR="navy"]([/COLOR]Creature[COLOR="navy"]*[/COLOR] creature = env->getCreatureByUID(popNumber(L)))
		lua_pushboolean(L, [B][COLOR="red"]Spell[COLOR="navy"]::[/COLOR]CreateIllusion[/COLOR][/B](creature, name, time) == RET_NOERROR);
	[COLOR="blue"]else[/COLOR]
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, [COLOR="blue"]false[/COLOR]);
	}
	[COLOR="blue"]return[/COLOR] [COLOR="darkorange"]1[/COLOR];
}
 
Last edited:
Status
Not open for further replies.
Back
Top