Go Back   EQEmulator Home > EQEmulator Forums > Development > Development: Custom Code

Development: Custom Code This is for code thatdoes not emulate live and wont be added to the official code.

Reply
 
Thread Tools Display Modes
  #1  
Old 04-15-2012, 12:00 PM
chrsschb's Avatar
chrsschb
Dragon
 
Join Date: Nov 2008
Location: GA
Posts: 904
Default

By sharing it you allow more experienced coders to fine tune it.
Reply With Quote
  #2  
Old 04-15-2012, 12:08 PM
provocating's Avatar
provocating
Demi-God
 
Join Date: Nov 2007
Posts: 2,175
Default

This was one of them in East Commons.

Code:
#Battlestaff Fuzzietoe 22210
INSERT INTO `npc_types` (id, name, lastname, level, race, class, bodytype, hp, mana, gender, texture, helmtexture, size, hp_regen_rate, mana_regen_rate, loottable_id, merchant_id, alt_currency_id, npc_spells_id, npc_faction_id, adventure_template_id, trap_template, mindmg, maxdmg, attack_count, npcspecialattks, aggroradius, face, luclin_hairstyle, luclin_haircolor, luclin_eyecolor, luclin_eyecolor2, luclin_beardcolor, luclin_beard, drakkin_heritage, drakkin_tattoo, drakkin_details, armortint_id, armortint_red, armortint_green, armortint_blue, d_meele_texture1, d_meele_texture2, prim_melee_type, sec_melee_type, runspeed, MR, CR, DR, FR, PR, Corrup, see_invis, see_invis_undead, qglobal, AC, npc_aggro, spawn_limit, attack_speed, findable, STR, STA, DEX, AGI, _INT, WIS, CHA, see_hide, see_improved_hide, trackable, isbot, exclude, ATK, Accuracy, slow_mitigation, version, maxlevel, scalerate, private_corpse, unique_spawn_by_name, underwater) VALUES ('22210', 'Battlestaff_Fuzzietoe', '', '65', '11', '41', '1', '4476', '0', '0', '2', '0', '5', '0', '0', '0', '346724', '0', '0', '0', '0', '0', '54', '110', '-1', '', '70', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '28', '28', '1.25', '9', '9', '9', '9', '9', '9', '0', '0', '0', '614', '0', '0', '-7.37742', '0', '137', '137', '137', '137', '137', '137', '137', '0', '0', '1', '0', '1', '0', '0', '0', '0', '0', '100', '0', '0', '0');
INSERT INTO `spawngroup` (`id`, `name`, `spawn_limit`, `dist`, `max_x`, `min_x`, `max_y`, `min_y`, `delay`) VALUES (200005, 'ecommons_200005', 0, 0, 0, 0, 0, 0, 0);
INSERT INTO `spawn2` (`id`, `spawngroupID`, `zone`, `version`, `x`, `y`, `z`, `heading`, `respawntime`, `variance`, `pathgrid`, `_condition`, `cond_value`, `enabled`, `animation`) VALUES (300005, 200005, 'ecommons', 0, 888.600000, -1056.700000, -3.2, 233.8, 1200, 0, 0, 0, 1, 1, 0);
INSERT INTO `spawnentry` (`spawngroupID`, `npcID`, `chance`) VALUES (200005, 22210, 100);
INSERT INTO `merchantlist` (`merchantid`, `slot`, `item`, `faction_required`, `level_required`, `alt_currency_cost`) VALUES (346724, 1, 13006, -100, 0, 0);
Battlestaff_Fuzzietoe.pl

Code:
#!/usr/bin/perl -w 
use DBI;

$db_login='eqemu';
$db_password='pass';
$db_host='127.0.0.1';
$db_database='peq';

# 1 warrior, 2 cleric, 4 paladin, 8 ranger, 16 sk, 32, druid, 64 monk, 128 bard, 256, rogue,
# 512 shaman, 1024 necro, 2048 wiz, 4096 mage, 8192 enchant, 16384 beast, 32768 beserk
$target_class=0;

$min_vendor_count=20;
$max_vendor_count=100;

@random_result_set=();

$size=0;
$announce_time=600; #Random announce time offset.
$reload_items_time=14400; #Random reload time offset. (3600=one hour, 14400=four hours, 86400=one day)
$initial_stock_delay=12; #NPC is not always up on slow loading zones.

