Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Plugins & Mods

Quests::Plugins & Mods Completed plugins for public use as well as modifications.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-10-2012, 12:49 AM
Drajor's Avatar
Drajor
Developer
 
Join Date: Nov 2012
Location: Halas
Posts: 355
Default Class Utils

Hello all. This plugin is mostly for improving code readability and reducing the chances of human error when typing class names.

Code:
### 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();
}
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 10:31 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3