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

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

Reply
 
Thread Tools Display Modes
  #1  
Old 05-11-2011, 02:32 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default Random Features and Clone Mob Plugins

These 2 plugins are fun and handy. The CloneAppearance plugin is nice for events or special item scripts and such. The RandomFeatures plugin is good for adding variety to player race NPCs as needed.

Here are the steps to add these plugins to your server:

1. Open notepad, or whatever text editor you prefer.

2. Copy and paste the following code into Notepad:

Code:
#Usage: plugin::RandomFeatures(Mob);
# Chooses a random set of facial features for playable races (NPCs or Players)

sub RandomFeatures {

	my $Mob = $_[0];

	if ($Mob)
	{
		$MobRace = $Mob->GetRace();
		
		if ($MobRace <= 12 || $MobRace == 128 || $MobRace == 130 || $MobRace == 330 || $MobRace == 522)
		{
			
			$Gender = $Mob->GetGender();
			$Texture = 0xFF;
			$HelmTexture = 0xFF;
			$HairColor = 0xFF;
			$BeardColor = 0xFF;
			$EyeColor1 = 0xFF;
			$EyeColor2 = 0xFF;
			$HairStyle = 0xFF;
			$LuclinFace = 0xFF;
			$Beard = 0xFF;
			$DrakkinHeritage = 0xFFFFFFFF;
			$DrakkinTattoo = 0xFFFFFFFF;
			$DrakkinDetails = 0xFFFFFFFF;
			
			# Set some common feature settings
			$EyeColor1 = plugin::RandomRange(0, 9);
			$EyeColor2 = plugin::RandomRange(0, 9);
			$LuclinFace = plugin::RandomRange(0, 7);
			
			# Adjust all settings based on the min and max for each feature of each $MobRace and $Gender
			#plugin::Debug("About to switch case");
			use Switch;

			switch ($MobRace)
			{
				case (1)
				{
					# Human
					$HairColor = plugin::RandomRange(0, 19);
					if ($Gender == 0) {
						$BeardColor = $HairColor;
						$HairStyle = plugin::RandomRange(0, 3);
						$Beard = plugin::RandomRange(0, 5);
					}
					if ($Gender == 1) {
						$HairStyle = plugin::RandomRange(0, 2);
					}
				}
				case (2)
				{
					# Barbarian
					$HairColor = plugin::RandomRange(0, 19);
					$LuclinFace = plugin::RandomRange(0, 87);
					if ($Gender == 0) { #
						$BeardColor = $HairColor;
						$HairStyle = plugin::RandomRange(0, 3);
						$Beard = plugin::RandomRange(0, 5);
					}
					if ($Gender == 1) { #
						$HairStyle = plugin::RandomRange(0, 2);
					}
				}
				case (3) 
				{
					# Erudite
					if ($Gender == 0) { #
						$BeardColor = plugin::RandomRange(0, 19);
						$Beard = plugin::RandomRange(0, 5);
						$LuclinFace = plugin::RandomRange(0, 57);
					}
					if ($Gender == 1) { #
						$LuclinFace = plugin::RandomRange(0, 87);
					}
				}
				case (4) 
				{
					# WoodElf
					$HairColor = plugin::RandomRange(0, 19);
					if ($Gender == 0) { #
						$HairStyle = plugin::RandomRange(0, 3);
					}
					if ($Gender == 1) { #
						$HairStyle = plugin::RandomRange(0, 2);
					}
				}
				case (5) 
				{
					# HighElf
					$HairColor = plugin::RandomRange(0, 14);
					if ($Gender == 0) { #
						$HairStyle = plugin::RandomRange(0, 3);
						$LuclinFace = plugin::RandomRange(0, 37);
						$BeardColor = $HairColor;
					}
					if ($Gender == 1) { #
						$HairStyle = plugin::RandomRange(0, 2);
					}
				}
				case (6) 
				{
					# DarkElf
					$HairColor = plugin::RandomRange(13, 18);
					if ($Gender == 0) { #
						$HairStyle = plugin::RandomRange(0, 3);
						$LuclinFace = plugin::RandomRange(0, 37);
						$BeardColor = $HairColor;
					}
					if ($Gender == 1) { #
						$HairStyle = plugin::RandomRange(0, 2);
					}
				}
				case (7) 
				{
					# HalfElf
					$HairColor = plugin::RandomRange(0, 19);
					if ($Gender == 0) { #
						$HairStyle = plugin::RandomRange(0, 3);
						$LuclinFace = plugin::RandomRange(0, 37);
						$BeardColor = $HairColor;
					}
					if ($Gender == 1) { #
						$HairStyle = plugin::RandomRange(0, 2);
					}
				}
				case (8) 
				{
					# Dwarf
					$HairColor = plugin::RandomRange(0, 19);
					$BeardColor = $HairColor;
					if ($Gender == 0) { #
						$HairStyle = plugin::RandomRange(0, 3);
						$Beard = plugin::RandomRange(0, 5);
					}
					if ($Gender == 1) { #
						$HairStyle = plugin::RandomRange(0, 2);
						$LuclinFace = plugin::RandomRange(0, 17);
					}
				}
				case (9) 
				{
					# Troll
					$EyeColor1 = plugin::RandomRange(0, 10);
					$EyeColor2 = plugin::RandomRange(0, 10);
					if ($Gender == 1) { #
						$HairStyle = plugin::RandomRange(0, 3);
						$HairColor = plugin::RandomRange(0, 23);
					}
				}
				case (10) 
				{
					# Ogre
					if ($Gender == 1) { #
						$HairStyle = plugin::RandomRange(0, 3);
						$HairColor = plugin::RandomRange(0, 23);
					}
				}
				case (11) 
				{
					# Halfling
					$HairColor = plugin::RandomRange(0, 19);
					if ($Gender == 0) { #
						$BeardColor = $HairColor;
						$HairStyle = plugin::RandomRange(0, 3);
						$Beard = plugin::RandomRange(0, 5);
					}
					if ($Gender == 1) { #
						$HairStyle = plugin::RandomRange(0, 2);
					}
				}
				case (12) 
				{
					# Gnome
					$HairColor = plugin::RandomRange(0, 24);
					if ($Gender == 0) { #
						$BeardColor = $HairColor;
						$HairStyle = plugin::RandomRange(0, 3);
						$Beard = plugin::RandomRange(0, 5);
					}
					if ($Gender == 1) { #
						$HairStyle = plugin::RandomRange(0, 2);
					}
				}
				case (128) 
				{
					# Iksar
					$LuclinFace = plugin::RandomRange(0, 9);
				}
				case (130) 
				{
					# VahShir
					$LuclinFace = plugin::RandomRange(0, 9);
				}
				case (330) 
				{
					# Froglok
					$LuclinFace = plugin::RandomRange(0, 9);
				}
				case (522) 
				{
					# Drakkin
					$HairColor = plugin::RandomRange(0, 3);
					$BeardColor = $HairColor;
					$EyeColor1 = plugin::RandomRange(0, 11);
					$EyeColor2 = plugin::RandomRange(0, 11);
					$LuclinFace = plugin::RandomRange(0, 6);
					$DrakkinHeritage = plugin::RandomRange(0, 6);
					$DrakkinTattoo = plugin::RandomRange(0, 7);
					$DrakkinDetails = plugin::RandomRange(0, 7);
					if ($Gender == 0) { #
						$Beard = plugin::RandomRange(0, 12);
						$HairStyle = plugin::RandomRange(0, 8);
					}
					if ($Gender == 1) { #
						$Beard = plugin::RandomRange(0, 3);
						$HairStyle = plugin::RandomRange(0, 7);
					}
				}

			}
			#plugin::Debug("About to SendIllusion");
			$Mob->SendIllusion($MobRace,$Gender,$Texture,$HelmTexture,$LuclinFace,$HairStyle,$HairColor,$Beard,$BeardColor,$DrakkinHeritage,$DrakkinTattoo,$DrakkinDetails); # ,$size
		}
	}

}


