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

[C++] doTargetCombatHealth(cid, target, type, min, max, effect)

perdigs

New Member
Joined
Aug 22, 2010
Messages
114
Reaction score
1
I need one change in the c++ codes to this function
i need add a hit color but this comand use the hit color configured in condition and combat_type
exemple in my c++ codes i configure the COMBAT_PHYSICALDAMAGE to hit color blue
if i use this comand the hit is ever blue, i need changes to use this comand and set the hit black, or yellow or red...
Plese help me.
 
its can be done in lua kinda easy...
LUA:
function onStatsChange(cid, attacker, combatee, value)
if combatee ~= COMBAT_PHYSICALDAMAGE then
if isCreature(attacker) or isPlayer(attacker) then
doSendMagicEffect(getThingPos(cid), 135)
doSendMagicEffect(getThingPos(attacker), 3)
doCreatureAddHealth(attacker, -value)
doSendAnimatedText(getThingPos(attacker), -value, 191)
end
end
return true
end

it might not work just writed in browser but you should undersand idea...
 
Code:
int32_t LuaScriptInterface::luaDoTargetCombatHealth(lua_State* L)
{
	//doTargetCombatHealth(cid, target, type, min, max, effect)
	MagicEffect_t effect = (MagicEffect_t)popNumber(L);
	int32_t maxChange = (int32_t)popNumber(L), minChange = (int32_t)popNumber(L);

	CombatType_t combatType = (CombatType_t)popNumber(L);
	uint32_t targetCid = popNumber(L), cid = popNumber(L);

	ScriptEnviroment* env = getEnv();
	Creature* creature = NULL;
	if(cid)
	{
		if(!(creature = env->getCreatureByUID(cid)))
		{
			errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
			lua_pushboolean(L, false);
			return 1;
		}
	}

	Creature* target = env->getCreatureByUID(targetCid);
	if(target)
	{
		CombatParams params;
		params.combatType = combatType;
		params.effects.impact = effect;

		Combat::doCombatHealth(creature, target, minChange, maxChange, params);
		lua_pushboolean(L, true);
	}
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}

This is a script of doTargetCombatHealth

i need a one change to set a color of hit.
 
Last edited:
e this will be fapply :P
Code:
int32_t LuaScriptInterface::luaDoTargetCombatHealth(lua_State* L)
{
	//doTargetCombatHealth(cid, target, type, min, max, effect[B][COLOR="red"][, color][/COLOR][/B])
[B][COLOR="red"]	ScriptEnviroment* env = getEnv();
	int32_t params = lua_gettop(L);

	TextColor_t color = TEXTCOLOR_UNKNOWN;
	if(params > 6)
		color = (TextColor_t)popNumber(L);[/COLOR][/B]

	MagicEffect_t effect = (MagicEffect_t)popNumber(L);
	int32_t maxChange = (int32_t)popNumber(L), minChange = (int32_t)popNumber(L);

	CombatType_t combatType = (CombatType_t)popNumber(L);
	uint32_t targetCid = popNumber(L), cid = popNumber(L);

	Creature* creature = NULL;
	if(cid)
	{
		if(!(creature = env->getCreatureByUID(cid)))
		{
			errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
			lua_pushboolean(L, false);
			return 1;
		}
	}

	Creature* target = env->getCreatureByUID(targetCid);
	if(target)
	{
		[B][COLOR="red"]g_game.combatChangeHealth(combatType, creature, target, random_range(minChange, maxChange, DISTRO_NORMAL), effect, color, false);[/COLOR][/B]
		lua_pushboolean(L, true);
	}
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}
 
Tks Cyko but dont work on target enemy dont have hit color
only the monster receive the damage but the hits dont up a values.
 
Back
Top