• 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 Potioins help custom vocs

Dexftw

Total Boss
Joined
Jan 30, 2011
Messages
317
Reaction score
8
fail spelling title lol Can I get some help with my custom vocations using potions, not sure how this works what do I need to change for them to work.

Code:
local ultimateHealthPot = 8473
local greatHealthPot = 7591
local greatManaPot = 7590
local greatSpiritPot = 8472
local strongHealthPot = 7588
local strongManaPot = 7589
local healthPot = 7618
local manaPot = 7620
local smallHealthPot = 8704
local antidotePot = 8474
local greatEmptyPot = 7635
local strongEmptyPot = 7634
local emptyPot = 7636

local antidote = createCombatObject()
setCombatParam(antidote, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(antidote, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(antidote, COMBAT_PARAM_TARGETCASTERORTOPMOST, TRUE)
setCombatParam(antidote, COMBAT_PARAM_AGGRESSIVE, FALSE)
setCombatParam(antidote, COMBAT_PARAM_DISPEL, CONDITION_POISON)

local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
-- 1000 - 100 due to exact condition timing. -100 doesn't hurt us, and players don't have reminding ~50ms exhaustion.

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(itemEx.uid ~= cid or itemEx.itemid ~= 1) then
return TRUE
end

if(getCreatureCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return TRUE
end

if(item.itemid == antidotePot) then
if(doCombat(cid, antidote, numberToVariant(cid)) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, emptyPot)
elseif(item.itemid == smallHealthPot) then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 50, 100, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, emptyPot)
elseif(item.itemid == healthPot) then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 100, 200, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, emptyPot)
elseif(item.itemid == manaPot) then
if(doTargetCombatMana(0, cid, 70, 130, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, emptyPot)
elseif(item.itemid == strongHealthPot) then
if(not(isKnight(cid) or isPaladin(cid) or getPlayerVocation(cid) == BLAH) or (getPlayerLevel(cid) < 50)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by cavalrymen, paladins and knights of level 50 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end

if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 200, 400, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, strongEmptyPot)
elseif(item.itemid == strongManaPot) then
if(not(isSorcerer(cid) or isDruid(cid) or isPaladin(cid) or getPlayerVocation(cid) == BLAH) or (getPlayerLevel(cid) < 50)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by alchemists, sorcerers, druids and paladins of level 50 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end

if(doTargetCombatMana(0, cid, 110, 190, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, strongEmptyPot)
elseif(item.itemid == greatSpiritPot) then
if(not(isPaladin(cid)) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by paladins of level 80 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end

if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 200, 400, CONST_ME_MAGIC_BLUE) == LUA_ERROR or doTargetCombatMana(0, cid, 110, 190, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, greatEmptyPot)
elseif(item.itemid == greatHealthPot) then
if(not(isKnight(cid) or getPlayerVocation(cid) == BLAH) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by cavalrymen and knights of level 80 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end

if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 500, 700, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, greatEmptyPot)
elseif(item.itemid == greatManaPot) then
if(not(isSorcerer(cid) or isDruid(cid) or getPlayerVocation(cid) == BLAH) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by alchemists, sorcerers and druids of level 80 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end

if(doTargetCombatMana(0, cid, 200, 300, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, greatEmptyPot)
elseif(item.itemid == ultimateHealthPot) then
if(not(isWarrior(cid) or getPlayerVocation(cid) == Striker) or (getPlayerLevel(cid) < 130)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by cavalrymen and knights of level 130 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end

if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 800, 1000, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
doTransformItem(item.uid, greatEmptyPot)
end
return TRUE
end
 
Last edited:
What OT are you using?
When I added new vocations to my OT I had to change many files, I'll try and include them all here.

data\lib\031-vocations.lua (changes in red):
Code:
function isSorcerer(cid)
	return isInArray({1, 5[COLOR="#FF0000"], 9[/COLOR]}, getPlayerVocation(cid))
end

function isDruid(cid)
	return isInArray({2, 6[COLOR="#FF0000"], 10[/COLOR]}, getPlayerVocation(cid))
end

function isPaladin(cid)
	return isInArray({3, 7[COLOR="#FF0000"], 11[/COLOR]}, getPlayerVocation(cid))
end

function isKnight(cid)
	return isInArray({4, 8[COLOR="#FF0000"], 12[/COLOR]}, getPlayerVocation(cid))
end

function isRookie(cid)
	return isInArray({0}, getPlayerVocation(cid))
end

data\weapons\weapons.xml (changes in red):
Code:
		<!-- Warsinger Bow -->
	<distance id="8854" level="80" unproperly="1" event="function" value="default">
		<vocation id="3"/>
		<vocation id="7" showInDescription="0"/>
		[COLOR="#FF0000"]<vocation id="11"/>[/COLOR]
	</distance>

data\xml\vocations.xml (changes in red):
Code:
<?xml version="1.0" encoding="UTF-8"?>
<vocations>
	<vocation id="0" name="None" description="none" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="3" gainhpamount="4" gainmanaticks="3" gainmanaamount="2" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="no" droploot="no">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="1" name="Sorcerer" description="a sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="6" gainhpamount="5" gainmanaticks="3" gainmanaamount="5" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="30" fromvoc="1">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="2" name="Druid" description="a druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="6" gainhpamount="5" gainmanaticks="3" gainmanaamount="5" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="30" fromvoc="2">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="3" name="Paladin" description="a paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="4" gainhpamount="5" gainmanaticks="4" gainmanaamount="5" manamultiplier="1.4" attackspeed="2000" soulmax="100" gainsoulticks="30" fromvoc="3">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="4" name="Knight" description="a knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="3" gainhpamount="5" gainmanaticks="6" gainmanaamount="5" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="30" fromvoc="4">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="5" name="Master Sorcerer" description="a master sorcerer" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="10" gainmanaticks="2" gainmanaamount="10" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="1" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="6" name="Elder Druid" description="an elder druid" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="10" gainmanaticks="2" gainmanaamount="10" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="2" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="7" name="Royal Paladin" description="a royal paladin" needpremium="1" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="10" gainmanaticks="3" gainmanaamount="10" manamultiplier="1.4" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="3" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="8" name="Elite Knight" description="an elite knight" needpremium="1" gaincap="25" gainhp="15" gainmana="5" gainhpticks="2" gainhpamount="10" gainmanaticks="4" gainmanaamount="10" manamultiplier="3.0" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="4" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
	</vocation>

	[COLOR="#FF0000"]<vocation id="9" name="Shadow Sorcerer" description="a shadow sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="20" gainmanaticks="2" gainmanaamount="20" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="5" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="10" name="Feral Druid" description="a feral druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="4" gainhpamount="20" gainmanaticks="2" gainmanaamount="20" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="6" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="11" name="Holy Paladin" description="a holy paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="20" gainmanaticks="3" gainmanaamount="20" manamultiplier="1.4" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="7" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/>
	</vocation>
	<vocation id="12" name="Fury Knight" description="a fury knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="2" gainhpamount="20" gainmanaticks="4" gainmanaamount="20" manamultiplier="3.0" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="8" lessloss="30">
		<formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
		<skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/>
	</vocation>[/COLOR]

</vocations>

There may also be other files you will need to edit but hopefully this will get you started.

Cheers.
 
Uhm, U don't have a lib-vocations file on here, im using the 9.1 tfs by talaturen

Try data\global.lua (changes in red)

Code:
function isSorcerer(cid)
        if(isPlayer(cid) == FALSE) then
                debugPrint("isSorcerer: Player not found.")
                return false
        end

        return (isInArray({1,5[COLOR="#FF0000"],9[/COLOR]}, getPlayerVocation(cid)) == TRUE)
end

function isDruid(cid)
        if(isPlayer(cid) == FALSE) then
                debugPrint("isDruid: Player not found.")
                return false
        end

        return (isInArray({2,6[COLOR="#FF0000"],10[/COLOR]}, getPlayerVocation(cid)) == TRUE)
end

function isPaladin(cid)
        if(isPlayer(cid) == FALSE) then
                debugPrint("isPaladin: Player not found.")
                return false
        end

        return (isInArray({3,7[COLOR="#FF0000"],11[/COLOR]}, getPlayerVocation(cid)) == TRUE)
end

function isKnight(cid)
        if(isPlayer(cid) == FALSE) then
                debugPrint("isKnight: Player not found.")
                return false
        end

        return (isInArray({4,8[COLOR="#FF0000"],12[/COLOR]}, getPlayerVocation(cid)) == TRUE)
end
 

Similar threads

Back
Top