How to add a new vocation

Tutorial explaining how to add a new vocation in Canary Server. After add the new vocation, the server need to be compiled to apply the changes.

1 - src/creatures/creatures_definitions.hpp and search for:

enum Vocation_t : uint16_t {
	VOCATION_NONE = 0,
	VOCATION_SORCERER = 1,
	VOCATION_DRUID = 2,
	VOCATION_PALADIN = 3,
	VOCATION_KNIGHT = 4,
	VOCATION_MASTER_SORCERER = 5,
	VOCATION_ELDER_DRUID = 6,
	VOCATION_ROYAL_PALADIN = 7,
	VOCATION_ELITE_KNIGHT = 8,
	VOCATION_LAST = VOCATION_ELITE_KNIGHT
};
  • Add your new vocation, in the example was used Warrior And Elite Warrior vocations;

  • Being the last vocation you add it to the VOCATION_LAST.

  • It will look like this:

enum Vocation_t : uint16_t {
    VOCATION_NONE = 0,
    VOCATION_SORCERER = 1,
    VOCATION_DRUID = 2,
    VOCATION_PALADIN = 3,
    VOCATION_KNIGHT = 4,
    VOCATION_MASTER_SORCERER = 5,
    VOCATION_ELDER_DRUID = 6,
    VOCATION_ROYAL_PALADIN = 7,
    VOCATION_ELITE_KNIGHT = 8,
    VOCATION_WARRIOR = 9,
    VOCATION_ELITE_WARRIOR = 10,
    VOCATION_LAST = VOCATION_ELITE_WARRIOR
};

2 - data/libs/vocation.lua:

  • Add your new vocation following the example below:

  • In ClientID is 0, it will show in the client Vocation: None (but it will be a Warrior or a Elite Warrior). This will appear only at the time of log in and showing the characters, once in the game it will show that the vocation is a Warrior or a Elite Warrior.

VOCATION = {
    ID = {
        NONE = 0,
        SORCERER = 1,
        DRUID = 2,
        PALADIN = 3,
        KNIGHT = 4,
        MASTER_SORCERER = 5,
        ELDER_DRUID = 6,
        ROYAL_PALADIN = 7,
        ELITE_KNIGHT = 8,
        WARRIOR = 9,
        ELITE_WARRIOR = 10
    },
    CLIENT_ID = {
        NONE = 0,
        KNIGHT = 1,
        PALADIN = 2,
        SORCERER = 3,
        DRUID = 4,
        ELITE_KNIGHT = 11,
        ROYAL_PALADIN = 12,
        MASTER_SORCERER = 13,
        ELDER_DRUID = 14,
        WARRIOR = 0,
        ELITE_WARRIOR = 0
    },
    BASE_ID = {
        NONE = 0,
        SORCERER = 1,
        DRUID = 2,
        PALADIN = 3,
        KNIGHT = 4,
        WARRIOR = 5,
        ELITE_WARRIOR = 6
    }
}

3 - data/libs/functions/player.lua and search for:

function Player.isSorcerer(self)
	return table.contains({VOCATION.ID.SORCERER, VOCATION.ID.MASTER_SORCERER}, self:getVocation():getId())
end

function Player.isDruid(self)
	return table.contains({VOCATION.ID.DRUID, VOCATION.ID.ELDER_DRUID}, self:getVocation():getId())
end

function Player.isKnight(self)
	return table.contains({VOCATION.ID.KNIGHT, VOCATION.ID.ELITE_KNIGHT}, self:getVocation():getId())
end

function Player.isPaladin(self)
	return table.contains({VOCATION.ID.PALADIN, VOCATION.ID.ROYAL_PALADIN}, self:getVocation():getId())
end

function Player.isMage(self)
	return table.contains({VOCATION.ID.SORCERER, VOCATION.ID.MASTER_SORCERER, VOCATION.ID.DRUID, VOCATION.ID.ELDER_DRUID},
		self:getVocation():getId())
end
  • Below the vocations functions add the function for the new vocation:

function Player.isWarrior(self)
    return table.contains({VOCATION.ID.WARRIOR, VOCATION.ID.ELITE_WARRIOR}, self:getVocation():getId())
end

4 - data/XML/vocations.xml:

  • Add the new vocation like the example below:

<vocation id="9" clientid="0" baseid="5" name="Warrior" description="a warrior" magicshield="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="4000" gainhpamount="1" gainmanaticks="6000" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" basespeed="110" soulmax="200" gainsoulticks="15000" fromvoc="4">
		<formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
		<skill id="0" multiplier="1.1" />
		<skill id="1" multiplier="1.1" />
		<skill id="2" multiplier="1.1" />
		<skill id="3" multiplier="1.1" />
		<skill id="4" multiplier="1.4" />
		<skill id="5" multiplier="1.1" />
		<skill id="6" multiplier="1.1" />
</vocation>
<vocation id="10" clientid="0" baseid="6" name="Elite Warrior" description="a elite warrior" magicshield="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="4000" gainhpamount="1" gainmanaticks="6000" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" basespeed="110" soulmax="200" gainsoulticks="15000" fromvoc="4">
		<formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
		<skill id="0" multiplier="1.1" />
		<skill id="1" multiplier="1.1" />
		<skill id="2" multiplier="1.1" />
		<skill id="3" multiplier="1.1" />
		<skill id="4" multiplier="1.4" />
		<skill id="5" multiplier="1.1" />
		<skill id="6" multiplier="1.1" />
</vocation>

5 - Credits:

  • Majesty