• 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 1.X+ HELP The Oracle customization

gnadaja98

New Member
Joined
May 15, 2024
Messages
13
Reaction score
2
Hi comunnity i need help for modification The Oracle.lua my vocations.xml:

XML:
<?xml version="1.0" encoding="UTF-8"?>
<vocations>
    <vocation id="0" name="None" description="none" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="10" gainmanaticks="6" gainmanaamount="10" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="0" >
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>

<!--RACES-->
    <vocation id="1" name="Human" description="a human" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="10" gainmanaticks="6" gainmanaamount="10" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="1">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
        <vocation id="12" name="Elf" description="a elf" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="10" gainmanaticks="6" gainmanaamount="10" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="12" >
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
        <vocation id="23" name="Dwarf" description="a dwarf" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="10" gainmanaticks="6" gainmanaamount="10" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="23">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
        <vocation id="34" name="Pandawan" description="a pandawan" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="10" gainmanaticks="6" gainmanaamount="10" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="34" attackable="no">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
        <vocation id="45" name="Undead" description="a undead" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="10" gainmanaticks="6" gainmanaamount="10" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="45">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
        <vocation id="56" name="Troll" description="a troll" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="10" gainmanaticks="6" gainmanaamount="10" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="56">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
        <vocation id="78" name="Orc" description="a orc" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="10" gainmanaticks="6" gainmanaamount="10" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="78">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
        <vocation id="67" name="Tauren" description="a tauren" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="10" gainmanaticks="6" gainmanaamount="10" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="67">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>

And i have 10 vocs for each race like this:

XML:
<!--HUMANOS-->
    <vocation id="2" name="Human Mage" description="a human mage" needpremium="0" gaincap="5" gainhp="5" gainmana="30" gainhpticks="1" gainhpamount="2" gainmanaticks="2" gainmanaamount="400" manamultiplier="1.5" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="1">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
        <vocation id="3" name="Human Priest" description="a human priest" needpremium="0" gaincap="5" gainhp="5" gainmana="30" gainhpticks="6" gainhpamount="10" gainmanaticks="1" gainmanaamount="1000" manamultiplier="1.5" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="1">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
        <vocation id="4" name="Human Invoker" description="a human invoker" needpremium="0" gaincap="5" gainhp="5" gainmana="30" gainhpticks="6" gainhpamount="10" gainmanaticks="1" gainmanaamount="1000" manamultiplier="1.5" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="1">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
        <vocation id="5" name="Human Hunter" description="a human hunter" needpremium="0" gaincap="5" gainhp="10" gainmana="10" gainhpticks="1" gainhpamount="10" gainmanaticks="1" gainmanaamount="100" manamultiplier="2.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="1">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="1.1"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
........

    <vocation id="24" name="Dwarf Mage" description="a dwarf mage" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="10" gainmanaticks="6" gainmanaamount="10" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="23">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
        <vocation id="25" name="Dwarf Priest" description="a dwarf priest" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="10" gainmanaticks="6" gainmanaamount="10" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="23">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>
        <vocation id="26" name="Dwarf Invoker" description="a dwarf invoker" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="10" gainmanaticks="6" gainmanaamount="10" manamultiplier="4.0" attackspeed="1000" soulmax="100" gainsoulticks="120" fromvoc="23">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="2.0" defense="1.0" armor="1.0"/>
        <skill id="0" multiplier="1.5"/>
        <skill id="1" multiplier="2.0"/>
        <skill id="2" multiplier="2.0"/>
        <skill id="3" multiplier="2.0"/>
        <skill id="4" multiplier="2.0"/>
        <skill id="5" multiplier="1.5"/>
        <skill id="6" multiplier="1.1"/>
    </vocation>

The Oracle.lua:

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local vocation = {}
local town = {}
local destination = {}

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local function greetCallback(cid)
    local player = Player(cid)
    local level = player:getLevel()
    if level < 8 then
        npcHandler:say("CHILD! COME BACK WHEN YOU HAVE GROWN UP!", cid)
        return false
    elseif level > 9 then
        npcHandler:say(player:getName() .. ", I CAN'T LET YOU LEAVE - YOU ARE TOO STRONG ALREADY! YOU CAN ONLY LEAVE WITH LEVEL 9 OR LOWER.", cid)
        return false
    elseif player:getVocation():getId() > 0 then
        npcHandler:say("YOU ALREADY HAVE A VOCATION!", cid)
        return false
    end
    return true
