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

[TFS 0.2.22] New Function: addCreatureMaxHP

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Reaction score
13
Location
Caracas, Venezuela
As the title says, I use TFS 0.2 patch 22, and Im just requesting this feature from any of the C++ pros here because Im sure there must be someone in this forum with the required skill to make this, so Im asking you for your help.

Im pretty sure this can only be done by source editing, but if it doesnt, better yet.

Anyways this is what Id like:

> 2 new Lua Functions called: addCreatureMaxHP and addCreatureMaxMana

What would they do? Well, the obvious, something like when you use a certain item you get 100 HP added to your max HP permanently. Same goes for mana.
Or better yet, an NPC who could sell a certain amount of hp/mana for a certain amount of money so you would get it added to your maxhp/maxmana permanently.

Im not really hopeful on this thread given the fact that most requests on this subforum have 0 replies and I understand it, but since I really need it and I will put all my efforts on finding how to do this Im also hopeful because Im aware of the level of skill some people here have and maybe, just maybe, some of those people will see this thread and then maybe, just maybe, they will find some time to help me out.

Its needless to say that Ill obviously +REP the person who could help me out on this, cause I always do and in this case its a must.

Thanks in advance.
 
okay it works

in player.cpp at the bottom add

PHP:
void Player::addMaxHealth(int32_t newHealth)
{
	healthMax += newHealth;
	sendStats();
}

void Player::addMaxMana(int32_t newMana)
{
	manaMax += newMana;
	sendStats();
}

in player.h search for
Code:
unit32_t maxDepotLimit
and add
PHP:
		void addMaxHealth(int32_t newHealth);
		void addMaxMana(int32_t newMana);


in luascript.cpp add the bottom add
PHP:
int32_t LuaScriptInterface::luaSetPlayerMaxHealth(lua_State* L)
{
	uint32_t addHealth = popNumber(L);
	uint32_t cid = popNumber(L);
	ScriptEnviroment* env = getScriptEnv();
	Player* player = env->getPlayerByUID(cid);
	if(player)
	{
		player->addMaxHealth(addHealth);
		lua_pushboolean(L, true);
	}
	else
	{
		reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	return 1;
}

int32_t LuaScriptInterface::luaSetPlayerMaxMana(lua_State* L)
{
	uint32_t addMana = popNumber(L);
	uint32_t cid = popNumber(L);
	ScriptEnviroment* env = getScriptEnv();
	Player* player = env->getPlayerByUID(cid);
	if(player)
	{
		player->addMaxMana(addMana);
		lua_pushboolean(L, true);
	}
	else
	{
		reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	return 1;
}

also in luascript.cpp search for
Code:
	lua_register(m_luaState, "debugPrint", LuaScriptInterface::luaDebugPrint);
and after it add
PHP:
	//setPlayerMaxHealth(cid,health)
	lua_register(m_luaState, "setPlayerMaxHealth", LuaScriptInterface::luaSetPlayerMaxHealth);

	//setPlayerMaxMana(cid,mana)
	lua_register(m_luaState, "setPlayerMaxMana", LuaScriptInterface::luaSetPlayerMaxMana);


in luascript.h search for
Code:
		static int32_t internalGetPlayerInfo(lua_State* L, PlayerInfo_t info);
and after that add
PHP:
		static int32_t luaSetPlayerMaxHealth(lua_State *L);
		static int32_t luaSetPlayerMaxMana(lua_State *L);


then a sample lua script (made it a talkaction) is
PHP:
function onSay(cid, item, frompos, item2, topos)

setPlayerMaxHealth(cid,100)
setPlayerMaxMana(cid,100)

end

adds 100 mana and hp to the players max
 
Back
Top