Luascript.cpp:
[cpp] //getDamageRatio(cid, target)
lua_register(m_luaState, "getDamageRatio", LuaInterface::luaDoGetDamageRatio);
[/cpp]
[cpp]int32_t LuaInterface::luaDoGetDamageRatio(lua_State* L) // Damage Ratio
{
//getDamageRatio(cid, target)
ScriptEnviroment* env = getEnv();
Creature* target = env->getCreatureByUID(popNumber(L));
if(!target)
{
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}
Creature* player = env->getPlayerByUID(popNumber(L));
if(!player)
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}
lua_pushnumber(L, target->getDamageRatio(player));
return 1;
}[/cpp]
luascript.h:
[cpp]static int32_t luaDoGetDamageRatio(lua_State* L); // Damage Ratio[/cpp]
Now what to do:
Create a onKill script and register it onLogin to the player (as every script)
Put in the script:
Lua:
function onKill(cid, target, lastHit)
registerCreatureEvent(target, "showExp")
return true
end
Create another creaturescript:
XML:
<event type="death" name="showExp" event="script" value="YOURFILE.lua"/>
and put in:
Lua:
function onDeath(cid, corpse, deathList)
for i = 1, #deathList do
if isPlayer(deathList[i]) then
local exp = getConfigInfo('rateExperience')
if getBooleanFromString(getConfigInfo('experienceStages')) then
exp = getExperienceStage(getPlayerLevel(deathList[i]), getVocationInfo(getPlayerVocation(deathList[i])).experienceMultiplier)
end
local expgain = exp*getDamageRatio(deathList[i], cid)*getMonsterInfo(getCreatureName(cid)).experience
doPlayerSendTextMessage(deathList[i], MESSAGE_INFO_DESCR, "You gained ".. expgain .." experience.")
end
end
return true
end
You also need to check whether the player has 1.5exp because of stamina shit. That isn't included.