end

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    if msgcontains(msg, "yes") and npcHandler.topic[cid] == 0 then
        npcHandler:say("IN WHICH TOWN DO YOU WANT TO LIVE: {RHYVES}?", cid)
        npcHandler.topic[cid] = 1
    elseif npcHandler.topic[cid] == 1 then
        if msgcontains(msg, "rhyves") then
            town[cid] = 2
            destination[cid] = Position(159, 387, 6)
            npcHandler:say("IN RHYVES! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
            npcHandler.topic[cid] = 2
        else
            npcHandler:say("IN WHICH TOWN DO YOU WANT TO LIVE: {RHYVES}?", cid)
        end
    elseif npcHandler.topic[cid] == 2 then
        if msgcontains(msg, "sorcerer") then
            npcHandler:say("A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
            npcHandler.topic[cid] = 3
            vocation[cid] = 1
        elseif msgcontains(msg, "druid") then
            npcHandler:say("A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
            npcHandler.topic[cid] = 3
            vocation[cid] = 2
        elseif msgcontains(msg, "paladin") then
            npcHandler:say("A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
            npcHandler.topic[cid] = 3
            vocation[cid] = 3
        elseif msgcontains(msg, "knight") then
            npcHandler:say("A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
            npcHandler.topic[cid] = 3
            vocation[cid] = 4
        else
            npcHandler:say("{KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
        end
    elseif npcHandler.topic[cid] == 3 then
        if msgcontains(msg, "yes") then
            local player = Player(cid)
            npcHandler:say("SO BE IT!", cid)
            player:setVocation(Vocation(vocation[cid]))
            player:setTown(Town(town[cid]))

            local destination = destination[cid]
            npcHandler:releaseFocus(cid)
            player:teleportTo(destination)
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            destination:sendMagicEffect(CONST_ME_TELEPORT)
        else
            npcHandler:say("THEN WHAT? {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
            npcHandler.topic[cid] = 2
        end
    end
    return true
end

local function onAddFocus(cid)
    town[cid] = 0
    vocation[cid] = 0
    destination[cid] = 0
end

local function onReleaseFocus(cid)
    town[cid] = nil
    vocation[cid] = nil
    destination[cid] = nil
end

npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I want add if u are Human u can choose Human Vocs, if u are Elfs, u can choose Elfs Vocs, if u are Dwarf, u can choose Dwarf Vocs, and for all vocations, can someone help me?
 
Not tested, but should be good to go.

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local vocation = {}
local town = {}
local destination = {}

local vocation_options = {
	--[base_vocation] = {vocation_range_start, vocation_range_end}
	[1] = {2, 11}, -- human
	[12] = {13, 22}, -- elf
	[23] = {24, 33}, -- dwarf
	[34] = {35, 44}, -- padawan
	[45] = {46, 55}, -- undead
	[56] = {57, 66}, -- troll
	[67] = {68, 77}, -- tauren
	[78] = {79, 88}  -- orc
}

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                          npcHandler:onThink()                        end

local function getProfessionNamesFromRange(rangeStart, rangeEnd)
	local professions = ""
	for i = rangeStart, rangeEnd do
		local voc = Vocation(i)
		if professions ~= "" then
			professions = professions .. ", "
			if i == rangeEnd then
				professions = professions .. "OR "
			end
		end
		professions = professions .. "{" .. voc:getName():upper() .. "}"
	end
	return professions
end

local function greetCallback(cid)
	local player = Player(cid)
	local level = player:getLevel()
	if level < 8 then
		npcHandler:say("CHILD! COME BACK WHEN YOU HAVE GROWN UP!", cid)
		return false
	elseif level > 9 then
		npcHandler:say(player:getName() .. ", I CAN'T LET YOU LEAVE - YOU ARE TOO STRONG ALREADY! YOU CAN ONLY LEAVE WITH LEVEL 9 OR LOWER.", cid)
		return false
	elseif not vocation_options[player:getVocation():getId()] then
		npcHandler:say("YOU ALREADY HAVE A VOCATION!", cid)
		return false
	end
	return true
end

local function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end
	
	local player = Player(cid)
	local vocation = player:getVocation()
	local index = vocation_options[vocation:getId()]
	
	if msgcontains(msg, "yes") and npcHandler.topic[cid] == 0 then
		npcHandler:say("IN WHICH TOWN DO YOU WANT TO LIVE: {RHYVES}?", cid)
		npcHandler.topic[cid] = 1
	elseif npcHandler.topic[cid] == 1 then
		if msgcontains(msg, "rhyves") then
			town[cid] = 2
			destination[cid] = Position(159, 387, 6)
			npcHandler:say("IN RHYVES! AND WHAT PROFESSION HAVE YOU CHOSEN: " .. getProfessionNamesFromRange(index[1], index[2]) .. "?", cid)
			npcHandler.topic[cid] = 2
		else
			npcHandler:say("IN WHICH TOWN DO YOU WANT TO LIVE: {RHYVES}?", cid)
		end
	elseif npcHandler.topic[cid] == 2 then
		local professions = {}
		for i = index[1], index[2] do
			local voc = Vocation(i)
			professions[#professions + 1] = {voc:getName():lower(), i}
		end
		for i = 1, #professions do
			if msgcontains(msg, professions[i][1]) then
				npcHandler:say("A " .. professions[i][1]:upper() .. "! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
				npcHandler.topic[cid] = 3
				vocation[cid] = professions[i][2]
				return true
			end
		end
		npcHandler:say(getProfessionNamesFromRange(index[1], index[2]) .. "?", cid)
	elseif npcHandler.topic[cid] == 3 then
		if msgcontains(msg, "yes") then
			local player = Player(cid)
			npcHandler:say("SO BE IT!", cid)
			player:setVocation(Vocation(vocation[cid]))
			player:setTown(Town(town[cid]))
	
			local destination = destination[cid]
			npcHandler:releaseFocus(cid)
			player:teleportTo(destination)
			player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
			destination:sendMagicEffect(CONST_ME_TELEPORT)
		else
			npcHandler:say("THEN WHAT? " .. getProfessionNamesFromRange(index[1], index[2]) .. "?", cid)
			npcHandler.topic[cid] = 2
		end
	end
	return true
end

local function onAddFocus(cid)
	town[cid] = 0
	vocation[cid] = 0
	destination[cid] = 0
	npcHandler.topic[cid] = 0
end

local function onReleaseFocus(cid)
	town[cid] = nil
	vocation[cid] = nil
	destination[cid] = nil
	npcHandler.topic[cid] = nil
end

npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus)
npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus)

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top