$dbh=DBI->connect('DBI:mysql:' . $db_database . ';host=' . $db_host, $db_login, $db_password
	           ) || die "Could not connect to database: $DBI::errstr";

$sth = $dbh->prepare('SELECT id FROM items WHERE nodrop=1 and norent=1 and questitemflag=0 and stacksize=1 AND price>0 AND classes > ' . $target_class );
$sth->execute();
while (@row=$sth->fetchrow_array){
		push (@random_result_set, $row[0]);
	}
$size=@random_result_set;
$vendor_item_count=$min_vendor_count+int(rand($max_vendor_count-$min_vendor_count));

sub EVENT_SPAWN
{
	quest::settimer("initial_stock", $initial_stock_delay); 
	quest::settimer("reload_items", int(rand($reload_items_time)+3600)); #Timer for item inventory reload.
	quest::settimer("announce", int(rand($announce_time)+240)); #Random announcements.
}

sub EVENT_TIMER
{
	if($timer eq "initial_stock")
		{
		LOAD_VENDOR();
		quest::stoptimer("initial_stock"); 	
		}

	if($timer eq "reload_items")
		{
		LOAD_VENDOR();	
		}
		
	if($timer eq "announce")
		{
			if(@random_result_set>0)
			{
				$rand=int(rand(6));
				     if ($rand==0) {quest::shout(sprintf("%s%s%s%s%s%s%s","New vendor up in the east commons tunnel check these items for sale (" . ANNOUNCE(int(rand($vendor_item_count)+1)) . ", " . ANNOUNCE(int(rand($vendor_item_count)+1)) . ", " . ANNOUNCE(int(rand($vendor_item_count)+1))));}
				elsif ($rand==1) {quest::shout(sprintf("%s%s%s%s%s%s%s","Check out my wares just inside the east commons tunnel (" . ANNOUNCE(int(rand($vendor_item_count)+1)) . ", " . ANNOUNCE(int(rand($vendor_item_count)+1)) . ", " . ANNOUNCE(int(rand($vendor_item_count)+1))));}
				elsif ($rand==2) {quest::shout(sprintf("%s%s%s%s%s%s%s","Lowest prices in Norath !!!  Check out my " . ANNOUNCE(int(rand($vendor_item_count)+1)) . ", " . ANNOUNCE(int(rand($vendor_item_count)+1)) . ", " . ANNOUNCE(int(rand($vendor_item_count)+1))));}
				elsif ($rand==3) {quest::shout(sprintf("%s%s%s%s%s%s%s","WTS  " . ANNOUNCE(int(rand($vendor_item_count)+1)) . " and " . ANNOUNCE(int(rand($vendor_item_count)+1)) . " and " . ANNOUNCE(int(rand($vendor_item_count)+1))));}
				elsif ($rand==4) {quest::shout(sprintf("%s%s","Selling  " . ANNOUNCE(int(rand($vendor_item_count)+1))));}
				elsif ($rand==5) {quest::shout(sprintf("%s%s","Come visit Battlestaff Fuzzietoe at the entrance to the East Commons tunnel, great prices on items like this " . ANNOUNCE(int(rand($vendor_item_count)+1))));}
			}
			$npc->SetAppearance(int(rand(2)));
		}
		
	if($timer eq "initial_load_vendor")
		{
		#quest::shout('end load');
		LOAD_VENDOR();	
		#quest::shout('end load2');
		quest::stoptimer("initial_load_vendor"); 
		}	
}
 
sub ANNOUNCE
{
	sprintf("%c%06X%s%s%c",0x12,$random_result_set[$_[0]],"00000000000000000000000000000000000000000000",quest::itemname($random_result_set[$_[0]]),0x12);
}
 
 sub LOAD_VENDOR
 {
	quest::merchantclear($npc->GetNPCTypeID());
	
	fisher_yates_shuffle( \@random_result_set);
	
	#Iterate through current items, add them.
	for ($i=0; $i<=$vendor_item_count; $i++) 
		{ 
			#quest::emote("Adding item " . $random_result_set[$i]);
			quest::MerchantSetItem($npc->GetNPCTypeID(), $random_result_set[$i], 1);
		} 
 }
 
 sub fisher_yates_shuffle
{
    my $array=shift;
    my $i=@$array;
    while ( --$i )
    {
        my $j = int rand( $i+1 );
        @$array[$i,$j]=@$array[$j,$i];
    }
}

$dbh ->disconnect();
Reply With Quote
Reply

Thread Tools
Display Modes

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 09:22 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