#Usage: plugin::CloneAppearance(MobA, MobB, CloneName=false);
# Clones the looks of a mob
# MobA is the target mob to clone from
# MonB is the mob that is changing to clone MobA
# CloneName is an optional field that if set to 1 will clone the name of the target as well

sub CloneAppearance {
	my $MobA = $_[0];
	my $MobB = $_[1];
	my $CloneName = $_[2];
	
	my $Race = $MobA->GetRace();
	my $Gender = $MobA->GetGender();
	my $Texture = $MobA->GetTexture();
	my $HelmTexture = $MobA->GetHelmTexture();
	my $Face = $MobA->GetLuclinFace();
	my $HairStyle = $MobA->GetHairStyle();
	my $HairColor = $MobA->GetHairColor();
	my $Beard = $MobA->GetBeard();
	my $BeardColor = $MobA->GetBeardColor();
	my $DrakkinHeritage = $MobA->GetDrakkinHeritage();
	my $DrakkinTattoo = $MobA->GetDrakkinTattoo();
	my $DrakkinDetails = $MobA->GetDrakkinDetails();
	my $Size = $MobA->GetSize();
	
	if (!$Size)
	{
		%RaceSizes = (
			1 => 6, # Human
			2 => 8, # Barbarian
			3 => 6, # Erudite
			4 => 5, # Wood Elf
			5 => 5, # High Elf
			6 => 5, # Dark Elf
			7 => 5, # Half Elf
			8 => 4, # Dwarf
			9 => 9, # Troll
			10 => 9, # Ogre
			11 => 3, # Halfling
			12 => 3, # Gnome
			128 => 6, # Iksar
			130 => 6, # Vah Shir
			330 => 5, # Froglok
			522 => 6, # Drakkin
		);
		
		$Size = $RaceSizes{$Race};
	}
	
	if (!$Size)
	{
		$Size = 6;
	}

	if ($Size > 15)
	{
		$Size = 15;
	}
	
	$MobB->SendIllusion($Race, $Gender, $Texture, $HelmTexture, $Face, $HairStyle, $HairColor, $Beard, $BeardColor, $DrakkinHeritage, $DrakkinTattoo, $DrakkinDetails, $Size);
	
	for ($slot = 0; $slot < 7; $slot++)
	{
		my $Color = 0;
		my $Material = 0;
		if ($MobA->IsClient() || $slot > 6)
		{
			$Color = $MobA->GetEquipmentColor($slot);
			$Material = $MobA->GetEquipmentMaterial($slot);
		}
		else
		{
			$Color = $MobA->GetArmorTint($slot);
			if ($slot == 0)
			{
				$Material = $MobA->GetHelmTexture();
			}
			else
			{
				$Material = $MobA->GetTexture();
			}
		}
		$MobB->WearChange($slot, $Material, $Color);
	}
	
	$PrimaryModel = $MobA->GetEquipmentMaterial(7);
	$SecondaryModel = $MobA->GetEquipmentMaterial(8);
	
	# NPCs can set animations and attack messages, but clients only set the model change
	if ($MobB->IsNPC())
	{
		plugin::SetWeapons($PrimaryModel, $SecondaryModel, 1);
	}
	else
	{
		$MobB->WearChange(7, $PrimaryModel, 0);
		$MobB->WearChange(8, $SecondaryModel, 0);
	}
	
	if ($CloneName)
	{
		my $CloneName = $MobA->GetCleanName();
		$MobB->TempName($CloneName);
	}
	
	
}

