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

Life Drain Hp To Player Spell Help

Blackcody

RiseOfTibia Owner
Joined
Aug 31, 2008
Messages
136
Reaction score
1
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_BATS)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, true)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -2, -10, -2, -20, 5, 5, 2, 3)

function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end

But i need it to add the hp taken from monster to player
 
Havent tested, test it please post if something wrong!


Code:
function onCastSpell(cid, var)
	if getPlayerStorageValue(cid, 3) >= 1 then
	setPlayerStorageValue(cid, 3, -1)
	return true
	end
	if getPlayerStorageValue(cid, 5) >= 1 then
			if isPlayer(getCreatureTarget(cid)) then
			huah = getPlayerLevel(getCreatureTarget(cid))
			else
			huah = getPlayerLevel(getCreatureMaster(getCreatureTarget(cid)))
			end
		local levels = huah
		doTargetCombatHealth(getCreatureTarget(cid), cid, COMBAT_PHYSICALDAMAGE, -(math.random((levels*3),(levels*5))), -((math.random((levels*3),(levels*5))+10)), 3)
		return true
		end
local x = x
	local life = getCreatureHealth(getCreatureTarget(cid))
	doTargetCombatHealth(cid, getCreatureTarget(cid), GRASSDAMAGE, -x, -(x+1), 255)
	local newlife = life - getCreatureHealth(getCreatureTarget(cid))
	if newlife >= 1 then
	doCreatureAddHealth(cid, newlife)
	doSendMagicEffect(getThingPos(cid), 14)
	doSendMagicEffect(getThingPos(getCreatureTarget(cid)), 14)
	doSendAnimatedText(getThingPos(cid), "+"..newlife.."", 35)
	end

end
 
LUA:
local config = {
	min = 50 * 2 + 400 * 3,
	max = 40 * 2.5 + 500 * 3.5
}

function onCastSpell(cid, var)
	local target = getCreatureTarget(cid)
	if not isCreature(target) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
		doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
		return false
	end
 
	local drain = math.min(getCreatureHealth(target), math.random(config.min, config.max))
	doTargetCombatHealth(cid, target, COMBAT_HOLYDAMAGE, -drain, -drain, CONST_ME_HOLYDAMAGE)
	doCreatureAddHealth(cid, drain * (45 / 100))
	doSendDistanceShoot(getThingPos(target), getThingPos(cid), CONST_ANI_HOLY)
	return true
end
 
Back
Top