Drajor
11-10-2012, 12:49 AM
Hello all. This plugin is mostly for improving code readability and reducing the chances of human error when typing class names.
### Drajor from Drajorian Guard - DrajorEQ@gmail.com
### Dependencies: the val() method is used from globals.pl
### This plugin contains some simple methods for dealing with class types.
### A special thanks to Akkadius for advice!:)
# defined in classes.h
use constant {
WARRIOR => 1,
CLERIC => 2,
PALADIN => 3,
RANGER => 4,
SHADOWKNIGHT => 5,
DRUID => 6,
MONK => 7,
BARD => 8,
ROGUE => 9,
SHAMAN => 10,
NECROMANCER => 11,
WIZARD => 12,
MAGICIAN => 13,
ENCHANTER => 14,
BEASTLORD => 15,
BERSERKER => 16
};
%CLASSES = (
"Warrior", WARRIOR,
"Cleric", CLERIC,
"Paladin", PALADIN,
"Ranger", RANGER,
"Shadowknight", SHADOWKNIGHT,
"Druid", DRUID,
"Monk", MONK,
"Bard", BARD,
"Rogue", ROGUE,
"Shaman", SHAMAN,
"Necromancer", NECROMANCER,
"Wizard", WIZARD,
"Magician", MAGICIAN,
"Enchanter", ENCHANTER,
"Beastlord", BEASTLORD,
"Berserker", BERSERKER
);
# Returns the numerical class ID for the character.
sub getClassID {
return $CLASSES{plugin::val('$class')};
}
# Check if the character is a specific class.
sub isWarrior { return ( plugin::getClassID() == WARRIOR ); }
sub isCleric { return ( plugin::getClassID() == CLERIC ); }
sub isPaladin { return ( plugin::getClassID() == PALADIN ); }
sub isRanger { return ( plugin::getClassID() == RANGER ); }
sub isShadowknight { return ( plugin::getClassID() == SHADOWKNIGHT ); }
sub isDruid { return ( plugin::getClassID() == WARRIOR ); }
sub isMonk { return ( plugin::getClassID() == MONK ); }
sub isBard { return ( plugin::getClassID() == BARD ); }
sub isRogue { return ( plugin::getClassID() == ROGUE ); }
sub isShaman { return ( plugin::getClassID() == SHAMAN ); }
sub isNecromancer { return ( plugin::getClassID() == NECROMANCER ); }
sub isWizard { return ( plugin::getClassID() == WIZARD ); }
sub isMagician { return ( plugin::getClassID() == MAGICIAN ); }
sub isEnchanter { return ( plugin::getClassID() == ENCHANTER ); }
sub isBeastlord { return ( plugin::getClassID() == BEASTLORD ); }
sub isBerserker { return ( plugin::getClassID() == BERSERKER ); }
# Check if the character is a plate wearing class.
sub isPlateClass {
$myclass = plugin::getClassID();
return (
$myclass == WARRIOR or
$myclass == CLERIC or
$myclass == PALADIN or
$myclass == SHADOWKNIGHT or
$myclass == BARD
) ? 1 : 0;
}
# Check if the character is a chain wearing class.
sub isChainClass {
$myclass = plugin::getClassID();
return (
$myclass == RANGER or
$myclass == ROGUE or
$myclass == SHAMAN or
$myclass == BERSERKER
) ? 1 : 0;
}
# Check if the character is a leather wearing class.
sub isLeatherClass {
$myclass = plugin::getClassID();
return (
$myclass == DRUID or
$myclass == MONK or
$myclass == BEASTLORD
) ? 1 : 0;
}
# Check if the character is a cloth wearing class.
sub isClothClass {
$myclass = plugin::getClassID();
return (
$myclass == NECROMANCER or
$myclass == WIZARD or
$myclass == MAGICIAN or
$myclass == ENCHANTER
) ? 1 : 0;
}
# Check if the character is a spell caster.
sub isSpellCaster {
$myclass = plugin::getClassID();
return (
$myclass != WARRIOR and
$myclass != ROGUE and
$myclass != BERSERKER
) ? 1 : 0;
}
# Check if the character is pure melee.
sub isMelee {
return !plugin::isSpellCaster();
}
### Drajor from Drajorian Guard - DrajorEQ@gmail.com
### Dependencies: the val() method is used from globals.pl
### This plugin contains some simple methods for dealing with class types.
### A special thanks to Akkadius for advice!:)
# defined in classes.h
use constant {
WARRIOR => 1,
CLERIC => 2,
PALADIN => 3,
RANGER => 4,
SHADOWKNIGHT => 5,
DRUID => 6,
MONK => 7,
BARD => 8,
ROGUE => 9,
SHAMAN => 10,
NECROMANCER => 11,
WIZARD => 12,
MAGICIAN => 13,
ENCHANTER => 14,
BEASTLORD => 15,
BERSERKER => 16
};
%CLASSES = (
"Warrior", WARRIOR,
"Cleric", CLERIC,
"Paladin", PALADIN,
"Ranger", RANGER,
"Shadowknight", SHADOWKNIGHT,
"Druid", DRUID,
"Monk", MONK,
"Bard", BARD,
"Rogue", ROGUE,
"Shaman", SHAMAN,
"Necromancer", NECROMANCER,
"Wizard", WIZARD,
"Magician", MAGICIAN,
"Enchanter", ENCHANTER,
"Beastlord", BEASTLORD,
"Berserker", BERSERKER
);
# Returns the numerical class ID for the character.
sub getClassID {
return $CLASSES{plugin::val('$class')};
}
# Check if the character is a specific class.
sub isWarrior { return ( plugin::getClassID() == WARRIOR ); }
sub isCleric { return ( plugin::getClassID() == CLERIC ); }
sub isPaladin { return ( plugin::getClassID() == PALADIN ); }
sub isRanger { return ( plugin::getClassID() == RANGER ); }
sub isShadowknight { return ( plugin::getClassID() == SHADOWKNIGHT ); }
sub isDruid { return ( plugin::getClassID() == WARRIOR ); }
sub isMonk { return ( plugin::getClassID() == MONK ); }
sub isBard { return ( plugin::getClassID() == BARD ); }
sub isRogue { return ( plugin::getClassID() == ROGUE ); }
sub isShaman { return ( plugin::getClassID() == SHAMAN ); }
sub isNecromancer { return ( plugin::getClassID() == NECROMANCER ); }
sub isWizard { return ( plugin::getClassID() == WIZARD ); }
sub isMagician { return ( plugin::getClassID() == MAGICIAN ); }
sub isEnchanter { return ( plugin::getClassID() == ENCHANTER ); }
sub isBeastlord { return ( plugin::getClassID() == BEASTLORD ); }
sub isBerserker { return ( plugin::getClassID() == BERSERKER ); }
# Check if the character is a plate wearing class.
sub isPlateClass {
$myclass = plugin::getClassID();
return (
$myclass == WARRIOR or
$myclass == CLERIC or
$myclass == PALADIN or
$myclass == SHADOWKNIGHT or
$myclass == BARD
) ? 1 : 0;
}
# Check if the character is a chain wearing class.
sub isChainClass {
$myclass = plugin::getClassID();
return (
$myclass == RANGER or
$myclass == ROGUE or
$myclass == SHAMAN or
$myclass == BERSERKER
) ? 1 : 0;
}
# Check if the character is a leather wearing class.
sub isLeatherClass {
$myclass = plugin::getClassID();
return (
$myclass == DRUID or
$myclass == MONK or
$myclass == BEASTLORD
) ? 1 : 0;
}
# Check if the character is a cloth wearing class.
sub isClothClass {
$myclass = plugin::getClassID();
return (
$myclass == NECROMANCER or
$myclass == WIZARD or
$myclass == MAGICIAN or
$myclass == ENCHANTER
) ? 1 : 0;
}
# Check if the character is a spell caster.
sub isSpellCaster {
$myclass = plugin::getClassID();
return (
$myclass != WARRIOR and
$myclass != ROGUE and
$myclass != BERSERKER
) ? 1 : 0;
}
# Check if the character is pure melee.
sub isMelee {
return !plugin::isSpellCaster();
}