return 1; # Plugins may or may not require this return line.
3. Save that file to your server /plugins/ folder and name it "illusion_tools.pl".

4. Do a #questreload and the new plugin should be ready for use
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #2  
Old 05-11-2011, 06:37 PM
ChaosSlayerZ's Avatar
ChaosSlayerZ
Demi-God
 
Join Date: Mar 2009
Location: Umm
Posts: 1,492
Default

how do i actually run plugin on a mob?
just put
plugin::RandomFeatures(Mob);

into mob script when it spawns?

is (Mob) - suppose to be a variable?
Reply With Quote
  #3  
Old 05-11-2011, 11:52 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

For example:

Code:
plugin::RandomFeatures($npc);
or

Code:
plugin::RandomFeatures($client);
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #4  
Old 05-12-2011, 08:21 PM
ChaosSlayerZ's Avatar
ChaosSlayerZ
Demi-God
 
Join Date: Mar 2009
Location: Umm
Posts: 1,492
Default

can I use npc id or npctype for $npc?

or does it have to pulled in some >$npc form of specific npc?
Reply With Quote
  #5  
Old 05-13-2011, 03:38 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

It has to be a specific NPC, but you can use entity list searches to find any NPC by entity ID or NPC Type ID and then get that NPC and use the plugin on it.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #6  
Old 05-13-2011, 12:01 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default

Trevius,

This has been added to the repository.

Thanks,
~Akka
Reply With Quote
  #7  
Old 12-08-2011, 06:40 AM
pepsiphreak79
Sarnak
 
Join Date: Sep 2011
Posts: 70
Default

Can this be used by making a .pl for the mod and inserting
Sub EVENT_SPAWN {
plugin::RandomFeatures($npc);
}

will that change them on spawn?
or do i need to include a code to get the $npc variable for each specific mob?
__________________
--Any Code by me is considered open source Beta--
Not a DEV not a Coder
Just a person....
Reply With Quote
  #8  
Old 12-09-2011, 03:36 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Yes, that is how you use it. The only problem with your solution is that many things don't update properly in EVENT_SPAWN, due to it being handled at the same time the NPC is actually being sent to the client. So, to make it work properly 100% of the time, you can just start a timer from event spawn and set it to something like 1 second. Then, the NPC will spawn and a second later it will change its features randomly. Don't forget to stop the timer in the EVENT_TIMER or you will be changing the random features every second.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
Reply


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 06:38 PM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3