Thread: Armor Crates
View Single Post
  #1  
Old 11-29-2017, 11:57 PM
Splose
Banned
 
Join Date: Apr 2014
Posts: 279
Default Armor Crates

Hey all.

For my custom "tutorial" zone I was wanting a way to make sure players got a full set of starter gear without having to farm for specific pieces due to them not dropping the first time around. I've made a solution that can be applicable to a ton of other situations and I thought it would be useful to other server developers.

Instead of having gear drop that may or may not suit the player's class, you can have these "loot crates" drop that will award the player a piece of gear suitable to their class every time. Well worth the extra work in my opinion.

Here's how:

I have a set of gear using a modified version of kingly krab's set generation scripts found here.

I copied the blank armor set "Glowing Othni" from live and added a BLANK spell to it, mainly for the description, but also very important that the item is listed as itemtype "21". This is so the item is consumed upon use of its 1 charge.



Please ignore the current description as I'm lazy and just copied an existing spell I was using for AA tokens.

On each piece of this new glowing othni set I set the script file ID to 1, as that is the name of the script I'm currently using. Note: The check at the bottom is because all set pieces awarded through this script are Lore items.

quests/global/items/script_1.pl
Code:
sub EVENT_ITEM_CLICK {

	#::		Dragonscale Set	#########################################
	if($itemid == 135056) {	#:: Chest
		my %ArmorList = (
		"Warrior" => 135015,
		"Cleric" => 135015,
		"Paladin" => 135015,
		"Ranger" => 135008,
		"Shadowknight" => 135015,
		"Druid" => 135022,
		"Monk" => 135029,
		"Bard" => 135015,
		"Rogue" => 135008,
		"Shaman" => 135008,
		"Necromancer" => 135001,
		"Wizard" => 135001,
		"Magician" => 135001,
		"Enchanter" => 135001,
		"Beastlord" => 135022,
		"Berserker" => 135008);
	
		$ItemToSummon = $ArmorList{$class};		
	}
	if($itemid == 135052) {	#:: Legs
		my %ArmorList = (
		"Warrior" => 135018,
		"Cleric" => 135018,
		"Paladin" => 135018,
		"Ranger" => 135011,
		"Shadowknight" => 135018,
		"Druid" => 135025,
		"Monk" => 135032,
		"Bard" => 135018,
		"Rogue" => 135011,
		"Shaman" => 135011,
		"Necromancer" => 135004,
		"Wizard" => 135004,
		"Magician" => 135004,
		"Enchanter" => 135004,
		"Beastlord" => 135025,
		"Berserker" => 135011);
	
		$ItemToSummon = $ArmorList{$class};		
	}
	if($itemid == 135050) {	#:: Feet
		my %ArmorList = (
		"Warrior" => 135019,
		"Cleric" => 135019,
		"Paladin" => 135019,
		"Ranger" => 135012,
		"Shadowknight" => 135019,
		"Druid" => 135026,
		"Monk" => 135033,
		"Bard" => 135019,
		"Rogue" => 135012,
		"Shaman" => 135012,
		"Necromancer" => 135005,
		"Wizard" => 135005,
		"Magician" => 135005,
		"Enchanter" => 135005,
		"Beastlord" => 135026,
		"Berserker" => 135012);
	
		$ItemToSummon = $ArmorList{$class};		
	}
	if($itemid == 135055) {	#:: Hands
		my %ArmorList = (
		"Warrior" => 135020,
		"Cleric" => 135020,
		"Paladin" => 135020,
		"Ranger" => 135013,
		"Shadowknight" => 135020,
		"Druid" => 135027,
		"Monk" => 135034,
		"Bard" => 135020,
		"Rogue" => 135013,
		"Shaman" => 135013,
		"Necromancer" => 135006,
		"Wizard" => 135006,
		"Magician" => 135006,
		"Enchanter" => 135006,
		"Beastlord" => 135027,
		"Berserker" => 135013);
	
		$ItemToSummon = $ArmorList{$class};		
	}
	#::		Dragonscale Set End #####################################
	
	$client->Message(15, "Armor DEBUG: " . $ItemToSummon . "");	
	
	if(plugin::check_hasitem($client,$ItemToSummon)) { 
		$client->Message(15, "ERROR: Claiming this item would result in a lore item.");
		$client->SummonItem($itemid, 1); 
	}
	else {
		$client->SummonItem($ItemToSummon, 1);
	}
}
Reply With Quote